Launch Face Settings when device enrolled face

In legacy flow FaceEnrollIntroduction check maxFacesEnrolled()
then update introduction description and prevent user go to next
enroll step, the CUJ was not good to user, instead bring user
to Face Settings and let user decide the next action(Delete face or
change config) is more make sense.

As any applications could broadcast intent(android.settings.FACE_ENROLL)
to bring FaceEnrollIntroduction up, we add a check in onCreate() and check
if device has been enrolled max face, launch FaceSettingsInternalActivity.

In addition, skip to register any posture change callback when
maxFacesEnrolled() during activity onStart().

Test: atest SettingsGoogleUnitTests
Test: m -j SettingsGoogleRoboTests RunSettingsGoogleRoboTests
Test: m RunSettingsRoboTests ROBOTEST_FILTER= \
      "FaceEnrollIntroductionTest"
Test: m RunSettingsRoboTests ROBOTEST_FILTER= \
      "FingerprintEnrollIntroductionTest"
Test: Manual enrolled face, unfold device, launch Tips Security page
and click "Set up Face Unlock", device launch Face Settings insteand of
posture guidance page.

Bug: 263830403
Change-Id: Ied8b92259810f954ce6b2daaa9b87fc996ad752a
This commit is contained in:
lbill
2023-02-04 04:02:35 +00:00
committed by Milton Wu
parent 91eab671d1
commit c7dd729a43
4 changed files with 160 additions and 6 deletions

View File

@@ -28,6 +28,7 @@ import android.hardware.SensorPrivacyManager;
import android.hardware.biometrics.BiometricAuthenticator;
import android.hardware.face.FaceManager;
import android.os.Bundle;
import android.os.UserHandle;
import android.text.Html;
import android.text.method.LinkMovementMethod;
import android.util.Log;
@@ -42,6 +43,7 @@ import androidx.annotation.StringRes;
import androidx.annotation.VisibleForTesting;
import com.android.settings.R;
import com.android.settings.Settings;
import com.android.settings.Utils;
import com.android.settings.biometrics.BiometricEnrollActivity;
import com.android.settings.biometrics.BiometricEnrollIntroduction;
@@ -110,8 +112,26 @@ public class FaceEnrollIntroduction extends BiometricEnrollIntroduction {
@Override
protected void onCreate(Bundle savedInstanceState) {
mFaceManager = getFaceManager();
if (savedInstanceState == null
&& !WizardManagerHelper.isAnySetupWizard(getIntent())
&& !getIntent().getBooleanExtra(EXTRA_FROM_SETTINGS_SUMMARY, false)
&& maxFacesEnrolled()) {
// from tips && maxEnrolled
Log.d(TAG, "launch face settings");
launchFaceSettingsActivity();
finish();
}
super.onCreate(savedInstanceState);
// Wait super::onCreated() then return because SuperNotCalledExceptio will be thrown
// if we don't wait for it.
if (isFinishing()) {
return;
}
// Apply extracted theme color to icons.
final ImageView iconGlasses = findViewById(R.id.icon_glasses);
final ImageView iconLooking = findViewById(R.id.icon_looking);
@@ -152,8 +172,6 @@ public class FaceEnrollIntroduction extends BiometricEnrollIntroduction {
infoMessageRequireEyes.setText(getInfoMessageRequireEyes());
}
mFaceManager = getFaceManager();
// This path is an entry point for SetNewPasswordController, e.g.
// adb shell am start -a android.app.action.SET_NEW_PASSWORD
if (mToken == null && BiometricUtils.containsGatekeeperPasswordHandle(getIntent())) {
@@ -191,6 +209,24 @@ public class FaceEnrollIntroduction extends BiometricEnrollIntroduction {
Log.v(TAG, "cameraPrivacyEnabled : " + cameraPrivacyEnabled);
}
private void launchFaceSettingsActivity() {
final Intent intent = new Intent(this, Settings.FaceSettingsInternalActivity.class);
final byte[] token = getIntent().getByteArrayExtra(
ChooseLockSettingsHelper.EXTRA_KEY_CHALLENGE_TOKEN);
if (token != null) {
intent.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_CHALLENGE_TOKEN, token);
}
final int userId = getIntent().getIntExtra(Intent.EXTRA_USER_ID, UserHandle.myUserId());
if (userId != UserHandle.USER_NULL) {
intent.putExtra(Intent.EXTRA_USER_ID, userId);
}
BiometricUtils.copyMultiBiometricExtras(getIntent(), intent);
intent.putExtra(EXTRA_FROM_SETTINGS_SUMMARY, true);
intent.putExtra(EXTRA_KEY_CHALLENGE, getIntent().getLongExtra(EXTRA_KEY_CHALLENGE, -1L));
intent.putExtra(EXTRA_KEY_SENSOR_ID, getIntent().getIntExtra(EXTRA_KEY_SENSOR_ID, -1));
startActivity(intent);
}
@VisibleForTesting
@Nullable
protected FaceManager getFaceManager() {
@@ -232,6 +268,15 @@ public class FaceEnrollIntroduction extends BiometricEnrollIntroduction {
@Override
protected void onStart() {
super.onStart();
listenFoldEventForPostureGuidance();
}
private void listenFoldEventForPostureGuidance() {
if (maxFacesEnrolled()) {
Log.d(TAG, "Device has enrolled face, do not show posture guidance");
return;
}
if (getPostureGuidanceIntent() == null) {
Log.d(TAG, "Device do not support posture guidance");
return;