Allow data switch in emergency call.

Remove the restriction that no data switching can happen in emergency
call at all.
In the scenario of DSDS, if the mergency call is placed on non-dds
subscription, we could setup data conneciton on it if data is allowed.
So we should still re-evaluate data sub even in emergency call. The
only thing we need to make sure is, in older devices where on-demand
ps attach / detach is needed, don't detach the phone in voice call.

Bug: 134073343
Test: sanity
Change-Id: Ie2549f2cd426c902935a07afd90a4771b8498f8f
diff --git a/src/java/com/android/internal/telephony/PhoneSwitcher.java b/src/java/com/android/internal/telephony/PhoneSwitcher.java
index 6aca872..0d8af1a 100644
--- a/src/java/com/android/internal/telephony/PhoneSwitcher.java
+++ b/src/java/com/android/internal/telephony/PhoneSwitcher.java
@@ -327,7 +327,13 @@
             }
         }
 
-        return (mPhoneIdInVoiceCall != oldPhoneIdInVoiceCall);
+        if (mPhoneIdInVoiceCall != oldPhoneIdInVoiceCall) {
+            log("isPhoneInVoiceCallChanged from phoneId " + oldPhoneIdInVoiceCall
+                    + " to phoneId " + mPhoneIdInVoiceCall);
+            return true;
+        } else {
+            return false;
+        }
     }
 
     @VisibleForTesting
@@ -606,19 +612,6 @@
         }
     }
 
-    private boolean isEmergency() {
-        if (isInEmergencyCallbackMode()) return true;
-        for (Phone p : mPhones) {
-            if (p == null) continue;
-            if (p.isInEmergencyCall()) return true;
-            Phone imsPhone = p.getImsPhone();
-            if (imsPhone != null && imsPhone.isInEmergencyCall()) {
-                return true;
-            }
-        }
-        return false;
-    }
-
     private boolean isInEmergencyCallbackMode() {
         for (Phone p : mPhones) {
             if (p == null) continue;
@@ -734,10 +727,6 @@
      */
     private boolean onEvaluate(boolean requestsChanged, String reason) {
         StringBuilder sb = new StringBuilder(reason);
-        if (isEmergency()) {
-            log("onEvaluate for reason " + reason + " aborted due to Emergency");
-            return false;
-        }
 
         // If we use HAL_COMMAND_PREFERRED_DATA,
         boolean diffDetected = mHalCommandToUse != HAL_COMMAND_PREFERRED_DATA && requestsChanged;
@@ -812,12 +801,19 @@
                         newActivePhones.add(mPhones[i].getPhoneId());
                     }
                 } else {
-                    for (DcRequest dcRequest : mPrioritizedDcRequests) {
-                        int phoneIdForRequest = phoneIdForRequest(dcRequest.networkRequest);
-                        if (phoneIdForRequest == INVALID_PHONE_INDEX) continue;
-                        if (newActivePhones.contains(phoneIdForRequest)) continue;
-                        newActivePhones.add(phoneIdForRequest);
-                        if (newActivePhones.size() >= mMaxActivePhones) break;
+                    // First try to activate phone in voice call.
+                    if (mPhoneIdInVoiceCall != SubscriptionManager.INVALID_PHONE_INDEX) {
+                        newActivePhones.add(mPhoneIdInVoiceCall);
+                    }
+
+                    if (newActivePhones.size() < mMaxActivePhones) {
+                        for (DcRequest dcRequest : mPrioritizedDcRequests) {
+                            int phoneIdForRequest = phoneIdForRequest(dcRequest.networkRequest);
+                            if (phoneIdForRequest == INVALID_PHONE_INDEX) continue;
+                            if (newActivePhones.contains(phoneIdForRequest)) continue;
+                            newActivePhones.add(phoneIdForRequest);
+                            if (newActivePhones.size() >= mMaxActivePhones) break;
+                        }
                     }
 
                     if (newActivePhones.size() < mMaxActivePhones