Merge "[DU02]Remove DevicePolicyManagerInternal from NetworkStatsAccess" am: 00827ef1db
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1930817 Change-Id: I16ab25212da3d05e5c0f6ff47b6769c35e13722c
This commit is contained in:
@@ -24,7 +24,7 @@ import static android.net.TrafficStats.UID_TETHERING;
|
|||||||
import android.Manifest;
|
import android.Manifest;
|
||||||
import android.annotation.IntDef;
|
import android.annotation.IntDef;
|
||||||
import android.app.AppOpsManager;
|
import android.app.AppOpsManager;
|
||||||
import android.app.admin.DevicePolicyManagerInternal;
|
import android.app.admin.DevicePolicyManager;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
import android.os.Binder;
|
import android.os.Binder;
|
||||||
@@ -32,8 +32,6 @@ import android.os.Process;
|
|||||||
import android.os.UserHandle;
|
import android.os.UserHandle;
|
||||||
import android.telephony.TelephonyManager;
|
import android.telephony.TelephonyManager;
|
||||||
|
|
||||||
import com.android.server.LocalServices;
|
|
||||||
|
|
||||||
import java.lang.annotation.Retention;
|
import java.lang.annotation.Retention;
|
||||||
import java.lang.annotation.RetentionPolicy;
|
import java.lang.annotation.RetentionPolicy;
|
||||||
|
|
||||||
@@ -109,8 +107,7 @@ public final class NetworkStatsAccess {
|
|||||||
/** Returns the {@link NetworkStatsAccess.Level} for the given caller. */
|
/** Returns the {@link NetworkStatsAccess.Level} for the given caller. */
|
||||||
public static @NetworkStatsAccess.Level int checkAccessLevel(
|
public static @NetworkStatsAccess.Level int checkAccessLevel(
|
||||||
Context context, int callingUid, String callingPackage) {
|
Context context, int callingUid, String callingPackage) {
|
||||||
final DevicePolicyManagerInternal dpmi = LocalServices.getService(
|
final DevicePolicyManager mDpm = context.getSystemService(DevicePolicyManager.class);
|
||||||
DevicePolicyManagerInternal.class);
|
|
||||||
final TelephonyManager tm = (TelephonyManager)
|
final TelephonyManager tm = (TelephonyManager)
|
||||||
context.getSystemService(Context.TELEPHONY_SERVICE);
|
context.getSystemService(Context.TELEPHONY_SERVICE);
|
||||||
boolean hasCarrierPrivileges;
|
boolean hasCarrierPrivileges;
|
||||||
@@ -123,8 +120,9 @@ public final class NetworkStatsAccess {
|
|||||||
Binder.restoreCallingIdentity(token);
|
Binder.restoreCallingIdentity(token);
|
||||||
}
|
}
|
||||||
|
|
||||||
final boolean isDeviceOwner = dpmi != null && dpmi.isActiveDeviceOwner(callingUid);
|
final boolean isDeviceOwner = mDpm != null && mDpm.isDeviceOwnerApp(callingPackage);
|
||||||
final int appId = UserHandle.getAppId(callingUid);
|
final int appId = UserHandle.getAppId(callingUid);
|
||||||
|
|
||||||
if (hasCarrierPrivileges || isDeviceOwner
|
if (hasCarrierPrivileges || isDeviceOwner
|
||||||
|| appId == Process.SYSTEM_UID || appId == Process.NETWORK_STACK_UID) {
|
|| appId == Process.SYSTEM_UID || appId == Process.NETWORK_STACK_UID) {
|
||||||
// Carrier-privileged apps and device owners, and the system (including the
|
// Carrier-privileged apps and device owners, and the system (including the
|
||||||
@@ -139,8 +137,8 @@ public final class NetworkStatsAccess {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//TODO(b/169395065) Figure out if this flow makes sense in Device Owner mode.
|
//TODO(b/169395065) Figure out if this flow makes sense in Device Owner mode.
|
||||||
boolean isProfileOwner = dpmi != null && (dpmi.isActiveProfileOwner(callingUid)
|
boolean isProfileOwner = mDpm != null && (mDpm.isProfileOwnerApp(callingPackage)
|
||||||
|| dpmi.isActiveDeviceOwner(callingUid));
|
|| mDpm.isDeviceOwnerApp(callingPackage));
|
||||||
if (isProfileOwner) {
|
if (isProfileOwner) {
|
||||||
// Apps with the AppOps permission, profile owners, and apps with the privileged
|
// Apps with the AppOps permission, profile owners, and apps with the privileged
|
||||||
// permission can access data usage for all apps in this user/profile.
|
// permission can access data usage for all apps in this user/profile.
|
||||||
|
|||||||
Reference in New Issue
Block a user