Post Connection Events to handler.

The disconnect messages are posted to the handler, but the connection
events were not.  This meant when merging calls into a conference, the
event to indicate the calls merged successfully would come BEFORE the
disconnect signals arrived in Telecom.
Putting the connection events to the handler ensures they arrive AFTER
the disconnect signals.

Test: Described in other CL on topic.
Bug: 139169804
Change-Id: I7491504032538e8ccc87cfc65b5eaaeb31e32de0
diff --git a/src/com/android/services/telephony/TelephonyConnection.java b/src/com/android/services/telephony/TelephonyConnection.java
index 996c8ea..414e4d2 100644
--- a/src/com/android/services/telephony/TelephonyConnection.java
+++ b/src/com/android/services/telephony/TelephonyConnection.java
@@ -43,6 +43,7 @@
 import android.util.Pair;
 
 import com.android.ims.ImsCall;
+import com.android.internal.os.SomeArgs;
 import com.android.internal.telephony.Call;
 import com.android.internal.telephony.CallFailCause;
 import com.android.internal.telephony.CallStateException;
@@ -98,6 +99,7 @@
     private static final int MSG_CDMA_VOICE_PRIVACY_OFF = 16;
     private static final int MSG_HANGUP = 17;
     private static final int MSG_SET_CALL_RADIO_TECH = 18;
+    private static final int MSG_ON_CONNECTION_EVENT = 19;
 
     private final Handler mHandler = new Handler(Looper.getMainLooper()) {
         @Override
@@ -267,6 +269,15 @@
                         refreshDisableAddCall();
                     }
                     break;
+                case MSG_ON_CONNECTION_EVENT:
+                    SomeArgs args = (SomeArgs) msg.obj;
+                    try {
+                        sendConnectionEvent((String) args.arg1, (Bundle) args.arg2);
+
+                    } finally {
+                        args.recycle();
+                    }
+                    break;
             }
         }
     };
@@ -554,7 +565,10 @@
          */
         @Override
         public void onConnectionEvent(String event, Bundle extras) {
-            sendConnectionEvent(event, extras);
+            SomeArgs args = SomeArgs.obtain();
+            args.arg1 = event;
+            args.arg2 = extras;
+            mHandler.obtainMessage(MSG_ON_CONNECTION_EVENT, args).sendToTarget();
         }
 
         @Override