Skip to content

Commit 355c044

Browse files
committed
feat: handle vbmeta related prop
- enforce boot hash to lowercase
1 parent 293f9e1 commit 355c044

4 files changed

Lines changed: 23 additions & 19 deletions

File tree

module/common/boot_hash

Lines changed: 0 additions & 6 deletions
This file was deleted.

module/install_func.sh

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,10 @@ find_config() {
3232
}
3333

3434
migrate_config() {
35-
# Migrate boot_hash
36-
if [ ! -f "/data/adb/boot_hash" ]; then
37-
mv "$COMPATH/boot_hash" "/data/adb/boot_hash"
38-
else
39-
rm -f "$COMPATH/boot_hash"
35+
# remove empty file
36+
if [ -f "/data/adb/boot_hash" ]; then
37+
hash_value=$(grep -v '^#' "/data/adb/boot_hash" | tr -d '[:space:]' | tr '[:upper:]' '[:lower:]')
38+
[ -z "$hash_value" ] && rm -f /data/adb/boot_hash || echo "$hash_value" > /data/adb/boot_hash
4039
fi
4140

4241
# Migrate security_patch config*

module/service.sh

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,25 @@ add_denylist_to_target() {
2222
done
2323
}
2424

25+
resetprop_if_empty() {
26+
CURRENT=$(getprop "$1")
27+
[ -z "$CURRENT" ] && resetprop -n "$1" "$2"
28+
}
29+
2530
# Spoof security patch
2631
if [ -f "/data/adb/tricky_store/security_patch_auto_config" ]; then
2732
sh "$MODPATH/common/get_extra.sh" --security-patch
2833
fi
2934

30-
# Reset verified Boot Hash
31-
hash_value=$(grep -v '^#' "/data/adb/boot_hash" | tr -d '[:space:]')
32-
if [ -n "$hash_value" ]; then
33-
resetprop -n ro.boot.vbmeta.digest "$hash_value"
35+
# Reset vbmeta related prop
36+
if [ -f "/data/adb/boot_hash" ]; then
37+
hash_value=$(grep -v '^#' "/data/adb/boot_hash" | tr -d '[:space:]' | tr '[:upper:]' '[:lower:]')
38+
[ -z "$hash_value" ] && rm -f /data/adb/boot_hash || resetprop -n ro.boot.vbmeta.digest "$hash_value"
3439
fi
35-
40+
resetprop_if_empty ro.boot.vbmeta.invalidate_on_error yes
41+
resetprop_if_empty ro.boot.vbmeta.avb_version 1.0
42+
resetprop_if_empty ro.boot.vbmeta.hash_alg sha256
43+
resetprop_if_empty ro.boot.vbmeta.size 10496
3644

3745
# Disable TSupport-A auto update target to prevent overwrite
3846
if [ -d "$TSPA" ]; then

module/webui/scripts/boot_hash.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ const bootHashOverlay = document.getElementById('boot-hash-overlay');
44
const inputBox = document.getElementById('boot-hash-input');
55
const saveButton = document.getElementById('boot-hash-save-button');
66

7-
// Remove empty spaces from input
7+
// Remove empty spaces from input and convert to lowercase
88
window.trimInput = (input) => {
9-
input.value = input.value.replace(/\s+/g, '');
9+
input.value = input.value.replace(/\s+/g, '').toLowerCase();
1010
};
1111

1212
// Function to handle Verified Boot Hash
@@ -38,10 +38,13 @@ document.getElementById("boot-hash").addEventListener("click", async () => {
3838
saveButton.addEventListener("click", async () => {
3939
const inputValue = inputBox.value.trim();
4040
try {
41-
await execCommand(`echo "${inputValue}" > /data/adb/boot_hash`);
4241
await execCommand(`
4342
PATH=/data/adb/ap/bin:/data/adb/ksu/bin:/data/adb/magisk:$PATH
4443
resetprop -n ro.boot.vbmeta.digest ${inputValue}
44+
[ -z "${inputValue}" ] && rm -f /data/adb/boot_hash || {
45+
echo "${inputValue}" > /data/adb/boot_hash
46+
chmod 644 /data/adb/boot_hash
47+
}
4548
`);
4649
showPrompt("prompt.boot_hash_set");
4750
closeBootHashMenu();

0 commit comments

Comments
 (0)