1 /*
2  * Copyright (C) 2023 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.privatespace.onelock;
18 
19 import android.app.settings.SettingsEnums;
20 import android.content.Context;
21 import android.os.UserHandle;
22 import android.util.Log;
23 
24 import com.android.settings.R;
25 import com.android.settings.biometrics.combination.BiometricsSettingsBase;
26 import com.android.settings.privatespace.PrivateSpaceMaintainer;
27 
28 public class PrivateSpaceBiometricSettings extends BiometricsSettingsBase {
29     private static final String TAG = "PSBiometricSettings";
30     private static final String KEY_FACE_SETTINGS = "private_space_face_unlock_settings";
31     private static final String KEY_FINGERPRINT_SETTINGS =
32             "private_space_fingerprint_unlock_settings";
33 
34     @Override
onAttach(Context context)35     public void onAttach(Context context) {
36         if (android.os.Flags.allowPrivateProfile()
37                 && android.multiuser.Flags.enableBiometricsToUnlockPrivateSpace()
38                 && android.multiuser.Flags.enablePrivateSpaceFeatures()) {
39             super.onAttach(context);
40             UserHandle privateProfileHandle =
41                     PrivateSpaceMaintainer.getInstance(context).getPrivateProfileHandle();
42             if (privateProfileHandle != null) {
43                 mUserId = privateProfileHandle.getIdentifier();
44             } else {
45                 mUserId = -1;
46                 Log.e(TAG, "Private profile user handle is not expected to be null.");
47             }
48         }
49     }
50 
51     @Override
getPreferenceScreenResId()52     protected int getPreferenceScreenResId() {
53         return R.xml.private_space_biometric_settings;
54     }
55 
56     @Override
getFacePreferenceKey()57     public String getFacePreferenceKey() {
58         return KEY_FACE_SETTINGS;
59     }
60 
61     @Override
getFingerprintPreferenceKey()62     public String getFingerprintPreferenceKey() {
63         return KEY_FINGERPRINT_SETTINGS;
64     }
65 
66     @Override
getUnlockPhonePreferenceKey()67     public String getUnlockPhonePreferenceKey() {
68         return "";
69     }
70 
71     @Override
getUseInAppsPreferenceKey()72     public String getUseInAppsPreferenceKey() {
73         return "";
74     }
75 
76     @Override
getLogTag()77     protected String getLogTag() {
78         return TAG;
79     }
80 
81     @Override
getMetricsCategory()82     public int getMetricsCategory() {
83         return SettingsEnums.PRIVATE_SPACE_SETTINGS;
84     }
85 }
86