Loading core/java/android/app/admin/DevicePolicyManager.java +26 −2 Original line number Diff line number Diff line Loading @@ -8261,7 +8261,7 @@ public class DevicePolicyManager { } /** * Called by a device or profile owner to restrict packages from accessing metered data. * Called by a device or profile owner to restrict packages from using metered data. * * @param admin which {@link DeviceAdminReceiver} this request is associated with. * @param packageNames the list of package names to be restricted. Loading @@ -8283,7 +8283,7 @@ public class DevicePolicyManager { /** * Called by a device or profile owner to retrieve the list of packages which are restricted * by the admin from accessing metered data. * by the admin from using metered data. * * @param admin which {@link DeviceAdminReceiver} this request is associated with. * @return the list of restricted package names. Loading @@ -8301,6 +8301,30 @@ public class DevicePolicyManager { return new ArrayList<>(); } /** * Called by the system to check if a package is restricted from using metered data * by {@param admin}. * * @param admin which {@link DeviceAdminReceiver} this request is associated with. * @param packageName the package whose restricted status is needed. * @param userId the user to which {@param packageName} belongs. * @return {@code true} if the package is restricted by admin, otherwise {@code false} * @throws SecurityException if the caller doesn't run with {@link Process#SYSTEM_UID} * @hide */ public boolean isMeteredDataDisabledForUser(@NonNull ComponentName admin, String packageName, @UserIdInt int userId) { throwIfParentInstance("getMeteredDataDisabledForUser"); if (mService != null) { try { return mService.isMeteredDataDisabledForUser(admin, packageName, userId); } catch (RemoteException re) { throw re.rethrowFromSystemServer(); } } return false; } /** * Called by device owners to retrieve device logs from before the device's last reboot. * <p> Loading core/java/android/app/admin/IDevicePolicyManager.aidl +2 −0 Original line number Diff line number Diff line Loading @@ -413,4 +413,6 @@ interface IDevicePolicyManager { List<ApnSetting> getOverrideApns(in ComponentName admin); void setOverrideApnsEnabled(in ComponentName admin, boolean enabled); boolean isOverrideApnEnabled(in ComponentName admin); boolean isMeteredDataDisabledForUser(in ComponentName admin, String packageName, int userId); } packages/SettingsLib/src/com/android/settingslib/RestrictedLockUtils.java +20 −0 Original line number Diff line number Diff line Loading @@ -362,6 +362,26 @@ public class RestrictedLockUtils { return getProfileOrDeviceOwner(context, userId); } /** * Check if {@param packageName} is restricted by the profile or device owner from using * metered data. * * @return EnforcedAdmin object containing the enforced admin component and admin user details, * or {@code null} if the {@param packageName} is not restricted. */ public static EnforcedAdmin checkIfMeteredDataRestricted(Context context, String packageName, int userId) { final EnforcedAdmin enforcedAdmin = getProfileOrDeviceOwner(context, userId); if (enforcedAdmin == null) { return null; } final DevicePolicyManager dpm = (DevicePolicyManager) context.getSystemService( Context.DEVICE_POLICY_SERVICE); return dpm.isMeteredDataDisabledForUser(enforcedAdmin.component, packageName, userId) ? enforcedAdmin : null; } /** * Checks if {@link android.app.admin.DevicePolicyManager#setAutoTimeRequired} is enforced * on the device. Loading packages/SettingsLib/src/com/android/settingslib/applications/ApplicationsState.java +3 −1 Original line number Diff line number Diff line Loading @@ -48,6 +48,7 @@ import android.os.RemoteException; import android.os.SystemClock; import android.os.UserHandle; import android.os.UserManager; import android.support.annotation.VisibleForTesting; import android.text.format.Formatter; import android.util.IconDrawableFactory; import android.util.Log; Loading Loading @@ -1282,7 +1283,8 @@ public class ApplicationsState { // A location where extra info can be placed to be used by custom filters. public Object extraInfo; AppEntry(Context context, ApplicationInfo info, long id) { @VisibleForTesting(otherwise = VisibleForTesting.PACKAGE_PRIVATE) public AppEntry(Context context, ApplicationInfo info, long id) { apkFile = new File(info.sourceDir); this.id = id; this.info = info; Loading services/devicepolicy/java/com/android/server/devicepolicy/BaseIDevicePolicyManager.java +6 −0 Original line number Diff line number Diff line Loading @@ -178,4 +178,10 @@ abstract class BaseIDevicePolicyManager extends IDevicePolicyManager.Stub { public void clearSystemUpdatePolicyFreezePeriodRecord() { } @Override public boolean isMeteredDataDisabledForUser(ComponentName admin, String packageName, int userId) { return false; } } Loading
core/java/android/app/admin/DevicePolicyManager.java +26 −2 Original line number Diff line number Diff line Loading @@ -8261,7 +8261,7 @@ public class DevicePolicyManager { } /** * Called by a device or profile owner to restrict packages from accessing metered data. * Called by a device or profile owner to restrict packages from using metered data. * * @param admin which {@link DeviceAdminReceiver} this request is associated with. * @param packageNames the list of package names to be restricted. Loading @@ -8283,7 +8283,7 @@ public class DevicePolicyManager { /** * Called by a device or profile owner to retrieve the list of packages which are restricted * by the admin from accessing metered data. * by the admin from using metered data. * * @param admin which {@link DeviceAdminReceiver} this request is associated with. * @return the list of restricted package names. Loading @@ -8301,6 +8301,30 @@ public class DevicePolicyManager { return new ArrayList<>(); } /** * Called by the system to check if a package is restricted from using metered data * by {@param admin}. * * @param admin which {@link DeviceAdminReceiver} this request is associated with. * @param packageName the package whose restricted status is needed. * @param userId the user to which {@param packageName} belongs. * @return {@code true} if the package is restricted by admin, otherwise {@code false} * @throws SecurityException if the caller doesn't run with {@link Process#SYSTEM_UID} * @hide */ public boolean isMeteredDataDisabledForUser(@NonNull ComponentName admin, String packageName, @UserIdInt int userId) { throwIfParentInstance("getMeteredDataDisabledForUser"); if (mService != null) { try { return mService.isMeteredDataDisabledForUser(admin, packageName, userId); } catch (RemoteException re) { throw re.rethrowFromSystemServer(); } } return false; } /** * Called by device owners to retrieve device logs from before the device's last reboot. * <p> Loading
core/java/android/app/admin/IDevicePolicyManager.aidl +2 −0 Original line number Diff line number Diff line Loading @@ -413,4 +413,6 @@ interface IDevicePolicyManager { List<ApnSetting> getOverrideApns(in ComponentName admin); void setOverrideApnsEnabled(in ComponentName admin, boolean enabled); boolean isOverrideApnEnabled(in ComponentName admin); boolean isMeteredDataDisabledForUser(in ComponentName admin, String packageName, int userId); }
packages/SettingsLib/src/com/android/settingslib/RestrictedLockUtils.java +20 −0 Original line number Diff line number Diff line Loading @@ -362,6 +362,26 @@ public class RestrictedLockUtils { return getProfileOrDeviceOwner(context, userId); } /** * Check if {@param packageName} is restricted by the profile or device owner from using * metered data. * * @return EnforcedAdmin object containing the enforced admin component and admin user details, * or {@code null} if the {@param packageName} is not restricted. */ public static EnforcedAdmin checkIfMeteredDataRestricted(Context context, String packageName, int userId) { final EnforcedAdmin enforcedAdmin = getProfileOrDeviceOwner(context, userId); if (enforcedAdmin == null) { return null; } final DevicePolicyManager dpm = (DevicePolicyManager) context.getSystemService( Context.DEVICE_POLICY_SERVICE); return dpm.isMeteredDataDisabledForUser(enforcedAdmin.component, packageName, userId) ? enforcedAdmin : null; } /** * Checks if {@link android.app.admin.DevicePolicyManager#setAutoTimeRequired} is enforced * on the device. Loading
packages/SettingsLib/src/com/android/settingslib/applications/ApplicationsState.java +3 −1 Original line number Diff line number Diff line Loading @@ -48,6 +48,7 @@ import android.os.RemoteException; import android.os.SystemClock; import android.os.UserHandle; import android.os.UserManager; import android.support.annotation.VisibleForTesting; import android.text.format.Formatter; import android.util.IconDrawableFactory; import android.util.Log; Loading Loading @@ -1282,7 +1283,8 @@ public class ApplicationsState { // A location where extra info can be placed to be used by custom filters. public Object extraInfo; AppEntry(Context context, ApplicationInfo info, long id) { @VisibleForTesting(otherwise = VisibleForTesting.PACKAGE_PRIVATE) public AppEntry(Context context, ApplicationInfo info, long id) { apkFile = new File(info.sourceDir); this.id = id; this.info = info; Loading
services/devicepolicy/java/com/android/server/devicepolicy/BaseIDevicePolicyManager.java +6 −0 Original line number Diff line number Diff line Loading @@ -178,4 +178,10 @@ abstract class BaseIDevicePolicyManager extends IDevicePolicyManager.Stub { public void clearSystemUpdatePolicyFreezePeriodRecord() { } @Override public boolean isMeteredDataDisabledForUser(ComponentName admin, String packageName, int userId) { return false; } }