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

Commit d32b58c8 authored by Robert Greenwalt's avatar Robert Greenwalt
Browse files

Listen for retry intents.

Re-adding code stripped out during the NetworkAgent changes.  Going back
to having ApnContexts pre-initialized at startup since they are no longer
NetworkAgents.  This also lets us preregister for each of their retry alarms.

Undo of damage done by: https://googleplex-android-review.googlesource.com/#/c/476836/

bug:15563289
Change-Id: I6f8855eb24d913c73fef647d4219ae7041216e2b
parent b36f67e8
Loading
Loading
Loading
Loading
+57 −13
Original line number Diff line number Diff line
@@ -154,6 +154,16 @@ public final class DcTracker extends DcTrackerBase {
        p.getContext().getContentResolver().registerContentObserver(
                Telephony.Carriers.CONTENT_URI, true, mApnObserver);

        initApnContexts();

        for (ApnContext apnContext : mApnContexts.values()) {
            // Register the reconnect and restart actions.
            IntentFilter filter = new IntentFilter();
            filter.addAction(INTENT_RECONNECT_ALARM + '.' + apnContext.getApnType());
            filter.addAction(INTENT_RESTART_TRYSETUP_ALARM + '.' + apnContext.getApnType());
            mPhone.getContext().registerReceiver(mIntentReceiver, filter, null, mPhone);
        }

        ConnectivityManager cm = (ConnectivityManager)p.getContext().getSystemService(
                Context.CONNECTIVITY_SERVICE);

@@ -313,19 +323,7 @@ public final class DcTracker extends DcTrackerBase {
        }
        ApnContext apnContext = mApnContexts.get(name);
        if (apnContext == null) {
            if (DBG) log("Attempting to create new ApnContext for " + type);
            String[] networkConfigStrings = mPhone.getContext().getResources().getStringArray(
                    com.android.internal.R.array.networkAttributes);
            for (String networkConfigString : networkConfigStrings) {
                NetworkConfig networkConfig = new NetworkConfig(networkConfigString);
                if (networkConfig.type == type) {
                    apnContext = addApnContext(name, networkConfig);
                    break;
                }
            }
            if (apnContext == null) {
                loge("Unable to create new ApnContext for " + type);
            }
            loge("Request for unsupported mobile type: " + type);
        }
        return apnContext;
    }
@@ -373,6 +371,52 @@ public final class DcTracker extends DcTrackerBase {
        return apnContext;
    }

    protected void initApnContexts() {
        log("initApnContexts: E");
        // Load device network attributes from resources
        String[] networkConfigStrings = mPhone.getContext().getResources().getStringArray(
                com.android.internal.R.array.networkAttributes);
        for (String networkConfigString : networkConfigStrings) {
            NetworkConfig networkConfig = new NetworkConfig(networkConfigString);
            ApnContext apnContext = null;

            switch (networkConfig.type) {
            case ConnectivityManager.TYPE_MOBILE:
                apnContext = addApnContext(PhoneConstants.APN_TYPE_DEFAULT, networkConfig);
                break;
            case ConnectivityManager.TYPE_MOBILE_MMS:
                apnContext = addApnContext(PhoneConstants.APN_TYPE_MMS, networkConfig);
                break;
            case ConnectivityManager.TYPE_MOBILE_SUPL:
                apnContext = addApnContext(PhoneConstants.APN_TYPE_SUPL, networkConfig);
                break;
            case ConnectivityManager.TYPE_MOBILE_DUN:
                apnContext = addApnContext(PhoneConstants.APN_TYPE_DUN, networkConfig);
                break;
            case ConnectivityManager.TYPE_MOBILE_HIPRI:
                apnContext = addApnContext(PhoneConstants.APN_TYPE_HIPRI, networkConfig);
                break;
            case ConnectivityManager.TYPE_MOBILE_FOTA:
                apnContext = addApnContext(PhoneConstants.APN_TYPE_FOTA, networkConfig);
                break;
            case ConnectivityManager.TYPE_MOBILE_IMS:
                apnContext = addApnContext(PhoneConstants.APN_TYPE_IMS, networkConfig);
                break;
            case ConnectivityManager.TYPE_MOBILE_CBS:
                apnContext = addApnContext(PhoneConstants.APN_TYPE_CBS, networkConfig);
                break;
            case ConnectivityManager.TYPE_MOBILE_IA:
                apnContext = addApnContext(PhoneConstants.APN_TYPE_IA, networkConfig);
                break;
            default:
                log("initApnContexts: skipping unknown type=" + networkConfig.type);
                continue;
            }
            log("initApnContexts: apnContext=" + apnContext);
        }
        log("initApnContexts: X mApnContexts=" + mApnContexts);
    }

    @Override
    public LinkProperties getLinkProperties(String apnType) {
        ApnContext apnContext = mApnContexts.get(apnType);