添加特殊权限白名单
AndroidQ及其以上版本 , 当priv-app遇到特殊权限也会由于白名单问题导致开不了机, 举例如下:
01-01 00:00:10.084 1020 1020 E AndroidRuntime: *** FATAL EXCEPTION IN SYSTEM PROCESS: main
01-01 00:00:10.084 1020 1020 E AndroidRuntime: java.lang.IllegalStateException: Signature|privileged permissions not in privapp-permissions whitelist: {com.android.writeimei (/system/priv-app/WriteIMEIApp): android.permission.REBOOT}
01-01 00:00:10.084 1020 1020 E AndroidRuntime: at com.android.server.pm.permission.PermissionManagerService.systemReady(PermissionManagerService.java:4807)
01-01 00:00:10.084 1020 1020 E AndroidRuntime: at com.android.server.pm.permission.PermissionManagerService.access
500
(
P
e
r
m
i
s
s
i
o
n
M
a
n
a
g
e
r
S
e
r
v
i
c
e
.
j
a
v
a
:
182
)
01
−
0100
:
00
:
10.08410201020
E
A
n
d
r
o
i
d
R
u
n
t
i
m
e
:
a
t
c
o
m
.
a
n
d
r
o
i
d
.
s
e
r
v
e
r
.
p
m
.
p
e
r
m
i
s
s
i
o
n
.
P
e
r
m
i
s
s
i
o
n
M
a
n
a
g
e
r
S
e
r
v
i
c
e
500(PermissionManagerService.java:182) 01-01 00:00:10.084 1020 1020 E AndroidRuntime: at com.android.server.pm.permission.PermissionManagerService
500(PermissionManagerService.java:182)01−0100:00:10.08410201020EAndroidRuntime:atcom.android.server.pm.permission.PermissionManagerServicePermissionManagerServiceInternalImpl.systemReady(PermissionManagerService.java:4890)
这个报错中可以得到信息包名com.android.writeimei 作为priv-app 由于 android.permission.REBOOT这个特殊权限 导致白名单问题。
解决方案
方案一:
- frameworks/base/data/etc :
添加权限文件:com.android.writeimei.xml <?xml version="1.0" encoding="utf-8"?>
2)Android.bp添加编译申明
prebuilt_etc {
name: “privapp_whitelist_com.android.writeimei”,
system_ext_specific: true, //包名安装未知 system_extra
sub_dir: “permissions”,
src: “com.android.writeimei.xml”,
filename_from_src: true,
}
方案二:
直接修改privapp-permissions-platform.xml:
-
<privapp-permissions package="com.android.writeimei">
-
<permission name="android.permission.REBOOT"/>