-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathservice.sh
73 lines (68 loc) · 2.37 KB
/
service.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
#!/system/bin/sh
until [[ -z $(dumpsys window policy | grep mInputRestricted | grep true) ]]; do
sleep 2
done
##设置环境变量##
export DIR="${0%/*}"
export PATH="${DIR}/busybox/bin:${PATH}"
export version='v6.1'
export versionCode='202209041'
export inform="ASGuard ${version}(${versionCode}) created by 沍澤"
export CONFIG="/data/media/0/Android/ASGuard.conf"
export LOG_PATH="/data/media/0/Android/log_ASG.txt"
export PROP="${DIR}/module.prop"
export description="一个无障碍功能管理模块.在\"获取root权限\"的APP完全替代\"一般使用无障碍权限\"的APP前的Msgiask模块的不错选择."
export AS exAS EAS EAST package_whitelist CTime log clean mode exclude MODPATH LastConf WhitelistCleaner
for var in $(ls "${DIR}/busybox/bin"); do
chmod 111 "${DIR}/busybox/bin/${var}"
chown 'root:root' "${DIR}/busybox/bin/${var}"
done
source "${DIR}/config/Function.sh"
if [[ $? != 0 ]]; then
change_prop "错误" "Function.sh加载失败"
exit 1 > "${LOG_PATH}"
fi
##读取配置后记录文件信息,当文件信息产生改动重新读取##
load_config
LastConf="$(ls -l "${CONFIG%/*}/" | grep "${CONFIG##*/}")"
if [[ ${log=1} -ne 0 ]]; then
echo "${inform}" > "${LOG_PATH}"
echo "运行日期:$(date '+%Y.%m.%d %X')" >> "${LOG_PATH}"
else
[[ -f "${LOG_PATH}" ]] && rm -rf "${LOG_PATH}" >/dev/null 2>&1
fi
##电池优化白名单操作##
startWhitelistClean "${AS} ${package_whitelist}" &
mylog "${AS} ${package_whitelist}" "Whitelist"
##匹配AS的无障碍开关##
EAS="$(getService "${AS:-}")"
##删去排除名单##
for var in $(echo ${exclude}); do
EAS="$(echo "${EAS}" | grep -v "${var}")"
done
mylog "${exclude}" "过滤开关"
##判断是否清空已开启的无障碍##
if [[ ${clean} == 1 ]]; then
write_EAST -c
fi
##选择加载文件路径##
case "${mode:-A}" in
R) file="${DIR}/config/Refresh.sh" ;;
F) file="${DIR}/config/Focus.sh" ;;
M) file="${DIR}/config/Monitor.sh" ;;
*) file="${DIR}/config/Auto.sh" ;;
esac
if [[ ! -f "${file}" ]]; then
mylog "\"${file}\"文件丢失"
change_prop "加载失败" "${file}文件丢失"
exit 2 > "${LOG_PATH}"
fi
cp -f "${file}" "${DIR}/ASGuard_Process.sh"
chmod 111 "${DIR}/ASGuard_Process.sh"
chown 'root:root' "${DIR}/ASGuard_Process.sh"
settings put secure accessibility_enabled 1
while [[ "$(ps -ef | grep 'ASGuard_Process' | grep -v grep | wc -l)" == "0" ]]; do
nohup sh "${DIR}/ASGuard_Process.sh" &
sleep 2
done
exit