ConnectionServiceAdapter.java revision 6b7f955c2d9b231660b8c54f8ef8e8e6ad802625
1bb69b0c2d821a9806fb00037284c399cbc78277dBen Gilad/* 2ab5d282dd6f487578ae86b2d53d0d8edc9b71747Sailesh Nepal * Copyright (C) 2014 The Android Open Source Project 3bb69b0c2d821a9806fb00037284c399cbc78277dBen Gilad * 4bb69b0c2d821a9806fb00037284c399cbc78277dBen Gilad * Licensed under the Apache License, Version 2.0 (the "License"); 5bb69b0c2d821a9806fb00037284c399cbc78277dBen Gilad * you may not use this file except in compliance with the License. 6bb69b0c2d821a9806fb00037284c399cbc78277dBen Gilad * You may obtain a copy of the License at 7bb69b0c2d821a9806fb00037284c399cbc78277dBen Gilad * 8bb69b0c2d821a9806fb00037284c399cbc78277dBen Gilad * http://www.apache.org/licenses/LICENSE-2.0 9bb69b0c2d821a9806fb00037284c399cbc78277dBen Gilad * 10bb69b0c2d821a9806fb00037284c399cbc78277dBen Gilad * Unless required by applicable law or agreed to in writing, software 11bb69b0c2d821a9806fb00037284c399cbc78277dBen Gilad * distributed under the License is distributed on an "AS IS" BASIS, 12bb69b0c2d821a9806fb00037284c399cbc78277dBen Gilad * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13bb69b0c2d821a9806fb00037284c399cbc78277dBen Gilad * See the License for the specific language governing permissions and 14bb69b0c2d821a9806fb00037284c399cbc78277dBen Gilad * limitations under the License. 15bb69b0c2d821a9806fb00037284c399cbc78277dBen Gilad */ 16bb69b0c2d821a9806fb00037284c399cbc78277dBen Gilad 17ef9f6f957d897ea0ed82114185b8fa3fefd4917bTyler Gunnpackage android.telecom; 18bb69b0c2d821a9806fb00037284c399cbc78277dBen Gilad 19612038642fa9cf1545dbcc8274d313192ce928b5Sailesh Nepalimport android.net.Uri; 206b7f955c2d9b231660b8c54f8ef8e8e6ad802625Santos Cordonimport android.os.Bundle; 2152d8a15e146e682319380322f94ceb6d93fa1a97Santos Cordonimport android.os.IBinder.DeathRecipient; 22ab5d282dd6f487578ae86b2d53d0d8edc9b71747Sailesh Nepalimport android.os.RemoteException; 23ab5d282dd6f487578ae86b2d53d0d8edc9b71747Sailesh Nepal 24ef9f6f957d897ea0ed82114185b8fa3fefd4917bTyler Gunnimport com.android.internal.telecom.IConnectionServiceAdapter; 25ef9f6f957d897ea0ed82114185b8fa3fefd4917bTyler Gunnimport com.android.internal.telecom.RemoteServiceCallback; 26bb69b0c2d821a9806fb00037284c399cbc78277dBen Gilad 27b0c0e36faf5b4218f290e95584528a41c1f22f21Jay Shraunerimport java.util.Collections; 284dd9df58a6bf662264f0aebddfb14b850358f9b9Sailesh Nepalimport java.util.Iterator; 29980acb9bd6984a9daad5f584bd35e8d503820200Santos Cordonimport java.util.List; 3052d8a15e146e682319380322f94ceb6d93fa1a97Santos Cordonimport java.util.Set; 31b0c0e36faf5b4218f290e95584528a41c1f22f21Jay Shraunerimport java.util.concurrent.ConcurrentHashMap; 32980acb9bd6984a9daad5f584bd35e8d503820200Santos Cordon 33bb69b0c2d821a9806fb00037284c399cbc78277dBen Gilad/** 342a46b90222e5c9c73de012382a604a71f9c0c30cSailesh Nepal * Provides methods for IConnectionService implementations to interact with the system phone app. 352bed9563edbec63ad41e2cd5fccc205d5b0891e5Sailesh Nepal * 362bed9563edbec63ad41e2cd5fccc205d5b0891e5Sailesh Nepal * @hide 37bb69b0c2d821a9806fb00037284c399cbc78277dBen Gilad */ 382a46b90222e5c9c73de012382a604a71f9c0c30cSailesh Nepalfinal class ConnectionServiceAdapter implements DeathRecipient { 39229e3820dce98f64fd4834d5f421faec9a9d7026Jay Shrauner /** 40229e3820dce98f64fd4834d5f421faec9a9d7026Jay Shrauner * ConcurrentHashMap constructor params: 8 is initial table size, 0.9f is 41229e3820dce98f64fd4834d5f421faec9a9d7026Jay Shrauner * load factor before resizing, 1 means we only expect a single thread to 42229e3820dce98f64fd4834d5f421faec9a9d7026Jay Shrauner * access the map so make only a single shard 43229e3820dce98f64fd4834d5f421faec9a9d7026Jay Shrauner */ 44b0c0e36faf5b4218f290e95584528a41c1f22f21Jay Shrauner private final Set<IConnectionServiceAdapter> mAdapters = Collections.newSetFromMap( 45229e3820dce98f64fd4834d5f421faec9a9d7026Jay Shrauner new ConcurrentHashMap<IConnectionServiceAdapter, Boolean>(8, 0.9f, 1)); 46ab5d282dd6f487578ae86b2d53d0d8edc9b71747Sailesh Nepal 472a46b90222e5c9c73de012382a604a71f9c0c30cSailesh Nepal ConnectionServiceAdapter() { 4852d8a15e146e682319380322f94ceb6d93fa1a97Santos Cordon } 4952d8a15e146e682319380322f94ceb6d93fa1a97Santos Cordon 502a46b90222e5c9c73de012382a604a71f9c0c30cSailesh Nepal void addAdapter(IConnectionServiceAdapter adapter) { 5152d8a15e146e682319380322f94ceb6d93fa1a97Santos Cordon if (mAdapters.add(adapter)) { 5252d8a15e146e682319380322f94ceb6d93fa1a97Santos Cordon try { 5352d8a15e146e682319380322f94ceb6d93fa1a97Santos Cordon adapter.asBinder().linkToDeath(this, 0); 5452d8a15e146e682319380322f94ceb6d93fa1a97Santos Cordon } catch (RemoteException e) { 5552d8a15e146e682319380322f94ceb6d93fa1a97Santos Cordon mAdapters.remove(adapter); 5652d8a15e146e682319380322f94ceb6d93fa1a97Santos Cordon } 5752d8a15e146e682319380322f94ceb6d93fa1a97Santos Cordon } 5852d8a15e146e682319380322f94ceb6d93fa1a97Santos Cordon } 5952d8a15e146e682319380322f94ceb6d93fa1a97Santos Cordon 602a46b90222e5c9c73de012382a604a71f9c0c30cSailesh Nepal void removeAdapter(IConnectionServiceAdapter adapter) { 61229e3820dce98f64fd4834d5f421faec9a9d7026Jay Shrauner if (adapter != null && mAdapters.remove(adapter)) { 6252d8a15e146e682319380322f94ceb6d93fa1a97Santos Cordon adapter.asBinder().unlinkToDeath(this, 0); 6352d8a15e146e682319380322f94ceb6d93fa1a97Santos Cordon } 6452d8a15e146e682319380322f94ceb6d93fa1a97Santos Cordon } 6552d8a15e146e682319380322f94ceb6d93fa1a97Santos Cordon 6652d8a15e146e682319380322f94ceb6d93fa1a97Santos Cordon /** ${inheritDoc} */ 6752d8a15e146e682319380322f94ceb6d93fa1a97Santos Cordon @Override 6852d8a15e146e682319380322f94ceb6d93fa1a97Santos Cordon public void binderDied() { 694dd9df58a6bf662264f0aebddfb14b850358f9b9Sailesh Nepal Iterator<IConnectionServiceAdapter> it = mAdapters.iterator(); 704dd9df58a6bf662264f0aebddfb14b850358f9b9Sailesh Nepal while (it.hasNext()) { 714dd9df58a6bf662264f0aebddfb14b850358f9b9Sailesh Nepal IConnectionServiceAdapter adapter = it.next(); 7252d8a15e146e682319380322f94ceb6d93fa1a97Santos Cordon if (!adapter.asBinder().isBinderAlive()) { 734dd9df58a6bf662264f0aebddfb14b850358f9b9Sailesh Nepal it.remove(); 744dd9df58a6bf662264f0aebddfb14b850358f9b9Sailesh Nepal adapter.asBinder().unlinkToDeath(this, 0); 7552d8a15e146e682319380322f94ceb6d93fa1a97Santos Cordon } 7652d8a15e146e682319380322f94ceb6d93fa1a97Santos Cordon } 77ab5d282dd6f487578ae86b2d53d0d8edc9b71747Sailesh Nepal } 78bb69b0c2d821a9806fb00037284c399cbc78277dBen Gilad 796107bab041fb7d851fbf865b7310d294aae970c8Ihab Awad void handleCreateConnectionComplete( 80b19a0bcdd8a5020c61a0d697f600fdc943c86f59Ihab Awad String id, 81b19a0bcdd8a5020c61a0d697f600fdc943c86f59Ihab Awad ConnectionRequest request, 82b19a0bcdd8a5020c61a0d697f600fdc943c86f59Ihab Awad ParcelableConnection connection) { 832a46b90222e5c9c73de012382a604a71f9c0c30cSailesh Nepal for (IConnectionServiceAdapter adapter : mAdapters) { 8452d8a15e146e682319380322f94ceb6d93fa1a97Santos Cordon try { 856107bab041fb7d851fbf865b7310d294aae970c8Ihab Awad adapter.handleCreateConnectionComplete(id, request, connection); 86506e38690fe5e3b627e243fdc20948c514b87680Sailesh Nepal } catch (RemoteException e) { 87506e38690fe5e3b627e243fdc20948c514b87680Sailesh Nepal } 88506e38690fe5e3b627e243fdc20948c514b87680Sailesh Nepal } 89ab5d282dd6f487578ae86b2d53d0d8edc9b71747Sailesh Nepal } 90bb69b0c2d821a9806fb00037284c399cbc78277dBen Gilad 91bb69b0c2d821a9806fb00037284c399cbc78277dBen Gilad /** 92bb69b0c2d821a9806fb00037284c399cbc78277dBen Gilad * Sets a call's state to active (e.g., an ongoing call where two parties can actively 93bb69b0c2d821a9806fb00037284c399cbc78277dBen Gilad * communicate). 943784133b95f1206c0c6bbbddb5921ef396b5b941Santos Cordon * 953784133b95f1206c0c6bbbddb5921ef396b5b941Santos Cordon * @param callId The unique ID of the call whose state is changing to active. 96bb69b0c2d821a9806fb00037284c399cbc78277dBen Gilad */ 972a46b90222e5c9c73de012382a604a71f9c0c30cSailesh Nepal void setActive(String callId) { 982a46b90222e5c9c73de012382a604a71f9c0c30cSailesh Nepal for (IConnectionServiceAdapter adapter : mAdapters) { 9952d8a15e146e682319380322f94ceb6d93fa1a97Santos Cordon try { 10052d8a15e146e682319380322f94ceb6d93fa1a97Santos Cordon adapter.setActive(callId); 10152d8a15e146e682319380322f94ceb6d93fa1a97Santos Cordon } catch (RemoteException e) { 10252d8a15e146e682319380322f94ceb6d93fa1a97Santos Cordon } 103ab5d282dd6f487578ae86b2d53d0d8edc9b71747Sailesh Nepal } 104ab5d282dd6f487578ae86b2d53d0d8edc9b71747Sailesh Nepal } 105bb69b0c2d821a9806fb00037284c399cbc78277dBen Gilad 106bb69b0c2d821a9806fb00037284c399cbc78277dBen Gilad /** 107bb69b0c2d821a9806fb00037284c399cbc78277dBen Gilad * Sets a call's state to ringing (e.g., an inbound ringing call). 1083784133b95f1206c0c6bbbddb5921ef396b5b941Santos Cordon * 1093784133b95f1206c0c6bbbddb5921ef396b5b941Santos Cordon * @param callId The unique ID of the call whose state is changing to ringing. 110bb69b0c2d821a9806fb00037284c399cbc78277dBen Gilad */ 1112a46b90222e5c9c73de012382a604a71f9c0c30cSailesh Nepal void setRinging(String callId) { 1122a46b90222e5c9c73de012382a604a71f9c0c30cSailesh Nepal for (IConnectionServiceAdapter adapter : mAdapters) { 11352d8a15e146e682319380322f94ceb6d93fa1a97Santos Cordon try { 11452d8a15e146e682319380322f94ceb6d93fa1a97Santos Cordon adapter.setRinging(callId); 11552d8a15e146e682319380322f94ceb6d93fa1a97Santos Cordon } catch (RemoteException e) { 11652d8a15e146e682319380322f94ceb6d93fa1a97Santos Cordon } 117ab5d282dd6f487578ae86b2d53d0d8edc9b71747Sailesh Nepal } 118ab5d282dd6f487578ae86b2d53d0d8edc9b71747Sailesh Nepal } 119bb69b0c2d821a9806fb00037284c399cbc78277dBen Gilad 120bb69b0c2d821a9806fb00037284c399cbc78277dBen Gilad /** 121bb69b0c2d821a9806fb00037284c399cbc78277dBen Gilad * Sets a call's state to dialing (e.g., dialing an outbound call). 1223784133b95f1206c0c6bbbddb5921ef396b5b941Santos Cordon * 1233784133b95f1206c0c6bbbddb5921ef396b5b941Santos Cordon * @param callId The unique ID of the call whose state is changing to dialing. 124bb69b0c2d821a9806fb00037284c399cbc78277dBen Gilad */ 1252a46b90222e5c9c73de012382a604a71f9c0c30cSailesh Nepal void setDialing(String callId) { 1262a46b90222e5c9c73de012382a604a71f9c0c30cSailesh Nepal for (IConnectionServiceAdapter adapter : mAdapters) { 12752d8a15e146e682319380322f94ceb6d93fa1a97Santos Cordon try { 12852d8a15e146e682319380322f94ceb6d93fa1a97Santos Cordon adapter.setDialing(callId); 12952d8a15e146e682319380322f94ceb6d93fa1a97Santos Cordon } catch (RemoteException e) { 13052d8a15e146e682319380322f94ceb6d93fa1a97Santos Cordon } 131ab5d282dd6f487578ae86b2d53d0d8edc9b71747Sailesh Nepal } 132ab5d282dd6f487578ae86b2d53d0d8edc9b71747Sailesh Nepal } 133bb69b0c2d821a9806fb00037284c399cbc78277dBen Gilad 134bb69b0c2d821a9806fb00037284c399cbc78277dBen Gilad /** 135bb69b0c2d821a9806fb00037284c399cbc78277dBen Gilad * Sets a call's state to disconnected. 1363784133b95f1206c0c6bbbddb5921ef396b5b941Santos Cordon * 1373784133b95f1206c0c6bbbddb5921ef396b5b941Santos Cordon * @param callId The unique ID of the call whose state is changing to disconnected. 1387f3d41fd124dd7c4a8b72c1d48df08a8ee7209ecAndrew Lee * @param disconnectCause The reason for the disconnection, as described by 1397f3d41fd124dd7c4a8b72c1d48df08a8ee7209ecAndrew Lee * {@link android.telecomm.DisconnectCause}. 140bb69b0c2d821a9806fb00037284c399cbc78277dBen Gilad */ 1417f3d41fd124dd7c4a8b72c1d48df08a8ee7209ecAndrew Lee void setDisconnected(String callId, DisconnectCause disconnectCause) { 1422a46b90222e5c9c73de012382a604a71f9c0c30cSailesh Nepal for (IConnectionServiceAdapter adapter : mAdapters) { 14352d8a15e146e682319380322f94ceb6d93fa1a97Santos Cordon try { 1447f3d41fd124dd7c4a8b72c1d48df08a8ee7209ecAndrew Lee adapter.setDisconnected(callId, disconnectCause); 14552d8a15e146e682319380322f94ceb6d93fa1a97Santos Cordon } catch (RemoteException e) { 14652d8a15e146e682319380322f94ceb6d93fa1a97Santos Cordon } 147ab5d282dd6f487578ae86b2d53d0d8edc9b71747Sailesh Nepal } 148ab5d282dd6f487578ae86b2d53d0d8edc9b71747Sailesh Nepal } 14981ccaaa25cc90c576c7df7c2cccb8a232e8536a1Yorke Lee 15081ccaaa25cc90c576c7df7c2cccb8a232e8536a1Yorke Lee /** 15181ccaaa25cc90c576c7df7c2cccb8a232e8536a1Yorke Lee * Sets a call's state to be on hold. 15281ccaaa25cc90c576c7df7c2cccb8a232e8536a1Yorke Lee * 15381ccaaa25cc90c576c7df7c2cccb8a232e8536a1Yorke Lee * @param callId - The unique ID of the call whose state is changing to be on hold. 15481ccaaa25cc90c576c7df7c2cccb8a232e8536a1Yorke Lee */ 1552a46b90222e5c9c73de012382a604a71f9c0c30cSailesh Nepal void setOnHold(String callId) { 1562a46b90222e5c9c73de012382a604a71f9c0c30cSailesh Nepal for (IConnectionServiceAdapter adapter : mAdapters) { 15752d8a15e146e682319380322f94ceb6d93fa1a97Santos Cordon try { 15852d8a15e146e682319380322f94ceb6d93fa1a97Santos Cordon adapter.setOnHold(callId); 15952d8a15e146e682319380322f94ceb6d93fa1a97Santos Cordon } catch (RemoteException e) { 16052d8a15e146e682319380322f94ceb6d93fa1a97Santos Cordon } 16181ccaaa25cc90c576c7df7c2cccb8a232e8536a1Yorke Lee } 16281ccaaa25cc90c576c7df7c2cccb8a232e8536a1Yorke Lee } 16381ccaaa25cc90c576c7df7c2cccb8a232e8536a1Yorke Lee 164f835897f9f799490de27653ae39141ba6bc14223Ihab Awad /** 165ef9f6f957d897ea0ed82114185b8fa3fefd4917bTyler Gunn * Asks Telecom to start or stop a ringback tone for a call. 166f835897f9f799490de27653ae39141ba6bc14223Ihab Awad * 167f835897f9f799490de27653ae39141ba6bc14223Ihab Awad * @param callId The unique ID of the call whose ringback is being changed. 168ef9f6f957d897ea0ed82114185b8fa3fefd4917bTyler Gunn * @param ringback Whether Telecom should start playing a ringback tone. 169f835897f9f799490de27653ae39141ba6bc14223Ihab Awad */ 170100e293fa8021caed956597daa4e01cb19be1c33Andrew Lee void setRingbackRequested(String callId, boolean ringback) { 1712a46b90222e5c9c73de012382a604a71f9c0c30cSailesh Nepal for (IConnectionServiceAdapter adapter : mAdapters) { 17252d8a15e146e682319380322f94ceb6d93fa1a97Santos Cordon try { 173100e293fa8021caed956597daa4e01cb19be1c33Andrew Lee adapter.setRingbackRequested(callId, ringback); 17452d8a15e146e682319380322f94ceb6d93fa1a97Santos Cordon } catch (RemoteException e) { 17552d8a15e146e682319380322f94ceb6d93fa1a97Santos Cordon } 176f835897f9f799490de27653ae39141ba6bc14223Ihab Awad } 177f835897f9f799490de27653ae39141ba6bc14223Ihab Awad } 17881ccaaa25cc90c576c7df7c2cccb8a232e8536a1Yorke Lee 1795c9c86ec0f95d1f5e1aca212967f508fc736b895Ihab Awad void setConnectionCapabilities(String callId, int capabilities) { 1802a46b90222e5c9c73de012382a604a71f9c0c30cSailesh Nepal for (IConnectionServiceAdapter adapter : mAdapters) { 18152d8a15e146e682319380322f94ceb6d93fa1a97Santos Cordon try { 1825c9c86ec0f95d1f5e1aca212967f508fc736b895Ihab Awad adapter.setConnectionCapabilities(callId, capabilities); 18352d8a15e146e682319380322f94ceb6d93fa1a97Santos Cordon } catch (RemoteException ignored) { 18452d8a15e146e682319380322f94ceb6d93fa1a97Santos Cordon } 185980acb9bd6984a9daad5f584bd35e8d503820200Santos Cordon } 186980acb9bd6984a9daad5f584bd35e8d503820200Santos Cordon } 187980acb9bd6984a9daad5f584bd35e8d503820200Santos Cordon 188980acb9bd6984a9daad5f584bd35e8d503820200Santos Cordon /** 189980acb9bd6984a9daad5f584bd35e8d503820200Santos Cordon * Indicates whether or not the specified call is currently conferenced into the specified 190980acb9bd6984a9daad5f584bd35e8d503820200Santos Cordon * conference call. 191980acb9bd6984a9daad5f584bd35e8d503820200Santos Cordon * 192980acb9bd6984a9daad5f584bd35e8d503820200Santos Cordon * @param callId The unique ID of the call being conferenced. 193b693998fdfdd4498a33c4c69405f2708e4840aa7Santos Cordon * @param conferenceCallId The unique ID of the conference call. Null if call is not 19452d8a15e146e682319380322f94ceb6d93fa1a97Santos Cordon * conferenced. 195980acb9bd6984a9daad5f584bd35e8d503820200Santos Cordon */ 1962a46b90222e5c9c73de012382a604a71f9c0c30cSailesh Nepal void setIsConferenced(String callId, String conferenceCallId) { 1972a46b90222e5c9c73de012382a604a71f9c0c30cSailesh Nepal for (IConnectionServiceAdapter adapter : mAdapters) { 19852d8a15e146e682319380322f94ceb6d93fa1a97Santos Cordon try { 1990159ac0cfe20e8f85ee4150e64d91392850f8a3fSantos Cordon Log.d(this, "sending connection %s with conference %s", callId, conferenceCallId); 20052d8a15e146e682319380322f94ceb6d93fa1a97Santos Cordon adapter.setIsConferenced(callId, conferenceCallId); 20152d8a15e146e682319380322f94ceb6d93fa1a97Santos Cordon } catch (RemoteException ignored) { 20252d8a15e146e682319380322f94ceb6d93fa1a97Santos Cordon } 203980acb9bd6984a9daad5f584bd35e8d503820200Santos Cordon } 204980acb9bd6984a9daad5f584bd35e8d503820200Santos Cordon } 205980acb9bd6984a9daad5f584bd35e8d503820200Santos Cordon 206980acb9bd6984a9daad5f584bd35e8d503820200Santos Cordon /** 20717455a3d39350a39eb995897929977d793358365Anthony Lee * Indicates that the merge request on this call has failed. 20817455a3d39350a39eb995897929977d793358365Anthony Lee * 20917455a3d39350a39eb995897929977d793358365Anthony Lee * @param callId The unique ID of the call being conferenced. 21017455a3d39350a39eb995897929977d793358365Anthony Lee */ 21117455a3d39350a39eb995897929977d793358365Anthony Lee void onConferenceMergeFailed(String callId) { 21217455a3d39350a39eb995897929977d793358365Anthony Lee for (IConnectionServiceAdapter adapter : mAdapters) { 21317455a3d39350a39eb995897929977d793358365Anthony Lee try { 21417455a3d39350a39eb995897929977d793358365Anthony Lee Log.d(this, "merge failed for call %s", callId); 21517455a3d39350a39eb995897929977d793358365Anthony Lee adapter.setConferenceMergeFailed(callId); 21617455a3d39350a39eb995897929977d793358365Anthony Lee } catch (RemoteException ignored) { 21717455a3d39350a39eb995897929977d793358365Anthony Lee } 21817455a3d39350a39eb995897929977d793358365Anthony Lee } 21917455a3d39350a39eb995897929977d793358365Anthony Lee } 22017455a3d39350a39eb995897929977d793358365Anthony Lee 22117455a3d39350a39eb995897929977d793358365Anthony Lee /** 222980acb9bd6984a9daad5f584bd35e8d503820200Santos Cordon * Indicates that the call no longer exists. Can be used with either a call or a conference 223980acb9bd6984a9daad5f584bd35e8d503820200Santos Cordon * call. 224980acb9bd6984a9daad5f584bd35e8d503820200Santos Cordon * 225980acb9bd6984a9daad5f584bd35e8d503820200Santos Cordon * @param callId The unique ID of the call. 226980acb9bd6984a9daad5f584bd35e8d503820200Santos Cordon */ 2272a46b90222e5c9c73de012382a604a71f9c0c30cSailesh Nepal void removeCall(String callId) { 2282a46b90222e5c9c73de012382a604a71f9c0c30cSailesh Nepal for (IConnectionServiceAdapter adapter : mAdapters) { 22952d8a15e146e682319380322f94ceb6d93fa1a97Santos Cordon try { 23052d8a15e146e682319380322f94ceb6d93fa1a97Santos Cordon adapter.removeCall(callId); 23152d8a15e146e682319380322f94ceb6d93fa1a97Santos Cordon } catch (RemoteException ignored) { 23252d8a15e146e682319380322f94ceb6d93fa1a97Santos Cordon } 233980acb9bd6984a9daad5f584bd35e8d503820200Santos Cordon } 234980acb9bd6984a9daad5f584bd35e8d503820200Santos Cordon } 2356dea4aceba8f69ee4be346ec356d277a3c153f3dEvan Charlton 2362a46b90222e5c9c73de012382a604a71f9c0c30cSailesh Nepal void onPostDialWait(String callId, String remaining) { 2372a46b90222e5c9c73de012382a604a71f9c0c30cSailesh Nepal for (IConnectionServiceAdapter adapter : mAdapters) { 23852d8a15e146e682319380322f94ceb6d93fa1a97Santos Cordon try { 23952d8a15e146e682319380322f94ceb6d93fa1a97Santos Cordon adapter.onPostDialWait(callId, remaining); 24052d8a15e146e682319380322f94ceb6d93fa1a97Santos Cordon } catch (RemoteException ignored) { 24152d8a15e146e682319380322f94ceb6d93fa1a97Santos Cordon } 2426dea4aceba8f69ee4be346ec356d277a3c153f3dEvan Charlton } 2436dea4aceba8f69ee4be346ec356d277a3c153f3dEvan Charlton } 2448b4818d9b4d632f2d460e7ac9dea463b04db43feSailesh Nepal 24527d1c2d148fe377ca0d2744f0f85789a42c8f808Nancy Chen void onPostDialChar(String callId, char nextChar) { 24627d1c2d148fe377ca0d2744f0f85789a42c8f808Nancy Chen for (IConnectionServiceAdapter adapter : mAdapters) { 24727d1c2d148fe377ca0d2744f0f85789a42c8f808Nancy Chen try { 24827d1c2d148fe377ca0d2744f0f85789a42c8f808Nancy Chen adapter.onPostDialChar(callId, nextChar); 24927d1c2d148fe377ca0d2744f0f85789a42c8f808Nancy Chen } catch (RemoteException ignored) { 25027d1c2d148fe377ca0d2744f0f85789a42c8f808Nancy Chen } 25127d1c2d148fe377ca0d2744f0f85789a42c8f808Nancy Chen } 25227d1c2d148fe377ca0d2744f0f85789a42c8f808Nancy Chen } 25327d1c2d148fe377ca0d2744f0f85789a42c8f808Nancy Chen 2548b4818d9b4d632f2d460e7ac9dea463b04db43feSailesh Nepal /** 255b693998fdfdd4498a33c4c69405f2708e4840aa7Santos Cordon * Indicates that a new conference call has been created. 256b693998fdfdd4498a33c4c69405f2708e4840aa7Santos Cordon * 257b693998fdfdd4498a33c4c69405f2708e4840aa7Santos Cordon * @param callId The unique ID of the conference call. 258b693998fdfdd4498a33c4c69405f2708e4840aa7Santos Cordon */ 259823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon void addConferenceCall(String callId, ParcelableConference parcelableConference) { 2602a46b90222e5c9c73de012382a604a71f9c0c30cSailesh Nepal for (IConnectionServiceAdapter adapter : mAdapters) { 26152d8a15e146e682319380322f94ceb6d93fa1a97Santos Cordon try { 262823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon adapter.addConferenceCall(callId, parcelableConference); 26352d8a15e146e682319380322f94ceb6d93fa1a97Santos Cordon } catch (RemoteException ignored) { 26452d8a15e146e682319380322f94ceb6d93fa1a97Santos Cordon } 26552d8a15e146e682319380322f94ceb6d93fa1a97Santos Cordon } 26652d8a15e146e682319380322f94ceb6d93fa1a97Santos Cordon } 26752d8a15e146e682319380322f94ceb6d93fa1a97Santos Cordon 26852d8a15e146e682319380322f94ceb6d93fa1a97Santos Cordon /** 26952d8a15e146e682319380322f94ceb6d93fa1a97Santos Cordon * Retrieves a list of remote connection services usable to place calls. 27052d8a15e146e682319380322f94ceb6d93fa1a97Santos Cordon */ 2712a46b90222e5c9c73de012382a604a71f9c0c30cSailesh Nepal void queryRemoteConnectionServices(RemoteServiceCallback callback) { 27252d8a15e146e682319380322f94ceb6d93fa1a97Santos Cordon // Only supported when there is only one adapter. 27352d8a15e146e682319380322f94ceb6d93fa1a97Santos Cordon if (mAdapters.size() == 1) { 27452d8a15e146e682319380322f94ceb6d93fa1a97Santos Cordon try { 27552d8a15e146e682319380322f94ceb6d93fa1a97Santos Cordon mAdapters.iterator().next().queryRemoteConnectionServices(callback); 27652d8a15e146e682319380322f94ceb6d93fa1a97Santos Cordon } catch (RemoteException e) { 27752d8a15e146e682319380322f94ceb6d93fa1a97Santos Cordon Log.e(this, e, "Exception trying to query for remote CSs"); 27852d8a15e146e682319380322f94ceb6d93fa1a97Santos Cordon } 279b693998fdfdd4498a33c4c69405f2708e4840aa7Santos Cordon } 280b693998fdfdd4498a33c4c69405f2708e4840aa7Santos Cordon } 2815ffbe8b850c2703b64617f0140d051a5412dd861Andrew Lee 2825ffbe8b850c2703b64617f0140d051a5412dd861Andrew Lee /** 2835ffbe8b850c2703b64617f0140d051a5412dd861Andrew Lee * Sets the call video provider for a call. 2845ffbe8b850c2703b64617f0140d051a5412dd861Andrew Lee * 2855ffbe8b850c2703b64617f0140d051a5412dd861Andrew Lee * @param callId The unique ID of the call to set with the given call video provider. 286b19a0bcdd8a5020c61a0d697f600fdc943c86f59Ihab Awad * @param videoProvider The call video provider instance to set on the call. 2875ffbe8b850c2703b64617f0140d051a5412dd861Andrew Lee */ 288b19a0bcdd8a5020c61a0d697f600fdc943c86f59Ihab Awad void setVideoProvider( 289b19a0bcdd8a5020c61a0d697f600fdc943c86f59Ihab Awad String callId, Connection.VideoProvider videoProvider) { 2902a46b90222e5c9c73de012382a604a71f9c0c30cSailesh Nepal for (IConnectionServiceAdapter adapter : mAdapters) { 2915ffbe8b850c2703b64617f0140d051a5412dd861Andrew Lee try { 292b19a0bcdd8a5020c61a0d697f600fdc943c86f59Ihab Awad adapter.setVideoProvider( 293e8dc4bef00e391defbdee0264b2ed955b1117841Santos Cordon callId, 294b19a0bcdd8a5020c61a0d697f600fdc943c86f59Ihab Awad videoProvider == null ? null : videoProvider.getInterface()); 2955ffbe8b850c2703b64617f0140d051a5412dd861Andrew Lee } catch (RemoteException e) { 2965ffbe8b850c2703b64617f0140d051a5412dd861Andrew Lee } 2975ffbe8b850c2703b64617f0140d051a5412dd861Andrew Lee } 2985ffbe8b850c2703b64617f0140d051a5412dd861Andrew Lee } 2998d83fa9bbd2ad15299a4419241eb10404e7839beTyler Gunn 3008d83fa9bbd2ad15299a4419241eb10404e7839beTyler Gunn /** 30133aaae4a07fdcce223fe74d96d751f4bffa6723aSailesh Nepal * Requests that the framework use VOIP audio mode for this connection. 30233aaae4a07fdcce223fe74d96d751f4bffa6723aSailesh Nepal * 30333aaae4a07fdcce223fe74d96d751f4bffa6723aSailesh Nepal * @param callId The unique ID of the call to set with the given call video provider. 30433aaae4a07fdcce223fe74d96d751f4bffa6723aSailesh Nepal * @param isVoip True if the audio mode is VOIP. 30533aaae4a07fdcce223fe74d96d751f4bffa6723aSailesh Nepal */ 306100e293fa8021caed956597daa4e01cb19be1c33Andrew Lee void setIsVoipAudioMode(String callId, boolean isVoip) { 30733aaae4a07fdcce223fe74d96d751f4bffa6723aSailesh Nepal for (IConnectionServiceAdapter adapter : mAdapters) { 30833aaae4a07fdcce223fe74d96d751f4bffa6723aSailesh Nepal try { 309100e293fa8021caed956597daa4e01cb19be1c33Andrew Lee adapter.setIsVoipAudioMode(callId, isVoip); 31033aaae4a07fdcce223fe74d96d751f4bffa6723aSailesh Nepal } catch (RemoteException e) { 31133aaae4a07fdcce223fe74d96d751f4bffa6723aSailesh Nepal } 31233aaae4a07fdcce223fe74d96d751f4bffa6723aSailesh Nepal } 31333aaae4a07fdcce223fe74d96d751f4bffa6723aSailesh Nepal } 31433aaae4a07fdcce223fe74d96d751f4bffa6723aSailesh Nepal 315e7ef59a77d55c9802cc7d919f7dd794bd5fea30eSailesh Nepal void setStatusHints(String callId, StatusHints statusHints) { 316e7ef59a77d55c9802cc7d919f7dd794bd5fea30eSailesh Nepal for (IConnectionServiceAdapter adapter : mAdapters) { 317e7ef59a77d55c9802cc7d919f7dd794bd5fea30eSailesh Nepal try { 318e7ef59a77d55c9802cc7d919f7dd794bd5fea30eSailesh Nepal adapter.setStatusHints(callId, statusHints); 319e7ef59a77d55c9802cc7d919f7dd794bd5fea30eSailesh Nepal } catch (RemoteException e) { 320e7ef59a77d55c9802cc7d919f7dd794bd5fea30eSailesh Nepal } 321e7ef59a77d55c9802cc7d919f7dd794bd5fea30eSailesh Nepal } 322e7ef59a77d55c9802cc7d919f7dd794bd5fea30eSailesh Nepal } 323e7ef59a77d55c9802cc7d919f7dd794bd5fea30eSailesh Nepal 324100e293fa8021caed956597daa4e01cb19be1c33Andrew Lee void setAddress(String callId, Uri address, int presentation) { 3252a46b90222e5c9c73de012382a604a71f9c0c30cSailesh Nepal for (IConnectionServiceAdapter adapter : mAdapters) { 3268d83fa9bbd2ad15299a4419241eb10404e7839beTyler Gunn try { 327100e293fa8021caed956597daa4e01cb19be1c33Andrew Lee adapter.setAddress(callId, address, presentation); 328612038642fa9cf1545dbcc8274d313192ce928b5Sailesh Nepal } catch (RemoteException e) { 329612038642fa9cf1545dbcc8274d313192ce928b5Sailesh Nepal } 330612038642fa9cf1545dbcc8274d313192ce928b5Sailesh Nepal } 331612038642fa9cf1545dbcc8274d313192ce928b5Sailesh Nepal } 332612038642fa9cf1545dbcc8274d313192ce928b5Sailesh Nepal 333612038642fa9cf1545dbcc8274d313192ce928b5Sailesh Nepal void setCallerDisplayName(String callId, String callerDisplayName, int presentation) { 334612038642fa9cf1545dbcc8274d313192ce928b5Sailesh Nepal for (IConnectionServiceAdapter adapter : mAdapters) { 335612038642fa9cf1545dbcc8274d313192ce928b5Sailesh Nepal try { 336612038642fa9cf1545dbcc8274d313192ce928b5Sailesh Nepal adapter.setCallerDisplayName(callId, callerDisplayName, presentation); 337612038642fa9cf1545dbcc8274d313192ce928b5Sailesh Nepal } catch (RemoteException e) { 3388d83fa9bbd2ad15299a4419241eb10404e7839beTyler Gunn } 3398d83fa9bbd2ad15299a4419241eb10404e7839beTyler Gunn } 3408d83fa9bbd2ad15299a4419241eb10404e7839beTyler Gunn } 341aa07df84f279a87ad6370758c9d792a660f2cebbTyler Gunn 342aa07df84f279a87ad6370758c9d792a660f2cebbTyler Gunn /** 343aa07df84f279a87ad6370758c9d792a660f2cebbTyler Gunn * Sets the video state associated with a call. 344aa07df84f279a87ad6370758c9d792a660f2cebbTyler Gunn * 345b19a0bcdd8a5020c61a0d697f600fdc943c86f59Ihab Awad * Valid values: {@link VideoProfile.VideoState#AUDIO_ONLY}, 346b19a0bcdd8a5020c61a0d697f600fdc943c86f59Ihab Awad * {@link VideoProfile.VideoState#BIDIRECTIONAL}, 347b19a0bcdd8a5020c61a0d697f600fdc943c86f59Ihab Awad * {@link VideoProfile.VideoState#TX_ENABLED}, 348b19a0bcdd8a5020c61a0d697f600fdc943c86f59Ihab Awad * {@link VideoProfile.VideoState#RX_ENABLED}. 349aa07df84f279a87ad6370758c9d792a660f2cebbTyler Gunn * 350aa07df84f279a87ad6370758c9d792a660f2cebbTyler Gunn * @param callId The unique ID of the call to set the video state for. 351aa07df84f279a87ad6370758c9d792a660f2cebbTyler Gunn * @param videoState The video state. 352aa07df84f279a87ad6370758c9d792a660f2cebbTyler Gunn */ 353aa07df84f279a87ad6370758c9d792a660f2cebbTyler Gunn void setVideoState(String callId, int videoState) { 354aa07df84f279a87ad6370758c9d792a660f2cebbTyler Gunn Log.v(this, "setVideoState: %d", videoState); 355aa07df84f279a87ad6370758c9d792a660f2cebbTyler Gunn for (IConnectionServiceAdapter adapter : mAdapters) { 356aa07df84f279a87ad6370758c9d792a660f2cebbTyler Gunn try { 357aa07df84f279a87ad6370758c9d792a660f2cebbTyler Gunn adapter.setVideoState(callId, videoState); 358aa07df84f279a87ad6370758c9d792a660f2cebbTyler Gunn } catch (RemoteException ignored) { 359aa07df84f279a87ad6370758c9d792a660f2cebbTyler Gunn } 360aa07df84f279a87ad6370758c9d792a660f2cebbTyler Gunn } 361aa07df84f279a87ad6370758c9d792a660f2cebbTyler Gunn } 3622ab88cc313fc4af7fb9436e236cd3a5d1ac58478Sailesh Nepal 3637c7bc7f6917484250974c5da00af9ef756844b0aSantos Cordon void setConferenceableConnections(String callId, List<String> conferenceableCallIds) { 3647c7bc7f6917484250974c5da00af9ef756844b0aSantos Cordon Log.v(this, "setConferenceableConnections: %s, %s", callId, conferenceableCallIds); 3657c7bc7f6917484250974c5da00af9ef756844b0aSantos Cordon for (IConnectionServiceAdapter adapter : mAdapters) { 3667c7bc7f6917484250974c5da00af9ef756844b0aSantos Cordon try { 3677c7bc7f6917484250974c5da00af9ef756844b0aSantos Cordon adapter.setConferenceableConnections(callId, conferenceableCallIds); 3687c7bc7f6917484250974c5da00af9ef756844b0aSantos Cordon } catch (RemoteException ignored) { 3697c7bc7f6917484250974c5da00af9ef756844b0aSantos Cordon } 3707c7bc7f6917484250974c5da00af9ef756844b0aSantos Cordon } 3717c7bc7f6917484250974c5da00af9ef756844b0aSantos Cordon } 3724a57b9b59b74c97e559a301af0add13cd4c3331cTyler Gunn 3734a57b9b59b74c97e559a301af0add13cd4c3331cTyler Gunn /** 3744a57b9b59b74c97e559a301af0add13cd4c3331cTyler Gunn * Informs telecom of an existing connection which was added by the {@link ConnectionService}. 3754a57b9b59b74c97e559a301af0add13cd4c3331cTyler Gunn * 3764a57b9b59b74c97e559a301af0add13cd4c3331cTyler Gunn * @param callId The unique ID of the call being added. 3774a57b9b59b74c97e559a301af0add13cd4c3331cTyler Gunn * @param connection The connection. 3784a57b9b59b74c97e559a301af0add13cd4c3331cTyler Gunn */ 3794a57b9b59b74c97e559a301af0add13cd4c3331cTyler Gunn void addExistingConnection(String callId, ParcelableConnection connection) { 3804a57b9b59b74c97e559a301af0add13cd4c3331cTyler Gunn Log.v(this, "addExistingConnection: %s", callId); 3814a57b9b59b74c97e559a301af0add13cd4c3331cTyler Gunn for (IConnectionServiceAdapter adapter : mAdapters) { 3824a57b9b59b74c97e559a301af0add13cd4c3331cTyler Gunn try { 3834a57b9b59b74c97e559a301af0add13cd4c3331cTyler Gunn adapter.addExistingConnection(callId, connection); 3844a57b9b59b74c97e559a301af0add13cd4c3331cTyler Gunn } catch (RemoteException ignored) { 3854a57b9b59b74c97e559a301af0add13cd4c3331cTyler Gunn } 3864a57b9b59b74c97e559a301af0add13cd4c3331cTyler Gunn } 3874a57b9b59b74c97e559a301af0add13cd4c3331cTyler Gunn } 3886b7f955c2d9b231660b8c54f8ef8e8e6ad802625Santos Cordon 3896b7f955c2d9b231660b8c54f8ef8e8e6ad802625Santos Cordon /** 3906b7f955c2d9b231660b8c54f8ef8e8e6ad802625Santos Cordon * Sets extras associated with a connection. 3916b7f955c2d9b231660b8c54f8ef8e8e6ad802625Santos Cordon * 3926b7f955c2d9b231660b8c54f8ef8e8e6ad802625Santos Cordon * @param callId The unique ID of the call. 3936b7f955c2d9b231660b8c54f8ef8e8e6ad802625Santos Cordon * @param extras The extras to associate with this call. 3946b7f955c2d9b231660b8c54f8ef8e8e6ad802625Santos Cordon */ 3956b7f955c2d9b231660b8c54f8ef8e8e6ad802625Santos Cordon void setExtras(String callId, Bundle extras) { 3966b7f955c2d9b231660b8c54f8ef8e8e6ad802625Santos Cordon Log.v(this, "setExtras: %s", extras); 3976b7f955c2d9b231660b8c54f8ef8e8e6ad802625Santos Cordon for (IConnectionServiceAdapter adapter : mAdapters) { 3986b7f955c2d9b231660b8c54f8ef8e8e6ad802625Santos Cordon try { 3996b7f955c2d9b231660b8c54f8ef8e8e6ad802625Santos Cordon adapter.setExtras(callId, extras); 4006b7f955c2d9b231660b8c54f8ef8e8e6ad802625Santos Cordon } catch (RemoteException ignored) { 4016b7f955c2d9b231660b8c54f8ef8e8e6ad802625Santos Cordon } 4026b7f955c2d9b231660b8c54f8ef8e8e6ad802625Santos Cordon } 4036b7f955c2d9b231660b8c54f8ef8e8e6ad802625Santos Cordon } 404bb69b0c2d821a9806fb00037284c399cbc78277dBen Gilad} 405