Loading services/core/java/com/android/server/net/NetworkPolicyManagerService.java +18 −0 Original line number Diff line number Diff line Loading @@ -1241,6 +1241,24 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub { private void setNetworkTemplateEnabled(NetworkTemplate template, boolean enabled) { // TODO: reach into ConnectivityManager to proactively disable bringing // up this network, since we know that traffic will be blocked. if (template.getMatchRule() == MATCH_MOBILE_ALL) { // If mobile data usage hits the limit or if the user resumes the data, we need to // notify telephony. final SubscriptionManager sm = SubscriptionManager.from(mContext); final TelephonyManager tm = TelephonyManager.from(mContext); final int[] subIds = sm.getActiveSubscriptionIdList(); for (int subId : subIds) { final String subscriberId = tm.getSubscriberId(subId); final NetworkIdentity probeIdent = new NetworkIdentity(TYPE_MOBILE, TelephonyManager.NETWORK_TYPE_UNKNOWN, subscriberId, null, false, true); // Template is matched when subscriber id matches. if (template.matches(probeIdent)) { tm.setPolicyDataEnabled(enabled, subId); } } } } /** Loading telephony/java/android/telephony/TelephonyManager.java +17 −0 Original line number Diff line number Diff line Loading @@ -5538,5 +5538,22 @@ public class TelephonyManager { } return 0; } /** * Policy control of data connection. Usually used when data limit is passed. * @param enabled True if enabling the data, otherwise disabling. * @param subId sub id * @hide */ public void setPolicyDataEnabled(boolean enabled, int subId) { try { ITelephony service = getITelephony(); if (service != null) { service.setPolicyDataEnabled(enabled, subId); } } catch (RemoteException e) { Log.e(TAG, "Error calling ITelephony#setPolicyDataEnabled", e); } } } telephony/java/com/android/internal/telephony/DctConstants.java +1 −0 Original line number Diff line number Diff line Loading @@ -105,6 +105,7 @@ public class DctConstants { public static final int EVENT_DEVICE_PROVISIONED_CHANGE = BASE + 43; public static final int EVENT_REDIRECTION_DETECTED = BASE + 44; public static final int EVENT_PCO_DATA_RECEIVED = BASE + 45; public static final int EVENT_SET_CARRIER_DATA_ENABLED = BASE + 46; /***** Constants *****/ Loading telephony/java/com/android/internal/telephony/ITelephony.aidl +8 −0 Original line number Diff line number Diff line Loading @@ -1158,4 +1158,12 @@ interface ITelephony { * @hide */ long getVtDataUsage(); /** * Policy control of data connection. Usually used when data limit is passed. * @param enabled True if enabling the data, otherwise disabling. * @param subId Subscription index * @hide */ void setPolicyDataEnabled(boolean enabled, int subId); } Loading
services/core/java/com/android/server/net/NetworkPolicyManagerService.java +18 −0 Original line number Diff line number Diff line Loading @@ -1241,6 +1241,24 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub { private void setNetworkTemplateEnabled(NetworkTemplate template, boolean enabled) { // TODO: reach into ConnectivityManager to proactively disable bringing // up this network, since we know that traffic will be blocked. if (template.getMatchRule() == MATCH_MOBILE_ALL) { // If mobile data usage hits the limit or if the user resumes the data, we need to // notify telephony. final SubscriptionManager sm = SubscriptionManager.from(mContext); final TelephonyManager tm = TelephonyManager.from(mContext); final int[] subIds = sm.getActiveSubscriptionIdList(); for (int subId : subIds) { final String subscriberId = tm.getSubscriberId(subId); final NetworkIdentity probeIdent = new NetworkIdentity(TYPE_MOBILE, TelephonyManager.NETWORK_TYPE_UNKNOWN, subscriberId, null, false, true); // Template is matched when subscriber id matches. if (template.matches(probeIdent)) { tm.setPolicyDataEnabled(enabled, subId); } } } } /** Loading
telephony/java/android/telephony/TelephonyManager.java +17 −0 Original line number Diff line number Diff line Loading @@ -5538,5 +5538,22 @@ public class TelephonyManager { } return 0; } /** * Policy control of data connection. Usually used when data limit is passed. * @param enabled True if enabling the data, otherwise disabling. * @param subId sub id * @hide */ public void setPolicyDataEnabled(boolean enabled, int subId) { try { ITelephony service = getITelephony(); if (service != null) { service.setPolicyDataEnabled(enabled, subId); } } catch (RemoteException e) { Log.e(TAG, "Error calling ITelephony#setPolicyDataEnabled", e); } } }
telephony/java/com/android/internal/telephony/DctConstants.java +1 −0 Original line number Diff line number Diff line Loading @@ -105,6 +105,7 @@ public class DctConstants { public static final int EVENT_DEVICE_PROVISIONED_CHANGE = BASE + 43; public static final int EVENT_REDIRECTION_DETECTED = BASE + 44; public static final int EVENT_PCO_DATA_RECEIVED = BASE + 45; public static final int EVENT_SET_CARRIER_DATA_ENABLED = BASE + 46; /***** Constants *****/ Loading
telephony/java/com/android/internal/telephony/ITelephony.aidl +8 −0 Original line number Diff line number Diff line Loading @@ -1158,4 +1158,12 @@ interface ITelephony { * @hide */ long getVtDataUsage(); /** * Policy control of data connection. Usually used when data limit is passed. * @param enabled True if enabling the data, otherwise disabling. * @param subId Subscription index * @hide */ void setPolicyDataEnabled(boolean enabled, int subId); }