Merge "Don't activate VVM if carrier config changed without signal" into nyc-mr2-dev
diff --git a/src/com/android/phone/CallFeaturesSetting.java b/src/com/android/phone/CallFeaturesSetting.java
index b5e8026..a6d54ef 100644
--- a/src/com/android/phone/CallFeaturesSetting.java
+++ b/src/com/android/phone/CallFeaturesSetting.java
@@ -330,7 +330,8 @@
         } else {
             int resId = com.android.internal.R.string.wifi_calling_off_summary;
             if (ImsManager.isWfcEnabledByUser(mPhone.getContext())) {
-                int wfcMode = ImsManager.getWfcMode(mPhone.getContext());
+                boolean isRoaming = telephonyManager.isNetworkRoaming();
+                int wfcMode = ImsManager.getWfcMode(mPhone.getContext(), isRoaming);
                 switch (wfcMode) {
                     case ImsConfig.WfcModeFeatureValueConstants.WIFI_ONLY:
                         resId = com.android.internal.R.string.wfc_mode_wifi_only_summary;
diff --git a/src/com/android/phone/vvm/omtp/protocol/OmtpProtocol.java b/src/com/android/phone/vvm/omtp/protocol/OmtpProtocol.java
index d002652..7ec3dba 100644
--- a/src/com/android/phone/vvm/omtp/protocol/OmtpProtocol.java
+++ b/src/com/android/phone/vvm/omtp/protocol/OmtpProtocol.java
@@ -28,6 +28,7 @@
     public OmtpMessageSender createMessageSender(SmsManager smsManager, short applicationPort,
             String destinationNumber) {
         return new OmtpStandardMessageSender(smsManager, applicationPort, destinationNumber,
-                null, OmtpConstants.PROTOCOL_VERSION1_1, null);
+                OmtpConstants.CLIENT_TYPE_GOOGLE_10, OmtpConstants.PROTOCOL_VERSION1_1,
+                null /*clientPrefix*/);
     }
 }
diff --git a/src/com/android/phone/vvm/omtp/protocol/Vvm3EventHandler.java b/src/com/android/phone/vvm/omtp/protocol/Vvm3EventHandler.java
index d95879f..524c96d 100644
--- a/src/com/android/phone/vvm/omtp/protocol/Vvm3EventHandler.java
+++ b/src/com/android/phone/vvm/omtp/protocol/Vvm3EventHandler.java
@@ -18,13 +18,17 @@
 
 import android.annotation.IntDef;
 import android.content.Context;
+import android.provider.VoicemailContract.Status;
+import android.telecom.PhoneAccountHandle;
 import android.util.Log;
+
 import com.android.phone.VoicemailStatus;
 import com.android.phone.settings.VoicemailChangePinActivity;
 import com.android.phone.vvm.omtp.DefaultOmtpEventHandler;
 import com.android.phone.vvm.omtp.OmtpEvents;
 import com.android.phone.vvm.omtp.OmtpEvents.Type;
 import com.android.phone.vvm.omtp.OmtpVvmCarrierConfigHelper;
+
 import java.lang.annotation.Retention;
 import java.lang.annotation.RetentionPolicy;
 
@@ -113,19 +117,22 @@
         OmtpEvents event) {
         switch (event) {
             case CONFIG_REQUEST_STATUS_SUCCESS:
-                if (status.getPhoneAccountHandle() == null) {
-                    // This should never happen.
-                    Log.e(TAG, "status editor has null phone account handle");
-                    return true;
-                }
-
-                if (!VoicemailChangePinActivity
-                    .isDefaultOldPinSet(context, status.getPhoneAccountHandle())) {
+                if (!isPinRandomized(context, status.getPhoneAccountHandle())) {
                     return false;
                 } else {
                     postError(status, PIN_NOT_SET);
                 }
                 break;
+            case CONFIG_ACTIVATING_SUBSEQUENT:
+                if (isPinRandomized(context, status.getPhoneAccountHandle())) {
+                    status.setConfigurationState(PIN_NOT_SET);
+                } else {
+                    status.setConfigurationState(Status.CONFIGURATION_STATE_OK);
+                }
+                status
+                        .setNotificationChannelState(Status.NOTIFICATION_CHANNEL_STATE_OK)
+                        .setDataChannelState(Status.DATA_CHANNEL_STATE_OK).apply();
+                break;
             case CONFIG_DEFAULT_PIN_REPLACED:
                 postError(status, PIN_NOT_SET);
                 break;
@@ -269,4 +276,13 @@
         }
         editor.apply();
     }
+
+    private static boolean isPinRandomized(Context context, PhoneAccountHandle phoneAccountHandle) {
+        if (phoneAccountHandle == null) {
+            // This should never happen.
+            Log.e(TAG, "status editor has null phone account handle");
+            return false;
+        }
+        return VoicemailChangePinActivity.isDefaultOldPinSet(context, phoneAccountHandle);
+    }
 }
diff --git a/src/com/android/phone/vvm/omtp/sms/OmtpCvvmMessageSender.java b/src/com/android/phone/vvm/omtp/sms/OmtpCvvmMessageSender.java
index 7f45254..98d8594 100644
--- a/src/com/android/phone/vvm/omtp/sms/OmtpCvvmMessageSender.java
+++ b/src/com/android/phone/vvm/omtp/sms/OmtpCvvmMessageSender.java
@@ -48,7 +48,7 @@
     private void sendCvvmMessage(String request, PendingIntent sentIntent) {
         StringBuilder sb = new StringBuilder().append(request);
         sb.append(OmtpConstants.SMS_PREFIX_SEPARATOR);
-        appendField(sb, "dt", "15");
+        appendField(sb, "dt" /* device type */, "6" /* no VTT (transcription) support*/);
         sendSms(sb.toString(), sentIntent);
     }
 }
diff --git a/src/com/android/services/telephony/CdmaConferenceController.java b/src/com/android/services/telephony/CdmaConferenceController.java
index 0a7c18b..846df61 100644
--- a/src/com/android/services/telephony/CdmaConferenceController.java
+++ b/src/com/android/services/telephony/CdmaConferenceController.java
@@ -122,8 +122,18 @@
                 }
             }, ADD_OUTGOING_CONNECTION_DELAY_MILLIS);
         } else {
-            // This is the first connection, or it is incoming, so let it flow through.
-            addInternal(connection);
+            // Post the call to addInternal to the handler with no delay.
+            // Why you ask?  In TelephonyConnectionService#
+            // onCreateIncomingConnection(PhoneAccountHandle, ConnectionRequest) or
+            // TelephonyConnectionService#onCreateOutgoingConnection(PhoneAccountHandle,
+            // ConnectionRequest) we can create a new connection it will trigger a call to
+            // TelephonyConnectionService#addConnectionToConferenceController, which will cause us
+            // to get here.  HOWEVER, at this point ConnectionService#addConnection has not yet run,
+            // so if we end up calling ConnectionService#addConference, the connection service will
+            // not yet know about the new connection, so it won't get added to the conference.
+            // Posting to the handler ensures addConnection has a chance to happen before we add the
+            // conference.
+            mHandler.post(() -> addInternal(connection));
         }
     }