1 /* 2 * Copyright (C) 2017 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.fingerprint; 18 19 import android.app.admin.DevicePolicyManager; 20 import android.content.Context; 21 import android.hardware.fingerprint.FingerprintManager; 22 import android.widget.Button; 23 24 import com.android.settings.R; 25 import com.android.settings.Utils; 26 27 public class FingerprintSuggestionActivity extends SetupFingerprintEnrollIntroduction { 28 29 @Override 30 protected void initViews() { 31 super.initViews(); 32 33 final Button cancelButton = findViewById(R.id.fingerprint_cancel_button); 34 cancelButton.setText(R.string.security_settings_fingerprint_enroll_introduction_cancel); 35 } 36 37 @Override 38 public void finish() { 39 // Always use RESULT_CANCELED because this action can be done multiple times 40 setResult(RESULT_CANCELED); 41 super.finish(); 42 } 43 44 public static boolean isSuggestionComplete(Context context) { 45 return !Utils.hasFingerprintHardware(context) 46 || !isFingerprintEnabled(context) 47 || isNotSingleFingerprintEnrolled(context); 48 } 49 50 private static boolean isNotSingleFingerprintEnrolled(Context context) { 51 final FingerprintManager manager = Utils.getFingerprintManagerOrNull(context); 52 return manager == null || manager.getEnrolledFingerprints().size() != 1; 53 } 54 55 static boolean isFingerprintEnabled(Context context) { 56 final DevicePolicyManager dpManager = 57 (DevicePolicyManager) context.getSystemService(Context.DEVICE_POLICY_SERVICE); 58 final int dpmFlags = dpManager.getKeyguardDisabledFeatures(null, /* admin */ 59 context.getUserId()); 60 return (dpmFlags & DevicePolicyManager.KEYGUARD_DISABLE_FINGERPRINT) == 0; 61 } 62 } 63