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 R.string.security_settings_fingerprint_v2_enroll_introduction_footer_message_consent_6 49 }; 50 51 @Override onCreate(Bundle savedInstanceState)52 protected void onCreate(Bundle savedInstanceState) { 53 super.onCreate(savedInstanceState); 54 55 setDescriptionText( 56 R.string.security_settings_fingerprint_enroll_introduction_consent_message); 57 } 58 59 @Override onNextButtonClick(View view)60 protected void onNextButtonClick(View view) { 61 onConsentResult(true /* granted */); 62 } 63 64 @Override onSkipButtonClick(View view)65 protected void onSkipButtonClick(View view) { 66 onConsentResult(false /* granted */); 67 } 68 69 @Override onEnrollmentSkipped(@ullable Intent data)70 protected void onEnrollmentSkipped(@Nullable Intent data) { 71 onConsentResult(false /* granted */); 72 } 73 74 @Override onFinishedEnrolling(@ullable Intent data)75 protected void onFinishedEnrolling(@Nullable Intent data) { 76 onConsentResult(true /* granted */); 77 } 78 onConsentResult(boolean granted)79 private void onConsentResult(boolean granted) { 80 final Intent result = new Intent(); 81 result.putExtra(EXTRA_KEY_MODALITY, TYPE_FINGERPRINT); 82 setResult(granted ? RESULT_CONSENT_GRANTED : RESULT_CONSENT_DENIED, result); 83 finish(); 84 } 85 86 @Override onSetOrConfirmCredentials(@ullable Intent data)87 protected boolean onSetOrConfirmCredentials(@Nullable Intent data) { 88 // prevent challenge from being generated by default 89 return true; 90 } 91 92 @StringRes 93 @Override getFooterTitle1()94 protected int getFooterTitle1() { 95 return R.string.security_settings_fingerprint_enroll_introduction_footer_title_consent_1; 96 } 97 98 @StringRes 99 @Override getFooterMessage2()100 protected int getFooterMessage2() { 101 return R.string.security_settings_fingerprint_v2_enroll_introduction_footer_message_consent_2; 102 } 103 104 @StringRes 105 @Override getFooterMessage3()106 protected int getFooterMessage3() { 107 return R.string.security_settings_fingerprint_v2_enroll_introduction_footer_message_consent_3; 108 } 109 110 @StringRes getFooterMessage4()111 protected int getFooterMessage4() { 112 return R.string.security_settings_fingerprint_v2_enroll_introduction_footer_message_consent_4; 113 } 114 115 @StringRes getFooterMessage5()116 protected int getFooterMessage5() { 117 return R.string.security_settings_fingerprint_v2_enroll_introduction_footer_message_consent_5; 118 } 119 120 @StringRes getFooterMessage6()121 protected int getFooterMessage6() { 122 return R.string.security_settings_fingerprint_v2_enroll_introduction_footer_message_consent_6; 123 } 124 125 @Override getHeaderResDefault()126 protected int getHeaderResDefault() { 127 return R.string.security_settings_fingerprint_enroll_consent_introduction_title; 128 } 129 130 @Override getMetricsCategory()131 public int getMetricsCategory() { 132 return SettingsEnums.FINGERPRINT_PARENTAL_CONSENT; 133 } 134 135 136 @Override updateDescriptionText()137 protected void updateDescriptionText() { 138 super.updateDescriptionText(); 139 setDescriptionText( 140 R.string.security_settings_fingerprint_enroll_introduction_consent_message); 141 } 142 } 143