summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2024-05-10 15:45:02 +0000
committerAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2024-05-10 15:45:02 +0000
commit3b802357ec6eaeff69c431af759e6b752aaae2d6 (patch)
treee2641bdfa28d8c5b60d2c57315244080b311f4a6
parent394beb78b2cd73194ff75e4424e9e5348c86623e (diff)
parent034d759fa2127a0fa115b8b714eb5059536db5ed (diff)
downloadsetupwizard-busytown-mac-infra-release.tar.gz
Snap for 11819167 from 034d759fa2127a0fa115b8b714eb5059536db5ed to busytown-mac-infra-releasebusytown-mac-infra-release
Change-Id: I36ae7a9d0df9fa8bcfb024b920b89e5e9fd49e7e
-rw-r--r--library/main/build.gradle2
-rw-r--r--library/main/tests/robotests/Android.bp2
-rw-r--r--library/utils/src/com/android/car/setupwizardlib/IInitialLockSetupService.aidl14
-rw-r--r--library/utils/src/com/android/car/setupwizardlib/InitialLockSetupConstants.java6
-rw-r--r--library/utils/src/com/android/car/setupwizardlib/InitialLockSetupHelper.java17
5 files changed, 27 insertions, 14 deletions
diff --git a/library/main/build.gradle b/library/main/build.gradle
index 17ab59a..8af3194 100644
--- a/library/main/build.gradle
+++ b/library/main/build.gradle
@@ -82,5 +82,5 @@ dependencies {
testImplementation 'com.google.truth:truth:0.41'
testImplementation 'org.mockito:mockito-core:3.6.0'
- testImplementation 'org.robolectric:robolectric:4.5.1'
+ testImplementation 'org.robolectric:robolectric:4.8.2'
}
diff --git a/library/main/tests/robotests/Android.bp b/library/main/tests/robotests/Android.bp
index 9d91639..de2e823 100644
--- a/library/main/tests/robotests/Android.bp
+++ b/library/main/tests/robotests/Android.bp
@@ -2,6 +2,7 @@
// CarSetupWizardLib app just for Robolectric test target. #
//##############################################################
package {
+ default_team: "trendy_team_automotive",
default_applicable_licenses: ["Android-Apache-2.0"],
}
@@ -34,4 +35,5 @@ android_robolectric_test {
],
instrumentation_for: "CarSetupWizardLib",
+ upstream: true,
}
diff --git a/library/utils/src/com/android/car/setupwizardlib/IInitialLockSetupService.aidl b/library/utils/src/com/android/car/setupwizardlib/IInitialLockSetupService.aidl
index 305195b..3cc4bd4 100644
--- a/library/utils/src/com/android/car/setupwizardlib/IInitialLockSetupService.aidl
+++ b/library/utils/src/com/android/car/setupwizardlib/IInitialLockSetupService.aidl
@@ -44,5 +44,19 @@ interface IInitialLockSetupService {
* deserializable by the service.
*/
int setLock(in int lockType, in byte[] password) = 3;
+
+ /**
+ * Added in LIBRARY_VERSION = 2.
+ *
+ * Returns a message String combing all input validation error messages to
+ * directly display to user. If there is no error and the credentialBytes
+ * is valid then it will return an empty String. The String returned should
+ * be the same message as shown to users in the Security Settings page
+ * and should be properly localized.
+
+ * @param credentialBytes input value in bytes representing one of
+ * Password, PIN, or Pattern input.
+ */
+ String checkValidLockAndReturnError(in int lockType, in byte[] credentialBytes) = 4;
}
diff --git a/library/utils/src/com/android/car/setupwizardlib/InitialLockSetupConstants.java b/library/utils/src/com/android/car/setupwizardlib/InitialLockSetupConstants.java
index 8ca5c6e..7362cd1 100644
--- a/library/utils/src/com/android/car/setupwizardlib/InitialLockSetupConstants.java
+++ b/library/utils/src/com/android/car/setupwizardlib/InitialLockSetupConstants.java
@@ -27,8 +27,12 @@ public interface InitialLockSetupConstants {
/**
* The library version. All relevant changes should bump this version number and ensure
* all relevant parts of the interface handle backwards compatibility.
+ *
+ * Library version 1: Initial implementation
+ * Library version 2: Add API checkValidLockAndReturnError to allow complexity validation
+ * error to be retrieved from Settings.
*/
- int LIBRARY_VERSION = 1;
+ int LIBRARY_VERSION = 2;
/**
* Lock types supported by the InitialLockSetupService.
diff --git a/library/utils/src/com/android/car/setupwizardlib/InitialLockSetupHelper.java b/library/utils/src/com/android/car/setupwizardlib/InitialLockSetupHelper.java
index 191ddbc..f4c6385 100644
--- a/library/utils/src/com/android/car/setupwizardlib/InitialLockSetupHelper.java
+++ b/library/utils/src/com/android/car/setupwizardlib/InitialLockSetupHelper.java
@@ -18,6 +18,8 @@ package com.android.car.setupwizardlib;
import com.android.car.setupwizardlib.InitialLockSetupConstants.ValidateLockFlags;
+import java.nio.charset.StandardCharsets;
+
/**
* Provides helper methods for the usage of the InitialLockSetupService.
*/
@@ -54,18 +56,13 @@ public class InitialLockSetupHelper {
}
/**
- * Converts a {@link CharSequence} into an array of bytes. This is for security reasons to avoid
- * storing strings in memory.
+ * Converts a {@link CharSequence} into an array of bytes.
*/
public static byte[] charSequenceToByteArray(CharSequence chars) {
if (chars == null) {
return null;
}
- byte[] byteArray = new byte[chars.length()];
- for (int i = 0; i < chars.length(); i++) {
- byteArray[i] = (byte) chars.charAt(i);
- }
- return byteArray;
+ return chars.toString().getBytes(StandardCharsets.UTF_8);
}
/**
@@ -75,11 +72,7 @@ public class InitialLockSetupHelper {
if (input == null) {
return null;
}
- StringBuffer charSequence = new StringBuffer();
- for (int i = 0; i < input.length; i++) {
- charSequence.append((char) input[i]);
- }
- return charSequence;
+ return new String(input, StandardCharsets.UTF_8);
}
/** Return an ASCII-equivalent array of character digits for a numeric byte input. */