diff options
author | Lalit Kansara <lkansara@codeaurora.org> | 2016-12-06 14:44:19 +0530 |
---|---|---|
committer | Lalit Kansara <lkansara@codeaurora.org> | 2016-12-06 14:44:19 +0530 |
commit | 0f732c5a8b59fa71e1ace20337c03e623cd10d2b (patch) | |
tree | 70ea1d7f95c95163848ce24e5beec4e717b6602a /src/java/com/android/internal/telephony/ServiceStateTracker.java | |
parent | a5d7faeb6a3ba74912e0f18d07ec1b6cd2600c3d (diff) | |
parent | 86dd3d2269bc264138cc314b349864dfd8cb115a (diff) | |
download | android_frameworks_opt_telephony-0f732c5a8b59fa71e1ace20337c03e623cd10d2b.tar.gz android_frameworks_opt_telephony-0f732c5a8b59fa71e1ace20337c03e623cd10d2b.tar.bz2 android_frameworks_opt_telephony-0f732c5a8b59fa71e1ace20337c03e623cd10d2b.zip |
Merge commit '86dd3d2269bc264138cc314b349864dfd8cb115a' into remote
Conflicts:
src/java/android/telephony/SmsManager.java
src/java/com/android/internal/telephony/BaseCommands.java
src/java/com/android/internal/telephony/CommandsInterface.java
src/java/com/android/internal/telephony/GsmCdmaCallTracker.java
src/java/com/android/internal/telephony/GsmCdmaConnection.java
src/java/com/android/internal/telephony/GsmCdmaPhone.java
src/java/com/android/internal/telephony/IccProvider.java
src/java/com/android/internal/telephony/ImsSMSDispatcher.java
src/java/com/android/internal/telephony/InboundSmsHandler.java
src/java/com/android/internal/telephony/Phone.java
src/java/com/android/internal/telephony/PhoneInternalInterface.java
src/java/com/android/internal/telephony/RIL.java
src/java/com/android/internal/telephony/ServiceStateTracker.java
src/java/com/android/internal/telephony/TelephonyEventLog.java
src/java/com/android/internal/telephony/cdma/CdmaSMSDispatcher.java
src/java/com/android/internal/telephony/dataconnection/DcTracker.java
src/java/com/android/internal/telephony/imsphone/ImsPhoneCallTracker.java
src/java/com/android/internal/telephony/imsphone/ImsPhoneConnection.java
src/java/com/android/internal/telephony/test/SimulatedCommandsVerifier.java
src/java/com/android/internal/telephony/uicc/AdnRecord.java
src/java/com/android/internal/telephony/uicc/UiccController.java
tests/telephonytests/src/com/android/internal/telephony/GsmCdmaCallTrackerTest.java
tests/telephonytests/src/com/android/internal/telephony/ImsSMSDispatcherTest.java
tests/telephonytests/src/com/android/internal/telephony/ServiceStateTrackerTest.java
tests/telephonytests/src/com/android/internal/telephony/gsm/GsmInboundSmsHandlerTest.java
Change-Id: I353ccef1d324716b13196ff6b3a56a74e091de51
Diffstat (limited to 'src/java/com/android/internal/telephony/ServiceStateTracker.java')
-rw-r--r-- | src/java/com/android/internal/telephony/ServiceStateTracker.java | 428 |
1 files changed, 287 insertions, 141 deletions
diff --git a/src/java/com/android/internal/telephony/ServiceStateTracker.java b/src/java/com/android/internal/telephony/ServiceStateTracker.java index c089b6067..db7f95ac5 100644 --- a/src/java/com/android/internal/telephony/ServiceStateTracker.java +++ b/src/java/com/android/internal/telephony/ServiceStateTracker.java @@ -66,6 +66,7 @@ import android.telephony.cdma.CdmaCellLocation; import android.telephony.gsm.GsmCellLocation; import android.text.TextUtils; import android.util.EventLog; +import android.util.LocalLog; import android.util.Pair; import android.util.TimeUtils; @@ -83,12 +84,14 @@ import com.android.internal.annotations.VisibleForTesting; import com.android.internal.telephony.cdma.CdmaSubscriptionSourceManager; import com.android.internal.telephony.cdma.EriInfo; import com.android.internal.telephony.dataconnection.DcTracker; +import com.android.internal.telephony.metrics.TelephonyMetrics; import com.android.internal.telephony.uicc.IccCardApplicationStatus.AppState; import com.android.internal.telephony.uicc.IccRecords; import com.android.internal.telephony.uicc.RuimRecords; import com.android.internal.telephony.uicc.SIMRecords; import com.android.internal.telephony.uicc.UiccCardApplication; import com.android.internal.telephony.uicc.UiccController; +import com.android.internal.util.IndentingPrintWriter; /** * {@hide} @@ -104,7 +107,6 @@ public class ServiceStateTracker extends Handler { private UiccController mUiccController = null; private UiccCardApplication mUiccApplcation = null; private IccRecords mIccRecords = null; - private TelephonyEventLog mEventLog; private boolean mVoiceCapable; @@ -253,6 +255,8 @@ public class ServiceStateTracker extends Handler { private boolean mImsRegistrationOnOff = false; private boolean mAlarmSwitch = false; + /** Radio is disabled by carrier. Radio power will not be override if this field is set */ + private boolean mRadioDisabledByCarrier = false; private PendingIntent mRadioOffIntent = null; private static final String ACTION_RADIO_OFF = "android.intent.action.ACTION_RADIO_OFF"; private boolean mPowerOffDelayNeed = true; @@ -273,6 +277,14 @@ public class ServiceStateTracker extends Handler { private final SstSubscriptionsChangedListener mOnSubscriptionsChangedListener = new SstSubscriptionsChangedListener(); + + private final RatRatcheter mRatRatcheter; + + private final LocalLog mRoamingLog = new LocalLog(10); + private final LocalLog mAttachLog = new LocalLog(10); + private final LocalLog mPhoneTypeLog = new LocalLog(10); + private final LocalLog mRatLog = new LocalLog(20); + private class SstSubscriptionsChangedListener extends OnSubscriptionsChangedListener { public final AtomicInteger mPreviousSubId = new AtomicInteger(SubscriptionManager.INVALID_SUBSCRIPTION_ID); @@ -483,13 +495,10 @@ public class ServiceStateTracker extends Handler { private String mCurrentCarrier = null; public ServiceStateTracker(GsmCdmaPhone phone, CommandsInterface ci) { - initOnce(phone, ci); - updatePhoneType(); - } - - private void initOnce(GsmCdmaPhone phone, CommandsInterface ci) { mPhone = phone; mCi = ci; + + mRatRatcheter = new RatRatcheter(mPhone); mVoiceCapable = mPhone.getContext().getResources().getBoolean( com.android.internal.R.bool.config_voice_capable); mUiccController = UiccController.getInstance(); @@ -537,8 +546,9 @@ public class ServiceStateTracker extends Handler { filter.addAction(ACTION_RADIO_OFF); context.registerReceiver(mIntentReceiver, filter); - mEventLog = new TelephonyEventLog(mPhone.getPhoneId()); mPhone.notifyOtaspChanged(OTASP_UNINITIALIZED); + + updatePhoneType(); } @VisibleForTesting @@ -609,6 +619,15 @@ public class ServiceStateTracker extends Handler { // strength information displayed on the UI. mCi.getSignalStrength(obtainMessage(EVENT_GET_SIGNAL_STRENGTH)); sendMessage(obtainMessage(EVENT_PHONE_TYPE_SWITCHED)); + + logPhoneTypeChange(); + + // Tell everybody that we've thrown away state and are starting over with + // empty, detached ServiceStates. + mVoiceRoamingOffRegistrants.notifyRegistrants(); + mDataRoamingOffRegistrants.notifyRegistrants(); + mDetachedRegistrants.notifyRegistrants(); + notifyDataRegStateRilRadioTechnologyChanged(); } @VisibleForTesting @@ -631,6 +650,7 @@ public class ServiceStateTracker extends Handler { public boolean getDesiredPowerState() { return mDesiredPowerState; } + public boolean getPowerStateFromCarrier() { return !mRadioDisabledByCarrier; } private SignalStrength mLastSignalStrength = null; protected boolean notifySignalStrength() { @@ -797,6 +817,16 @@ public class ServiceStateTracker extends Handler { } /** + * Radio power set from carrier action. if set to false means carrier desire to turn radio off + * and radio wont be re-enabled unless carrier explicitly turn it back on. + * @param enable indicate if radio power is enabled or disabled from carrier action. + */ + public void setRadioPowerFromCarrier(boolean enable) { + mRadioDisabledByCarrier = !enable; + setPowerStateToDesired(); + } + + /** * These two flags manage the behavior of the cell lock -- the * lock should be held if either flag is true. The intention is * to allow temporary acquisition of the lock to get a single @@ -945,6 +975,7 @@ public class ServiceStateTracker extends Handler { } // This will do nothing in the 'radio not available' case setPowerStateToDesired(); + // These events are modem triggered, so pollState() needs to be forced modemTriggeredPollState(); break; @@ -1531,7 +1562,7 @@ public class ServiceStateTracker extends Handler { mNewSS.setCdmaRoamingIndicator(mDefaultRoamingIndicator); } else if (namMatch && !mIsInPrl) { // TODO this will be removed when we handle roaming on LTE on CDMA+LTE phones - if (isRatLte(mNewSS.getRilVoiceRadioTechnology())) { + if (ServiceState.isLte(mNewSS.getRilVoiceRadioTechnology())) { log("Turn off roaming indicator as voice is LTE"); mNewSS.setCdmaRoamingIndicator(EriInfo.ROAMING_INDICATOR_OFF); } else { @@ -1847,19 +1878,17 @@ public class ServiceStateTracker extends Handler { } } - // If the unsolicited signal strength comes just before data RAT family changes (i.e. - // from UNKNOWN to LTE, CDMA to LTE, LTE to CDMA), the signal bar might display - // the wrong information until the next unsolicited signal strength information coming - // from the modem, which might take a long time to come or even not come at all. - // In order to provide the best user experience, we query the latest signal - // information so it will show up on the UI on time. - + // If the unsolicited signal strength comes just before data RAT family changes + // (i.e. from UNKNOWN to LTE, CDMA to LTE, LTE to CDMA), the signal bar might + // display the wrong information until the next unsolicited signal strength + // information coming from the modem, which might take a long time to come or + // even not come at all. In order to provide the best user experience, we + // query the latest signal information so it will show up on the UI on time. int oldDataRAT = mSS.getRilDataRadioTechnology(); if ((oldDataRAT == ServiceState.RIL_RADIO_TECHNOLOGY_UNKNOWN && newDataRAT != ServiceState.RIL_RADIO_TECHNOLOGY_UNKNOWN) || - (ServiceState.isCdma(oldDataRAT) && - isRatLte(newDataRAT)) || (isRatLte(oldDataRAT) && - ServiceState.isCdma(newDataRAT))) { + (ServiceState.isCdma(oldDataRAT) && ServiceState.isLte(newDataRAT)) || + (ServiceState.isLte(oldDataRAT) && ServiceState.isCdma(newDataRAT))) { mCi.getSignalStrength(obtainMessage(EVENT_GET_SIGNAL_STRENGTH)); } @@ -2087,6 +2116,36 @@ public class ServiceStateTracker extends Handler { } protected void updateSpnDisplay() { + updateOperatorNameFromEri(); + + String wfcVoiceSpnFormat = null; + String wfcDataSpnFormat = null; + if (mPhone.getImsPhone() != null && mPhone.getImsPhone().isWifiCallingEnabled()) { + // In Wi-Fi Calling mode show SPN+WiFi + + String[] wfcSpnFormats = mPhone.getContext().getResources().getStringArray( + com.android.internal.R.array.wfcSpnFormats); + int voiceIdx = 0; + int dataIdx = 0; + CarrierConfigManager configLoader = (CarrierConfigManager) + mPhone.getContext().getSystemService(Context.CARRIER_CONFIG_SERVICE); + if (configLoader != null) { + try { + PersistableBundle b = configLoader.getConfigForSubId(mPhone.getSubId()); + if (b != null) { + voiceIdx = b.getInt(CarrierConfigManager.KEY_WFC_SPN_FORMAT_IDX_INT); + dataIdx = b.getInt( + CarrierConfigManager.KEY_WFC_DATA_SPN_FORMAT_IDX_INT); + } + } catch (Exception e) { + loge("updateSpnDisplay: carrier config error: " + e); + } + } + + wfcVoiceSpnFormat = wfcSpnFormats[voiceIdx]; + wfcDataSpnFormat = wfcSpnFormats[dataIdx]; + } + if (mPhone.isPhoneTypeGsm()) { // The values of plmn/showPlmn change in different scenarios. // 1) No service but emergency call allowed -> expected @@ -2150,36 +2209,13 @@ public class ServiceStateTracker extends Handler { && ((rule & SIMRecords.SPN_RULE_SHOW_SPN) == SIMRecords.SPN_RULE_SHOW_SPN); - if (!TextUtils.isEmpty(spn) - && mPhone.getImsPhone() != null - && mPhone.getImsPhone().isWifiCallingEnabled()) { + if (!TextUtils.isEmpty(spn) && !TextUtils.isEmpty(wfcVoiceSpnFormat) && + !TextUtils.isEmpty(wfcDataSpnFormat)) { // In Wi-Fi Calling mode show SPN+WiFi - final String[] wfcSpnFormats = - mPhone.getContext().getResources().getStringArray( - com.android.internal.R.array.wfcSpnFormats); - int voiceIdx = 0; - int dataIdx = 0; - CarrierConfigManager configLoader = (CarrierConfigManager) - mPhone.getContext().getSystemService(Context.CARRIER_CONFIG_SERVICE); - if (configLoader != null) { - try { - PersistableBundle b = configLoader.getConfigForSubId(mPhone.getSubId()); - if (b != null) { - voiceIdx = b.getInt(CarrierConfigManager.KEY_WFC_SPN_FORMAT_IDX_INT); - dataIdx = b.getInt( - CarrierConfigManager.KEY_WFC_DATA_SPN_FORMAT_IDX_INT); - } - } catch (Exception e) { - loge("updateSpnDisplay: carrier config error: " + e); - } - } - - String formatVoice = wfcSpnFormats[voiceIdx]; - String formatData = wfcSpnFormats[dataIdx]; String originalSpn = spn.trim(); - spn = String.format(formatVoice, originalSpn); - dataSpn = String.format(formatData, originalSpn); + spn = String.format(wfcVoiceSpnFormat, originalSpn); + dataSpn = String.format(wfcDataSpnFormat, originalSpn); showSpn = true; showPlmn = false; } else if (mSS.getVoiceRegState() == ServiceState.STATE_POWER_OFF @@ -2203,10 +2239,9 @@ public class ServiceStateTracker extends Handler { || !TextUtils.equals(dataSpn, mCurDataSpn) || !TextUtils.equals(plmn, mCurPlmn)) { if (DBG) { - log(String.format("updateSpnDisplay: changed" + - " sending intent rule=" + rule + - " showPlmn='%b' plmn='%s' showSpn='%b' spn='%s' dataSpn='%s' subId='%d'", - showPlmn, plmn, showSpn, spn, dataSpn, subId)); + log(String.format("updateSpnDisplay: changed sending intent rule=" + rule + + " showPlmn='%b' plmn='%s' showSpn='%b' spn='%s' dataSpn='%s' " + + "subId='%d'", showPlmn, plmn, showSpn, spn, dataSpn, subId)); } Intent intent = new Intent(TelephonyIntents.SPN_STRINGS_UPDATED_ACTION); intent.addFlags(Intent.FLAG_RECEIVER_REPLACE_PENDING); @@ -2251,6 +2286,19 @@ public class ServiceStateTracker extends Handler { "of service, set plmn='" + plmn + "'"); } + if (!TextUtils.isEmpty(plmn) && !TextUtils.isEmpty(wfcVoiceSpnFormat)) { + // In Wi-Fi Calling mode show SPN+WiFi + + String originalPlmn = plmn.trim(); + plmn = String.format(wfcVoiceSpnFormat, originalPlmn); + } else if (mCi.getRadioState() == CommandsInterface.RadioState.RADIO_OFF) { + // todo: temporary hack; should have a better fix. This is to avoid using operator + // name from ServiceState (populated in resetServiceStateInIwlanMode()) until + // wifi calling is actually enabled + log("updateSpnDisplay: overwriting plmn from " + plmn + " to null as radio " + + "state is off"); + plmn = null; + } if (mSubId != subId || !TextUtils.equals(plmn, mCurPlmn)) { // Allow A blank plmn, "" to set showPlmn to true. Previously, we @@ -2290,7 +2338,8 @@ public class ServiceStateTracker extends Handler { ", mDesiredPowerState=" + mDesiredPowerState + ", getRadioState=" + mCi.getRadioState() + ", mPowerOffDelayNeed=" + mPowerOffDelayNeed + - ", mAlarmSwitch=" + mAlarmSwitch); + ", mAlarmSwitch=" + mAlarmSwitch + + ", mRadioDisabledByCarrier=" + mRadioDisabledByCarrier); } if (mPhone.isPhoneTypeGsm() && mAlarmSwitch) { @@ -2302,10 +2351,10 @@ public class ServiceStateTracker extends Handler { } // If we want it on and it's off, turn it on - if (mDesiredPowerState + if (mDesiredPowerState && !mRadioDisabledByCarrier && mCi.getRadioState() == CommandsInterface.RadioState.RADIO_OFF) { mCi.setRadioPower(true, null); - } else if (!mDesiredPowerState && mCi.getRadioState().isOn()) { + } else if ((!mDesiredPowerState || mRadioDisabledByCarrier) && mCi.getRadioState().isOn()) { // If it's on and available and we want it off gracefully if (mPhone.isPhoneTypeGsm() && mPowerOffDelayNeed) { if (mImsRegistrationOnOff && !mAlarmSwitch) { @@ -2369,6 +2418,22 @@ public class ServiceStateTracker extends Handler { } } + private void logRoamingChange() { + mRoamingLog.log(mSS.toString()); + } + + private void logAttachChange() { + mAttachLog.log(mSS.toString()); + } + + private void logPhoneTypeChange() { + mPhoneTypeLog.log(Integer.toString(mPhone.getPhoneType())); + } + + private void logRatChange() { + mRatLog.log(mSS.toString()); + } + protected void log(String s) { Rlog.d(LOG_TAG, s); } @@ -2427,9 +2492,11 @@ public class ServiceStateTracker extends Handler { } public void onImsCapabilityChanged() { - if (mPhone.isPhoneTypeGsm()) { - sendMessage(obtainMessage(EVENT_IMS_CAPABILITY_CHANGED)); - } + sendMessage(obtainMessage(EVENT_IMS_CAPABILITY_CHANGED)); + } + + public boolean isRadioOn() { + return mCi.getRadioState() == CommandsInterface.RadioState.RADIO_ON; } private void updateRilImsRadioTechnology() { @@ -2565,6 +2632,14 @@ public class ServiceStateTracker extends Handler { boolean hasVoiceRegStateChanged = mSS.getVoiceRegState() != mNewSS.getVoiceRegState(); + boolean hasLocationChanged = !mNewCellLoc.equals(mCellLoc); + + // ratchet the new tech up through it's rat family but don't drop back down + // until cell change + if (hasLocationChanged == false) { + mRatRatcheter.ratchetRat(mSS, mNewSS); + } + boolean hasRilVoiceRadioTechnologyChanged = mSS.getRilVoiceRadioTechnology() != mNewSS.getRilVoiceRadioTechnology(); @@ -2581,8 +2656,6 @@ public class ServiceStateTracker extends Handler { boolean hasDataRoamingOff = mSS.getDataRoaming() && !mNewSS.getDataRoaming(); - boolean hasLocationChanged = !mNewCellLoc.equals(mCellLoc); - boolean hasCssIndicatorChanged = (mSS.getCssIndicator() != mNewSS.getCssIndicator()); TelephonyManager tm = @@ -2731,7 +2804,11 @@ public class ServiceStateTracker extends Handler { log("Broadcasting ServiceState : " + mSS); mPhone.notifyServiceStateChanged(mSS); - mEventLog.writeServiceStateChanged(mSS); + TelephonyMetrics.getInstance().writeServiceStateChanged(mPhone.getPhoneId(), mSS); + } + + if (hasGprsAttached || hasGprsDetached || hasRegistered || hasDeregistered) { + logAttachChange(); } if (hasGprsAttached) { @@ -2742,6 +2819,10 @@ public class ServiceStateTracker extends Handler { mDetachedRegistrants.notifyRegistrants(); } + if (hasRilDataRadioTechnologyChanged || hasRilVoiceRadioTechnologyChanged) { + logRatChange(); + } + if (hasDataRegStateChanged || hasRilDataRadioTechnologyChanged) { notifyDataRegStateRilRadioTechnologyChanged(); @@ -2753,6 +2834,10 @@ public class ServiceStateTracker extends Handler { } } + if (hasVoiceRoamingOn || hasVoiceRoamingOff || hasDataRoamingOn || hasDataRoamingOff) { + logRoamingChange(); + } + if (hasVoiceRoamingOn) { mVoiceRoamingOnRegistrants.notifyRegistrants(); } @@ -2815,6 +2900,14 @@ public class ServiceStateTracker extends Handler { boolean hasCdmaDataConnectionChanged = mSS.getDataRegState() != mNewSS.getDataRegState(); + boolean hasLocationChanged = !mNewCellLoc.equals(mCellLoc); + + // ratchet the new tech up through it's rat family but don't drop back down + // until cell change + if (hasLocationChanged == false) { + mRatRatcheter.ratchetRat(mSS, mNewSS); + } + boolean hasRilVoiceRadioTechnologyChanged = mSS.getRilVoiceRadioTechnology() != mNewSS.getRilVoiceRadioTechnology(); @@ -2831,8 +2924,6 @@ public class ServiceStateTracker extends Handler { boolean hasDataRoamingOff = mSS.getDataRoaming() && !mNewSS.getDataRoaming(); - boolean hasLocationChanged = !mNewCellLoc.equals(mCellLoc); - TelephonyManager tm = (TelephonyManager) mPhone.getContext().getSystemService(Context.TELEPHONY_SERVICE); @@ -2875,19 +2966,7 @@ public class ServiceStateTracker extends Handler { } if (hasChanged) { - if ((mCi.getRadioState().isOn()) && (!mIsSubscriptionFromRuim)) { - String eriText; - // Now the Phone sees the new ServiceState so it can get the new ERI text - if (mSS.getVoiceRegState() == ServiceState.STATE_IN_SERVICE) { - eriText = mPhone.getCdmaEriText(); - } else { - // Note that ServiceState.STATE_OUT_OF_SERVICE is valid used for - // mRegistrationState 0,2,3 and 4 - eriText = mPhone.getContext().getText( - com.android.internal.R.string.roamingTextSearching).toString(); - } - mSS.setOperatorAlphaLong(eriText); - } + updateSpnDisplay(); String operatorNumeric; @@ -2936,11 +3015,16 @@ public class ServiceStateTracker extends Handler { tm.setNetworkRoamingForPhone(mPhone.getPhoneId(), (mSS.getVoiceRoaming() || mSS.getDataRoaming())); - updateSpnDisplay(); // set roaming type setRoamingType(mSS); log("Broadcasting ServiceState : " + mSS); mPhone.notifyServiceStateChanged(mSS); + + TelephonyMetrics.getInstance().writeServiceStateChanged(mPhone.getPhoneId(), mSS); + } + + if (hasCdmaDataConnectionAttached || hasCdmaDataConnectionDetached || hasRegistered) { + logAttachChange(); } if (hasCdmaDataConnectionAttached) { @@ -2951,6 +3035,10 @@ public class ServiceStateTracker extends Handler { mDetachedRegistrants.notifyRegistrants(); } + if (hasRilDataRadioTechnologyChanged || hasRilVoiceRadioTechnologyChanged) { + logRatChange(); + } + if (hasCdmaDataConnectionChanged || hasRilDataRadioTechnologyChanged) { notifyDataRegStateRilRadioTechnologyChanged(); if (ServiceState.RIL_RADIO_TECHNOLOGY_IWLAN @@ -2969,6 +3057,10 @@ public class ServiceStateTracker extends Handler { mVoiceRoamingOffRegistrants.notifyRegistrants(); } + if (hasVoiceRoamingOn || hasVoiceRoamingOff || hasDataRoamingOn || hasDataRoamingOff) { + logRoamingChange(); + } + if (hasDataRoamingOn) { mDataRoamingOnRegistrants.notifyRegistrants(); } @@ -3012,6 +3104,14 @@ public class ServiceStateTracker extends Handler { boolean hasCdmaDataConnectionChanged = mSS.getDataRegState() != mNewSS.getDataRegState(); + boolean hasLocationChanged = !mNewCellLoc.equals(mCellLoc); + + // ratchet the new tech up through it's rat family but don't drop back down + // until cell change + if (hasLocationChanged == false) { + mRatRatcheter.ratchetRat(mSS, mNewSS); + } + boolean hasVoiceRadioTechnologyChanged = mSS.getRilVoiceRadioTechnology() != mNewSS.getRilVoiceRadioTechnology(); @@ -3028,24 +3128,22 @@ public class ServiceStateTracker extends Handler { boolean hasDataRoamingOff = mSS.getDataRoaming() && !mNewSS.getDataRoaming(); - boolean hasLocationChanged = !mNewCellLoc.equals(mCellLoc); - boolean has4gHandoff = mNewSS.getDataRegState() == ServiceState.STATE_IN_SERVICE && - ((isRatLte(mSS.getRilDataRadioTechnology()) && - (mNewSS.getRilDataRadioTechnology() == ServiceState.RIL_RADIO_TECHNOLOGY_EHRPD)) || - ((mSS.getRilDataRadioTechnology() == ServiceState.RIL_RADIO_TECHNOLOGY_EHRPD) && - isRatLte(mNewSS.getRilDataRadioTechnology()))); + ((ServiceState.isLte(mSS.getRilDataRadioTechnology()) && + (mNewSS.getRilDataRadioTechnology() == ServiceState.RIL_RADIO_TECHNOLOGY_EHRPD)) || + ((mSS.getRilDataRadioTechnology() == ServiceState.RIL_RADIO_TECHNOLOGY_EHRPD) && + ServiceState.isLte(mNewSS.getRilDataRadioTechnology()))); boolean hasMultiApnSupport = - ((isRatLte(mNewSS.getRilDataRadioTechnology()) || - (mNewSS.getRilDataRadioTechnology() == ServiceState.RIL_RADIO_TECHNOLOGY_EHRPD)) && - (!isRatLte(mSS.getRilDataRadioTechnology()) && - (mSS.getRilDataRadioTechnology() != ServiceState.RIL_RADIO_TECHNOLOGY_EHRPD))); + ((ServiceState.isLte(mNewSS.getRilDataRadioTechnology()) || + (mNewSS.getRilDataRadioTechnology() == ServiceState.RIL_RADIO_TECHNOLOGY_EHRPD)) && + (!ServiceState.isLte(mSS.getRilDataRadioTechnology()) && + (mSS.getRilDataRadioTechnology() != ServiceState.RIL_RADIO_TECHNOLOGY_EHRPD))); boolean hasLostMultiApnSupport = ((mNewSS.getRilDataRadioTechnology() >= ServiceState.RIL_RADIO_TECHNOLOGY_IS95A) && - (mNewSS.getRilDataRadioTechnology() <= ServiceState.RIL_RADIO_TECHNOLOGY_EVDO_A)); + (mNewSS.getRilDataRadioTechnology() <= ServiceState.RIL_RADIO_TECHNOLOGY_EVDO_A)); TelephonyManager tm = (TelephonyManager) mPhone.getContext().getSystemService(Context.TELEPHONY_SERVICE); @@ -3107,52 +3205,7 @@ public class ServiceStateTracker extends Handler { } if (hasChanged) { - boolean hasBrandOverride = mUiccController.getUiccCard(getPhoneId()) == null ? false : - (mUiccController.getUiccCard(getPhoneId()).getOperatorBrandOverride() != null); - if (!hasBrandOverride && (mCi.getRadioState().isOn()) && (mPhone.isEriFileLoaded()) && - (!isRatLte(mSS.getRilVoiceRadioTechnology()) || - mPhone.getContext().getResources().getBoolean(com.android.internal.R. - bool.config_LTE_eri_for_network_name)) && - !mIsSubscriptionFromRuim) { - // Only when CDMA is in service, ERI will take effect - String eriText = mSS.getOperatorAlphaLong(); - // Now the Phone sees the new ServiceState so it can get the new ERI text - if (mSS.getVoiceRegState() == ServiceState.STATE_IN_SERVICE) { - eriText = mPhone.getCdmaEriText(); - } else if (mSS.getVoiceRegState() == ServiceState.STATE_POWER_OFF) { - eriText = (mIccRecords != null) ? mIccRecords.getServiceProviderName() : null; - if (TextUtils.isEmpty(eriText)) { - // Sets operator alpha property by retrieving from - // build-time system property - eriText = SystemProperties.get("ro.cdma.home.operator.alpha"); - } - } else if (mSS.getDataRegState() != ServiceState.STATE_IN_SERVICE) { - // Note that ServiceState.STATE_OUT_OF_SERVICE is valid used - // for mRegistrationState 0,2,3 and 4 - eriText = mPhone.getContext() - .getText(com.android.internal.R.string.roamingTextSearching).toString(); - } - mSS.setOperatorAlphaLong(eriText); - } - - if (mUiccApplcation != null && mUiccApplcation.getState() == AppState.APPSTATE_READY && - mIccRecords != null && - ((mSS.getVoiceRegState() == ServiceState.STATE_IN_SERVICE) - || (mSS.getDataRegState() == ServiceState.STATE_IN_SERVICE)) - && !isRatLte(mSS.getRilVoiceRadioTechnology())) { - // SIM is found on the device. If ERI roaming is OFF, and SID/NID matches - // one configured in SIM, use operator name from CSIM record. Note that ERI, SID, - // and NID are CDMA only, not applicable to LTE. - boolean showSpn = - ((RuimRecords)mIccRecords).getCsimSpnDisplayCondition(); - int iconIndex = mSS.getCdmaEriIconIndex(); - - if (showSpn && (iconIndex == EriInfo.ROAMING_INDICATOR_OFF) && - isInHomeSidNid(mSS.getSystemId(), mSS.getNetworkId()) && - mIccRecords != null) { - mSS.setOperatorAlphaLong(mIccRecords.getServiceProviderName()); - } - } + updateSpnDisplay(); String operatorNumeric; @@ -3199,10 +3252,16 @@ public class ServiceStateTracker extends Handler { tm.setNetworkRoamingForPhone(mPhone.getPhoneId(), (mSS.getVoiceRoaming() || mSS.getDataRoaming())); - updateSpnDisplay(); setRoamingType(mSS); log("Broadcasting ServiceState : " + mSS); mPhone.notifyServiceStateChanged(mSS); + + TelephonyMetrics.getInstance().writeServiceStateChanged(mPhone.getPhoneId(), mSS); + } + + if (hasCdmaDataConnectionAttached || has4gHandoff || hasCdmaDataConnectionDetached || + hasRegistered || hasDeregistered) { + logAttachChange(); } if (hasCdmaDataConnectionAttached || has4gHandoff) { @@ -3213,6 +3272,10 @@ public class ServiceStateTracker extends Handler { mDetachedRegistrants.notifyRegistrants(); } + if (hasDataRadioTechnologyChanged || hasVoiceRadioTechnologyChanged) { + logRatChange(); + } + if ((hasCdmaDataConnectionChanged || hasDataRadioTechnologyChanged)) { notifyDataRegStateRilRadioTechnologyChanged(); if (ServiceState.RIL_RADIO_TECHNOLOGY_IWLAN @@ -3223,6 +3286,10 @@ public class ServiceStateTracker extends Handler { } } + if (hasVoiceRoamingOn || hasVoiceRoamingOff || hasDataRoamingOn || hasDataRoamingOff) { + logRoamingChange(); + } + if (hasVoiceRoamingOn) { mVoiceRoamingOnRegistrants.notifyRegistrants(); } @@ -3244,6 +3311,68 @@ public class ServiceStateTracker extends Handler { } } + private void updateOperatorNameFromEri() { + if (mPhone.isPhoneTypeCdma()) { + if ((mCi.getRadioState().isOn()) && (!mIsSubscriptionFromRuim)) { + String eriText; + // Now the Phone sees the new ServiceState so it can get the new ERI text + if (mSS.getVoiceRegState() == ServiceState.STATE_IN_SERVICE) { + eriText = mPhone.getCdmaEriText(); + } else { + // Note that ServiceState.STATE_OUT_OF_SERVICE is valid used for + // mRegistrationState 0,2,3 and 4 + eriText = mPhone.getContext().getText( + com.android.internal.R.string.roamingTextSearching).toString(); + } + mSS.setOperatorAlphaLong(eriText); + } + } else if (mPhone.isPhoneTypeCdmaLte()) { + boolean hasBrandOverride = mUiccController.getUiccCard(getPhoneId()) != null && + mUiccController.getUiccCard(getPhoneId()).getOperatorBrandOverride() != null; + if (!hasBrandOverride && (mCi.getRadioState().isOn()) && (mPhone.isEriFileLoaded()) && + (!ServiceState.isLte(mSS.getRilVoiceRadioTechnology()) || + mPhone.getContext().getResources().getBoolean(com.android.internal.R. + bool.config_LTE_eri_for_network_name))) { + // Only when CDMA is in service, ERI will take effect + String eriText = mSS.getOperatorAlphaLong(); + // Now the Phone sees the new ServiceState so it can get the new ERI text + if (mSS.getVoiceRegState() == ServiceState.STATE_IN_SERVICE) { + eriText = mPhone.getCdmaEriText(); + } else if (mSS.getVoiceRegState() == ServiceState.STATE_POWER_OFF) { + eriText = (mIccRecords != null) ? mIccRecords.getServiceProviderName() : null; + if (TextUtils.isEmpty(eriText)) { + // Sets operator alpha property by retrieving from + // build-time system property + eriText = SystemProperties.get("ro.cdma.home.operator.alpha"); + } + } else if (mSS.getDataRegState() != ServiceState.STATE_IN_SERVICE) { + // Note that ServiceState.STATE_OUT_OF_SERVICE is valid used + // for mRegistrationState 0,2,3 and 4 + eriText = mPhone.getContext() + .getText(com.android.internal.R.string.roamingTextSearching).toString(); + } + mSS.setOperatorAlphaLong(eriText); + } + + if (mUiccApplcation != null && mUiccApplcation.getState() == AppState.APPSTATE_READY && + mIccRecords != null && (mSS.getVoiceRegState() == ServiceState.STATE_IN_SERVICE) + && !ServiceState.isLte(mSS.getRilVoiceRadioTechnology())) { + // SIM is found on the device. If ERI roaming is OFF, and SID/NID matches + // one configured in SIM, use operator name from CSIM record. Note that ERI, SID, + // and NID are CDMA only, not applicable to LTE. + boolean showSpn = + ((RuimRecords) mIccRecords).getCsimSpnDisplayCondition(); + int iconIndex = mSS.getCdmaEriIconIndex(); + + if (showSpn && (iconIndex == EriInfo.ROAMING_INDICATOR_OFF) && + isInHomeSidNid(mSS.getSystemId(), mSS.getNetworkId()) && + mIccRecords != null) { + mSS.setOperatorAlphaLong(mIccRecords.getServiceProviderName()); + } + } + } + } + /** * Check whether the specified SID and NID pair appears in the HOME SID/NID list * read from NV or SIM. @@ -3984,6 +4113,8 @@ public class ServiceStateTracker extends Handler { intent.addFlags(Intent.FLAG_RECEIVER_REPLACE_PENDING); intent.putExtra("time", time); mPhone.getContext().sendStickyBroadcastAsUser(intent, UserHandle.ALL); + + TelephonyMetrics.getInstance().writeNITZEvent(mPhone.getPhoneId(), time); } private void revertToNitzTime() { @@ -4352,7 +4483,7 @@ public class ServiceStateTracker extends Handler { //override isGsm for CDMA LTE if (mPhone.isPhoneTypeGsm() || (mPhone.isPhoneTypeCdmaLte() && - isRatLte(mSS.getRilDataRadioTechnology()))) { + ServiceState.isLte(mSS.getRilDataRadioTechnology()))) { isGsm = true; } @@ -4625,11 +4756,31 @@ public class ServiceStateTracker extends Handler { pw.println(" mImsRegistered=" + mImsRegistered); pw.println(" mImsRegistrationOnOff=" + mImsRegistrationOnOff); pw.println(" mAlarmSwitch=" + mAlarmSwitch); + pw.println(" mRadioDisabledByCarrier" + mRadioDisabledByCarrier); pw.println(" mPowerOffDelayNeed=" + mPowerOffDelayNeed); pw.println(" mDeviceShuttingDown=" + mDeviceShuttingDown); pw.println(" mSpnUpdatePending=" + mSpnUpdatePending); + pw.println(" Roaming Log:"); + IndentingPrintWriter ipw = new IndentingPrintWriter(pw, " "); + ipw.increaseIndent(); + mRoamingLog.dump(fd, ipw, args); + ipw.decreaseIndent(); + ipw.println(" Attach Log:"); + ipw.increaseIndent(); + mAttachLog.dump(fd, ipw, args); + ipw.decreaseIndent(); + + ipw.println(" Phone Change Log:"); + ipw.increaseIndent(); + mPhoneTypeLog.dump(fd, ipw, args); + ipw.decreaseIndent(); + + ipw.println(" Rat Change Log:"); + ipw.increaseIndent(); + mRatLog.dump(fd, ipw, args); + ipw.decreaseIndent(); } public boolean isImsRegistered() { @@ -4825,10 +4976,13 @@ public class ServiceStateTracker extends Handler { log("pollStateDone: reset iwlan RAT value"); resetIwlanRatVal = true; } + // operator info should be kept in SS + String operator = mNewSS.getOperatorAlphaLong(); mNewSS.setStateOff(); if (resetIwlanRatVal) { mNewSS.setRilDataRadioTechnology(ServiceState.RIL_RADIO_TECHNOLOGY_IWLAN); mNewSS.setDataRegState(ServiceState.STATE_IN_SERVICE); + mNewSS.setOperatorAlphaLong(operator); log("pollStateDone: mNewSS = " + mNewSS); } } @@ -4899,12 +5053,4 @@ public class ServiceStateTracker extends Handler { public boolean isDeviceShuttingDown() { return mDeviceShuttingDown; } - - /** - * {@hide} - */ - public boolean isRatLte(int rat) { - return (rat == ServiceState.RIL_RADIO_TECHNOLOGY_LTE || - rat == ServiceState.RIL_RADIO_TECHNOLOGY_LTE_CA); - } } |