Skip to content

Commit df03a28

Browse files
KOWX712osm0sis
andcommitted
autopif: use canary channel fp
ref: osm0sis/PlayIntegrityFork@453b734 Co-Authored-By: osm0sis <osm0sis@outlook.com>
1 parent f23b096 commit df03a28

2 files changed

Lines changed: 62 additions & 76 deletions

File tree

.github/workflows/autopif.yml

Lines changed: 37 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -4,66 +4,42 @@ on:
44
schedule:
55
- cron: '0 0 * * *'
66
workflow_dispatch:
7-
inputs:
8-
force_update:
9-
description: 'Force update'
10-
required: false
11-
type: boolean
12-
default: false
137

148
jobs:
15-
get_rom_info:
9+
get_device_list:
1610
runs-on: ubuntu-latest
1711
outputs:
1812
matrix: ${{ steps.get_info.outputs.matrix }}
19-
need_update: ${{ steps.get_info.outputs.need_update }}
20-
ota_hash: ${{ steps.get_info.outputs.ota_hash }}
2113
steps:
2214
- name: Checkout repository
2315
uses: actions/checkout@v6
2416
with:
2517
fetch-depth: 1
2618
ref: bot
2719

28-
- name: Get ROM info
20+
- name: Get device list
2921
id: get_info
3022
run: |
3123
download() { wget -T 20 --no-check-certificate "$1" -O "$2"; }
3224
3325
mkdir -p tmp && cd tmp
3426
download https://developer.android.com/about/versions PIXEL_VERSIONS_HTML
3527
download "$(grep -o 'https://developer.android.com/about/versions/.*[0-9]"' PIXEL_VERSIONS_HTML | sort -ru | cut -d\" -f1 | head -n1)" PIXEL_LATEST_HTML
36-
download "https://developer.android.com$(grep -o 'href=".*download-ota.*"' PIXEL_LATEST_HTML | grep 'qpr' | cut -d\" -f2 | head -n1)" PIXEL_OTA_HTML
28+
download "https://developer.android.com$(grep -o 'href=".*download.*"' PIXEL_LATEST_HTML | grep 'qpr' | cut -d\" -f2 | head -n1)" PIXEL_FI_HTML
3729
3830
# Extract device information
39-
grep -A1 'tr id=' PIXEL_OTA_HTML | grep 'td' | sed 's;.*<td>\(.*\)</td>;\1;' | sed 's/^[[:space:]]*//g;s/[[:space:]]*$//g' > MODEL_LIST
40-
grep -o 'tr id="[^\"]*"' PIXEL_OTA_HTML | awk -F\" '{print $2 "_beta"}' | sed 's/^[[:space:]]*//g;s/[[:space:]]*$//g' > PRODUCT_LIST
41-
for i in $(cat PRODUCT_LIST); do
42-
OTA_LINK=$(grep "ota/$i" PIXEL_OTA_HTML | cut -d\" -f2 || echo "")
43-
echo "$OTA_LINK" >> OTA_LIST
44-
done
45-
46-
CURRENT_HASH=$(sha256sum OTA_LIST | cut -d' ' -f1)
47-
LAST_HASH=$(cat ../HASH || echo '')
48-
49-
if [ "$CURRENT_HASH" == "$LAST_HASH" ] && [ "${{ github.event.inputs.force_update }}" != "true" ]; then
50-
echo "need_update=false" >> $GITHUB_OUTPUT
51-
echo "matrix={}" >> $GITHUB_OUTPUT
52-
echo "ota_hash=$CURRENT_HASH" >> $GITHUB_OUTPUT
53-
else
54-
echo "need_update=true" >> $GITHUB_OUTPUT
55-
matrix_json=$(paste -d ',' MODEL_LIST PRODUCT_LIST OTA_LIST | jq -R 'split(",") | {model: .[0], product: .[1], ota_link: .[2]}' | jq -s '{include: [.[] | select(.ota_link != "")]}' | jq -c .)
56-
echo "matrix=$matrix_json" >> $GITHUB_OUTPUT
57-
echo "ota_hash=$CURRENT_HASH" >> $GITHUB_OUTPUT
58-
fi
31+
grep -A1 'tr id=' PIXEL_FI_HTML | grep 'td' | sed 's;.*<td>\(.*\)</td>;\1;' | sed 's/^[[:space:]]*//g;s/[[:space:]]*$//g' > MODEL_LIST
32+
grep -o 'tr id="[^\"]*"' PIXEL_FI_HTML | awk -F\" '{print $2 "_beta"}' | sed 's/^[[:space:]]*//g;s/[[:space:]]*$//g' > PRODUCT_LIST
33+
34+
matrix_json=$(paste MODEL_LIST PRODUCT_LIST | jq -R 'split("\t") | {model: .[0], product: .[1]}' | jq -s '{include: .}' | jq -c .)
35+
echo "matrix=$matrix_json" >> $GITHUB_OUTPUT
5936
6037
process_rom:
61-
needs: get_rom_info
62-
if: needs.get_rom_info.outputs.need_update == 'true'
38+
needs: get_device_list
6339
runs-on: ubuntu-latest
6440
strategy:
6541
fail-fast: false
66-
matrix: ${{ fromJson(needs.get_rom_info.outputs.matrix) }}
42+
matrix: ${{ fromJson(needs.get_device_list.outputs.matrix) }}
6743

6844
steps:
6945
- name: Checkout repository
@@ -72,16 +48,6 @@ jobs:
7248
fetch-depth: 1
7349
ref: bot
7450

75-
- name: Set up Python
76-
uses: actions/setup-python@v6
77-
with:
78-
python-version: '3.x'
79-
80-
- name: Install dependencies
81-
run: |
82-
python -m pip install --upgrade pip
83-
pip install git+https://github.com/5ec1cff/payload-dumper
84-
8551
- name: Process ROM
8652
uses: nick-invision/retry@v3
8753
with:
@@ -90,14 +56,26 @@ jobs:
9056
command: |
9157
model="${{ matrix.model }}"
9258
product="${{ matrix.product }}"
93-
ota_link="${{ matrix.ota_link }}"
9459
9560
mkdir -p tmp && cd tmp
9661
97-
# Get other information
98-
payload_dumper --metadata --out . "$ota_link"
99-
FINGERPRINT=$(grep -am1 'post-build=' metadata | cut -d= -f2)
100-
SECURITY_PATCH=$(grep -am1 'security-patch-level=' metadata | cut -d= -f2)
62+
# Get device fingerprint and security patch from Flash Tool and bulletins
63+
DEVICE="$(echo "$product" | sed 's/_beta//')"
64+
wget -T 20 --no-check-certificate https://flash.android.com -O PIXEL_FLASH_HTML
65+
FLASH_KEY=$(grep -o '<body data-client-config=.*' PIXEL_FLASH_HTML | cut -d\; -f2 | cut -d\& -f1)
66+
curl -H "Referer: https://flash.android.com" -s "https://content-flashstation-pa.googleapis.com/v1/builds?product=$product&key=$FLASH_KEY" > PIXEL_STATION_JSON
67+
CANARY_LATEST_JSON="$(tac PIXEL_STATION_JSON | grep -m1 -A13 'canary')"
68+
ID="$(echo "$CANARY_LATEST_JSON" | grep 'releaseCandidateName' | cut -d\" -f4)"
69+
INCREMENTAL="$(echo "$CANARY_LATEST_JSON" | grep 'buildId' | cut -d\" -f4)"
70+
FINGERPRINT="google/$product/$DEVICE:CANARY/$ID/$INCREMENTAL:user/release-keys"
71+
wget -T 20 --no-check-certificate https://source.android.com/docs/security/bulletin/pixel -O PIXEL_SECBULL_HTML
72+
SECBULL_ID="$(echo "$CANARY_LATEST_JSON" | grep '"id"' | sed -e 's;.*canary-\(.*\)".*;\1;' -e 's;^\(.\{4\}\);\1-;')"
73+
SECURITY_PATCH="$(grep "<td>$SECBULL_ID" PIXEL_SECBULL_HTML | sed 's;.*<td>\(.*\)</td>;\1;')"
74+
75+
if [ -z "$ID" ] || [ -z "$INCREMENTAL" ] || [ -z "$SECURITY_PATCH" ]; then
76+
echo "! Failed to get pif.prop for $product"
77+
exit 1
78+
fi
10179
10280
cat <<EOF > ../${product}.prop
10381
FINGERPRINT=$FINGERPRINT
@@ -113,8 +91,7 @@ jobs:
11391
path: ${{ matrix.product }}.prop
11492

11593
commit_and_push:
116-
needs: [get_rom_info, process_rom]
117-
if: needs.get_rom_info.outputs.need_update == 'true'
94+
needs: [get_device_list, process_rom]
11895
runs-on: ubuntu-latest
11996
steps:
12097
- name: Checkout repository
@@ -131,21 +108,24 @@ jobs:
131108
uses: actions/download-artifact@v7
132109
with:
133110
path: device_prop
134-
111+
135112
- name: Flatten artifacts
136113
run: |
137114
find device_prop -mindepth 2 -type f -exec mv -t device_prop/ {} +
138115
find device_prop -type d -empty -delete
139116
140-
- name: Export formatted device list and new hash
117+
- name: Export formatted device list
141118
run: |
142-
echo '${{ needs.get_rom_info.outputs.matrix }}' | jq '.include | map({model, product})' > device_list.json
143-
echo '${{ needs.get_rom_info.outputs.ota_hash }}' > HASH
119+
echo '${{ needs.get_device_list.outputs.matrix }}' | jq '.include | map({model, product})' > device_list.json
144120
145121
- name: Commit and Push
146122
run: |
147123
git config --global user.email "github-actions[bot]@users.noreply.github.com"
148124
git config --global user.name "github-actions[bot]"
149125
150-
git add device_prop/. device_list.json HASH
151-
git commit -m "update device list" && git push
126+
git add device_prop/. device_list.json
127+
if git diff --cached --quiet; then
128+
echo "No changes to commit"
129+
else
130+
git commit -m "update device list" && git push
131+
fi

module/autopif.sh

Lines changed: 25 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -54,46 +54,52 @@ get_model_product_list() {
5454
exit 0
5555
}
5656

57-
# Get latest Pixel Beta information
57+
# Get latest Pixel Canary information
5858
download https://developer.android.com/about/versions PIXEL_VERSIONS_HTML
59-
BETA_URL=$(grep -o 'https://developer.android.com/about/versions/.*[0-9]"' PIXEL_VERSIONS_HTML | sort -ru | cut -d\" -f1 | head -n1)
60-
download "$BETA_URL" PIXEL_LATEST_HTML
59+
LATEST_URL=$(grep -o 'https://developer.android.com/about/versions/.*[0-9]"' PIXEL_VERSIONS_HTML | sort -ru | cut -d\" -f1 | head -n1)
60+
download "$LATEST_URL" PIXEL_LATEST_HTML
6161

62-
# Get OTA information
63-
OTA_URL="https://developer.android.com$(grep -o 'href=".*download-ota.*"' PIXEL_LATEST_HTML | grep 'qpr' | cut -d\" -f2 | head -n1)"
64-
download "$OTA_URL" PIXEL_OTA_HTML
62+
# Get FI information
63+
FI_URL="https://developer.android.com$(grep -o 'href=".*download.*"' PIXEL_LATEST_HTML | grep 'qpr' | cut -d\" -f2 | head -n1)"
64+
download "$FI_URL" PIXEL_FI_HTML
6565

6666
# Extract device information
67-
MODEL_LIST="$(grep -A1 'tr id=' PIXEL_OTA_HTML | grep 'td' | sed 's;.*<td>\(.*\)</td>;\1;')"
68-
PRODUCT_LIST="$(grep -o 'tr id="[^"]*"' PIXEL_OTA_HTML | awk -F\" '{print $2 "_beta"}')"
69-
OTA_LIST="$(grep 'ota/.*_beta' PIXEL_OTA_HTML | cut -d\" -f2)"
67+
MODEL_LIST="$(grep -A1 'tr id=' PIXEL_FI_HTML | grep 'td' | sed 's;.*<td>\(.*\)</td>;\1;')"
68+
PRODUCT_LIST="$(grep -o 'tr id="[^"]*"' PIXEL_FI_HTML | awk -F\" '{print $2 "_beta"}')"
7069

7170
# List available devices
7271
if [ "$1" = "--list" ] || [ "$1" = "-l" ]; then
7372
get_model_product_list
7473
fi
7574

7675
# Select and configure device
77-
echo "- Selecting Pixel Beta device ..."
76+
echo "- Selecting Pixel Canary device ..."
7877
if [ -z "$PRODUCT" ] || ! echo "$PRODUCT_LIST" | grep -q "$PRODUCT"; then
7978
set_random_beta
8079
fi
8180
echo "$MODEL ($PRODUCT)"
8281

83-
# Get device fingerprint and security patch from OTA metadata
84-
OTA_LINK="$(echo "$OTA_LIST" | grep "$PRODUCT")"
82+
# Get device fingerprint and security patch from Flash Tool and bulletins
83+
DEVICE="$(echo "$PRODUCT" | sed 's/_beta//')"
84+
download https://flash.android.com PIXEL_FLASH_HTML
85+
FLASH_KEY=$(grep -o '<body data-client-config=.*' PIXEL_FLASH_HTML | cut -d\; -f2 | cut -d\& -f1)
8586
if command -v curl > /dev/null 2>&1; then
86-
curl --connect-timeout 10 -s "$OTA_LINK" | strings | head -n15 > PIXEL_ZIP_METADATA || download_fail "$OTA_LINK"
87+
curl --connect-timeout 10 -H "Referer: https://flash.android.com" -s "https://content-flashstation-pa.googleapis.com/v1/builds?product=$PRODUCT&key=$FLASH_KEY" > PIXEL_STATION_JSON || download_fail "https://flash.android.com"
8788
else
88-
busybox wget -T 10 --no-check-certificate -qO - "$OTA_LINK" | strings | head -n15 > PIXEL_ZIP_METADATA || download_fail "$OTA_LINK"
89+
busybox wget -T 10 --header "Referer: https://flash.android.com" -qO - "https://content-flashstation-pa.googleapis.com/v1/builds?product=$PRODUCT&key=$FLASH_KEY" > PIXEL_STATION_JSON || download_fail "https://flash.android.com"
8990
fi
90-
FINGERPRINT="$(grep -am1 'post-build=' PIXEL_ZIP_METADATA | cut -d= -f2)"
91-
SECURITY_PATCH="$(grep -am1 'security-patch-level=' PIXEL_ZIP_METADATA | cut -d= -f2)"
91+
CANARY_LATEST_JSON="$(tac PIXEL_STATION_JSON | grep -m1 -A13 'canary')"
92+
ID="$(echo "$CANARY_LATEST_JSON" | grep 'releaseCandidateName' | cut -d\" -f4)"
93+
INCREMENTAL="$(echo "$CANARY_LATEST_JSON" | grep 'buildId' | cut -d\" -f4)"
94+
FINGERPRINT="google/$PRODUCT/$DEVICE:CANARY/$ID/$INCREMENTAL:user/release-keys"
95+
download https://source.android.com/docs/security/bulletin/pixel PIXEL_SECBULL_HTML
96+
SECBULL_ID="$(echo "$CANARY_LATEST_JSON" | grep '"id"' | sed -e 's;.*canary-\(.*\)".*;\1;' -e 's;^\(.\{4\}\);\1-;')"
97+
SECURITY_PATCH="$(grep "<td>$SECBULL_ID" PIXEL_SECBULL_HTML | sed 's;.*<td>\(.*\)</td>;\1;')"
9298

9399
# Validate required field to prevent empty pif.prop
94-
if [ -z "$FINGERPRINT" ] || [ -z "$SECURITY_PATCH" ]; then
95-
# link to download pixel rom metadata
96-
download_fail "https://dl.google.com"
100+
if [ -z "$ID" ] || [ -z "$INCREMENTAL" ] || [ -z "$SECURITY_PATCH" ]; then
101+
echo "! Failed to get pif.prop"
102+
exit 1
97103
fi
98104

99105
# Preserve previous setting

0 commit comments

Comments
 (0)