3 * Copyright (C) 2014 The Android Open Source Project
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
18 package com.android.settings;
20 import android.app.Activity;
21 import android.app.KeyguardManager;
22 import android.content.Intent;
23 import android.os.Bundle;
24 import android.util.Log;
27 * Launch this when you want to confirm the user is present by asking them to enter their
28 * PIN/password/pattern.
30 public class ConfirmDeviceCredentialActivity extends Activity {
31 public static final String TAG = ConfirmDeviceCredentialActivity.class.getSimpleName();
33 public static Intent createIntent(CharSequence title, CharSequence details) {
34 Intent intent = new Intent();
35 intent.setClassName("com.android.settings",
36 ConfirmDeviceCredentialActivity.class.getName());
37 intent.putExtra(KeyguardManager.EXTRA_TITLE, title);
38 intent.putExtra(KeyguardManager.EXTRA_DESCRIPTION, details);
43 public void onCreate(Bundle savedInstanceState) {
44 super.onCreate(savedInstanceState);
46 Intent intent = getIntent();
47 String title = intent.getStringExtra(KeyguardManager.EXTRA_TITLE);
48 String details = intent.getStringExtra(KeyguardManager.EXTRA_DESCRIPTION);
50 ChooseLockSettingsHelper helper = new ChooseLockSettingsHelper(this);
51 if (!helper.launchConfirmationActivity(0 /* request code */, title, details)) {
52 Log.d(TAG, "No pattern, password or PIN set.");
53 setResult(Activity.RESULT_OK);
59 protected void onActivityResult(int requestCode, int resultCode, Intent data) {
60 boolean credentialsConfirmed = (resultCode == Activity.RESULT_OK);
61 Log.d(TAG, "Device credentials confirmed: " + credentialsConfirmed);
62 setResult(credentialsConfirmed ? Activity.RESULT_OK : Activity.RESULT_CANCELED);