Toni Barzic | e7d6e4d | 2016-03-30 11:43:19 -0700 | [diff] [blame] | 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 | |
Maurice Lam | 2eb170c | 2017-04-28 16:18:47 -0700 | [diff] [blame] | 17 | package com.android.settings.password; |
Toni Barzic | e7d6e4d | 2016-03-30 11:43:19 -0700 | [diff] [blame] | 18 | |
| 19 | import android.content.Context; |
| 20 | import android.content.Intent; |
| 21 | |
Rubin Xu | 010116a | 2019-09-11 17:36:37 +0100 | [diff] [blame] | 22 | import com.android.internal.widget.LockscreenCredential; |
| 23 | |
Toni Barzic | e7d6e4d | 2016-03-30 11:43:19 -0700 | [diff] [blame] | 24 | /** |
| 25 | * Helper for handling managed passwords in security settings UI. |
| 26 | * It provides resources that should be shown in settings UI when lock password quality is set to |
| 27 | * {@link android.app.admin.DevicePolicyManager#PASSWORD_QUALITY_MANAGED} and hooks for implementing |
| 28 | * an option for setting the password quality to |
| 29 | * {@link android.app.admin.DevicePolicyManager#PASSWORD_QUALITY_MANAGED}. |
| 30 | */ |
| 31 | public class ManagedLockPasswordProvider { |
| 32 | /** Factory method to make it easier to inject extended ManagedLockPasswordProviders. */ |
Maurice Lam | 2eb170c | 2017-04-28 16:18:47 -0700 | [diff] [blame] | 33 | public static ManagedLockPasswordProvider get(Context context, int userId) { |
Toni Barzic | e7d6e4d | 2016-03-30 11:43:19 -0700 | [diff] [blame] | 34 | return new ManagedLockPasswordProvider(); |
| 35 | } |
| 36 | |
| 37 | protected ManagedLockPasswordProvider() {} |
| 38 | |
| 39 | /** |
| 40 | * Whether choosing/setting a managed lock password is supported for the user. |
| 41 | * Please update {@link #getPickerOptionTitle(boolean)} if overridden to return true. |
| 42 | */ |
| 43 | boolean isSettingManagedPasswordSupported() { return false; } |
| 44 | |
| 45 | /** |
| 46 | * Whether the user should be able to choose managed lock password. |
| 47 | */ |
| 48 | boolean isManagedPasswordChoosable() { return false; } |
| 49 | |
| 50 | /** |
| 51 | * Returns title for managed password preference in security (lock) setting picker. |
| 52 | * Should be overridden if {@link #isManagedPasswordSupported()} returns true. |
| 53 | * @param forFingerprint Whether fingerprint unlock is enabled. |
| 54 | */ |
Maurice Lam | edb3944 | 2017-04-27 18:54:33 -0700 | [diff] [blame] | 55 | CharSequence getPickerOptionTitle(boolean forFingerprint) { return ""; } |
Toni Barzic | e7d6e4d | 2016-03-30 11:43:19 -0700 | [diff] [blame] | 56 | |
| 57 | /** |
Toni Barzic | e7d6e4d | 2016-03-30 11:43:19 -0700 | [diff] [blame] | 58 | * Creates intent that should be launched when user chooses managed password in the lock |
| 59 | * settings picker. |
| 60 | * @param requirePasswordToDecrypt Whether a password is needed to decrypt the user. |
| 61 | * @param password Current lock password. |
| 62 | * @return Intent that should update lock password to a managed password. |
| 63 | */ |
Rubin Xu | 010116a | 2019-09-11 17:36:37 +0100 | [diff] [blame] | 64 | Intent createIntent(boolean requirePasswordToDecrypt, LockscreenCredential password) { |
Toni Barzic | e7d6e4d | 2016-03-30 11:43:19 -0700 | [diff] [blame] | 65 | return null; |
| 66 | } |
| 67 | } |