On data only devices use data registration state.
Wink Saville [Fri, 19 Apr 2013 22:07:52 +0000 (15:07 -0700)]
Some operators may report that the voice registration state is
not in service on a data only device. So use the Data registration
state for data only devices.

Bug: 8213254
Change-Id: Ieb6eef65fa5afb3d2c1a39b32a5bc5825ccc7f1c

src/java/com/android/internal/telephony/ServiceStateTracker.java
src/java/com/android/internal/telephony/cdma/CdmaLteServiceStateTracker.java
src/java/com/android/internal/telephony/cdma/CdmaServiceStateTracker.java
src/java/com/android/internal/telephony/gsm/GsmServiceStateTracker.java

index dc96c6c..474523c 100644 (file)
@@ -53,6 +53,8 @@ public abstract class ServiceStateTracker extends Handler {
 
     protected PhoneBase mPhoneBase;
 
+    protected boolean mVoiceCapable;
+
     public ServiceState mSS = new ServiceState();
     protected ServiceState mNewSS = new ServiceState();
 
@@ -196,6 +198,8 @@ public abstract class ServiceStateTracker extends Handler {
         mPhoneBase = phoneBase;
         mCellInfo = cellInfo;
         mCi = ci;
+        mVoiceCapable = mPhoneBase.getContext().getResources().getBoolean(
+                com.android.internal.R.bool.config_voice_capable);
         mUiccController = UiccController.getInstance();
         mUiccController.registerForIccChanged(this, EVENT_ICC_CHANGED, null);
         mCi.setOnSignalStrengthUpdate(this, EVENT_SIGNAL_STRENGTH_UPDATE, null);
@@ -230,6 +234,22 @@ public abstract class ServiceStateTracker extends Handler {
     }
 
     /**
+     * Some operators have been known to report registration failure
+     * data only devices, to fix that use DataRegState.
+     */
+    protected void useDataRegStateForDataOnlyDevices() {
+        if (mVoiceCapable == false) {
+            if (DBG) {
+                log("useDataRegStateForDataOnlyDevice: VoiceRegState=" + mNewSS.getVoiceRegState()
+                    + " DataRegState=" + mNewSS.getDataRegState());
+            }
+            // TODO: Consider not lying and instead have callers know the difference. 
+            mNewSS.setVoiceRegState(mNewSS.getDataRegState());
+        }
+    }
+
+
+    /**
      * Registration point for combined roaming on
      * combined roaming is true when roaming is true and ONS differs SPN
      *
index 74fbb61..43b0614 100644 (file)
@@ -251,6 +251,8 @@ public class CdmaLteServiceStateTracker extends CdmaServiceStateTracker {
     protected void pollStateDone() {
         log("pollStateDone: lte 1 ss=[" + mSS + "] newSS=[" + mNewSS + "]");
 
+        useDataRegStateForDataOnlyDevices();
+
         boolean hasRegistered = mSS.getVoiceRegState() != ServiceState.STATE_IN_SERVICE
                 && mNewSS.getVoiceRegState() == ServiceState.STATE_IN_SERVICE;
 
index 9026be6..3936e9e 100644 (file)
@@ -964,6 +964,8 @@ public class CdmaServiceStateTracker extends ServiceStateTracker {
             mNewSS.setRoaming(true);
         }
 
+        useDataRegStateForDataOnlyDevices();
+
         boolean hasRegistered =
             mSS.getVoiceRegState() != ServiceState.STATE_IN_SERVICE
             && mNewSS.getVoiceRegState() == ServiceState.STATE_IN_SERVICE;
index d4d2edc..99512f4 100644 (file)
@@ -806,6 +806,8 @@ final class GsmServiceStateTracker extends ServiceStateTracker {
             mNewSS.setRoaming(true);
         }
 
+        useDataRegStateForDataOnlyDevices();
+
         boolean hasRegistered =
             mSS.getVoiceRegState() != ServiceState.STATE_IN_SERVICE
             && mNewSS.getVoiceRegState() == ServiceState.STATE_IN_SERVICE;