Create a test ART apex that forces execution of JIT zygote.
Implemented by making odrefresh a no-op.
Test: install test module
Bug: 208420244
Change-Id: I5612cac6156af88d40e96aa490da753859ee1dc2
diff --git a/build/apex/Android.bp b/build/apex/Android.bp
index 864f4ca..d299c72 100644
--- a/build/apex/Android.bp
+++ b/build/apex/Android.bp
@@ -34,11 +34,6 @@
"dexoptanalyzer",
"profman",
]
-// - Base requirements (binaries for which the "first" version is preferred on device
-// (likely 64-bit).
-art_runtime_base_binaries_first_on_device = [
- "odrefresh",
-]
// - Base requirements (libraries).
//
@@ -258,7 +253,7 @@
// Default values shared by device ART APEXes.
apex_defaults {
- name: "com.android.art-device-defaults",
+ name: "com.android.art-device-defaults-minus-odrefresh",
defaults: ["com.android.art-defaults"],
compile_multilib: "both",
manifest: "manifest-art.json",
@@ -279,7 +274,6 @@
},
first: {
binaries: art_runtime_base_binaries_first_on_device_first_on_host +
- art_runtime_base_binaries_first_on_device +
art_tools_common_binaries +
art_tools_device_only_binaries,
},
@@ -307,6 +301,16 @@
compressible: true,
}
+apex_defaults {
+ name: "com.android.art-device-defaults",
+ defaults: ["com.android.art-device-defaults-minus-odrefresh"],
+ multilib: {
+ first: {
+ binaries: ["odrefresh"],
+ },
+ },
+}
+
// Default values shared by (device) Debug and Testing ART APEXes.
apex_defaults {
name: "com.android.art-devel-defaults",
@@ -359,6 +363,22 @@
min_sdk_version: "31",
}
+apex_test {
+ name: "test_jitzygote_com.android.art",
+ defaults: ["com.android.art-device-defaults-minus-odrefresh"],
+ multilib: {
+ first: {
+ binaries: ["odrefresh_broken"],
+ },
+ },
+ key: "com.android.art.key",
+ manifest: "test_apex_manifest.json",
+ file_contexts: ":com.android.art-file_contexts",
+ certificate: ":com.android.art.certificate",
+ installable: false,
+ min_sdk_version: "31",
+}
+
// Release version of the ART APEX module (not containing debug
// variants nor tools), included in user builds. Also used for
// storage-constrained devices in userdebug and eng builds.
diff --git a/odrefresh/Android.bp b/odrefresh/Android.bp
index b4d0f49..316052d 100644
--- a/odrefresh/Android.bp
+++ b/odrefresh/Android.bp
@@ -118,6 +118,17 @@
],
}
+// A no-op version of the odrefresh binary.
+art_cc_binary {
+ name: "odrefresh_broken",
+ defaults: ["art_defaults"],
+ stem: "odrefresh",
+ local_include_dirs: ["include"],
+ header_libs: ["libbase_headers"],
+ srcs: ["odrefresh_broken.cc"],
+ apex_available: ["test_jitzygote_com.android.art"],
+}
+
art_cc_binary {
name: "odrefreshd",
defaults: [
diff --git a/odrefresh/odrefresh_broken.cc b/odrefresh/odrefresh_broken.cc
new file mode 100644
index 0000000..7b7d095
--- /dev/null
+++ b/odrefresh/odrefresh_broken.cc
@@ -0,0 +1,25 @@
+/*
+ * 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 <android-base/macros.h>
+#include <odrefresh/odrefresh.h>
+
+
+int main(int argc ATTRIBUTE_UNUSED, char** argv ATTRIBUTE_UNUSED) {
+ // Return a value that will make odsign just cleanup all potential existing /data
+ // artifacts.
+ return art::odrefresh::ExitCode::kCleanupFailed;
+}