diff options
4 files changed, 70 insertions, 39 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/globalactions/GlobalActionsDialogLite.java b/packages/SystemUI/src/com/android/systemui/globalactions/GlobalActionsDialogLite.java index 040ee7938f1d..3eb17400446c 100644 --- a/packages/SystemUI/src/com/android/systemui/globalactions/GlobalActionsDialogLite.java +++ b/packages/SystemUI/src/com/android/systemui/globalactions/GlobalActionsDialogLite.java @@ -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 { diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfaces.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfaces.java index af09bf281c0c..dad72d1b69cf 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfaces.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfaces.java @@ -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(); diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfacesImpl.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfacesImpl.java index ccb87bf44dc8..190a82fe7857 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfacesImpl.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfacesImpl.java @@ -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; diff --git a/packages/SystemUI/tests/src/com/android/systemui/globalactions/GlobalActionsDialogLiteTest.java b/packages/SystemUI/tests/src/com/android/systemui/globalactions/GlobalActionsDialogLiteTest.java index 6aa5a00c36da..b1cf0517ddd1 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/globalactions/GlobalActionsDialogLiteTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/globalactions/GlobalActionsDialogLiteTest.java @@ -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, @@ -348,6 +348,34 @@ public class GlobalActionsDialogLiteTest extends SysuiTestCase { } @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 = mGlobalActionsDialogLite.makeBugReportActionForTesting(); @@ -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, |