Allow normal voice calls on CS phone only when in service.
Anju Mathapati [Wed, 8 Jul 2015 21:54:25 +0000 (14:54 -0700)]
If there is no service in GSM/CDMA do not allow dial requests
for non emergency CS voice calls.

Bug: 22351845
Change-Id: I7f6f196ff7975442876cb734122defebaee9f7af

src/java/com/android/internal/telephony/cdma/CDMAPhone.java
src/java/com/android/internal/telephony/gsm/GSMPhone.java

index 9c74fe1..4248df3 100644 (file)
@@ -427,6 +427,7 @@ public class CDMAPhone extends PhoneBase {
             throw new CallStateException("Sending UUS information NOT supported in CDMA!");
         }
 
+        boolean isEmergency = PhoneNumberUtils.isEmergencyNumber(dialString);
         ImsPhone imsPhone = mImsPhone;
 
         boolean imsUseEnabled = isImsUseEnabled()
@@ -435,7 +436,7 @@ public class CDMAPhone extends PhoneBase {
                  && (imsPhone.getServiceState().getState() == ServiceState.STATE_IN_SERVICE);
 
         boolean useImsForEmergency = imsPhone != null
-                && PhoneNumberUtils.isEmergencyNumber(dialString)
+                && isEmergency
                 &&  mContext.getResources().getBoolean(
                         com.android.internal.R.bool.useImsAlwaysForEmergencyCall)
                 && ImsManager.isNonTtyOrTtyOnVolteEnabled(mContext)
@@ -470,6 +471,10 @@ public class CDMAPhone extends PhoneBase {
             }
         }
 
+        if ((mSST != null) && (mSST.mSS.getState() == ServiceState.STATE_OUT_OF_SERVICE)
+                && !isEmergency) {
+            throw new CallStateException("cannot dial in current state");
+        }
         if (DBG) Rlog.d(LOG_TAG, "Trying (non-IMS) CS call");
         return dialInternal(dialString, null, videoState, intentExtras);
     }
index 6f1591e..b618014 100755 (executable)
@@ -802,6 +802,7 @@ public class GSMPhone extends PhoneBase {
     public Connection
     dial (String dialString, UUSInfo uusInfo, int videoState, Bundle intentExtras)
             throws CallStateException {
+        boolean isEmergency = PhoneNumberUtils.isEmergencyNumber(dialString);
         ImsPhone imsPhone = mImsPhone;
 
         boolean imsUseEnabled = isImsUseEnabled()
@@ -810,7 +811,7 @@ public class GSMPhone extends PhoneBase {
                  && (imsPhone.getServiceState().getState() == ServiceState.STATE_IN_SERVICE);
 
         boolean useImsForEmergency = imsPhone != null
-                && PhoneNumberUtils.isEmergencyNumber(dialString)
+                && isEmergency
                 &&  mContext.getResources().getBoolean(
                         com.android.internal.R.bool.useImsAlwaysForEmergencyCall)
                 && ImsManager.isNonTtyOrTtyOnVolteEnabled(mContext)
@@ -845,6 +846,10 @@ public class GSMPhone extends PhoneBase {
             }
         }
 
+        if ((mSST != null) && (mSST.mSS.getState() == ServiceState.STATE_OUT_OF_SERVICE)
+                && !isEmergency) {
+            throw new CallStateException("cannot dial in current state");
+        }
         if (LOCAL_DEBUG) Rlog.d(LOG_TAG, "Trying (non-IMS) CS call");
         return dialInternal(dialString, null, VideoProfile.STATE_AUDIO_ONLY, intentExtras);
     }