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
This commit is contained in:
lbill
2022-12-08 07:11:23 +00:00
parent 1eee5eda6c
commit ee6366761b
12 changed files with 859 additions and 103 deletions

View File

@@ -16,6 +16,7 @@
package com.android.settings.biometrics;
import android.annotation.IntDef;
import android.app.Activity;
import android.app.PendingIntent;
import android.app.admin.DevicePolicyManager;
@@ -49,12 +50,37 @@ import com.android.settings.password.SetupChooseLockGeneric;
import com.google.android.setupcompat.util.WizardManagerHelper;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
/**
* Common biometric utilities.
*/
public class BiometricUtils {
private static final String TAG = "BiometricUtils";
// Note: Theis IntDef must align SystemUI DevicePostureInt
@IntDef(prefix = {"DEVICE_POSTURE_"}, value = {
DEVICE_POSTURE_UNKNOWN,
DEVICE_POSTURE_CLOSED,
DEVICE_POSTURE_HALF_OPENED,
DEVICE_POSTURE_OPENED,
DEVICE_POSTURE_FLIPPED
})
@Retention(RetentionPolicy.SOURCE)
public @interface DevicePostureInt {}
// NOTE: These constants **must** match those defined for Jetpack Sidecar. This is because we
// use the Device State -> Jetpack Posture map in DevicePostureControllerImpl to translate
// between the two.
public static final int DEVICE_POSTURE_UNKNOWN = 0;
public static final int DEVICE_POSTURE_CLOSED = 1;
public static final int DEVICE_POSTURE_HALF_OPENED = 2;
public static final int DEVICE_POSTURE_OPENED = 3;
public static final int DEVICE_POSTURE_FLIPPED = 4;
public static int sAllowEnrollPosture = DEVICE_POSTURE_UNKNOWN;
/**
* Request was sent for starting another enrollment of a previously
* enrolled biometric of the same type.
@@ -334,6 +360,51 @@ public class BiometricUtils {
|| isMultiBiometricFingerprintEnrollmentFlow(activity);
}
/**
* Used to check if the activity is showing a posture guidance to user.
*
* @param devicePosture the device posture state
* @param isLaunchedPostureGuidance True launching a posture guidance to user
* @return True if the activity is showing posture guidance to user
*/
public static boolean isPostureGuidanceShowing(@DevicePostureInt int devicePosture,
boolean isLaunchedPostureGuidance) {
return !isPostureAllowEnrollment(devicePosture) && isLaunchedPostureGuidance;
}
/**
* Used to check if current device posture state is allow to enroll biometrics.
* For compatibility, we don't restrict enrollment if device do not config.
*
* @param devicePosture True if current device posture allow enrollment
* @return True if current device posture state allow enrollment
*/
public static boolean isPostureAllowEnrollment(@DevicePostureInt int devicePosture) {
return (sAllowEnrollPosture == DEVICE_POSTURE_UNKNOWN)
|| (devicePosture == sAllowEnrollPosture);
}
/**
* Used to check if the activity should show a posture guidance to user.
*
* @param devicePosture the device posture state
* @param isLaunchedPostureGuidance True launching a posture guidance to user
* @return True if posture disallow enroll and posture guidance not showing, false otherwise.
*/
public static boolean shouldShowPostureGuidance(@DevicePostureInt int devicePosture,
boolean isLaunchedPostureGuidance) {
return !isPostureAllowEnrollment(devicePosture) && !isLaunchedPostureGuidance;
}
/**
* Sets allowed device posture for face enrollment.
*
* @param devicePosture the allowed posture state {@link DevicePostureInt} for enrollment
*/
public static void setDevicePosturesAllowEnroll(@DevicePostureInt int devicePosture) {
sAllowEnrollPosture = devicePosture;
}
public static void copyMultiBiometricExtras(@NonNull Intent fromIntent,
@NonNull Intent toIntent) {
PendingIntent pendingIntent = (PendingIntent) fromIntent.getExtra(