From 66d09a42d904375a00ffe5d4c3913982a441aa22 Mon Sep 17 00:00:00 2001 From: Kevin Chyn Date: Wed, 31 Oct 2018 13:30:44 -0700 Subject: [PATCH] Add android.settings.BIOMETRIC_ENROLL action intent Fixes: 112925362 Test: adb shell am start -a android.settings.BIOMETRIC_ENROLL Change-Id: I8dc37520b290483dab46cee2f6ca8612f4cf870e --- AndroidManifest.xml | 9 +++ .../biometrics/BiometricEnrollActivity.java | 60 +++++++++++++++++++ 2 files changed, 69 insertions(+) create mode 100644 src/com/android/settings/biometrics/BiometricEnrollActivity.java diff --git a/AndroidManifest.xml b/AndroidManifest.xml index 8cad8a4ba6f..bbabe90ecaf 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -1524,6 +1524,15 @@ android:exported="false" android:screenOrientation="portrait"/> + + + + + + + diff --git a/src/com/android/settings/biometrics/BiometricEnrollActivity.java b/src/com/android/settings/biometrics/BiometricEnrollActivity.java new file mode 100644 index 00000000000..ee359454007 --- /dev/null +++ b/src/com/android/settings/biometrics/BiometricEnrollActivity.java @@ -0,0 +1,60 @@ +/* + * Copyright (C) 2018 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License + */ + +package com.android.settings.biometrics; + +import android.app.settings.SettingsEnums; +import android.content.Intent; +import android.content.pm.PackageManager; +import android.os.Bundle; + +import com.android.settings.biometrics.face.FaceEnrollIntroduction; +import com.android.settings.biometrics.fingerprint.FingerprintEnrollIntroduction; +import com.android.settings.core.InstrumentedActivity; + +/** + * Trampoline activity launched by the {@code android.settings.BIOMETRIC_ENROLL} action which + * shows the user an appropriate enrollment flow depending on the device's biometric hardware. + * This activity must only allow enrollment of biometrics that can be used by + * {@link android.hardware.biometrics.BiometricPrompt}. + */ +public class BiometricEnrollActivity extends InstrumentedActivity { + + private static final String SETTINGS_PACKAGE = "com.android.settings"; + + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + + final PackageManager pm = getApplicationContext().getPackageManager(); + final Intent intent = new Intent(); + + // This logic may have to be modified on devices with multiple biometrics. + if (pm.hasSystemFeature(PackageManager.FEATURE_FINGERPRINT)) { + intent.setClassName(SETTINGS_PACKAGE, FingerprintEnrollIntroduction.class.getName()); + } else if (pm.hasSystemFeature(PackageManager.FEATURE_FACE)) { + intent.setClassName(SETTINGS_PACKAGE, FaceEnrollIntroduction.class.getName()); + } + + startActivity(intent); + finish(); + } + + @Override + public int getMetricsCategory() { + return SettingsEnums.BIOMETRIC_ENROLL_ACTIVITY; + } +}