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

Commit b8de37d5 authored by Clark Scheff's avatar Clark Scheff Committed by Adnan Begovic
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
(cherry picked from commit 6a7eb48b)
parent 29bc8a9a
Loading
Loading
Loading
Loading
+14 −9
Original line number Diff line number Diff line
@@ -1188,6 +1188,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!
@@ -1211,8 +1215,10 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
    }

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

    public void refreshAllStatusBarIcons() {
        refreshAllIconsForLayout(mStatusIcons);
@@ -3209,12 +3215,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;
@@ -3254,10 +3262,7 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
    private void recreateStatusBar() {
        mRecreating = true;

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

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