Merge "Disable VT when users turn off data or hit data limit" into nyc-mr1-dev

This commit is contained in:
Jack Yu
2016-07-14 04:58:53 +00:00
committed by Android (Google) Code Review
4 changed files with 44 additions and 0 deletions

View File

@@ -1241,6 +1241,24 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub {
private void setNetworkTemplateEnabled(NetworkTemplate template, boolean enabled) { private void setNetworkTemplateEnabled(NetworkTemplate template, boolean enabled) {
// TODO: reach into ConnectivityManager to proactively disable bringing // TODO: reach into ConnectivityManager to proactively disable bringing
// up this network, since we know that traffic will be blocked. // 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);
}
}
}
} }
/** /**

View File

@@ -5538,5 +5538,22 @@ public class TelephonyManager {
} }
return 0; 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);
}
}
} }

View File

@@ -105,6 +105,7 @@ public class DctConstants {
public static final int EVENT_DEVICE_PROVISIONED_CHANGE = BASE + 43; public static final int EVENT_DEVICE_PROVISIONED_CHANGE = BASE + 43;
public static final int EVENT_REDIRECTION_DETECTED = BASE + 44; public static final int EVENT_REDIRECTION_DETECTED = BASE + 44;
public static final int EVENT_PCO_DATA_RECEIVED = BASE + 45; public static final int EVENT_PCO_DATA_RECEIVED = BASE + 45;
public static final int EVENT_SET_CARRIER_DATA_ENABLED = BASE + 46;
/***** Constants *****/ /***** Constants *****/

View File

@@ -1158,4 +1158,12 @@ interface ITelephony {
* @hide * @hide
*/ */
long getVtDataUsage(); 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);
} }