2024-12-24 09:48:43 +02:00
|
|
|
#!/bin/sh
|
2024-12-24 09:52:57 +02:00
|
|
|
PATH=/data/adb/ap/bin:/data/adb/ksu/bin:/data/adb/magisk:/data/data/com.termux/files/usr/bin:$PATH
|
2024-12-24 09:58:00 +02:00
|
|
|
|
|
|
|
# functions
|
2024-12-24 09:48:43 +02:00
|
|
|
die() { echo "Error: $@!"; exit 1; }
|
2024-12-24 09:43:15 +02:00
|
|
|
|
2024-12-24 09:48:43 +02:00
|
|
|
find_busybox() {
|
2024-12-24 09:52:57 +02:00
|
|
|
command -v busybox "$@"
|
2024-12-24 09:48:43 +02:00
|
|
|
}
|
2024-12-24 09:43:15 +02:00
|
|
|
|
2024-12-24 09:48:43 +02:00
|
|
|
if date -D '%s' -d "$(date '+%s')" 2>&1 | grep -qE "bad date|invalid option"; then
|
|
|
|
find_busybox && date() { $BUSYBOX date "$@"; } || die "date broken"
|
|
|
|
fi
|
|
|
|
|
2024-12-24 09:58:00 +02:00
|
|
|
download() {
|
|
|
|
if command -v curl > /dev/null 2>&1; then
|
|
|
|
curl --connect-timeout 10 -s "$1"
|
|
|
|
else
|
|
|
|
busybox wget -T 10 --no-check-certificate -qO - "$1"
|
|
|
|
fi
|
|
|
|
}
|
2024-12-24 09:48:43 +02:00
|
|
|
|
|
|
|
if echo -e "A\nB" | grep -q "A.*B"; then
|
|
|
|
find_busybox || die "grep broken"
|
|
|
|
grep() { $BUSYBOX grep "$@"; }
|
|
|
|
fi
|
|
|
|
|
|
|
|
set_random_beta() {
|
|
|
|
if [ "$(echo "$MODEL_LIST" | wc -l)" -ne "$(echo "$PRODUCT_LIST" | wc -l)" ]; then
|
|
|
|
die "MODEL_LIST and PRODUCT_LIST have different lengths."
|
|
|
|
fi
|
|
|
|
count=$(echo "$MODEL_LIST" | wc -l)
|
|
|
|
rand_index=$(( $$ % count ))
|
|
|
|
MODEL=$(echo "$MODEL_LIST" | sed -n "$((rand_index + 1))p")
|
|
|
|
PRODUCT=$(echo "$PRODUCT_LIST" | sed -n "$((rand_index + 1))p")
|
|
|
|
DEVICE=$(echo "$PRODUCT" | sed 's/_beta//')
|
|
|
|
}
|
2024-12-24 09:43:15 +02:00
|
|
|
|
2024-12-24 09:48:43 +02:00
|
|
|
DIR="$MODPATH/autopif"
|
|
|
|
mkdir -p "$DIR"
|
|
|
|
cd "$DIR"
|
2024-12-24 09:43:15 +02:00
|
|
|
|
2024-12-24 10:52:58 +02:00
|
|
|
download https://developer.android.com/topic/generic-system-image/releases > PIXEL_GSI_HTML || {
|
|
|
|
echo "download failed!"
|
|
|
|
exit 0
|
|
|
|
}
|
2024-12-24 09:48:43 +02:00
|
|
|
grep -m1 -o 'li>.*(Beta)' PIXEL_GSI_HTML | cut -d\> -f2
|
2024-12-24 10:52:58 +02:00
|
|
|
grep -m1 -o 'Date:.*' PIXEL_GSI_HTML
|
2024-12-24 09:48:43 +02:00
|
|
|
|
|
|
|
RELEASE="$(grep -m1 'corresponding Google Pixel builds' PIXEL_GSI_HTML | grep -o '/versions/.*' | cut -d/ -f3)"
|
|
|
|
ID="$(grep -m1 -o 'Build:.*' PIXEL_GSI_HTML | cut -d' ' -f2)"
|
|
|
|
INCREMENTAL="$(grep -m1 -o "$ID-.*-" PIXEL_GSI_HTML | cut -d- -f2)"
|
|
|
|
|
2024-12-24 09:58:00 +02:00
|
|
|
download "https://developer.android.com$(grep -m1 'corresponding Google Pixel builds' PIXEL_GSI_HTML | grep -o 'href.*' | cut -d\" -f2)" > PIXEL_GET_HTML || exit 1
|
|
|
|
download "https://developer.android.com$(grep -m1 'Factory images for Google Pixel' PIXEL_GET_HTML | grep -o 'href.*' | cut -d\" -f2)" > PIXEL_BETA_HTML || exit 1
|
2024-12-24 09:48:43 +02:00
|
|
|
|
|
|
|
MODEL_LIST="$(grep -A1 'tr id=' PIXEL_BETA_HTML | grep 'td' | sed 's;.*<td>\(.*\)</td>;\1;')"
|
|
|
|
PRODUCT_LIST="$(grep -o 'factory/.*_beta' PIXEL_BETA_HTML | cut -d/ -f2)"
|
|
|
|
|
2024-12-24 09:58:00 +02:00
|
|
|
download https://source.android.com/docs/security/bulletin/pixel > PIXEL_SECBULL_HTML|| exit 1
|
2024-12-24 09:43:15 +02:00
|
|
|
|
2024-12-24 09:48:43 +02:00
|
|
|
SECURITY_PATCH="$(grep -A15 "$(grep -m1 -o 'Security patch level:.*' PIXEL_GSI_HTML | cut -d' ' -f4-)" PIXEL_SECBULL_HTML | grep -m1 -B1 '</tr>' | grep 'td' | sed 's;.*<td>\(.*\)</td>;\1;')"
|
|
|
|
|
|
|
|
echo "- Selecting Pixel Beta device ..."
|
|
|
|
[ -z "$PRODUCT" ] && set_random_beta
|
|
|
|
echo "$MODEL ($PRODUCT)"
|
|
|
|
|
|
|
|
sdk_version="$(getprop ro.build.version.sdk)"
|
|
|
|
sdk_version="${sdk_version:-25}"
|
|
|
|
echo "Device SDK version: $sdk_version"
|
|
|
|
|
|
|
|
echo "- Dumping values to pif.json ..."
|
|
|
|
cat <<EOF | tee pif.json
|
2024-12-24 09:46:12 +02:00
|
|
|
{
|
2024-12-24 09:48:43 +02:00
|
|
|
"FINGERPRINT": "google/$PRODUCT/$DEVICE:$RELEASE/$ID/$INCREMENTAL:user/release-keys",
|
2024-12-24 09:46:12 +02:00
|
|
|
"MANUFACTURER": "Google",
|
|
|
|
"MODEL": "$MODEL",
|
|
|
|
"SECURITY_PATCH": "$SECURITY_PATCH",
|
2024-12-24 09:48:43 +02:00
|
|
|
"DEVICE_INITIAL_SDK_INT": $sdk_version
|
2024-12-24 09:46:12 +02:00
|
|
|
}
|
|
|
|
EOF
|
2024-12-24 09:43:15 +02:00
|
|
|
|
2024-12-24 09:48:43 +02:00
|
|
|
cp "$DIR/pif.json" "/data/adb/pif.json"
|
|
|
|
echo "- new pif.json saved to /data/adb/pif.json"
|
|
|
|
|
|
|
|
cd "$MODPATH"
|
|
|
|
|
|
|
|
echo "- Cleaning up ..."
|
|
|
|
rm -rf "$DIR"
|
|
|
|
|
|
|
|
su -c killall com.google.android.gms.unstable || echo ""
|