Merge changes from topic "unicorn-hand" into sc-dev

* changes:
  Add new enum for parental consent UI.
  Add handoff activity to parental consent flow.
This commit is contained in:
Joe Bolinger
2021-06-21 17:06:29 +00:00
committed by Android (Google) Code Review
8 changed files with 153 additions and 9 deletions

View File

@@ -69,6 +69,8 @@ public class BiometricEnrollActivity extends InstrumentedActivity {
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 @@ public class BiometricEnrollActivity extends InstrumentedActivity {
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 @@ public class BiometricEnrollActivity extends InstrumentedActivity {
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 @@ public class BiometricEnrollActivity extends InstrumentedActivity {
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;

View File

@@ -0,0 +1,75 @@
/*
* 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() {
return SettingsEnums.BIOMETRIC_CONSENT_PARENT_TO_CHILD;
}
}

View File

@@ -176,6 +176,19 @@ public class BiometricUtils {
return intent;
}
/**
* 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

View File

@@ -18,6 +18,7 @@ package com.android.settings.biometrics.face;
import static android.hardware.biometrics.BiometricAuthenticator.TYPE_FACE;
import android.app.settings.SettingsEnums;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
@@ -29,8 +30,6 @@ import com.android.settings.R;
/**
* Displays parental consent information for face authentication.
*
* TODO(b/188847063): swap strings for consent screen
*/
public class FaceEnrollParentalConsent extends FaceEnrollIntroduction {
@@ -103,4 +102,9 @@ public class FaceEnrollParentalConsent extends FaceEnrollIntroduction {
protected int getHeaderResDefault() {
return R.string.security_settings_face_enroll_consent_introduction_title;
}
@Override
public int getMetricsCategory() {
return SettingsEnums.FACE_PARENTAL_CONSENT;
}
}

View File

@@ -18,6 +18,7 @@ package com.android.settings.biometrics.fingerprint;
import static android.hardware.biometrics.BiometricAuthenticator.TYPE_FINGERPRINT;
import android.app.settings.SettingsEnums;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
@@ -29,8 +30,6 @@ import com.android.settings.R;
/**
* Displays parental consent information for fingerprint authentication.
*
* TODO(b/188847063): swap strings for consent screen
*/
public class FingerprintEnrollParentalConsent extends FingerprintEnrollIntroduction {
@@ -97,4 +96,9 @@ public class FingerprintEnrollParentalConsent extends FingerprintEnrollIntroduct
protected int getHeaderResDefault() {
return R.string.security_settings_fingerprint_enroll_consent_introduction_title;
}
@Override
public int getMetricsCategory() {
return SettingsEnums.FINGERPRINT_PARENTAL_CONSENT;
}
}