Add handoff activity to parental consent flow.
Bug: 188847063
Test: manual
Change-Id: Ib6f38aae487a536fb8e85d608a22378a17c1bc64
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 6f6482d..0c65f01 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -1823,6 +1823,10 @@
android:exported="false"
android:screenOrientation="portrait"/>
+ <activity android:name=".biometrics.BiometricHandoffActivity"
+ android:exported="false"
+ android:screenOrientation="portrait"/>
+
<!-- Must not be exported -->
<activity android:name=".biometrics.BiometricEnrollActivity$InternalActivity"
android:exported="false"
diff --git a/res/layout/biometric_handoff.xml b/res/layout/biometric_handoff.xml
new file mode 100644
index 0000000..4861568
--- /dev/null
+++ b/res/layout/biometric_handoff.xml
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ ~ Copyright (C) 2021 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.
+ -->
+
+<com.google.android.setupdesign.GlifLayout
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ style="?attr/face_layout_theme"
+ android:id="@+id/setup_wizard_layout"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent">
+</com.google.android.setupdesign.GlifLayout>
\ No newline at end of file
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 1fba96c..7493e74 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -1008,6 +1008,10 @@
<string name="biometric_settings_use_biometric_unlock_phone">Unlocking your phone</string>
<!-- Text shown on a toggle which allows or disallows the device to use biometric for authentication. [CHAR LIMIT=50] -->
<string name="biometric_settings_use_biometric_for_apps">Authentication in apps</string>
+ <!-- Message shown during enrollment to prompt a child to give the device to a parent or guardian. [CHAR LIMIT=NONE]-->
+ <string name="biometric_settings_hand_back_to_guardian">Hand the phone back to your parent</string>
+ <!-- Button text shown during enrollment to proceed after a child user has handed the device to a parent or guardian. [CHAR LIMIT=22] -->
+ <string name="biometric_settings_hand_back_to_guardian_ok">OK</string>
<!-- Title of dialog shown when the user tries to skip setting up a screen lock, warning them of potential consequences of not doing so [CHAR LIMIT=30]-->
<string name="lock_screen_intro_skip_title">Skip screen lock?</string>
diff --git a/src/com/android/settings/biometrics/BiometricEnrollActivity.java b/src/com/android/settings/biometrics/BiometricEnrollActivity.java
index 6ab9ab8..db5e003 100644
--- a/src/com/android/settings/biometrics/BiometricEnrollActivity.java
+++ b/src/com/android/settings/biometrics/BiometricEnrollActivity.java
@@ -69,6 +69,8 @@
private static final int REQUEST_CONFIRM_LOCK = 2;
// prompt for parental consent options
private static final int REQUEST_CHOOSE_OPTIONS = 3;
+ // prompt hand phone back to parent after enrollment
+ private static final int REQUEST_HANDOFF_PARENT = 4;
public static final int RESULT_SKIP = BiometricEnrollBase.RESULT_SKIP;
@@ -303,11 +305,8 @@
final boolean isStillPrompting = mParentalConsentHelper.launchNext(
this, REQUEST_CHOOSE_OPTIONS, resultCode, data);
if (!isStillPrompting) {
- Log.d(TAG, "Enrollment options set, starting enrollment now");
-
- mParentalOptions = mParentalConsentHelper.getConsentResult();
- mParentalConsentHelper = null;
- startEnroll();
+ Log.d(TAG, "Enrollment options set, requesting handoff");
+ launchHandoffToParent();
}
} else {
Log.d(TAG, "Unknown or cancelled parental consent");
@@ -315,6 +314,18 @@
finish();
}
break;
+ case REQUEST_HANDOFF_PARENT:
+ if (resultCode == RESULT_OK) {
+ Log.d(TAG, "Enrollment options set, starting enrollment");
+ mParentalOptions = mParentalConsentHelper.getConsentResult();
+ mParentalConsentHelper = null;
+ startEnroll();
+ } else {
+ Log.d(TAG, "Unknown or cancelled handoff");
+ setResult(RESULT_CANCELED);
+ finish();
+ }
+ break;
default:
Log.w(TAG, "Unknown consenting requestCode: " + requestCode + ", finishing");
finish();
@@ -492,6 +503,11 @@
mMultiBiometricEnrollHelper.startNextStep();
}
+ private void launchHandoffToParent() {
+ final Intent intent = BiometricUtils.getHandoffToParentIntent(this, getIntent());
+ startActivityForResult(intent, REQUEST_HANDOFF_PARENT);
+ }
+
@Override
public int getMetricsCategory() {
return SettingsEnums.BIOMETRIC_ENROLL_ACTIVITY;
diff --git a/src/com/android/settings/biometrics/BiometricHandoffActivity.java b/src/com/android/settings/biometrics/BiometricHandoffActivity.java
new file mode 100644
index 0000000..f8ffe32
--- /dev/null
+++ b/src/com/android/settings/biometrics/BiometricHandoffActivity.java
@@ -0,0 +1,76 @@
+/*
+ * Copyright (C) 2021 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.os.Bundle;
+import android.view.View;
+
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
+
+import com.android.settings.R;
+
+import com.google.android.setupcompat.template.FooterBarMixin;
+import com.google.android.setupcompat.template.FooterButton;
+import com.google.android.setupdesign.GlifLayout;
+
+/**
+ * Prompts the user to hand the device to their parent or guardian.
+ */
+public class BiometricHandoffActivity extends BiometricEnrollBase {
+
+ @Nullable
+ private FooterButton mPrimaryFooterButton;
+
+ @Override
+ protected void onCreate(@Nullable Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.biometric_handoff);
+
+ setHeaderText(R.string.biometric_settings_hand_back_to_guardian);
+
+ final GlifLayout layout = getLayout();
+ mFooterBarMixin = layout.getMixin(FooterBarMixin.class);
+ mFooterBarMixin.setPrimaryButton(getPrimaryFooterButton());
+ }
+
+ @NonNull
+ protected FooterButton getPrimaryFooterButton() {
+ if (mPrimaryFooterButton == null) {
+ mPrimaryFooterButton = new FooterButton.Builder(this)
+ .setText(R.string.biometric_settings_hand_back_to_guardian_ok)
+ .setButtonType(FooterButton.ButtonType.NEXT)
+ .setListener(this::onNextButtonClick)
+ .setTheme(R.style.SudGlifButton_Primary)
+ .build();
+ }
+ return mPrimaryFooterButton;
+ }
+
+ @Override
+ protected void onNextButtonClick(View view) {
+ setResult(RESULT_OK);
+ finish();
+ }
+
+ @Override
+ public int getMetricsCategory() {
+ // TODO (b/188847063): add new category
+ return SettingsEnums.BIOMETRIC_ENROLL_ACTIVITY;
+ }
+}
diff --git a/src/com/android/settings/biometrics/BiometricUtils.java b/src/com/android/settings/biometrics/BiometricUtils.java
index 03cdb0d..a98c355 100644
--- a/src/com/android/settings/biometrics/BiometricUtils.java
+++ b/src/com/android/settings/biometrics/BiometricUtils.java
@@ -177,6 +177,19 @@
}
/**
+ * Start an activity that prompts the user to hand the device to their parent or guardian.
+ * @param context caller's context
+ * @param activityIntent The intent that started the caller's activity
+ * @return Intent for starting BiometricHandoffActivity
+ */
+ public static Intent getHandoffToParentIntent(@NonNull Context context,
+ @NonNull Intent activityIntent) {
+ final Intent intent = new Intent(context, BiometricHandoffActivity.class);
+ WizardManagerHelper.copyWizardManagerExtras(activityIntent, intent);
+ return intent;
+ }
+
+ /**
* @param activity Reference to the calling activity, used to startActivity
* @param intent Intent pointing to the enrollment activity
* @param requestCode If non-zero, will invoke startActivityForResult instead of startActivity
diff --git a/src/com/android/settings/biometrics/face/FaceEnrollParentalConsent.java b/src/com/android/settings/biometrics/face/FaceEnrollParentalConsent.java
index 1f55d82..5770a2e 100644
--- a/src/com/android/settings/biometrics/face/FaceEnrollParentalConsent.java
+++ b/src/com/android/settings/biometrics/face/FaceEnrollParentalConsent.java
@@ -30,7 +30,7 @@
/**
* Displays parental consent information for face authentication.
*
- * TODO(b/188847063): swap strings for consent screen
+ * TODO (b/188847063): add new metrics category
*/
public class FaceEnrollParentalConsent extends FaceEnrollIntroduction {
diff --git a/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollParentalConsent.java b/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollParentalConsent.java
index 5d8cf9b..fbd52b7 100644
--- a/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollParentalConsent.java
+++ b/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollParentalConsent.java
@@ -30,7 +30,7 @@
/**
* Displays parental consent information for fingerprint authentication.
*
- * TODO(b/188847063): swap strings for consent screen
+ * TODO (b/188847063): add new metrics category
*/
public class FingerprintEnrollParentalConsent extends FingerprintEnrollIntroduction {