1 /* 2 * Copyright (C) 2021 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.android.settings.biometrics.fingerprint; 18 19 import static android.hardware.biometrics.BiometricAuthenticator.TYPE_FINGERPRINT; 20 21 import android.app.settings.SettingsEnums; 22 import android.content.Intent; 23 import android.os.Bundle; 24 import android.view.View; 25 26 import androidx.annotation.Nullable; 27 import androidx.annotation.StringRes; 28 29 import com.android.settings.R; 30 31 /** 32 * Displays parental consent information for fingerprint authentication. 33 */ 34 public class FingerprintEnrollParentalConsent extends FingerprintEnrollIntroduction { 35 36 /** 37 * List of string resources to log when recording the result of this activity in gms. 38 * This must be updated when any strings are added/removed. 39 */ 40 public static final int[] CONSENT_STRING_RESOURCES = new int[] { 41 R.string.security_settings_fingerprint_enroll_consent_introduction_title, 42 R.string.security_settings_fingerprint_enroll_introduction_consent_message, 43 R.string.security_settings_fingerprint_enroll_introduction_footer_title_consent_1, 44 R.string.security_settings_fingerprint_v2_enroll_introduction_footer_message_consent_2, 45 R.string.security_settings_fingerprint_v2_enroll_introduction_footer_message_consent_3, 46 R.string.security_settings_fingerprint_v2_enroll_introduction_footer_message_consent_4, 47 R.string.security_settings_fingerprint_v2_enroll_introduction_footer_message_consent_5 48 }; 49 50 @Override onCreate(Bundle savedInstanceState)51 protected void onCreate(Bundle savedInstanceState) { 52 super.onCreate(savedInstanceState); 53 54 setDescriptionText( 55 R.string.security_settings_fingerprint_enroll_introduction_consent_message); 56 } 57 58 @Override onNextButtonClick(View view)59 protected void onNextButtonClick(View view) { 60 onConsentResult(true /* granted */); 61 } 62 63 @Override onSkipButtonClick(View view)64 protected void onSkipButtonClick(View view) { 65 onConsentResult(false /* granted */); 66 } 67 68 @Override onEnrollmentSkipped(@ullable Intent data)69 protected void onEnrollmentSkipped(@Nullable Intent data) { 70 onConsentResult(false /* granted */); 71 } 72 73 @Override onFinishedEnrolling(@ullable Intent data)74 protected void onFinishedEnrolling(@Nullable Intent data) { 75 onConsentResult(true /* granted */); 76 } 77 onConsentResult(boolean granted)78 private void onConsentResult(boolean granted) { 79 final Intent result = new Intent(); 80 result.putExtra(EXTRA_KEY_MODALITY, TYPE_FINGERPRINT); 81 setResult(granted ? RESULT_CONSENT_GRANTED : RESULT_CONSENT_DENIED, result); 82 finish(); 83 } 84 85 @Override onSetOrConfirmCredentials(@ullable Intent data)86 protected boolean onSetOrConfirmCredentials(@Nullable Intent data) { 87 // prevent challenge from being generated by default 88 return true; 89 } 90 91 @StringRes 92 @Override getFooterTitle1()93 protected int getFooterTitle1() { 94 return R.string.security_settings_fingerprint_enroll_introduction_footer_title_consent_1; 95 } 96 97 @StringRes 98 @Override getFooterMessage2()99 protected int getFooterMessage2() { 100 return R.string.security_settings_fingerprint_v2_enroll_introduction_footer_message_consent_2; 101 } 102 103 @StringRes 104 @Override getFooterMessage3()105 protected int getFooterMessage3() { 106 return R.string.security_settings_fingerprint_v2_enroll_introduction_footer_message_consent_3; 107 } 108 109 @StringRes getFooterMessage4()110 protected int getFooterMessage4() { 111 return R.string.security_settings_fingerprint_v2_enroll_introduction_footer_message_consent_4; 112 } 113 114 @StringRes getFooterMessage5()115 protected int getFooterMessage5() { 116 return R.string.security_settings_fingerprint_v2_enroll_introduction_footer_message_consent_5; 117 } 118 119 @Override getHeaderResDefault()120 protected int getHeaderResDefault() { 121 return R.string.security_settings_fingerprint_enroll_consent_introduction_title; 122 } 123 124 @Override getMetricsCategory()125 public int getMetricsCategory() { 126 return SettingsEnums.FINGERPRINT_PARENTAL_CONSENT; 127 } 128 } 129