summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Jiakai Zhang <jiakaiz@google.com> 2024-06-14 12:49:15 +0000
committer Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> 2024-06-14 12:49:15 +0000
commite576a11a250ac6cdc63b08a7d19a0615a130cb8c (patch)
treebc88294d0f812ec92980a0b1907351c16c458890
parent24258a546379d87a6668d357df1811d3dc05bbf5 (diff)
parent068476a119f551bdc80e0d3dbad0bebe116d127f (diff)
Merge "Only enable Pre-reboot Dexopt if version >= 2." into main am: ebe488b67c am: 068476a119
Original change: https://android-review.googlesource.com/c/platform/frameworks/native/+/3131796 Change-Id: I08dd1efb7a80caa409a0e1cb551052be31b13e66 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
-rw-r--r--cmds/installd/otapreopt_script.sh35
1 files changed, 20 insertions, 15 deletions
diff --git a/cmds/installd/otapreopt_script.sh b/cmds/installd/otapreopt_script.sh
index 2d889fd80d..9384926e29 100644
--- a/cmds/installd/otapreopt_script.sh
+++ b/cmds/installd/otapreopt_script.sh
@@ -59,22 +59,27 @@ function infinite_source {
done
}
-# Delegate to Pre-reboot Dexopt, a feature of ART Service.
-# ART Service decides what to do with this request:
-# - If Pre-reboot Dexopt is disabled or unsupported, the command returns
-# non-zero. This is always the case if the current system is Android 14 or
-# earlier.
-# - If Pre-reboot Dexopt is enabled in synchronous mode, the command blocks
-# until Pre-reboot Dexopt finishes, and returns zero no matter it succeeds or
-# not. This is the default behavior if the current system is Android 15.
-# - If Pre-reboot Dexopt is enabled in asynchronous mode, the command schedules
-# an asynchronous job and returns 0 immediately. The job will then run by the
-# job scheduler when the device is idle and charging.
-if infinite_source | pm art on-ota-staged --slot "$TARGET_SLOT_SUFFIX"; then
- # Handled by Pre-reboot Dexopt.
- exit 0
+PR_DEXOPT_JOB_VERSION="$(pm art pr-dexopt-job --version)"
+if (( $? == 0 )) && (( $PR_DEXOPT_JOB_VERSION >= 2 )); then
+ # Delegate to Pre-reboot Dexopt, a feature of ART Service.
+ # ART Service decides what to do with this request:
+ # - If Pre-reboot Dexopt is disabled or unsupported, the command returns
+ # non-zero. This is always the case if the current system is Android 14 or
+ # earlier.
+ # - If Pre-reboot Dexopt is enabled in synchronous mode, the command blocks
+ # until Pre-reboot Dexopt finishes, and returns zero no matter it succeeds or
+ # not. This is the default behavior if the current system is Android 15.
+ # - If Pre-reboot Dexopt is enabled in asynchronous mode, the command schedules
+ # an asynchronous job and returns 0 immediately. The job will then run by the
+ # job scheduler when the device is idle and charging.
+ if infinite_source | pm art on-ota-staged --slot "$TARGET_SLOT_SUFFIX"; then
+ # Handled by Pre-reboot Dexopt.
+ exit 0
+ fi
+ echo "Pre-reboot Dexopt not enabled. Fall back to otapreopt."
+else
+ echo "Pre-reboot Dexopt is too old. Fall back to otapreopt."
fi
-echo "Pre-reboot Dexopt not enabled. Fall back to otapreopt."
if [ "$(/system/bin/otapreopt_chroot --version)" != 2 ]; then
# We require an updated chroot wrapper that reads dexopt commands from stdin.