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 package com.android.settings.biometrics.combination; 17 18 import android.app.admin.DevicePolicyManager; 19 import android.content.Context; 20 21 import androidx.lifecycle.Lifecycle; 22 import androidx.preference.Preference; 23 24 import com.android.settings.Utils; 25 import com.android.settings.biometrics.fingerprint.FingerprintStatusPreferenceController; 26 import com.android.settingslib.RestrictedLockUtils; 27 import com.android.settingslib.RestrictedLockUtilsInternal; 28 import com.android.settingslib.RestrictedPreference; 29 30 /** 31 * Preference controller for fingerprint settings within the biometrics settings page of work 32 * profile, that controls the ability to unlock the phone with fingerprint. 33 */ 34 public class BiometricFingerprintStatusPreferenceController extends 35 FingerprintStatusPreferenceController { 36 BiometricFingerprintStatusPreferenceController(Context context, String key)37 public BiometricFingerprintStatusPreferenceController(Context context, String key) { 38 super(context, key, null /* lifecycle */); 39 } 40 BiometricFingerprintStatusPreferenceController( Context context, String key, Lifecycle lifecycle)41 public BiometricFingerprintStatusPreferenceController( 42 Context context, String key, Lifecycle lifecycle) { 43 super(context, key, lifecycle); 44 } 45 46 @Override updateState(Preference preference)47 public void updateState(Preference preference) { 48 super.updateState(preference); 49 final boolean isFingerprintEnrolled = mFingerprintStatusUtils.hasEnrolled(); 50 final RestrictedLockUtils.EnforcedAdmin admin = 51 RestrictedLockUtilsInternal.checkIfKeyguardFeaturesDisabled( 52 mContext, DevicePolicyManager.KEYGUARD_DISABLE_FINGERPRINT, getUserId()); 53 if (admin != null && !isFingerprintEnrolled) { 54 ((RestrictedPreference) preference).setDisabledByAdmin(admin); 55 } else { 56 preference.setEnabled(true); 57 } 58 } 59 60 @Override isDeviceSupported()61 protected boolean isDeviceSupported() { 62 return Utils.isMultipleBiometricsSupported(mContext) && isHardwareSupported(); 63 } 64 65 @Override isHardwareSupported()66 protected boolean isHardwareSupported() { 67 return Utils.hasFingerprintHardware(mContext); 68 } 69 } 70