Loading src/java/com/android/internal/telephony/dataconnection/DataConnection.java +5 −14 Original line number Diff line number Diff line Loading @@ -598,24 +598,13 @@ public class DataConnection extends StateMachine { ApnContext apnContext = cp.mApnContext; if (apnContext == alreadySent) continue; if (reason != null) apnContext.setReason(reason); Pair<ApnContext, Integer> pair = new Pair<ApnContext, Integer>(apnContext, cp.mConnectionGeneration); Pair<ApnContext, Integer> pair = new Pair<>(apnContext, cp.mConnectionGeneration); Message msg = mDct.obtainMessage(event, pair); AsyncResult.forMessage(msg); msg.sendToTarget(); } } private void notifyAllOfConnected(String reason) { notifyAllWithEvent(null, DctConstants.EVENT_DATA_SETUP_COMPLETE, reason); } private void notifyAllDisconnectCompleted(@DataFailCause.FailCause int cause) { notifyAllWithEvent(null, DctConstants.EVENT_DISCONNECT_DONE, DataFailCause.toString(cause)); } /** * Send the connectionCompletedMsg. * Loading Loading @@ -1487,7 +1476,8 @@ public class DataConnection extends StateMachine { log("DcInactiveState: enter notifyAllDisconnectCompleted failCause=" + mDcFailCause); } notifyAllDisconnectCompleted(mDcFailCause); notifyAllWithEvent(null, DctConstants.EVENT_DISCONNECT_DONE, DataFailCause.toString(mDcFailCause)); } // Remove ourselves from cid mapping, before clearSettings Loading Loading @@ -1685,7 +1675,8 @@ public class DataConnection extends StateMachine { updateNetworkInfo(); // If we were retrying there maybe more than one, otherwise they'll only be one. notifyAllOfConnected(Phone.REASON_CONNECTED); notifyAllWithEvent(null, DctConstants.EVENT_DATA_SETUP_COMPLETE, Phone.REASON_CONNECTED); mPhone.getCallTracker().registerForVoiceCallStarted(getHandler(), DataConnection.EVENT_DATA_CONNECTION_VOICE_CALL_STARTED, null); Loading src/java/com/android/internal/telephony/dataconnection/DcTracker.java +49 −58 Original line number Diff line number Diff line Loading @@ -2577,15 +2577,8 @@ public class DcTracker extends Handler { * A SETUP (aka bringUp) has completed, possibly with an error. If * there is an error this method will call {@link #onDataSetupCompleteError}. */ private void onDataSetupComplete(AsyncResult ar) { int cause = DataFailCause.UNKNOWN; boolean handleError = false; ApnContext apnContext = getValidApnContext(ar, "onDataSetupComplete"); if (apnContext == null) return; if (ar.exception == null) { private void onDataSetupComplete(ApnContext apnContext, boolean success, int cause) { if (success) { DataConnection dataConnection = apnContext.getDataConnection(); if (RADIO_TESTS) { Loading @@ -2608,8 +2601,7 @@ public class DcTracker extends Handler { } if (dataConnection == null) { log("onDataSetupComplete: no connection to DC, handle as error"); cause = DataFailCause.CONNECTION_TO_DATACONNECTIONAC_BROKEN; handleError = true; onDataSetupCompleteError(apnContext); } else { ApnSetting apn = apnContext.getApnSetting(); if (DBG) { Loading Loading @@ -2720,7 +2712,6 @@ public class DcTracker extends Handler { } } } else { cause = (int) (ar.result); if (DBG) { ApnSetting apn = apnContext.getApnSetting(); log(String.format("onDataSetupComplete: error apn=%s cause=%s", Loading Loading @@ -2756,51 +2747,17 @@ public class DcTracker extends Handler { log("cause = " + cause + ", mark apn as permanent failed. apn = " + apn); apnContext.markApnPermanentFailed(apn); } handleError = true; } if (handleError) { onDataSetupCompleteError(ar); onDataSetupCompleteError(apnContext); } } /** * check for obsolete messages. Return ApnContext if valid, null if not */ private ApnContext getValidApnContext(AsyncResult ar, String logString) { if (ar != null && ar.userObj instanceof Pair) { Pair<ApnContext, Integer>pair = (Pair<ApnContext, Integer>)ar.userObj; ApnContext apnContext = pair.first; if (apnContext != null) { final int generation = apnContext.getConnectionGeneration(); if (DBG) { log("getValidApnContext (" + logString + ") on " + apnContext + " got " + generation + " vs " + pair.second); } if (generation == pair.second) { return apnContext; } else { log("ignoring obsolete " + logString); return null; } } } throw new RuntimeException(logString + ": No apnContext"); } /** * Error has occurred during the SETUP {aka bringUP} request and the DCT * should either try the next waiting APN or start over from the * beginning if the list is empty. Between each SETUP request there will * be a delay defined by {@link #getApnDelay()}. */ private void onDataSetupCompleteError(AsyncResult ar) { ApnContext apnContext = getValidApnContext(ar, "onDataSetupCompleteError"); if (apnContext == null) return; private void onDataSetupCompleteError(ApnContext apnContext) { long delay = apnContext.getDelayForNextApn(mFailFast); // Check if we need to retry or not. Loading Loading @@ -2835,10 +2792,7 @@ public class DcTracker extends Handler { /** * Called when EVENT_DISCONNECT_DONE is received. */ private void onDisconnectDone(AsyncResult ar) { ApnContext apnContext = getValidApnContext(ar, "onDisconnectDone"); if (apnContext == null) return; private void onDisconnectDone(ApnContext apnContext) { if(DBG) log("onDisconnectDone: EVENT_DISCONNECT_DONE apnContext=" + apnContext); apnContext.setState(DctConstants.State.IDLE); Loading Loading @@ -3330,6 +3284,10 @@ public class DcTracker extends Handler { public void handleMessage (Message msg) { if (VDBG) log("handleMessage msg=" + msg); AsyncResult ar; Pair<ApnContext, Integer> pair; ApnContext apnContext; int generation; switch (msg.what) { case DctConstants.EVENT_RECORDS_LOADED: // If onRecordsLoadedOrSubIdChanged() is not called here, it should be called on Loading Loading @@ -3387,7 +3345,7 @@ public class DcTracker extends Handler { cleanUpAllConnectionsInternal(false, Phone.REASON_PS_RESTRICT_ENABLED); mReregisterOnReconnectFailure = false; } ApnContext apnContext = mApnContextsByType.get(ApnSetting.TYPE_DEFAULT); apnContext = mApnContextsByType.get(ApnSetting.TYPE_DEFAULT); if (apnContext != null) { apnContext.setReason(Phone.REASON_PS_RESTRICT_ENABLED); trySetupData(apnContext); Loading Loading @@ -3472,16 +3430,49 @@ public class DcTracker extends Handler { break; case DctConstants.EVENT_DATA_SETUP_COMPLETE: onDataSetupComplete((AsyncResult) msg.obj); ar = (AsyncResult) msg.obj; pair = (Pair<ApnContext, Integer>) ar.userObj; apnContext = pair.first; generation = pair.second; if (apnContext.getConnectionGeneration() == generation) { boolean success = true; int cause = DataFailCause.UNKNOWN; if (ar.exception != null) { success = false; cause = (int) ar.result; } onDataSetupComplete(apnContext, success, cause); } else { loge("EVENT_DATA_SETUP_COMPLETE: Dropped the event because generation " + "did not match."); } break; case DctConstants.EVENT_DATA_SETUP_COMPLETE_ERROR: onDataSetupCompleteError((AsyncResult) msg.obj); ar = (AsyncResult) msg.obj; pair = (Pair<ApnContext, Integer>) ar.userObj; apnContext = pair.first; generation = pair.second; if (apnContext.getConnectionGeneration() == generation) { onDataSetupCompleteError(apnContext); } else { loge("EVENT_DATA_SETUP_COMPLETE_ERROR: Dropped the event because generation " + "did not match."); } break; case DctConstants.EVENT_DISCONNECT_DONE: log("DataConnectionTracker.handleMessage: EVENT_DISCONNECT_DONE msg=" + msg); onDisconnectDone((AsyncResult) msg.obj); log("EVENT_DISCONNECT_DONE msg=" + msg); ar = (AsyncResult) msg.obj; pair = (Pair<ApnContext, Integer>) ar.userObj; apnContext = pair.first; generation = pair.second; if (apnContext.getConnectionGeneration() == generation) { onDisconnectDone(apnContext); } else { loge("EVENT_DISCONNECT_DONE: Dropped the event because generation " + "did not match."); } break; case DctConstants.EVENT_VOICE_CALL_STARTED: Loading Loading @@ -3622,7 +3613,7 @@ public class DcTracker extends Handler { onDataServiceBindingChanged((Boolean) ((AsyncResult) msg.obj).result); break; case DctConstants.EVENT_DATA_ENABLED_CHANGED: AsyncResult ar = (AsyncResult) msg.obj; ar = (AsyncResult) msg.obj; if (ar.result instanceof Pair) { Pair<Boolean, Integer> p = (Pair<Boolean, Integer>) ar.result; boolean enabled = p.first; Loading Loading
src/java/com/android/internal/telephony/dataconnection/DataConnection.java +5 −14 Original line number Diff line number Diff line Loading @@ -598,24 +598,13 @@ public class DataConnection extends StateMachine { ApnContext apnContext = cp.mApnContext; if (apnContext == alreadySent) continue; if (reason != null) apnContext.setReason(reason); Pair<ApnContext, Integer> pair = new Pair<ApnContext, Integer>(apnContext, cp.mConnectionGeneration); Pair<ApnContext, Integer> pair = new Pair<>(apnContext, cp.mConnectionGeneration); Message msg = mDct.obtainMessage(event, pair); AsyncResult.forMessage(msg); msg.sendToTarget(); } } private void notifyAllOfConnected(String reason) { notifyAllWithEvent(null, DctConstants.EVENT_DATA_SETUP_COMPLETE, reason); } private void notifyAllDisconnectCompleted(@DataFailCause.FailCause int cause) { notifyAllWithEvent(null, DctConstants.EVENT_DISCONNECT_DONE, DataFailCause.toString(cause)); } /** * Send the connectionCompletedMsg. * Loading Loading @@ -1487,7 +1476,8 @@ public class DataConnection extends StateMachine { log("DcInactiveState: enter notifyAllDisconnectCompleted failCause=" + mDcFailCause); } notifyAllDisconnectCompleted(mDcFailCause); notifyAllWithEvent(null, DctConstants.EVENT_DISCONNECT_DONE, DataFailCause.toString(mDcFailCause)); } // Remove ourselves from cid mapping, before clearSettings Loading Loading @@ -1685,7 +1675,8 @@ public class DataConnection extends StateMachine { updateNetworkInfo(); // If we were retrying there maybe more than one, otherwise they'll only be one. notifyAllOfConnected(Phone.REASON_CONNECTED); notifyAllWithEvent(null, DctConstants.EVENT_DATA_SETUP_COMPLETE, Phone.REASON_CONNECTED); mPhone.getCallTracker().registerForVoiceCallStarted(getHandler(), DataConnection.EVENT_DATA_CONNECTION_VOICE_CALL_STARTED, null); Loading
src/java/com/android/internal/telephony/dataconnection/DcTracker.java +49 −58 Original line number Diff line number Diff line Loading @@ -2577,15 +2577,8 @@ public class DcTracker extends Handler { * A SETUP (aka bringUp) has completed, possibly with an error. If * there is an error this method will call {@link #onDataSetupCompleteError}. */ private void onDataSetupComplete(AsyncResult ar) { int cause = DataFailCause.UNKNOWN; boolean handleError = false; ApnContext apnContext = getValidApnContext(ar, "onDataSetupComplete"); if (apnContext == null) return; if (ar.exception == null) { private void onDataSetupComplete(ApnContext apnContext, boolean success, int cause) { if (success) { DataConnection dataConnection = apnContext.getDataConnection(); if (RADIO_TESTS) { Loading @@ -2608,8 +2601,7 @@ public class DcTracker extends Handler { } if (dataConnection == null) { log("onDataSetupComplete: no connection to DC, handle as error"); cause = DataFailCause.CONNECTION_TO_DATACONNECTIONAC_BROKEN; handleError = true; onDataSetupCompleteError(apnContext); } else { ApnSetting apn = apnContext.getApnSetting(); if (DBG) { Loading Loading @@ -2720,7 +2712,6 @@ public class DcTracker extends Handler { } } } else { cause = (int) (ar.result); if (DBG) { ApnSetting apn = apnContext.getApnSetting(); log(String.format("onDataSetupComplete: error apn=%s cause=%s", Loading Loading @@ -2756,51 +2747,17 @@ public class DcTracker extends Handler { log("cause = " + cause + ", mark apn as permanent failed. apn = " + apn); apnContext.markApnPermanentFailed(apn); } handleError = true; } if (handleError) { onDataSetupCompleteError(ar); onDataSetupCompleteError(apnContext); } } /** * check for obsolete messages. Return ApnContext if valid, null if not */ private ApnContext getValidApnContext(AsyncResult ar, String logString) { if (ar != null && ar.userObj instanceof Pair) { Pair<ApnContext, Integer>pair = (Pair<ApnContext, Integer>)ar.userObj; ApnContext apnContext = pair.first; if (apnContext != null) { final int generation = apnContext.getConnectionGeneration(); if (DBG) { log("getValidApnContext (" + logString + ") on " + apnContext + " got " + generation + " vs " + pair.second); } if (generation == pair.second) { return apnContext; } else { log("ignoring obsolete " + logString); return null; } } } throw new RuntimeException(logString + ": No apnContext"); } /** * Error has occurred during the SETUP {aka bringUP} request and the DCT * should either try the next waiting APN or start over from the * beginning if the list is empty. Between each SETUP request there will * be a delay defined by {@link #getApnDelay()}. */ private void onDataSetupCompleteError(AsyncResult ar) { ApnContext apnContext = getValidApnContext(ar, "onDataSetupCompleteError"); if (apnContext == null) return; private void onDataSetupCompleteError(ApnContext apnContext) { long delay = apnContext.getDelayForNextApn(mFailFast); // Check if we need to retry or not. Loading Loading @@ -2835,10 +2792,7 @@ public class DcTracker extends Handler { /** * Called when EVENT_DISCONNECT_DONE is received. */ private void onDisconnectDone(AsyncResult ar) { ApnContext apnContext = getValidApnContext(ar, "onDisconnectDone"); if (apnContext == null) return; private void onDisconnectDone(ApnContext apnContext) { if(DBG) log("onDisconnectDone: EVENT_DISCONNECT_DONE apnContext=" + apnContext); apnContext.setState(DctConstants.State.IDLE); Loading Loading @@ -3330,6 +3284,10 @@ public class DcTracker extends Handler { public void handleMessage (Message msg) { if (VDBG) log("handleMessage msg=" + msg); AsyncResult ar; Pair<ApnContext, Integer> pair; ApnContext apnContext; int generation; switch (msg.what) { case DctConstants.EVENT_RECORDS_LOADED: // If onRecordsLoadedOrSubIdChanged() is not called here, it should be called on Loading Loading @@ -3387,7 +3345,7 @@ public class DcTracker extends Handler { cleanUpAllConnectionsInternal(false, Phone.REASON_PS_RESTRICT_ENABLED); mReregisterOnReconnectFailure = false; } ApnContext apnContext = mApnContextsByType.get(ApnSetting.TYPE_DEFAULT); apnContext = mApnContextsByType.get(ApnSetting.TYPE_DEFAULT); if (apnContext != null) { apnContext.setReason(Phone.REASON_PS_RESTRICT_ENABLED); trySetupData(apnContext); Loading Loading @@ -3472,16 +3430,49 @@ public class DcTracker extends Handler { break; case DctConstants.EVENT_DATA_SETUP_COMPLETE: onDataSetupComplete((AsyncResult) msg.obj); ar = (AsyncResult) msg.obj; pair = (Pair<ApnContext, Integer>) ar.userObj; apnContext = pair.first; generation = pair.second; if (apnContext.getConnectionGeneration() == generation) { boolean success = true; int cause = DataFailCause.UNKNOWN; if (ar.exception != null) { success = false; cause = (int) ar.result; } onDataSetupComplete(apnContext, success, cause); } else { loge("EVENT_DATA_SETUP_COMPLETE: Dropped the event because generation " + "did not match."); } break; case DctConstants.EVENT_DATA_SETUP_COMPLETE_ERROR: onDataSetupCompleteError((AsyncResult) msg.obj); ar = (AsyncResult) msg.obj; pair = (Pair<ApnContext, Integer>) ar.userObj; apnContext = pair.first; generation = pair.second; if (apnContext.getConnectionGeneration() == generation) { onDataSetupCompleteError(apnContext); } else { loge("EVENT_DATA_SETUP_COMPLETE_ERROR: Dropped the event because generation " + "did not match."); } break; case DctConstants.EVENT_DISCONNECT_DONE: log("DataConnectionTracker.handleMessage: EVENT_DISCONNECT_DONE msg=" + msg); onDisconnectDone((AsyncResult) msg.obj); log("EVENT_DISCONNECT_DONE msg=" + msg); ar = (AsyncResult) msg.obj; pair = (Pair<ApnContext, Integer>) ar.userObj; apnContext = pair.first; generation = pair.second; if (apnContext.getConnectionGeneration() == generation) { onDisconnectDone(apnContext); } else { loge("EVENT_DISCONNECT_DONE: Dropped the event because generation " + "did not match."); } break; case DctConstants.EVENT_VOICE_CALL_STARTED: Loading Loading @@ -3622,7 +3613,7 @@ public class DcTracker extends Handler { onDataServiceBindingChanged((Boolean) ((AsyncResult) msg.obj).result); break; case DctConstants.EVENT_DATA_ENABLED_CHANGED: AsyncResult ar = (AsyncResult) msg.obj; ar = (AsyncResult) msg.obj; if (ar.result instanceof Pair) { Pair<Boolean, Integer> p = (Pair<Boolean, Integer>) ar.result; boolean enabled = p.first; Loading