Skip to content

Commit 6e7625c

Browse files
kufikugelcodex-corp
authored andcommitted
HeadsUp: Correctly add and remove the window
isAttachedToWindow() basically works to determine if the view was attached or not. But on the boot up process when already addHeadsUpView is called but the system is not fully up and a recreation happens (eg on TRDS...due that the UIModeManager is doing its work as soon as system is ready) the view gets attached....but not removed on the recreation due that at this time isAttachedToWindow() will return false even though the window was added. To solve simply use a boolean instead of isAttachedToWindow() Change-Id: Ib576a83cadc581683f2a5b0afc922c53b01888b7
1 parent 10dfc4d commit 6e7625c

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

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

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,7 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
329329
private HeadsUpNotificationView mHeadsUpNotificationView;
330330
private int mHeadsUpNotificationDecay;
331331
private boolean mHeadsUpExpandedByDefault;
332+
private boolean mHeadsUpNotificationViewAttached;
332333

333334
// on-screen navigation buttons
334335
private NavigationBarView mNavigationBarView = null;
@@ -1594,10 +1595,11 @@ private WindowManager.LayoutParams getNavigationBarLayoutParams() {
15941595
}
15951596

15961597
private void addHeadsUpView() {
1597-
if (mHeadsUpNotificationView != null && mHeadsUpNotificationView.isAttachedToWindow()) {
1598+
if (mHeadsUpNotificationViewAttached) {
15981599
return;
15991600
}
16001601

1602+
mHeadsUpNotificationViewAttached = true;
16011603
WindowManager.LayoutParams lp = new WindowManager.LayoutParams(
16021604
LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT,
16031605
WindowManager.LayoutParams.TYPE_STATUS_BAR_PANEL, // above the status bar!
@@ -1619,7 +1621,8 @@ private void addHeadsUpView() {
16191621
}
16201622

16211623
private void removeHeadsUpView() {
1622-
if (mHeadsUpNotificationView != null && mHeadsUpNotificationView.isAttachedToWindow()) {
1624+
if (mHeadsUpNotificationViewAttached) {
1625+
mHeadsUpNotificationViewAttached = false;
16231626
mWindowManager.removeView(mHeadsUpNotificationView);
16241627
}
16251628
}
@@ -3933,7 +3936,7 @@ private void resetUserSetupObserver() {
39333936

39343937
private void setHeadsUpVisibility(boolean vis) {
39353938
if (DEBUG) Log.v(TAG, (vis ? "showing" : "hiding") + " heads up window");
3936-
if (mHeadsUpNotificationView != null && mHeadsUpNotificationView.isAttachedToWindow()) {
3939+
if (mHeadsUpNotificationViewAttached) {
39373940
mHeadsUpNotificationView.setVisibility(vis ? View.VISIBLE : View.GONE);
39383941
if (!vis) {
39393942
if (DEBUG) Log.d(TAG, "setting heads up entry to null");

0 commit comments

Comments
 (0)