Skip to content

Commit 6e8db88

Browse files
committed
Fix race condition in status bar init code.
There was a hole between the initial call to get the display metrics and the attachment of the status bar to its window, meaning there was an opportunity for the orientation to change without the status bar's orientation change handler being called. In this scenario the notification panel would be sized for the wrong orientation until the configuration changed again in some way. Bug: 5509445 Change-Id: Ib1bff79c317945a61ccfccddc073cce015f34caa
1 parent 6e03b22 commit 6e8db88

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ public void start() {
252252
mWindowManager = IWindowManager.Stub.asInterface(
253253
ServiceManager.getService(Context.WINDOW_SERVICE));
254254

255-
super.start();
255+
super.start(); // calls makeStatusBarView()
256256

257257
addNavigationBar();
258258

@@ -270,12 +270,7 @@ protected View makeStatusBarView() {
270270

271271
Resources res = context.getResources();
272272

273-
mDisplay.getMetrics(mDisplayMetrics);
274-
if (DEBUG) {
275-
Slog.d(TAG, "makeStatusBarView: mDisplayMetrics=" + mDisplayMetrics);
276-
mDisplayMetrics = res.getDisplayMetrics();
277-
Slog.d(TAG, "makeStatusBarView: mDisplayMetrics2=" + mDisplayMetrics);
278-
}
273+
updateDisplaySize(); // populates mDisplayMetrics
279274
loadDimens();
280275

281276
mIconSize = res.getDimensionPixelSize(com.android.internal.R.dimen.status_bar_icon_size);
@@ -1793,6 +1788,11 @@ public void run() {
17931788
}
17941789

17951790
void onBarViewAttached() {
1791+
// The status bar has just been attached to the view hierarchy; it's possible that the
1792+
// screen has rotated in-between when we set up the window and now, so let's double-check
1793+
// the display metrics just in case.
1794+
updateDisplaySize();
1795+
17961796
WindowManager.LayoutParams lp;
17971797
int pixelFormat;
17981798
Drawable bg;

0 commit comments

Comments
 (0)