Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 6a7eb48b authored by Clark Scheff's avatar Clark Scheff Committed by Adnan
Browse files

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.

Change-Id: Ida916eba496c4183e47288ef24a8a93c46a7eddf
parent d05d99a4
Loading
Loading
Loading
Loading
+14 −9
Original line number Diff line number Diff line
@@ -1198,6 +1198,10 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
    }

    private void addHeadsUpView() {
        if (mHeadsUpNotificationView != null && mHeadsUpNotificationView.isAttachedToWindow()) {
            return;
        }

        WindowManager.LayoutParams lp = new WindowManager.LayoutParams(
                LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT,
                WindowManager.LayoutParams.TYPE_STATUS_BAR_PANEL, // above the status bar!
@@ -1221,8 +1225,10 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
    }

    private void removeHeadsUpView() {
        if (mHeadsUpNotificationView != null && mHeadsUpNotificationView.isAttachedToWindow()) {
            mWindowManager.removeView(mHeadsUpNotificationView);
        }
    }

    public void refreshAllStatusBarIcons() {
        refreshAllIconsForLayout(mStatusIcons);
@@ -3219,12 +3225,14 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
    private void setHeadsUpVisibility(boolean vis) {
        if (!ENABLE_HEADS_UP) return;
        if (DEBUG) Log.v(TAG, (vis ? "showing" : "hiding") + " heads up window");
        if (mHeadsUpNotificationView != null && mHeadsUpNotificationView.isAttachedToWindow()) {
            mHeadsUpNotificationView.setVisibility(vis ? View.VISIBLE : View.GONE);
            if (!vis) {
                if (DEBUG) Log.d(TAG, "setting heads up entry to null");
                mInterruptingNotificationEntry = null;
            }
        }
    }

    public void animateHeadsUp(boolean animateInto, float frac) {
        if (!ENABLE_HEADS_UP || mHeadsUpNotificationView == null) return;
@@ -3264,10 +3272,7 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
    private void recreateStatusBar() {
        mRecreating = true;

        if (mHeadsUpNotificationView != null) {
        removeHeadsUpView();
            mHeadsUpNotificationView = null;
        }

        mStatusBarContainer.removeAllViews();
        mStatusBarContainer.clearDisappearingChildren();