2 * Copyright (C) 2015 The Android Open Source Project
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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
17 package com.android.settings.fingerprint;
19 import android.app.admin.DevicePolicyManager;
20 import android.content.Intent;
21 import android.hardware.fingerprint.FingerprintManager;
22 import android.os.Bundle;
24 import com.android.settings.ChooseLockGeneric;
25 import com.android.settings.ChooseLockSettingsHelper;
26 import com.android.settings.R;
29 * Onboarding activity for fingerprint enrollment.
31 public class FingerprintEnrollOnboard extends FingerprintEnrollBase {
33 private static final int CHOOSE_LOCK_GENERIC_REQUEST = 1;
36 protected void onCreate(Bundle savedInstanceState) {
37 super.onCreate(savedInstanceState);
38 setContentView(R.layout.fingerprint_enroll_onboard);
39 setHeaderText(R.string.security_settings_fingerprint_enroll_onboard_title);
43 protected void onNextButtonClick() {
48 protected void onActivityResult(int requestCode, int resultCode, Intent data) {
49 if (requestCode == CHOOSE_LOCK_GENERIC_REQUEST && resultCode == RESULT_FINISHED) {
50 byte[] token = data.getByteArrayExtra(
51 ChooseLockSettingsHelper.EXTRA_KEY_CHALLENGE_TOKEN);
52 setResult(RESULT_FINISHED);
53 launchFindSensor(token);
55 super.onActivityResult(requestCode, resultCode, data);
59 private void launchChooseLock() {
60 Intent intent = new Intent();
61 long challenge = getSystemService(FingerprintManager.class).preEnroll();
62 intent.setClassName("com.android.settings", ChooseLockGeneric.class.getName());
63 intent.putExtra(ChooseLockGeneric.ChooseLockGenericFragment.MINIMUM_QUALITY_KEY,
64 DevicePolicyManager.PASSWORD_QUALITY_SOMETHING);
65 intent.putExtra(ChooseLockGeneric.ChooseLockGenericFragment.HIDE_DISABLED_PREFS, true);
66 intent.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_HAS_CHALLENGE, true);
67 intent.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_CHALLENGE, challenge);
68 startActivityForResult(intent, CHOOSE_LOCK_GENERIC_REQUEST);
71 private void launchFindSensor(byte[] token) {
72 Intent intent = new Intent();
73 intent.setClassName("com.android.settings", FingerprintEnrollFindSensor.class.getName());
74 intent.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_CHALLENGE_TOKEN, token);
75 startActivity(intent);