OSDN Git Service

am 46eb1857: (-s ours) Import translations. DO NOT MERGE
[android-x86/packages-apps-Settings.git] / src / com / android / settings / ConfirmDeviceCredentialActivity.java
1
2 /*
3  * Copyright (C) 2014 The Android Open Source Project
4  *
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
8  *
9  *      http://www.apache.org/licenses/LICENSE-2.0
10  *
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.
16  */
17
18 package com.android.settings;
19
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;
25
26 /**
27  * Launch this when you want to confirm the user is present by asking them to enter their
28  * PIN/password/pattern.
29  */
30 public class ConfirmDeviceCredentialActivity extends Activity {
31     public static final String TAG = ConfirmDeviceCredentialActivity.class.getSimpleName();
32
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);
39         return intent;
40     }
41
42     @Override
43     public void onCreate(Bundle savedInstanceState) {
44         super.onCreate(savedInstanceState);
45
46         Intent intent = getIntent();
47         String title = intent.getStringExtra(KeyguardManager.EXTRA_TITLE);
48         String details = intent.getStringExtra(KeyguardManager.EXTRA_DESCRIPTION);
49
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);
54             finish();
55         }
56     }
57
58     @Override
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);
63         finish();
64     }
65 }