Skip to content

Commit

Permalink
addon: handle mounting of /product on A only devices
Browse files Browse the repository at this point in the history
* On devices with a separate product partition, addon scripts were
  not able to remove AOSP counterpart apps among possibly other
  similar issues as well

* So fix it by mounting /product on before we get started

* Also thanks to @nikhilmenghani for his input
  • Loading branch information
merothh committed Aug 27, 2020
1 parent f253671 commit 334628a
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion scripts/bkup_tail.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,21 @@
EOF
}

mount_product() {
active_slot=`getprop ro.boot.slot_suffix`
if [ -z "$active_slot" ]; then
# We're on an A only device
if [ "$(getprop ro.boot.dynamic_partitions)" = "true" ]; then
mount -o ro -t auto /dev/block/mapper/product /product 2> /dev/null
blockdev --setrw /dev/block/mapper/product 2> /dev/null
mount -o rw,remount -t auto /dev/block/mapper/product /product 2> /dev/null
else
mount -o ro -t auto /product 2> /dev/null
mount -o rw,remount -t auto /product 2> /dev/null
fi
fi
}

# Backup/Restore using /sdcard if the installed GApps size plus a buffer for other addon.d backups (204800=200MB) is larger than /tmp
installed_gapps_size_kb=$(grep "^installed_gapps_size_kb" $TMP/gapps.prop | cut -d '=' -f 2)
if [ ! "$installed_gapps_size_kb" ]; then
Expand Down Expand Up @@ -31,6 +46,8 @@ case "$1" in
list_files | while read -r FILE DUMMY; do
backup_file "$S"/"$FILE"
done

umount /product
;;
restore)
list_files | while read -r FILE REPLACEMENT; do
Expand All @@ -40,12 +57,14 @@ case "$1" in
done
;;
pre-backup)
# Stub
mount_product
;;
post-backup)
# Stub
;;
pre-restore)
mount_product

# Remove Stock/AOSP apps (from GApps Installer)

# Remove 'other' apps (per installer.data)
Expand Down Expand Up @@ -81,6 +100,9 @@ case "$1" in
*/overlay/*) chcon -h u:object_r:vendor_overlay_file:s0 "$SYS/$i";;
esac
done

umount /product

if [ "$rom_build_sdk" -ge "26" ]; then # Android 8.0+ uses 0600 for its permission on build.prop
chmod 600 "$SYS/build.prop"
fi
Expand Down

0 comments on commit 334628a

Please sign in to comment.