1package {
2    default_applicable_licenses: ["Android-Apache-2.0"],
3}
4
5android_app_certificate {
6    name: "MicrodroidTestAppCert",
7
8    // The default app cert is the same as the default platform cert
9    // (on a test-keys build), which means we end up getting assigned
10    // the permissions via signature and can't reliably disclaim
11    // them. So instead we use our own custom cert. See b/290582742.
12    // Created via: development/tools/make_key microdroid_test_app '/CN=microdroid_test_app'
13    certificate: "microdroid_test_app",
14}
15
16java_defaults {
17    name: "MicrodroidTestAppsDefaults",
18    test_suites: [
19        "cts",
20        "vts",
21        "general-tests",
22    ],
23    static_libs: [
24        "com.android.microdroid.testservice-java",
25        "com.android.microdroid.test.vmshare_service-java",
26        "com.android.virt.vm_attestation.testservice-java",
27    ],
28    certificate: ":MicrodroidTestAppCert",
29    sdk_version: "test_current",
30    jni_uses_platform_apis: true,
31    use_embedded_native_libs: true,
32    // We only support 64-bit ABI, but CTS demands all APKs to be multi-ABI.
33    compile_multilib: "both",
34}
35
36java_defaults {
37    name: "MicrodroidVersionsTestAppDefaults",
38    srcs: ["src/java/**/*.java"],
39    defaults: ["MicrodroidTestAppsDefaults"],
40    static_libs: [
41        "MicrodroidDeviceTestHelper",
42        "VmAttestationTestUtil",
43        "androidx.test.runner",
44        "androidx.test.ext.junit",
45        "authfs_test_apk_assets",
46        "cbor-java",
47        "truth",
48        "compatibility-common-util-devicesidelib",
49        "measure_io_as_jar",
50    ],
51    jni_libs: [
52        "MicrodroidTestNativeLib",
53        "MicrodroidIdleNativeLib",
54        "MicrodroidEmptyNativeLib",
55        "MicrodroidExitNativeLib",
56        "MicrodroidPrivateLinkingNativeLib",
57        "MicrodroidCrashNativeLib",
58        "libvm_attestation_test_payload",
59    ],
60    min_sdk_version: "33",
61}
62
63android_test {
64    name: "MicrodroidTestApp",
65    defaults: ["MicrodroidVersionsTestAppDefaults"],
66    manifest: "AndroidManifestV5.xml",
67    // Defined in ../vmshareapp/Android.bp
68    data: [
69        ":MicrodroidTestAppUpdated",
70        ":MicrodroidVmShareApp",
71        ":test_microdroid_vendor_image",
72        ":test_microdroid_vendor_image_unsigned",
73    ],
74}
75
76android_test_helper_app {
77    name: "MicrodroidTestAppUpdated",
78    defaults: ["MicrodroidVersionsTestAppDefaults"],
79    manifest: "AndroidManifestV6.xml",
80}
81
82// Defaults shared between MicrodroidTestNativeLib and MicrodroidPayloadInOtherAppNativeLib shared
83// libs. They are expected to share everything apart from the name, so that one app
84// (MicrodroidTestApp) can start a payload defined in the another app (MicrodroidVmShareApp).
85cc_defaults {
86    name: "MicrodroidTestNativeLibDefaults",
87    defaults: ["avf_build_flags_cc"],
88    srcs: ["src/native/testbinary.cpp"],
89    stl: "libc++_static",
90    header_libs: ["vm_payload_restricted_headers"],
91    shared_libs: [
92        "libbinder_ndk",
93        "libcap",
94        "MicrodroidTestNativeLibSub",
95        "libvm_payload#current",
96    ],
97    static_libs: [
98        "com.android.microdroid.testservice-ndk",
99        "libbase",
100        "libfstab",
101        "libfsverity_digests_proto_cc",
102        "liblog",
103        "libprotobuf-cpp-lite-ndk",
104    ],
105}
106
107cc_library_shared {
108    name: "MicrodroidPayloadInOtherAppNativeLib",
109    defaults: ["MicrodroidTestNativeLibDefaults"],
110}
111
112cc_library_shared {
113    name: "MicrodroidTestNativeLib",
114    defaults: ["MicrodroidTestNativeLibDefaults"],
115}
116
117cc_library_shared {
118    name: "MicrodroidTestNativeLibSub",
119    defaults: ["avf_build_flags_cc"],
120    srcs: ["src/native/testlib.cpp"],
121    stl: "libc++_static",
122}
123
124cc_library_shared {
125    name: "MicrodroidIdleNativeLib",
126    defaults: ["avf_build_flags_cc"],
127    srcs: ["src/native/idlebinary.cpp"],
128    header_libs: ["vm_payload_headers"],
129    stl: "libc++_static",
130}
131
132// An empty payload missing AVmPayload_main
133cc_library_shared {
134    name: "MicrodroidEmptyNativeLib",
135    defaults: ["avf_build_flags_cc"],
136    srcs: ["src/native/emptybinary.cpp"],
137    stl: "none",
138}
139
140// A payload that exits immediately on start
141cc_library_shared {
142    name: "MicrodroidExitNativeLib",
143    defaults: ["avf_build_flags_cc"],
144    srcs: ["src/native/exitbinary.cpp"],
145    header_libs: ["vm_payload_headers"],
146    stl: "libc++_static",
147}
148
149// A payload which tries to link against libselinux, one of private libraries
150cc_library_shared {
151    name: "MicrodroidPrivateLinkingNativeLib",
152    defaults: ["avf_build_flags_cc"],
153    srcs: ["src/native/idlebinary.cpp"],
154    header_libs: ["vm_payload_headers"],
155    // HACK: linking against "libselinux" will embed libselinux.so into the apk
156    // link against a stub to prevent libselinux.so from being embedded
157    shared_libs: ["libselinux#latest"],
158    stl: "libc++_static",
159}
160
161// A payload that crashes immediately on start
162cc_library_shared {
163    name: "MicrodroidCrashNativeLib",
164    defaults: ["avf_build_flags_cc"],
165    srcs: ["src/native/crashbinary.cpp"],
166    header_libs: ["vm_payload_headers"],
167    stl: "libc++_static",
168}
169