Merge changes from topic "b/159260556" into rvc-dev am: 5731877f1e am: 2738860066
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/11905665 Change-Id: Ieb2cc275f0a1b963dbad81aee16ca5e81b00b9cc
This commit is contained in:
@@ -79,7 +79,6 @@ import android.telephony.SubscriptionInfo;
|
|||||||
import android.telephony.SubscriptionManager;
|
import android.telephony.SubscriptionManager;
|
||||||
import android.telephony.SubscriptionManager.OnSubscriptionsChangedListener;
|
import android.telephony.SubscriptionManager.OnSubscriptionsChangedListener;
|
||||||
import android.telephony.TelephonyManager;
|
import android.telephony.TelephonyManager;
|
||||||
import android.util.EventLog;
|
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.util.SparseArray;
|
import android.util.SparseArray;
|
||||||
import android.util.SparseBooleanArray;
|
import android.util.SparseBooleanArray;
|
||||||
@@ -1075,17 +1074,6 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
|
|||||||
!= LockPatternUtils.StrongAuthTracker.STRONG_AUTH_NOT_REQUIRED;
|
!= LockPatternUtils.StrongAuthTracker.STRONG_AUTH_NOT_REQUIRED;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isUserEncryptedOrLockdown(int userId) {
|
|
||||||
// Biometrics should not be started in this case. Think carefully before modifying this
|
|
||||||
// method, see b/79776455
|
|
||||||
final int strongAuth = mStrongAuthTracker.getStrongAuthForUser(userId);
|
|
||||||
final boolean isLockDown =
|
|
||||||
containsFlag(strongAuth, STRONG_AUTH_REQUIRED_AFTER_DPM_LOCK_NOW)
|
|
||||||
|| containsFlag(strongAuth, STRONG_AUTH_REQUIRED_AFTER_USER_LOCKDOWN);
|
|
||||||
final boolean isEncrypted = containsFlag(strongAuth, STRONG_AUTH_REQUIRED_AFTER_BOOT);
|
|
||||||
return isLockDown || isEncrypted;
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean containsFlag(int haystack, int needle) {
|
private boolean containsFlag(int haystack, int needle) {
|
||||||
return (haystack & needle) != 0;
|
return (haystack & needle) != 0;
|
||||||
}
|
}
|
||||||
@@ -1915,7 +1903,6 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
|
|||||||
private boolean shouldListenForFingerprint() {
|
private boolean shouldListenForFingerprint() {
|
||||||
final boolean allowedOnBouncer =
|
final boolean allowedOnBouncer =
|
||||||
!(mFingerprintLockedOut && mBouncer && mCredentialAttempted);
|
!(mFingerprintLockedOut && mBouncer && mCredentialAttempted);
|
||||||
final int user = getCurrentUser();
|
|
||||||
|
|
||||||
// Only listen if this KeyguardUpdateMonitor belongs to the primary user. There is an
|
// Only listen if this KeyguardUpdateMonitor belongs to the primary user. There is an
|
||||||
// instance of KeyguardUpdateMonitor for each user but KeyguardUpdateMonitor is user-aware.
|
// instance of KeyguardUpdateMonitor for each user but KeyguardUpdateMonitor is user-aware.
|
||||||
@@ -1924,7 +1911,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
|
|||||||
shouldListenForFingerprintAssistant() || (mKeyguardOccluded && mIsDreaming))
|
shouldListenForFingerprintAssistant() || (mKeyguardOccluded && mIsDreaming))
|
||||||
&& !mSwitchingUser && !isFingerprintDisabled(getCurrentUser())
|
&& !mSwitchingUser && !isFingerprintDisabled(getCurrentUser())
|
||||||
&& (!mKeyguardGoingAway || !mDeviceInteractive) && mIsPrimaryUser
|
&& (!mKeyguardGoingAway || !mDeviceInteractive) && mIsPrimaryUser
|
||||||
&& allowedOnBouncer && !isUserEncryptedOrLockdown(user);
|
&& allowedOnBouncer;
|
||||||
return shouldListen;
|
return shouldListen;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1938,8 +1925,12 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
|
|||||||
&& !statusBarShadeLocked;
|
&& !statusBarShadeLocked;
|
||||||
final int user = getCurrentUser();
|
final int user = getCurrentUser();
|
||||||
final int strongAuth = mStrongAuthTracker.getStrongAuthForUser(user);
|
final int strongAuth = mStrongAuthTracker.getStrongAuthForUser(user);
|
||||||
final boolean isTimedOut =
|
final boolean isLockDown =
|
||||||
containsFlag(strongAuth, STRONG_AUTH_REQUIRED_AFTER_TIMEOUT);
|
containsFlag(strongAuth, STRONG_AUTH_REQUIRED_AFTER_DPM_LOCK_NOW)
|
||||||
|
|| containsFlag(strongAuth, STRONG_AUTH_REQUIRED_AFTER_USER_LOCKDOWN);
|
||||||
|
final boolean isEncryptedOrTimedOut =
|
||||||
|
containsFlag(strongAuth, STRONG_AUTH_REQUIRED_AFTER_BOOT)
|
||||||
|
|| containsFlag(strongAuth, STRONG_AUTH_REQUIRED_AFTER_TIMEOUT);
|
||||||
|
|
||||||
boolean canBypass = mKeyguardBypassController != null
|
boolean canBypass = mKeyguardBypassController != null
|
||||||
&& mKeyguardBypassController.canBypass();
|
&& mKeyguardBypassController.canBypass();
|
||||||
@@ -1948,9 +1939,10 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
|
|||||||
// TrustAgents or biometrics are keeping the device unlocked.
|
// TrustAgents or biometrics are keeping the device unlocked.
|
||||||
boolean becauseCannotSkipBouncer = !getUserCanSkipBouncer(user) || canBypass;
|
boolean becauseCannotSkipBouncer = !getUserCanSkipBouncer(user) || canBypass;
|
||||||
|
|
||||||
// Scan even when timeout to show a preemptive bouncer when bypassing.
|
// Scan even when encrypted or timeout to show a preemptive bouncer when bypassing.
|
||||||
// Lock-down mode shouldn't scan, since it is more explicit.
|
// Lock-down mode shouldn't scan, since it is more explicit.
|
||||||
boolean strongAuthAllowsScanning = (!isTimedOut || canBypass && !mBouncer);
|
boolean strongAuthAllowsScanning = (!isEncryptedOrTimedOut || canBypass && !mBouncer)
|
||||||
|
&& !isLockDown;
|
||||||
|
|
||||||
// Only listen if this KeyguardUpdateMonitor belongs to the primary user. There is an
|
// Only listen if this KeyguardUpdateMonitor belongs to the primary user. There is an
|
||||||
// instance of KeyguardUpdateMonitor for each user but KeyguardUpdateMonitor is user-aware.
|
// instance of KeyguardUpdateMonitor for each user but KeyguardUpdateMonitor is user-aware.
|
||||||
@@ -1960,7 +1952,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
|
|||||||
&& !mSwitchingUser && !isFaceDisabled(user) && becauseCannotSkipBouncer
|
&& !mSwitchingUser && !isFaceDisabled(user) && becauseCannotSkipBouncer
|
||||||
&& !mKeyguardGoingAway && mFaceSettingEnabledForUser.get(user) && !mLockIconPressed
|
&& !mKeyguardGoingAway && mFaceSettingEnabledForUser.get(user) && !mLockIconPressed
|
||||||
&& strongAuthAllowsScanning && mIsPrimaryUser
|
&& strongAuthAllowsScanning && mIsPrimaryUser
|
||||||
&& !mSecureCameraLaunched && !isUserEncryptedOrLockdown(user);
|
&& !mSecureCameraLaunched;
|
||||||
|
|
||||||
// Aggregate relevant fields for debug logging.
|
// Aggregate relevant fields for debug logging.
|
||||||
if (DEBUG_FACE || DEBUG_SPEW) {
|
if (DEBUG_FACE || DEBUG_SPEW) {
|
||||||
@@ -2033,11 +2025,6 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
|
|||||||
if (mFingerprintCancelSignal != null) {
|
if (mFingerprintCancelSignal != null) {
|
||||||
mFingerprintCancelSignal.cancel();
|
mFingerprintCancelSignal.cancel();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isUserEncryptedOrLockdown(userId)) {
|
|
||||||
// If this happens, shouldListenForFingerprint() is wrong. SafetyNet for b/79776455
|
|
||||||
EventLog.writeEvent(0x534e4554, "79776455", "startListeningForFingerprint");
|
|
||||||
}
|
|
||||||
mFingerprintCancelSignal = new CancellationSignal();
|
mFingerprintCancelSignal = new CancellationSignal();
|
||||||
mFpm.authenticate(null, mFingerprintCancelSignal, 0, mFingerprintAuthenticationCallback,
|
mFpm.authenticate(null, mFingerprintCancelSignal, 0, mFingerprintAuthenticationCallback,
|
||||||
null, userId);
|
null, userId);
|
||||||
@@ -2056,11 +2043,6 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
|
|||||||
if (mFaceCancelSignal != null) {
|
if (mFaceCancelSignal != null) {
|
||||||
mFaceCancelSignal.cancel();
|
mFaceCancelSignal.cancel();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isUserEncryptedOrLockdown(userId)) {
|
|
||||||
// If this happens, shouldListenForFace() is wrong. SafetyNet for b/79776455
|
|
||||||
EventLog.writeEvent(0x534e4554, "79776455", "startListeningForFace");
|
|
||||||
}
|
|
||||||
mFaceCancelSignal = new CancellationSignal();
|
mFaceCancelSignal = new CancellationSignal();
|
||||||
mFaceManager.authenticate(null, mFaceCancelSignal, 0,
|
mFaceManager.authenticate(null, mFaceCancelSignal, 0,
|
||||||
mFaceAuthenticationCallback, null, userId);
|
mFaceAuthenticationCallback, null, userId);
|
||||||
|
|||||||
@@ -451,6 +451,12 @@ public class KeyguardUpdateMonitorTest extends SysuiTestCase {
|
|||||||
verify(mFaceManager, never()).authenticate(any(), any(), anyInt(), any(), any(), anyInt());
|
verify(mFaceManager, never()).authenticate(any(), any(), anyInt(), any(), any(), anyInt());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void requiresAuthentication_whenEncryptedKeyguard_andBypass() {
|
||||||
|
testStrongAuthExceptOnBouncer(
|
||||||
|
KeyguardUpdateMonitor.StrongAuthTracker.STRONG_AUTH_REQUIRED_AFTER_BOOT);
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void requiresAuthentication_whenTimeoutKeyguard_andBypass() {
|
public void requiresAuthentication_whenTimeoutKeyguard_andBypass() {
|
||||||
testStrongAuthExceptOnBouncer(
|
testStrongAuthExceptOnBouncer(
|
||||||
@@ -507,20 +513,10 @@ public class KeyguardUpdateMonitorTest extends SysuiTestCase {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testIgnoresAuth_whenLockdown() {
|
public void testIgnoresAuth_whenLockdown() {
|
||||||
testIgnoresAuth(
|
|
||||||
KeyguardUpdateMonitor.StrongAuthTracker.STRONG_AUTH_REQUIRED_AFTER_USER_LOCKDOWN);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testIgnoresAuth_whenEncrypted() {
|
|
||||||
testIgnoresAuth(
|
|
||||||
KeyguardUpdateMonitor.StrongAuthTracker.STRONG_AUTH_REQUIRED_AFTER_BOOT);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void testIgnoresAuth(int strongAuth) {
|
|
||||||
mKeyguardUpdateMonitor.dispatchStartedWakingUp();
|
mKeyguardUpdateMonitor.dispatchStartedWakingUp();
|
||||||
mTestableLooper.processAllMessages();
|
mTestableLooper.processAllMessages();
|
||||||
when(mStrongAuthTracker.getStrongAuthForUser(anyInt())).thenReturn(strongAuth);
|
when(mStrongAuthTracker.getStrongAuthForUser(anyInt())).thenReturn(
|
||||||
|
KeyguardUpdateMonitor.StrongAuthTracker.STRONG_AUTH_REQUIRED_AFTER_USER_LOCKDOWN);
|
||||||
|
|
||||||
mKeyguardUpdateMonitor.onKeyguardVisibilityChanged(true);
|
mKeyguardUpdateMonitor.onKeyguardVisibilityChanged(true);
|
||||||
verify(mFaceManager, never()).authenticate(any(), any(), anyInt(), any(), any(), anyInt());
|
verify(mFaceManager, never()).authenticate(any(), any(), anyInt(), any(), any(), anyInt());
|
||||||
|
|||||||
Reference in New Issue
Block a user