Merge "adb-remount-test: Refactor restore()" am: 3a6ec217c6

Original change: https://android-review.googlesource.com/c/platform/system/core/+/2191315

Change-Id: I5dc5ffdf6fa24cc8425ac2285d6ca156ebd5d5a5
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Yi-yo Chiang 2022-08-31 07:40:58 +00:00 committed by Automerger Merge Worker
commit a6a2350682

View file

@ -985,6 +985,39 @@ adb_sh ls -l /dev/block/by-name/ /dev/block/mapper/ </dev/null 2>/dev/null |
LOG INFO "partition ${name} device ${device} size ${size}K"
done
overlayfs_supported=true
can_restore_verity=false
restore() {
LOG INFO "restoring device"
${overlayfs_supported} || return 0
inFastboot &&
fastboot reboot &&
adb_wait "${ADB_WAIT}" ||
true
if ! inAdb; then
LOG ERROR "expect adb device"
return 1
fi
adb_root || true
local reboot=false
if surgically_wipe_overlayfs; then
reboot=true
fi
if ${can_restore_verity}; then
if ! adb enable-verity; then
LOG ERROR "adb enable-verity"
return 1
fi
LOG INFO "restored verity"
reboot=true
fi >&2
if ${reboot}; then
adb_reboot &&
adb_wait "${ADB_WAIT}"
fi
}
# If reboot too soon after fresh flash, could trip device update failure logic
if ${screen_wait}; then
LOG WARNING "waiting for screen to come up. Consider --no-wait-screen option"
@ -995,35 +1028,9 @@ if ! wait_for_screen && ${screen_wait}; then
fi
# Can we test remount -R command?
overlayfs_supported=true
if [ "orange" != "`get_property ro.boot.verifiedbootstate`" -o \
"2" != "`get_property partition.system.verified`" ]; then
restore() {
${overlayfs_supported} || return 0
inFastboot &&
fastboot reboot &&
adb_wait ${ADB_WAIT} ||
true
if inAdb; then
if surgically_wipe_overlayfs; then
adb_reboot &&
adb_wait ${ADB_WAIT}
fi
fi
}
else
restore() {
${overlayfs_supported} || return 0
inFastboot &&
fastboot reboot &&
adb_wait ${ADB_WAIT} ||
true
inAdb &&
adb_root &&
adb enable-verity >/dev/null 2>/dev/null &&
adb_reboot &&
adb_wait ${ADB_WAIT}
}
if [ "orange" = "$(get_property ro.boot.verifiedbootstate)" ] &&
[ "2" = "$(get_property partition.system.verified)" ]; then
can_restore_verity=true
LOG RUN "Testing adb shell su root remount -R command"
@ -1118,14 +1125,7 @@ echo "${D}" >&2
if [ X"${D}" = X"${D##* 100[%] }" ] && ${no_dedupe} ; then
overlayfs_needed=false
# if device does not need overlays, then adb enable-verity will brick device
restore() {
${overlayfs_supported} || return 0
inFastboot &&
fastboot reboot &&
adb_wait ${ADB_WAIT}
inAdb &&
adb_wait ${ADB_WAIT}
}
can_restore_verity=false
elif ! ${overlayfs_supported}; then
die "need overlayfs, but do not have it"
fi