From ab847cf16dd42af71a6e4a444709c1ce1a227bc6 Mon Sep 17 00:00:00 2001 From: John Spurlock Date: Wed, 15 Jan 2014 14:13:59 -0500 Subject: [PATCH] Tear down bars on destroy() and avoid null pointers. Change-Id: Ie393689bbf2f0b28895bfde5098c883b5d4ea4a6 --- .../systemui/statusbar/phone/PhoneStatusBar.java | 14 ++++++++++---- .../statusbar/phone/PhoneStatusBarView.java | 5 +++-- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java index a8920e417ee52..124a6bc2b82af 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java @@ -1432,6 +1432,7 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode { } private void releaseFocus() { + if (mStatusBarWindow == null) return; WindowManager.LayoutParams lp = (WindowManager.LayoutParams) mStatusBarWindow.getLayoutParams(); lp.flags |= WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE; @@ -1463,8 +1464,10 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode { mHandler.sendEmptyMessage(MSG_CLOSE_SEARCH_PANEL); } - mStatusBarWindow.cancelExpandHelper(); - mStatusBarView.collapseAllPanels(true); + if (mStatusBarWindow != null) { + mStatusBarWindow.cancelExpandHelper(); + mStatusBarView.collapseAllPanels(true); + } } public ViewPropertyAnimator setVisibilityWhenDone( @@ -1673,7 +1676,7 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode { if (SPEW) Log.d(TAG, "makeExpandedInvisible: mExpandedVisible=" + mExpandedVisible + " mExpandedVisible=" + mExpandedVisible); - if (!mExpandedVisible) { + if (!mExpandedVisible || mStatusBarWindow == null) { return; } @@ -2076,7 +2079,8 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode { // until status bar window is attached to the window manager, // because... well, what's the point otherwise? And trying to // run a ticker without being attached will crash! - if (n.getNotification().tickerText != null && mStatusBarWindow.getWindowToken() != null) { + if (n.getNotification().tickerText != null && mStatusBarWindow != null + && mStatusBarWindow.getWindowToken() != null) { if (0 == (mDisabled & (StatusBarManager.DISABLE_NOTIFICATION_ICONS | StatusBarManager.DISABLE_NOTIFICATION_TICKER))) { mTicker.addEntry(n); @@ -2726,9 +2730,11 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode { super.destroy(); if (mStatusBarWindow != null) { mWindowManager.removeViewImmediate(mStatusBarWindow); + mStatusBarWindow = null; } if (mNavigationBarView != null) { mWindowManager.removeViewImmediate(mNavigationBarView); + mNavigationBarView = null; } mContext.unregisterReceiver(mBroadcastReceiver); } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarView.java index d0e9a999b13c5..d9e3fdfc86708 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarView.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarView.java @@ -170,7 +170,7 @@ public class PhoneStatusBarView extends PanelBar { mBar.makeExpandedInvisibleSoon(); mFadingPanel = null; mLastFullyOpenedPanel = null; - if (mScrimColor != 0 && ActivityManager.isHighEndGfx()) { + if (mScrimColor != 0 && ActivityManager.isHighEndGfx() && mBar.mStatusBarWindow != null) { mBar.mStatusBarWindow.setBackgroundColor(0); } } @@ -214,7 +214,8 @@ public class PhoneStatusBarView extends PanelBar { Log.v(TAG, "panelExpansionChanged: f=" + frac); } - if (panel == mFadingPanel && mScrimColor != 0 && ActivityManager.isHighEndGfx()) { + if (panel == mFadingPanel && mScrimColor != 0 && ActivityManager.isHighEndGfx() + && mBar.mStatusBarWindow != null) { if (mShouldFade) { frac = mPanelExpandedFractionSum; // don't judge me // let's start this 20% of the way down the screen