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

Commit d397b908 authored by Aran Ink's avatar Aran Ink
Browse files

Add dismissImmediate to ListPopupWindow to prevent window leaks in GlobalActionsDialog.

Fixes: 154640131
Test: Manual -- Use 'adb shell dumpsys window windows || grep "PopupWindow"' to confirm number of PopupWindows displayed (should be zero at home screen.)
Open GlobalActions. Tap the power overflow menu and check number of PopupWindows while the overflow dropdown is visible (should be 1).
Put the phone to sleep by pressing the power button. Wake phone and make sure number of PopupWindows is 0.
Repeat with Controls structure switcher dropdown and add controls dropdown.

Change-Id: I4ae2d86e981465e8e6c0adf924a6fc2eabfc88ee
parent 8f0b08f1
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -745,6 +745,15 @@ public class ListPopupWindow implements ShowableListMenu {
        mHandler.removeCallbacks(mResizePopupRunnable);
    }

    /**
     * Remove existing exit transition from PopupWindow and force immediate dismissal.
     * @hide
     */
    public void dismissImmediate() {
        mPopup.setExitTransition(null);
        dismiss();
    }

    /**
     * Set a listener to receive a callback when the popup is dismissed.
     *
+1 −1
Original line number Diff line number Diff line
@@ -536,7 +536,7 @@ class ControlsUiControllerImpl @Inject constructor (
    override fun hide() {
        Log.d(ControlsUiController.TAG, "hide()")
        hidden = true
        popup?.dismiss()
        popup?.dismissImmediate()
        activeDialog?.dismiss()
        ControlActionCoordinator.closeDialog()

+8 −5
Original line number Diff line number Diff line
@@ -484,8 +484,7 @@ public class GlobalActionsDialog implements DialogInterface.OnDismissListener,
     */
    @VisibleForTesting
    protected int getMaxShownPowerItems() {
        // TODO: Overflow disabled on keyguard while we solve for touch blocking issues.
        if (shouldUseControlsLayout() && !mKeyguardShowing) {
        if (shouldUseControlsLayout()) {
            return mResources.getInteger(com.android.systemui.R.integer.power_menu_max_columns);
        } else {
            return Integer.MAX_VALUE;
@@ -2246,7 +2245,7 @@ public class GlobalActionsDialog implements DialogInterface.OnDismissListener,
            mShowing = false;
            resetOrientation();
            dismissPanel();
            dismissOverflow();
            dismissOverflow(true);
            if (mControlsUiController != null) mControlsUiController.hide();
            mNotificationShadeWindowController.setForceHasTopUi(mHadTopUi);
            mDepthController.updateGlobalDialogVisibility(0, null /* view */);
@@ -2259,11 +2258,15 @@ public class GlobalActionsDialog implements DialogInterface.OnDismissListener,
            }
        }

        private void dismissOverflow() {
        private void dismissOverflow(boolean immediate) {
            if (mOverflowPopup != null) {
                if (immediate) {
                    mOverflowPopup.dismissImmediate();
                } else {
                    mOverflowPopup.dismiss();
                }
            }
        }

        private void setRotationSuggestionsEnabled(boolean enabled) {
            try {