Skip to content
Permalink
Browse files

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
  • Loading branch information
osm0sis committed Oct 16, 2019
1 parent 98b1ac6 commit 6515f57493b5a83791ec8401d6d5e728614fe124
Showing with 19 additions and 11 deletions.
  1. +19 −11 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,26 +165,34 @@ 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;
}
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...";

0 comments on commit 6515f57

Please sign in to comment.
You can’t perform that action at this time.