diff options
author | Wink Saville <wink@google.com> | 2011-05-19 11:28:36 -0700 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2011-05-19 11:28:36 -0700 |
commit | 09ded82b784b9f6e01d4cd4298097fd2b459560b (patch) | |
tree | 09697eaf442ec304b66091f8114f86355796fa2a /telephony | |
parent | 0a36cec642fb58e295d0608026890d95d0ae3cc0 (diff) | |
parent | ab5baa1d5fbd433e4c391ea06d177aa6a6c1c736 (diff) | |
download | frameworks_base-09ded82b784b9f6e01d4cd4298097fd2b459560b.zip frameworks_base-09ded82b784b9f6e01d4cd4298097fd2b459560b.tar.gz frameworks_base-09ded82b784b9f6e01d4cd4298097fd2b459560b.tar.bz2 |
am ab5baa1d: Merge "Reset connection while data state changed." into honeycomb-LTE
* commit 'ab5baa1d5fbd433e4c391ea06d177aa6a6c1c736':
Reset connection while data state changed.
Diffstat (limited to 'telephony')
3 files changed, 83 insertions, 113 deletions
diff --git a/telephony/java/com/android/internal/telephony/ApnContext.java b/telephony/java/com/android/internal/telephony/ApnContext.java index ce1a3b6..496c43c 100644 --- a/telephony/java/com/android/internal/telephony/ApnContext.java +++ b/telephony/java/com/android/internal/telephony/ApnContext.java @@ -85,12 +85,10 @@ public class ApnContext { public synchronized DataConnectionAc getDataConnectionAc() { - log("getDataConnectionAc dcac=" + mDataConnectionAc); return mDataConnectionAc; } public synchronized void setDataConnectionAc(DataConnectionAc dcac) { - log("setDataConnectionAc dcac=" + dcac); mDataConnectionAc = dcac; } diff --git a/telephony/java/com/android/internal/telephony/DataConnection.java b/telephony/java/com/android/internal/telephony/DataConnection.java index 12d19a1..2e781b2 100644 --- a/telephony/java/com/android/internal/telephony/DataConnection.java +++ b/telephony/java/com/android/internal/telephony/DataConnection.java @@ -511,14 +511,14 @@ public abstract class DataConnection extends StateMachine { log("onSetupConnectionCompleted received DataCallState: " + response); cid = response.cid; // set link properties based on data call response - result = response.setLinkProperties(mLinkProperties, - isOkToUseSystemPropertyDns(response)); + result = setLinkProperties(response, mLinkProperties); } return result; } - private boolean isOkToUseSystemPropertyDns(DataCallState response) { + private DataCallState.SetupResult setLinkProperties(DataCallState response, + LinkProperties lp) { // Check if system property dns usable boolean okToUseSystemPropertyDns = false; String propertyPrefix = "net." + response.ifname + "."; @@ -526,7 +526,9 @@ public abstract class DataConnection extends StateMachine { dnsServers[0] = SystemProperties.get(propertyPrefix + "dns1"); dnsServers[1] = SystemProperties.get(propertyPrefix + "dns2"); okToUseSystemPropertyDns = isDnsOk(dnsServers); - return okToUseSystemPropertyDns; + + // set link properties based on data call response + return response.setLinkProperties(lp, okToUseSystemPropertyDns); } private boolean updateLinkProperty(DataCallState newState) { @@ -535,29 +537,25 @@ public abstract class DataConnection extends StateMachine { if (newState == null) return changed; DataCallState.SetupResult result; - LinkProperties linkProperties = new LinkProperties(); + LinkProperties newLp = new LinkProperties(); // set link properties based on data call response - result = newState.setLinkProperties(linkProperties, - isOkToUseSystemPropertyDns(newState)); - + result = setLinkProperties(newState, newLp); if (result != DataCallState.SetupResult.SUCCESS) { - log("updateLinkProperty failed : " + result); + if (DBG) log("UpdateLinkProperty failed : " + result); return changed; } + // copy HTTP proxy as it is not part DataCallState. + newLp.setHttpProxy(mLinkProperties.getHttpProxy()); - if (mLinkProperties != null) { - // Before comparison, copy HTTP proxy from the original - // as it is not part DataCallState. - linkProperties.setHttpProxy(mLinkProperties.getHttpProxy()); - if (!mLinkProperties.equals(linkProperties)) { - mLinkProperties = linkProperties; - changed = true; - } - } else { - mLinkProperties = linkProperties; + if (DBG) log("old LP=" + mLinkProperties); + if (DBG) log("new LP=" + newLp); + + if (mLinkProperties == null || !mLinkProperties.equals(newLp)) { + mLinkProperties = newLp; changed = true; } + return changed; } @@ -635,8 +633,9 @@ public abstract class DataConnection extends StateMachine { DataCallState newState = (DataCallState) msg.obj; int updated = updateLinkProperty(newState) ? 1 : 0; if (DBG) { - log("REQ_UPDATE_LINK_PROPERTIES_DATA_CALL_STATE updated=" + updated + - " newState=" + newState); + log("REQ_UPDATE_LINK_PROPERTIES_DATA_CALL_STATE updated=" + + (updated == 1) + + " newState=" + newState); } mAc.replyToMessage(msg, DataConnectionAc.RSP_UPDATE_LINK_PROPERTIES_DATA_CALL_STATE, diff --git a/telephony/java/com/android/internal/telephony/gsm/GsmDataConnectionTracker.java b/telephony/java/com/android/internal/telephony/gsm/GsmDataConnectionTracker.java index 49b626e..6b4054a 100644 --- a/telephony/java/com/android/internal/telephony/gsm/GsmDataConnectionTracker.java +++ b/telephony/java/com/android/internal/telephony/gsm/GsmDataConnectionTracker.java @@ -970,32 +970,6 @@ public final class GsmDataConnectionTracker extends DataConnectionTracker { return true; } - private boolean dataCallStatesHasCID (ArrayList<DataCallState> states, int cid) { - for (int i = 0, s = states.size() ; i < s ; i++) { - if (states.get(i).cid == cid) return true; - } - return false; - } - - private boolean dataCallStatesHasActiveCID (ArrayList<DataCallState> states, int cid) { - for (int i = 0, s = states.size() ; i < s ; i++) { - if ((states.get(i).cid == cid) && (states.get(i).active != 0)) { - return true; - } - } - - return false; - } - - private DataCallState findDataCallStateByCID (ArrayList<DataCallState> states, int cid) { - for (int i = 0, s = states.size() ; i < s ; i++) { - if (states.get(i).cid == cid) { - return states.get(i); - } - } - return null; - } - /** * Handles changes to the APN database. */ @@ -1023,15 +997,13 @@ public final class GsmDataConnectionTracker extends DataConnectionTracker { } /** - * @param explicitPoll if true, indicates that *we* polled for this - * update while state == CONNECTED rather than having it delivered - * via an unsolicited response (which could have happened at any - * previous state + * @param ar is the result of RIL_REQUEST_DATA_CALL_LIST + * or RIL_UNSOL_DATA_CALL_LIST_CHANGED */ private void onDataStateChanged (AsyncResult ar) { ArrayList<DataCallState> dataCallStates; - if (DBG) log("onDataStateChanged(ar) E"); + if (DBG) log("onDataStateChanged(ar): E"); dataCallStates = (ArrayList<DataCallState>)(ar.result); if (ar.exception != null) { @@ -1042,78 +1014,79 @@ public final class GsmDataConnectionTracker extends DataConnectionTracker { return; } - for (ApnContext apnContext : mApnContexts.values()) { - onDataStateChanged(dataCallStates, apnContext); - } - if (DBG) log("onDataStateChanged(ar) X"); - } - - private void onDataStateChanged (ArrayList<DataCallState> dataCallStates, - ApnContext apnContext) { - if (DBG) log("onDataStateChanged(dataCallState, apnContext): apnContext=" + apnContext); - - if (apnContext == null) { - // Should not happen - if (DBG) log("onDataStateChanged(dataCallState, apnContext): ignore apnContext=null"); - return; + // Create a hash map to store the dataCallState of each call id + // TODO: Depends on how frequent the DATA_CALL_LIST got updated, + // may cache response to reduce comparison. + HashMap<Integer, DataCallState> response; + response = new HashMap<Integer, DataCallState>(); + if (DBG) log("onDataStateChanged(ar): DataCallState size=" + dataCallStates.size()); + for (DataCallState dc : dataCallStates) { + response.put(dc.cid, dc); + if (DBG) log("onDataStateChanged(ar): " + dc.cid + ": " + dc.toString()); } - if (apnContext.getState() == State.CONNECTED) { - // The way things are supposed to work, the PDP list - // should not contain the CID after it disconnects. - // However, the way things really work, sometimes the PDP - // context is still listed with active = false, which - // makes it hard to distinguish an activating context from - // an activated-and-then deactivated one. + // For each connected apn, check if there is a matched active + // data call state, which has the same link properties. + if (DBG) log(" ApnContext size=" + mApnContexts.values().size()); + for (ApnContext apnContext : mApnContexts.values()) { + if (DBG){ + log("onDataStateChanged(ar): " + apnContext.toString()); + if (apnContext.getDataConnection() != null) { + log("onDataStateChanged(ar): " + apnContext.getDataConnection().toString()); + } + } DataConnectionAc dcac = apnContext.getDataConnectionAc(); if (dcac == null) { - if (DBG) log("onDataStateChanged(dataCallState, apnContext): dcac==null BAD NEWS"); - return; + continue; } - int cid = dcac.getCidSync(); - if (!dataCallStatesHasCID(dataCallStates, cid)) { - // It looks like the PDP context has deactivated. - // Tear everything down and try to reconnect. + int connectionId = dcac.getCidSync(); - if (DBG) { - log("onDataStateChanged(dataCallStates,apnContext) " + - "PDP connection has dropped. Reconnecting"); + if (apnContext.getState() == State.CONNECTED) { + // The way things are supposed to work, the PDP list + // should not contain the CID after it disconnects. + // However, the way things really work, sometimes the PDP + // context is still listed with active = false, which + // makes it hard to distinguish an activating context from + // an activated-and-then de-activated one. + if (response.containsKey(connectionId)) { + DataCallState newState = response.get(connectionId); + if (DBG) log("onDataStateChanged(ar): Found ConnId=" + connectionId + + " newState=" + newState.toString()); + if (newState.active != 0) { + boolean changed + = dcac.updateLinkPropertiesDataCallStateSync(newState); + if (changed) { + if (DBG) log("onDataStateChanged(ar): Found and changed, notify"); + mPhone.notifyDataConnection(Phone.REASON_LINK_PROPERTIES_CHANGED, + apnContext.getApnType()); + // Temporary hack, if false we'll reset connections and at this + // time a transition from CDMA -> Global fails. The DEACTIVATE + // fails with a GENERIC_FAILURE and the VZWINTERNET connection is + // never setup. @see bug/ + if (SystemProperties.getBoolean("telephony.ignore-state-changes", + true)) { + log("onDataStateChanged(ar): STOPSHIP don't reset, continue"); + continue; + } + } else { + if (DBG) log("onDataStateChanged(ar): Found but no change, skip"); + continue; + } + } } - // Add an event log when the network drops PDP - int cellLocationId = getCellLocationId(); - EventLog.writeEvent(EventLogTags.PDP_NETWORK_DROP, cellLocationId, - TelephonyManager.getDefault().getNetworkType()); - - cleanUpConnection(true, apnContext); - } else if (!dataCallStatesHasActiveCID(dataCallStates, - apnContext.getDataConnectionAc().getCidSync())) { - if (DBG) { - log("onDataStateChanged(dataCallStates,apnContext) " + - "PDP connection has dropped (active=false case). Reconnecting"); - } + if (DBG) log("onDataStateChanged(ar): reset connection."); - // Log the network drop on the event log. - int cellLocationId = getCellLocationId(); - EventLog.writeEvent(EventLogTags.PDP_NETWORK_DROP, cellLocationId, + // Add an event log when the network drops PDP + int cid = getCellLocationId(); + EventLog.writeEvent(EventLogTags.PDP_NETWORK_DROP, cid, TelephonyManager.getDefault().getNetworkType()); cleanUpConnection(true, apnContext); - } else { - // Here, data call list has active cid for given ApnContext. - // Check if link property has been updated. - DataCallState state = findDataCallStateByCID(dataCallStates, - apnContext.getDataConnectionAc().getCidSync()); - - if ((dcac != null) && (state != null)){ - if (dcac.updateLinkPropertiesDataCallStateSync(state)) { - // notify data change for this apn - mPhone.notifyDataConnection(Phone.REASON_LINK_PROPERTIES_CHANGED, - apnContext.getApnType()); - } - } } } + + if (DBG) log("onDataStateChanged(ar): X"); } private void notifyDefaultData(ApnContext apnContext) { @@ -2143,7 +2116,7 @@ public final class GsmDataConnectionTracker extends DataConnectionTracker { @Override protected void log(String s) { - Log.d(LOG_TAG, "[GsmDCT] " + s); + Log.d(LOG_TAG, "[GsmDCT] "+ s); } @Override |