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

Commit 62f8fa46 authored by Sandeep Gutta's avatar Sandeep Gutta Committed by Steve Kondik
Browse files

MSIM: Enable data+mms.

Change-Id: Id195112e4078e449a44ac08cb44283b57a29defc
parent 932009d4
Loading
Loading
Loading
Loading
+2 −3
Original line number Diff line number Diff line
@@ -26,6 +26,7 @@ import com.android.internal.telephony.PhoneBase;
import com.android.internal.telephony.PhoneProxy;
import com.android.internal.telephony.SubscriptionController;
import com.android.internal.telephony.dataconnection.DcSwitchAsyncChannel.RequestInfo;
import com.android.internal.telephony.SubscriptionController;

import android.os.Message;
import android.os.SystemProperties;
@@ -108,9 +109,7 @@ public class DcSwitchStateMachine extends StateMachine {
                    if (!isPrimarySubFeatureEnable) {
                        SubscriptionController subscriptionController
                                = SubscriptionController.getInstance();

                        //FIXME: DctController runtime exception, Revert this later
                        //subscriptionController.setDefaultDataSubId(subId);
                        subscriptionController.setDefaultDataSubId(subId);
                    }

                    mAc.replyToMessage(msg, DcSwitchAsyncChannel.RSP_CONNECT,
+2 −252
Original line number Diff line number Diff line
@@ -145,8 +145,6 @@ public final class DcTracker extends DcTrackerBase {

    private static final int PROVISIONING_SPINNER_TIMEOUT_MILLIS = 120 * 1000;

    static final Uri PREFERAPN_NO_UPDATE_URI =
                        Uri.parse("content://telephony/carriers/preferapn_no_update");
    static final Uri PREFERAPN_NO_UPDATE_URI_USING_SUBID =
                        Uri.parse("content://telephony/carriers/preferapn_no_update/subId/");
    static final String APN_ID = "apn_id";
@@ -189,30 +187,6 @@ public final class DcTracker extends DcTrackerBase {

    /* IWLAN and WWAN co-exist flag */
    private boolean mWwanIwlanCoexistFlag = false;
    private long mSubId;


    private BroadcastReceiver defaultDdsBroadcastReceiver = new BroadcastReceiver() {
        public void onReceive(Context context, Intent intent) {
            mSubId = mPhone.getSubId();
            log("got ACTION_DEFAULT_DATA_SUBSCRIPTION_CHANGED, new DDS = "
                    + intent.getIntExtra(PhoneConstants.SUBSCRIPTION_KEY,
                            SubscriptionManager.INVALID_SUBSCRIPTION_ID));
            updateSubIdAndCapability();

            if (mSubId == SubscriptionController.getInstance().getDefaultDataSubId()) {
                log("Dct is default-DDS now, process any pending MMS requests");
            }
        }
    };

    private BroadcastReceiver subInfoBroadcastReceiver = new BroadcastReceiver() {
        public void onReceive(Context context, Intent intent) {
            mSubId = mPhone.getSubId();
            log("got ACTION_SUBINFO_RECORD_UPDATED, mySubId = " + mSubId);
            updateSubIdAndCapability();
        }
    };

    private CdmaApnProfileTracker mOmhApt;

@@ -261,24 +235,6 @@ public final class DcTracker extends DcTrackerBase {
        addEmergencyApnSetting();

        mProvisionActionName = "com.android.internal.telephony.PROVISION" + p.getPhoneId();
        mPhone.getContext().registerReceiver(subInfoBroadcastReceiver,
                new IntentFilter(TelephonyIntents.ACTION_SUBINFO_RECORD_UPDATED));

        mPhone.getContext().registerReceiver(defaultDdsBroadcastReceiver,
                new IntentFilter(TelephonyIntents.ACTION_DEFAULT_DATA_SUBSCRIPTION_CHANGED));

    }

    private void processPendingNetworkRequests(NetworkRequest n) {
//        ((TelephonyNetworkFactory)mNetworkFactory).processPendingNetworkRequests(n);
    }

    private void updateSubIdAndCapability() {
//        ((TelephonyNetworkFactory)mNetworkFactory).updateNetworkCapability(mSubId);
    }

    private void releaseAllNetworkRequests() {
//        ((TelephonyNetworkFactory)mNetworkFactory).releaseAllNetworkRequests();
    }

    protected void registerForAllEvents() {
@@ -330,16 +286,6 @@ public final class DcTracker extends DcTrackerBase {
            mProvisioningSpinner = null;
        }

/* Fix Me - SAND
        mPhone.getContext().unregisterReceiver(defaultDdsBroadcastReceiver);
        mPhone.getContext().unregisterReceiver(subInfoBroadcastReceiver);
*/

        ConnectivityManager cm = (ConnectivityManager)mPhone.getContext().getSystemService(
                Context.CONNECTIVITY_SERVICE);
//        cm.unregisterNetworkFactory(mNetworkFactoryMessenger);
//        mNetworkFactoryMessenger = null;

        cleanUpAllConnections(true, null);

        super.dispose();
@@ -379,180 +325,6 @@ public final class DcTracker extends DcTrackerBase {
        //SubscriptionManager.unregisterForDdsSwitch(this);
    }

/* FIXME - LMR1_INTERNAL
    private class TelephonyNetworkFactory extends NetworkFactory {
        private PhoneBase mPhone;
        private NetworkCapabilities mNetworkCapabilities;

        //Thread safety not required as long as list operation are done by single thread.
        private SparseArray<NetworkRequest> mDdsRequests = new SparseArray<NetworkRequest>();

        public TelephonyNetworkFactory(Looper l, Context c, String TAG,
                NetworkCapabilities nc, PhoneBase phone) {
            super(l, c, TAG, nc);
            mPhone = phone;
            mNetworkCapabilities = nc;
        }

        public void processPendingNetworkRequests(NetworkRequest n) {
            for (int i = 0; i < mDdsRequests.size(); i++) {
                NetworkRequest nr = mDdsRequests.valueAt(i);
                if (nr.equals(n)) {
                    log("Found pending request in ddsRequest list = " + nr);
                    ApnContext apnContext = apnContextForNetworkRequest(nr);
                    if (apnContext != null) {
                        log("Activating APN=" + apnContext);
                        apnContext.incRefCount();
                    }
                }
            }
        }

        private void registerOnDemandDdsCallback() {
            SubscriptionController subController = SubscriptionController.getInstance();

            subController.registerForOnDemandDdsLockNotification(mPhone.getSubId(),
                    new SubscriptionController.OnDemandDdsLockNotifier() {
                        public void notifyOnDemandDdsLockGranted(NetworkRequest n) {
                            log("Got the tempDds lock for the request = " + n);
                            processPendingNetworkRequests(n);
                        }
                    });
        }

        public void updateNetworkCapability(long subId) {
            log("update networkCapabilites for subId = " + subId);

            mNetworkCapabilities.setNetworkSpecifier(""+subId);
            if ((subId > 0 && SubscriptionController.getInstance().
                    getSubState(subId) == SubscriptionManager.ACTIVE) &&
                    (subId == SubscriptionController.getInstance().getDefaultDataSubId())) {
                log("INTERNET capability is with subId = " + subId);
                //Only defaultDataSub provides INTERNET.
                mNetworkCapabilities.addCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET);
            } else {
                log("INTERNET capability is removed from subId = " + subId);
                mNetworkCapabilities.removeCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET);

            }
            setScoreFilter(50);
            registerOnDemandDdsCallback();

            log("Ready to handle network requests");
        }

        @Override
        protected void needNetworkFor(NetworkRequest networkRequest, int score) {
            // figure out the apn type and enable it
            if (DBG) log("Cellular needs Network for " + networkRequest);
            SubscriptionController subController = SubscriptionController.getInstance();
            log("subController = " + subController);

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

            log("CurrentDds = " + currentDds);
            log("mySubId = " + subId);
            log("Requested networkSpecifier = " + requestedSpecifier);
            log("my networkSpecifier = " + mNetworkCapabilities.getNetworkSpecifier());

            if (subId < 0) {
                log("Can't handle any network request now, subId not ready.");
                return;
            }

            // 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);

                //Queue this request and initiate temp DDS switch.
                //Once the DDS switch is done we will revist the pending requests.
                mDdsRequests.put(networkRequest.requestId, networkRequest);
                requestOnDemandDataSubscriptionLock(networkRequest);

                return;
            } else {
                if(isNetworkRequestForInternet(networkRequest)) {
                    log("Activating internet request on subId = " + subId);
                    ApnContext apnContext = apnContextForNetworkRequest(networkRequest);
                    if (apnContext != null) {
                        log("Activating APN=" + apnContext);
                        apnContext.incRefCount();
                    }
                } else {
                    if(isValidRequest(networkRequest)) {
                        //non-default APN requests for this subscription.
                        mDdsRequests.put(networkRequest.requestId, networkRequest);
                        requestOnDemandDataSubscriptionLock(networkRequest);
                    } else {
                        log("Bogus request req = " + networkRequest);
                    }
                }
            }
        }

        private boolean isValidRequest(NetworkRequest n) {
            int[] types = n.networkCapabilities.getCapabilities();
            return (types.length > 0);
        }

        private boolean isNetworkRequestForInternet(NetworkRequest n) {
            boolean flag = n.networkCapabilities.hasCapability
                (NetworkCapabilities.NET_CAPABILITY_INTERNET);
            log("Is the request for Internet = " + flag);
            return flag;
        }

        private void requestOnDemandDataSubscriptionLock(NetworkRequest n) {
            if(!isNetworkRequestForInternet(n)) {
                //Request tempDDS lock only for non-default PDP requests
                SubscriptionController subController = SubscriptionController.getInstance();
                log("requestOnDemandDataSubscriptionLock for request = " + n);
                subController.startOnDemandDataSubscriptionRequest(n);
            }
        }

        private void removeRequestFromList(SparseArray<NetworkRequest> list, NetworkRequest n) {
            NetworkRequest nr = list.get(n.requestId);
            if (nr != null) {
                log("Removing request = " + nr);
                list.remove(n.requestId);
                ApnContext apnContext = apnContextForNetworkRequest(n);
                if (apnContext != null) {
                    log("Deactivating APN=" + apnContext);
                    apnContext.decRefCount();
                }
            }
        }

        private void removeRequestIfFound(NetworkRequest n) {
            log("Release the request from dds queue, if found");
            removeRequestFromList(mDdsRequests, n);

            if(!isNetworkRequestForInternet(n)) {
                SubscriptionController subController = SubscriptionController.getInstance();
                subController.stopOnDemandDataSubscriptionRequest(n);
            } else {
                // Internet requests are not queued in DDS list. So deactivate here explicitly.
                ApnContext apnContext = apnContextForNetworkRequest(n);
                if (apnContext != null) {
                    log("Deactivating APN=" + apnContext);
                    apnContext.decRefCount();
                }
            }
        }
    }
*/

    @Override
    public void incApnRefCount(String name) {
        ApnContext apnContext = mApnContexts.get(name);
@@ -561,28 +333,6 @@ public final class DcTracker extends DcTrackerBase {
        }
    }


/* FIXME - LMR1_INTERNAL
        @Override
        protected void releaseNetworkFor(NetworkRequest networkRequest) {
            if (DBG) log("Cellular releasing Network for " + networkRequest);
            removeRequestIfFound(networkRequest);
        }

        public void releaseAllNetworkRequests() {
            log("releaseAllNetworkRequests");
            SubscriptionController subController = SubscriptionController.getInstance();
            for (int i = 0; i < mDdsRequests.size(); i++) {
                NetworkRequest nr = mDdsRequests.valueAt(i);
                if (nr != null) {
                    log("Removing request = " + nr);
                    subController.stopOnDemandDataSubscriptionRequest(nr);
                    mDdsRequests.remove(nr.requestId);
                }
            }
        }
*/

    @Override
    public void decApnRefCount(String name) {
        ApnContext apnContext = mApnContexts.get(name);
@@ -3104,7 +2854,7 @@ public final class DcTracker extends DcTrackerBase {
            return;
        }

        String subId = Long.toString(mPhone.getSubId());
        String subId = Integer.toString(mPhone.getSubId());
        Uri uri = Uri.withAppendedPath(PREFERAPN_NO_UPDATE_URI_USING_SUBID, subId);
        log("setPreferredApn: delete");
        ContentResolver resolver = mPhone.getContext().getContentResolver();
@@ -3124,7 +2874,7 @@ public final class DcTracker extends DcTrackerBase {
            return null;
        }

        String subId = Long.toString(mPhone.getSubId());
        String subId = Integer.toString(mPhone.getSubId());
        Uri uri = Uri.withAppendedPath(PREFERAPN_NO_UPDATE_URI_USING_SUBID, subId);
        Cursor cursor = mPhone.getContext().getContentResolver().query(
                uri, new String[] { "_id", "name", "apn" },
+2 −1
Original line number Diff line number Diff line
@@ -638,7 +638,7 @@ public abstract class DcTrackerBase extends Handler {
        mDcTesterFailBringUpAll.dispose();
    }

    public long getSubId() {
    public int getSubId() {
        return mPhone.getSubId();
    }

@@ -773,6 +773,7 @@ public abstract class DcTrackerBase extends Handler {
    public void setDataOnRoamingEnabled(boolean enabled) {
        if (getDataOnRoamingEnabled() != enabled) {
            final ContentResolver resolver = mPhone.getContext().getContentResolver();

            Settings.Global.putInt(resolver,
                    Settings.Global.DATA_ROAMING + mPhone.getPhoneId(), enabled ? 1 : 0);
            // will trigger handleDataOnRoamingChange() through observer
+390 −204

File changed.File mode changed from 100644 to 100755.

Preview size limit exceeded, changes collapsed.