Skip to content

Commit 5f549e4

Browse files
authored
Improved device check
1 parent bd19028 commit 5f549e4

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

boot-switcher/META-INF/com/google/android/update-binary

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,23 @@ abort() { ui_print "E$1: $2"; cleanup; exit $1; }
2323

2424
# <<< TWRP init <<<
2525

26+
# >>> Custom functions >>>
27+
28+
# Verify device boardname validity (e.g. not unset, no spaces / uppercase chars)
29+
invalid_device() { [[ -z "$CURRENT_DEVICE" || "$CURRENT_DEVICE" = *" "* || "$CURRENT_DEVICE" =~ [A-Z] ]]; }
30+
31+
# <<< Custom functions <<<
32+
2633
# Constants & variables
2734
TARGET_DEVICES="cheeseburger dumpling"
28-
CURRENT_DEVICE=`getprop ro.product.device`
35+
CURRENT_DEVICE=`getprop ro.omni.device`
2936
ROOT="/data/.stowaways/sailfishos"
3037

3138
# >>> Sanity checks >>>
3239

3340
# Device
34-
[ -z "$CURRENT_DEVICE" ] && CURRENT_DEVICE=`getprop ro.build.product`
41+
invalid_device && CURRENT_DEVICE=`getprop ro.product.device`
42+
invalid_device && CURRENT_DEVICE=`getprop ro.build.product`
3543
echo $TARGET_DEVICES | grep -q $CURRENT_DEVICE || abort 7 "This package is for '$TARGET_DEVICES' devices; this is a '$CURRENT_DEVICE'."
3644

3745
# Treble
@@ -195,4 +203,4 @@ log "Boot target updated successfully."
195203
ui_print " All done, enjoy your new OS!"
196204
ui_print
197205
cleanup
198-
exit 0
206+
exit 0

0 commit comments

Comments
 (0)