代码路径: frameworks/base/telephony/java/com/android/internal/telephony/TelephonyPermissions.java 在TelephonyPermissions.java文件中checkReadDeviceIdentifiers()方法中默认给应用授权
@VisibleForTesting
public static boolean checkReadDeviceIdentifiers(Context context,
Supplier<ITelephony> telephonySupplier, int subId, int pid, int uid,
String callingPackage, String message) {
final int appId = UserHandle.getAppId(uid);
if (appId == Process.SYSTEM_UID || appId == Process.ROOT_UID) {
return true;
}
if (context.checkPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE, pid,
uid) == PackageManager.PERMISSION_GRANTED||("包名".equals(callingPackage))) {
return true;
}
if (checkCarrierPrivilegeForAnySubId(context, telephonySupplier, uid)) {
return true;
}
if (callingPackage != null) {
long token = Binder.clearCallingIdentity();
AppOpsManager appOpsManager = (AppOpsManager) context.getSystemService(
Context.APP_OPS_SERVICE);
try {
if (appOpsManager.noteOpNoThrow(AppOpsManager.OPSTR_READ_DEVICE_IDENTIFIERS, uid,
callingPackage) == AppOpsManager.MODE_ALLOWED) {
return true;
}
} finally {
Binder.restoreCallingIdentity(token);
}
DevicePolicyManager devicePolicyManager =
(DevicePolicyManager) context.getSystemService(
Context.DEVICE_POLICY_SERVICE);
if (devicePolicyManager != null && devicePolicyManager.checkDeviceIdentifierAccess(
callingPackage, pid, uid)) {
return true;
}
}
return reportAccessDeniedToReadIdentifiers(context, subId, pid, uid, callingPackage,
message);
}
|