Merge "Controls UI - Show msg prior to first unlock" into rvc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
b30138550c
@@ -22,6 +22,7 @@ import static android.view.WindowManager.TAKE_SCREENSHOT_FULLSCREEN;
|
||||
|
||||
import static com.android.internal.widget.LockPatternUtils.StrongAuthTracker.SOME_AUTH_REQUIRED_AFTER_USER_REQUEST;
|
||||
import static com.android.internal.widget.LockPatternUtils.StrongAuthTracker.STRONG_AUTH_NOT_REQUIRED;
|
||||
import static com.android.internal.widget.LockPatternUtils.StrongAuthTracker.STRONG_AUTH_REQUIRED_AFTER_BOOT;
|
||||
import static com.android.internal.widget.LockPatternUtils.StrongAuthTracker.STRONG_AUTH_REQUIRED_AFTER_USER_LOCKDOWN;
|
||||
import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_GLOBAL_ACTIONS_SHOWING;
|
||||
|
||||
@@ -395,11 +396,14 @@ public class GlobalActionsDialog implements DialogInterface.OnDismissListener,
|
||||
controlsComponent.getControlsListingController().get()
|
||||
.addCallback(list -> {
|
||||
mControlsServiceInfos = list;
|
||||
// This callback may occur after the dialog has been shown.
|
||||
// If so, add controls into the already visible space
|
||||
if (mDialog != null && !mDialog.isShowingControls()
|
||||
&& shouldShowControls()) {
|
||||
mDialog.showControls(mControlsUiControllerOptional.get());
|
||||
// This callback may occur after the dialog has been shown. If so, add
|
||||
// controls into the already visible space or show the lock msg if needed.
|
||||
if (mDialog != null) {
|
||||
if (!mDialog.isShowingControls() && shouldShowControls()) {
|
||||
mDialog.showControls(mControlsUiControllerOptional.get());
|
||||
} else if (shouldShowLockMessage()) {
|
||||
mDialog.showLockMessage();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -700,9 +704,8 @@ public class GlobalActionsDialog implements DialogInterface.OnDismissListener,
|
||||
mStatusBarService, mNotificationShadeWindowController,
|
||||
controlsAvailable(), uiController,
|
||||
mSysUiState, this::onRotate, mKeyguardShowing, mPowerAdapter);
|
||||
boolean walletViewAvailable = walletViewController != null
|
||||
&& walletViewController.getPanelContent() != null;
|
||||
if (shouldShowLockMessage(walletViewAvailable)) {
|
||||
|
||||
if (shouldShowLockMessage()) {
|
||||
dialog.showLockMessage();
|
||||
}
|
||||
dialog.setCanceledOnTouchOutside(false); // Handled by the custom class.
|
||||
@@ -2591,7 +2594,9 @@ public class GlobalActionsDialog implements DialogInterface.OnDismissListener,
|
||||
|
||||
private boolean shouldShowControls() {
|
||||
return (mKeyguardStateController.isUnlocked() || mShowLockScreenCardsAndControls)
|
||||
&& controlsAvailable();
|
||||
&& controlsAvailable()
|
||||
&& mLockPatternUtils.getStrongAuthForUser(getCurrentUser().id)
|
||||
!= STRONG_AUTH_REQUIRED_AFTER_BOOT;
|
||||
}
|
||||
|
||||
private boolean controlsAvailable() {
|
||||
@@ -2601,10 +2606,18 @@ public class GlobalActionsDialog implements DialogInterface.OnDismissListener,
|
||||
&& !mControlsServiceInfos.isEmpty();
|
||||
}
|
||||
|
||||
private boolean shouldShowLockMessage(boolean walletViewAvailable) {
|
||||
private boolean walletViewAvailable() {
|
||||
GlobalActionsPanelPlugin.PanelViewController walletViewController =
|
||||
getWalletViewController();
|
||||
return walletViewController != null && walletViewController.getPanelContent() != null;
|
||||
}
|
||||
|
||||
private boolean shouldShowLockMessage() {
|
||||
boolean isLockedAfterBoot = mLockPatternUtils.getStrongAuthForUser(getCurrentUser().id)
|
||||
== STRONG_AUTH_REQUIRED_AFTER_BOOT;
|
||||
return !mKeyguardStateController.isUnlocked()
|
||||
&& !mShowLockScreenCardsAndControls
|
||||
&& (controlsAvailable() || walletViewAvailable);
|
||||
&& (!mShowLockScreenCardsAndControls || isLockedAfterBoot)
|
||||
&& (controlsAvailable() || walletViewAvailable());
|
||||
}
|
||||
|
||||
private void onPowerMenuLockScreenSettingsChanged() {
|
||||
|
||||
@@ -16,6 +16,8 @@
|
||||
|
||||
package com.android.systemui.globalactions;
|
||||
|
||||
import static com.android.internal.widget.LockPatternUtils.StrongAuthTracker.STRONG_AUTH_NOT_REQUIRED;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import static junit.framework.Assert.assertEquals;
|
||||
@@ -34,11 +36,13 @@ import android.app.IActivityManager;
|
||||
import android.app.admin.DevicePolicyManager;
|
||||
import android.app.trust.TrustManager;
|
||||
import android.content.ContentResolver;
|
||||
import android.content.pm.UserInfo;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.Color;
|
||||
import android.media.AudioManager;
|
||||
import android.net.ConnectivityManager;
|
||||
import android.os.Handler;
|
||||
import android.os.RemoteException;
|
||||
import android.os.UserManager;
|
||||
import android.service.dreams.IDreamManager;
|
||||
import android.telephony.TelephonyManager;
|
||||
@@ -424,10 +428,12 @@ public class GlobalActionsDialogTest extends SysuiTestCase {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testShouldShowLockScreenMessage() {
|
||||
public void testShouldShowLockScreenMessage() throws RemoteException {
|
||||
mGlobalActionsDialog = spy(mGlobalActionsDialog);
|
||||
mGlobalActionsDialog.mDialog = null;
|
||||
when(mKeyguardStateController.isUnlocked()).thenReturn(false);
|
||||
when(mActivityManager.getCurrentUser()).thenReturn(newUserInfo());
|
||||
when(mLockPatternUtils.getStrongAuthForUser(anyInt())).thenReturn(STRONG_AUTH_NOT_REQUIRED);
|
||||
mGlobalActionsDialog.mShowLockScreenCardsAndControls = false;
|
||||
setupDefaultActions();
|
||||
when(mWalletPlugin.onPanelShown(any(), anyBoolean())).thenReturn(mWalletController);
|
||||
@@ -444,10 +450,13 @@ public class GlobalActionsDialogTest extends SysuiTestCase {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testShouldNotShowLockScreenMessage_whenWalletOrControlsShownOnLockScreen() {
|
||||
public void testShouldNotShowLockScreenMessage_whenWalletOrControlsShownOnLockScreen()
|
||||
throws RemoteException {
|
||||
mGlobalActionsDialog = spy(mGlobalActionsDialog);
|
||||
mGlobalActionsDialog.mDialog = null;
|
||||
when(mKeyguardStateController.isUnlocked()).thenReturn(false);
|
||||
when(mActivityManager.getCurrentUser()).thenReturn(newUserInfo());
|
||||
when(mLockPatternUtils.getStrongAuthForUser(anyInt())).thenReturn(STRONG_AUTH_NOT_REQUIRED);
|
||||
mGlobalActionsDialog.mShowLockScreenCardsAndControls = true;
|
||||
setupDefaultActions();
|
||||
when(mWalletPlugin.onPanelShown(any(), anyBoolean())).thenReturn(mWalletController);
|
||||
@@ -464,10 +473,14 @@ public class GlobalActionsDialogTest extends SysuiTestCase {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testShouldNotShowLockScreenMessage_whenControlsAndWalletBothDisabled() {
|
||||
public void testShouldNotShowLockScreenMessage_whenControlsAndWalletBothDisabled()
|
||||
throws RemoteException {
|
||||
mGlobalActionsDialog = spy(mGlobalActionsDialog);
|
||||
mGlobalActionsDialog.mDialog = null;
|
||||
when(mKeyguardStateController.isUnlocked()).thenReturn(false);
|
||||
|
||||
when(mActivityManager.getCurrentUser()).thenReturn(newUserInfo());
|
||||
when(mLockPatternUtils.getStrongAuthForUser(anyInt())).thenReturn(STRONG_AUTH_NOT_REQUIRED);
|
||||
mGlobalActionsDialog.mShowLockScreenCardsAndControls = true;
|
||||
setupDefaultActions();
|
||||
when(mWalletPlugin.onPanelShown(any(), anyBoolean())).thenReturn(mWalletController);
|
||||
@@ -484,6 +497,10 @@ public class GlobalActionsDialogTest extends SysuiTestCase {
|
||||
mGlobalActionsDialog.showOrHideDialog(false, true, mWalletPlugin);
|
||||
}
|
||||
|
||||
private UserInfo newUserInfo() {
|
||||
return new UserInfo(0, null, null, UserInfo.FLAG_PRIMARY, null);
|
||||
}
|
||||
|
||||
private void setupDefaultActions() {
|
||||
String[] actions = {
|
||||
GlobalActionsDialog.GLOBAL_ACTION_KEY_POWER,
|
||||
|
||||
Reference in New Issue
Block a user