Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 1a105fea authored by Maurice Lam's avatar Maurice Lam
Browse files

Tweaks to integrate BiometricEnrollActivity to SUW

- Default backup screen lock type to PIN when in SUW
- Propagate the result codes in BiometricEnrollIntroduction, so that
  when the user hits back, SUW will get RESULT_CANCELED
- Follow-up change that was missed in ag/6664364 to not start activity
  when neither fingerprint nor face is available

Test: Manual
Bug: 120797018
Change-Id: I6d4f662928451fb86f301ddb5c6586622c7e6cf7
parent a035165e
Loading
Loading
Loading
Loading
+5 −5
Original line number Diff line number Diff line
@@ -41,19 +41,19 @@ public class BiometricEnrollActivity extends InstrumentedActivity {
        super.onCreate(savedInstanceState);

        final PackageManager pm = getApplicationContext().getPackageManager();
        Intent intent;
        Intent intent = null;

        // This logic may have to be modified on devices with multiple biometrics.
        if (pm.hasSystemFeature(PackageManager.FEATURE_FINGERPRINT)) {
            intent = getFingerprintEnrollIntent();
        } else if (pm.hasSystemFeature(PackageManager.FEATURE_FACE)) {
            intent = getFaceEnrollIntent();
        } else {
            intent = new Intent();
        }

        if (intent != null) {
            intent.setFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT);
            startActivity(intent);
        }
        finish();
    }

+15 −7
Original line number Diff line number Diff line
@@ -21,11 +21,14 @@ import android.content.Intent;
import android.os.Bundle;
import android.os.UserHandle;
import android.os.UserManager;
import android.os.storage.StorageManager;
import android.view.View;
import android.widget.TextView;

import com.android.internal.widget.LockPatternUtils;
import com.android.settings.R;
import com.android.settings.password.ChooseLockGeneric;
import com.android.settings.password.ChooseLockGeneric.ChooseLockGenericFragment;
import com.android.settings.password.ChooseLockSettingsHelper;
import com.android.settings.password.SetupChooseLockGeneric;

@@ -202,7 +205,14 @@ public abstract class BiometricEnrollIntroduction extends BiometricEnrollBase

    protected Intent getChooseLockIntent() {
        if (WizardManagerHelper.isAnySetupWizard(getIntent())) {
            // Default to PIN lock in setup wizard
            Intent intent = new Intent(this, SetupChooseLockGeneric.class);
            if (StorageManager.isFileEncryptedNativeOrEmulated()) {
                intent.putExtra(
                        LockPatternUtils.PASSWORD_TYPE_KEY,
                        DevicePolicyManager.PASSWORD_QUALITY_NUMERIC);
                intent.putExtra(ChooseLockGenericFragment.EXTRA_SHOW_OPTIONS_BUTTON, true);
            }
            WizardManagerHelper.copyWizardManagerExtras(getIntent(), intent);
            return intent;
        } else {
@@ -212,23 +222,21 @@ public abstract class BiometricEnrollIntroduction extends BiometricEnrollBase

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        final boolean isResultFinished = resultCode == RESULT_FINISHED;
        final int result = isResultFinished ? RESULT_OK : RESULT_SKIP;
        if (requestCode == BIOMETRIC_FIND_SENSOR_REQUEST) {
            if (isResultFinished || resultCode == RESULT_SKIP) {
                setResult(result, data);
            if (resultCode == RESULT_FINISHED || resultCode == RESULT_SKIP) {
                setResult(resultCode, data);
                finish();
                return;
            }
        } else if (requestCode == CHOOSE_LOCK_GENERIC_REQUEST) {
            if (isResultFinished) {
            if (resultCode == RESULT_FINISHED) {
                updatePasswordQuality();
                mToken = data.getByteArrayExtra(
                        ChooseLockSettingsHelper.EXTRA_KEY_CHALLENGE_TOKEN);
                overridePendingTransition(R.anim.sud_slide_next_in, R.anim.sud_slide_next_out);
                return;
            } else {
                setResult(result, data);
                setResult(resultCode, data);
                finish();
            }
        } else if (requestCode == CONFIRM_REQUEST) {
@@ -236,7 +244,7 @@ public abstract class BiometricEnrollIntroduction extends BiometricEnrollBase
                mToken = data.getByteArrayExtra(ChooseLockSettingsHelper.EXTRA_KEY_CHALLENGE_TOKEN);
                overridePendingTransition(R.anim.sud_slide_next_in, R.anim.sud_slide_next_out);
            } else {
                setResult(result, data);
                setResult(resultCode, data);
                finish();
            }
        } else if (requestCode == LEARN_MORE_REQUEST) {