Wiring up Ims framework multi-endpoint APIs.
Tyler Gunn [Wed, 13 Apr 2016 22:44:38 +0000 (15:44 -0700)]
Completing wireup of the Ims framework multi-endpoint APIs so that we can
hook into the telephony code.

Note: I followed how the ImsEcbm API was handled, which seemed pretty
similar to the multi-endpoint APIs.

Bug: 27458894
Change-Id: I21c6fc95947692a3cf4541ddb7510e1da702ec84

src/java/com/android/ims/ImsExternalCallStateListener.java [new file with mode: 0644]
src/java/com/android/ims/ImsManager.java
src/java/com/android/ims/ImsMultiEndpoint.java [new file with mode: 0644]

diff --git a/src/java/com/android/ims/ImsExternalCallStateListener.java b/src/java/com/android/ims/ImsExternalCallStateListener.java
new file mode 100644 (file)
index 0000000..3f4f163
--- /dev/null
@@ -0,0 +1,36 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License
+ */
+
+package com.android.ims;
+
+import java.util.List;
+
+/**
+ * Listener for receiving notifications about {@link ImsExternalCallState} information received
+ * from the network via a dialog event package.
+ *
+ * @hide
+ */
+public class ImsExternalCallStateListener {
+    /**
+     * Notifies client when Dialog Event Package update is received
+     *
+     * @param externalCallState the external call state.
+     */
+    public void onImsExternalCallStateUpdate(List<ImsExternalCallState> externalCallState) {
+        // no-op
+    }
+}
index 000f990..465ce3f 100644 (file)
@@ -36,6 +36,7 @@ import android.telephony.TelephonyManager;
 import com.android.ims.internal.IImsCallSession;
 import com.android.ims.internal.IImsEcbm;
 import com.android.ims.internal.IImsEcbmListener;
+import com.android.ims.internal.IImsMultiEndpoint;
 import com.android.ims.internal.IImsRegistrationListener;
 import com.android.ims.internal.IImsService;
 import com.android.ims.internal.IImsUt;
@@ -175,6 +176,8 @@ public class ImsManager {
     // ECBM interface
     private ImsEcbm mEcbm = null;
 
+    private ImsMultiEndpoint mMultiEndpoint = null;
+
     /**
      * Gets a manager instance.
      *
@@ -764,6 +767,7 @@ public class ImsManager {
             mUt = null;
             mConfig = null;
             mEcbm = null;
+            mMultiEndpoint = null;
         }
     }
 
@@ -1229,6 +1233,7 @@ public class ImsManager {
             mUt = null;
             mConfig = null;
             mEcbm = null;
+            mMultiEndpoint = null;
 
             if (mContext != null) {
                 Intent intent = new Intent(ACTION_IMS_SERVICE_DOWN);
@@ -1375,6 +1380,7 @@ public class ImsManager {
             }
         }
     }
+
     /**
      * Gets the ECBM interface to request ECBM exit.
      *
@@ -1403,6 +1409,34 @@ public class ImsManager {
     }
 
     /**
+     * Gets the Multi-Endpoint interface to subscribe to multi-enpoint notifications..
+     *
+     * @param serviceId a service id which is obtained from {@link ImsManager#open}
+     * @return the multi-endpoint interface instance
+     * @throws ImsException if getting the multi-endpoint interface results in an error
+     */
+    public ImsMultiEndpoint getMultiEndpointInterface(int serviceId) throws ImsException {
+        if (mMultiEndpoint == null) {
+            checkAndThrowExceptionIfServiceUnavailable();
+
+            try {
+                IImsMultiEndpoint iImsMultiEndpoint = mImsService.getMultiEndpointInterface(
+                        serviceId);
+
+                if (iImsMultiEndpoint == null) {
+                    throw new ImsException("getMultiEndpointInterface()",
+                            ImsReasonInfo.CODE_MULTIENDPOINT_NOT_SUPPORTED);
+                }
+                mMultiEndpoint = new ImsMultiEndpoint(iImsMultiEndpoint);
+            } catch (RemoteException e) {
+                throw new ImsException("getMultiEndpointInterface()", e,
+                        ImsReasonInfo.CODE_LOCAL_IMS_SERVICE_DOWN);
+            }
+        }
+        return mMultiEndpoint;
+    }
+
+    /**
      * Resets ImsManager settings back to factory defaults.
      *
      * @hide
diff --git a/src/java/com/android/ims/ImsMultiEndpoint.java b/src/java/com/android/ims/ImsMultiEndpoint.java
new file mode 100644 (file)
index 0000000..2cc19b1
--- /dev/null
@@ -0,0 +1,81 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License
+ */
+
+package com.android.ims;
+
+import com.android.ims.internal.IImsMultiEndpoint;
+import com.android.ims.internal.IImsExternalCallStateListener;
+
+import android.os.RemoteException;
+import android.telephony.Rlog;
+
+import java.util.List;
+
+/**
+ * Provides APIs for the IMS multi-endpoint functionality.  Specifically, provides a means for IMS
+ * to subscribe to dialog event packages issued by the network.
+ *
+ * @hide
+ */
+public class ImsMultiEndpoint {
+    /**
+     * Adapter class for {@link IImsExternalCallStateListener}.
+     */
+    private class ImsExternalCallStateListenerProxy extends IImsExternalCallStateListener.Stub {
+        private ImsExternalCallStateListener mListener;
+
+        public ImsExternalCallStateListenerProxy(ImsExternalCallStateListener listener) {
+            mListener = listener;
+        }
+
+
+        /**
+         * Notifies client when Dialog Event Package update is received
+         *
+         * @param externalCallState the external call state.
+         */
+        @Override
+        public void onImsExternalCallStateUpdate(List<ImsExternalCallState> externalCallState) {
+            if (DBG) Rlog.d(TAG, "onImsExternalCallStateUpdate");
+
+            if (mListener != null) {
+                mListener.onImsExternalCallStateUpdate(externalCallState);
+            }
+        }
+    }
+
+    private static final String TAG = "ImsMultiEndpoint";
+    private static final boolean DBG = true;
+
+    private final IImsMultiEndpoint mImsMultiendpoint;
+
+    public ImsMultiEndpoint(IImsMultiEndpoint iImsMultiEndpoint) {
+        if (DBG) Rlog.d(TAG, "ImsMultiEndpoint created");
+        mImsMultiendpoint = iImsMultiEndpoint;
+    }
+
+    public void setExternalCallStateListener(ImsExternalCallStateListener externalCallStateListener)
+            throws ImsException {
+        try {
+            if (DBG) Rlog.d(TAG, "setExternalCallStateListener");
+            mImsMultiendpoint.setListener(new ImsExternalCallStateListenerProxy(
+                    externalCallStateListener));
+        } catch (RemoteException e) {
+            throw new ImsException("setExternalCallStateListener could not be set.", e,
+                    ImsReasonInfo.CODE_LOCAL_IMS_SERVICE_DOWN);
+        }
+    }
+}