Skip to content

Commit 10dfc4d

Browse files
0xD34Dcodex-corp
authored andcommitted
HeadsUp: Only remove heads up if attached to window
Attempting to remove mHeadsUpNoficiationView from the window manager when it is not currently attached will throw an IllegalArgumentException so we check if it is attached and if so remove it, otherwise carry on. As well remove possible left children in statusbarview Change-Id: Ida916eba496c4183e47288ef24a8a93c46a7eddf Conflicts: packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
1 parent 790ec8d commit 10dfc4d

1 file changed

Lines changed: 17 additions & 11 deletions

File tree

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

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1594,6 +1594,10 @@ private WindowManager.LayoutParams getNavigationBarLayoutParams() {
15941594
}
15951595

15961596
private void addHeadsUpView() {
1597+
if (mHeadsUpNotificationView != null && mHeadsUpNotificationView.isAttachedToWindow()) {
1598+
return;
1599+
}
1600+
15971601
WindowManager.LayoutParams lp = new WindowManager.LayoutParams(
15981602
LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT,
15991603
WindowManager.LayoutParams.TYPE_STATUS_BAR_PANEL, // above the status bar!
@@ -1615,7 +1619,9 @@ private void addHeadsUpView() {
16151619
}
16161620

16171621
private void removeHeadsUpView() {
1618-
mWindowManager.removeView(mHeadsUpNotificationView);
1622+
if (mHeadsUpNotificationView != null && mHeadsUpNotificationView.isAttachedToWindow()) {
1623+
mWindowManager.removeView(mHeadsUpNotificationView);
1624+
}
16191625
}
16201626

16211627
public void refreshAllStatusBarIcons() {
@@ -3927,11 +3933,13 @@ private void resetUserSetupObserver() {
39273933

39283934
private void setHeadsUpVisibility(boolean vis) {
39293935
if (DEBUG) Log.v(TAG, (vis ? "showing" : "hiding") + " heads up window");
3930-
mHeadsUpNotificationView.setVisibility(vis ? View.VISIBLE : View.GONE);
3931-
if (!vis) {
3932-
if (DEBUG) Log.d(TAG, "setting heads up entry to null");
3933-
mInterruptingNotificationEntry = null;
3934-
mHeadsUpPackageName = null;
3936+
if (mHeadsUpNotificationView != null && mHeadsUpNotificationView.isAttachedToWindow()) {
3937+
mHeadsUpNotificationView.setVisibility(vis ? View.VISIBLE : View.GONE);
3938+
if (!vis) {
3939+
if (DEBUG) Log.d(TAG, "setting heads up entry to null");
3940+
mInterruptingNotificationEntry = null;
3941+
mHeadsUpPackageName = null;
3942+
}
39353943
}
39363944
}
39373945

@@ -3977,10 +3985,6 @@ private static void copyNotifications(ArrayList<Pair<IBinder, StatusBarNotificat
39773985

39783986
private void recreateStatusBar() {
39793987
mRecreating = true;
3980-
if (mHeadsUpNotificationView != null) {
3981-
removeHeadsUpView();
3982-
mHeadsUpNotificationView = null;
3983-
}
39843988

39853989
synchronized(mLock){
39863990
while (mTickerInProgress){
@@ -3991,9 +3995,11 @@ private void recreateStatusBar() {
39913995
}
39923996
}
39933997
}
3998+
3999+
removeHeadsUpView();
4000+
39944001
mStatusBarContainer.removeAllViews();
39954002
mStatusBarContainer.clearDisappearingChildren();
3996-
removeHeadsUpView();
39974003

39984004
// extract icons from the soon-to-be recreated viewgroup.
39994005
int nIcons = mStatusIcons.getChildCount();

0 commit comments

Comments
 (0)