// We have READ_PHONE_STATE permission, so return true as long as the AppOps bit hasn't been
// revoked.
AppOpsManager appOps = (AppOpsManager) context.getSystemService(Context.APP_OPS_SERVICE);
- return appOps.noteOp(AppOpsManager.OP_READ_PHONE_STATE, uid, callingPackage)
+ return appOps.noteOp(AppOpsManager.OPSTR_READ_PHONE_STATE, uid, callingPackage)
== AppOpsManager.MODE_ALLOWED;
}
// We have READ_PHONE_STATE permission, so return true as long as the AppOps bit hasn't been
// revoked.
AppOpsManager appOps = (AppOpsManager) context.getSystemService(Context.APP_OPS_SERVICE);
- return appOps.noteOp(AppOpsManager.OP_READ_PHONE_STATE, uid, callingPackage) ==
+ return appOps.noteOp(AppOpsManager.OPSTR_READ_PHONE_STATE, uid, callingPackage) ==
AppOpsManager.MODE_ALLOWED;
}
// We have READ_CALL_LOG permission, so return true as long as the AppOps bit hasn't been
// revoked.
AppOpsManager appOps = (AppOpsManager) context.getSystemService(Context.APP_OPS_SERVICE);
- return appOps.noteOp(AppOpsManager.OP_READ_CALL_LOG, uid, callingPackage) ==
+ return appOps.noteOp(AppOpsManager.OPSTR_READ_CALL_LOG, uid, callingPackage) ==
AppOpsManager.MODE_ALLOWED;
}
String callingPackage, String message) {
// Default SMS app can always read it.
AppOpsManager appOps = (AppOpsManager) context.getSystemService(Context.APP_OPS_SERVICE);
- if (appOps.noteOp(AppOpsManager.OP_WRITE_SMS, uid, callingPackage) ==
+ if (appOps.noteOp(AppOpsManager.OPSTR_WRITE_SMS, uid, callingPackage) ==
AppOpsManager.MODE_ALLOWED) {
return true;
}
// Can be read with READ_SMS too.
try {
context.enforcePermission(android.Manifest.permission.READ_SMS, pid, uid, message);
- int opCode = AppOpsManager.permissionToOpCode(android.Manifest.permission.READ_SMS);
- if (opCode != AppOpsManager.OP_NONE) {
- return appOps.noteOp(opCode, uid, callingPackage) == AppOpsManager.MODE_ALLOWED;
- } else {
- return true;
- }
+ return appOps.noteOp(AppOpsManager.OPSTR_READ_SMS, uid, callingPackage)
+ == AppOpsManager.MODE_ALLOWED;
+
} catch (SecurityException readSmsSecurityException) {
}
// Can be read with READ_PHONE_NUMBERS too.
try {
context.enforcePermission(android.Manifest.permission.READ_PHONE_NUMBERS, pid, uid,
message);
- int opCode = AppOpsManager.permissionToOpCode(
- android.Manifest.permission.READ_PHONE_NUMBERS);
- if (opCode != AppOpsManager.OP_NONE) {
- return appOps.noteOp(opCode, uid, callingPackage) == AppOpsManager.MODE_ALLOWED;
- } else {
- return true;
- }
+ return appOps.noteOp(AppOpsManager.OPSTR_READ_PHONE_NUMBERS, uid, callingPackage)
+ == AppOpsManager.MODE_ALLOWED;
+
} catch (SecurityException readPhoneNumberSecurityException) {
}