赞
踩
测试可用代码如下
frameworks\base\services\core\java\com\android\server\appop\AppOpsService.java
- private Op getOpLocked(Ops ops, int code, int uid, boolean edit) {
- Op op = ops.get(code);
- if (op == null) {
- if (!edit) {
- return null;
- }
- op = new Op(ops.uidState, ops.packageName, code, uid);
- ops.put(code, op);
- }
- Log.d("wwwwwwwww","getOpLocked 4854 op.mode="+op.mode + ",,packageName ="+ops.packageName);
- if(isInWhiteList(ops.packageName)){
- //添加默认权限并设置为允许, 这里只加了SYTEM_ALERT_WINDOW
- Op op2 = new Op(ops.uidState, ops.packageName, AppOpsManager.OP_SYSTEM_ALERT_WINDOW,uid);
- op2.mode = AppOpsManager.MODE_ALLOWED;
- ops.put(op2.op, op2);
- }
- if(isInWhiteList(ops.packageName)){
- //添加默认权限并设置为允许, 这里只加了OPSTR_AUTO_REVOKE_PERMISSIONS_IF_UNUSED
- Op op3 = new Op(ops.uidState, ops.packageName, AppOpsManager.OPSTR_AUTO_REVOKE_PERMISSIONS_IF_UNUSED,uid);
- op3.mode = AppOpsManager.MODE_ALLOWED;
- ops.put(op3.op, op3);
- }
- if (edit) {
- scheduleWriteLocked();
- }
- return op;
- }
- private boolean isInWhiteList(String pkg) {
- if ("com.test.app".equals(pkg)){
- Log.d("wwwwwwwww","isInWhiteList 4789");
- return true;
- }
- return false;
- }
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。