Add the skeleton for the client-side API
android.system.virtualmachine is added as the client-side API for the
controlling of virtual machines. This change doesn't add any new API.
It adds an empty library to the existing framework.
Bug: 183496040
Test: atest MicrodroidHostTestCases
Change-Id: I9c52dfaf7e33137e5e3d6c587b5cc3932f667025
diff --git a/tests/hostside/AndroidTest.xml b/tests/hostside/AndroidTest.xml
index adad01d..eda733a 100644
--- a/tests/hostside/AndroidTest.xml
+++ b/tests/hostside/AndroidTest.xml
@@ -22,11 +22,6 @@
a test-only permission, run it without selinux -->
<target_preparer class="com.android.tradefed.targetprep.DisableSELinuxTargetPreparer"/>
- <target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
- <option name="cleanup-apks" value="true" />
- <option name="test-file-name" value="MicrodroidTestApp.apk" />
- </target_preparer>
-
<test class="com.android.compatibility.common.tradefed.testtype.JarHostTest" >
<option name="jar" value="MicrodroidHostTestCases.jar" />
</test>
diff --git a/tests/hostside/helper/java/android/virt/test/VirtualizationTestCaseBase.java b/tests/hostside/helper/java/android/virt/test/VirtualizationTestCaseBase.java
index dccdca8..5821309 100644
--- a/tests/hostside/helper/java/android/virt/test/VirtualizationTestCaseBase.java
+++ b/tests/hostside/helper/java/android/virt/test/VirtualizationTestCaseBase.java
@@ -139,7 +139,7 @@
return String.join(" ", Arrays.asList(strs));
}
- private File findTestFile(String name) throws Exception {
+ public File findTestFile(String name) throws Exception {
return (new CompatibilityBuildHelper(getBuild())).getTestFile(name);
}
diff --git a/tests/hostside/java/android/virt/test/MicrodroidTestCase.java b/tests/hostside/java/android/virt/test/MicrodroidTestCase.java
index 08492b3..0b82d43 100644
--- a/tests/hostside/java/android/virt/test/MicrodroidTestCase.java
+++ b/tests/hostside/java/android/virt/test/MicrodroidTestCase.java
@@ -30,13 +30,13 @@
@RunWith(DeviceJUnit4ClassRunner.class)
public class MicrodroidTestCase extends VirtualizationTestCaseBase {
private static final long MICRODROID_ADB_CONNECT_TIMEOUT_MINUTES = 5;
+ private static final String APK_NAME = "MicrodroidTestApp.apk";
+ private static final String PACKAGE_NAME = "com.android.microdroid.test";
@Test
public void testMicrodroidBoots() throws Exception {
- final String apkName = "MicrodroidTestApp.apk";
- final String packageName = "com.android.microdroid.test";
final String configPath = "assets/vm_config.json"; // path inside the APK
- final String cid = startMicrodroid(apkName, packageName, configPath);
+ final String cid = startMicrodroid(APK_NAME, PACKAGE_NAME, configPath);
adbConnectToMicrodroid(cid, MICRODROID_ADB_CONNECT_TIMEOUT_MINUTES);
// Test writing to /data partition
@@ -83,6 +83,8 @@
prepareVirtualizationTestSetup();
+ getDevice().installPackage(findTestFile(APK_NAME), /* reinstall */ false);
+
// clear the log
getDevice().executeShellV2Command("logcat -c");
}
@@ -90,5 +92,7 @@
@After
public void shutdown() throws Exception {
cleanUpVirtualizationTestSetup();
+
+ getDevice().uninstallPackage(PACKAGE_NAME);
}
}
diff --git a/tests/testapk/Android.bp b/tests/testapk/Android.bp
index fc5681e..f14fca8 100644
--- a/tests/testapk/Android.bp
+++ b/tests/testapk/Android.bp
@@ -5,6 +5,9 @@
android_app {
name: "MicrodroidTestApp",
srcs: ["src/java/**/*.java"],
+ libs: [
+ "android.system.virtualmachine",
+ ],
jni_libs: ["MicrodroidTestNativeLib"],
platform_apis: true,
use_embedded_native_libs: true,
diff --git a/tests/testapk/AndroidManifest.xml b/tests/testapk/AndroidManifest.xml
index 74ae206..94f49dd 100644
--- a/tests/testapk/AndroidManifest.xml
+++ b/tests/testapk/AndroidManifest.xml
@@ -15,6 +15,7 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.android.microdroid.test">
<application android:label="Microdroid Test">
+ <uses-library android:name="android.system.virtualmachine" android:required="true" />
<activity android:name="TestActivity" android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />