-
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathservice.sh
107 lines (90 loc) · 2.65 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
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
MODPATH=${0%/*}
# log
exec 2>$MODPATH/debug.log
set -x
# var
API=`getprop ro.build.version.sdk`
# property
resetprop -n ro.gallery.device cepheus
resetprop -n ro.product.miui.gallery Xiaomi
# wait
until [ "`getprop sys.boot_completed`" == 1 ]; do
sleep 10
done
# list
PKGS="`cat $MODPATH/package.txt`
com.miui.gallery:photo_editor
com.miui.gallery:widgetProvider
com.miui.gallery:remote
com.miui.gallery:pushservice"
for PKG in $PKGS; do
magisk --denylist rm $PKG 2>/dev/null
magisk --sulist add $PKG 2>/dev/null
done
if magisk magiskhide sulist; then
for PKG in $PKGS; do
magisk magiskhide add $PKG
done
else
for PKG in $PKGS; do
magisk magiskhide rm $PKG
done
fi
# function
grant_permission() {
pm grant $PKG android.permission.READ_EXTERNAL_STORAGE
pm grant $PKG android.permission.WRITE_EXTERNAL_STORAGE
if [ "$API" -ge 29 ]; then
pm grant $PKG android.permission.ACCESS_MEDIA_LOCATION 2>/dev/null
appops set $PKG ACCESS_MEDIA_LOCATION allow
fi
if [ "$API" -ge 33 ]; then
pm grant $PKG android.permission.READ_MEDIA_AUDIO
pm grant $PKG android.permission.READ_MEDIA_VIDEO
pm grant $PKG android.permission.READ_MEDIA_IMAGES
appops set $PKG ACCESS_RESTRICTED_SETTINGS allow
fi
appops set $PKG LEGACY_STORAGE allow
appops set $PKG READ_EXTERNAL_STORAGE allow
appops set $PKG WRITE_EXTERNAL_STORAGE allow
appops set $PKG READ_MEDIA_AUDIO allow
appops set $PKG READ_MEDIA_VIDEO allow
appops set $PKG READ_MEDIA_IMAGES allow
appops set $PKG WRITE_MEDIA_AUDIO allow
appops set $PKG WRITE_MEDIA_VIDEO allow
appops set $PKG WRITE_MEDIA_IMAGES allow
if [ "$API" -ge 30 ]; then
appops set $PKG MANAGE_EXTERNAL_STORAGE allow
appops set $PKG NO_ISOLATED_STORAGE allow
appops set $PKG AUTO_REVOKE_PERMISSIONS_IF_UNUSED ignore
fi
if [ "$API" -ge 31 ]; then
appops set $PKG MANAGE_MEDIA allow
fi
if [ "$API" -ge 34 ]; then
appops set $PKG READ_MEDIA_VISUAL_USER_SELECTED allow
fi
PKGOPS=`appops get $PKG`
UID=`dumpsys package $PKG 2>/dev/null | grep -m 1 Id= | sed -e 's| userId=||g' -e 's| appId=||g'`
if [ "$UID" ] && [ "$UID" -gt 9999 ]; then
appops set --uid "$UID" LEGACY_STORAGE allow
appops set --uid "$UID" READ_EXTERNAL_STORAGE allow
appops set --uid "$UID" WRITE_EXTERNAL_STORAGE allow
if [ "$API" -ge 29 ]; then
appops set --uid "$UID" ACCESS_MEDIA_LOCATION allow
fi
if [ "$API" -ge 34 ]; then
appops set --uid "$UID" READ_MEDIA_VISUAL_USER_SELECTED allow
fi
UIDOPS=`appops get --uid "$UID"`
fi
}
# grant
PKG=com.miui.gallery
appops set $PKG SYSTEM_ALERT_WINDOW allow
grant_permission
# grant
PKG=cn.wps.moffice_eng.xiaomi.lite
if appops get $PKG > /dev/null 2>&1; then
grant_permission
fi