Merge "EMBMS test app"
diff --git a/src/com/android/phone/PhoneGlobals.java b/src/com/android/phone/PhoneGlobals.java
index 7a3683f..9ecb209 100644
--- a/src/com/android/phone/PhoneGlobals.java
+++ b/src/com/android/phone/PhoneGlobals.java
@@ -646,6 +646,7 @@
             } else if (action.equals(TelephonyIntents.ACTION_ANY_DATA_CONNECTION_STATE_CHANGED)) {
                 int subId = intent.getIntExtra(PhoneConstants.SUBSCRIPTION_KEY,
                         SubscriptionManager.INVALID_SUBSCRIPTION_ID);
+                int phoneId = SubscriptionManager.getPhoneId(subId);
                 final String apnType = intent.getStringExtra(PhoneConstants.DATA_APN_TYPE_KEY);
                 final String state = intent.getStringExtra(PhoneConstants.STATE_KEY);
                 final String reason = intent.getStringExtra(PhoneConstants.STATE_CHANGE_REASON_KEY);
@@ -655,6 +656,8 @@
                     Log.d(LOG_TAG, "- reason: " + reason);
                     Log.d(LOG_TAG, "- subId: " + subId);
                 }
+                Phone phone = SubscriptionManager.isValidPhoneId(phoneId) ?
+                        PhoneFactory.getPhone(phoneId) : PhoneFactory.getDefaultPhone();
 
                 // If the apn type of data connection state changed event is NOT default,
                 // ignore the broadcast intent and avoid action.
@@ -668,7 +671,7 @@
                 // (b) you just lost data connectivity because you're roaming.
                 if (PhoneConstants.DataState.DISCONNECTED.name().equals(state)
                         && Phone.REASON_ROAMING_ON.equals(reason)
-                        && !getPhone(subId).getDataRoamingEnabled()) {
+                        && !phone.getDataRoamingEnabled()) {
                     // Notify the user that data call is disconnected due to roaming. Note that
                     // calling this multiple times will not cause multiple notifications.
                     mHandler.sendEmptyMessage(EVENT_DATA_ROAMING_DISCONNECTED);
diff --git a/src/com/android/phone/PhoneInterfaceManager.java b/src/com/android/phone/PhoneInterfaceManager.java
index f59e97f..a5f9c07 100644
--- a/src/com/android/phone/PhoneInterfaceManager.java
+++ b/src/com/android/phone/PhoneInterfaceManager.java
@@ -80,6 +80,7 @@
 import com.android.internal.telephony.MccTable;
 import com.android.internal.telephony.OperatorInfo;
 import com.android.internal.telephony.Phone;
+import com.android.internal.telephony.PhoneConstantConversions;
 import com.android.internal.telephony.PhoneConstants;
 import com.android.internal.telephony.PhoneFactory;
 import com.android.internal.telephony.ProxyController;
@@ -1576,16 +1577,16 @@
     public int getCallStateForSlot(int slotIndex) {
         Phone phone = PhoneFactory.getPhone(slotIndex);
         return phone == null ? TelephonyManager.CALL_STATE_IDLE :
-            DefaultPhoneNotifier.convertCallState(phone.getState());
+            PhoneConstantConversions.convertCallState(phone.getState());
     }
 
     @Override
     public int getDataState() {
         Phone phone = getPhone(mSubscriptionController.getDefaultDataSubId());
         if (phone != null) {
-            return DefaultPhoneNotifier.convertDataState(phone.getDataConnectionState());
+            return PhoneConstantConversions.convertDataState(phone.getDataConnectionState());
         } else {
-            return DefaultPhoneNotifier.convertDataState(PhoneConstants.DataState.DISCONNECTED);
+            return PhoneConstantConversions.convertDataState(PhoneConstants.DataState.DISCONNECTED);
         }
     }
 
diff --git a/src/com/android/phone/otasp/OtaspSimStateReceiver.java b/src/com/android/phone/otasp/OtaspSimStateReceiver.java
index c0409ba..213aa9f 100644
--- a/src/com/android/phone/otasp/OtaspSimStateReceiver.java
+++ b/src/com/android/phone/otasp/OtaspSimStateReceiver.java
@@ -24,7 +24,6 @@
 import android.telephony.TelephonyManager;
 import android.util.Log;
 import com.android.internal.telephony.Phone;
-import com.android.internal.telephony.ServiceStateTracker;
 import com.android.phone.PhoneGlobals;
 
 public class OtaspSimStateReceiver extends BroadcastReceiver {
@@ -36,10 +35,10 @@
         @Override
         public void onOtaspChanged(int otaspMode) {
             logd("onOtaspChanged: otaspMode=" + otaspMode);
-            if (otaspMode == ServiceStateTracker.OTASP_NEEDED) {
+            if (otaspMode == TelephonyManager.OTASP_NEEDED) {
                 logd("otasp activation required, start otaspActivationService");
                 mContext.startService(new Intent(mContext, OtaspActivationService.class));
-            } else if (otaspMode == ServiceStateTracker.OTASP_NOT_NEEDED) {
+            } else if (otaspMode == TelephonyManager.OTASP_NOT_NEEDED) {
                 OtaspActivationService.updateActivationState(mContext, true);
             }
         }
diff --git a/src/com/android/phone/vvm/omtp/OmtpVvmCarrierConfigHelper.java b/src/com/android/phone/vvm/omtp/OmtpVvmCarrierConfigHelper.java
index c82012a..486b07c 100644
--- a/src/com/android/phone/vvm/omtp/OmtpVvmCarrierConfigHelper.java
+++ b/src/com/android/phone/vvm/omtp/OmtpVvmCarrierConfigHelper.java
@@ -192,8 +192,11 @@
             names.add(bundle.getString(KEY_CARRIER_VVM_PACKAGE_NAME_STRING));
         }
         if (bundle.containsKey(KEY_CARRIER_VVM_PACKAGE_NAME_STRING_ARRAY)) {
-            names.addAll(Arrays.asList(
-                    bundle.getStringArray(KEY_CARRIER_VVM_PACKAGE_NAME_STRING_ARRAY)));
+            String[] vvmPackages = bundle.getStringArray(KEY_CARRIER_VVM_PACKAGE_NAME_STRING_ARRAY);
+            if (vvmPackages != null && vvmPackages.length > 0) {
+                names.addAll(Arrays.asList(
+                        bundle.getStringArray(KEY_CARRIER_VVM_PACKAGE_NAME_STRING_ARRAY)));
+            }
         }
         if (names.isEmpty()) {
             return null;
diff --git a/src/com/android/services/telephony/TelephonyConnectionService.java b/src/com/android/services/telephony/TelephonyConnectionService.java
index d6faede..0148df6 100644
--- a/src/com/android/services/telephony/TelephonyConnectionService.java
+++ b/src/com/android/services/telephony/TelephonyConnectionService.java
@@ -817,7 +817,7 @@
         } catch (CallStateException e) {
             Log.e(this, e, "placeOutgoingConnection, phone.dial exception: " + e);
             int cause = android.telephony.DisconnectCause.OUTGOING_FAILURE;
-            if (e.getError() == CallStateException.ERROR_DISCONNECTED) {
+            if (e.getError() == CallStateException.ERROR_OUT_OF_SERVICE) {
                 cause = android.telephony.DisconnectCause.OUT_OF_SERVICE;
             } else if (e.getError() == CallStateException.ERROR_POWER_OFF) {
                 cause = android.telephony.DisconnectCause.POWER_OFF;