Merge "4/ Add config_face_auth_supported_posture to listen for Face by posture" into tm-qpr-dev
This commit is contained in:
@@ -668,6 +668,16 @@
|
|||||||
<item>17</item> <!-- WAKE_REASON_BIOMETRIC -->
|
<item>17</item> <!-- WAKE_REASON_BIOMETRIC -->
|
||||||
</integer-array>
|
</integer-array>
|
||||||
|
|
||||||
|
<!-- Whether to support posture listening for face auth, default is 0(DEVICE_POSTURE_UNKNOWN)
|
||||||
|
means systemui will try listening on all postures.
|
||||||
|
0 : DEVICE_POSTURE_UNKNOWN
|
||||||
|
1 : DEVICE_POSTURE_CLOSED
|
||||||
|
2 : DEVICE_POSTURE_HALF_OPENED
|
||||||
|
3 : DEVICE_POSTURE_OPENED
|
||||||
|
4 : DEVICE_POSTURE_FLIPPED
|
||||||
|
-->
|
||||||
|
<integer name="config_face_auth_supported_posture">0</integer>
|
||||||
|
|
||||||
<!-- Whether the communal service should be enabled -->
|
<!-- Whether the communal service should be enabled -->
|
||||||
<bool name="config_communalServiceEnabled">false</bool>
|
<bool name="config_communalServiceEnabled">false</bool>
|
||||||
|
|
||||||
|
|||||||
@@ -50,6 +50,7 @@ import com.android.keyguard.InternalFaceAuthReasons.KEYGUARD_RESET
|
|||||||
import com.android.keyguard.InternalFaceAuthReasons.KEYGUARD_VISIBILITY_CHANGED
|
import com.android.keyguard.InternalFaceAuthReasons.KEYGUARD_VISIBILITY_CHANGED
|
||||||
import com.android.keyguard.InternalFaceAuthReasons.NON_STRONG_BIOMETRIC_ALLOWED_CHANGED
|
import com.android.keyguard.InternalFaceAuthReasons.NON_STRONG_BIOMETRIC_ALLOWED_CHANGED
|
||||||
import com.android.keyguard.InternalFaceAuthReasons.OCCLUDING_APP_REQUESTED
|
import com.android.keyguard.InternalFaceAuthReasons.OCCLUDING_APP_REQUESTED
|
||||||
|
import com.android.keyguard.InternalFaceAuthReasons.POSTURE_CHANGED
|
||||||
import com.android.keyguard.InternalFaceAuthReasons.PRIMARY_BOUNCER_SHOWN
|
import com.android.keyguard.InternalFaceAuthReasons.PRIMARY_BOUNCER_SHOWN
|
||||||
import com.android.keyguard.InternalFaceAuthReasons.PRIMARY_BOUNCER_SHOWN_OR_WILL_BE_SHOWN
|
import com.android.keyguard.InternalFaceAuthReasons.PRIMARY_BOUNCER_SHOWN_OR_WILL_BE_SHOWN
|
||||||
import com.android.keyguard.InternalFaceAuthReasons.RETRY_AFTER_HW_UNAVAILABLE
|
import com.android.keyguard.InternalFaceAuthReasons.RETRY_AFTER_HW_UNAVAILABLE
|
||||||
@@ -126,6 +127,7 @@ private object InternalFaceAuthReasons {
|
|||||||
const val STRONG_AUTH_ALLOWED_CHANGED = "Face auth stopped because strong auth allowed changed"
|
const val STRONG_AUTH_ALLOWED_CHANGED = "Face auth stopped because strong auth allowed changed"
|
||||||
const val NON_STRONG_BIOMETRIC_ALLOWED_CHANGED =
|
const val NON_STRONG_BIOMETRIC_ALLOWED_CHANGED =
|
||||||
"Face auth stopped because non strong biometric allowed changed"
|
"Face auth stopped because non strong biometric allowed changed"
|
||||||
|
const val POSTURE_CHANGED = "Face auth started/stopped due to device posture changed."
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -173,6 +175,7 @@ constructor(private val id: Int, val reason: String, var extraInfo: Int = 0) :
|
|||||||
return PowerManager.wakeReasonToString(extraInfo)
|
return PowerManager.wakeReasonToString(extraInfo)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@UiEvent(doc = POSTURE_CHANGED) FACE_AUTH_UPDATED_POSTURE_CHANGED(1265, POSTURE_CHANGED),
|
||||||
@Deprecated(
|
@Deprecated(
|
||||||
"Not a face auth trigger.",
|
"Not a face auth trigger.",
|
||||||
ReplaceWith(
|
ReplaceWith(
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ data class KeyguardFaceListenModel(
|
|||||||
var keyguardGoingAway: Boolean = false,
|
var keyguardGoingAway: Boolean = false,
|
||||||
var listeningForFaceAssistant: Boolean = false,
|
var listeningForFaceAssistant: Boolean = false,
|
||||||
var occludingAppRequestingFaceAuth: Boolean = false,
|
var occludingAppRequestingFaceAuth: Boolean = false,
|
||||||
|
val postureAllowsListening: Boolean = false,
|
||||||
var primaryUser: Boolean = false,
|
var primaryUser: Boolean = false,
|
||||||
var secureCameraLaunched: Boolean = false,
|
var secureCameraLaunched: Boolean = false,
|
||||||
var supportsDetect: Boolean = false,
|
var supportsDetect: Boolean = false,
|
||||||
|
|||||||
@@ -63,11 +63,13 @@ import static com.android.keyguard.FaceAuthUiEvent.FACE_AUTH_UPDATED_KEYGUARD_RE
|
|||||||
import static com.android.keyguard.FaceAuthUiEvent.FACE_AUTH_UPDATED_KEYGUARD_VISIBILITY_CHANGED;
|
import static com.android.keyguard.FaceAuthUiEvent.FACE_AUTH_UPDATED_KEYGUARD_VISIBILITY_CHANGED;
|
||||||
import static com.android.keyguard.FaceAuthUiEvent.FACE_AUTH_UPDATED_ON_FACE_AUTHENTICATED;
|
import static com.android.keyguard.FaceAuthUiEvent.FACE_AUTH_UPDATED_ON_FACE_AUTHENTICATED;
|
||||||
import static com.android.keyguard.FaceAuthUiEvent.FACE_AUTH_UPDATED_ON_KEYGUARD_INIT;
|
import static com.android.keyguard.FaceAuthUiEvent.FACE_AUTH_UPDATED_ON_KEYGUARD_INIT;
|
||||||
|
import static com.android.keyguard.FaceAuthUiEvent.FACE_AUTH_UPDATED_POSTURE_CHANGED;
|
||||||
import static com.android.keyguard.FaceAuthUiEvent.FACE_AUTH_UPDATED_PRIMARY_BOUNCER_SHOWN;
|
import static com.android.keyguard.FaceAuthUiEvent.FACE_AUTH_UPDATED_PRIMARY_BOUNCER_SHOWN;
|
||||||
import static com.android.keyguard.FaceAuthUiEvent.FACE_AUTH_UPDATED_STARTED_WAKING_UP;
|
import static com.android.keyguard.FaceAuthUiEvent.FACE_AUTH_UPDATED_STARTED_WAKING_UP;
|
||||||
import static com.android.keyguard.FaceAuthUiEvent.FACE_AUTH_UPDATED_STRONG_AUTH_CHANGED;
|
import static com.android.keyguard.FaceAuthUiEvent.FACE_AUTH_UPDATED_STRONG_AUTH_CHANGED;
|
||||||
import static com.android.keyguard.FaceAuthUiEvent.FACE_AUTH_UPDATED_USER_SWITCHING;
|
import static com.android.keyguard.FaceAuthUiEvent.FACE_AUTH_UPDATED_USER_SWITCHING;
|
||||||
import static com.android.systemui.DejankUtils.whitelistIpcs;
|
import static com.android.systemui.DejankUtils.whitelistIpcs;
|
||||||
|
import static com.android.systemui.statusbar.policy.DevicePostureController.DEVICE_POSTURE_UNKNOWN;
|
||||||
|
|
||||||
import android.annotation.AnyThread;
|
import android.annotation.AnyThread;
|
||||||
import android.annotation.MainThread;
|
import android.annotation.MainThread;
|
||||||
@@ -155,6 +157,7 @@ import com.android.systemui.shared.system.TaskStackChangeListener;
|
|||||||
import com.android.systemui.shared.system.TaskStackChangeListeners;
|
import com.android.systemui.shared.system.TaskStackChangeListeners;
|
||||||
import com.android.systemui.statusbar.StatusBarState;
|
import com.android.systemui.statusbar.StatusBarState;
|
||||||
import com.android.systemui.statusbar.phone.KeyguardBypassController;
|
import com.android.systemui.statusbar.phone.KeyguardBypassController;
|
||||||
|
import com.android.systemui.statusbar.policy.DevicePostureController;
|
||||||
import com.android.systemui.telephony.TelephonyListenerManager;
|
import com.android.systemui.telephony.TelephonyListenerManager;
|
||||||
import com.android.systemui.util.Assert;
|
import com.android.systemui.util.Assert;
|
||||||
import com.android.systemui.util.settings.SecureSettings;
|
import com.android.systemui.util.settings.SecureSettings;
|
||||||
@@ -357,6 +360,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
|
|||||||
private final TrustManager mTrustManager;
|
private final TrustManager mTrustManager;
|
||||||
private final UserManager mUserManager;
|
private final UserManager mUserManager;
|
||||||
private final DevicePolicyManager mDevicePolicyManager;
|
private final DevicePolicyManager mDevicePolicyManager;
|
||||||
|
private final DevicePostureController mPostureController;
|
||||||
private final BroadcastDispatcher mBroadcastDispatcher;
|
private final BroadcastDispatcher mBroadcastDispatcher;
|
||||||
private final SecureSettings mSecureSettings;
|
private final SecureSettings mSecureSettings;
|
||||||
private final InteractionJankMonitor mInteractionJankMonitor;
|
private final InteractionJankMonitor mInteractionJankMonitor;
|
||||||
@@ -374,6 +378,9 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
|
|||||||
private final FaceManager mFaceManager;
|
private final FaceManager mFaceManager;
|
||||||
private final LockPatternUtils mLockPatternUtils;
|
private final LockPatternUtils mLockPatternUtils;
|
||||||
private final boolean mWakeOnFingerprintAcquiredStart;
|
private final boolean mWakeOnFingerprintAcquiredStart;
|
||||||
|
@VisibleForTesting
|
||||||
|
@DevicePostureController.DevicePostureInt
|
||||||
|
protected int mConfigFaceAuthSupportedPosture;
|
||||||
|
|
||||||
private KeyguardBypassController mKeyguardBypassController;
|
private KeyguardBypassController mKeyguardBypassController;
|
||||||
private List<SubscriptionInfo> mSubscriptionInfo;
|
private List<SubscriptionInfo> mSubscriptionInfo;
|
||||||
@@ -384,6 +391,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
|
|||||||
private boolean mLogoutEnabled;
|
private boolean mLogoutEnabled;
|
||||||
private boolean mIsFaceEnrolled;
|
private boolean mIsFaceEnrolled;
|
||||||
private int mActiveMobileDataSubscription = SubscriptionManager.INVALID_SUBSCRIPTION_ID;
|
private int mActiveMobileDataSubscription = SubscriptionManager.INVALID_SUBSCRIPTION_ID;
|
||||||
|
private int mPostureState = DEVICE_POSTURE_UNKNOWN;
|
||||||
private FingerprintInteractiveToAuthProvider mFingerprintInteractiveToAuthProvider;
|
private FingerprintInteractiveToAuthProvider mFingerprintInteractiveToAuthProvider;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1794,6 +1802,17 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@VisibleForTesting
|
||||||
|
final DevicePostureController.Callback mPostureCallback =
|
||||||
|
new DevicePostureController.Callback() {
|
||||||
|
@Override
|
||||||
|
public void onPostureChanged(int posture) {
|
||||||
|
mPostureState = posture;
|
||||||
|
updateFaceListeningState(BIOMETRIC_ACTION_UPDATE,
|
||||||
|
FACE_AUTH_UPDATED_POSTURE_CHANGED);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
CancellationSignal mFingerprintCancelSignal;
|
CancellationSignal mFingerprintCancelSignal;
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
@@ -2060,6 +2079,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
|
|||||||
@Nullable FingerprintManager fingerprintManager,
|
@Nullable FingerprintManager fingerprintManager,
|
||||||
@Nullable BiometricManager biometricManager,
|
@Nullable BiometricManager biometricManager,
|
||||||
FaceWakeUpTriggersConfig faceWakeUpTriggersConfig,
|
FaceWakeUpTriggersConfig faceWakeUpTriggersConfig,
|
||||||
|
DevicePostureController devicePostureController,
|
||||||
Optional<FingerprintInteractiveToAuthProvider> interactiveToAuthProvider) {
|
Optional<FingerprintInteractiveToAuthProvider> interactiveToAuthProvider) {
|
||||||
mContext = context;
|
mContext = context;
|
||||||
mSubscriptionManager = subscriptionManager;
|
mSubscriptionManager = subscriptionManager;
|
||||||
@@ -2089,6 +2109,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
|
|||||||
mDreamManager = dreamManager;
|
mDreamManager = dreamManager;
|
||||||
mTelephonyManager = telephonyManager;
|
mTelephonyManager = telephonyManager;
|
||||||
mDevicePolicyManager = devicePolicyManager;
|
mDevicePolicyManager = devicePolicyManager;
|
||||||
|
mPostureController = devicePostureController;
|
||||||
mPackageManager = packageManager;
|
mPackageManager = packageManager;
|
||||||
mFpm = fingerprintManager;
|
mFpm = fingerprintManager;
|
||||||
mFaceManager = faceManager;
|
mFaceManager = faceManager;
|
||||||
@@ -2100,6 +2121,8 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
|
|||||||
R.array.config_face_acquire_device_entry_ignorelist))
|
R.array.config_face_acquire_device_entry_ignorelist))
|
||||||
.boxed()
|
.boxed()
|
||||||
.collect(Collectors.toSet());
|
.collect(Collectors.toSet());
|
||||||
|
mConfigFaceAuthSupportedPosture = mContext.getResources().getInteger(
|
||||||
|
R.integer.config_face_auth_supported_posture);
|
||||||
mFaceWakeUpTriggersConfig = faceWakeUpTriggersConfig;
|
mFaceWakeUpTriggersConfig = faceWakeUpTriggersConfig;
|
||||||
|
|
||||||
mHandler = new Handler(mainLooper) {
|
mHandler = new Handler(mainLooper) {
|
||||||
@@ -2290,6 +2313,9 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
|
|||||||
FACE_AUTH_TRIGGERED_ENROLLMENTS_CHANGED));
|
FACE_AUTH_TRIGGERED_ENROLLMENTS_CHANGED));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
if (mConfigFaceAuthSupportedPosture != DEVICE_POSTURE_UNKNOWN) {
|
||||||
|
mPostureController.addCallback(mPostureCallback);
|
||||||
|
}
|
||||||
updateBiometricListeningState(BIOMETRIC_ACTION_UPDATE, FACE_AUTH_UPDATED_ON_KEYGUARD_INIT);
|
updateBiometricListeningState(BIOMETRIC_ACTION_UPDATE, FACE_AUTH_UPDATED_ON_KEYGUARD_INIT);
|
||||||
|
|
||||||
TaskStackChangeListeners.getInstance().registerTaskStackListener(mTaskStackListener);
|
TaskStackChangeListeners.getInstance().registerTaskStackListener(mTaskStackListener);
|
||||||
@@ -2794,6 +2820,9 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
|
|||||||
final boolean biometricEnabledForUser = mBiometricEnabledForUser.get(user);
|
final boolean biometricEnabledForUser = mBiometricEnabledForUser.get(user);
|
||||||
final boolean shouldListenForFaceAssistant = shouldListenForFaceAssistant();
|
final boolean shouldListenForFaceAssistant = shouldListenForFaceAssistant();
|
||||||
final boolean isUdfpsFingerDown = mAuthController.isUdfpsFingerDown();
|
final boolean isUdfpsFingerDown = mAuthController.isUdfpsFingerDown();
|
||||||
|
final boolean isPostureAllowedForFaceAuth =
|
||||||
|
mConfigFaceAuthSupportedPosture == 0 /* DEVICE_POSTURE_UNKNOWN */ ? true
|
||||||
|
: (mPostureState == mConfigFaceAuthSupportedPosture);
|
||||||
|
|
||||||
// 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.
|
||||||
@@ -2810,7 +2839,8 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
|
|||||||
&& faceAuthAllowedOrDetectionIsNeeded && mIsPrimaryUser
|
&& faceAuthAllowedOrDetectionIsNeeded && mIsPrimaryUser
|
||||||
&& (!mSecureCameraLaunched || mOccludingAppRequestingFace)
|
&& (!mSecureCameraLaunched || mOccludingAppRequestingFace)
|
||||||
&& faceAndFpNotAuthenticated
|
&& faceAndFpNotAuthenticated
|
||||||
&& !mGoingToSleep;
|
&& !mGoingToSleep
|
||||||
|
&& isPostureAllowedForFaceAuth;
|
||||||
|
|
||||||
// Aggregate relevant fields for debug logging.
|
// Aggregate relevant fields for debug logging.
|
||||||
logListenerModelData(
|
logListenerModelData(
|
||||||
@@ -2830,6 +2860,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
|
|||||||
mKeyguardGoingAway,
|
mKeyguardGoingAway,
|
||||||
shouldListenForFaceAssistant,
|
shouldListenForFaceAssistant,
|
||||||
mOccludingAppRequestingFace,
|
mOccludingAppRequestingFace,
|
||||||
|
isPostureAllowedForFaceAuth,
|
||||||
mIsPrimaryUser,
|
mIsPrimaryUser,
|
||||||
mSecureCameraLaunched,
|
mSecureCameraLaunched,
|
||||||
supportsDetect,
|
supportsDetect,
|
||||||
@@ -2915,7 +2946,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
|
|||||||
getKeyguardSessionId(),
|
getKeyguardSessionId(),
|
||||||
faceAuthUiEvent.getExtraInfo()
|
faceAuthUiEvent.getExtraInfo()
|
||||||
);
|
);
|
||||||
|
mLogger.logFaceUnlockPossible(unlockPossible);
|
||||||
if (unlockPossible) {
|
if (unlockPossible) {
|
||||||
mFaceCancelSignal = new CancellationSignal();
|
mFaceCancelSignal = new CancellationSignal();
|
||||||
|
|
||||||
|
|||||||
@@ -132,6 +132,12 @@ class KeyguardUpdateMonitorLogger @Inject constructor(
|
|||||||
logBuffer.log(TAG, DEBUG, { int1 = faceRunningState }, { "faceRunningState: $int1" })
|
logBuffer.log(TAG, DEBUG, { int1 = faceRunningState }, { "faceRunningState: $int1" })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun logFaceUnlockPossible(isFaceUnlockPossible: Boolean) {
|
||||||
|
logBuffer.log(TAG, DEBUG,
|
||||||
|
{ bool1 = isFaceUnlockPossible },
|
||||||
|
{"isUnlockWithFacePossible: $bool1"})
|
||||||
|
}
|
||||||
|
|
||||||
fun logFingerprintAuthForWrongUser(authUserId: Int) {
|
fun logFingerprintAuthForWrongUser(authUserId: Int) {
|
||||||
logBuffer.log(TAG, DEBUG,
|
logBuffer.log(TAG, DEBUG,
|
||||||
{ int1 = authUserId },
|
{ int1 = authUserId },
|
||||||
|
|||||||
@@ -32,6 +32,9 @@ import static com.android.keyguard.KeyguardUpdateMonitor.BIOMETRIC_STATE_CANCELL
|
|||||||
import static com.android.keyguard.KeyguardUpdateMonitor.DEFAULT_CANCEL_SIGNAL_TIMEOUT;
|
import static com.android.keyguard.KeyguardUpdateMonitor.DEFAULT_CANCEL_SIGNAL_TIMEOUT;
|
||||||
import static com.android.keyguard.KeyguardUpdateMonitor.HAL_POWER_PRESS_TIMEOUT;
|
import static com.android.keyguard.KeyguardUpdateMonitor.HAL_POWER_PRESS_TIMEOUT;
|
||||||
import static com.android.keyguard.KeyguardUpdateMonitor.getCurrentUser;
|
import static com.android.keyguard.KeyguardUpdateMonitor.getCurrentUser;
|
||||||
|
import static com.android.systemui.statusbar.policy.DevicePostureController.DEVICE_POSTURE_CLOSED;
|
||||||
|
import static com.android.systemui.statusbar.policy.DevicePostureController.DEVICE_POSTURE_OPENED;
|
||||||
|
import static com.android.systemui.statusbar.policy.DevicePostureController.DEVICE_POSTURE_UNKNOWN;
|
||||||
|
|
||||||
import static com.google.common.truth.Truth.assertThat;
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
|
|
||||||
@@ -125,6 +128,7 @@ import com.android.systemui.plugins.statusbar.StatusBarStateController;
|
|||||||
import com.android.systemui.settings.UserTracker;
|
import com.android.systemui.settings.UserTracker;
|
||||||
import com.android.systemui.statusbar.StatusBarState;
|
import com.android.systemui.statusbar.StatusBarState;
|
||||||
import com.android.systemui.statusbar.phone.KeyguardBypassController;
|
import com.android.systemui.statusbar.phone.KeyguardBypassController;
|
||||||
|
import com.android.systemui.statusbar.policy.DevicePostureController;
|
||||||
import com.android.systemui.telephony.TelephonyListenerManager;
|
import com.android.systemui.telephony.TelephonyListenerManager;
|
||||||
import com.android.systemui.util.settings.GlobalSettings;
|
import com.android.systemui.util.settings.GlobalSettings;
|
||||||
import com.android.systemui.util.settings.SecureSettings;
|
import com.android.systemui.util.settings.SecureSettings;
|
||||||
@@ -194,6 +198,8 @@ public class KeyguardUpdateMonitorTest extends SysuiTestCase {
|
|||||||
@Mock
|
@Mock
|
||||||
private DevicePolicyManager mDevicePolicyManager;
|
private DevicePolicyManager mDevicePolicyManager;
|
||||||
@Mock
|
@Mock
|
||||||
|
private DevicePostureController mDevicePostureController;
|
||||||
|
@Mock
|
||||||
private IDreamManager mDreamManager;
|
private IDreamManager mDreamManager;
|
||||||
@Mock
|
@Mock
|
||||||
private KeyguardBypassController mKeyguardBypassController;
|
private KeyguardBypassController mKeyguardBypassController;
|
||||||
@@ -301,6 +307,7 @@ public class KeyguardUpdateMonitorTest extends SysuiTestCase {
|
|||||||
.thenReturn(new ServiceState());
|
.thenReturn(new ServiceState());
|
||||||
when(mLockPatternUtils.getLockSettings()).thenReturn(mLockSettings);
|
when(mLockPatternUtils.getLockSettings()).thenReturn(mLockSettings);
|
||||||
when(mAuthController.isUdfpsEnrolled(anyInt())).thenReturn(false);
|
when(mAuthController.isUdfpsEnrolled(anyInt())).thenReturn(false);
|
||||||
|
when(mDevicePostureController.getDevicePosture()).thenReturn(DEVICE_POSTURE_UNKNOWN);
|
||||||
|
|
||||||
mMockitoSession = ExtendedMockito.mockitoSession()
|
mMockitoSession = ExtendedMockito.mockitoSession()
|
||||||
.spyStatic(SubscriptionManager.class)
|
.spyStatic(SubscriptionManager.class)
|
||||||
@@ -312,6 +319,9 @@ public class KeyguardUpdateMonitorTest extends SysuiTestCase {
|
|||||||
when(mUserTracker.getUserId()).thenReturn(mCurrentUserId);
|
when(mUserTracker.getUserId()).thenReturn(mCurrentUserId);
|
||||||
ExtendedMockito.doReturn(mActivityService).when(ActivityManager::getService);
|
ExtendedMockito.doReturn(mActivityService).when(ActivityManager::getService);
|
||||||
|
|
||||||
|
mContext.getOrCreateTestableResources().addOverride(
|
||||||
|
com.android.systemui.R.integer.config_face_auth_supported_posture,
|
||||||
|
DEVICE_POSTURE_UNKNOWN);
|
||||||
mFaceWakeUpTriggersConfig = new FaceWakeUpTriggersConfig(
|
mFaceWakeUpTriggersConfig = new FaceWakeUpTriggersConfig(
|
||||||
mContext.getResources(),
|
mContext.getResources(),
|
||||||
mGlobalSettings,
|
mGlobalSettings,
|
||||||
@@ -2242,6 +2252,54 @@ public class KeyguardUpdateMonitorTest extends SysuiTestCase {
|
|||||||
eq(true));
|
eq(true));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testShouldListenForFace_withAuthSupportPostureConfig_returnsTrue()
|
||||||
|
throws RemoteException {
|
||||||
|
mKeyguardUpdateMonitor.mConfigFaceAuthSupportedPosture = DEVICE_POSTURE_CLOSED;
|
||||||
|
keyguardNotGoingAway();
|
||||||
|
bouncerFullyVisibleAndNotGoingToSleep();
|
||||||
|
currentUserIsPrimary();
|
||||||
|
currentUserDoesNotHaveTrust();
|
||||||
|
biometricsNotDisabledThroughDevicePolicyManager();
|
||||||
|
biometricsEnabledForCurrentUser();
|
||||||
|
userNotCurrentlySwitching();
|
||||||
|
supportsFaceDetection();
|
||||||
|
|
||||||
|
deviceInPostureStateOpened();
|
||||||
|
mTestableLooper.processAllMessages();
|
||||||
|
// Should not listen for face when posture state in DEVICE_POSTURE_OPENED
|
||||||
|
assertThat(mKeyguardUpdateMonitor.shouldListenForFace()).isFalse();
|
||||||
|
|
||||||
|
deviceInPostureStateClosed();
|
||||||
|
mTestableLooper.processAllMessages();
|
||||||
|
// Should listen for face when posture state in DEVICE_POSTURE_CLOSED
|
||||||
|
assertThat(mKeyguardUpdateMonitor.shouldListenForFace()).isTrue();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testShouldListenForFace_withoutAuthSupportPostureConfig_returnsTrue()
|
||||||
|
throws RemoteException {
|
||||||
|
mKeyguardUpdateMonitor.mConfigFaceAuthSupportedPosture = DEVICE_POSTURE_UNKNOWN;
|
||||||
|
keyguardNotGoingAway();
|
||||||
|
bouncerFullyVisibleAndNotGoingToSleep();
|
||||||
|
currentUserIsPrimary();
|
||||||
|
currentUserDoesNotHaveTrust();
|
||||||
|
biometricsNotDisabledThroughDevicePolicyManager();
|
||||||
|
biometricsEnabledForCurrentUser();
|
||||||
|
userNotCurrentlySwitching();
|
||||||
|
supportsFaceDetection();
|
||||||
|
|
||||||
|
deviceInPostureStateClosed();
|
||||||
|
mTestableLooper.processAllMessages();
|
||||||
|
// Whether device in any posture state, always listen for face
|
||||||
|
assertThat(mKeyguardUpdateMonitor.shouldListenForFace()).isTrue();
|
||||||
|
|
||||||
|
deviceInPostureStateOpened();
|
||||||
|
mTestableLooper.processAllMessages();
|
||||||
|
// Whether device in any posture state, always listen for face
|
||||||
|
assertThat(mKeyguardUpdateMonitor.shouldListenForFace()).isTrue();
|
||||||
|
}
|
||||||
|
|
||||||
private void userDeviceLockDown() {
|
private void userDeviceLockDown() {
|
||||||
when(mStrongAuthTracker.isUnlockingWithBiometricAllowed(anyBoolean())).thenReturn(false);
|
when(mStrongAuthTracker.isUnlockingWithBiometricAllowed(anyBoolean())).thenReturn(false);
|
||||||
when(mStrongAuthTracker.getStrongAuthForUser(mCurrentUserId))
|
when(mStrongAuthTracker.getStrongAuthForUser(mCurrentUserId))
|
||||||
@@ -2321,6 +2379,14 @@ public class KeyguardUpdateMonitorTest extends SysuiTestCase {
|
|||||||
.onAuthenticationAcquired(FINGERPRINT_ACQUIRED_START);
|
.onAuthenticationAcquired(FINGERPRINT_ACQUIRED_START);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void deviceInPostureStateOpened() {
|
||||||
|
mKeyguardUpdateMonitor.mPostureCallback.onPostureChanged(DEVICE_POSTURE_OPENED);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void deviceInPostureStateClosed() {
|
||||||
|
mKeyguardUpdateMonitor.mPostureCallback.onPostureChanged(DEVICE_POSTURE_CLOSED);
|
||||||
|
}
|
||||||
|
|
||||||
private void successfulFingerprintAuth() {
|
private void successfulFingerprintAuth() {
|
||||||
mKeyguardUpdateMonitor.mFingerprintAuthenticationCallback
|
mKeyguardUpdateMonitor.mFingerprintAuthenticationCallback
|
||||||
.onAuthenticationSucceeded(
|
.onAuthenticationSucceeded(
|
||||||
@@ -2462,7 +2528,8 @@ public class KeyguardUpdateMonitorTest extends SysuiTestCase {
|
|||||||
mPowerManager, mTrustManager, mSubscriptionManager, mUserManager,
|
mPowerManager, mTrustManager, mSubscriptionManager, mUserManager,
|
||||||
mDreamManager, mDevicePolicyManager, mSensorPrivacyManager, mTelephonyManager,
|
mDreamManager, mDevicePolicyManager, mSensorPrivacyManager, mTelephonyManager,
|
||||||
mPackageManager, mFaceManager, mFingerprintManager, mBiometricManager,
|
mPackageManager, mFaceManager, mFingerprintManager, mBiometricManager,
|
||||||
mFaceWakeUpTriggersConfig, Optional.of(mInteractiveToAuthProvider));
|
mFaceWakeUpTriggersConfig, mDevicePostureController,
|
||||||
|
Optional.of(mInteractiveToAuthProvider));
|
||||||
setStrongAuthTracker(KeyguardUpdateMonitorTest.this.mStrongAuthTracker);
|
setStrongAuthTracker(KeyguardUpdateMonitorTest.this.mStrongAuthTracker);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user