Properly expose LockTypes constants as systemAPIs
Test: N/A Bug: 182260585 Change-Id: Iaab2608eb206cd41b906dea728f2430efe0560c6
This commit is contained in:
committed by
Kholoud Mohamed
parent
39217229c8
commit
62f2f6a670
@@ -698,6 +698,9 @@ package android.app {
|
||||
method @RequiresPermission(android.Manifest.permission.SHOW_KEYGUARD_MESSAGE) public void requestDismissKeyguard(@NonNull android.app.Activity, @Nullable CharSequence, @Nullable android.app.KeyguardManager.KeyguardDismissCallback);
|
||||
method @RequiresPermission("android.permission.SET_INITIAL_LOCK") public boolean setLock(int, @NonNull byte[], int);
|
||||
method @RequiresPermission(android.Manifest.permission.CONTROL_KEYGUARD_SECURE_NOTIFICATIONS) public void setPrivateNotificationsAllowed(boolean);
|
||||
field public static final int PASSWORD = 0; // 0x0
|
||||
field public static final int PATTERN = 2; // 0x2
|
||||
field public static final int PIN = 1; // 0x1
|
||||
}
|
||||
|
||||
public class Notification implements android.os.Parcelable {
|
||||
|
||||
@@ -133,6 +133,42 @@ public class KeyguardManager {
|
||||
*/
|
||||
public static final String EXTRA_DISALLOW_BIOMETRICS_IF_POLICY_EXISTS = "check_dpm";
|
||||
|
||||
/**
|
||||
*
|
||||
* Password lock type, see {@link #setLock}
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
@SystemApi
|
||||
public static final int PASSWORD = 0;
|
||||
|
||||
/**
|
||||
*
|
||||
* Pin lock type, see {@link #setLock}
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
@SystemApi
|
||||
public static final int PIN = 1;
|
||||
|
||||
/**
|
||||
*
|
||||
* Pattern lock type, see {@link #setLock}
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
@SystemApi
|
||||
public static final int PATTERN = 2;
|
||||
|
||||
/**
|
||||
* Available lock types
|
||||
*/
|
||||
@IntDef({
|
||||
PASSWORD,
|
||||
PIN,
|
||||
PATTERN
|
||||
})
|
||||
@interface LockTypes {}
|
||||
|
||||
/**
|
||||
* Get an intent to prompt the user to confirm credentials (pin, pattern, password or biometrics
|
||||
@@ -695,7 +731,7 @@ public class KeyguardManager {
|
||||
PasswordMetrics adminMetrics =
|
||||
devicePolicyManager.getPasswordMinimumMetrics(mContext.getUserId());
|
||||
// Check if the password fits the mold of a pin or pattern.
|
||||
boolean isPinOrPattern = lockType != LockTypes.PASSWORD;
|
||||
boolean isPinOrPattern = lockType != PASSWORD;
|
||||
|
||||
return PasswordMetrics.validatePassword(
|
||||
adminMetrics, complexity, isPinOrPattern, password).size() == 0;
|
||||
@@ -759,7 +795,7 @@ public class KeyguardManager {
|
||||
boolean success = false;
|
||||
try {
|
||||
switch (lockType) {
|
||||
case LockTypes.PASSWORD:
|
||||
case PASSWORD:
|
||||
CharSequence passwordStr = new String(password, Charset.forName("UTF-8"));
|
||||
lockPatternUtils.setLockCredential(
|
||||
LockscreenCredential.createPassword(passwordStr),
|
||||
@@ -767,7 +803,7 @@ public class KeyguardManager {
|
||||
userId);
|
||||
success = true;
|
||||
break;
|
||||
case LockTypes.PIN:
|
||||
case PIN:
|
||||
CharSequence pinStr = new String(password);
|
||||
lockPatternUtils.setLockCredential(
|
||||
LockscreenCredential.createPin(pinStr),
|
||||
@@ -775,7 +811,7 @@ public class KeyguardManager {
|
||||
userId);
|
||||
success = true;
|
||||
break;
|
||||
case LockTypes.PATTERN:
|
||||
case PATTERN:
|
||||
List<LockPatternView.Cell> pattern =
|
||||
LockPatternUtils.byteArrayToPattern(password);
|
||||
lockPatternUtils.setLockCredential(
|
||||
@@ -796,18 +832,4 @@ public class KeyguardManager {
|
||||
}
|
||||
return success;
|
||||
}
|
||||
|
||||
/**
|
||||
* Available lock types
|
||||
*/
|
||||
@IntDef({
|
||||
LockTypes.PASSWORD,
|
||||
LockTypes.PIN,
|
||||
LockTypes.PATTERN
|
||||
})
|
||||
@interface LockTypes {
|
||||
int PASSWORD = 0;
|
||||
int PIN = 1;
|
||||
int PATTERN = 2;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user