Disable VT when users turn off data or hit data limit
Disable VT when users turn off data or hit data limit. If there are ongoing VT calls, we'll need to downgrade them to VoLTE calls. bug: 27316521 Change-Id: I89fe42f6cf6c419c21c4f2006e9cb43cf7e13503
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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 *****/
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user