Clean up choose lock intent creation
Consolidated the many variants of ChooseLock*.createIntent, so that it will take the same set of arguments. Also modified SetupChooseLock*.createIntent to modifyIntentForSetup, which will take the intent created by ChooseLock* and modify it for use with setup. Test: cd tests/robotests && mma Change-Id: I5ff033f459c33ec9980872a536b3996d89f2bbbb
This commit is contained in:
@@ -0,0 +1,87 @@
|
||||
/*
|
||||
* Copyright (C) 2016 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License
|
||||
*/
|
||||
|
||||
package com.android.settings.password;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
|
||||
import com.android.settings.R;
|
||||
|
||||
/**
|
||||
* Helper for handling managed passwords in security settings UI.
|
||||
* It provides resources that should be shown in settings UI when lock password quality is set to
|
||||
* {@link android.app.admin.DevicePolicyManager#PASSWORD_QUALITY_MANAGED} and hooks for implementing
|
||||
* an option for setting the password quality to
|
||||
* {@link android.app.admin.DevicePolicyManager#PASSWORD_QUALITY_MANAGED}.
|
||||
*/
|
||||
public class ManagedLockPasswordProvider {
|
||||
/** Factory method to make it easier to inject extended ManagedLockPasswordProviders. */
|
||||
public static ManagedLockPasswordProvider get(Context context, int userId) {
|
||||
return new ManagedLockPasswordProvider();
|
||||
}
|
||||
|
||||
protected ManagedLockPasswordProvider() {}
|
||||
|
||||
/**
|
||||
* Whether choosing/setting a managed lock password is supported for the user.
|
||||
* Please update {@link #getPickerOptionTitle(boolean)} if overridden to return true.
|
||||
*/
|
||||
boolean isSettingManagedPasswordSupported() { return false; }
|
||||
|
||||
/**
|
||||
* Whether the user should be able to choose managed lock password.
|
||||
*/
|
||||
boolean isManagedPasswordChoosable() { return false; }
|
||||
|
||||
/**
|
||||
* Returns title for managed password preference in security (lock) setting picker.
|
||||
* Should be overridden if {@link #isManagedPasswordSupported()} returns true.
|
||||
* @param forFingerprint Whether fingerprint unlock is enabled.
|
||||
*/
|
||||
String getPickerOptionTitle(boolean forFingerprint) { return ""; }
|
||||
|
||||
/**
|
||||
* Gets resource id of the lock screen preference that should be displayed in security settings
|
||||
* if the current password quality is set to
|
||||
* {@link android.app.admin.DevicePolicyManager#PASSWORD_QUALITY_MANAGED}.
|
||||
* @param forProfile Whether the settings are shown for a user profile rather than a user.
|
||||
*/
|
||||
public int getResIdForLockUnlockScreen(boolean forProfile) {
|
||||
return forProfile ? R.xml.security_settings_password_profile
|
||||
: R.xml.security_settings_password;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets resource id of the subscreen that should be shown after clicking gear icon for lock
|
||||
* screen preference in security settings if the current password quality is set to
|
||||
* {@link android.app.admin.DevicePolicyManager#PASSWORD_QUALITY_MANAGED}.
|
||||
*/
|
||||
public int getResIdForLockUnlockSubScreen() {
|
||||
return R.xml.security_settings_password_sub;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates intent that should be launched when user chooses managed password in the lock
|
||||
* settings picker.
|
||||
* @param requirePasswordToDecrypt Whether a password is needed to decrypt the user.
|
||||
* @param password Current lock password.
|
||||
* @return Intent that should update lock password to a managed password.
|
||||
*/
|
||||
Intent createIntent(boolean requirePasswordToDecrypt, String password) {
|
||||
return null;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user