From 754e56bff6911fdd667b6c03d8b7ba1269dba966 Mon Sep 17 00:00:00 2001 From: Yury Khmel Date: Sat, 3 Mar 2018 14:48:38 -0800 Subject: arc: Enable packages cache generation during sign stage. This regenerates packages cache during signing the image once apks are changed due timestamp and key update. TEST=Build image, sign it useing devkeys and deploy to device. Perform user sign-in and enable ARC. Test logcat and everything is clear. BUG=b:74108152 Change-Id: I4809a1f87c8b8f52094054dbb4c8ba3e059aee89 Reviewed-on: https://chromium-review.googlesource.com/948064 Commit-Ready: Yury Khmel Tested-by: Yury Khmel Reviewed-by: Mike Frysinger --- scripts/image_signing/sign_android_image.sh | 46 ++++++++++++++++++++++++++++- 1 file changed, 45 insertions(+), 1 deletion(-) diff --git a/scripts/image_signing/sign_android_image.sh b/scripts/image_signing/sign_android_image.sh index 5a6d321a..c8238704 100755 --- a/scripts/image_signing/sign_android_image.sh +++ b/scripts/image_signing/sign_android_image.sh @@ -96,6 +96,11 @@ build flavor '${flavor_prop}'." # Copy the content instead of mv to avoid owner/mode changes. sudo cp "${aligned_apk}" "${apk}" && rm -f "${aligned_apk}" + # Set timestamp rounded to second since squash file system has resolution + # in seconds. Required in order for the packages cache generator output is + # compatible with the packed file system. + sudo touch "${apk}" -t "$(date +%m%d%H%M.%S)" + : $(( counter_${keyname} += 1 )) : $(( counter_total += 1 )) done < <(find "${system_mnt}/system" -type f -name '*.apk' -print0) @@ -218,7 +223,7 @@ main() { local compression_method=$(sudo unsquashfs -s "${system_img}" | \ awk '$1 == "Compression" { print $2 }') - info "Unpacking squashfs image to ${system_img}" + info "Unpacking squashfs system image to ${system_mnt}" sudo "${unsquashfs}" -x -f -no-progress -d "${system_mnt}" "${system_img}" snapshot_file_properties "${system_mnt}" > "${working_dir}/properties.orig" @@ -235,6 +240,45 @@ main() { die "Unexpected change of file property, diff\n${d}" fi + # Packages cache needs to be regenerated when the key and timestamp are + # changed for apks. + local packages_cache="${system_mnt}/system/etc/packages_cache.xml" + if [[ -f "${packages_cache}" ]]; then + if type -P aapt &>/dev/null; then + info "Regenerating packages cache ${packages_cache}" + # For the sanity check. + local packages_before=$(grep "