3-1/ Impl FoldProvider.FoldCallback for Face enroll activities
Create a mechanism to allow OEM config posture guidance with 'config_face_enroll_guidance_page', and customize the config 'config_face_enroll_supported_posture' with standard postures 0 : DEVICE_POSTURE_UNKNOWN 1 : DEVICE_POSTURE_CLOSED 2 : DEVICE_POSTURE_HALF_OPENED 3 : DEVICE_POSTURE_OPENED 4 : DEVICE_POSTURE_FLIPPED For example, if we set 1 for the device, then device only allow to enroll face in closed(folded) state, if device do not in the allow state, we will prompt specific guidance page activity defined in config_face_enroll_guidance_page. At this stage , we only integrate 2 states OPENED/CLOSED through ScreenSizeFoldProvider and register for onFoldUpdated() callback - isFold(DEVICE_POSTURE_CLOSED): finish posture guidance - !isFold(DEVICE_POSTURE_OPENED): launch posture guidance - onActivityResult : reset mOnGuidanceShown false 1. Fix A11y lottie animation bug 2. Impl FoldProvider.FoldCallback 3. Register callback to ScreenSizeFoldProvider 4. Integrate back stack, skip, cancel events - Back key : RESULT_CANCELED - Skip btn : RESULT_SKIP - Posture changed : RESULT_FINISHED 5. Set single instance for relative activities 6. FaceEnrollFoldPage listen for onConfigurationChanged() 7. Add empty face_posture_guidance_lottie.json for overlay Test: atest SettingsGoogleUnitTests Test: m -j SettingsGoogleRoboTests RunSettingsGoogleRoboTests Test: m RunSettingsRoboTests ROBOTEST_FILTER= \ "com.android.settings.biometrics.face.FaceEnrollEducationTest" Test: m RunSettingsRoboTests ROBOTEST_FILTER= \ "com.android.settings.biometrics.face.FaceEnrollIntroductionTest" Test: Manual launch security settings face enroll, unfold device and observe posture guidance showing fullscreen on top Test: Fold device ensure the posture guidance activity finish Bug: 261141826 Fixes: 231908496 Change-Id: Ib9f43f82f7d19f3f187c2f6f8984e76cd843afbc Merged-In: Ib9f43f82f7d19f3f187c2f6f8984e76cd843afbc
This commit is contained in:
@@ -23,6 +23,7 @@ import static com.android.settings.biometrics.BiometricUtils.GatekeeperCredentia
|
||||
import android.app.admin.DevicePolicyManager;
|
||||
import android.app.settings.SettingsEnums;
|
||||
import android.content.Intent;
|
||||
import android.content.res.Configuration;
|
||||
import android.hardware.SensorPrivacyManager;
|
||||
import android.hardware.biometrics.BiometricAuthenticator;
|
||||
import android.hardware.face.FaceManager;
|
||||
@@ -50,6 +51,8 @@ import com.android.settings.password.ChooseLockSettingsHelper;
|
||||
import com.android.settings.password.SetupSkipDialog;
|
||||
import com.android.settings.utils.SensorPrivacyManagerHelper;
|
||||
import com.android.settingslib.RestrictedLockUtilsInternal;
|
||||
import com.android.systemui.unfold.compat.ScreenSizeFoldProvider;
|
||||
import com.android.systemui.unfold.updates.FoldProvider;
|
||||
|
||||
import com.google.android.setupcompat.template.FooterButton;
|
||||
import com.google.android.setupcompat.util.WizardManagerHelper;
|
||||
@@ -99,6 +102,12 @@ public class FaceEnrollIntroduction extends BiometricEnrollIntroduction {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean shouldFinishWhenBackgrounded() {
|
||||
return super.shouldFinishWhenBackgrounded() && !BiometricUtils.isPostureGuidanceShowing(
|
||||
mDevicePostureState, mLaunchedPostureGuidance);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
@@ -188,14 +197,76 @@ public class FaceEnrollIntroduction extends BiometricEnrollIntroduction {
|
||||
return Utils.getFaceManagerOrNull(this);
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
@Nullable
|
||||
protected Intent getPostureGuidanceIntent() {
|
||||
return mPostureGuidanceIntent;
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
@Nullable
|
||||
protected FoldProvider.FoldCallback getPostureCallback() {
|
||||
return mFoldCallback;
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
@BiometricUtils.DevicePostureInt
|
||||
protected int getDevicePostureState() {
|
||||
return mDevicePostureState;
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
@Nullable
|
||||
protected byte[] requestGatekeeperHat(long challenge) {
|
||||
return BiometricUtils.requestGatekeeperHat(this, getIntent(), mUserId, challenge);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onConfigurationChanged(@NonNull Configuration newConfig) {
|
||||
super.onConfigurationChanged(newConfig);
|
||||
if (mScreenSizeFoldProvider != null && getPostureCallback() != null) {
|
||||
mScreenSizeFoldProvider.onConfigurationChange(newConfig);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStart() {
|
||||
super.onStart();
|
||||
if (getPostureGuidanceIntent() == null) {
|
||||
Log.d(TAG, "Device do not support posture guidance");
|
||||
return;
|
||||
}
|
||||
|
||||
BiometricUtils.setDevicePosturesAllowEnroll(
|
||||
getResources().getInteger(R.integer.config_face_enroll_supported_posture));
|
||||
|
||||
if (getPostureCallback() == null) {
|
||||
mFoldCallback = isFolded -> {
|
||||
mDevicePostureState = isFolded ? BiometricUtils.DEVICE_POSTURE_CLOSED
|
||||
: BiometricUtils.DEVICE_POSTURE_OPENED;
|
||||
if (BiometricUtils.shouldShowPostureGuidance(mDevicePostureState,
|
||||
mLaunchedPostureGuidance) && !mNextLaunched) {
|
||||
launchPostureGuidance();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
if (mScreenSizeFoldProvider == null) {
|
||||
mScreenSizeFoldProvider = new ScreenSizeFoldProvider(getApplicationContext());
|
||||
mScreenSizeFoldProvider.registerCallback(mFoldCallback, getMainExecutor());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
if (requestCode == REQUEST_POSTURE_GUIDANCE) {
|
||||
mLaunchedPostureGuidance = false;
|
||||
if (resultCode == RESULT_CANCELED || resultCode == RESULT_SKIP) {
|
||||
onSkipButtonClick(getCurrentFocus());
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// If user has skipped or finished enrolling, don't restart enrollment.
|
||||
final boolean isEnrollRequest = requestCode == BIOMETRIC_FIND_SENSOR_REQUEST
|
||||
|| requestCode == ENROLL_NEXT_BIOMETRIC_REQUEST;
|
||||
@@ -206,10 +277,12 @@ public class FaceEnrollIntroduction extends BiometricEnrollIntroduction {
|
||||
hasEnrolledFace = data.getBooleanExtra(EXTRA_FINISHED_ENROLL_FACE, false);
|
||||
}
|
||||
|
||||
if (resultCode == RESULT_CANCELED && hasEnrolledFace) {
|
||||
setResult(resultCode, data);
|
||||
finish();
|
||||
return;
|
||||
if (resultCode == RESULT_CANCELED) {
|
||||
if (hasEnrolledFace || !BiometricUtils.isPostureAllowEnrollment(mDevicePostureState)) {
|
||||
setResult(resultCode, data);
|
||||
finish();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (isEnrollRequest && isResultSkipOrFinished || hasEnrolledFace) {
|
||||
|
Reference in New Issue
Block a user