Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 37506e24 authored by Jack Yu's avatar Jack Yu Committed by android-build-merger
Browse files

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

am: 92a07ae7

Change-Id: Ia53f350beda8d9671cb67c2a01ed0071b65c4b76
parents 4a5e1bd9 92a07ae7
Loading
Loading
Loading
Loading
+18 −0
Original line number Diff line number Diff line
@@ -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);
                }
            }
        }
    }

    /**
+17 −0
Original line number Diff line number Diff line
@@ -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);
        }
    }
}
+1 −0
Original line number Diff line number Diff line
@@ -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 *****/

+8 −0
Original line number Diff line number Diff line
@@ -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);
}