Merge "4/ Add config_face_auth_supported_posture to listen for Face by posture" into tm-qpr-dev am: d601b5a445
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/20641162 Change-Id: I476708cbbc1d12c7fb202dcaac079bacc9c86823 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -668,6 +668,16 @@
|
||||
<item>17</item> <!-- WAKE_REASON_BIOMETRIC -->
|
||||
</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 -->
|
||||
<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.NON_STRONG_BIOMETRIC_ALLOWED_CHANGED
|
||||
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_OR_WILL_BE_SHOWN
|
||||
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 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)
|
||||
}
|
||||
},
|
||||
@UiEvent(doc = POSTURE_CHANGED) FACE_AUTH_UPDATED_POSTURE_CHANGED(1265, POSTURE_CHANGED),
|
||||
@Deprecated(
|
||||
"Not a face auth trigger.",
|
||||
ReplaceWith(
|
||||
|
||||
@@ -39,6 +39,7 @@ data class KeyguardFaceListenModel(
|
||||
var keyguardGoingAway: Boolean = false,
|
||||
var listeningForFaceAssistant: Boolean = false,
|
||||
var occludingAppRequestingFaceAuth: Boolean = false,
|
||||
val postureAllowsListening: Boolean = false,
|
||||
var primaryUser: Boolean = false,
|
||||
var secureCameraLaunched: 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_ON_FACE_AUTHENTICATED;
|
||||
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_STARTED_WAKING_UP;
|
||||
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.systemui.DejankUtils.whitelistIpcs;
|
||||
import static com.android.systemui.statusbar.policy.DevicePostureController.DEVICE_POSTURE_UNKNOWN;
|
||||
|
||||
import android.annotation.AnyThread;
|
||||
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.statusbar.StatusBarState;
|
||||
import com.android.systemui.statusbar.phone.KeyguardBypassController;
|
||||
import com.android.systemui.statusbar.policy.DevicePostureController;
|
||||
import com.android.systemui.telephony.TelephonyListenerManager;
|
||||
import com.android.systemui.util.Assert;
|
||||
import com.android.systemui.util.settings.SecureSettings;
|
||||
@@ -357,6 +360,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
|
||||
private final TrustManager mTrustManager;
|
||||
private final UserManager mUserManager;
|
||||
private final DevicePolicyManager mDevicePolicyManager;
|
||||
private final DevicePostureController mPostureController;
|
||||
private final BroadcastDispatcher mBroadcastDispatcher;
|
||||
private final SecureSettings mSecureSettings;
|
||||
private final InteractionJankMonitor mInteractionJankMonitor;
|
||||
@@ -374,6 +378,9 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
|
||||
private final FaceManager mFaceManager;
|
||||
private final LockPatternUtils mLockPatternUtils;
|
||||
private final boolean mWakeOnFingerprintAcquiredStart;
|
||||
@VisibleForTesting
|
||||
@DevicePostureController.DevicePostureInt
|
||||
protected int mConfigFaceAuthSupportedPosture;
|
||||
|
||||
private KeyguardBypassController mKeyguardBypassController;
|
||||
private List<SubscriptionInfo> mSubscriptionInfo;
|
||||
@@ -384,6 +391,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
|
||||
private boolean mLogoutEnabled;
|
||||
private boolean mIsFaceEnrolled;
|
||||
private int mActiveMobileDataSubscription = SubscriptionManager.INVALID_SUBSCRIPTION_ID;
|
||||
private int mPostureState = DEVICE_POSTURE_UNKNOWN;
|
||||
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
|
||||
CancellationSignal mFingerprintCancelSignal;
|
||||
@VisibleForTesting
|
||||
@@ -2060,6 +2079,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
|
||||
@Nullable FingerprintManager fingerprintManager,
|
||||
@Nullable BiometricManager biometricManager,
|
||||
FaceWakeUpTriggersConfig faceWakeUpTriggersConfig,
|
||||
DevicePostureController devicePostureController,
|
||||
Optional<FingerprintInteractiveToAuthProvider> interactiveToAuthProvider) {
|
||||
mContext = context;
|
||||
mSubscriptionManager = subscriptionManager;
|
||||
@@ -2089,6 +2109,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
|
||||
mDreamManager = dreamManager;
|
||||
mTelephonyManager = telephonyManager;
|
||||
mDevicePolicyManager = devicePolicyManager;
|
||||
mPostureController = devicePostureController;
|
||||
mPackageManager = packageManager;
|
||||
mFpm = fingerprintManager;
|
||||
mFaceManager = faceManager;
|
||||
@@ -2100,6 +2121,8 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
|
||||
R.array.config_face_acquire_device_entry_ignorelist))
|
||||
.boxed()
|
||||
.collect(Collectors.toSet());
|
||||
mConfigFaceAuthSupportedPosture = mContext.getResources().getInteger(
|
||||
R.integer.config_face_auth_supported_posture);
|
||||
mFaceWakeUpTriggersConfig = faceWakeUpTriggersConfig;
|
||||
|
||||
mHandler = new Handler(mainLooper) {
|
||||
@@ -2290,6 +2313,9 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
|
||||
FACE_AUTH_TRIGGERED_ENROLLMENTS_CHANGED));
|
||||
}
|
||||
});
|
||||
if (mConfigFaceAuthSupportedPosture != DEVICE_POSTURE_UNKNOWN) {
|
||||
mPostureController.addCallback(mPostureCallback);
|
||||
}
|
||||
updateBiometricListeningState(BIOMETRIC_ACTION_UPDATE, FACE_AUTH_UPDATED_ON_KEYGUARD_INIT);
|
||||
|
||||
TaskStackChangeListeners.getInstance().registerTaskStackListener(mTaskStackListener);
|
||||
@@ -2734,7 +2760,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
|
||||
user,
|
||||
shouldListen,
|
||||
biometricEnabledForUser,
|
||||
mPrimaryBouncerIsOrWillBeShowing,
|
||||
mPrimaryBouncerIsOrWillBeShowing,
|
||||
userCanSkipBouncer,
|
||||
mCredentialAttempted,
|
||||
mDeviceInteractive,
|
||||
@@ -2794,6 +2820,9 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
|
||||
final boolean biometricEnabledForUser = mBiometricEnabledForUser.get(user);
|
||||
final boolean shouldListenForFaceAssistant = shouldListenForFaceAssistant();
|
||||
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
|
||||
// instance of KeyguardUpdateMonitor for each user but KeyguardUpdateMonitor is user-aware.
|
||||
@@ -2810,7 +2839,8 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
|
||||
&& faceAuthAllowedOrDetectionIsNeeded && mIsPrimaryUser
|
||||
&& (!mSecureCameraLaunched || mOccludingAppRequestingFace)
|
||||
&& faceAndFpNotAuthenticated
|
||||
&& !mGoingToSleep;
|
||||
&& !mGoingToSleep
|
||||
&& isPostureAllowedForFaceAuth;
|
||||
|
||||
// Aggregate relevant fields for debug logging.
|
||||
logListenerModelData(
|
||||
@@ -2830,6 +2860,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
|
||||
mKeyguardGoingAway,
|
||||
shouldListenForFaceAssistant,
|
||||
mOccludingAppRequestingFace,
|
||||
isPostureAllowedForFaceAuth,
|
||||
mIsPrimaryUser,
|
||||
mSecureCameraLaunched,
|
||||
supportsDetect,
|
||||
@@ -2915,7 +2946,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
|
||||
getKeyguardSessionId(),
|
||||
faceAuthUiEvent.getExtraInfo()
|
||||
);
|
||||
|
||||
mLogger.logFaceUnlockPossible(unlockPossible);
|
||||
if (unlockPossible) {
|
||||
mFaceCancelSignal = new CancellationSignal();
|
||||
|
||||
|
||||
@@ -132,6 +132,12 @@ class KeyguardUpdateMonitorLogger @Inject constructor(
|
||||
logBuffer.log(TAG, DEBUG, { int1 = faceRunningState }, { "faceRunningState: $int1" })
|
||||
}
|
||||
|
||||
fun logFaceUnlockPossible(isFaceUnlockPossible: Boolean) {
|
||||
logBuffer.log(TAG, DEBUG,
|
||||
{ bool1 = isFaceUnlockPossible },
|
||||
{"isUnlockWithFacePossible: $bool1"})
|
||||
}
|
||||
|
||||
fun logFingerprintAuthForWrongUser(authUserId: Int) {
|
||||
logBuffer.log(TAG, DEBUG,
|
||||
{ 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.HAL_POWER_PRESS_TIMEOUT;
|
||||
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;
|
||||
|
||||
@@ -125,6 +128,7 @@ import com.android.systemui.plugins.statusbar.StatusBarStateController;
|
||||
import com.android.systemui.settings.UserTracker;
|
||||
import com.android.systemui.statusbar.StatusBarState;
|
||||
import com.android.systemui.statusbar.phone.KeyguardBypassController;
|
||||
import com.android.systemui.statusbar.policy.DevicePostureController;
|
||||
import com.android.systemui.telephony.TelephonyListenerManager;
|
||||
import com.android.systemui.util.settings.GlobalSettings;
|
||||
import com.android.systemui.util.settings.SecureSettings;
|
||||
@@ -194,6 +198,8 @@ public class KeyguardUpdateMonitorTest extends SysuiTestCase {
|
||||
@Mock
|
||||
private DevicePolicyManager mDevicePolicyManager;
|
||||
@Mock
|
||||
private DevicePostureController mDevicePostureController;
|
||||
@Mock
|
||||
private IDreamManager mDreamManager;
|
||||
@Mock
|
||||
private KeyguardBypassController mKeyguardBypassController;
|
||||
@@ -301,6 +307,7 @@ public class KeyguardUpdateMonitorTest extends SysuiTestCase {
|
||||
.thenReturn(new ServiceState());
|
||||
when(mLockPatternUtils.getLockSettings()).thenReturn(mLockSettings);
|
||||
when(mAuthController.isUdfpsEnrolled(anyInt())).thenReturn(false);
|
||||
when(mDevicePostureController.getDevicePosture()).thenReturn(DEVICE_POSTURE_UNKNOWN);
|
||||
|
||||
mMockitoSession = ExtendedMockito.mockitoSession()
|
||||
.spyStatic(SubscriptionManager.class)
|
||||
@@ -312,6 +319,9 @@ public class KeyguardUpdateMonitorTest extends SysuiTestCase {
|
||||
when(mUserTracker.getUserId()).thenReturn(mCurrentUserId);
|
||||
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(
|
||||
mContext.getResources(),
|
||||
mGlobalSettings,
|
||||
@@ -2242,6 +2252,54 @@ public class KeyguardUpdateMonitorTest extends SysuiTestCase {
|
||||
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() {
|
||||
when(mStrongAuthTracker.isUnlockingWithBiometricAllowed(anyBoolean())).thenReturn(false);
|
||||
when(mStrongAuthTracker.getStrongAuthForUser(mCurrentUserId))
|
||||
@@ -2321,6 +2379,14 @@ public class KeyguardUpdateMonitorTest extends SysuiTestCase {
|
||||
.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() {
|
||||
mKeyguardUpdateMonitor.mFingerprintAuthenticationCallback
|
||||
.onAuthenticationSucceeded(
|
||||
@@ -2462,7 +2528,8 @@ public class KeyguardUpdateMonitorTest extends SysuiTestCase {
|
||||
mPowerManager, mTrustManager, mSubscriptionManager, mUserManager,
|
||||
mDreamManager, mDevicePolicyManager, mSensorPrivacyManager, mTelephonyManager,
|
||||
mPackageManager, mFaceManager, mFingerprintManager, mBiometricManager,
|
||||
mFaceWakeUpTriggersConfig, Optional.of(mInteractiveToAuthProvider));
|
||||
mFaceWakeUpTriggersConfig, mDevicePostureController,
|
||||
Optional.of(mInteractiveToAuthProvider));
|
||||
setStrongAuthTracker(KeyguardUpdateMonitorTest.this.mStrongAuthTracker);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user