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

Commit 35e17cac authored by Yashdev Singh's avatar Yashdev Singh Committed by Linux Build Service Account
Browse files

Telephony: Implement Data+MMS functionality

- DSDA: Allow simultaneous on-demand PDN activation on either sub.
- 7+5 mode functionality: Differentiate between permanent
  and temp DDS switches.
- ALLOW_DATA failure retries implementation.

Conflicts:
	src/java/com/android/internal/telephony/dataconnection/DcSwitchAsyncChannel.java
	src/java/com/android/internal/telephony/dataconnection/DctController.java

Change-Id: Iff9e847a76bd46215569b566db412667ba8ed008
parent c595be2e
Loading
Loading
Loading
Loading
+30 −6
Original line number Diff line number Diff line
@@ -46,8 +46,9 @@ public class DcSwitchAsyncChannel extends AsyncChannel {
    static final int EVENT_DATA_DETACHED =            BASE + 8;
    static final int EVENT_EMERGENCY_CALL_STARTED =   BASE + 9;
    static final int EVENT_EMERGENCY_CALL_ENDED =     BASE + 10;
    static final int EVENT_RESET =                    BASE + 11;

    private static final int CMD_TO_STRING_COUNT = EVENT_EMERGENCY_CALL_ENDED - BASE + 1;
    private static final int CMD_TO_STRING_COUNT = EVENT_RESET - BASE + 1;
    private static String[] sCmdToString = new String[CMD_TO_STRING_COUNT];
    static {
        sCmdToString[REQ_CONNECT - BASE] = "REQ_CONNECT";
@@ -61,13 +62,14 @@ public class DcSwitchAsyncChannel extends AsyncChannel {
        sCmdToString[EVENT_DATA_DETACHED - BASE] = "EVENT_DATA_DETACHED";
        sCmdToString[EVENT_EMERGENCY_CALL_STARTED - BASE] = "EVENT_EMERGENCY_CALL_STARTED";
        sCmdToString[EVENT_EMERGENCY_CALL_ENDED - BASE] = "EVENT_EMERGENCY_CALL_ENDED";
        sCmdToString[EVENT_RESET - BASE] = "EVENT_RESET";
    }

    public static class RequestInfo {
        boolean executed;
        final NetworkRequest request;
        final int priority;
        final int phoneId;
        public boolean executed;
        public final NetworkRequest request;
        public final int priority;
        public final int phoneId;
        private final LocalLog requestLog;

        public RequestInfo(NetworkRequest request, int priority, LocalLog l, int phoneId) {
@@ -93,6 +95,16 @@ public class DcSwitchAsyncChannel extends AsyncChannel {
        }
    }

    public static class ConnectInfo {
        final RequestInfo request;
        final Message responseMessage;

        public ConnectInfo(RequestInfo req, Message msg) {
            this.request = req;
            this.responseMessage = msg;
        }
    }

    protected static String cmdToString(int cmd) {
        cmd -= BASE;
        if ((cmd >= 0) && (cmd < sCmdToString.length)) {
@@ -108,7 +120,14 @@ public class DcSwitchAsyncChannel extends AsyncChannel {
    }

    public int connect(RequestInfo apnRequest) {
        sendMessage(REQ_CONNECT, apnRequest);
        ConnectInfo connectInfo = new ConnectInfo(apnRequest, null);
        sendMessage(REQ_CONNECT, connectInfo);
        return PhoneConstants.APN_REQUEST_STARTED;
    }

    public int connect(RequestInfo apnRequest, Message msg) {
        ConnectInfo connectInfo = new ConnectInfo(apnRequest, msg);
        sendMessage(REQ_CONNECT, connectInfo);
        return PhoneConstants.APN_REQUEST_STARTED;
    }

@@ -137,6 +156,11 @@ public class DcSwitchAsyncChannel extends AsyncChannel {
        }
    }

    public void reset() {
        sendMessage(EVENT_RESET);
        if (DBG) log("EVENT_RESET");
    }

    private boolean rspIsIdle(Message response) {
        boolean retVal = response.arg1 == 1;
        if (DBG) log("rspIsIdle=" + retVal);
+40 −8
Original line number Diff line number Diff line
@@ -26,6 +26,7 @@ import com.android.internal.telephony.Phone;
import com.android.internal.telephony.PhoneConstants;
import com.android.internal.telephony.PhoneBase;
import com.android.internal.telephony.PhoneProxy;
import com.android.internal.telephony.dataconnection.DcSwitchAsyncChannel.ConnectInfo;
import com.android.internal.telephony.dataconnection.DcSwitchAsyncChannel.RequestInfo;

import android.os.AsyncResult;
@@ -48,6 +49,8 @@ public class DcSwitchStateMachine extends StateMachine {
    private Phone mPhone;
    private AsyncChannel mAc;

    private Message mResponseMsg = null;

    private IdleState mIdleState = new IdleState();
    private EmergencyState mEmergencyState = new EmergencyState();
    private AttachingState mAttachingState = new AttachingState();
@@ -87,7 +90,7 @@ public class DcSwitchStateMachine extends StateMachine {
        @Override
        public void enter() {
            if (DBG) log("IdleState: enter");

            mResponseMsg = null;
            try {
                DctController.getInstance().processRequests();
            } catch (RuntimeException e) {
@@ -101,7 +104,9 @@ public class DcSwitchStateMachine extends StateMachine {

            switch (msg.what) {
                case DcSwitchAsyncChannel.REQ_CONNECT: {
                    RequestInfo apnRequest = (RequestInfo)msg.obj;
                    ConnectInfo connectInfo = (ConnectInfo)msg.obj;
                    RequestInfo apnRequest = connectInfo.request;
                    mResponseMsg = connectInfo.responseMessage;
                    apnRequest.log("DcSwitchStateMachine.IdleState: REQ_CONNECT");
                    if (DBG) log("IdleState: REQ_CONNECT, apnRequest=" + apnRequest);
                    transitionTo(mAttachingState);
@@ -216,13 +221,19 @@ public class DcSwitchStateMachine extends StateMachine {
            }
        }

        @Override
        public void exit() {
            mResponseMsg = null;
        }

        @Override
        public boolean processMessage(Message msg) {
            boolean retVal;

            switch (msg.what) {
                case DcSwitchAsyncChannel.REQ_CONNECT: {
                    RequestInfo apnRequest = (RequestInfo)msg.obj;
                    ConnectInfo connectInfo = (ConnectInfo)msg.obj;
                    RequestInfo apnRequest = connectInfo.request;
                    apnRequest.log("DcSwitchStateMachine.AttachingState: REQ_CONNECT");
                    if (DBG) log("AttachingState: REQ_CONNECT, apnRequest=" + apnRequest);

@@ -241,10 +252,27 @@ public class DcSwitchStateMachine extends StateMachine {
                    if (mCurrentAllowedSequence != msg.arg1) {
                        loge("EVENT_DATA_ALLOWED ignored arg1=" + msg.arg1 + ", seq=" +
                                mCurrentAllowedSequence);
                    } else if (ar.exception != null) {
                    } else {
                        if (ar.exception != null) {
                            loge("EVENT_DATA_ALLOWED failed, " + ar.exception);
                        //TODO: Implement backoff retries and abort logic.
                            if (mResponseMsg != null) {
                                // Inform DctController about the failure.
                                Message responseMsg = Message.obtain(mResponseMsg);
                                responseMsg.obj = new AsyncResult(null, null, ar.exception);
                                responseMsg.sendToTarget();
                            }
                        } else {
                            logd("EVENT_DATA_ALLOWED success");
                            mResponseMsg = null;
                        }
                    }
                    retVal = HANDLED;
                    break;
                }

                case DcSwitchAsyncChannel.EVENT_RESET: {
                    if (DBG) log("AttachingState requested abort/reset");
                    transitionTo(mIdleState);
                    retVal = HANDLED;
                    break;
                }
@@ -311,7 +339,8 @@ public class DcSwitchStateMachine extends StateMachine {

            switch (msg.what) {
                case DcSwitchAsyncChannel.REQ_CONNECT: {
                    RequestInfo apnRequest = (RequestInfo)msg.obj;
                    ConnectInfo connectInfo = (ConnectInfo)msg.obj;
                    RequestInfo apnRequest = connectInfo.request;
                    apnRequest.log("DcSwitchStateMachine.AttachedState: REQ_CONNECT");
                    if (DBG) log("AttachedState: REQ_CONNECT, apnRequest=" + apnRequest);

@@ -368,7 +397,8 @@ public class DcSwitchStateMachine extends StateMachine {

            switch (msg.what) {
                case DcSwitchAsyncChannel.REQ_CONNECT: {
                    RequestInfo apnRequest = (RequestInfo)msg.obj;
                    ConnectInfo connectInfo = (ConnectInfo)msg.obj;
                    RequestInfo apnRequest = connectInfo.request;
                    apnRequest.log("DcSwitchStateMachine.DetachingState: REQ_CONNECT");
                    if (DBG) log("DetachingState: REQ_CONNECT, apnRequest=" + apnRequest);

@@ -463,11 +493,13 @@ public class DcSwitchStateMachine extends StateMachine {
                            DcSwitchAsyncChannel.RSP_IS_IDLE_OR_DETACHING_STATE, val ? 1 : 0);
                    break;
                }

                case DcSwitchAsyncChannel.EVENT_EMERGENCY_CALL_STARTED: {
                    mPreEmergencyState = getCurrentState();
                    transitionTo(mEmergencyState);
                    break;
                }

                default:
                    if (DBG) {
                        log("DefaultState: shouldn't happen but ignore msg.what=0x" +
+18 −18
Original line number Diff line number Diff line
@@ -51,7 +51,7 @@ import java.util.Iterator;
import java.util.Map.Entry;

public class DctController extends Handler {
    private static final String LOG_TAG = "DctController";
    protected static String LOG_TAG = "DctController";
    private static final boolean DBG = true;

    private static final int EVENT_PROCESS_REQUESTS = 100;
@@ -67,15 +67,15 @@ public class DctController extends Handler {
    private static final int EVENT_DATA_DETACHED = 600;
    private static final int EVENT_EMERGENCY_CALL_TOGGLED = 700;

    private static DctController sDctController;
    protected static DctController sDctController;

    private int mPhoneNum;
    private PhoneProxy[] mPhones;
    protected int mPhoneNum;
    protected PhoneProxy[] mPhones;
    private DcSwitchStateMachine[] mDcSwitchStateMachine;
    private DcSwitchAsyncChannel[] mDcSwitchAsyncChannel;
    protected DcSwitchAsyncChannel[] mDcSwitchAsyncChannel;
    private Handler[] mDcSwitchStateHandler;
    private HashMap<Integer, RequestInfo> mRequestInfos = new HashMap<Integer, RequestInfo>();
    private Context mContext;
    protected HashMap<Integer, RequestInfo> mRequestInfos = new HashMap<Integer, RequestInfo>();
    protected Context mContext;

    /** Used to send us NetworkRequests from ConnectivityService.  Remember it so we can
     * unregister on dispose. */
@@ -83,7 +83,7 @@ public class DctController extends Handler {
    private NetworkFactory[] mNetworkFactory;
    private NetworkCapabilities[] mNetworkFilter;

    private SubscriptionController mSubController = SubscriptionController.getInstance();
    protected SubscriptionController mSubController = SubscriptionController.getInstance();

    private SubscriptionManager mSubMgr;

@@ -207,7 +207,7 @@ public class DctController extends Handler {
        return sDctController;
    }

    private DctController(PhoneProxy[] phones) {
    protected DctController(PhoneProxy[] phones) {
        logd("DctController(): phones.length=" + phones.length);
        if (phones == null || phones.length == 0) {
            if (phones == null) {
@@ -330,7 +330,7 @@ public class DctController extends Handler {
        return PhoneConstants.APN_REQUEST_STARTED;
    }

    void processRequests() {
    protected void processRequests() {
        logd("processRequests");
        sendMessage(obtainMessage(EVENT_PROCESS_REQUESTS));
    }
@@ -360,7 +360,7 @@ public class DctController extends Handler {
        sendMessage(obtainMessage(EVENT_RETRY_ATTACH, phoneId, 0));
    }

    private void onProcessRequest() {
    protected void onProcessRequest() {
        //process all requests
        //1. Check all requests and find subscription of the top priority
        //   request
@@ -488,9 +488,9 @@ public class DctController extends Handler {
        }
    }

    private void onSettingsChanged() {
    protected void onSettingsChanged() {
        //Sub Selection
        long dataSubId = mSubController.getDefaultDataSubId();
        int dataSubId = mSubController.getDefaultDataSubId();

        int activePhoneId = -1;
        for (int i=0; i<mDcSwitchStateMachine.length; i++) {
@@ -537,7 +537,7 @@ public class DctController extends Handler {
        processRequests();
    }

    private int getTopPriorityRequestPhoneId() {
    protected int getTopPriorityRequestPhoneId() {
        RequestInfo retRequestInfo = null;
        int phoneId = 0;
        int priority = -1;
@@ -665,7 +665,7 @@ public class DctController extends Handler {
        return name;
    }

    private int getRequestPhoneId(NetworkRequest networkRequest) {
    protected int getRequestPhoneId(NetworkRequest networkRequest) {
        String specifier = networkRequest.networkCapabilities.getNetworkSpecifier();
        int subId;
        if (specifier == null || specifier.equals("")) {
@@ -683,15 +683,15 @@ public class DctController extends Handler {
        return phoneId;
    }

    private static void logd(String s) {
    protected static void logd(String s) {
        if (DBG) Rlog.d(LOG_TAG, s);
    }

    private static void loge(String s) {
    protected static void loge(String s) {
        if (DBG) Rlog.e(LOG_TAG, s);
    }

    private class TelephonyNetworkFactory extends NetworkFactory {
    protected class TelephonyNetworkFactory extends NetworkFactory {
        private final SparseArray<NetworkRequest> mPendingReq = new SparseArray<NetworkRequest>();
        private Phone mPhone;