AppOps 悬浮窗权限 ,获得 mode值
/**
* 悬浮窗权限 mode AppOpsManager
* @param ctx
* @return
* {@link AppOpsManager#MODE_ALLOWED} 0: 有权限;
* {@link AppOpsManager#MODE_IGNORED} 1: 无权限,但是不会引发crash;
* {@link AppOpsManager#MODE_ERRORED} 2: 无权限,会引发crash;
* {@link AppOpsManager#MODE_DEFAULT} 3: ;
*/
public static int opsSystemAlertWinMode(Context ctx) {
//系统小于6
if (SdkCheck.sdkLess6()) {
return 0;
}
String saw = "android:system_alert_window";
String op = AppOpsManagerCompat.permissionToOp(Manifest.permission.SYSTEM_ALERT_WINDOW);
L.d(TAG, "opsSystemAlertWinMode : op=" + op);
int mode = 0;
mode = AppOpsManagerCompat.noteProxyOpNoThrow(ctx,op,
ctx.getPackageName());
L.d(TAG, "opsSystemAlertWinMode : mode=" + mode);
return mode;
}