post-fs-data: Dynamically select SDK version at runtime

This allows the module to keep working after major system upgrades.
This commit is contained in:
Danny Lin 2021-06-26 19:02:41 -07:00
parent e94eb5b275
commit 7a732dc9e2
No known key found for this signature in database
GPG Key ID: 1988FAA1797EE5AC
2 changed files with 29 additions and 7 deletions

View File

@ -16,15 +16,15 @@ if getprop ro.build.id | grep -q SPB2; then
version="12 Beta 2"
fi
if mv "$MODPATH/system_sdk$sdk" $MODPATH/system; then
ui_print "Installing for Android $version"
else
# Initial version check; version can be changed later.
if [[ ! -d "$MODPATH/system_sdk$sdk" ]]; then
ui_print "Android $version (SDK $sdk) is not supported!"
rm -fr "$MODPATH"
exit 1
fi
# Remove unused SDKs
rm -fr $MODPATH/system_sdk*
# Set executable permissions
set_perm_recursive $MODPATH/system/bin 0 0 0755 0755
for sdk in $MODPATH/system_sdk*
do
set_perm_recursive $sdk/bin 0 0 0755 0755
done

22
post-fs-data.sh Executable file
View File

@ -0,0 +1,22 @@
#!/system/bin/sh
MODPATH="/data/adb/modules/safetynet-fix"
# Get runtime version
sdk="$(getprop ro.build.version.sdk)"
version="$(getprop ro.vendor.build.version.release)"
if getprop ro.build.id | grep -q SPB2; then
sdk=31-b2
version="12 Beta 2"
fi
# Prepare to update version
rm -fr "$MODPATH/system"
# Make sure version is supported
if [[ ! -d "$MODPATH/system_sdk$sdk" ]]; then
exit
fi
# Symlink results in the wrong SELinux context
cp -r "$MODPATH/system_sdk$sdk" "$MODPATH/system"