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