• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2016 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.password;
18 
19 import static android.app.admin.DevicePolicyManager.ACTION_SET_NEW_PARENT_PROFILE_PASSWORD;
20 import static android.app.admin.DevicePolicyManager.ACTION_SET_NEW_PASSWORD;
21 
22 import android.app.Activity;
23 import android.app.admin.DevicePolicyManager;
24 import android.content.Intent;
25 import android.os.Bundle;
26 import android.util.Log;
27 
28 import com.android.settings.Utils;
29 
30 /**
31  * Trampolines {@link DevicePolicyManager#ACTION_SET_NEW_PASSWORD} and
32  * {@link DevicePolicyManager#ACTION_SET_NEW_PARENT_PROFILE_PASSWORD} intent to the appropriate UI
33  * activity for handling set new password.
34  */
35 public class SetNewPasswordActivity extends Activity implements SetNewPasswordController.Ui {
36     private static final String TAG = "SetNewPasswordActivity";
37     private String mNewPasswordAction;
38     private SetNewPasswordController mSetNewPasswordController;
39 
40     @Override
onCreate(Bundle savedState)41     protected void onCreate(Bundle savedState) {
42         super.onCreate(savedState);
43 
44         mNewPasswordAction = getIntent().getAction();
45         if (!ACTION_SET_NEW_PASSWORD.equals(mNewPasswordAction)
46                 && !ACTION_SET_NEW_PARENT_PROFILE_PASSWORD.equals(mNewPasswordAction)) {
47             Log.e(TAG, "Unexpected action to launch this activity");
48             finish();
49             return;
50         }
51         mSetNewPasswordController = SetNewPasswordController.create(
52                 this, this, getIntent(), getActivityToken());
53         mSetNewPasswordController.dispatchSetNewPasswordIntent();
54     }
55 
56     @Override
launchChooseLock(Bundle chooseLockFingerprintExtras)57     public void launchChooseLock(Bundle chooseLockFingerprintExtras) {
58         final boolean isInSetupWizard = !Utils.isDeviceProvisioned(this);
59         Intent intent = isInSetupWizard ? new Intent(this, SetupChooseLockGeneric.class)
60                 : new Intent(this, ChooseLockGeneric.class);
61         intent.setAction(mNewPasswordAction);
62         intent.putExtras(chooseLockFingerprintExtras);
63         startActivity(intent);
64         finish();
65     }
66 }
67