• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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.face;
18 
19 import static android.hardware.biometrics.BiometricAuthenticator.TYPE_FACE;
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 face authentication.
33  */
34 public class FaceEnrollParentalConsent extends FaceEnrollIntroduction {
35 
36     @Override
onCreate(Bundle savedInstanceState)37     protected void onCreate(Bundle savedInstanceState) {
38         super.onCreate(savedInstanceState);
39 
40         setDescriptionText(R.string.security_settings_face_enroll_introduction_consent_message);
41     }
42 
43     @Override
onNextButtonClick(View view)44     protected void onNextButtonClick(View view) {
45         onConsentResult(true /* granted */);
46     }
47 
48     @Override
onSkipButtonClick(View view)49     protected void onSkipButtonClick(View view) {
50         onConsentResult(false /* granted */);
51     }
52 
53     @Override
onEnrollmentSkipped(@ullable Intent data)54     protected void onEnrollmentSkipped(@Nullable Intent data) {
55         onConsentResult(false /* granted */);
56     }
57 
58     @Override
onFinishedEnrolling(@ullable Intent data)59     protected void onFinishedEnrolling(@Nullable Intent data) {
60         onConsentResult(true /* granted */);
61     }
62 
onConsentResult(boolean granted)63     private void onConsentResult(boolean granted) {
64         final Intent result = new Intent();
65         result.putExtra(EXTRA_KEY_MODALITY, TYPE_FACE);
66         setResult(granted ? RESULT_CONSENT_GRANTED : RESULT_CONSENT_DENIED, result);
67         finish();
68     }
69 
70     @Override
onSetOrConfirmCredentials(@ullable Intent data)71     protected boolean onSetOrConfirmCredentials(@Nullable Intent data) {
72         // prevent challenge from being generated by default
73         return true;
74     }
75 
76     @Override
generateChallengeOnCreate()77     protected boolean generateChallengeOnCreate() {
78         return false;
79     }
80 
81     @Override
82     @StringRes
getInfoMessageGlasses()83     protected int getInfoMessageGlasses() {
84         return R.string.security_settings_face_enroll_introduction_info_consent_glasses;
85     }
86 
87     @Override
88     @StringRes
getInfoMessageLooking()89     protected int getInfoMessageLooking() {
90         return R.string.security_settings_face_enroll_introduction_info_consent_looking;
91     }
92 
93     @Override
94     @StringRes
getInfoMessageRequireEyes()95     protected int getInfoMessageRequireEyes() {
96         return R.string.security_settings_face_enroll_introduction_info_consent_gaze;
97     }
98 
99     @Override
100     @StringRes
getHowMessage()101     protected int getHowMessage() {
102         return R.string.security_settings_face_enroll_introduction_how_consent_message;
103     }
104 
105     @Override
106     @StringRes
getInControlTitle()107     protected int getInControlTitle() {
108         return R.string.security_settings_face_enroll_introduction_control_consent_title;
109     }
110 
111     @Override
112     @StringRes
getInControlMessage()113     protected int getInControlMessage() {
114         return R.string.security_settings_face_enroll_introduction_control_consent_message;
115     }
116 
117     @Override
getHeaderResDefault()118     protected int getHeaderResDefault() {
119         return R.string.security_settings_face_enroll_consent_introduction_title;
120     }
121 
122     @Override
getMetricsCategory()123     public int getMetricsCategory() {
124         return SettingsEnums.FACE_PARENTAL_CONSENT;
125     }
126 }
127