Loading api/current.txt +2 −0 Original line number Diff line number Diff line Loading @@ -6420,6 +6420,7 @@ package android.app.admin { method public android.content.ComponentName getMandatoryBackupTransport(); method public int getMaximumFailedPasswordsForWipe(android.content.ComponentName); method public long getMaximumTimeToLock(android.content.ComponentName); method public java.util.List<java.lang.String> getMeteredDataDisabled(android.content.ComponentName); method public int getOrganizationColor(android.content.ComponentName); method public java.lang.CharSequence getOrganizationName(android.content.ComponentName); method public android.app.admin.DevicePolicyManager getParentProfileInstance(android.content.ComponentName); Loading Loading @@ -6524,6 +6525,7 @@ package android.app.admin { method public void setMasterVolumeMuted(android.content.ComponentName, boolean); method public void setMaximumFailedPasswordsForWipe(android.content.ComponentName, int); method public void setMaximumTimeToLock(android.content.ComponentName, long); method public java.util.List<java.lang.String> setMeteredDataDisabled(android.content.ComponentName, java.util.List<java.lang.String>); method public void setNetworkLoggingEnabled(android.content.ComponentName, boolean); method public void setOrganizationColor(android.content.ComponentName, int); method public void setOrganizationName(android.content.ComponentName, java.lang.CharSequence); core/java/android/app/admin/DevicePolicyManager.java +41 −0 Original line number Diff line number Diff line Loading @@ -8227,6 +8227,47 @@ public class DevicePolicyManager { return new DevicePolicyManager(mContext, mService, true); } /** * Called by a device or profile owner to restrict packages from accessing metered data. * * @param admin which {@link DeviceAdminReceiver} this request is associated with. * @param packageNames the list of package names to be restricted. * @return a list of package names which could not be restricted. * @throws SecurityException if {@code admin} is not a device or profile owner. */ public @NonNull List<String> setMeteredDataDisabled(@NonNull ComponentName admin, @NonNull List<String> packageNames) { throwIfParentInstance("setMeteredDataDisabled"); if (mService != null) { try { return mService.setMeteredDataDisabled(admin, packageNames); } catch (RemoteException re) { throw re.rethrowFromSystemServer(); } } return packageNames; } /** * Called by a device or profile owner to retrieve the list of packages which are restricted * by the admin from accessing metered data. * * @param admin which {@link DeviceAdminReceiver} this request is associated with. * @return the list of restricted package names. * @throws SecurityException if {@code admin} is not a device or profile owner. */ public @NonNull List<String> getMeteredDataDisabled(@NonNull ComponentName admin) { throwIfParentInstance("getMeteredDataDisabled"); if (mService != null) { try { return mService.getMeteredDataDisabled(admin); } catch (RemoteException re) { throw re.rethrowFromSystemServer(); } } return new ArrayList<>(); } /** * Called by device owners to retrieve device logs from before the device's last reboot. * <p> Loading core/java/android/app/admin/IDevicePolicyManager.aidl +3 −0 Original line number Diff line number Diff line Loading @@ -400,4 +400,7 @@ interface IDevicePolicyManager { void setPrintingEnabled(in ComponentName admin, boolean enabled); boolean isPrintingEnabled(); CharSequence getPrintingDisabledReason(); List<String> setMeteredDataDisabled(in ComponentName admin, in List<String> packageNames); List<String> getMeteredDataDisabled(in ComponentName admin); } services/core/java/com/android/server/net/NetworkPolicyLogger.java +10 −0 Original line number Diff line number Diff line Loading @@ -37,6 +37,7 @@ import com.android.server.am.ProcessList; import java.text.SimpleDateFormat; import java.util.Arrays; import java.util.Date; import java.util.Set; public class NetworkPolicyLogger { static final String TAG = "NetworkPolicy"; Loading @@ -62,6 +63,7 @@ public class NetworkPolicyLogger { private static final int EVENT_TEMP_POWER_SAVE_WL_CHANGED = 10; private static final int EVENT_UID_FIREWALL_RULE_CHANGED = 11; private static final int EVENT_FIREWALL_CHAIN_ENABLED = 12; private static final int EVENT_UPDATE_METERED_RESTRICTED_PKGS = 13; static final int NTWK_BLOCKED_POWER = 0; static final int NTWK_ALLOWED_NON_METERED = 1; Loading Loading @@ -179,6 +181,14 @@ public class NetworkPolicyLogger { } } void meteredRestrictedPkgsChanged(Set<Integer> restrictedUids) { synchronized (mLock) { final String log = "Metered restricted uids: " + restrictedUids; if (LOGD) Slog.d(TAG, log); mEventsBuffer.event(log); } } void dumpLogs(IndentingPrintWriter pw) { synchronized (mLock) { pw.println(); Loading services/core/java/com/android/server/net/NetworkPolicyManagerInternal.java +19 −0 Original line number Diff line number Diff line Loading @@ -19,6 +19,8 @@ package com.android.server.net; import android.net.Network; import android.telephony.SubscriptionPlan; import java.util.Set; /** * Network Policy Manager local system service interface. * Loading Loading @@ -71,4 +73,21 @@ public abstract class NetworkPolicyManagerInternal { * Informs that admin data is loaded and available. */ public abstract void onAdminDataAvailable(); /** * Sets a list of packages which are restricted by admin from accessing metered data. * * @param packageNames the list of restricted packages. * @param userId the userId in which {@param packagesNames} are restricted. */ public abstract void setMeteredRestrictedPackages( Set<String> packageNames, int userId); /** * Similar to {@link #setMeteredRestrictedPackages(Set, int)} but updates the restricted * packages list asynchronously. */ public abstract void setMeteredRestrictedPackagesAsync( Set<String> packageNames, int userId); } Loading
api/current.txt +2 −0 Original line number Diff line number Diff line Loading @@ -6420,6 +6420,7 @@ package android.app.admin { method public android.content.ComponentName getMandatoryBackupTransport(); method public int getMaximumFailedPasswordsForWipe(android.content.ComponentName); method public long getMaximumTimeToLock(android.content.ComponentName); method public java.util.List<java.lang.String> getMeteredDataDisabled(android.content.ComponentName); method public int getOrganizationColor(android.content.ComponentName); method public java.lang.CharSequence getOrganizationName(android.content.ComponentName); method public android.app.admin.DevicePolicyManager getParentProfileInstance(android.content.ComponentName); Loading Loading @@ -6524,6 +6525,7 @@ package android.app.admin { method public void setMasterVolumeMuted(android.content.ComponentName, boolean); method public void setMaximumFailedPasswordsForWipe(android.content.ComponentName, int); method public void setMaximumTimeToLock(android.content.ComponentName, long); method public java.util.List<java.lang.String> setMeteredDataDisabled(android.content.ComponentName, java.util.List<java.lang.String>); method public void setNetworkLoggingEnabled(android.content.ComponentName, boolean); method public void setOrganizationColor(android.content.ComponentName, int); method public void setOrganizationName(android.content.ComponentName, java.lang.CharSequence);
core/java/android/app/admin/DevicePolicyManager.java +41 −0 Original line number Diff line number Diff line Loading @@ -8227,6 +8227,47 @@ public class DevicePolicyManager { return new DevicePolicyManager(mContext, mService, true); } /** * Called by a device or profile owner to restrict packages from accessing metered data. * * @param admin which {@link DeviceAdminReceiver} this request is associated with. * @param packageNames the list of package names to be restricted. * @return a list of package names which could not be restricted. * @throws SecurityException if {@code admin} is not a device or profile owner. */ public @NonNull List<String> setMeteredDataDisabled(@NonNull ComponentName admin, @NonNull List<String> packageNames) { throwIfParentInstance("setMeteredDataDisabled"); if (mService != null) { try { return mService.setMeteredDataDisabled(admin, packageNames); } catch (RemoteException re) { throw re.rethrowFromSystemServer(); } } return packageNames; } /** * Called by a device or profile owner to retrieve the list of packages which are restricted * by the admin from accessing metered data. * * @param admin which {@link DeviceAdminReceiver} this request is associated with. * @return the list of restricted package names. * @throws SecurityException if {@code admin} is not a device or profile owner. */ public @NonNull List<String> getMeteredDataDisabled(@NonNull ComponentName admin) { throwIfParentInstance("getMeteredDataDisabled"); if (mService != null) { try { return mService.getMeteredDataDisabled(admin); } catch (RemoteException re) { throw re.rethrowFromSystemServer(); } } return new ArrayList<>(); } /** * Called by device owners to retrieve device logs from before the device's last reboot. * <p> Loading
core/java/android/app/admin/IDevicePolicyManager.aidl +3 −0 Original line number Diff line number Diff line Loading @@ -400,4 +400,7 @@ interface IDevicePolicyManager { void setPrintingEnabled(in ComponentName admin, boolean enabled); boolean isPrintingEnabled(); CharSequence getPrintingDisabledReason(); List<String> setMeteredDataDisabled(in ComponentName admin, in List<String> packageNames); List<String> getMeteredDataDisabled(in ComponentName admin); }
services/core/java/com/android/server/net/NetworkPolicyLogger.java +10 −0 Original line number Diff line number Diff line Loading @@ -37,6 +37,7 @@ import com.android.server.am.ProcessList; import java.text.SimpleDateFormat; import java.util.Arrays; import java.util.Date; import java.util.Set; public class NetworkPolicyLogger { static final String TAG = "NetworkPolicy"; Loading @@ -62,6 +63,7 @@ public class NetworkPolicyLogger { private static final int EVENT_TEMP_POWER_SAVE_WL_CHANGED = 10; private static final int EVENT_UID_FIREWALL_RULE_CHANGED = 11; private static final int EVENT_FIREWALL_CHAIN_ENABLED = 12; private static final int EVENT_UPDATE_METERED_RESTRICTED_PKGS = 13; static final int NTWK_BLOCKED_POWER = 0; static final int NTWK_ALLOWED_NON_METERED = 1; Loading Loading @@ -179,6 +181,14 @@ public class NetworkPolicyLogger { } } void meteredRestrictedPkgsChanged(Set<Integer> restrictedUids) { synchronized (mLock) { final String log = "Metered restricted uids: " + restrictedUids; if (LOGD) Slog.d(TAG, log); mEventsBuffer.event(log); } } void dumpLogs(IndentingPrintWriter pw) { synchronized (mLock) { pw.println(); Loading
services/core/java/com/android/server/net/NetworkPolicyManagerInternal.java +19 −0 Original line number Diff line number Diff line Loading @@ -19,6 +19,8 @@ package com.android.server.net; import android.net.Network; import android.telephony.SubscriptionPlan; import java.util.Set; /** * Network Policy Manager local system service interface. * Loading Loading @@ -71,4 +73,21 @@ public abstract class NetworkPolicyManagerInternal { * Informs that admin data is loaded and available. */ public abstract void onAdminDataAvailable(); /** * Sets a list of packages which are restricted by admin from accessing metered data. * * @param packageNames the list of restricted packages. * @param userId the userId in which {@param packagesNames} are restricted. */ public abstract void setMeteredRestrictedPackages( Set<String> packageNames, int userId); /** * Similar to {@link #setMeteredRestrictedPackages(Set, int)} but updates the restricted * packages list asynchronously. */ public abstract void setMeteredRestrictedPackagesAsync( Set<String> packageNames, int userId); }