in NetworkStatsAccess.checkAccessLevel, check SYSTEM_UID ahead
to avoid possible deadlock from following DevicePolicyManager.isDeviceOwnerApp move SYSTEM_UID checking ahead. Change-Id: I182cadb175ca5028b6fe8e7f6316dcd349e32573
This commit is contained in:
parent
91d6cf8686
commit
8fe5189801
1 changed files with 9 additions and 6 deletions
|
|
@ -111,6 +111,12 @@ public final class NetworkStatsAccess {
|
|||
/** Returns the {@link NetworkStatsAccess.Level} for the given caller. */
|
||||
public static @NetworkStatsAccess.Level int checkAccessLevel(
|
||||
Context context, int callingPid, int callingUid, @Nullable String callingPackage) {
|
||||
final int appId = UserHandle.getAppId(callingUid);
|
||||
if (appId == Process.SYSTEM_UID) {
|
||||
// the system can access data usage for all apps on the device.
|
||||
// check system uid first, to avoid possible dead lock from other APIs
|
||||
return NetworkStatsAccess.Level.DEVICE;
|
||||
}
|
||||
final DevicePolicyManager mDpm = context.getSystemService(DevicePolicyManager.class);
|
||||
final TelephonyManager tm = (TelephonyManager)
|
||||
context.getSystemService(Context.TELEPHONY_SERVICE);
|
||||
|
|
@ -126,16 +132,13 @@ public final class NetworkStatsAccess {
|
|||
Binder.restoreCallingIdentity(token);
|
||||
}
|
||||
|
||||
final int appId = UserHandle.getAppId(callingUid);
|
||||
|
||||
final boolean isNetworkStack = PermissionUtils.hasAnyPermissionOf(
|
||||
context, callingPid, callingUid, android.Manifest.permission.NETWORK_STACK,
|
||||
NetworkStack.PERMISSION_MAINLINE_NETWORK_STACK);
|
||||
|
||||
if (hasCarrierPrivileges || isDeviceOwner
|
||||
|| appId == Process.SYSTEM_UID || isNetworkStack) {
|
||||
// Carrier-privileged apps and device owners, and the system (including the
|
||||
// network stack) can access data usage for all apps on the device.
|
||||
if (hasCarrierPrivileges || isDeviceOwner || isNetworkStack) {
|
||||
// Carrier-privileged apps and device owners, and the network stack
|
||||
// can access data usage for all apps on the device.
|
||||
return NetworkStatsAccess.Level.DEVICE;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue