Loading core/java/android/net/INetworkPolicyManager.aidl +2 −2 Original line number Diff line number Diff line Loading @@ -34,7 +34,7 @@ interface INetworkPolicyManager { void registerListener(INetworkPolicyListener listener); void unregisterListener(INetworkPolicyListener listener); void setNetworkPolicy(int networkType, String subscriberId, in NetworkPolicy policy); NetworkPolicy getNetworkPolicy(int networkType, String subscriberId); void setNetworkPolicies(in NetworkPolicy[] policies); NetworkPolicy[] getNetworkPolicies(); } core/java/android/net/NetworkPolicy.java +24 −8 Original line number Diff line number Diff line Loading @@ -26,17 +26,27 @@ import android.os.Parcelable; * @hide */ public class NetworkPolicy implements Parcelable, Comparable<NetworkPolicy> { public final int cycleDay; public final long warningBytes; public final long limitBytes; public final int networkTemplate; public final String subscriberId; public int cycleDay; public long warningBytes; public long limitBytes; public NetworkPolicy(int cycleDay, long warningBytes, long limitBytes) { public static final long WARNING_DISABLED = -1; public static final long LIMIT_DISABLED = -1; public NetworkPolicy(int networkTemplate, String subscriberId, int cycleDay, long warningBytes, long limitBytes) { this.networkTemplate = networkTemplate; this.subscriberId = subscriberId; this.cycleDay = cycleDay; this.warningBytes = warningBytes; this.limitBytes = limitBytes; } public NetworkPolicy(Parcel in) { networkTemplate = in.readInt(); subscriberId = in.readString(); cycleDay = in.readInt(); warningBytes = in.readLong(); limitBytes = in.readLong(); Loading @@ -44,6 +54,8 @@ public class NetworkPolicy implements Parcelable, Comparable<NetworkPolicy> { /** {@inheritDoc} */ public void writeToParcel(Parcel dest, int flags) { dest.writeInt(networkTemplate); dest.writeString(subscriberId); dest.writeInt(cycleDay); dest.writeLong(warningBytes); dest.writeLong(limitBytes); Loading @@ -56,17 +68,21 @@ public class NetworkPolicy implements Parcelable, Comparable<NetworkPolicy> { /** {@inheritDoc} */ public int compareTo(NetworkPolicy another) { if (another == null || limitBytes < another.limitBytes) { if (another == null || another.limitBytes == LIMIT_DISABLED) { // other value is missing or disabled; we win return -1; } else { } if (limitBytes == LIMIT_DISABLED || another.limitBytes < limitBytes) { // we're disabled or other limit is smaller; they win return 1; } return 0; } @Override public String toString() { return "NetworkPolicy: cycleDay=" + cycleDay + ", warningBytes=" + warningBytes + ", limitBytes=" + limitBytes; return "NetworkPolicy: networkTemplate=" + networkTemplate + ", cycleDay=" + cycleDay + ", warningBytes=" + warningBytes + ", limitBytes=" + limitBytes; } public static final Creator<NetworkPolicy> CREATOR = new Creator<NetworkPolicy>() { Loading core/java/android/net/NetworkPolicyManager.java +4 −4 Original line number Diff line number Diff line Loading @@ -55,17 +55,17 @@ public class NetworkPolicyManager { } /** {@hide} */ public void setNetworkPolicy(int networkType, String subscriberId, NetworkPolicy policy) { public void setNetworkPolicies(NetworkPolicy[] policies) { try { mService.setNetworkPolicy(networkType, subscriberId, policy); mService.setNetworkPolicies(policies); } catch (RemoteException e) { } } /** {@hide} */ public NetworkPolicy getNetworkPolicy(int networkType, String subscriberId) { public NetworkPolicy[] getNetworkPolicies() { try { return mService.getNetworkPolicy(networkType, subscriberId); return mService.getNetworkPolicies(); } catch (RemoteException e) { return null; } Loading core/java/android/net/TrafficStats.java +14 −5 Original line number Diff line number Diff line Loading @@ -41,11 +41,9 @@ public class TrafficStats { */ public final static int UNSUPPORTED = -1; // TODO: find better home for these template constants /** * Template to combine all {@link ConnectivityManager#TYPE_MOBILE} style * networks together. Only uses statistics for currently active IMSI. * networks together. Only uses statistics for requested IMSI. * * @hide */ Loading @@ -54,7 +52,7 @@ public class TrafficStats { /** * Template to combine all {@link ConnectivityManager#TYPE_MOBILE} style * networks together that roughly meet a "3G" definition, or lower. Only * uses statistics for currently active IMSI. * uses statistics for requested IMSI. * * @hide */ Loading @@ -63,7 +61,7 @@ public class TrafficStats { /** * Template to combine all {@link ConnectivityManager#TYPE_MOBILE} style * networks together that meet a "4G" definition. Only uses statistics for * currently active IMSI. * requested IMSI. * * @hide */ Loading Loading @@ -184,6 +182,17 @@ public class TrafficStats { } } /** {@hide} */ public static boolean isNetworkTemplateMobile(int networkTemplate) { switch (networkTemplate) { case TEMPLATE_MOBILE_3G_LOWER: case TEMPLATE_MOBILE_4G: case TEMPLATE_MOBILE_ALL: return true; } return false; } /** * Get the total number of packets transmitted through the mobile interface. * Loading services/java/com/android/server/net/NetworkIdentity.java +2 −0 Original line number Diff line number Diff line Loading @@ -26,6 +26,7 @@ import static android.net.TrafficStats.TEMPLATE_WIFI; import static android.telephony.TelephonyManager.NETWORK_CLASS_2_G; import static android.telephony.TelephonyManager.NETWORK_CLASS_3_G; import static android.telephony.TelephonyManager.NETWORK_CLASS_4_G; import static android.telephony.TelephonyManager.NETWORK_CLASS_UNKNOWN; import static android.telephony.TelephonyManager.getNetworkClass; import android.content.Context; Loading Loading @@ -148,6 +149,7 @@ public class NetworkIdentity { if (isNetworkTypeMobile(type) && Objects.equal(this.subscriberId, subscriberId)) { switch (getNetworkClass(subType)) { case NETWORK_CLASS_UNKNOWN: case NETWORK_CLASS_2_G: case NETWORK_CLASS_3_G: return true; Loading Loading
core/java/android/net/INetworkPolicyManager.aidl +2 −2 Original line number Diff line number Diff line Loading @@ -34,7 +34,7 @@ interface INetworkPolicyManager { void registerListener(INetworkPolicyListener listener); void unregisterListener(INetworkPolicyListener listener); void setNetworkPolicy(int networkType, String subscriberId, in NetworkPolicy policy); NetworkPolicy getNetworkPolicy(int networkType, String subscriberId); void setNetworkPolicies(in NetworkPolicy[] policies); NetworkPolicy[] getNetworkPolicies(); }
core/java/android/net/NetworkPolicy.java +24 −8 Original line number Diff line number Diff line Loading @@ -26,17 +26,27 @@ import android.os.Parcelable; * @hide */ public class NetworkPolicy implements Parcelable, Comparable<NetworkPolicy> { public final int cycleDay; public final long warningBytes; public final long limitBytes; public final int networkTemplate; public final String subscriberId; public int cycleDay; public long warningBytes; public long limitBytes; public NetworkPolicy(int cycleDay, long warningBytes, long limitBytes) { public static final long WARNING_DISABLED = -1; public static final long LIMIT_DISABLED = -1; public NetworkPolicy(int networkTemplate, String subscriberId, int cycleDay, long warningBytes, long limitBytes) { this.networkTemplate = networkTemplate; this.subscriberId = subscriberId; this.cycleDay = cycleDay; this.warningBytes = warningBytes; this.limitBytes = limitBytes; } public NetworkPolicy(Parcel in) { networkTemplate = in.readInt(); subscriberId = in.readString(); cycleDay = in.readInt(); warningBytes = in.readLong(); limitBytes = in.readLong(); Loading @@ -44,6 +54,8 @@ public class NetworkPolicy implements Parcelable, Comparable<NetworkPolicy> { /** {@inheritDoc} */ public void writeToParcel(Parcel dest, int flags) { dest.writeInt(networkTemplate); dest.writeString(subscriberId); dest.writeInt(cycleDay); dest.writeLong(warningBytes); dest.writeLong(limitBytes); Loading @@ -56,17 +68,21 @@ public class NetworkPolicy implements Parcelable, Comparable<NetworkPolicy> { /** {@inheritDoc} */ public int compareTo(NetworkPolicy another) { if (another == null || limitBytes < another.limitBytes) { if (another == null || another.limitBytes == LIMIT_DISABLED) { // other value is missing or disabled; we win return -1; } else { } if (limitBytes == LIMIT_DISABLED || another.limitBytes < limitBytes) { // we're disabled or other limit is smaller; they win return 1; } return 0; } @Override public String toString() { return "NetworkPolicy: cycleDay=" + cycleDay + ", warningBytes=" + warningBytes + ", limitBytes=" + limitBytes; return "NetworkPolicy: networkTemplate=" + networkTemplate + ", cycleDay=" + cycleDay + ", warningBytes=" + warningBytes + ", limitBytes=" + limitBytes; } public static final Creator<NetworkPolicy> CREATOR = new Creator<NetworkPolicy>() { Loading
core/java/android/net/NetworkPolicyManager.java +4 −4 Original line number Diff line number Diff line Loading @@ -55,17 +55,17 @@ public class NetworkPolicyManager { } /** {@hide} */ public void setNetworkPolicy(int networkType, String subscriberId, NetworkPolicy policy) { public void setNetworkPolicies(NetworkPolicy[] policies) { try { mService.setNetworkPolicy(networkType, subscriberId, policy); mService.setNetworkPolicies(policies); } catch (RemoteException e) { } } /** {@hide} */ public NetworkPolicy getNetworkPolicy(int networkType, String subscriberId) { public NetworkPolicy[] getNetworkPolicies() { try { return mService.getNetworkPolicy(networkType, subscriberId); return mService.getNetworkPolicies(); } catch (RemoteException e) { return null; } Loading
core/java/android/net/TrafficStats.java +14 −5 Original line number Diff line number Diff line Loading @@ -41,11 +41,9 @@ public class TrafficStats { */ public final static int UNSUPPORTED = -1; // TODO: find better home for these template constants /** * Template to combine all {@link ConnectivityManager#TYPE_MOBILE} style * networks together. Only uses statistics for currently active IMSI. * networks together. Only uses statistics for requested IMSI. * * @hide */ Loading @@ -54,7 +52,7 @@ public class TrafficStats { /** * Template to combine all {@link ConnectivityManager#TYPE_MOBILE} style * networks together that roughly meet a "3G" definition, or lower. Only * uses statistics for currently active IMSI. * uses statistics for requested IMSI. * * @hide */ Loading @@ -63,7 +61,7 @@ public class TrafficStats { /** * Template to combine all {@link ConnectivityManager#TYPE_MOBILE} style * networks together that meet a "4G" definition. Only uses statistics for * currently active IMSI. * requested IMSI. * * @hide */ Loading Loading @@ -184,6 +182,17 @@ public class TrafficStats { } } /** {@hide} */ public static boolean isNetworkTemplateMobile(int networkTemplate) { switch (networkTemplate) { case TEMPLATE_MOBILE_3G_LOWER: case TEMPLATE_MOBILE_4G: case TEMPLATE_MOBILE_ALL: return true; } return false; } /** * Get the total number of packets transmitted through the mobile interface. * Loading
services/java/com/android/server/net/NetworkIdentity.java +2 −0 Original line number Diff line number Diff line Loading @@ -26,6 +26,7 @@ import static android.net.TrafficStats.TEMPLATE_WIFI; import static android.telephony.TelephonyManager.NETWORK_CLASS_2_G; import static android.telephony.TelephonyManager.NETWORK_CLASS_3_G; import static android.telephony.TelephonyManager.NETWORK_CLASS_4_G; import static android.telephony.TelephonyManager.NETWORK_CLASS_UNKNOWN; import static android.telephony.TelephonyManager.getNetworkClass; import android.content.Context; Loading Loading @@ -148,6 +149,7 @@ public class NetworkIdentity { if (isNetworkTypeMobile(type) && Objects.equal(this.subscriberId, subscriberId)) { switch (getNetworkClass(subType)) { case NETWORK_CLASS_UNKNOWN: case NETWORK_CLASS_2_G: case NETWORK_CLASS_3_G: return true; Loading