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

Commit 04237c1a authored by Susheel nyamala's avatar Susheel nyamala Committed by Gerrit - the friendly Code Review server
Browse files

Add network policy for each sub on powerup

To display data limit for each sub in DataUsage window, network
policy is needed. Currently network policy is added only if the sub is
set as Dds. Add network policy for each sub irrespective of Dds.

Change-Id: Id6b897302172bcfa081ba9fa295ff7abf2a014c8
CRs-Fixed: 786102
parent 3dfb5ec9
Loading
Loading
Loading
Loading
+37 −26
Original line number Diff line number Diff line
@@ -1207,10 +1207,14 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub {

        final TelephonyManager tele = TelephonyManager.from(mContext);

        // avoid creating policy when SIM isn't ready
        if (!isDdsSimStateReady()) return;
        for (int pid = 0; pid < tele.getPhoneCount(); pid++) {
            long[] subIds = SubscriptionManager.getSubId(pid);
            if ((subIds == null || subIds.length == 0) ||
                   !isSimStateReady(pid)) {
                continue;
            }

        final String subscriberId = tele.getSubscriberId(SubscriptionManager.getDefaultDataSubId());
            final String subscriberId = tele.getSubscriberId(subIds[0]);
            final NetworkIdentity probeIdent = new NetworkIdentity(
                    TYPE_MOBILE, TelephonyManager.NETWORK_TYPE_UNKNOWN, subscriberId, null, false);

@@ -1243,6 +1247,7 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub {
                addNetworkPolicyLocked(policy);
            }
        }
    }

    private void readPolicyLocked() {
        if (LOGV) Slog.v(TAG, "readPolicyLocked()");
@@ -2269,4 +2274,10 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub {
        int slotId = SubscriptionManager.getSlotId(SubscriptionManager.getDefaultDataSubId());
        return tm.getSimState(slotId) == TelephonyManager.SIM_STATE_READY;
    }

    // Return true if SIM state of input subscription is in READY state
    private boolean isSimStateReady(int slotId) {
        final TelephonyManager tm = TelephonyManager.from(mContext);
        return tm.getSimState(slotId) == TelephonyManager.SIM_STATE_READY;
    }
}