Loading core/java/com/android/internal/widget/LockPatternUtils.java +1 −1 Original line number Diff line number Diff line Loading @@ -1051,7 +1051,7 @@ public class LockPatternUtils { } final int patternSize = pattern.size(); byte[] res = new byte[patternSize]; byte[] res = newNonMovableByteArray(patternSize); for (int i = 0; i < patternSize; i++) { LockPatternView.Cell cell = pattern.get(i); res[i] = (byte) (cell.getRow() * 3 + cell.getColumn() + '1'); Loading core/java/com/android/internal/widget/LockscreenCredential.java +15 −6 Original line number Diff line number Diff line Loading @@ -81,9 +81,9 @@ public class LockscreenCredential implements Parcelable, AutoCloseable { /** * Private constructor, use static builder methods instead. * * <p> Builder methods should create a private copy of the credential bytes and pass in here. * LockscreenCredential will only store the reference internally without copying. This is to * minimize the number of extra copies introduced. * <p> Builder methods should create a private copy of the credential bytes using a non-movable * array and pass it in here. LockscreenCredential will only store the reference internally * without copying. This is to minimize the number of extra copies introduced. */ private LockscreenCredential(int type, byte[] credential, boolean hasInvalidChars) { Objects.requireNonNull(credential); Loading Loading @@ -141,7 +141,7 @@ public class LockscreenCredential implements Parcelable, AutoCloseable { */ public static LockscreenCredential createUnifiedProfilePassword(@NonNull byte[] password) { return new LockscreenCredential(CREDENTIAL_TYPE_PASSWORD, Arrays.copyOf(password, password.length), /* hasInvalidChars= */ false); copyOfArrayNonMovable(password), /* hasInvalidChars= */ false); } /** Loading Loading @@ -237,7 +237,7 @@ public class LockscreenCredential implements Parcelable, AutoCloseable { /** Create a copy of the credential */ public LockscreenCredential duplicate() { return new LockscreenCredential(mType, mCredential != null ? Arrays.copyOf(mCredential, mCredential.length) : null, mCredential != null ? copyOfArrayNonMovable(mCredential) : null, mHasInvalidChars); } Loading @@ -251,6 +251,15 @@ public class LockscreenCredential implements Parcelable, AutoCloseable { } } /** * Copies the given array into a new non-movable array. */ private static byte[] copyOfArrayNonMovable(byte[] array) { byte[] copy = LockPatternUtils.newNonMovableByteArray(array.length); System.arraycopy(array, 0, copy, 0, array.length); return copy; } /** * Checks whether the credential meets basic requirements for setting it as a new credential. * Loading Loading @@ -440,7 +449,7 @@ public class LockscreenCredential implements Parcelable, AutoCloseable { * @return A byte array representing the input */ private static byte[] charsToBytesTruncating(CharSequence chars) { byte[] bytes = new byte[chars.length()]; byte[] bytes = LockPatternUtils.newNonMovableByteArray(chars.length()); for (int i = 0; i < chars.length(); i++) { bytes[i] = (byte) chars.charAt(i); } Loading Loading
core/java/com/android/internal/widget/LockPatternUtils.java +1 −1 Original line number Diff line number Diff line Loading @@ -1051,7 +1051,7 @@ public class LockPatternUtils { } final int patternSize = pattern.size(); byte[] res = new byte[patternSize]; byte[] res = newNonMovableByteArray(patternSize); for (int i = 0; i < patternSize; i++) { LockPatternView.Cell cell = pattern.get(i); res[i] = (byte) (cell.getRow() * 3 + cell.getColumn() + '1'); Loading
core/java/com/android/internal/widget/LockscreenCredential.java +15 −6 Original line number Diff line number Diff line Loading @@ -81,9 +81,9 @@ public class LockscreenCredential implements Parcelable, AutoCloseable { /** * Private constructor, use static builder methods instead. * * <p> Builder methods should create a private copy of the credential bytes and pass in here. * LockscreenCredential will only store the reference internally without copying. This is to * minimize the number of extra copies introduced. * <p> Builder methods should create a private copy of the credential bytes using a non-movable * array and pass it in here. LockscreenCredential will only store the reference internally * without copying. This is to minimize the number of extra copies introduced. */ private LockscreenCredential(int type, byte[] credential, boolean hasInvalidChars) { Objects.requireNonNull(credential); Loading Loading @@ -141,7 +141,7 @@ public class LockscreenCredential implements Parcelable, AutoCloseable { */ public static LockscreenCredential createUnifiedProfilePassword(@NonNull byte[] password) { return new LockscreenCredential(CREDENTIAL_TYPE_PASSWORD, Arrays.copyOf(password, password.length), /* hasInvalidChars= */ false); copyOfArrayNonMovable(password), /* hasInvalidChars= */ false); } /** Loading Loading @@ -237,7 +237,7 @@ public class LockscreenCredential implements Parcelable, AutoCloseable { /** Create a copy of the credential */ public LockscreenCredential duplicate() { return new LockscreenCredential(mType, mCredential != null ? Arrays.copyOf(mCredential, mCredential.length) : null, mCredential != null ? copyOfArrayNonMovable(mCredential) : null, mHasInvalidChars); } Loading @@ -251,6 +251,15 @@ public class LockscreenCredential implements Parcelable, AutoCloseable { } } /** * Copies the given array into a new non-movable array. */ private static byte[] copyOfArrayNonMovable(byte[] array) { byte[] copy = LockPatternUtils.newNonMovableByteArray(array.length); System.arraycopy(array, 0, copy, 0, array.length); return copy; } /** * Checks whether the credential meets basic requirements for setting it as a new credential. * Loading Loading @@ -440,7 +449,7 @@ public class LockscreenCredential implements Parcelable, AutoCloseable { * @return A byte array representing the input */ private static byte[] charsToBytesTruncating(CharSequence chars) { byte[] bytes = new byte[chars.length()]; byte[] bytes = LockPatternUtils.newNonMovableByteArray(chars.length()); for (int i = 0; i < chars.length(); i++) { bytes[i] = (byte) chars.charAt(i); } Loading