Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e7e5563e authored by Kholoud Mohamed's avatar Kholoud Mohamed Committed by Android (Google) Code Review
Browse files

Merge "Properly expose LockTypes constants as systemAPIs" into sc-dev

parents 17ea6fca 62f2f6a6
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -699,6 +699,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 {
+40 −18
Original line number Diff line number Diff line
@@ -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;
    }
}