• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2015 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.Activity;
20 import android.app.Dialog;
21 import android.app.settings.SettingsEnums;
22 import android.content.DialogInterface;
23 import android.content.Intent;
24 import android.os.Bundle;
25 import android.os.UserHandle;
26 import android.view.View;
27 
28 import androidx.annotation.NonNull;
29 import androidx.appcompat.app.AlertDialog;
30 import androidx.fragment.app.FragmentManager;
31 
32 import com.android.settings.R;
33 import com.android.settings.SetupWizardUtils;
34 import com.android.settings.biometrics.BiometricUtils;
35 import com.android.settings.core.instrumentation.InstrumentedDialogFragment;
36 import com.android.settings.password.ChooseLockSettingsHelper;
37 
38 public class SetupFingerprintEnrollFindSensor extends FingerprintEnrollFindSensor {
39 
40     @Override
getFingerprintEnrollingIntent()41     protected Intent getFingerprintEnrollingIntent() {
42         Intent intent = new Intent(this, SetupFingerprintEnrollEnrolling.class);
43         intent.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_CHALLENGE_TOKEN, mToken);
44         intent.putExtra(EXTRA_KEY_CHALLENGE, mChallenge);
45         intent.putExtra(EXTRA_KEY_SENSOR_ID, mSensorId);
46         if (mUserId != UserHandle.USER_NULL) {
47             intent.putExtra(Intent.EXTRA_USER_ID, mUserId);
48         }
49         BiometricUtils.copyMultiBiometricExtras(getIntent(), intent);
50         SetupWizardUtils.copySetupExtras(getIntent(), intent);
51         return intent;
52     }
53 
54     @Override
onSkipButtonClick(View view)55     protected void onSkipButtonClick(View view) {
56         new SkipFingerprintDialog().show(getSupportFragmentManager());
57     }
58 
59     @Override
getMetricsCategory()60     public int getMetricsCategory() {
61         return SettingsEnums.FINGERPRINT_FIND_SENSOR_SETUP;
62     }
63 
64     public static class SkipFingerprintDialog extends InstrumentedDialogFragment
65             implements DialogInterface.OnClickListener {
66         private static final String TAG_SKIP_DIALOG = "skip_dialog";
67 
68         @Override
getMetricsCategory()69         public int getMetricsCategory() {
70             return SettingsEnums.DIALOG_FINGERPRINT_SKIP_SETUP;
71         }
72 
73         @Override
onCreateDialog(Bundle savedInstanceState)74         public Dialog onCreateDialog(Bundle savedInstanceState) {
75             return onCreateDialogBuilder().create();
76         }
77 
78         @NonNull
onCreateDialogBuilder()79         public AlertDialog.Builder onCreateDialogBuilder() {
80             return new AlertDialog.Builder(getActivity(), R.style.Theme_AlertDialog)
81                     .setTitle(R.string.setup_fingerprint_enroll_skip_title)
82                     .setPositiveButton(R.string.skip_anyway_button_label, this)
83                     .setNegativeButton(R.string.go_back_button_label, this)
84                     .setMessage(R.string.setup_fingerprint_enroll_skip_after_adding_lock_text);
85         }
86 
87         @Override
onClick(DialogInterface dialog, int button)88         public void onClick(DialogInterface dialog, int button) {
89             switch (button) {
90                 case DialogInterface.BUTTON_POSITIVE:
91                     Activity activity = getActivity();
92                     if (activity != null) {
93                         activity.setResult(RESULT_SKIP);
94                         activity.finish();
95                     }
96                     break;
97             }
98         }
99 
show(FragmentManager manager)100         public void show(FragmentManager manager) {
101             show(manager, TAG_SKIP_DIALOG);
102         }
103     }
104 }
105