diff options
author | osm0sis <osm0sis@outlook.com> | 2019-10-16 17:05:52 -0300 |
---|---|---|
committer | osm0sis <osm0sis@outlook.com> | 2019-10-16 17:05:52 -0300 |
commit | 6515f57493b5a83791ec8401d6d5e728614fe124 (patch) | |
tree | 782f78162ed969f5401edfd8ff259d0a075f2df6 | |
parent | 98b1ac602f0c0e819a73882ce3c00231dd714855 (diff) |
Backend: fix getprop and devicecheck for GSIs
- add additional prop locations to getprop failure fallback
- add vendor props to devicecheck and getprop parsing fallback check to avoid false negatives on GSIs
- mask errors from devicecheck getprops as not all of them may exist on GSIs or non-GSIs
Thanks @lazerl0rd for the information and start on the changes
Closes #44
-rwxr-xr-x | META-INF/com/google/android/update-binary | 30 |
1 files changed, 19 insertions, 11 deletions
diff --git a/META-INF/com/google/android/update-binary b/META-INF/com/google/android/update-binary index e149a28..94f1510 100755 --- a/META-INF/com/google/android/update-binary +++ b/META-INF/com/google/android/update-binary @@ -27,7 +27,7 @@ ui_printfile() { show_progress() { echo "progress $1 $2" > $OUTFD; } file_getprop() { $bb grep "^$2=" "$1" | $bb cut -d= -f2-; } int2ver() { - if [ "$1" -eq "$1" ] 2>/dev/null; then + if [ "$1" -eq "$1" ] 2>/dev/null; then echo "$1.0.0"; elif [ ! "$(echo "$1" | $bb cut -d. -f3)" ]; then echo "$1.0"; @@ -165,11 +165,15 @@ unset LD_PRELOAD; if [ ! "$(getprop 2>/dev/null)" ]; then getprop() { - local propval="$(file_getprop /default.prop $1 2>/dev/null)"; - test "$propval" || local propval="$(file_getprop /system/build.prop $1 2>/dev/null)"; + local propdir propfile propval; + for propdir in / /system_root /system /vendor /odm /product; do + for propfile in default.prop build.prop; do + test "$propval" || propval="$(file_getprop $propdir/$propfile $1 2>/dev/null)"; + done; + done; test "$propval" && echo "$propval" || echo ""; } -elif [ ! "$(getprop ro.product.device 2>/dev/null)" -a ! "$(getprop ro.build.product 2>/dev/null)" ]; then +elif [ ! "$(getprop ro.product.device 2>/dev/null)" -a ! "$(getprop ro.build.product 2>/dev/null)" -a ! "$(getprop ro.vendor.product.device 2>/dev/null)" -a ! "$(getprop ro.vendor.build.product 2>/dev/null)" ]; then getprop() { ($(which getprop) | $bb grep "$1" | $bb cut -d[ -f3 | $bb cut -d] -f1) 2>/dev/null; } @@ -177,14 +181,18 @@ fi; if [ "$(file_getprop anykernel.sh do.devicecheck)" == 1 ]; then ui_print "Checking device..."; - device=$(getprop ro.product.device); - product=$(getprop ro.build.product); + device=$(getprop ro.product.device 2>/dev/null); + product=$(getprop ro.build.product 2>/dev/null); + vendordevice=$(getprop ro.vendor.product.device 2>/dev/null); + vendorproduct=$(getprop ro.vendor.build.product 2>/dev/null); for testname in $(file_getprop anykernel.sh 'device.name.*'); do - if [ "$device" == "$testname" -o "$product" == "$testname" ]; then - ui_print "$testname" " "; - match=1; - break; - fi; + for devicename in $device $product $vendordevice $vendorproduct; do + if [ "$devicename" == "$testname" ]; then + ui_print "$testname" " "; + match=1; + break 2; + fi; + done; done; if [ ! "$match" ]; then abort " " "Unsupported device. Aborting..."; |