Implement test IMS conference event package harness.
Tyler Gunn [Mon, 27 Oct 2014 16:15:23 +0000 (09:15 -0700)]
- Change some methods on ImsCall so we can externally fake out the
reception of an ImsConferenceState instance.

Bug: 18119796
Change-Id: I0ed4ddce5d9e11e47f26c4931780e65d6a6b337d

src/java/com/android/ims/ImsCall.java

index 778679a..c927113 100644 (file)
@@ -34,6 +34,7 @@ import com.android.ims.internal.CallGroupManager;
 import com.android.ims.internal.ICall;
 import com.android.ims.internal.ImsCallSession;
 import com.android.ims.internal.ImsStreamMediaSession;
+import com.android.internal.annotations.VisibleForTesting;
 
 /**
  * Handles an IMS voice / video call over LTE. You can instantiate this class with
@@ -1569,7 +1570,8 @@ public class ImsCall implements ICall {
                         ", endpoint=" + endpoint);
             }
 
-            if ((mCallGroup != null) && (!mCallGroup.isOwner(ImsCall.this))) {
+            if (mCallGroup == null ||
+                    ((mCallGroup != null) && (!mCallGroup.isOwner(ImsCall.this)))) {
                 continue;
             }
 
@@ -2217,20 +2219,7 @@ public class ImsCall implements ICall {
                         + ", state=" + state);
             }
 
-            ImsCall.Listener listener;
-
-            synchronized(ImsCall.this) {
-                notifyConferenceStateUpdated(state);
-                listener = mListener;
-            }
-
-            if (listener != null) {
-                try {
-                    listener.onCallConferenceStateUpdated(ImsCall.this, state);
-                } catch (Throwable t) {
-                    loge("callSessionConferenceStateUpdated :: ", t);
-                }
-            }
+            conferenceStateUpdated(state);
         }
 
         @Override
@@ -2256,4 +2245,30 @@ public class ImsCall implements ICall {
             }
         }
     }
+
+    /**
+     * Report a new conference state to the current {@link ImsCall} and inform listeners of the
+     * change.  Marked as {@code VisibleForTesting} so that the
+     * {@code com.android.internal.telephony.TelephonyTester} class can inject a test conference
+     * event package into a regular ongoing IMS call.
+     *
+     * @param state The {@link ImsConferenceState}.
+     */
+    @VisibleForTesting
+    public void conferenceStateUpdated(ImsConferenceState state) {
+        Listener listener;
+
+        synchronized(this) {
+            notifyConferenceStateUpdated(state);
+            listener = mListener;
+        }
+
+        if (listener != null) {
+            try {
+                listener.onCallConferenceStateUpdated(this, state);
+            } catch (Throwable t) {
+                loge("callSessionConferenceStateUpdated :: ", t);
+            }
+        }
+    }
 }