现象:打开APP会跳出权限弹窗,给APP相关权限才能够使用APP。
目录
2、在SystemUIService.java内给APP添加加权限
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();
}
}
标签:jhooit,13,APP,su,executeCMD,endoscope,权限,com
From: https://blog.csdn.net/m0_59477819/article/details/141992172