@
cybermonster @
honeycomb [到时候会出现不让你管理,否则不给用微信的情况]
-----------------------------------------------------
App 可以检测到 op RUN_IN_BACKGROUND 是否被 ignore / deny.
final int OP_RUN_IN_BACKGROUND = 63;
int mode = (int) AppOpsManager.class
.getMethod("checkOp",
int.class,
int.class,
String.class)
.invoke(getSystemService(AppOpsManager.class),
OP_RUN_IN_BACKGROUND,
Binder.getCallingUid(),
getPackageName());
System.out.println(mode);
targetSdkVersion 23 的 Legacy 应用, 上面的代码安装上时返回 0 (MODE_ALLOWED), adb 设为 ignore 后返回 1 (MODE_IGNORED), 设为 deny 后抛出 java.lang.SecurityException: com.company.test from uid 10172 not allowed to perform RUN_IN_BACKGROUND.