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

Commit 547e11e8 authored by Hyunyoung Song's avatar Hyunyoung Song
Browse files

Fix Panel View not being able to handle touch when NexusLauncher dies

Bug: 116744159
Test: builds
Also verified by executing following while touching on the device
$ adb shell am force-stop com.google.android.apps.nexuslauncher

Change-Id: I075dc05fbda2cc99573a78fcc239355a59e3a8ac
parent 8ad9ef4a
Loading
Loading
Loading
Loading
+35 −1
Original line number Original line Diff line number Diff line
@@ -17,6 +17,10 @@
package com.android.systemui;
package com.android.systemui;


import static android.content.pm.PackageManager.MATCH_DIRECT_BOOT_UNAWARE;
import static android.content.pm.PackageManager.MATCH_DIRECT_BOOT_UNAWARE;
import static android.view.MotionEvent.ACTION_DOWN;
import static android.view.MotionEvent.ACTION_UP;
import static android.view.MotionEvent.ACTION_CANCEL;

import static com.android.systemui.shared.system.NavigationBarCompat.FLAG_DISABLE_SWIPE_UP;
import static com.android.systemui.shared.system.NavigationBarCompat.FLAG_DISABLE_SWIPE_UP;
import static com.android.systemui.shared.system.NavigationBarCompat.FLAG_SHOW_OVERVIEW_BUTTON;
import static com.android.systemui.shared.system.NavigationBarCompat.FLAG_SHOW_OVERVIEW_BUTTON;
import static com.android.systemui.shared.system.NavigationBarCompat.InteractionType;
import static com.android.systemui.shared.system.NavigationBarCompat.InteractionType;
@@ -86,6 +90,7 @@ public class OverviewProxyService implements CallbackController<OverviewProxyLis
    private boolean mIsEnabled;
    private boolean mIsEnabled;
    private int mCurrentBoundedUserId = -1;
    private int mCurrentBoundedUserId = -1;
    private float mBackButtonAlpha;
    private float mBackButtonAlpha;
    private MotionEvent mStatusBarGestureDownEvent;


    private ISystemUiProxy mSysUiProxy = new ISystemUiProxy.Stub() {
    private ISystemUiProxy mSysUiProxy = new ISystemUiProxy.Stub() {


@@ -108,6 +113,9 @@ public class OverviewProxyService implements CallbackController<OverviewProxyLis
        }
        }


        public void onStatusBarMotionEvent(MotionEvent event) {
        public void onStatusBarMotionEvent(MotionEvent event) {
            if (!verifyCaller("onStatusBarMotionEvent")) {
                return;
            }
            long token = Binder.clearCallingIdentity();
            long token = Binder.clearCallingIdentity();
            try {
            try {
                // TODO move this logic to message queue
                // TODO move this logic to message queue
@@ -115,6 +123,16 @@ public class OverviewProxyService implements CallbackController<OverviewProxyLis
                    StatusBar bar = SysUiServiceProvider.getComponent(mContext, StatusBar.class);
                    StatusBar bar = SysUiServiceProvider.getComponent(mContext, StatusBar.class);
                    if (bar != null) {
                    if (bar != null) {
                        bar.dispatchNotificationsPanelTouchEvent(event);
                        bar.dispatchNotificationsPanelTouchEvent(event);

                        int action = event.getActionMasked();
                        if (action == ACTION_DOWN) {
                            mStatusBarGestureDownEvent = MotionEvent.obtain(event);
                        }
                        if (action == ACTION_UP || action == ACTION_CANCEL) {
                            mStatusBarGestureDownEvent.recycle();
                            mStatusBarGestureDownEvent = null;
                        }
                        event.recycle();
                    }
                    }
                });
                });
            } finally {
            } finally {
@@ -298,7 +316,7 @@ public class OverviewProxyService implements CallbackController<OverviewProxyLis


    // This is the death handler for the binder from the launcher service
    // This is the death handler for the binder from the launcher service
    private final IBinder.DeathRecipient mOverviewServiceDeathRcpt
    private final IBinder.DeathRecipient mOverviewServiceDeathRcpt
            = this::startConnectionToCurrentUser;
            = this::cleanupAfterDeath;


    public OverviewProxyService(Context context) {
    public OverviewProxyService(Context context) {
        mContext = context;
        mContext = context;
@@ -328,6 +346,22 @@ public class OverviewProxyService implements CallbackController<OverviewProxyLis
        return mBackButtonAlpha;
        return mBackButtonAlpha;
    }
    }


    public void cleanupAfterDeath() {
        if (mStatusBarGestureDownEvent != null) {
            mHandler.post(()-> {
                StatusBar bar = SysUiServiceProvider.getComponent(mContext, StatusBar.class);
                if (bar != null) {
                    System.out.println("MERONG dispatchNotificationPanelTouchEvent");
                    mStatusBarGestureDownEvent.setAction(MotionEvent.ACTION_CANCEL);
                    bar.dispatchNotificationsPanelTouchEvent(mStatusBarGestureDownEvent);
                    mStatusBarGestureDownEvent.recycle();
                    mStatusBarGestureDownEvent = null;
                }
            });
        }
        startConnectionToCurrentUser();
    }

    public void startConnectionToCurrentUser() {
    public void startConnectionToCurrentUser() {
        if (mHandler.getLooper() != Looper.myLooper()) {
        if (mHandler.getLooper() != Looper.myLooper()) {
            mHandler.post(mConnectionRunnable);
            mHandler.post(mConnectionRunnable);
+1 −0
Original line number Original line Diff line number Diff line
@@ -2852,6 +2852,7 @@ public class StatusBar extends SystemUI implements DemoMode,
                }
                }
            }
            }
            else if (Intent.ACTION_SCREEN_OFF.equals(action)) {
            else if (Intent.ACTION_SCREEN_OFF.equals(action)) {
                mStatusBarWindowController.setNotTouchable(false);
                finishBarAnimations();
                finishBarAnimations();
                resetUserExpandedStates();
                resetUserExpandedStates();
            }
            }