rk3566 rk3588 Android11/13 给内置APP添加相关权限,无需手动同意APP权限

现象:打开APP会跳出权限弹窗,给APP相关权限才能够使用APP。

目录

1、adb查看logcat

2、在SystemUIService.java内给APP添加加权限

3、开机自启动APP

4、executeCMD函数


1、adb查看logcat

打开APP,logcat会打印APP包名。我这边包名是com.jhooit.endoscope

2、在SystemUIService.java内给APP添加加权限

保证程序在启动过程中就给APP足够的权限

rk3566_r:/ $ pm dump com.jhooit.endoscope | grep permission //这个adb指令可以查看所需的权限,也可以直接把权限给满,这下面给的权限基本可以满足所有APP。

3566_Android11\sdk\frameworks\base\packages\SystemUI\src\com\android\systemui SystemUIService.java  

executeCMD("su","appops set com.jhooit.endoscope WRITE_SETTINGS allow");
executeCMD("su","appops set com.jhooit.endoscope SYSTEM_ALERT_WINDOW allow");
executeCMD("su","appops set com.jhooit.endoscope MANAGE_EXTERNAL_STORAGE allow");
executeCMD("su","pm grant com.jhooit.endoscope android.permission.CAMERA");
executeCMD("su","pm grant com.jhooit.endoscope android.permission.READ_PHONE_STATE");
executeCMD("su","pm grant com.jhooit.endoscope android.permission.WRITE_MEDIA_STORAGE");
executeCMD("su","pm grant com.jhooit.endoscope android.permission.ACCESS_FINE_LOCATION");
executeCMD("su","pm grant com.jhooit.endoscope android.permission.RECORD_AUDIO");
executeCMD("su","pm grant com.jhooit.endoscope android.permission.CALL_PHONE");
executeCMD("su","pm grant com.jhooit.endoscope android.permission.GET_ACCOUNTS");
executeCMD("su","pm grant com.jhooit.endoscope android.permission.READ_EXTERNAL_STORAGE");
executeCMD("su","pm grant com.jhooit.endoscope android.permission.WRITE_EXTERNAL_STORAGE");
executeCMD("su","pm grant com.jhooit.endoscope android.permission.READ_MEDIA_AUDIO");
executeCMD("su","pm grant com.jhooit.endoscope android.permission.READ_MEDIA_VIDEO");
executeCMD("su","pm grant com.jhooit.endoscope android.permission.READ_MEDIA_IMAGES");

3、开机自启动APP

需要开机自启动的APP 在SystemUIService.java  函数内加入

executeCMD("su","am start -n com.jhooit.endoscope/com.jhooit.endoscope.ui.MainActivity");

4、executeCMD函数

public void executeCMD(String cmd, String cmd1){
				try {
						Runtime runtime = Runtime.getRuntime();
						java.lang.Process process = runtime.exec(cmd);
						DataOutputStream os = new DataOutputStream(process.getOutputStream());
						os.writeBytes(cmd1+"\n");
						os.writeBytes("exit\n");
						os.flush();
						} catch (IOException e) {
						e.printStackTrace();
				}
		}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值