val mAppOps = context.getSystemService(Context.APP_OPS_SERVICE) as AppOpsManager val appInfo = context.applicationInfo val pkg = context.applicationContext.packageName val uid = appInfo.uid
val appOpsClass: Class<*>? /* Context.APP_OPS_MANAGER */
try { appOpsClass = Class.forName(AppOpsManager::class.java.name) val checkOpNoThrowMethod = appOpsClass!!.getMethod(CHECK_OP_NO_THROW, Integer.TYPE, Integer.TYPE, String::class.java) val opPostNotificationValue = appOpsClass.getDeclaredField(OP_POST_NOTIFICATION) val value = opPostNotificationValue.get(Int::class.java) asInt