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
17package com.android.settings.password;
18
19import android.annotation.Nullable;
20import android.app.Activity;
21import android.app.admin.DevicePolicyManager;
22import android.content.Intent;
23import android.os.Bundle;
24
25import com.android.settings.ChooseLockGeneric;
26
27/**
28 * Trampolines {@link DevicePolicyManager#ACTION_SET_NEW_PASSWORD} and
29 * {@link DevicePolicyManager#ACTION_SET_NEW_PARENT_PROFILE_PASSWORD} intent to the appropriate UI
30 * activity for handling set new password.
31 */
32public class SetNewPasswordActivity extends Activity implements SetNewPasswordController.Ui {
33    private String mNewPasswordAction;
34    private SetNewPasswordController mSetNewPasswordController;
35
36    @Override
37    protected void onCreate(Bundle savedState) {
38        super.onCreate(savedState);
39
40        mNewPasswordAction = getIntent().getAction();
41        mSetNewPasswordController = new SetNewPasswordController(this, this);
42        mSetNewPasswordController.dispatchSetNewPasswordIntent();
43    }
44
45    @Override
46    public void launchChooseLock(@Nullable Bundle chooseLockFingerprintExtras) {
47        Intent intent = new Intent(this, ChooseLockGeneric.class)
48                .setAction(mNewPasswordAction);
49        if (chooseLockFingerprintExtras != null) {
50            intent.putExtras(chooseLockFingerprintExtras);
51        }
52        startActivity(intent);
53        finish();
54    }
55}
56