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

Commit 19e19b29 authored by Lucas Silva's avatar Lucas Silva Committed by Automerger Merge Worker
Browse files

Merge "Update ActivityStarter to dismiss dreams when starting activities."...

Merge "Update ActivityStarter to dismiss dreams  when starting activities." into tm-dev am: cd2cf901 am: a3625dcd

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/18602463



Change-Id: Ic8e0a907677d62ca42322a976767b22c2e815858
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents 9fd0212e a3625dcd
Loading
Loading
Loading
Loading
+14 −5
Original line number Original line Diff line number Diff line
@@ -83,7 +83,6 @@ import android.os.SystemProperties;
import android.os.Trace;
import android.os.Trace;
import android.os.UserHandle;
import android.os.UserHandle;
import android.provider.Settings;
import android.provider.Settings;
import android.service.dreams.DreamService;
import android.service.dreams.IDreamManager;
import android.service.dreams.IDreamManager;
import android.service.notification.StatusBarNotification;
import android.service.notification.StatusBarNotification;
import android.text.TextUtils;
import android.text.TextUtils;
@@ -781,7 +780,8 @@ public class CentralSurfacesImpl extends CoreStartable implements
            InteractionJankMonitor jankMonitor,
            InteractionJankMonitor jankMonitor,
            DeviceStateManager deviceStateManager,
            DeviceStateManager deviceStateManager,
            DreamOverlayStateController dreamOverlayStateController,
            DreamOverlayStateController dreamOverlayStateController,
            WiredChargingRippleController wiredChargingRippleController) {
            WiredChargingRippleController wiredChargingRippleController,
            IDreamManager dreamManager) {
        super(context);
        super(context);
        mNotificationsController = notificationsController;
        mNotificationsController = notificationsController;
        mFragmentService = fragmentService;
        mFragmentService = fragmentService;
@@ -872,6 +872,7 @@ public class CentralSurfacesImpl extends CoreStartable implements
        mLockscreenShadeTransitionController = lockscreenShadeTransitionController;
        mLockscreenShadeTransitionController = lockscreenShadeTransitionController;
        mStartingSurfaceOptional = startingSurfaceOptional;
        mStartingSurfaceOptional = startingSurfaceOptional;
        mNotifPipelineFlags = notifPipelineFlags;
        mNotifPipelineFlags = notifPipelineFlags;
        mDreamManager = dreamManager;
        lockscreenShadeTransitionController.setCentralSurfaces(this);
        lockscreenShadeTransitionController.setCentralSurfaces(this);
        statusBarWindowStateController.addListener(this::onStatusBarWindowStateChanged);
        statusBarWindowStateController.addListener(this::onStatusBarWindowStateChanged);


@@ -925,8 +926,6 @@ public class CentralSurfacesImpl extends CoreStartable implements
                SysuiStatusBarStateController.RANK_STATUS_BAR);
                SysuiStatusBarStateController.RANK_STATUS_BAR);


        mWindowManager = (WindowManager) mContext.getSystemService(Context.WINDOW_SERVICE);
        mWindowManager = (WindowManager) mContext.getSystemService(Context.WINDOW_SERVICE);
        mDreamManager = IDreamManager.Stub.asInterface(
                ServiceManager.checkService(DreamService.DREAM_SERVICE));


        mDisplay = mContext.getDisplay();
        mDisplay = mContext.getDisplay();
        mDisplayId = mDisplay.getDisplayId();
        mDisplayId = mDisplay.getDisplayId();
@@ -1793,6 +1792,12 @@ public class CentralSurfacesImpl extends CoreStartable implements
            collapseShade();
            collapseShade();
        }
        }


        // We should exit the dream to prevent the activity from starting below the
        // dream.
        if (mKeyguardUpdateMonitor.isDreaming()) {
            awakenDreams();
        }

        mActivityLaunchAnimator.startIntentWithAnimation(controller, animate,
        mActivityLaunchAnimator.startIntentWithAnimation(controller, animate,
                intent.getPackage(), showOverLockscreenWhenLocked, (adapter) -> TaskStackBuilder
                intent.getPackage(), showOverLockscreenWhenLocked, (adapter) -> TaskStackBuilder
                        .create(mContext)
                        .create(mContext)
@@ -2738,6 +2743,10 @@ public class CentralSurfacesImpl extends CoreStartable implements
            mStatusBarKeyguardViewManager.dismissWithAction(action, cancelAction,
            mStatusBarKeyguardViewManager.dismissWithAction(action, cancelAction,
                    afterKeyguardGone);
                    afterKeyguardGone);
        } else {
        } else {
            // If the keyguard isn't showing but the device is dreaming, we should exit the dream.
            if (mKeyguardUpdateMonitor.isDreaming()) {
                awakenDreams();
            }
            action.onDismiss();
            action.onDismiss();
        }
        }
    }
    }
@@ -3986,7 +3995,7 @@ public class CentralSurfacesImpl extends CoreStartable implements


    protected WindowManager mWindowManager;
    protected WindowManager mWindowManager;
    protected IWindowManager mWindowManagerService;
    protected IWindowManager mWindowManagerService;
    private IDreamManager mDreamManager;
    private final IDreamManager mDreamManager;


    protected Display mDisplay;
    protected Display mDisplay;
    private int mDisplayId;
    private int mDisplayId;
+31 −1
Original line number Original line Diff line number Diff line
@@ -477,7 +477,7 @@ public class CentralSurfacesImplTest extends SysuiTestCase {
                mJankMonitor,
                mJankMonitor,
                mDeviceStateManager,
                mDeviceStateManager,
                mDreamOverlayStateController,
                mDreamOverlayStateController,
                mWiredChargingRippleController);
                mWiredChargingRippleController, mDreamManager);
        when(mKeyguardViewMediator.registerCentralSurfaces(
        when(mKeyguardViewMediator.registerCentralSurfaces(
                any(CentralSurfacesImpl.class),
                any(CentralSurfacesImpl.class),
                any(NotificationPanelViewController.class),
                any(NotificationPanelViewController.class),
@@ -533,6 +533,36 @@ public class CentralSurfacesImplTest extends SysuiTestCase {
        mCentralSurfaces.executeRunnableDismissingKeyguard(null, null, false, false, false);
        mCentralSurfaces.executeRunnableDismissingKeyguard(null, null, false, false, false);
    }
    }


    @Test
    public void executeRunnableDismissingKeyguard_dreaming_notShowing() throws RemoteException {
        when(mStatusBarKeyguardViewManager.isShowing()).thenReturn(false);
        when(mStatusBarKeyguardViewManager.isOccluded()).thenReturn(false);
        when(mKeyguardUpdateMonitor.isDreaming()).thenReturn(true);

        mCentralSurfaces.executeRunnableDismissingKeyguard(() ->  {},
                /* cancelAction= */ null,
                /* dismissShade= */ false,
                /* afterKeyguardGone= */ false,
                /* deferred= */ false);
        mUiBgExecutor.runAllReady();
        verify(mDreamManager, times(1)).awaken();
    }

    @Test
    public void executeRunnableDismissingKeyguard_notDreaming_notShowing() throws RemoteException {
        when(mStatusBarKeyguardViewManager.isShowing()).thenReturn(false);
        when(mStatusBarKeyguardViewManager.isOccluded()).thenReturn(false);
        when(mKeyguardUpdateMonitor.isDreaming()).thenReturn(false);

        mCentralSurfaces.executeRunnableDismissingKeyguard(() ->  {},
                /* cancelAction= */ null,
                /* dismissShade= */ false,
                /* afterKeyguardGone= */ false,
                /* deferred= */ false);
        mUiBgExecutor.runAllReady();
        verify(mDreamManager, never()).awaken();
    }

    @Test
    @Test
    public void lockscreenStateMetrics_notShowing() {
    public void lockscreenStateMetrics_notShowing() {
        // uninteresting state, except that fingerprint must be non-zero
        // uninteresting state, except that fingerprint must be non-zero