Loading src/java/com/android/internal/telephony/dataconnection/ApnContext.java +10 −2 Original line number Diff line number Diff line Loading @@ -405,14 +405,22 @@ public class ApnContext { } } /** * Request a network * * @param networkRequest Network request from clients * @param type The request type * @param onHandoverCompleteMsg When request type is handover, this message will be sent when * handover is completed. For normal request, this should be null. */ public void requestNetwork(NetworkRequest networkRequest, @RequestNetworkType int type, Message onCompleteMsg) { Message onHandoverCompleteMsg) { synchronized (mRefCountLock) { mNetworkRequests.add(networkRequest); logl("requestNetwork for " + networkRequest + ", type=" + DcTracker.requestTypeToString(type)); mDcTracker.enableApn(ApnSetting.getApnTypesBitmaskFromString(mApnType), type, onCompleteMsg); onHandoverCompleteMsg); if (mDataConnection != null) { // New network request added. Should re-evaluate properties of // the data connection. For example, the score may change. Loading src/java/com/android/internal/telephony/dataconnection/DcTracker.java +92 −98 Original line number Diff line number Diff line Loading @@ -209,10 +209,9 @@ public class DcTracker extends Handler { */ public static final int RELEASE_TYPE_HANDOVER = 3; /** The extras for request network completion message */ /** The extras for handover completion message */ static final String DATA_COMPLETE_MSG_EXTRA_NETWORK_REQUEST = "extra_network_request"; static final String DATA_COMPLETE_MSG_EXTRA_TRANSPORT_TYPE = "extra_transport_type"; static final String DATA_COMPLETE_MSG_EXTRA_REQUEST_TYPE = "extra_request_type"; static final String DATA_COMPLETE_MSG_EXTRA_SUCCESS = "extra_success"; /** * The flag indicates whether after handover failure, the data connection should remain on the Loading Loading @@ -721,7 +720,7 @@ public class DcTracker extends Handler { * messages to be sent. Using a list because there might be multiple network requests for * the same APN type. */ private final Map<Integer, List<Message>> mRequestNetworkCompletionMsgs = new HashMap<>(); private final Map<Integer, List<Message>> mHandoverCompletionMsgs = new HashMap<>(); //***** Constructor public DcTracker(Phone phone, @TransportType int transportType) { Loading Loading @@ -950,12 +949,24 @@ public class DcTracker extends Handler { mPhone.notifyDataActivity(); } /** * Request a network * * @param networkRequest Network request from clients * @param type The request type * @param onHandoverCompleteMsg When request type is handover, this message will be sent when * handover is completed. For normal request, this should be null. */ public void requestNetwork(NetworkRequest networkRequest, @RequestNetworkType int type, Message onCompleteMsg) { Message onHandoverCompleteMsg) { if (type != REQUEST_TYPE_HANDOVER && onHandoverCompleteMsg != null) { throw new RuntimeException("request network with normal type request type but passing " + "handover complete message."); } final int apnType = ApnContext.getApnTypeFromNetworkRequest(networkRequest); final ApnContext apnContext = mApnContextsByType.get(apnType); if (apnContext != null) { apnContext.requestNetwork(networkRequest, type, onCompleteMsg); apnContext.requestNetwork(networkRequest, type, onHandoverCompleteMsg); } } Loading Loading @@ -1538,7 +1549,7 @@ public class DcTracker extends Handler { if (apnContext.isConnectable()) { log("isConnectable() call trySetupData"); apnContext.setReason(reason); trySetupData(apnContext, REQUEST_TYPE_NORMAL); trySetupData(apnContext, REQUEST_TYPE_NORMAL, null); } } Loading @@ -1549,12 +1560,16 @@ public class DcTracker extends Handler { return isInEcm && !isInImsEcm; } private boolean trySetupData(ApnContext apnContext, @RequestNetworkType int requestType) { private void trySetupData(ApnContext apnContext, @RequestNetworkType int requestType, @Nullable Message onHandoverCompleteMsg) { if (onHandoverCompleteMsg != null) { addHandoverCompleteMsg(onHandoverCompleteMsg, apnContext.getApnTypeBitmask()); } if (mPhone.getSimulatedRadioControl() != null) { // Assume data is connected on the simulator log("trySetupData: X We're on the simulator; assuming connected retValue=true"); return true; return; } DataConnectionReasons dataConnectionReasons = new DataConnectionReasons(); Loading @@ -1573,7 +1588,31 @@ public class DcTracker extends Handler { } if (DBG) log(logStr); apnContext.requestLog(logStr); if (isDataAllowed) { if (!isDataAllowed) { StringBuilder str = new StringBuilder(); str.append("trySetupData failed. apnContext = [type=" + apnContext.getApnType() + ", mState=" + apnContext.getState() + ", apnEnabled=" + apnContext.isEnabled() + ", mDependencyMet=" + apnContext.isDependencyMet() + "] "); if (!mDataEnabledSettings.isDataEnabled()) { str.append("isDataEnabled() = false. " + mDataEnabledSettings); } // If this is a data retry, we should set the APN state to FAILED so it won't stay // in RETRYING forever. if (apnContext.getState() == DctConstants.State.RETRYING) { apnContext.setState(DctConstants.State.FAILED); str.append(" Stop retrying."); } if (DBG) log(str.toString()); apnContext.requestLog(str.toString()); sendHandoverCompleteMessages(apnContext.getApnTypeBitmask(), false, false); return; } if (apnContext.getState() == DctConstants.State.FAILED) { String str = "trySetupData: make a FAILED ApnContext IDLE so its reusable"; if (DBG) log(str); Loading @@ -1595,7 +1634,9 @@ public class DcTracker extends Handler { String str = "trySetupData: X No APN found retValue=false"; if (DBG) log(str); apnContext.requestLog(str); return false; sendHandoverCompleteMessages(apnContext.getApnTypeBitmask(), false, false); return; } else { apnContext.setWaitingApns(waitingApns); if (DBG) { Loading @@ -1605,32 +1646,8 @@ public class DcTracker extends Handler { } } boolean retValue = setupData(apnContext, radioTech, requestType); if (DBG) log("trySetupData: X retValue=" + retValue); return retValue; } else { StringBuilder str = new StringBuilder(); str.append("trySetupData failed. apnContext = [type=" + apnContext.getApnType() + ", mState=" + apnContext.getState() + ", apnEnabled=" + apnContext.isEnabled() + ", mDependencyMet=" + apnContext.isDependencyMet() + "] "); if (!mDataEnabledSettings.isDataEnabled()) { str.append("isDataEnabled() = false. " + mDataEnabledSettings); } // If this is a data retry, we should set the APN state to FAILED so it won't stay // in RETRYING forever. if (apnContext.getState() == DctConstants.State.RETRYING) { apnContext.setState(DctConstants.State.FAILED); str.append(" Stop retrying."); } if (DBG) log(str.toString()); apnContext.requestLog(str.toString()); return false; if (!setupData(apnContext, radioTech, requestType)) { sendHandoverCompleteMessages(apnContext.getApnTypeBitmask(), false, false); } } Loading Loading @@ -2552,38 +2569,33 @@ public class DcTracker extends Handler { return apnSetting.canHandleType(apnType); } private void addRequestNetworkCompleteMsg(Message onCompleteMsg, private void addHandoverCompleteMsg(Message onCompleteMsg, @ApnType int apnType) { if (onCompleteMsg != null) { List<Message> messageList = mRequestNetworkCompletionMsgs.get(apnType); List<Message> messageList = mHandoverCompletionMsgs.get(apnType); if (messageList == null) messageList = new ArrayList<>(); messageList.add(onCompleteMsg); mRequestNetworkCompletionMsgs.put(apnType, messageList); mHandoverCompletionMsgs.put(apnType, messageList); } } private void sendRequestNetworkCompleteMessages(@ApnType int apnType, @RequestNetworkType int requestType, boolean success, private void sendHandoverCompleteMessages(@ApnType int apnType, boolean success, boolean fallbackOnFailedHandover) { List<Message> messageList = mRequestNetworkCompletionMsgs.get(apnType); List<Message> messageList = mHandoverCompletionMsgs.get(apnType); if (messageList != null) { for (Message msg : messageList) { sendRequestNetworkCompleteMsg(msg, success, mTransportType, requestType, fallbackOnFailedHandover); sendHandoverCompleteMsg(msg, success, mTransportType, fallbackOnFailedHandover); } messageList.clear(); } } private void sendRequestNetworkCompleteMsg(Message message, boolean success, @TransportType int transport, @RequestNetworkType int requestType, boolean doFallbackOnFailedHandover) { private void sendHandoverCompleteMsg(Message message, boolean success, @TransportType int transport, boolean doFallbackOnFailedHandover) { if (message == null) return; Bundle b = message.getData(); b.putBoolean(DATA_COMPLETE_MSG_EXTRA_SUCCESS, success); b.putInt(DATA_COMPLETE_MSG_EXTRA_REQUEST_TYPE, requestType); b.putInt(DATA_COMPLETE_MSG_EXTRA_TRANSPORT_TYPE, transport); b.putBoolean(DATA_COMPLETE_MSG_EXTRA_HANDOVER_FAILURE_FALLBACK, doFallbackOnFailedHandover); message.sendToTarget(); Loading Loading @@ -2633,18 +2645,19 @@ public class DcTracker extends Handler { } public void enableApn(@ApnType int apnType, @RequestNetworkType int requestType, Message onCompleteMsg) { Message onHandoverCompleteMsg) { sendMessage(obtainMessage(DctConstants.EVENT_ENABLE_APN, apnType, requestType, onCompleteMsg)); onHandoverCompleteMsg)); } private void onEnableApn(@ApnType int apnType, @RequestNetworkType int requestType, Message onCompleteMsg) { Message onHandoverCompleteMsg) { ApnContext apnContext = mApnContextsByType.get(apnType); if (apnContext == null) { loge("onEnableApn(" + apnType + "): NO ApnContext"); sendRequestNetworkCompleteMsg(onCompleteMsg, false, mTransportType, requestType, false); if (onHandoverCompleteMsg != null) { sendHandoverCompleteMsg(onHandoverCompleteMsg, false, mTransportType, false); } return; } Loading @@ -2659,8 +2672,9 @@ public class DcTracker extends Handler { str = "onEnableApn: dependency is not met."; if (DBG) log(str); apnContext.requestLog(str); sendRequestNetworkCompleteMsg(onCompleteMsg, false, mTransportType, requestType, false); if (onHandoverCompleteMsg != null) { sendHandoverCompleteMsg(onHandoverCompleteMsg, false, mTransportType, false); } return; } Loading @@ -2668,24 +2682,15 @@ public class DcTracker extends Handler { DctConstants.State state = apnContext.getState(); switch(state) { case CONNECTING: if (DBG) log("onEnableApn: 'CONNECTING' so return"); apnContext.requestLog("onEnableApn state=CONNECTING, so return"); addRequestNetworkCompleteMsg(onCompleteMsg, apnType); return; case CONNECTED: if (DBG) log("onEnableApn: 'CONNECTED' so return"); // Don't add to local log since this is so common sendRequestNetworkCompleteMsg(onCompleteMsg, true, mTransportType, requestType, false); return; case DISCONNECTING: if (DBG) log("onEnableApn: 'DISCONNECTING' so return"); apnContext.requestLog("onEnableApn state=DISCONNECTING, so return"); sendRequestNetworkCompleteMsg(onCompleteMsg, false, mTransportType, requestType, false); if (DBG) log("onEnableApn: APN in " + state + " state. Exit now."); if (onHandoverCompleteMsg != null) { sendHandoverCompleteMsg(onHandoverCompleteMsg, false, mTransportType, false); } return; case IDLE: // fall through: this is unexpected but if it happens cleanup and try setup case FAILED: case RETRYING: // We're "READY" but not active so disconnect (cleanup = true) and Loading @@ -2707,12 +2712,7 @@ public class DcTracker extends Handler { apnContext.resetErrorCodeRetries(); if (mConfigReady || apnContext.getApnTypeBitmask() == ApnSetting.TYPE_EMERGENCY) { if (trySetupData(apnContext, requestType)) { addRequestNetworkCompleteMsg(onCompleteMsg, apnType); } else { sendRequestNetworkCompleteMsg(onCompleteMsg, false, mTransportType, requestType, false); } trySetupData(apnContext, requestType, onHandoverCompleteMsg); } else { log("onEnableApn: config not ready yet."); } Loading Loading @@ -3003,7 +3003,7 @@ public class DcTracker extends Handler { + DataCallResponse.failureModeToString(handoverFailureMode)); } else if (handoverFailureMode != DataCallResponse.HANDOVER_FAILURE_MODE_NO_FALLBACK_RETRY_HANDOVER) { sendRequestNetworkCompleteMessages(apnContext.getApnTypeBitmask(), requestType, success, sendHandoverCompleteMessages(apnContext.getApnTypeBitmask(), success, fallbackOnFailedHandover); } Loading Loading @@ -3218,8 +3218,8 @@ public class DcTracker extends Handler { log("onDataSetupCompleteError: Stop retrying APNs. delay=" + delay + ", requestType=" + requestTypeToString(requestType)); //send request network complete messages as needed sendRequestNetworkCompleteMessages(apnContext.getApnTypeBitmask(), requestType, false, fallbackOnFailedHandover); sendHandoverCompleteMessages(apnContext.getApnTypeBitmask(), false, fallbackOnFailedHandover); } } Loading Loading @@ -3777,7 +3777,7 @@ public class DcTracker extends Handler { apnContext = mApnContextsByType.get(ApnSetting.TYPE_DEFAULT); if (apnContext != null) { apnContext.setReason(Phone.REASON_PS_RESTRICT_ENABLED); trySetupData(apnContext, REQUEST_TYPE_NORMAL); trySetupData(apnContext, REQUEST_TYPE_NORMAL, null); } else { loge("**** Default ApnContext not found ****"); if (TelephonyUtils.IS_DEBUGGABLE) { Loading @@ -3790,13 +3790,7 @@ public class DcTracker extends Handler { case DctConstants.EVENT_TRY_SETUP_DATA: apnContext = (ApnContext) msg.obj; requestType = msg.arg1; if (!trySetupData(apnContext, requestType)) { // Note that this might be a retry handover request that we need to notify // handover completion. Note if it fails, we will not retry anymore (because // it's due to pre-condition not met) and will not fallback. sendRequestNetworkCompleteMessages(apnContext.getApnTypeBitmask(), requestType, false, false); } trySetupData(apnContext, requestType, null); break; case DctConstants.EVENT_CLEAN_UP_CONNECTION: if (DBG) log("EVENT_CLEAN_UP_CONNECTION"); Loading src/java/com/android/internal/telephony/dataconnection/TelephonyNetworkFactory.java +25 −20 Original line number Diff line number Diff line Loading @@ -193,8 +193,6 @@ public class TelephonyNetworkFactory extends NetworkFactory { } case EVENT_DATA_HANDOVER_COMPLETED: { Bundle bundle = msg.getData(); int requestType = bundle.getInt(DcTracker.DATA_COMPLETE_MSG_EXTRA_REQUEST_TYPE); if (requestType == DcTracker.REQUEST_TYPE_HANDOVER) { NetworkRequest nr = bundle.getParcelable( DcTracker.DATA_COMPLETE_MSG_EXTRA_NETWORK_REQUEST); boolean success = bundle.getBoolean( Loading @@ -210,7 +208,6 @@ public class TelephonyNetworkFactory extends NetworkFactory { } else { logl("Handover completed but cannot find handover entry!"); } } break; } } Loading @@ -222,12 +219,20 @@ public class TelephonyNetworkFactory extends NetworkFactory { return mTransportManager.getCurrentTransport(apnType); } /** * Request network * * @param networkRequest Network request from clients * @param requestType The request type * @param transport Transport type * @param onHandoverCompleteMsg When request type is handover, this message will be sent when * handover is completed. For normal request, this should be null. */ private void requestNetworkInternal(NetworkRequest networkRequest, @RequestNetworkType int requestType, int transport, Message onCompleteMsg) { @RequestNetworkType int requestType, int transport, Message onHandoverCompleteMsg) { if (mPhone.getDcTracker(transport) != null) { mPhone.getDcTracker(transport).requestNetwork(networkRequest, requestType, onCompleteMsg); onHandoverCompleteMsg); } } Loading Loading
src/java/com/android/internal/telephony/dataconnection/ApnContext.java +10 −2 Original line number Diff line number Diff line Loading @@ -405,14 +405,22 @@ public class ApnContext { } } /** * Request a network * * @param networkRequest Network request from clients * @param type The request type * @param onHandoverCompleteMsg When request type is handover, this message will be sent when * handover is completed. For normal request, this should be null. */ public void requestNetwork(NetworkRequest networkRequest, @RequestNetworkType int type, Message onCompleteMsg) { Message onHandoverCompleteMsg) { synchronized (mRefCountLock) { mNetworkRequests.add(networkRequest); logl("requestNetwork for " + networkRequest + ", type=" + DcTracker.requestTypeToString(type)); mDcTracker.enableApn(ApnSetting.getApnTypesBitmaskFromString(mApnType), type, onCompleteMsg); onHandoverCompleteMsg); if (mDataConnection != null) { // New network request added. Should re-evaluate properties of // the data connection. For example, the score may change. Loading
src/java/com/android/internal/telephony/dataconnection/DcTracker.java +92 −98 Original line number Diff line number Diff line Loading @@ -209,10 +209,9 @@ public class DcTracker extends Handler { */ public static final int RELEASE_TYPE_HANDOVER = 3; /** The extras for request network completion message */ /** The extras for handover completion message */ static final String DATA_COMPLETE_MSG_EXTRA_NETWORK_REQUEST = "extra_network_request"; static final String DATA_COMPLETE_MSG_EXTRA_TRANSPORT_TYPE = "extra_transport_type"; static final String DATA_COMPLETE_MSG_EXTRA_REQUEST_TYPE = "extra_request_type"; static final String DATA_COMPLETE_MSG_EXTRA_SUCCESS = "extra_success"; /** * The flag indicates whether after handover failure, the data connection should remain on the Loading Loading @@ -721,7 +720,7 @@ public class DcTracker extends Handler { * messages to be sent. Using a list because there might be multiple network requests for * the same APN type. */ private final Map<Integer, List<Message>> mRequestNetworkCompletionMsgs = new HashMap<>(); private final Map<Integer, List<Message>> mHandoverCompletionMsgs = new HashMap<>(); //***** Constructor public DcTracker(Phone phone, @TransportType int transportType) { Loading Loading @@ -950,12 +949,24 @@ public class DcTracker extends Handler { mPhone.notifyDataActivity(); } /** * Request a network * * @param networkRequest Network request from clients * @param type The request type * @param onHandoverCompleteMsg When request type is handover, this message will be sent when * handover is completed. For normal request, this should be null. */ public void requestNetwork(NetworkRequest networkRequest, @RequestNetworkType int type, Message onCompleteMsg) { Message onHandoverCompleteMsg) { if (type != REQUEST_TYPE_HANDOVER && onHandoverCompleteMsg != null) { throw new RuntimeException("request network with normal type request type but passing " + "handover complete message."); } final int apnType = ApnContext.getApnTypeFromNetworkRequest(networkRequest); final ApnContext apnContext = mApnContextsByType.get(apnType); if (apnContext != null) { apnContext.requestNetwork(networkRequest, type, onCompleteMsg); apnContext.requestNetwork(networkRequest, type, onHandoverCompleteMsg); } } Loading Loading @@ -1538,7 +1549,7 @@ public class DcTracker extends Handler { if (apnContext.isConnectable()) { log("isConnectable() call trySetupData"); apnContext.setReason(reason); trySetupData(apnContext, REQUEST_TYPE_NORMAL); trySetupData(apnContext, REQUEST_TYPE_NORMAL, null); } } Loading @@ -1549,12 +1560,16 @@ public class DcTracker extends Handler { return isInEcm && !isInImsEcm; } private boolean trySetupData(ApnContext apnContext, @RequestNetworkType int requestType) { private void trySetupData(ApnContext apnContext, @RequestNetworkType int requestType, @Nullable Message onHandoverCompleteMsg) { if (onHandoverCompleteMsg != null) { addHandoverCompleteMsg(onHandoverCompleteMsg, apnContext.getApnTypeBitmask()); } if (mPhone.getSimulatedRadioControl() != null) { // Assume data is connected on the simulator log("trySetupData: X We're on the simulator; assuming connected retValue=true"); return true; return; } DataConnectionReasons dataConnectionReasons = new DataConnectionReasons(); Loading @@ -1573,7 +1588,31 @@ public class DcTracker extends Handler { } if (DBG) log(logStr); apnContext.requestLog(logStr); if (isDataAllowed) { if (!isDataAllowed) { StringBuilder str = new StringBuilder(); str.append("trySetupData failed. apnContext = [type=" + apnContext.getApnType() + ", mState=" + apnContext.getState() + ", apnEnabled=" + apnContext.isEnabled() + ", mDependencyMet=" + apnContext.isDependencyMet() + "] "); if (!mDataEnabledSettings.isDataEnabled()) { str.append("isDataEnabled() = false. " + mDataEnabledSettings); } // If this is a data retry, we should set the APN state to FAILED so it won't stay // in RETRYING forever. if (apnContext.getState() == DctConstants.State.RETRYING) { apnContext.setState(DctConstants.State.FAILED); str.append(" Stop retrying."); } if (DBG) log(str.toString()); apnContext.requestLog(str.toString()); sendHandoverCompleteMessages(apnContext.getApnTypeBitmask(), false, false); return; } if (apnContext.getState() == DctConstants.State.FAILED) { String str = "trySetupData: make a FAILED ApnContext IDLE so its reusable"; if (DBG) log(str); Loading @@ -1595,7 +1634,9 @@ public class DcTracker extends Handler { String str = "trySetupData: X No APN found retValue=false"; if (DBG) log(str); apnContext.requestLog(str); return false; sendHandoverCompleteMessages(apnContext.getApnTypeBitmask(), false, false); return; } else { apnContext.setWaitingApns(waitingApns); if (DBG) { Loading @@ -1605,32 +1646,8 @@ public class DcTracker extends Handler { } } boolean retValue = setupData(apnContext, radioTech, requestType); if (DBG) log("trySetupData: X retValue=" + retValue); return retValue; } else { StringBuilder str = new StringBuilder(); str.append("trySetupData failed. apnContext = [type=" + apnContext.getApnType() + ", mState=" + apnContext.getState() + ", apnEnabled=" + apnContext.isEnabled() + ", mDependencyMet=" + apnContext.isDependencyMet() + "] "); if (!mDataEnabledSettings.isDataEnabled()) { str.append("isDataEnabled() = false. " + mDataEnabledSettings); } // If this is a data retry, we should set the APN state to FAILED so it won't stay // in RETRYING forever. if (apnContext.getState() == DctConstants.State.RETRYING) { apnContext.setState(DctConstants.State.FAILED); str.append(" Stop retrying."); } if (DBG) log(str.toString()); apnContext.requestLog(str.toString()); return false; if (!setupData(apnContext, radioTech, requestType)) { sendHandoverCompleteMessages(apnContext.getApnTypeBitmask(), false, false); } } Loading Loading @@ -2552,38 +2569,33 @@ public class DcTracker extends Handler { return apnSetting.canHandleType(apnType); } private void addRequestNetworkCompleteMsg(Message onCompleteMsg, private void addHandoverCompleteMsg(Message onCompleteMsg, @ApnType int apnType) { if (onCompleteMsg != null) { List<Message> messageList = mRequestNetworkCompletionMsgs.get(apnType); List<Message> messageList = mHandoverCompletionMsgs.get(apnType); if (messageList == null) messageList = new ArrayList<>(); messageList.add(onCompleteMsg); mRequestNetworkCompletionMsgs.put(apnType, messageList); mHandoverCompletionMsgs.put(apnType, messageList); } } private void sendRequestNetworkCompleteMessages(@ApnType int apnType, @RequestNetworkType int requestType, boolean success, private void sendHandoverCompleteMessages(@ApnType int apnType, boolean success, boolean fallbackOnFailedHandover) { List<Message> messageList = mRequestNetworkCompletionMsgs.get(apnType); List<Message> messageList = mHandoverCompletionMsgs.get(apnType); if (messageList != null) { for (Message msg : messageList) { sendRequestNetworkCompleteMsg(msg, success, mTransportType, requestType, fallbackOnFailedHandover); sendHandoverCompleteMsg(msg, success, mTransportType, fallbackOnFailedHandover); } messageList.clear(); } } private void sendRequestNetworkCompleteMsg(Message message, boolean success, @TransportType int transport, @RequestNetworkType int requestType, boolean doFallbackOnFailedHandover) { private void sendHandoverCompleteMsg(Message message, boolean success, @TransportType int transport, boolean doFallbackOnFailedHandover) { if (message == null) return; Bundle b = message.getData(); b.putBoolean(DATA_COMPLETE_MSG_EXTRA_SUCCESS, success); b.putInt(DATA_COMPLETE_MSG_EXTRA_REQUEST_TYPE, requestType); b.putInt(DATA_COMPLETE_MSG_EXTRA_TRANSPORT_TYPE, transport); b.putBoolean(DATA_COMPLETE_MSG_EXTRA_HANDOVER_FAILURE_FALLBACK, doFallbackOnFailedHandover); message.sendToTarget(); Loading Loading @@ -2633,18 +2645,19 @@ public class DcTracker extends Handler { } public void enableApn(@ApnType int apnType, @RequestNetworkType int requestType, Message onCompleteMsg) { Message onHandoverCompleteMsg) { sendMessage(obtainMessage(DctConstants.EVENT_ENABLE_APN, apnType, requestType, onCompleteMsg)); onHandoverCompleteMsg)); } private void onEnableApn(@ApnType int apnType, @RequestNetworkType int requestType, Message onCompleteMsg) { Message onHandoverCompleteMsg) { ApnContext apnContext = mApnContextsByType.get(apnType); if (apnContext == null) { loge("onEnableApn(" + apnType + "): NO ApnContext"); sendRequestNetworkCompleteMsg(onCompleteMsg, false, mTransportType, requestType, false); if (onHandoverCompleteMsg != null) { sendHandoverCompleteMsg(onHandoverCompleteMsg, false, mTransportType, false); } return; } Loading @@ -2659,8 +2672,9 @@ public class DcTracker extends Handler { str = "onEnableApn: dependency is not met."; if (DBG) log(str); apnContext.requestLog(str); sendRequestNetworkCompleteMsg(onCompleteMsg, false, mTransportType, requestType, false); if (onHandoverCompleteMsg != null) { sendHandoverCompleteMsg(onHandoverCompleteMsg, false, mTransportType, false); } return; } Loading @@ -2668,24 +2682,15 @@ public class DcTracker extends Handler { DctConstants.State state = apnContext.getState(); switch(state) { case CONNECTING: if (DBG) log("onEnableApn: 'CONNECTING' so return"); apnContext.requestLog("onEnableApn state=CONNECTING, so return"); addRequestNetworkCompleteMsg(onCompleteMsg, apnType); return; case CONNECTED: if (DBG) log("onEnableApn: 'CONNECTED' so return"); // Don't add to local log since this is so common sendRequestNetworkCompleteMsg(onCompleteMsg, true, mTransportType, requestType, false); return; case DISCONNECTING: if (DBG) log("onEnableApn: 'DISCONNECTING' so return"); apnContext.requestLog("onEnableApn state=DISCONNECTING, so return"); sendRequestNetworkCompleteMsg(onCompleteMsg, false, mTransportType, requestType, false); if (DBG) log("onEnableApn: APN in " + state + " state. Exit now."); if (onHandoverCompleteMsg != null) { sendHandoverCompleteMsg(onHandoverCompleteMsg, false, mTransportType, false); } return; case IDLE: // fall through: this is unexpected but if it happens cleanup and try setup case FAILED: case RETRYING: // We're "READY" but not active so disconnect (cleanup = true) and Loading @@ -2707,12 +2712,7 @@ public class DcTracker extends Handler { apnContext.resetErrorCodeRetries(); if (mConfigReady || apnContext.getApnTypeBitmask() == ApnSetting.TYPE_EMERGENCY) { if (trySetupData(apnContext, requestType)) { addRequestNetworkCompleteMsg(onCompleteMsg, apnType); } else { sendRequestNetworkCompleteMsg(onCompleteMsg, false, mTransportType, requestType, false); } trySetupData(apnContext, requestType, onHandoverCompleteMsg); } else { log("onEnableApn: config not ready yet."); } Loading Loading @@ -3003,7 +3003,7 @@ public class DcTracker extends Handler { + DataCallResponse.failureModeToString(handoverFailureMode)); } else if (handoverFailureMode != DataCallResponse.HANDOVER_FAILURE_MODE_NO_FALLBACK_RETRY_HANDOVER) { sendRequestNetworkCompleteMessages(apnContext.getApnTypeBitmask(), requestType, success, sendHandoverCompleteMessages(apnContext.getApnTypeBitmask(), success, fallbackOnFailedHandover); } Loading Loading @@ -3218,8 +3218,8 @@ public class DcTracker extends Handler { log("onDataSetupCompleteError: Stop retrying APNs. delay=" + delay + ", requestType=" + requestTypeToString(requestType)); //send request network complete messages as needed sendRequestNetworkCompleteMessages(apnContext.getApnTypeBitmask(), requestType, false, fallbackOnFailedHandover); sendHandoverCompleteMessages(apnContext.getApnTypeBitmask(), false, fallbackOnFailedHandover); } } Loading Loading @@ -3777,7 +3777,7 @@ public class DcTracker extends Handler { apnContext = mApnContextsByType.get(ApnSetting.TYPE_DEFAULT); if (apnContext != null) { apnContext.setReason(Phone.REASON_PS_RESTRICT_ENABLED); trySetupData(apnContext, REQUEST_TYPE_NORMAL); trySetupData(apnContext, REQUEST_TYPE_NORMAL, null); } else { loge("**** Default ApnContext not found ****"); if (TelephonyUtils.IS_DEBUGGABLE) { Loading @@ -3790,13 +3790,7 @@ public class DcTracker extends Handler { case DctConstants.EVENT_TRY_SETUP_DATA: apnContext = (ApnContext) msg.obj; requestType = msg.arg1; if (!trySetupData(apnContext, requestType)) { // Note that this might be a retry handover request that we need to notify // handover completion. Note if it fails, we will not retry anymore (because // it's due to pre-condition not met) and will not fallback. sendRequestNetworkCompleteMessages(apnContext.getApnTypeBitmask(), requestType, false, false); } trySetupData(apnContext, requestType, null); break; case DctConstants.EVENT_CLEAN_UP_CONNECTION: if (DBG) log("EVENT_CLEAN_UP_CONNECTION"); Loading
src/java/com/android/internal/telephony/dataconnection/TelephonyNetworkFactory.java +25 −20 Original line number Diff line number Diff line Loading @@ -193,8 +193,6 @@ public class TelephonyNetworkFactory extends NetworkFactory { } case EVENT_DATA_HANDOVER_COMPLETED: { Bundle bundle = msg.getData(); int requestType = bundle.getInt(DcTracker.DATA_COMPLETE_MSG_EXTRA_REQUEST_TYPE); if (requestType == DcTracker.REQUEST_TYPE_HANDOVER) { NetworkRequest nr = bundle.getParcelable( DcTracker.DATA_COMPLETE_MSG_EXTRA_NETWORK_REQUEST); boolean success = bundle.getBoolean( Loading @@ -210,7 +208,6 @@ public class TelephonyNetworkFactory extends NetworkFactory { } else { logl("Handover completed but cannot find handover entry!"); } } break; } } Loading @@ -222,12 +219,20 @@ public class TelephonyNetworkFactory extends NetworkFactory { return mTransportManager.getCurrentTransport(apnType); } /** * Request network * * @param networkRequest Network request from clients * @param requestType The request type * @param transport Transport type * @param onHandoverCompleteMsg When request type is handover, this message will be sent when * handover is completed. For normal request, this should be null. */ private void requestNetworkInternal(NetworkRequest networkRequest, @RequestNetworkType int requestType, int transport, Message onCompleteMsg) { @RequestNetworkType int requestType, int transport, Message onHandoverCompleteMsg) { if (mPhone.getDcTracker(transport) != null) { mPhone.getDcTracker(transport).requestNetwork(networkRequest, requestType, onCompleteMsg); onHandoverCompleteMsg); } } Loading