aboutsummaryrefslogtreecommitdiff
path: root/scripts/props.sh
blob: fd1bd0c125699003cdde657529ffbfe4bc252d34 (plain)
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
#!/bin/bash

if [ "$#" -ne 1 ]; then
	echo "[x] Incorrect arguments!"
	echo "     Using: $0 <BASE_DIR>"
	exit 1
fi

source .config

BASE_DIR=$1
BUILD_PROP="${BASE_DIR}/system_a/system/build.prop"

ADD_PROP_LIST=(
	"persist.camera.HAL3.enabled=1"

	"debug.hwui.render_dirty_regions=false"
	"debug.sf.skip_dirty_regions=1"
	"debug.sf.nobootanimation=1"
	"ro.max.fling_velocity=18000"
	"ro.min.fling_velocity=12000"
	"debug.sf.hw=1"

	"ro.telephony.call_ring.delay=0"
	"ro.media.enc.jpeg.quality=100"
	"ro.audio.silent=0"

	# Skip SetupWizard (required without GAPPS)
	"ro.setupwizard.enable_bypass=1"
	"ro.setupwizard.enterprise_mode=0"
	"ro.setupwizard.mode=DISABLED"
	"ro.setupwizard.network_required=false"
	"ro.setupwizard.wifi_required=false"
)

EDIT_PROP_LIST=(
	"persist.sys.zram_wb_enabled=false"
	"persist.sys.zram_wb_ai_enabled=false"
	"ro.zygote.preload.enable=1"
	"ro.moto.general.feature.ota=false"
	"ro.moto.general.clientid=false"
	"ro.moto.general.motosecure=false"
	"ro.moto.general.motofeedback=false"
	"ro.moto.general.motohelp=false"
	"ro.moto.general.time_weather=false"
	"ro.moto.general.feature.ironsource=false"
)

append_prop() {
	if ! grep -q "${1}" "$BUILD_PROP"; then
		echo -e "\t[+] Adding prop '${1}' to '${2}'"
		sed -i "$ a ${1}" "$BUILD_PROP"
	else
		echo -e "\t[i] Prop '${1}' is already present in '${2}'"
	fi
}

remove_prop() {
	if grep -q "^${1}" "${2}"; then
		echo -e "\t[-] Removing prop '${1}' from '${2}'"
		sed -i "/^${1}/d" "${2}"
	else
		echo -e "\t[i] Prop '${1}' is not present in '${2}'"
	fi
}

edit_prop() {
	prop_name="${1%%=*}"
	new_value="${1#*=}"
	if grep -q "${prop_name}=" "${2}"; then
		current_value=$(grep "^${prop_name}=" "${2}" | cut -d'=' -f2)
		if [ "$current_value" != "$new_value" ]; then
			echo "[=] Editing prop '${prop_name}' in '${2}'"
			sed -i "s/${prop_name}=.*/${prop_name}=${new_value}/" "${2}"
		else
			echo "[*] Prop '${prop_name}' already has the desired value (${new_value}) in '${2}'"
		fi
	else
		echo "[i] Prop '${prop_name}' is not present in '${2}'"
	fi
}


if [[ $ENABLE_INSECURE_ADB == 1 ]]; then
	ADD_PROP_LIST+=(
		"persist.adb.notify=0"
		"persist.service.adb.enable=1"
		"persist.service.debuggable=1"
		"persist.sys.usb.config=mtp,adb"
		"ro.adb.secure=0"
		"ro.debuggable=1"
		"ro.force.debuggable=1"
		"ro.control_privapp_permissions=log"
	)
fi

if [[ $DISABLE_MOTO_HELLO_UI == 1 ]]; then
	EDIT_PROP_LIST+=("ro.moto.general.feature.enable_systemui_hello_ui=false")
else
	if [[ $DISABLE_MOTO_HELLO_UI_BLUR == 1 ]]; then
		ADD_PROP_LIST+=(
			"ro.sf.blurs_are_expensive=1"
			"ro.surface_flinger.supports_background_blur=0"
			"persist.sysui.disableBlur=true"
		)
	fi
fi

for prop in "${EDIT_PROP_LIST[@]}"; do
	edit_prop "$prop" "${BUILD_PROP}"
done

for prop in "${ADD_PROP_LIST[@]}"; do
	append_prop "$prop" "${BUILD_PROP}"
done