-
Notifications
You must be signed in to change notification settings - Fork 2
/
ThemeWizard.sh
79 lines (63 loc) · 2.39 KB
/
ThemeWizard.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#!/bin/bash
ADB="adb"
THEME_STORE_PKG="com.heytap.themestore"
NEARME_THEME_STORE_PKG="com.nearme.themestore"
print_banner() {
local banner=(
"******************************************"
"* OPPO/OnePlus/Realme Theme Wizard *"
"* Theme Patching Tool *"
"* v1.3.1 *"
"* ---------------------------- *"
"* by @ImKKingshuk *"
"* Github- https://github.com/ImKKingshuk *"
"******************************************"
)
local width=$(tput cols)
for line in "${banner[@]}"; do
printf "%*s\n" $(((${#line} + width) / 2)) "$line"
done
echo
}
check_and_convert_trial_status() {
local setting_name="$1"
local display_name="$2"
local uuid_setting="$3"
local status=$($ADB shell settings get system "$setting_name" 2>/dev/null)
if [ "$status" -ne 0 ]; then
echo "$display_name Status: Trial"
$ADB shell settings put system "$uuid_setting" -1
$ADB shell settings put secure "$uuid_setting" -1
$ADB shell settings put system "$setting_name" 0
$ADB shell settings put secure "$setting_name" 0
echo "Successfully converted to permanent."
else
echo "$display_name Status: Permanent"
fi
}
main() {
print_banner
pkill -f "$ADB"
$ADB start-server
if [ $? -ne 0 ]; then
echo "ERROR - adb not found. Check if adb is in the PATH."
exit 1
fi
local device=$($ADB reconnect 2>&1 | tail -n 1)
if [[ "$device" == *"more than one device/emulator"* ]]; then
echo "ERROR - More than one Android device detected. Disconnect them or turn off USB debugging."
exit 1
fi
if [[ "$device" == *"no devices/emulators found"* ]]; then
echo "ERROR - No Android devices are connected. Make sure you have USB debugging turned on."
exit 1
fi
echo "Successfully connected to $device"
$ADB shell am force-stop "$THEME_STORE_PKG"
$ADB shell am force-stop "$NEARME_THEME_STORE_PKG"
check_and_convert_trial_status "persist.sys.trial.theme" "Theme" "persist.sys.oppo.theme_uuid"
check_and_convert_trial_status "persist.sys.trial.font" "Font" "persist.sys.trial.font"
check_and_convert_trial_status "persist.sys.trial.live_wp" "Live Wallpaper" "persist.sys.trial.live_wp_uuid"
$ADB kill-server
}
main