Merge "Fix TrustAgent showing unclear string." into tm-qpr-dev am: 06cbc8c0f5
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/20555844 Change-Id: Ie1ef2e87eb7677647b9d40fd4753af1213c9f4cd Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -1522,7 +1522,8 @@ public class LockPatternUtils {
|
|||||||
STRONG_AUTH_REQUIRED_AFTER_LOCKOUT,
|
STRONG_AUTH_REQUIRED_AFTER_LOCKOUT,
|
||||||
STRONG_AUTH_REQUIRED_AFTER_TIMEOUT,
|
STRONG_AUTH_REQUIRED_AFTER_TIMEOUT,
|
||||||
STRONG_AUTH_REQUIRED_AFTER_USER_LOCKDOWN,
|
STRONG_AUTH_REQUIRED_AFTER_USER_LOCKDOWN,
|
||||||
STRONG_AUTH_REQUIRED_AFTER_NON_STRONG_BIOMETRICS_TIMEOUT})
|
STRONG_AUTH_REQUIRED_AFTER_NON_STRONG_BIOMETRICS_TIMEOUT,
|
||||||
|
SOME_AUTH_REQUIRED_AFTER_TRUSTAGENT_EXPIRED})
|
||||||
@Retention(RetentionPolicy.SOURCE)
|
@Retention(RetentionPolicy.SOURCE)
|
||||||
public @interface StrongAuthFlags {}
|
public @interface StrongAuthFlags {}
|
||||||
|
|
||||||
@@ -1574,12 +1575,19 @@ public class LockPatternUtils {
|
|||||||
*/
|
*/
|
||||||
public static final int STRONG_AUTH_REQUIRED_AFTER_NON_STRONG_BIOMETRICS_TIMEOUT = 0x80;
|
public static final int STRONG_AUTH_REQUIRED_AFTER_NON_STRONG_BIOMETRICS_TIMEOUT = 0x80;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Some authentication is required because the trustagent either timed out or was disabled
|
||||||
|
* manually.
|
||||||
|
*/
|
||||||
|
public static final int SOME_AUTH_REQUIRED_AFTER_TRUSTAGENT_EXPIRED = 0x100;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Strong auth flags that do not prevent biometric methods from being accepted as auth.
|
* Strong auth flags that do not prevent biometric methods from being accepted as auth.
|
||||||
* If any other flags are set, biometric authentication is disabled.
|
* If any other flags are set, biometric authentication is disabled.
|
||||||
*/
|
*/
|
||||||
private static final int ALLOWING_BIOMETRIC = STRONG_AUTH_NOT_REQUIRED
|
private static final int ALLOWING_BIOMETRIC = STRONG_AUTH_NOT_REQUIRED
|
||||||
| SOME_AUTH_REQUIRED_AFTER_USER_REQUEST;
|
| SOME_AUTH_REQUIRED_AFTER_USER_REQUEST
|
||||||
|
| SOME_AUTH_REQUIRED_AFTER_TRUSTAGENT_EXPIRED;
|
||||||
|
|
||||||
private final SparseIntArray mStrongAuthRequiredForUser = new SparseIntArray();
|
private final SparseIntArray mStrongAuthRequiredForUser = new SparseIntArray();
|
||||||
private final H mHandler;
|
private final H mHandler;
|
||||||
|
|||||||
@@ -19,6 +19,9 @@ package com.android.internal.util;
|
|||||||
import static android.app.admin.DevicePolicyManager.PASSWORD_QUALITY_MANAGED;
|
import static android.app.admin.DevicePolicyManager.PASSWORD_QUALITY_MANAGED;
|
||||||
import static android.app.admin.DevicePolicyManager.PASSWORD_QUALITY_UNSPECIFIED;
|
import static android.app.admin.DevicePolicyManager.PASSWORD_QUALITY_UNSPECIFIED;
|
||||||
|
|
||||||
|
import static com.android.internal.widget.LockPatternUtils.StrongAuthTracker.SOME_AUTH_REQUIRED_AFTER_TRUSTAGENT_EXPIRED;
|
||||||
|
import static com.android.internal.widget.LockPatternUtils.StrongAuthTracker.STRONG_AUTH_REQUIRED_AFTER_LOCKOUT;
|
||||||
|
|
||||||
import static com.google.common.truth.Truth.assertThat;
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
|
|
||||||
import static org.junit.Assert.assertFalse;
|
import static org.junit.Assert.assertFalse;
|
||||||
@@ -37,6 +40,7 @@ import android.content.ComponentName;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.ContextWrapper;
|
import android.content.ContextWrapper;
|
||||||
import android.content.pm.UserInfo;
|
import android.content.pm.UserInfo;
|
||||||
|
import android.os.Looper;
|
||||||
import android.os.RemoteException;
|
import android.os.RemoteException;
|
||||||
import android.os.UserManager;
|
import android.os.UserManager;
|
||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
@@ -233,6 +237,45 @@ public class LockPatternUtilsTest {
|
|||||||
ComponentName.unflattenFromString("com.test/.TestAgent"));
|
ComponentName.unflattenFromString("com.test/.TestAgent"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void isBiometricAllowedForUser_afterTrustagentExpired_returnsTrue()
|
||||||
|
throws RemoteException {
|
||||||
|
TestStrongAuthTracker tracker = createStrongAuthTracker();
|
||||||
|
tracker.changeStrongAuth(SOME_AUTH_REQUIRED_AFTER_TRUSTAGENT_EXPIRED);
|
||||||
|
|
||||||
|
assertTrue(tracker.isBiometricAllowedForUser(
|
||||||
|
/* isStrongBiometric = */ true,
|
||||||
|
DEMO_USER_ID));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void isBiometricAllowedForUser_afterLockout_returnsFalse()
|
||||||
|
throws RemoteException {
|
||||||
|
TestStrongAuthTracker tracker = createStrongAuthTracker();
|
||||||
|
tracker.changeStrongAuth(STRONG_AUTH_REQUIRED_AFTER_LOCKOUT);
|
||||||
|
|
||||||
|
assertFalse(tracker.isBiometricAllowedForUser(
|
||||||
|
/* isStrongBiometric = */ true,
|
||||||
|
DEMO_USER_ID));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private TestStrongAuthTracker createStrongAuthTracker() {
|
||||||
|
final Context context = new ContextWrapper(InstrumentationRegistry.getTargetContext());
|
||||||
|
return new TestStrongAuthTracker(context, Looper.getMainLooper());
|
||||||
|
}
|
||||||
|
|
||||||
|
private static class TestStrongAuthTracker extends LockPatternUtils.StrongAuthTracker {
|
||||||
|
|
||||||
|
TestStrongAuthTracker(Context context, Looper looper) {
|
||||||
|
super(context, looper);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void changeStrongAuth(@StrongAuthFlags int strongAuthFlags) {
|
||||||
|
handleStrongAuthRequiredChanged(strongAuthFlags, DEMO_USER_ID);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private ILockSettings createTestLockSettings() {
|
private ILockSettings createTestLockSettings() {
|
||||||
final Context context = spy(new ContextWrapper(InstrumentationRegistry.getTargetContext()));
|
final Context context = spy(new ContextWrapper(InstrumentationRegistry.getTargetContext()));
|
||||||
mLockPatternUtils = spy(new LockPatternUtils(context));
|
mLockPatternUtils = spy(new LockPatternUtils(context));
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ import static com.android.keyguard.KeyguardSecurityView.PROMPT_REASON_NON_STRONG
|
|||||||
import static com.android.keyguard.KeyguardSecurityView.PROMPT_REASON_PREPARE_FOR_UPDATE;
|
import static com.android.keyguard.KeyguardSecurityView.PROMPT_REASON_PREPARE_FOR_UPDATE;
|
||||||
import static com.android.keyguard.KeyguardSecurityView.PROMPT_REASON_RESTART;
|
import static com.android.keyguard.KeyguardSecurityView.PROMPT_REASON_RESTART;
|
||||||
import static com.android.keyguard.KeyguardSecurityView.PROMPT_REASON_TIMEOUT;
|
import static com.android.keyguard.KeyguardSecurityView.PROMPT_REASON_TIMEOUT;
|
||||||
|
import static com.android.keyguard.KeyguardSecurityView.PROMPT_REASON_TRUSTAGENT_EXPIRED;
|
||||||
import static com.android.keyguard.KeyguardSecurityView.PROMPT_REASON_USER_REQUEST;
|
import static com.android.keyguard.KeyguardSecurityView.PROMPT_REASON_USER_REQUEST;
|
||||||
|
|
||||||
import android.animation.Animator;
|
import android.animation.Animator;
|
||||||
@@ -107,6 +108,8 @@ public class KeyguardPasswordView extends KeyguardAbsKeyInputView {
|
|||||||
return R.string.kg_prompt_reason_timeout_password;
|
return R.string.kg_prompt_reason_timeout_password;
|
||||||
case PROMPT_REASON_NON_STRONG_BIOMETRIC_TIMEOUT:
|
case PROMPT_REASON_NON_STRONG_BIOMETRIC_TIMEOUT:
|
||||||
return R.string.kg_prompt_reason_timeout_password;
|
return R.string.kg_prompt_reason_timeout_password;
|
||||||
|
case PROMPT_REASON_TRUSTAGENT_EXPIRED:
|
||||||
|
return R.string.kg_prompt_reason_timeout_password;
|
||||||
case PROMPT_REASON_NONE:
|
case PROMPT_REASON_NONE:
|
||||||
return 0;
|
return 0;
|
||||||
default:
|
default:
|
||||||
|
|||||||
@@ -313,6 +313,9 @@ public class KeyguardPatternViewController
|
|||||||
case PROMPT_REASON_NON_STRONG_BIOMETRIC_TIMEOUT:
|
case PROMPT_REASON_NON_STRONG_BIOMETRIC_TIMEOUT:
|
||||||
mMessageAreaController.setMessage(R.string.kg_prompt_reason_timeout_pattern);
|
mMessageAreaController.setMessage(R.string.kg_prompt_reason_timeout_pattern);
|
||||||
break;
|
break;
|
||||||
|
case PROMPT_REASON_TRUSTAGENT_EXPIRED:
|
||||||
|
mMessageAreaController.setMessage(R.string.kg_prompt_reason_timeout_pattern);
|
||||||
|
break;
|
||||||
case PROMPT_REASON_NONE:
|
case PROMPT_REASON_NONE:
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ import static com.android.keyguard.KeyguardSecurityView.PROMPT_REASON_NON_STRONG
|
|||||||
import static com.android.keyguard.KeyguardSecurityView.PROMPT_REASON_PREPARE_FOR_UPDATE;
|
import static com.android.keyguard.KeyguardSecurityView.PROMPT_REASON_PREPARE_FOR_UPDATE;
|
||||||
import static com.android.keyguard.KeyguardSecurityView.PROMPT_REASON_RESTART;
|
import static com.android.keyguard.KeyguardSecurityView.PROMPT_REASON_RESTART;
|
||||||
import static com.android.keyguard.KeyguardSecurityView.PROMPT_REASON_TIMEOUT;
|
import static com.android.keyguard.KeyguardSecurityView.PROMPT_REASON_TIMEOUT;
|
||||||
|
import static com.android.keyguard.KeyguardSecurityView.PROMPT_REASON_TRUSTAGENT_EXPIRED;
|
||||||
import static com.android.keyguard.KeyguardSecurityView.PROMPT_REASON_USER_REQUEST;
|
import static com.android.keyguard.KeyguardSecurityView.PROMPT_REASON_USER_REQUEST;
|
||||||
|
|
||||||
import android.animation.Animator;
|
import android.animation.Animator;
|
||||||
@@ -123,6 +124,8 @@ public abstract class KeyguardPinBasedInputView extends KeyguardAbsKeyInputView
|
|||||||
return R.string.kg_prompt_reason_timeout_pin;
|
return R.string.kg_prompt_reason_timeout_pin;
|
||||||
case PROMPT_REASON_NON_STRONG_BIOMETRIC_TIMEOUT:
|
case PROMPT_REASON_NON_STRONG_BIOMETRIC_TIMEOUT:
|
||||||
return R.string.kg_prompt_reason_timeout_pin;
|
return R.string.kg_prompt_reason_timeout_pin;
|
||||||
|
case PROMPT_REASON_TRUSTAGENT_EXPIRED:
|
||||||
|
return R.string.kg_prompt_reason_timeout_pin;
|
||||||
case PROMPT_REASON_NONE:
|
case PROMPT_REASON_NONE:
|
||||||
return 0;
|
return 0;
|
||||||
default:
|
default:
|
||||||
|
|||||||
@@ -60,6 +60,12 @@ public interface KeyguardSecurityView {
|
|||||||
*/
|
*/
|
||||||
int PROMPT_REASON_NON_STRONG_BIOMETRIC_TIMEOUT = 7;
|
int PROMPT_REASON_NON_STRONG_BIOMETRIC_TIMEOUT = 7;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Some auth is required because the trustagent expired either from timeout or manually by the
|
||||||
|
* user
|
||||||
|
*/
|
||||||
|
int PROMPT_REASON_TRUSTAGENT_EXPIRED = 8;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reset the view and prepare to take input. This should do things like clearing the
|
* Reset the view and prepare to take input. This should do things like clearing the
|
||||||
* password or pattern and clear error messages.
|
* password or pattern and clear error messages.
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ import static com.android.internal.config.sysui.SystemUiDeviceConfigFlags.NAV_BA
|
|||||||
import static com.android.internal.jank.InteractionJankMonitor.CUJ_LOCKSCREEN_OCCLUSION;
|
import static com.android.internal.jank.InteractionJankMonitor.CUJ_LOCKSCREEN_OCCLUSION;
|
||||||
import static com.android.internal.jank.InteractionJankMonitor.CUJ_LOCKSCREEN_TRANSITION_FROM_AOD;
|
import static com.android.internal.jank.InteractionJankMonitor.CUJ_LOCKSCREEN_TRANSITION_FROM_AOD;
|
||||||
import static com.android.internal.jank.InteractionJankMonitor.CUJ_LOCKSCREEN_UNLOCK_ANIMATION;
|
import static com.android.internal.jank.InteractionJankMonitor.CUJ_LOCKSCREEN_UNLOCK_ANIMATION;
|
||||||
|
import static com.android.internal.widget.LockPatternUtils.StrongAuthTracker.SOME_AUTH_REQUIRED_AFTER_TRUSTAGENT_EXPIRED;
|
||||||
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_REQUIRED_AFTER_DPM_LOCK_NOW;
|
import static com.android.internal.widget.LockPatternUtils.StrongAuthTracker.STRONG_AUTH_REQUIRED_AFTER_DPM_LOCK_NOW;
|
||||||
import static com.android.internal.widget.LockPatternUtils.StrongAuthTracker.STRONG_AUTH_REQUIRED_AFTER_LOCKOUT;
|
import static com.android.internal.widget.LockPatternUtils.StrongAuthTracker.STRONG_AUTH_REQUIRED_AFTER_LOCKOUT;
|
||||||
@@ -142,12 +143,12 @@ import com.android.systemui.statusbar.policy.KeyguardStateController;
|
|||||||
import com.android.systemui.statusbar.policy.UserSwitcherController;
|
import com.android.systemui.statusbar.policy.UserSwitcherController;
|
||||||
import com.android.systemui.util.DeviceConfigProxy;
|
import com.android.systemui.util.DeviceConfigProxy;
|
||||||
|
|
||||||
|
import dagger.Lazy;
|
||||||
|
|
||||||
import java.io.PrintWriter;
|
import java.io.PrintWriter;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.concurrent.Executor;
|
import java.util.concurrent.Executor;
|
||||||
|
|
||||||
import dagger.Lazy;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Mediates requests related to the keyguard. This includes queries about the
|
* Mediates requests related to the keyguard. This includes queries about the
|
||||||
* state of the keyguard, power management events that effect whether the keyguard
|
* state of the keyguard, power management events that effect whether the keyguard
|
||||||
@@ -821,6 +822,9 @@ public class KeyguardViewMediator implements CoreStartable, Dumpable,
|
|||||||
} else if (trustAgentsEnabled
|
} else if (trustAgentsEnabled
|
||||||
&& (strongAuth & SOME_AUTH_REQUIRED_AFTER_USER_REQUEST) != 0) {
|
&& (strongAuth & SOME_AUTH_REQUIRED_AFTER_USER_REQUEST) != 0) {
|
||||||
return KeyguardSecurityView.PROMPT_REASON_USER_REQUEST;
|
return KeyguardSecurityView.PROMPT_REASON_USER_REQUEST;
|
||||||
|
} else if (trustAgentsEnabled
|
||||||
|
&& (strongAuth & SOME_AUTH_REQUIRED_AFTER_TRUSTAGENT_EXPIRED) != 0) {
|
||||||
|
return KeyguardSecurityView.PROMPT_REASON_TRUSTAGENT_EXPIRED;
|
||||||
} else if (any && ((strongAuth & STRONG_AUTH_REQUIRED_AFTER_LOCKOUT) != 0
|
} else if (any && ((strongAuth & STRONG_AUTH_REQUIRED_AFTER_LOCKOUT) != 0
|
||||||
|| mUpdateMonitor.isFingerprintLockedOut())) {
|
|| mUpdateMonitor.isFingerprintLockedOut())) {
|
||||||
return KeyguardSecurityView.PROMPT_REASON_AFTER_LOCKOUT;
|
return KeyguardSecurityView.PROMPT_REASON_AFTER_LOCKOUT;
|
||||||
|
|||||||
@@ -690,7 +690,7 @@ public class TrustManagerService extends SystemService {
|
|||||||
*/
|
*/
|
||||||
public void lockUser(int userId) {
|
public void lockUser(int userId) {
|
||||||
mLockPatternUtils.requireStrongAuth(
|
mLockPatternUtils.requireStrongAuth(
|
||||||
StrongAuthTracker.SOME_AUTH_REQUIRED_AFTER_USER_REQUEST, userId);
|
StrongAuthTracker.SOME_AUTH_REQUIRED_AFTER_TRUSTAGENT_EXPIRED, userId);
|
||||||
try {
|
try {
|
||||||
WindowManagerGlobal.getWindowManagerService().lockNow(null);
|
WindowManagerGlobal.getWindowManagerService().lockNow(null);
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
@@ -2087,7 +2087,7 @@ public class TrustManagerService extends SystemService {
|
|||||||
if (mStrongAuthTracker.isTrustAllowedForUser(mUserId)) {
|
if (mStrongAuthTracker.isTrustAllowedForUser(mUserId)) {
|
||||||
if (DEBUG) Slog.d(TAG, "Revoking all trust because of trust timeout");
|
if (DEBUG) Slog.d(TAG, "Revoking all trust because of trust timeout");
|
||||||
mLockPatternUtils.requireStrongAuth(
|
mLockPatternUtils.requireStrongAuth(
|
||||||
mStrongAuthTracker.SOME_AUTH_REQUIRED_AFTER_USER_REQUEST, mUserId);
|
mStrongAuthTracker.SOME_AUTH_REQUIRED_AFTER_TRUSTAGENT_EXPIRED, mUserId);
|
||||||
}
|
}
|
||||||
maybeLockScreen(mUserId);
|
maybeLockScreen(mUserId);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user