Skip to content

Commit 02989be

Browse files
committed
Revert "Disable Pre-reboot Dexopt."
This reverts commit 3efe8ed. Reason for revert: Problem fixed Bug: 356858364 Change-Id: I8e976a4e3f8120d672861b967a7765d23d1099a1
1 parent 3efe8ed commit 02989be

1 file changed

Lines changed: 31 additions & 0 deletions

File tree

cmds/installd/otapreopt_script.sh

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,37 @@ else
5050
exit 1
5151
fi
5252

53+
# A source that infinitely emits arbitrary lines.
54+
# When connected to STDIN of another process, this source keeps STDIN open until
55+
# the consumer process closes STDIN or this script dies.
56+
function infinite_source {
57+
while echo .; do
58+
sleep 1
59+
done
60+
}
61+
62+
PR_DEXOPT_JOB_VERSION="$(pm art pr-dexopt-job --version)"
63+
if (( $? == 0 )) && (( $PR_DEXOPT_JOB_VERSION >= 3 )); then
64+
# Delegate to Pre-reboot Dexopt, a feature of ART Service.
65+
# ART Service decides what to do with this request:
66+
# - If Pre-reboot Dexopt is disabled or unsupported, the command returns
67+
# non-zero. This is always the case if the current system is Android 14 or
68+
# earlier.
69+
# - If Pre-reboot Dexopt is enabled in synchronous mode, the command blocks
70+
# until Pre-reboot Dexopt finishes, and returns zero no matter it succeeds or
71+
# not. This is the default behavior if the current system is Android 15.
72+
# - If Pre-reboot Dexopt is enabled in asynchronous mode, the command schedules
73+
# an asynchronous job and returns 0 immediately. The job will then run by the
74+
# job scheduler when the device is idle and charging.
75+
if infinite_source | pm art on-ota-staged --slot "$TARGET_SLOT_SUFFIX"; then
76+
# Handled by Pre-reboot Dexopt.
77+
exit 0
78+
fi
79+
echo "Pre-reboot Dexopt not enabled. Fall back to otapreopt."
80+
else
81+
echo "Pre-reboot Dexopt is too old. Fall back to otapreopt."
82+
fi
83+
5384
if [ "$(/system/bin/otapreopt_chroot --version)" != 2 ]; then
5485
# We require an updated chroot wrapper that reads dexopt commands from stdin.
5586
# Even if we kept compat with the old binary, the OTA preopt wouldn't work due

0 commit comments

Comments
 (0)