You've already forked PlayIntegrityFork
mirror of
https://github.com/osm0sis/PlayIntegrityFork.git
synced 2025-09-06 06:37:06 +00:00
Add custom.pif.json migration script
- runs during install/update when an old format file is detected and upgrades it to the current default format which now properly separates Build fields and system properties - supports all previously used deprecated entries, e.g. BUILD_ID, FIRST_API_LEVEL and VNDK_VERSION - extracts any missing information for default added fields from the FINGERPRINT - may also be run manually from command prompt with `sh migrate.sh` or with file explorer app supporting scripts like FX File Explorer
This commit is contained in:
@@ -18,6 +18,15 @@ if [ -f /data/adb/modules/playintegrityfix/custom.pif.json ]; then
|
|||||||
cp -af /data/adb/modules/playintegrityfix/custom.pif.json $MODPATH/custom.pif.json
|
cp -af /data/adb/modules/playintegrityfix/custom.pif.json $MODPATH/custom.pif.json
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Migrate custom.pif.json to latest defaults if needed
|
||||||
|
if [ -f "$MODPATH/custom.pif.json" ] && ! grep -q "api_level" $MODPATH/custom.pif.json; then
|
||||||
|
ui_print "- Running migration script on custom.pif.json:"
|
||||||
|
ui_print " "
|
||||||
|
chmod 755 $MODPATH/migrate.sh
|
||||||
|
sh $MODPATH/migrate.sh install $MODPATH/custom.pif.json
|
||||||
|
ui_print " "
|
||||||
|
fi
|
||||||
|
|
||||||
# Clean up any leftover files from previous deprecated methods
|
# Clean up any leftover files from previous deprecated methods
|
||||||
rm -f /data/data/com.google.android.gms/cache/pif.prop /data/data/com.google.android.gms/pif.prop
|
rm -f /data/data/com.google.android.gms/cache/pif.prop /data/data/com.google.android.gms/pif.prop
|
||||||
rm -f /data/data/com.google.android.gms/cache/pif.json /data/data/com.google.android.gms/pif.json
|
rm -f /data/data/com.google.android.gms/cache/pif.json /data/data/com.google.android.gms/pif.json
|
||||||
|
|||||||
92
module/migrate.sh
Normal file
92
module/migrate.sh
Normal file
@@ -0,0 +1,92 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
case "$1" in
|
||||||
|
install) INSTALL=1; shift;;
|
||||||
|
*) echo "custom.pif.json migration script \
|
||||||
|
\n by osm0sis @ xda-developers \n";;
|
||||||
|
esac;
|
||||||
|
|
||||||
|
item() { echo "- $@"; }
|
||||||
|
die() { [ "$INSTALL" ] || echo "\n\n! $@"; exit 1; }
|
||||||
|
grep_get_json() { grep "$1" "$DIR/custom.pif.json" | cut -d\" -f4; }
|
||||||
|
grep_check_json() { grep -q "$1" "$DIR/custom.pif.json" && [ "$(grep_get_json "$1")" ]; }
|
||||||
|
|
||||||
|
if [ -f "$1" ]; then
|
||||||
|
DIR="$1";
|
||||||
|
shift;
|
||||||
|
else
|
||||||
|
case "$0" in
|
||||||
|
*.sh) DIR="$0";;
|
||||||
|
*) DIR="$(lsof -p $$ 2>/dev/null | grep -o '/.*migrate.sh$')";;
|
||||||
|
esac;
|
||||||
|
fi;
|
||||||
|
DIR=$(dirname "$(readlink -f "$DIR")");
|
||||||
|
|
||||||
|
[ -f "$DIR/custom.pif.json" ] || die "No custom.pif.json found";
|
||||||
|
|
||||||
|
grep_check_json api_level && die "No migration required";
|
||||||
|
|
||||||
|
[ "$INSTALL" ] || item "Parsing fields ...";
|
||||||
|
|
||||||
|
FPFIELDS="BRAND PRODUCT DEVICE RELEASE ID INCREMENTAL TYPE TAGS";
|
||||||
|
ALLFIELDS="MANUFACTURER MODEL FINGERPRINT $FPFIELDS SECURITY_PATCH DEVICE_INITIAL_SDK_INT";
|
||||||
|
|
||||||
|
for FIELD in $ALLFIELDS; do
|
||||||
|
eval $FIELD=\"$(grep_get_json \"$FIELD\")\";
|
||||||
|
done;
|
||||||
|
|
||||||
|
if [ -z "$ID" ] && grep_check_json BUILD_ID; then
|
||||||
|
item 'Deprecated entry BUILD_ID found, changing to ID field and "*.build.id" property ...';
|
||||||
|
ID="$(grep_get_json BUILD_ID)";
|
||||||
|
fi;
|
||||||
|
|
||||||
|
if [ -n "$SECURITY_PATCH" ] && ! grep_check_json security_patch; then
|
||||||
|
item 'Simple entry SECURITY_PATCH found, changing to SECURITY_PATCH field and "*.security_patch" property ...';
|
||||||
|
fi;
|
||||||
|
|
||||||
|
if grep_check_json VNDK_VERSION; then
|
||||||
|
item 'Deprecated entry VNDK_VERSION found, changing to "*.vndk_version" property ...';
|
||||||
|
VNDK_VERSION="$(grep_get_json VNDK_VERSION)";
|
||||||
|
fi;
|
||||||
|
|
||||||
|
if [ -z "$DEVICE_INITIAL_SDK_INT" ] && grep_check_json FIRST_API_LEVEL; then
|
||||||
|
item 'Deprecated entry FIRST_API_LEVEL found, changing to DEVICE_INITIAL_SDK_INT field and "*api_level" property ...';
|
||||||
|
DEVICE_INITIAL_SDK_INT="$(grep_get_json FIRST_API_LEVEL)";
|
||||||
|
fi;
|
||||||
|
|
||||||
|
if [ -z "$RELEASE" -o -z "$INCREMENTAL" -o -z "$TYPE" -o -z "$TAGS" ]; then
|
||||||
|
item "Missing default fields found, deriving from FINGERPRINT ...";
|
||||||
|
IFS='/:' read F1 F2 F3 F4 F5 F6 F7 F8 <<EOF
|
||||||
|
$(grep_get_json FINGERPRINT)
|
||||||
|
EOF
|
||||||
|
i=1;
|
||||||
|
for FIELD in $FPFIELDS; do
|
||||||
|
eval [ -z "\$$FIELD" ] \&\& $FIELD=\"\$F$i\";
|
||||||
|
i=$((i+1));
|
||||||
|
done;
|
||||||
|
fi;
|
||||||
|
|
||||||
|
if [ -z "$DEVICE_INITIAL_SDK_INT" ]; then
|
||||||
|
item 'Missing required DEVICE_INITIAL_SDK_INT field and "*api_level" property value found, setting to 25 ...';
|
||||||
|
DEVICE_INITIAL_SDK_INT=25;
|
||||||
|
fi;
|
||||||
|
|
||||||
|
item "Renaming old file to custom.pif.json.bak ...";
|
||||||
|
mv -f "$DIR/custom.pif.json" "$DIR/custom.pif.json.bak";
|
||||||
|
|
||||||
|
[ "$INSTALL" ] || item "Writing fields and properties to updated custom.pif.json ...";
|
||||||
|
|
||||||
|
(echo "{";
|
||||||
|
echo " // Build Fields";
|
||||||
|
for FIELD in $ALLFIELDS; do
|
||||||
|
eval echo '\ \ \ \ \"$FIELD\": \"'\$$FIELD'\",';
|
||||||
|
done;
|
||||||
|
echo -e "\n // System Properties";
|
||||||
|
echo ' "*.build.id": "'$ID'",';
|
||||||
|
echo ' "*.security_patch": "'$SECURITY_PATCH'",';
|
||||||
|
[ -z "$VNDK_VERSION" ] || echo ' "*.vndk_version": "'$VNDK_VERSION'",';
|
||||||
|
echo ' "*api_level": "'$DEVICE_INITIAL_SDK_INT'"';
|
||||||
|
echo "}") > "$DIR/custom.pif.json";
|
||||||
|
|
||||||
|
[ "$INSTALL" ] || cat "$DIR/custom.pif.json";
|
||||||
|
|
||||||
Reference in New Issue
Block a user