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