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 @Override onCreate(Bundle savedInstanceState)37 protected void onCreate(Bundle savedInstanceState) { 38 super.onCreate(savedInstanceState); 39 40 setDescriptionText( 41 R.string.security_settings_fingerprint_enroll_introduction_consent_message); 42 } 43 44 @Override onNextButtonClick(View view)45 protected void onNextButtonClick(View view) { 46 onConsentResult(true /* granted */); 47 } 48 49 @Override onSkipButtonClick(View view)50 protected void onSkipButtonClick(View view) { 51 onConsentResult(false /* granted */); 52 } 53 54 @Override onEnrollmentSkipped(@ullable Intent data)55 protected void onEnrollmentSkipped(@Nullable Intent data) { 56 onConsentResult(false /* granted */); 57 } 58 59 @Override onFinishedEnrolling(@ullable Intent data)60 protected void onFinishedEnrolling(@Nullable Intent data) { 61 onConsentResult(true /* granted */); 62 } 63 onConsentResult(boolean granted)64 private void onConsentResult(boolean granted) { 65 final Intent result = new Intent(); 66 result.putExtra(EXTRA_KEY_MODALITY, TYPE_FINGERPRINT); 67 setResult(granted ? RESULT_CONSENT_GRANTED : RESULT_CONSENT_DENIED, result); 68 finish(); 69 } 70 71 @Override onSetOrConfirmCredentials(@ullable Intent data)72 protected boolean onSetOrConfirmCredentials(@Nullable Intent data) { 73 // prevent challenge from being generated by default 74 return true; 75 } 76 77 @StringRes 78 @Override getFooterTitle1()79 protected int getFooterTitle1() { 80 return R.string.security_settings_fingerprint_enroll_introduction_footer_title_consent_1; 81 } 82 83 @StringRes 84 @Override getFooterMessage2()85 protected int getFooterMessage2() { 86 return R.string.security_settings_fingerprint_v2_enroll_introduction_footer_message_consent_2; 87 } 88 89 @StringRes 90 @Override getFooterMessage3()91 protected int getFooterMessage3() { 92 return R.string.security_settings_fingerprint_v2_enroll_introduction_footer_message_consent_3; 93 } 94 95 @StringRes getFooterMessage4()96 protected int getFooterMessage4() { 97 return R.string.security_settings_fingerprint_v2_enroll_introduction_footer_message_consent_4; 98 } 99 100 @StringRes getFooterMessage5()101 protected int getFooterMessage5() { 102 return R.string.security_settings_fingerprint_v2_enroll_introduction_footer_message_consent_5; 103 } 104 105 @Override getHeaderResDefault()106 protected int getHeaderResDefault() { 107 return R.string.security_settings_fingerprint_enroll_consent_introduction_title; 108 } 109 110 @Override getMetricsCategory()111 public int getMetricsCategory() { 112 return SettingsEnums.FINGERPRINT_PARENTAL_CONSENT; 113 } 114 } 115