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

Commit a9fbf3db authored by Sukanya Rajkhowa's avatar Sukanya Rajkhowa Committed by Gerrit - the friendly Code Review server
Browse files

Telephony: Check for network specifier

If client uses older startUsingNetworkFeature() API, it will not set subId in
NetworkCapabilities. So, ConnectivityManager will forward the request to all
the available telephony factories. Process the request only if network specifier
of the request is the same as current TelephonyNetworkFactory's subId.

CRs-Fixed: 750793

Change-Id: Ic3f0a8c6291c3c44832ba1d1dd51743e1d0e76d4
parent 2b30225d
Loading
Loading
Loading
Loading
+10 −18
Original line number Diff line number Diff line
@@ -463,21 +463,6 @@ public final class DcTracker extends DcTrackerBase {
            log("Ready to handle network requests");
        }

        private long getSubIdFromNetworkRequest(NetworkRequest networkRequest) {
            String requestedSpecifierStr = networkRequest.networkCapabilities
                .getNetworkSpecifier();
            long requestedSpecifier = SubscriptionManager.INVALID_SUB_ID;

            try {
                requestedSpecifier = (requestedSpecifierStr != null)? Long.parseLong(
                        requestedSpecifierStr) : SubscriptionManager.INVALID_SUB_ID;
            } catch (NumberFormatException e){
                //nop
            }

            return requestedSpecifier;
        }

        @Override
        protected void needNetworkFor(NetworkRequest networkRequest, int score) {
            // figure out the apn type and enable it
@@ -487,7 +472,7 @@ public final class DcTracker extends DcTrackerBase {

            long currentDds = subController.getDefaultDataSubId();
            long subId = mPhone.getSubId();
            long requestedSpecifier = getSubIdFromNetworkRequest(networkRequest);
            long requestedSpecifier = subController.getSubIdFromNetworkRequest(networkRequest);

            log("CurrentDds = " + currentDds);
            log("mySubId = " + subId);
@@ -499,8 +484,15 @@ public final class DcTracker extends DcTrackerBase {
                return;
            }

            if ((requestedSpecifier != SubscriptionManager.INVALID_SUB_ID)
                    && (currentDds != requestedSpecifier)) {
            // For clients that do not send subId in NetworkCapabilities,
            // Connectivity will send to all network factories. Accept only
            // when requestedSpecifier is same as current factory's subId
            if (requestedSpecifier != subId) {
                log("requestedSpecifier is not same as mysubId. Bail out.");
                return;
            }

            if (currentDds != requestedSpecifier) {
                log("This request would result in DDS switch");
                log("Requested DDS switch to subId = " + requestedSpecifier);