diff options
5 files changed, 67 insertions, 26 deletions
diff --git a/telephony/java/com/android/internal/telephony/PhoneBase.java b/telephony/java/com/android/internal/telephony/PhoneBase.java index 1c03c5a..50dd76a 100644 --- a/telephony/java/com/android/internal/telephony/PhoneBase.java +++ b/telephony/java/com/android/internal/telephony/PhoneBase.java @@ -114,6 +114,7 @@ public abstract class PhoneBase extends Handler implements Phone { boolean mDoesRilSendMultipleCallRing; int mCallRingContinueToken = 0; int mCallRingDelay; + public boolean mIsTheCurrentActivePhone = true; /** * Set a system property, unless we're in unit test mode @@ -226,6 +227,8 @@ public abstract class PhoneBase extends Handler implements Phone { public void dispose() { synchronized(PhoneProxy.lockForRadioTechnologyChange) { mCM.unSetOnCallRing(this); + mDataConnection.onCleanUpConnection(false, REASON_RADIO_TURNED_OFF); + mIsTheCurrentActivePhone = false; } } diff --git a/telephony/java/com/android/internal/telephony/PhoneProxy.java b/telephony/java/com/android/internal/telephony/PhoneProxy.java index b1eaa93..c693ae1 100644 --- a/telephony/java/com/android/internal/telephony/PhoneProxy.java +++ b/telephony/java/com/android/internal/telephony/PhoneProxy.java @@ -23,6 +23,7 @@ import android.content.Intent; import android.content.SharedPreferences; import android.os.Handler; import android.os.Message; +import android.os.SystemProperties; import android.preference.PreferenceManager; import android.telephony.CellLocation; import android.telephony.PhoneStateListener; @@ -40,8 +41,6 @@ import java.util.List; public class PhoneProxy extends Handler implements Phone { public final static Object lockForRadioTechnologyChange = new Object(); -// private static boolean radioTechnologyChangeGsmToCdma = false; -// private static boolean radioTechnologyChangeCdmaToGsm = false; private Phone mActivePhone; private String mOutgoingPhone; @@ -50,12 +49,16 @@ public class PhoneProxy extends Handler implements Phone { private IccPhoneBookInterfaceManagerProxy mIccPhoneBookInterfaceManagerProxy; private PhoneSubInfoProxy mPhoneSubInfoProxy; + private boolean mResetModemOnRadioTechnologyChange = false; + private static final int EVENT_RADIO_TECHNOLOGY_CHANGED = 1; private static final String LOG_TAG = "PHONE"; //***** Class Methods public PhoneProxy(Phone phone) { mActivePhone = phone; + mResetModemOnRadioTechnologyChange = SystemProperties.getBoolean( + TelephonyProperties.PROPERTY_RESET_ON_RADIO_TECH_CHANGE, false); mIccSmsInterfaceManagerProxy = new IccSmsInterfaceManagerProxy( phone.getIccSmsInterfaceManager()); mIccPhoneBookInterfaceManagerProxy = new IccPhoneBookInterfaceManagerProxy( @@ -74,12 +77,15 @@ public class PhoneProxy extends Handler implements Phone { mOutgoingPhone = ((PhoneBase)mActivePhone).getPhoneName(); logd("Switching phone from " + mOutgoingPhone + "Phone to " + (mOutgoingPhone.equals("GSM") ? "CDMAPhone" : "GSMPhone") ); - boolean oldPowerState = false; //old power state to off - if (mCommandsInterface.getRadioState().isOn()) { - oldPowerState = true; - logd("Setting Radio Power to Off"); - mCommandsInterface.setRadioPower(false, null); + boolean oldPowerState = false; // old power state to off + if (mResetModemOnRadioTechnologyChange) { + if (mCommandsInterface.getRadioState().isOn()) { + oldPowerState = true; + logd("Setting Radio Power to Off"); + mCommandsInterface.setRadioPower(false, null); + } } + if(mOutgoingPhone.equals("GSM")) { logd("Make a new CDMAPhone and destroy the old GSMPhone."); @@ -93,8 +99,6 @@ public class PhoneProxy extends Handler implements Phone { //System.gc(); mActivePhone = PhoneFactory.getCdmaPhone(); - logd("Resetting Radio"); - mCommandsInterface.setRadioPower(oldPowerState, null); ((GSMPhone)oldPhone).removeReferences(); oldPhone = null; } else { @@ -111,12 +115,15 @@ public class PhoneProxy extends Handler implements Phone { //System.gc(); mActivePhone = PhoneFactory.getGsmPhone(); - logd("Resetting Radio:"); - mCommandsInterface.setRadioPower(oldPowerState, null); ((CDMAPhone)oldPhone).removeReferences(); oldPhone = null; } + if (mResetModemOnRadioTechnologyChange) { + logd("Resetting Radio"); + mCommandsInterface.setRadioPower(oldPowerState, null); + } + //Set the new interfaces in the proxy's mIccSmsInterfaceManagerProxy.setmIccSmsInterfaceManager( mActivePhone.getIccSmsInterfaceManager()); diff --git a/telephony/java/com/android/internal/telephony/TelephonyProperties.java b/telephony/java/com/android/internal/telephony/TelephonyProperties.java index 56d84bd..a113787 100644 --- a/telephony/java/com/android/internal/telephony/TelephonyProperties.java +++ b/telephony/java/com/android/internal/telephony/TelephonyProperties.java @@ -141,4 +141,10 @@ public interface TelephonyProperties * Property to override DEFAULT_WAKE_LOCK_TIMEOUT */ static final String PROPERTY_WAKE_LOCK_TIMEOUT = "ro.ril.wake_lock_timeout"; + + /** + * Set to true to indicate that the modem needs to be reset + * when there is a radio technology change. + */ + static final String PROPERTY_RESET_ON_RADIO_TECH_CHANGE = "persist.radio.reset_on_switch"; } diff --git a/telephony/java/com/android/internal/telephony/cdma/CdmaDataConnectionTracker.java b/telephony/java/com/android/internal/telephony/cdma/CdmaDataConnectionTracker.java index 9bc5e8e..b63b0c4 100644 --- a/telephony/java/com/android/internal/telephony/cdma/CdmaDataConnectionTracker.java +++ b/telephony/java/com/android/internal/telephony/cdma/CdmaDataConnectionTracker.java @@ -871,7 +871,7 @@ public final class CdmaDataConnectionTracker extends DataConnectionTracker { EventLog.writeEvent(TelephonyEventLog.EVENT_LOG_CDMA_DATA_DROP, val); } - protected void onDataStateChanged (AsyncResult ar) { + protected void onDataStateChanged(AsyncResult ar) { ArrayList<DataCallState> dataCallStates = (ArrayList<DataCallState>)(ar.result); if (ar.exception != null) { @@ -882,32 +882,46 @@ public final class CdmaDataConnectionTracker extends DataConnectionTracker { } if (state == State.CONNECTED) { - if (dataCallStates.size() >= 1) { - switch (dataCallStates.get(0).active) { + boolean isActiveOrDormantConnectionPresent = false; + int connectionState = DATA_CONNECTION_ACTIVE_PH_LINK_INACTIVE; + + // Check for an active or dormant connection element in + // the DATA_CALL_LIST array + for (int index = 0; index < dataCallStates.size(); index++) { + connectionState = dataCallStates.get(index).active; + if (connectionState != DATA_CONNECTION_ACTIVE_PH_LINK_INACTIVE) { + isActiveOrDormantConnectionPresent = true; + break; + } + } + + if (!isActiveOrDormantConnectionPresent) { + // No active or dormant connection + Log.i(LOG_TAG, "onDataStateChanged: No active connection" + + "state is CONNECTED, disconnecting/cleanup"); + writeEventLogCdmaDataDrop(); + cleanUpConnection(true, null); + return; + } + + switch (connectionState) { case DATA_CONNECTION_ACTIVE_PH_LINK_UP: Log.v(LOG_TAG, "onDataStateChanged: active=LINK_ACTIVE && CONNECTED, ignore"); activity = Activity.NONE; phone.notifyDataActivity(); + startNetStatPoll(); break; - case DATA_CONNECTION_ACTIVE_PH_LINK_INACTIVE: - Log.v(LOG_TAG, - "onDataStateChanged active=LINK_INACTIVE && CONNECTED, disconnecting/cleanup"); - writeEventLogCdmaDataDrop(); - cleanUpConnection(true, null); - break; + case DATA_CONNECTION_ACTIVE_PH_LINK_DOWN: Log.v(LOG_TAG, "onDataStateChanged active=LINK_DOWN && CONNECTED, dormant"); activity = Activity.DORMANT; phone.notifyDataActivity(); + stopNetStatPoll(); break; + default: Log.v(LOG_TAG, "onDataStateChanged: IGNORE unexpected DataCallState.active=" - + dataCallStates.get(0).active); - } - } else { - Log.v(LOG_TAG, "onDataStateChanged: network disconnected, clean up"); - writeEventLogCdmaDataDrop(); - cleanUpConnection(true, null); + + connectionState); } } else { // TODO: Do we need to do anything? @@ -954,6 +968,11 @@ public final class CdmaDataConnectionTracker extends DataConnectionTracker { public void handleMessage (Message msg) { + if (!phone.mIsTheCurrentActivePhone) { + Log.d(LOG_TAG, "Ignore CDMA msgs since CDMA phone is inactive"); + return; + } + switch (msg.what) { case EVENT_RECORDS_LOADED: onRecordsLoaded(); diff --git a/telephony/java/com/android/internal/telephony/gsm/GsmDataConnectionTracker.java b/telephony/java/com/android/internal/telephony/gsm/GsmDataConnectionTracker.java index d014a7e..494d0e0 100644 --- a/telephony/java/com/android/internal/telephony/gsm/GsmDataConnectionTracker.java +++ b/telephony/java/com/android/internal/telephony/gsm/GsmDataConnectionTracker.java @@ -1454,6 +1454,12 @@ public final class GsmDataConnectionTracker extends DataConnectionTracker { public void handleMessage (Message msg) { if (DBG) Log.d(LOG_TAG,"GSMDataConnTrack handleMessage "+msg); + + if (!mGsmPhone.mIsTheCurrentActivePhone) { + Log.d(LOG_TAG, "Ignore GSM msgs since GSM phone is inactive"); + return; + } + switch (msg.what) { case EVENT_RECORDS_LOADED: onRecordsLoaded(); |