Setup min_sdk_version, sdk_version and target_sdk_version for test apps
And make test apps use public/system APIs instead of hidden ones.
Test: atest CtsUserspaceRebootHostSideTestCases
Bug: 149020865
Change-Id: I30d5aca61777ff455fa24a5d1d12731fbcb1d8b7
diff --git a/hostsidetests/userspacereboot/testapps/BasicTestApp/Android.bp b/hostsidetests/userspacereboot/testapps/BasicTestApp/Android.bp
index 53ef0f1a..8e5ee606 100644
--- a/hostsidetests/userspacereboot/testapps/BasicTestApp/Android.bp
+++ b/hostsidetests/userspacereboot/testapps/BasicTestApp/Android.bp
@@ -22,5 +22,7 @@
"testng",
"truth-prebuilt",
],
- min_sdk_version: "30",
-}
\ No newline at end of file
+ min_sdk_version: "29",
+ // TODO(ioffe): change to number when SDK is finalized.
+ sdk_version: "system_current",
+}
diff --git a/hostsidetests/userspacereboot/testapps/BootCompletedTestApp/Android.bp b/hostsidetests/userspacereboot/testapps/BootCompletedTestApp/Android.bp
index 76fa942..a25b8df 100644
--- a/hostsidetests/userspacereboot/testapps/BootCompletedTestApp/Android.bp
+++ b/hostsidetests/userspacereboot/testapps/BootCompletedTestApp/Android.bp
@@ -23,5 +23,7 @@
"testng",
"truth-prebuilt",
],
- min_sdk_version: "30",
+ min_sdk_version: "29",
+ sdk_version: "29",
+ target_sdk_version: "29",
}
diff --git a/hostsidetests/userspacereboot/testapps/BootCompletedTestApp/src/com/android/cts/userspacereboot/bootcompleted/BootCompletedUserspaceRebootTest.java b/hostsidetests/userspacereboot/testapps/BootCompletedTestApp/src/com/android/cts/userspacereboot/bootcompleted/BootCompletedUserspaceRebootTest.java
index 93e1544..28603d0 100644
--- a/hostsidetests/userspacereboot/testapps/BootCompletedTestApp/src/com/android/cts/userspacereboot/bootcompleted/BootCompletedUserspaceRebootTest.java
+++ b/hostsidetests/userspacereboot/testapps/BootCompletedTestApp/src/com/android/cts/userspacereboot/bootcompleted/BootCompletedUserspaceRebootTest.java
@@ -50,10 +50,8 @@
private static final Duration BOOT_TIMEOUT = Duration.ofMinutes(6);
- private final Context mCeContext =
- getInstrumentation().getContext().createCredentialProtectedStorageContext();
- private final Context mDeContext =
- getInstrumentation().getContext().createDeviceProtectedStorageContext();
+ private final Context mCeContext = getInstrumentation().getContext();
+ private final Context mDeContext = mCeContext.createDeviceProtectedStorageContext();
/**
* Writes to a file in CE storage of {@link BootCompletedUserspaceRebootTest}.
@@ -75,7 +73,7 @@
@Test
public void testVerifyCeStorageUnlocked() throws Exception {
UserManager um = getInstrumentation().getContext().getSystemService(UserManager.class);
- assertThat(um.isUserUnlocked(0)).isTrue();
+ assertThat(um.isUserUnlocked()).isTrue();
try (Scanner scanner = new Scanner(mCeContext.openFileInput(FILE_NAME))) {
final String content = scanner.nextLine();
assertThat(content).isEqualTo(SECRET_MESSAGE);