Add MicrodroidTestApp

It's a test app (along with a native binary) that we will use to test
micdordoid. Right now, it doesn't have any test routine in it. For the
time being, the existing MicrodroidHostTestCases will use the apk to
check if zipfuse can correctly mount the file across the host Android
and microdroid. For this, the app right now is part of the virt APEX.

Later when we have app-facing Java APIs, the test app will be removed
from the virt APEX and installed separately (via adb install) and will
invoke the Java APIs and check the expected side effects.

Bug: 186377508
Test: m MicrodroidTestApp
Test: m com.android.virt

Change-Id: I929565f7fec1cd888ccc7a2b1c3021a2a85681ad
diff --git a/apex/Android.bp b/apex/Android.bp
index 459545c..63f257b 100644
--- a/apex/Android.bp
+++ b/apex/Android.bp
@@ -51,6 +51,10 @@
         "mk_cdisk",
         "mk_payload",
     ],
+    apps: [
+        // TODO(jiyong): remove this when microdroid_payload.json is created by virt manager
+        "MicrodroidTestApp",
+    ],
     prebuilts: [
         "com.android.virt.init.rc",
         "microdroid_cdisk.json",
diff --git a/tests/testapk/Android.bp b/tests/testapk/Android.bp
new file mode 100644
index 0000000..277ccc8
--- /dev/null
+++ b/tests/testapk/Android.bp
@@ -0,0 +1,19 @@
+package {
+    default_applicable_licenses: ["Android-Apache-2.0"],
+}
+
+android_app {
+    name: "MicrodroidTestApp",
+    srcs: ["src/java/**/*.java"],
+    jni_libs: ["MicrodroidTestNativeLib"],
+    sdk_version: "current",
+    apex_available: ["com.android.virt"], // TODO(jiyong): remove this from virt APEX
+}
+
+// TODO(jiyong): make this a binary, not a shared library
+cc_library_shared {
+    name: "MicrodroidTestNativeLib",
+    srcs: ["src/native/*.cpp"],
+    sdk_version: "current",
+    apex_available: ["com.android.virt"], // TODO(jiyong): remove this from virt APEX
+}
diff --git a/tests/testapk/AndroidManifest.xml b/tests/testapk/AndroidManifest.xml
new file mode 100644
index 0000000..05ebb4e
--- /dev/null
+++ b/tests/testapk/AndroidManifest.xml
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2021 The Android Open Source Project
+     Licensed under the Apache License, Version 2.0 (the "License");
+     you may not use this file except in compliance with the License.
+     You may obtain a copy of the License at
+
+          http://www.apache.org/licenses/LICENSE-2.0
+
+     Unless required by applicable law or agreed to in writing, software
+     distributed under the License is distributed on an "AS IS" BASIS,
+     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+     See the License for the specific language governing permissions and
+     limitations under the License.
+-->
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+      package="com.android.microdroid.test">
+    <application android:label="Microdroid Test">
+        <activity android:name="TestActivity">
+            <intent-filter>
+                <action android:name="android.intent.action.MAIN" />
+                <category android:name="android.intent.category.LAUNCHER" />
+            </intent-filter>
+        </activity>
+    </application>
+</manifest>
diff --git a/tests/testapk/src/java/com/android/microdroid/test/TestActivity.java b/tests/testapk/src/java/com/android/microdroid/test/TestActivity.java
new file mode 100644
index 0000000..b25869b
--- /dev/null
+++ b/tests/testapk/src/java/com/android/microdroid/test/TestActivity.java
@@ -0,0 +1,24 @@
+/*
+ * Copyright (C) 2021 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.android.microdroid.test;
+
+import android.app.Activity;
+import android.os.Bundle;
+
+public class TestActivity extends Activity {
+    @Override
+    public void onCreate(Bundle savedInstanceState) {}
+}
diff --git a/tests/testapk/src/native/testbinary.cpp b/tests/testapk/src/native/testbinary.cpp
new file mode 100644
index 0000000..c315bf1
--- /dev/null
+++ b/tests/testapk/src/native/testbinary.cpp
@@ -0,0 +1,20 @@
+/*
+ * Copyright (C) 2021 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#include <stdio.h>
+
+void say_hello() {
+    printf("Hello Microdroid\n");
+}