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

Commit b7b192af authored by Caitlin Shkuratov's avatar Caitlin Shkuratov
Browse files

[CS] Remove CentralSurfaces references from GlobalActionsDialogLite.

Replaces them with direct calls to controllers instead.

Bug: 277764509
Test: open power menu on lockscreen -> swipe down from top -> verify
shade opens
Test: open power menu on homescreen -> swipe down from top -> verify
shade opens
Test: open power menu while on app in landscape -> swipe down from top
-> verify shade opens
Test: atest GlobalActionsDialogLiteTest

Change-Id: I1911b05a16921b8618455d171aa7dc099f961e8d
parent 3697f77a
Loading
Loading
Loading
Loading
+35 −25
Original line number Diff line number Diff line
@@ -128,11 +128,11 @@ import com.android.systemui.settings.UserTracker;
import com.android.systemui.shade.ShadeController;
import com.android.systemui.statusbar.NotificationShadeWindowController;
import com.android.systemui.statusbar.VibratorHelper;
import com.android.systemui.statusbar.phone.CentralSurfaces;
import com.android.systemui.statusbar.phone.LightBarController;
import com.android.systemui.statusbar.phone.SystemUIDialog;
import com.android.systemui.statusbar.policy.ConfigurationController;
import com.android.systemui.statusbar.policy.KeyguardStateController;
import com.android.systemui.statusbar.window.StatusBarWindowController;
import com.android.systemui.telephony.TelephonyListenerManager;
import com.android.systemui.util.EmergencyDialerConstants;
import com.android.systemui.util.RingerModeTracker;
@@ -141,7 +141,6 @@ import com.android.systemui.util.settings.SecureSettings;

import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import java.util.concurrent.Executor;

import javax.inject.Inject;
@@ -244,6 +243,7 @@ public class GlobalActionsDialogLite implements DialogInterface.OnDismissListene
    private final IStatusBarService mStatusBarService;
    protected final LightBarController mLightBarController;
    protected final NotificationShadeWindowController mNotificationShadeWindowController;
    private final StatusBarWindowController mStatusBarWindowController;
    private final IWindowManager mIWindowManager;
    private final Executor mBackgroundExecutor;
    private final RingerModeTracker mRingerModeTracker;
@@ -251,7 +251,6 @@ public class GlobalActionsDialogLite implements DialogInterface.OnDismissListene
    protected Handler mMainHandler;
    private int mSmallestScreenWidthDp;
    private int mOrientation;
    private final Optional<CentralSurfaces> mCentralSurfacesOptional;
    private final ShadeController mShadeController;
    private final KeyguardUpdateMonitor mKeyguardUpdateMonitor;
    private final DialogLaunchAnimator mDialogLaunchAnimator;
@@ -356,13 +355,13 @@ public class GlobalActionsDialogLite implements DialogInterface.OnDismissListene
            IStatusBarService statusBarService,
            LightBarController lightBarController,
            NotificationShadeWindowController notificationShadeWindowController,
            StatusBarWindowController statusBarWindowController,
            IWindowManager iWindowManager,
            @Background Executor backgroundExecutor,
            UiEventLogger uiEventLogger,
            RingerModeTracker ringerModeTracker,
            @Main Handler handler,
            PackageManager packageManager,
            Optional<CentralSurfaces> centralSurfacesOptional,
            ShadeController shadeController,
            KeyguardUpdateMonitor keyguardUpdateMonitor,
            DialogLaunchAnimator dialogLaunchAnimator) {
@@ -390,13 +389,13 @@ public class GlobalActionsDialogLite implements DialogInterface.OnDismissListene
        mStatusBarService = statusBarService;
        mLightBarController = lightBarController;
        mNotificationShadeWindowController = notificationShadeWindowController;
        mStatusBarWindowController = statusBarWindowController;
        mIWindowManager = iWindowManager;
        mBackgroundExecutor = backgroundExecutor;
        mRingerModeTracker = ringerModeTracker;
        mMainHandler = handler;
        mSmallestScreenWidthDp = resources.getConfiguration().smallestScreenWidthDp;
        mOrientation = resources.getConfiguration().orientation;
        mCentralSurfacesOptional = centralSurfacesOptional;
        mShadeController = shadeController;
        mKeyguardUpdateMonitor = keyguardUpdateMonitor;
        mDialogLaunchAnimator = dialogLaunchAnimator;
@@ -449,10 +448,6 @@ public class GlobalActionsDialogLite implements DialogInterface.OnDismissListene
        return mUiEventLogger;
    }

    protected Optional<CentralSurfaces> getCentralSurfaces() {
        return mCentralSurfacesOptional;
    }

    protected KeyguardUpdateMonitor getKeyguardUpdateMonitor() {
        return mKeyguardUpdateMonitor;
    }
@@ -701,12 +696,21 @@ public class GlobalActionsDialogLite implements DialogInterface.OnDismissListene
    protected ActionsDialogLite createDialog() {
        initDialogItems();

        ActionsDialogLite dialog = new ActionsDialogLite(mContext,
        ActionsDialogLite dialog = new ActionsDialogLite(
                mContext,
                com.android.systemui.R.style.Theme_SystemUI_Dialog_GlobalActionsLite,
                mAdapter, mOverflowAdapter, mSysuiColorExtractor, mStatusBarService,
                mAdapter,
                mOverflowAdapter,
                mSysuiColorExtractor,
                mStatusBarService,
                mLightBarController,
                mNotificationShadeWindowController, this::onRefresh, mKeyguardShowing,
                mPowerAdapter, mUiEventLogger, mCentralSurfacesOptional,
                mKeyguardStateController,
                mNotificationShadeWindowController,
                mStatusBarWindowController,
                this::onRefresh,
                mKeyguardShowing,
                mPowerAdapter,
                mUiEventLogger,
                mShadeController,
                mKeyguardUpdateMonitor,
                mLockPatternUtils);
@@ -2208,13 +2212,14 @@ public class GlobalActionsDialogLite implements DialogInterface.OnDismissListene
        private boolean mKeyguardShowing;
        protected float mScrimAlpha;
        protected final LightBarController mLightBarController;
        private final KeyguardStateController mKeyguardStateController;
        protected final NotificationShadeWindowController mNotificationShadeWindowController;
        private final StatusBarWindowController mStatusBarWindowController;
        private ListPopupWindow mOverflowPopup;
        private Dialog mPowerOptionsDialog;
        protected final Runnable mOnRefreshCallback;
        private UiEventLogger mUiEventLogger;
        private GestureDetector mGestureDetector;
        private Optional<CentralSurfaces> mCentralSurfacesOptional;
        private final ShadeController mShadeController;
        private KeyguardUpdateMonitor mKeyguardUpdateMonitor;
        private LockPatternUtils mLockPatternUtils;
@@ -2248,8 +2253,7 @@ public class GlobalActionsDialogLite implements DialogInterface.OnDismissListene
                    public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX,
                            float distanceY) {
                        if (distanceY < 0 && distanceY > distanceX
                                && e1.getY() <= mCentralSurfacesOptional.map(
                                        CentralSurfaces::getStatusBarHeight).orElse(0)) {
                                && e1.getY() <= mStatusBarWindowController.getStatusBarHeight()) {
                            // Downwards scroll from top
                            openShadeAndDismiss();
                            return true;
@@ -2261,8 +2265,7 @@ public class GlobalActionsDialogLite implements DialogInterface.OnDismissListene
                    public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX,
                            float velocityY) {
                        if (velocityY > 0 && Math.abs(velocityY) > Math.abs(velocityX)
                                && e1.getY() <= mCentralSurfacesOptional.map(
                                        CentralSurfaces::getStatusBarHeight).orElse(0)) {
                                && e1.getY() <= mStatusBarWindowController.getStatusBarHeight()) {
                            // Downwards fling from top
                            openShadeAndDismiss();
                            return true;
@@ -2281,14 +2284,20 @@ public class GlobalActionsDialogLite implements DialogInterface.OnDismissListene
            mOverriddenBackDispatcher = mockDispatcher;
        }

        ActionsDialogLite(Context context, int themeRes, MyAdapter adapter,
        ActionsDialogLite(Context context,
                int themeRes,
                MyAdapter adapter,
                MyOverflowAdapter overflowAdapter,
                SysuiColorExtractor sysuiColorExtractor, IStatusBarService statusBarService,
                SysuiColorExtractor sysuiColorExtractor,
                IStatusBarService statusBarService,
                LightBarController lightBarController,
                KeyguardStateController keyguardStateController,
                NotificationShadeWindowController notificationShadeWindowController,
                Runnable onRefreshCallback, boolean keyguardShowing,
                MyPowerOptionsAdapter powerAdapter, UiEventLogger uiEventLogger,
                Optional<CentralSurfaces> centralSurfacesOptional,
                StatusBarWindowController statusBarWindowController,
                Runnable onRefreshCallback,
                boolean keyguardShowing,
                MyPowerOptionsAdapter powerAdapter,
                UiEventLogger uiEventLogger,
                ShadeController shadeController,
                KeyguardUpdateMonitor keyguardUpdateMonitor,
                LockPatternUtils lockPatternUtils) {
@@ -2302,11 +2311,12 @@ public class GlobalActionsDialogLite implements DialogInterface.OnDismissListene
            mColorExtractor = sysuiColorExtractor;
            mStatusBarService = statusBarService;
            mLightBarController = lightBarController;
            mKeyguardStateController = keyguardStateController;
            mNotificationShadeWindowController = notificationShadeWindowController;
            mStatusBarWindowController = statusBarWindowController;
            mOnRefreshCallback = onRefreshCallback;
            mKeyguardShowing = keyguardShowing;
            mUiEventLogger = uiEventLogger;
            mCentralSurfacesOptional = centralSurfacesOptional;
            mShadeController = shadeController;
            mKeyguardUpdateMonitor = keyguardUpdateMonitor;
            mLockPatternUtils = lockPatternUtils;
@@ -2355,7 +2365,7 @@ public class GlobalActionsDialogLite implements DialogInterface.OnDismissListene

        private void openShadeAndDismiss() {
            mUiEventLogger.log(GlobalActionsEvent.GA_CLOSE_TAP_OUTSIDE);
            if (mCentralSurfacesOptional.map(CentralSurfaces::isKeyguardShowing).orElse(false)) {
            if (mKeyguardStateController.isShowing()) {
                // match existing lockscreen behavior to open QS when swiping from status bar
                mShadeController.animateExpandQs();
            } else {
+0 −2
Original line number Diff line number Diff line
@@ -196,8 +196,6 @@ public interface CentralSurfaces extends Dumpable, LifecycleOwner {
    /** Get the Keyguard Message Area that displays auth messages. */
    AuthKeyguardMessageArea getKeyguardMessageArea();

    int getStatusBarHeight();

    boolean isLaunchingActivityOverLockscreen();

    void onKeyguardViewManagerStatesUpdated();
+0 −5
Original line number Diff line number Diff line
@@ -1688,11 +1688,6 @@ public class CentralSurfacesImpl implements CoreStartable, CentralSurfaces {
        return getNotificationShadeWindowViewController().getKeyguardMessageArea();
    }

    @Override
    public int getStatusBarHeight() {
        return mStatusBarWindowController.getStatusBarHeight();
    }

    private void updateReportRejectedTouchVisibility() {
        if (mReportRejectedTouch == null) {
            return;
+35 −7
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@ import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
@@ -70,10 +71,10 @@ import com.android.systemui.settings.UserTracker;
import com.android.systemui.shade.ShadeController;
import com.android.systemui.statusbar.NotificationShadeWindowController;
import com.android.systemui.statusbar.VibratorHelper;
import com.android.systemui.statusbar.phone.CentralSurfaces;
import com.android.systemui.statusbar.phone.LightBarController;
import com.android.systemui.statusbar.policy.ConfigurationController;
import com.android.systemui.statusbar.policy.KeyguardStateController;
import com.android.systemui.statusbar.window.StatusBarWindowController;
import com.android.systemui.telephony.TelephonyListenerManager;
import com.android.systemui.util.RingerModeLiveData;
import com.android.systemui.util.RingerModeTracker;
@@ -89,7 +90,6 @@ import org.mockito.Mock;
import org.mockito.MockitoAnnotations;

import java.util.List;
import java.util.Optional;
import java.util.concurrent.Executor;

@SmallTest
@@ -119,6 +119,7 @@ public class GlobalActionsDialogLiteTest extends SysuiTestCase {
    @Mock private IStatusBarService mStatusBarService;
    @Mock private LightBarController mLightBarController;
    @Mock private NotificationShadeWindowController mNotificationShadeWindowController;
    @Mock private StatusBarWindowController mStatusBarWindowController;
    @Mock private IWindowManager mWindowManager;
    @Mock private Executor mBackgroundExecutor;
    @Mock private UiEventLogger mUiEventLogger;
@@ -128,7 +129,6 @@ public class GlobalActionsDialogLiteTest extends SysuiTestCase {
    @Mock private Handler mHandler;
    @Mock private UserContextProvider mUserContextProvider;
    @Mock private VibratorHelper mVibratorHelper;
    @Mock private CentralSurfaces mCentralSurfaces;
    @Mock private ShadeController mShadeController;
    @Mock private KeyguardUpdateMonitor mKeyguardUpdateMonitor;
    @Mock private DialogLaunchAnimator mDialogLaunchAnimator;
@@ -172,13 +172,13 @@ public class GlobalActionsDialogLiteTest extends SysuiTestCase {
                mStatusBarService,
                mLightBarController,
                mNotificationShadeWindowController,
                mStatusBarWindowController,
                mWindowManager,
                mBackgroundExecutor,
                mUiEventLogger,
                mRingerModeTracker,
                mHandler,
                mPackageManager,
                Optional.of(mCentralSurfaces),
                mShadeController,
                mKeyguardUpdateMonitor,
                mDialogLaunchAnimator);
@@ -305,7 +305,7 @@ public class GlobalActionsDialogLiteTest extends SysuiTestCase {
        doReturn(4).when(mGlobalActionsDialogLite).getMaxShownPowerItems();
        doReturn(true).when(mGlobalActionsDialogLite).shouldDisplayLockdown(any());
        doReturn(true).when(mGlobalActionsDialogLite).shouldShowAction(any());
        doReturn(true).when(mCentralSurfaces).isKeyguardShowing();
        doReturn(true).when(mKeyguardStateController).isShowing();
        String[] actions = {
                GlobalActionsDialogLite.GLOBAL_ACTION_KEY_EMERGENCY,
                GlobalActionsDialogLite.GLOBAL_ACTION_KEY_LOCKDOWN,
@@ -329,7 +329,7 @@ public class GlobalActionsDialogLiteTest extends SysuiTestCase {
        doReturn(4).when(mGlobalActionsDialogLite).getMaxShownPowerItems();
        doReturn(true).when(mGlobalActionsDialogLite).shouldDisplayLockdown(any());
        doReturn(true).when(mGlobalActionsDialogLite).shouldShowAction(any());
        doReturn(false).when(mCentralSurfaces).isKeyguardShowing();
        doReturn(false).when(mKeyguardStateController).isShowing();
        String[] actions = {
                GlobalActionsDialogLite.GLOBAL_ACTION_KEY_EMERGENCY,
                GlobalActionsDialogLite.GLOBAL_ACTION_KEY_LOCKDOWN,
@@ -347,6 +347,34 @@ public class GlobalActionsDialogLiteTest extends SysuiTestCase {
        verify(mShadeController).animateExpandShade();
    }

    @Test
    public void testSwipeDown_pastStatusBarHeight_shadeNotOpened() {
        mGlobalActionsDialogLite = spy(mGlobalActionsDialogLite);
        doReturn(4).when(mGlobalActionsDialogLite).getMaxShownPowerItems();
        doReturn(true).when(mGlobalActionsDialogLite).shouldDisplayLockdown(any());
        doReturn(true).when(mGlobalActionsDialogLite).shouldShowAction(any());
        doReturn(false).when(mKeyguardStateController).isShowing();
        String[] actions = {
                GlobalActionsDialogLite.GLOBAL_ACTION_KEY_EMERGENCY,
                GlobalActionsDialogLite.GLOBAL_ACTION_KEY_LOCKDOWN,
                GlobalActionsDialogLite.GLOBAL_ACTION_KEY_POWER,
                GlobalActionsDialogLite.GLOBAL_ACTION_KEY_RESTART,
        };
        doReturn(actions).when(mGlobalActionsDialogLite).getDefaultActions();
        GlobalActionsDialogLite.ActionsDialogLite dialog = mGlobalActionsDialogLite.createDialog();

        doReturn(100).when(mStatusBarWindowController).getStatusBarHeight();

        GestureDetector.SimpleOnGestureListener gestureListener = spy(dialog.mGestureListener);
        // WHEN the start y is larger than the status bar height
        MotionEvent start = MotionEvent.obtain(0, 0, MotionEvent.ACTION_DOWN, 0, 200, 0);
        MotionEvent end = MotionEvent.obtain(0, 0, MotionEvent.ACTION_DOWN, 0, 500, 0);
        gestureListener.onFling(start, end, 0, 1000);

        // THEN the shade isn't opened
        verify(mShadeController, never()).animateExpandShade();
    }

    @Test
    public void testShouldLogBugreportPress() throws InterruptedException {
        GlobalActionsDialogLite.BugReportAction bugReportAction =
@@ -539,7 +567,7 @@ public class GlobalActionsDialogLiteTest extends SysuiTestCase {
        doReturn(4).when(mGlobalActionsDialogLite).getMaxShownPowerItems();
        doReturn(true).when(mGlobalActionsDialogLite).shouldDisplayLockdown(any());
        doReturn(true).when(mGlobalActionsDialogLite).shouldShowAction(any());
        doReturn(false).when(mCentralSurfaces).isKeyguardShowing();
        doReturn(false).when(mKeyguardStateController).isShowing();
        String[] actions = {
                GlobalActionsDialogLite.GLOBAL_ACTION_KEY_EMERGENCY,
                GlobalActionsDialogLite.GLOBAL_ACTION_KEY_LOCKDOWN,