Loading core/java/android/net/INetworkPolicyManager.aidl +3 −0 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ package android.net; import android.net.INetworkPolicyListener; import android.net.NetworkPolicy; import android.net.NetworkTemplate; /** * Interface that creates and modifies network policy rules. Loading @@ -37,4 +38,6 @@ interface INetworkPolicyManager { void setNetworkPolicies(in NetworkPolicy[] policies); NetworkPolicy[] getNetworkPolicies(); void snoozePolicy(in NetworkTemplate template); } core/java/android/net/NetworkPolicy.java +26 −5 Original line number Diff line number Diff line Loading @@ -21,6 +21,8 @@ import static com.android.internal.util.Preconditions.checkNotNull; import android.os.Parcel; import android.os.Parcelable; import com.android.internal.util.Objects; /** * Policy for networks matching a {@link NetworkTemplate}, including usage cycle * and limits to be enforced. Loading @@ -30,20 +32,21 @@ import android.os.Parcelable; public class NetworkPolicy implements Parcelable, Comparable<NetworkPolicy> { public static final long WARNING_DISABLED = -1; public static final long LIMIT_DISABLED = -1; public static final long SNOOZE_NEVER = -1; public final NetworkTemplate template; public int cycleDay; public long warningBytes; public long limitBytes; public long lastSnooze; // TODO: teach how to snooze limit for current cycle public NetworkPolicy( NetworkTemplate template, int cycleDay, long warningBytes, long limitBytes) { public NetworkPolicy(NetworkTemplate template, int cycleDay, long warningBytes, long limitBytes, long lastSnooze) { this.template = checkNotNull(template, "missing NetworkTemplate"); this.cycleDay = cycleDay; this.warningBytes = warningBytes; this.limitBytes = limitBytes; this.lastSnooze = lastSnooze; } public NetworkPolicy(Parcel in) { Loading @@ -51,6 +54,7 @@ public class NetworkPolicy implements Parcelable, Comparable<NetworkPolicy> { cycleDay = in.readInt(); warningBytes = in.readLong(); limitBytes = in.readLong(); lastSnooze = in.readLong(); } /** {@inheritDoc} */ Loading @@ -59,6 +63,7 @@ public class NetworkPolicy implements Parcelable, Comparable<NetworkPolicy> { dest.writeInt(cycleDay); dest.writeLong(warningBytes); dest.writeLong(limitBytes); dest.writeLong(lastSnooze); } /** {@inheritDoc} */ Loading @@ -79,10 +84,26 @@ public class NetworkPolicy implements Parcelable, Comparable<NetworkPolicy> { return 0; } @Override public int hashCode() { return Objects.hashCode(template, cycleDay, warningBytes, limitBytes, lastSnooze); } @Override public boolean equals(Object obj) { if (obj instanceof NetworkPolicy) { final NetworkPolicy other = (NetworkPolicy) obj; return Objects.equal(template, other.template) && cycleDay == other.cycleDay && warningBytes == other.warningBytes && limitBytes == other.limitBytes && lastSnooze == other.lastSnooze; } return false; } @Override public String toString() { return "NetworkPolicy[" + template + "]: cycleDay=" + cycleDay + ", warningBytes=" + warningBytes + ", limitBytes=" + limitBytes; + warningBytes + ", limitBytes=" + limitBytes + ", lastSnooze=" + lastSnooze; } public static final Creator<NetworkPolicy> CREATOR = new Creator<NetworkPolicy>() { Loading core/java/android/net/NetworkPolicyManager.java +3 −19 Original line number Diff line number Diff line Loading @@ -52,26 +52,10 @@ public class NetworkPolicyManager { private static final boolean ALLOW_PLATFORM_APP_POLICY = true; /** * {@link Intent} action launched when user selects {@link NetworkPolicy} * warning notification. * {@link Intent} extra that indicates which {@link NetworkTemplate} rule it * applies to. */ public static final String ACTION_DATA_USAGE_WARNING = "android.intent.action.DATA_USAGE_WARNING"; /** * {@link Intent} action launched when user selects {@link NetworkPolicy} * limit notification. */ public static final String ACTION_DATA_USAGE_LIMIT = "android.intent.action.DATA_USAGE_LIMIT"; /** * {@link Intent} extra included in {@link #ACTION_DATA_USAGE_WARNING} and * {@link #ACTION_DATA_USAGE_LIMIT} to indicate which * {@link NetworkTemplate} rule it applies to. */ public static final String EXTRA_NETWORK_TEMPLATE = "android.intent.extra.NETWORK_TEMPLATE"; public static final String EXTRA_NETWORK_TEMPLATE = "android.net.NETWORK_TEMPLATE"; private INetworkPolicyManager mService; Loading core/java/android/os/INetworkManagementService.aidl +16 −1 Original line number Diff line number Diff line Loading @@ -212,13 +212,28 @@ interface INetworkManagementService /** * Set quota for an interface. */ void setInterfaceQuota(String iface, long quota); void setInterfaceQuota(String iface, long quotaBytes); /** * Remove quota for an interface. */ void removeInterfaceQuota(String iface); /** * Set alert for an interface; requires that iface already has quota. */ void setInterfaceAlert(String iface, long alertBytes); /** * Remove alert for an interface. */ void removeInterfaceAlert(String iface); /** * Set alert across all interfaces. */ void setGlobalAlert(long alertBytes); /** * Control network activity of a UID over interfaces with a quota limit. */ Loading core/res/res/values/strings.xml +9 −0 Original line number Diff line number Diff line Loading @@ -3034,6 +3034,15 @@ <!-- Notification body when data usage has exceeded limit threshold, and has been disabled. [CHAR LIMIT=32] --> <string name="data_usage_limit_body">tap to enable</string> <!-- Notification title when 2G-3G data usage has exceeded limit threshold. [CHAR LIMIT=32] --> <string name="data_usage_3g_limit_snoozed_title">2G-3G data limit exceeded</string> <!-- Notification title when 4G data usage has exceeded limit threshold. [CHAR LIMIT=32] --> <string name="data_usage_4g_limit_snoozed_title">4G data limit exceeded</string> <!-- Notification title when mobile data usage has exceeded limit threshold. [CHAR LIMIT=32] --> <string name="data_usage_mobile_limit_snoozed_title">Mobile data limit exceeded</string> <!-- Notification body when data usage has exceeded limit threshold. [CHAR LIMIT=32] --> <string name="data_usage_limit_snoozed_body"><xliff:g id="size" example="3.8GB">%s</xliff:g> over specified limit</string> <!-- SSL Certificate dialogs --> <!-- Title for an SSL Certificate dialog --> <string name="ssl_certificate">Security certificate</string> Loading Loading
core/java/android/net/INetworkPolicyManager.aidl +3 −0 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ package android.net; import android.net.INetworkPolicyListener; import android.net.NetworkPolicy; import android.net.NetworkTemplate; /** * Interface that creates and modifies network policy rules. Loading @@ -37,4 +38,6 @@ interface INetworkPolicyManager { void setNetworkPolicies(in NetworkPolicy[] policies); NetworkPolicy[] getNetworkPolicies(); void snoozePolicy(in NetworkTemplate template); }
core/java/android/net/NetworkPolicy.java +26 −5 Original line number Diff line number Diff line Loading @@ -21,6 +21,8 @@ import static com.android.internal.util.Preconditions.checkNotNull; import android.os.Parcel; import android.os.Parcelable; import com.android.internal.util.Objects; /** * Policy for networks matching a {@link NetworkTemplate}, including usage cycle * and limits to be enforced. Loading @@ -30,20 +32,21 @@ import android.os.Parcelable; public class NetworkPolicy implements Parcelable, Comparable<NetworkPolicy> { public static final long WARNING_DISABLED = -1; public static final long LIMIT_DISABLED = -1; public static final long SNOOZE_NEVER = -1; public final NetworkTemplate template; public int cycleDay; public long warningBytes; public long limitBytes; public long lastSnooze; // TODO: teach how to snooze limit for current cycle public NetworkPolicy( NetworkTemplate template, int cycleDay, long warningBytes, long limitBytes) { public NetworkPolicy(NetworkTemplate template, int cycleDay, long warningBytes, long limitBytes, long lastSnooze) { this.template = checkNotNull(template, "missing NetworkTemplate"); this.cycleDay = cycleDay; this.warningBytes = warningBytes; this.limitBytes = limitBytes; this.lastSnooze = lastSnooze; } public NetworkPolicy(Parcel in) { Loading @@ -51,6 +54,7 @@ public class NetworkPolicy implements Parcelable, Comparable<NetworkPolicy> { cycleDay = in.readInt(); warningBytes = in.readLong(); limitBytes = in.readLong(); lastSnooze = in.readLong(); } /** {@inheritDoc} */ Loading @@ -59,6 +63,7 @@ public class NetworkPolicy implements Parcelable, Comparable<NetworkPolicy> { dest.writeInt(cycleDay); dest.writeLong(warningBytes); dest.writeLong(limitBytes); dest.writeLong(lastSnooze); } /** {@inheritDoc} */ Loading @@ -79,10 +84,26 @@ public class NetworkPolicy implements Parcelable, Comparable<NetworkPolicy> { return 0; } @Override public int hashCode() { return Objects.hashCode(template, cycleDay, warningBytes, limitBytes, lastSnooze); } @Override public boolean equals(Object obj) { if (obj instanceof NetworkPolicy) { final NetworkPolicy other = (NetworkPolicy) obj; return Objects.equal(template, other.template) && cycleDay == other.cycleDay && warningBytes == other.warningBytes && limitBytes == other.limitBytes && lastSnooze == other.lastSnooze; } return false; } @Override public String toString() { return "NetworkPolicy[" + template + "]: cycleDay=" + cycleDay + ", warningBytes=" + warningBytes + ", limitBytes=" + limitBytes; + warningBytes + ", limitBytes=" + limitBytes + ", lastSnooze=" + lastSnooze; } public static final Creator<NetworkPolicy> CREATOR = new Creator<NetworkPolicy>() { Loading
core/java/android/net/NetworkPolicyManager.java +3 −19 Original line number Diff line number Diff line Loading @@ -52,26 +52,10 @@ public class NetworkPolicyManager { private static final boolean ALLOW_PLATFORM_APP_POLICY = true; /** * {@link Intent} action launched when user selects {@link NetworkPolicy} * warning notification. * {@link Intent} extra that indicates which {@link NetworkTemplate} rule it * applies to. */ public static final String ACTION_DATA_USAGE_WARNING = "android.intent.action.DATA_USAGE_WARNING"; /** * {@link Intent} action launched when user selects {@link NetworkPolicy} * limit notification. */ public static final String ACTION_DATA_USAGE_LIMIT = "android.intent.action.DATA_USAGE_LIMIT"; /** * {@link Intent} extra included in {@link #ACTION_DATA_USAGE_WARNING} and * {@link #ACTION_DATA_USAGE_LIMIT} to indicate which * {@link NetworkTemplate} rule it applies to. */ public static final String EXTRA_NETWORK_TEMPLATE = "android.intent.extra.NETWORK_TEMPLATE"; public static final String EXTRA_NETWORK_TEMPLATE = "android.net.NETWORK_TEMPLATE"; private INetworkPolicyManager mService; Loading
core/java/android/os/INetworkManagementService.aidl +16 −1 Original line number Diff line number Diff line Loading @@ -212,13 +212,28 @@ interface INetworkManagementService /** * Set quota for an interface. */ void setInterfaceQuota(String iface, long quota); void setInterfaceQuota(String iface, long quotaBytes); /** * Remove quota for an interface. */ void removeInterfaceQuota(String iface); /** * Set alert for an interface; requires that iface already has quota. */ void setInterfaceAlert(String iface, long alertBytes); /** * Remove alert for an interface. */ void removeInterfaceAlert(String iface); /** * Set alert across all interfaces. */ void setGlobalAlert(long alertBytes); /** * Control network activity of a UID over interfaces with a quota limit. */ Loading
core/res/res/values/strings.xml +9 −0 Original line number Diff line number Diff line Loading @@ -3034,6 +3034,15 @@ <!-- Notification body when data usage has exceeded limit threshold, and has been disabled. [CHAR LIMIT=32] --> <string name="data_usage_limit_body">tap to enable</string> <!-- Notification title when 2G-3G data usage has exceeded limit threshold. [CHAR LIMIT=32] --> <string name="data_usage_3g_limit_snoozed_title">2G-3G data limit exceeded</string> <!-- Notification title when 4G data usage has exceeded limit threshold. [CHAR LIMIT=32] --> <string name="data_usage_4g_limit_snoozed_title">4G data limit exceeded</string> <!-- Notification title when mobile data usage has exceeded limit threshold. [CHAR LIMIT=32] --> <string name="data_usage_mobile_limit_snoozed_title">Mobile data limit exceeded</string> <!-- Notification body when data usage has exceeded limit threshold. [CHAR LIMIT=32] --> <string name="data_usage_limit_snoozed_body"><xliff:g id="size" example="3.8GB">%s</xliff:g> over specified limit</string> <!-- SSL Certificate dialogs --> <!-- Title for an SSL Certificate dialog --> <string name="ssl_certificate">Security certificate</string> Loading