Backend: introduce Android version check

- checks the supported.versions prop in anykernel.sh and matches against it to prevent users flashing incorrect kernels for ROM versions
- supported.versions can be a list, e.g. "7.1.2, 8.0, 8.1" or a range, e.g. "8.1 - 9" of versions in the correct formatting for that Android version in ro.build.version.release in /system/build.prop
This commit is contained in:
osm0sis committed 2018-12-16 18:31:53 -04:00
1 parent 9e24ea91f1
commit a31d03f2ce
2 files changed
+31 -2

No files matched your search

+29 -2
View File
@@ -1,5 +1,5 @@
#!/sbin/sh
# AnyKernel2 Backend
# AnyKernel2 Backend (DO NOT CHANGE)
# osm0sis @ xda-developers
OUTFD=/proc/self/fd/$2;
@@ -120,11 +120,38 @@ if [ "$(file_getprop anykernel.sh do.devicecheck)" == 1 ]; then
fi;
done;
ui_print " ";
if [ "$match" != 1 ]; then
if [ ! "$match" ]; then
abort "Unsupported device. Aborting...";
fi;
fi;
supported_ver="$(file_getprop anykernel.sh supported.versions | $bb tr -d '[:space:]')";
if [ "$supported_ver" ]; then
ui_print "Checking Android version...";
android_ver="$(file_getprop /system/build.prop ro.build.version.release)";
if [ "$(echo $supported_ver | $bb grep -)" ]; then
lo_ver=$(echo $supported_ver | $bb cut -d- -f1);
hi_ver=$(echo $supported_ver | $bb cut -d- -f2);
if [ "$(echo -e "$hi_ver\n$lo_ver\n$android_ver" | $bb sort -g | $bb grep -n "$android_ver" | $bb grep '^2:')" ]; then
supported=1;
fi;
else
for ver in $(echo $supported_ver | $bb sed 's;,; ;g'); do
if [ "$ver" == "$android_ver" ]; then
supported=1;
break;
fi;
done;
fi;
if [ "$supported" ]; then
ui_print "$android_ver";
ui_print " ";
else
ui_print " ";
abort "Unsupported Android version. Aborting...";
fi;
fi;
ui_print "Installing...";
for i in $($bb --list); do
$bb ln -s $bb bin/$i;