ConnectionServiceAdapter.java revision 876dbfb4767da4a2ba5459d5b78fb6eb55e4516f
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) { 5175c36b681e3331f4e60fa62abe4615c1ffc5b401Roshan Pius for (IConnectionServiceAdapter it : mAdapters) { 5275c36b681e3331f4e60fa62abe4615c1ffc5b401Roshan Pius if (it.asBinder() == adapter.asBinder()) { 5375c36b681e3331f4e60fa62abe4615c1ffc5b401Roshan Pius Log.w(this, "Ignoring duplicate adapter addition."); 5475c36b681e3331f4e60fa62abe4615c1ffc5b401Roshan Pius return; 5575c36b681e3331f4e60fa62abe4615c1ffc5b401Roshan Pius } 5675c36b681e3331f4e60fa62abe4615c1ffc5b401Roshan Pius } 5752d8a15e146e682319380322f94ceb6d93fa1a97Santos Cordon if (mAdapters.add(adapter)) { 5852d8a15e146e682319380322f94ceb6d93fa1a97Santos Cordon try { 5952d8a15e146e682319380322f94ceb6d93fa1a97Santos Cordon adapter.asBinder().linkToDeath(this, 0); 6052d8a15e146e682319380322f94ceb6d93fa1a97Santos Cordon } catch (RemoteException e) { 6152d8a15e146e682319380322f94ceb6d93fa1a97Santos Cordon mAdapters.remove(adapter); 6252d8a15e146e682319380322f94ceb6d93fa1a97Santos Cordon } 6352d8a15e146e682319380322f94ceb6d93fa1a97Santos Cordon } 6452d8a15e146e682319380322f94ceb6d93fa1a97Santos Cordon } 6552d8a15e146e682319380322f94ceb6d93fa1a97Santos Cordon 662a46b90222e5c9c73de012382a604a71f9c0c30cSailesh Nepal void removeAdapter(IConnectionServiceAdapter adapter) { 6775c36b681e3331f4e60fa62abe4615c1ffc5b401Roshan Pius if (adapter != null) { 6875c36b681e3331f4e60fa62abe4615c1ffc5b401Roshan Pius for (IConnectionServiceAdapter it : mAdapters) { 6975c36b681e3331f4e60fa62abe4615c1ffc5b401Roshan Pius if (it.asBinder() == adapter.asBinder() && mAdapters.remove(it)) { 7075c36b681e3331f4e60fa62abe4615c1ffc5b401Roshan Pius adapter.asBinder().unlinkToDeath(this, 0); 7175c36b681e3331f4e60fa62abe4615c1ffc5b401Roshan Pius break; 7275c36b681e3331f4e60fa62abe4615c1ffc5b401Roshan Pius } 7375c36b681e3331f4e60fa62abe4615c1ffc5b401Roshan Pius } 7452d8a15e146e682319380322f94ceb6d93fa1a97Santos Cordon } 7552d8a15e146e682319380322f94ceb6d93fa1a97Santos Cordon } 7652d8a15e146e682319380322f94ceb6d93fa1a97Santos Cordon 7752d8a15e146e682319380322f94ceb6d93fa1a97Santos Cordon /** ${inheritDoc} */ 7852d8a15e146e682319380322f94ceb6d93fa1a97Santos Cordon @Override 7952d8a15e146e682319380322f94ceb6d93fa1a97Santos Cordon public void binderDied() { 804dd9df58a6bf662264f0aebddfb14b850358f9b9Sailesh Nepal Iterator<IConnectionServiceAdapter> it = mAdapters.iterator(); 814dd9df58a6bf662264f0aebddfb14b850358f9b9Sailesh Nepal while (it.hasNext()) { 824dd9df58a6bf662264f0aebddfb14b850358f9b9Sailesh Nepal IConnectionServiceAdapter adapter = it.next(); 8352d8a15e146e682319380322f94ceb6d93fa1a97Santos Cordon if (!adapter.asBinder().isBinderAlive()) { 844dd9df58a6bf662264f0aebddfb14b850358f9b9Sailesh Nepal it.remove(); 854dd9df58a6bf662264f0aebddfb14b850358f9b9Sailesh Nepal adapter.asBinder().unlinkToDeath(this, 0); 8652d8a15e146e682319380322f94ceb6d93fa1a97Santos Cordon } 8752d8a15e146e682319380322f94ceb6d93fa1a97Santos Cordon } 88ab5d282dd6f487578ae86b2d53d0d8edc9b71747Sailesh Nepal } 89bb69b0c2d821a9806fb00037284c399cbc78277dBen Gilad 906107bab041fb7d851fbf865b7310d294aae970c8Ihab Awad void handleCreateConnectionComplete( 91b19a0bcdd8a5020c61a0d697f600fdc943c86f59Ihab Awad String id, 92b19a0bcdd8a5020c61a0d697f600fdc943c86f59Ihab Awad ConnectionRequest request, 93b19a0bcdd8a5020c61a0d697f600fdc943c86f59Ihab Awad ParcelableConnection connection) { 942a46b90222e5c9c73de012382a604a71f9c0c30cSailesh Nepal for (IConnectionServiceAdapter adapter : mAdapters) { 9552d8a15e146e682319380322f94ceb6d93fa1a97Santos Cordon try { 966107bab041fb7d851fbf865b7310d294aae970c8Ihab Awad adapter.handleCreateConnectionComplete(id, request, connection); 97506e38690fe5e3b627e243fdc20948c514b87680Sailesh Nepal } catch (RemoteException e) { 98506e38690fe5e3b627e243fdc20948c514b87680Sailesh Nepal } 99506e38690fe5e3b627e243fdc20948c514b87680Sailesh Nepal } 100ab5d282dd6f487578ae86b2d53d0d8edc9b71747Sailesh Nepal } 101bb69b0c2d821a9806fb00037284c399cbc78277dBen Gilad 102bb69b0c2d821a9806fb00037284c399cbc78277dBen Gilad /** 103bb69b0c2d821a9806fb00037284c399cbc78277dBen Gilad * Sets a call's state to active (e.g., an ongoing call where two parties can actively 104bb69b0c2d821a9806fb00037284c399cbc78277dBen Gilad * communicate). 1053784133b95f1206c0c6bbbddb5921ef396b5b941Santos Cordon * 1063784133b95f1206c0c6bbbddb5921ef396b5b941Santos Cordon * @param callId The unique ID of the call whose state is changing to active. 107bb69b0c2d821a9806fb00037284c399cbc78277dBen Gilad */ 1082a46b90222e5c9c73de012382a604a71f9c0c30cSailesh Nepal void setActive(String callId) { 1092a46b90222e5c9c73de012382a604a71f9c0c30cSailesh Nepal for (IConnectionServiceAdapter adapter : mAdapters) { 11052d8a15e146e682319380322f94ceb6d93fa1a97Santos Cordon try { 11152d8a15e146e682319380322f94ceb6d93fa1a97Santos Cordon adapter.setActive(callId); 11252d8a15e146e682319380322f94ceb6d93fa1a97Santos Cordon } catch (RemoteException e) { 11352d8a15e146e682319380322f94ceb6d93fa1a97Santos Cordon } 114ab5d282dd6f487578ae86b2d53d0d8edc9b71747Sailesh Nepal } 115ab5d282dd6f487578ae86b2d53d0d8edc9b71747Sailesh Nepal } 116bb69b0c2d821a9806fb00037284c399cbc78277dBen Gilad 117bb69b0c2d821a9806fb00037284c399cbc78277dBen Gilad /** 118bb69b0c2d821a9806fb00037284c399cbc78277dBen Gilad * Sets a call's state to ringing (e.g., an inbound ringing call). 1193784133b95f1206c0c6bbbddb5921ef396b5b941Santos Cordon * 1203784133b95f1206c0c6bbbddb5921ef396b5b941Santos Cordon * @param callId The unique ID of the call whose state is changing to ringing. 121bb69b0c2d821a9806fb00037284c399cbc78277dBen Gilad */ 1222a46b90222e5c9c73de012382a604a71f9c0c30cSailesh Nepal void setRinging(String callId) { 1232a46b90222e5c9c73de012382a604a71f9c0c30cSailesh Nepal for (IConnectionServiceAdapter adapter : mAdapters) { 12452d8a15e146e682319380322f94ceb6d93fa1a97Santos Cordon try { 12552d8a15e146e682319380322f94ceb6d93fa1a97Santos Cordon adapter.setRinging(callId); 12652d8a15e146e682319380322f94ceb6d93fa1a97Santos Cordon } catch (RemoteException e) { 12752d8a15e146e682319380322f94ceb6d93fa1a97Santos Cordon } 128ab5d282dd6f487578ae86b2d53d0d8edc9b71747Sailesh Nepal } 129ab5d282dd6f487578ae86b2d53d0d8edc9b71747Sailesh Nepal } 130bb69b0c2d821a9806fb00037284c399cbc78277dBen Gilad 131bb69b0c2d821a9806fb00037284c399cbc78277dBen Gilad /** 132bb69b0c2d821a9806fb00037284c399cbc78277dBen Gilad * Sets a call's state to dialing (e.g., dialing an outbound call). 1333784133b95f1206c0c6bbbddb5921ef396b5b941Santos Cordon * 1343784133b95f1206c0c6bbbddb5921ef396b5b941Santos Cordon * @param callId The unique ID of the call whose state is changing to dialing. 135bb69b0c2d821a9806fb00037284c399cbc78277dBen Gilad */ 1362a46b90222e5c9c73de012382a604a71f9c0c30cSailesh Nepal void setDialing(String callId) { 1372a46b90222e5c9c73de012382a604a71f9c0c30cSailesh Nepal for (IConnectionServiceAdapter adapter : mAdapters) { 13852d8a15e146e682319380322f94ceb6d93fa1a97Santos Cordon try { 13952d8a15e146e682319380322f94ceb6d93fa1a97Santos Cordon adapter.setDialing(callId); 14052d8a15e146e682319380322f94ceb6d93fa1a97Santos Cordon } catch (RemoteException e) { 14152d8a15e146e682319380322f94ceb6d93fa1a97Santos Cordon } 142ab5d282dd6f487578ae86b2d53d0d8edc9b71747Sailesh Nepal } 143ab5d282dd6f487578ae86b2d53d0d8edc9b71747Sailesh Nepal } 144bb69b0c2d821a9806fb00037284c399cbc78277dBen Gilad 145bb69b0c2d821a9806fb00037284c399cbc78277dBen Gilad /** 146bb69b0c2d821a9806fb00037284c399cbc78277dBen Gilad * Sets a call's state to disconnected. 1473784133b95f1206c0c6bbbddb5921ef396b5b941Santos Cordon * 1483784133b95f1206c0c6bbbddb5921ef396b5b941Santos Cordon * @param callId The unique ID of the call whose state is changing to disconnected. 1497f3d41fd124dd7c4a8b72c1d48df08a8ee7209ecAndrew Lee * @param disconnectCause The reason for the disconnection, as described by 1507f3d41fd124dd7c4a8b72c1d48df08a8ee7209ecAndrew Lee * {@link android.telecomm.DisconnectCause}. 151bb69b0c2d821a9806fb00037284c399cbc78277dBen Gilad */ 1527f3d41fd124dd7c4a8b72c1d48df08a8ee7209ecAndrew Lee void setDisconnected(String callId, DisconnectCause disconnectCause) { 1532a46b90222e5c9c73de012382a604a71f9c0c30cSailesh Nepal for (IConnectionServiceAdapter adapter : mAdapters) { 15452d8a15e146e682319380322f94ceb6d93fa1a97Santos Cordon try { 1557f3d41fd124dd7c4a8b72c1d48df08a8ee7209ecAndrew Lee adapter.setDisconnected(callId, disconnectCause); 15652d8a15e146e682319380322f94ceb6d93fa1a97Santos Cordon } catch (RemoteException e) { 15752d8a15e146e682319380322f94ceb6d93fa1a97Santos Cordon } 158ab5d282dd6f487578ae86b2d53d0d8edc9b71747Sailesh Nepal } 159ab5d282dd6f487578ae86b2d53d0d8edc9b71747Sailesh Nepal } 16081ccaaa25cc90c576c7df7c2cccb8a232e8536a1Yorke Lee 16181ccaaa25cc90c576c7df7c2cccb8a232e8536a1Yorke Lee /** 16281ccaaa25cc90c576c7df7c2cccb8a232e8536a1Yorke Lee * Sets a call's state to be on hold. 16381ccaaa25cc90c576c7df7c2cccb8a232e8536a1Yorke Lee * 16481ccaaa25cc90c576c7df7c2cccb8a232e8536a1Yorke Lee * @param callId - The unique ID of the call whose state is changing to be on hold. 16581ccaaa25cc90c576c7df7c2cccb8a232e8536a1Yorke Lee */ 1662a46b90222e5c9c73de012382a604a71f9c0c30cSailesh Nepal void setOnHold(String callId) { 1672a46b90222e5c9c73de012382a604a71f9c0c30cSailesh Nepal for (IConnectionServiceAdapter adapter : mAdapters) { 16852d8a15e146e682319380322f94ceb6d93fa1a97Santos Cordon try { 16952d8a15e146e682319380322f94ceb6d93fa1a97Santos Cordon adapter.setOnHold(callId); 17052d8a15e146e682319380322f94ceb6d93fa1a97Santos Cordon } catch (RemoteException e) { 17152d8a15e146e682319380322f94ceb6d93fa1a97Santos Cordon } 17281ccaaa25cc90c576c7df7c2cccb8a232e8536a1Yorke Lee } 17381ccaaa25cc90c576c7df7c2cccb8a232e8536a1Yorke Lee } 17481ccaaa25cc90c576c7df7c2cccb8a232e8536a1Yorke Lee 175f835897f9f799490de27653ae39141ba6bc14223Ihab Awad /** 176ef9f6f957d897ea0ed82114185b8fa3fefd4917bTyler Gunn * Asks Telecom to start or stop a ringback tone for a call. 177f835897f9f799490de27653ae39141ba6bc14223Ihab Awad * 178f835897f9f799490de27653ae39141ba6bc14223Ihab Awad * @param callId The unique ID of the call whose ringback is being changed. 179ef9f6f957d897ea0ed82114185b8fa3fefd4917bTyler Gunn * @param ringback Whether Telecom should start playing a ringback tone. 180f835897f9f799490de27653ae39141ba6bc14223Ihab Awad */ 181100e293fa8021caed956597daa4e01cb19be1c33Andrew Lee void setRingbackRequested(String callId, boolean ringback) { 1822a46b90222e5c9c73de012382a604a71f9c0c30cSailesh Nepal for (IConnectionServiceAdapter adapter : mAdapters) { 18352d8a15e146e682319380322f94ceb6d93fa1a97Santos Cordon try { 184100e293fa8021caed956597daa4e01cb19be1c33Andrew Lee adapter.setRingbackRequested(callId, ringback); 18552d8a15e146e682319380322f94ceb6d93fa1a97Santos Cordon } catch (RemoteException e) { 18652d8a15e146e682319380322f94ceb6d93fa1a97Santos Cordon } 187f835897f9f799490de27653ae39141ba6bc14223Ihab Awad } 188f835897f9f799490de27653ae39141ba6bc14223Ihab Awad } 18981ccaaa25cc90c576c7df7c2cccb8a232e8536a1Yorke Lee 1905c9c86ec0f95d1f5e1aca212967f508fc736b895Ihab Awad void setConnectionCapabilities(String callId, int capabilities) { 1912a46b90222e5c9c73de012382a604a71f9c0c30cSailesh Nepal for (IConnectionServiceAdapter adapter : mAdapters) { 19252d8a15e146e682319380322f94ceb6d93fa1a97Santos Cordon try { 1935c9c86ec0f95d1f5e1aca212967f508fc736b895Ihab Awad adapter.setConnectionCapabilities(callId, capabilities); 19452d8a15e146e682319380322f94ceb6d93fa1a97Santos Cordon } catch (RemoteException ignored) { 19552d8a15e146e682319380322f94ceb6d93fa1a97Santos Cordon } 196980acb9bd6984a9daad5f584bd35e8d503820200Santos Cordon } 197980acb9bd6984a9daad5f584bd35e8d503820200Santos Cordon } 198980acb9bd6984a9daad5f584bd35e8d503820200Santos Cordon 199980acb9bd6984a9daad5f584bd35e8d503820200Santos Cordon /** 200980acb9bd6984a9daad5f584bd35e8d503820200Santos Cordon * Indicates whether or not the specified call is currently conferenced into the specified 201980acb9bd6984a9daad5f584bd35e8d503820200Santos Cordon * conference call. 202980acb9bd6984a9daad5f584bd35e8d503820200Santos Cordon * 203980acb9bd6984a9daad5f584bd35e8d503820200Santos Cordon * @param callId The unique ID of the call being conferenced. 204b693998fdfdd4498a33c4c69405f2708e4840aa7Santos Cordon * @param conferenceCallId The unique ID of the conference call. Null if call is not 20552d8a15e146e682319380322f94ceb6d93fa1a97Santos Cordon * conferenced. 206980acb9bd6984a9daad5f584bd35e8d503820200Santos Cordon */ 2072a46b90222e5c9c73de012382a604a71f9c0c30cSailesh Nepal void setIsConferenced(String callId, String conferenceCallId) { 2082a46b90222e5c9c73de012382a604a71f9c0c30cSailesh Nepal for (IConnectionServiceAdapter adapter : mAdapters) { 20952d8a15e146e682319380322f94ceb6d93fa1a97Santos Cordon try { 2100159ac0cfe20e8f85ee4150e64d91392850f8a3fSantos Cordon Log.d(this, "sending connection %s with conference %s", callId, conferenceCallId); 21152d8a15e146e682319380322f94ceb6d93fa1a97Santos Cordon adapter.setIsConferenced(callId, conferenceCallId); 21252d8a15e146e682319380322f94ceb6d93fa1a97Santos Cordon } catch (RemoteException ignored) { 21352d8a15e146e682319380322f94ceb6d93fa1a97Santos Cordon } 214980acb9bd6984a9daad5f584bd35e8d503820200Santos Cordon } 215980acb9bd6984a9daad5f584bd35e8d503820200Santos Cordon } 216980acb9bd6984a9daad5f584bd35e8d503820200Santos Cordon 217980acb9bd6984a9daad5f584bd35e8d503820200Santos Cordon /** 21817455a3d39350a39eb995897929977d793358365Anthony Lee * Indicates that the merge request on this call has failed. 21917455a3d39350a39eb995897929977d793358365Anthony Lee * 22017455a3d39350a39eb995897929977d793358365Anthony Lee * @param callId The unique ID of the call being conferenced. 22117455a3d39350a39eb995897929977d793358365Anthony Lee */ 22217455a3d39350a39eb995897929977d793358365Anthony Lee void onConferenceMergeFailed(String callId) { 22317455a3d39350a39eb995897929977d793358365Anthony Lee for (IConnectionServiceAdapter adapter : mAdapters) { 22417455a3d39350a39eb995897929977d793358365Anthony Lee try { 22517455a3d39350a39eb995897929977d793358365Anthony Lee Log.d(this, "merge failed for call %s", callId); 22617455a3d39350a39eb995897929977d793358365Anthony Lee adapter.setConferenceMergeFailed(callId); 22717455a3d39350a39eb995897929977d793358365Anthony Lee } catch (RemoteException ignored) { 22817455a3d39350a39eb995897929977d793358365Anthony Lee } 22917455a3d39350a39eb995897929977d793358365Anthony Lee } 23017455a3d39350a39eb995897929977d793358365Anthony Lee } 23117455a3d39350a39eb995897929977d793358365Anthony Lee 23217455a3d39350a39eb995897929977d793358365Anthony Lee /** 233980acb9bd6984a9daad5f584bd35e8d503820200Santos Cordon * Indicates that the call no longer exists. Can be used with either a call or a conference 234980acb9bd6984a9daad5f584bd35e8d503820200Santos Cordon * call. 235980acb9bd6984a9daad5f584bd35e8d503820200Santos Cordon * 236980acb9bd6984a9daad5f584bd35e8d503820200Santos Cordon * @param callId The unique ID of the call. 237980acb9bd6984a9daad5f584bd35e8d503820200Santos Cordon */ 2382a46b90222e5c9c73de012382a604a71f9c0c30cSailesh Nepal void removeCall(String callId) { 2392a46b90222e5c9c73de012382a604a71f9c0c30cSailesh Nepal for (IConnectionServiceAdapter adapter : mAdapters) { 24052d8a15e146e682319380322f94ceb6d93fa1a97Santos Cordon try { 24152d8a15e146e682319380322f94ceb6d93fa1a97Santos Cordon adapter.removeCall(callId); 24252d8a15e146e682319380322f94ceb6d93fa1a97Santos Cordon } catch (RemoteException ignored) { 24352d8a15e146e682319380322f94ceb6d93fa1a97Santos Cordon } 244980acb9bd6984a9daad5f584bd35e8d503820200Santos Cordon } 245980acb9bd6984a9daad5f584bd35e8d503820200Santos Cordon } 2466dea4aceba8f69ee4be346ec356d277a3c153f3dEvan Charlton 2472a46b90222e5c9c73de012382a604a71f9c0c30cSailesh Nepal void onPostDialWait(String callId, String remaining) { 2482a46b90222e5c9c73de012382a604a71f9c0c30cSailesh Nepal for (IConnectionServiceAdapter adapter : mAdapters) { 24952d8a15e146e682319380322f94ceb6d93fa1a97Santos Cordon try { 25052d8a15e146e682319380322f94ceb6d93fa1a97Santos Cordon adapter.onPostDialWait(callId, remaining); 25152d8a15e146e682319380322f94ceb6d93fa1a97Santos Cordon } catch (RemoteException ignored) { 25252d8a15e146e682319380322f94ceb6d93fa1a97Santos Cordon } 2536dea4aceba8f69ee4be346ec356d277a3c153f3dEvan Charlton } 2546dea4aceba8f69ee4be346ec356d277a3c153f3dEvan Charlton } 2558b4818d9b4d632f2d460e7ac9dea463b04db43feSailesh Nepal 25627d1c2d148fe377ca0d2744f0f85789a42c8f808Nancy Chen void onPostDialChar(String callId, char nextChar) { 25727d1c2d148fe377ca0d2744f0f85789a42c8f808Nancy Chen for (IConnectionServiceAdapter adapter : mAdapters) { 25827d1c2d148fe377ca0d2744f0f85789a42c8f808Nancy Chen try { 25927d1c2d148fe377ca0d2744f0f85789a42c8f808Nancy Chen adapter.onPostDialChar(callId, nextChar); 26027d1c2d148fe377ca0d2744f0f85789a42c8f808Nancy Chen } catch (RemoteException ignored) { 26127d1c2d148fe377ca0d2744f0f85789a42c8f808Nancy Chen } 26227d1c2d148fe377ca0d2744f0f85789a42c8f808Nancy Chen } 26327d1c2d148fe377ca0d2744f0f85789a42c8f808Nancy Chen } 26427d1c2d148fe377ca0d2744f0f85789a42c8f808Nancy Chen 2658b4818d9b4d632f2d460e7ac9dea463b04db43feSailesh Nepal /** 266b693998fdfdd4498a33c4c69405f2708e4840aa7Santos Cordon * Indicates that a new conference call has been created. 267b693998fdfdd4498a33c4c69405f2708e4840aa7Santos Cordon * 268b693998fdfdd4498a33c4c69405f2708e4840aa7Santos Cordon * @param callId The unique ID of the conference call. 269b693998fdfdd4498a33c4c69405f2708e4840aa7Santos Cordon */ 270823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon void addConferenceCall(String callId, ParcelableConference parcelableConference) { 2712a46b90222e5c9c73de012382a604a71f9c0c30cSailesh Nepal for (IConnectionServiceAdapter adapter : mAdapters) { 27252d8a15e146e682319380322f94ceb6d93fa1a97Santos Cordon try { 273823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon adapter.addConferenceCall(callId, parcelableConference); 27452d8a15e146e682319380322f94ceb6d93fa1a97Santos Cordon } catch (RemoteException ignored) { 27552d8a15e146e682319380322f94ceb6d93fa1a97Santos Cordon } 27652d8a15e146e682319380322f94ceb6d93fa1a97Santos Cordon } 27752d8a15e146e682319380322f94ceb6d93fa1a97Santos Cordon } 27852d8a15e146e682319380322f94ceb6d93fa1a97Santos Cordon 27952d8a15e146e682319380322f94ceb6d93fa1a97Santos Cordon /** 28052d8a15e146e682319380322f94ceb6d93fa1a97Santos Cordon * Retrieves a list of remote connection services usable to place calls. 28152d8a15e146e682319380322f94ceb6d93fa1a97Santos Cordon */ 2822a46b90222e5c9c73de012382a604a71f9c0c30cSailesh Nepal void queryRemoteConnectionServices(RemoteServiceCallback callback) { 28352d8a15e146e682319380322f94ceb6d93fa1a97Santos Cordon // Only supported when there is only one adapter. 28452d8a15e146e682319380322f94ceb6d93fa1a97Santos Cordon if (mAdapters.size() == 1) { 28552d8a15e146e682319380322f94ceb6d93fa1a97Santos Cordon try { 28652d8a15e146e682319380322f94ceb6d93fa1a97Santos Cordon mAdapters.iterator().next().queryRemoteConnectionServices(callback); 28752d8a15e146e682319380322f94ceb6d93fa1a97Santos Cordon } catch (RemoteException e) { 28852d8a15e146e682319380322f94ceb6d93fa1a97Santos Cordon Log.e(this, e, "Exception trying to query for remote CSs"); 28952d8a15e146e682319380322f94ceb6d93fa1a97Santos Cordon } 290b693998fdfdd4498a33c4c69405f2708e4840aa7Santos Cordon } 291b693998fdfdd4498a33c4c69405f2708e4840aa7Santos Cordon } 2925ffbe8b850c2703b64617f0140d051a5412dd861Andrew Lee 2935ffbe8b850c2703b64617f0140d051a5412dd861Andrew Lee /** 2945ffbe8b850c2703b64617f0140d051a5412dd861Andrew Lee * Sets the call video provider for a call. 2955ffbe8b850c2703b64617f0140d051a5412dd861Andrew Lee * 2965ffbe8b850c2703b64617f0140d051a5412dd861Andrew Lee * @param callId The unique ID of the call to set with the given call video provider. 297b19a0bcdd8a5020c61a0d697f600fdc943c86f59Ihab Awad * @param videoProvider The call video provider instance to set on the call. 2985ffbe8b850c2703b64617f0140d051a5412dd861Andrew Lee */ 299b19a0bcdd8a5020c61a0d697f600fdc943c86f59Ihab Awad void setVideoProvider( 300b19a0bcdd8a5020c61a0d697f600fdc943c86f59Ihab Awad String callId, Connection.VideoProvider videoProvider) { 3012a46b90222e5c9c73de012382a604a71f9c0c30cSailesh Nepal for (IConnectionServiceAdapter adapter : mAdapters) { 3025ffbe8b850c2703b64617f0140d051a5412dd861Andrew Lee try { 303b19a0bcdd8a5020c61a0d697f600fdc943c86f59Ihab Awad adapter.setVideoProvider( 304e8dc4bef00e391defbdee0264b2ed955b1117841Santos Cordon callId, 305b19a0bcdd8a5020c61a0d697f600fdc943c86f59Ihab Awad videoProvider == null ? null : videoProvider.getInterface()); 3065ffbe8b850c2703b64617f0140d051a5412dd861Andrew Lee } catch (RemoteException e) { 3075ffbe8b850c2703b64617f0140d051a5412dd861Andrew Lee } 3085ffbe8b850c2703b64617f0140d051a5412dd861Andrew Lee } 3095ffbe8b850c2703b64617f0140d051a5412dd861Andrew Lee } 3108d83fa9bbd2ad15299a4419241eb10404e7839beTyler Gunn 3118d83fa9bbd2ad15299a4419241eb10404e7839beTyler Gunn /** 31233aaae4a07fdcce223fe74d96d751f4bffa6723aSailesh Nepal * Requests that the framework use VOIP audio mode for this connection. 31333aaae4a07fdcce223fe74d96d751f4bffa6723aSailesh Nepal * 31433aaae4a07fdcce223fe74d96d751f4bffa6723aSailesh Nepal * @param callId The unique ID of the call to set with the given call video provider. 31533aaae4a07fdcce223fe74d96d751f4bffa6723aSailesh Nepal * @param isVoip True if the audio mode is VOIP. 31633aaae4a07fdcce223fe74d96d751f4bffa6723aSailesh Nepal */ 317100e293fa8021caed956597daa4e01cb19be1c33Andrew Lee void setIsVoipAudioMode(String callId, boolean isVoip) { 31833aaae4a07fdcce223fe74d96d751f4bffa6723aSailesh Nepal for (IConnectionServiceAdapter adapter : mAdapters) { 31933aaae4a07fdcce223fe74d96d751f4bffa6723aSailesh Nepal try { 320100e293fa8021caed956597daa4e01cb19be1c33Andrew Lee adapter.setIsVoipAudioMode(callId, isVoip); 32133aaae4a07fdcce223fe74d96d751f4bffa6723aSailesh Nepal } catch (RemoteException e) { 32233aaae4a07fdcce223fe74d96d751f4bffa6723aSailesh Nepal } 32333aaae4a07fdcce223fe74d96d751f4bffa6723aSailesh Nepal } 32433aaae4a07fdcce223fe74d96d751f4bffa6723aSailesh Nepal } 32533aaae4a07fdcce223fe74d96d751f4bffa6723aSailesh Nepal 326e7ef59a77d55c9802cc7d919f7dd794bd5fea30eSailesh Nepal void setStatusHints(String callId, StatusHints statusHints) { 327e7ef59a77d55c9802cc7d919f7dd794bd5fea30eSailesh Nepal for (IConnectionServiceAdapter adapter : mAdapters) { 328e7ef59a77d55c9802cc7d919f7dd794bd5fea30eSailesh Nepal try { 329e7ef59a77d55c9802cc7d919f7dd794bd5fea30eSailesh Nepal adapter.setStatusHints(callId, statusHints); 330e7ef59a77d55c9802cc7d919f7dd794bd5fea30eSailesh Nepal } catch (RemoteException e) { 331e7ef59a77d55c9802cc7d919f7dd794bd5fea30eSailesh Nepal } 332e7ef59a77d55c9802cc7d919f7dd794bd5fea30eSailesh Nepal } 333e7ef59a77d55c9802cc7d919f7dd794bd5fea30eSailesh Nepal } 334e7ef59a77d55c9802cc7d919f7dd794bd5fea30eSailesh Nepal 335100e293fa8021caed956597daa4e01cb19be1c33Andrew Lee void setAddress(String callId, Uri address, int presentation) { 3362a46b90222e5c9c73de012382a604a71f9c0c30cSailesh Nepal for (IConnectionServiceAdapter adapter : mAdapters) { 3378d83fa9bbd2ad15299a4419241eb10404e7839beTyler Gunn try { 338100e293fa8021caed956597daa4e01cb19be1c33Andrew Lee adapter.setAddress(callId, address, presentation); 339612038642fa9cf1545dbcc8274d313192ce928b5Sailesh Nepal } catch (RemoteException e) { 340612038642fa9cf1545dbcc8274d313192ce928b5Sailesh Nepal } 341612038642fa9cf1545dbcc8274d313192ce928b5Sailesh Nepal } 342612038642fa9cf1545dbcc8274d313192ce928b5Sailesh Nepal } 343612038642fa9cf1545dbcc8274d313192ce928b5Sailesh Nepal 344612038642fa9cf1545dbcc8274d313192ce928b5Sailesh Nepal void setCallerDisplayName(String callId, String callerDisplayName, int presentation) { 345612038642fa9cf1545dbcc8274d313192ce928b5Sailesh Nepal for (IConnectionServiceAdapter adapter : mAdapters) { 346612038642fa9cf1545dbcc8274d313192ce928b5Sailesh Nepal try { 347612038642fa9cf1545dbcc8274d313192ce928b5Sailesh Nepal adapter.setCallerDisplayName(callId, callerDisplayName, presentation); 348612038642fa9cf1545dbcc8274d313192ce928b5Sailesh Nepal } catch (RemoteException e) { 3498d83fa9bbd2ad15299a4419241eb10404e7839beTyler Gunn } 3508d83fa9bbd2ad15299a4419241eb10404e7839beTyler Gunn } 3518d83fa9bbd2ad15299a4419241eb10404e7839beTyler Gunn } 352aa07df84f279a87ad6370758c9d792a660f2cebbTyler Gunn 353aa07df84f279a87ad6370758c9d792a660f2cebbTyler Gunn /** 354aa07df84f279a87ad6370758c9d792a660f2cebbTyler Gunn * Sets the video state associated with a call. 355aa07df84f279a87ad6370758c9d792a660f2cebbTyler Gunn * 35687b73f370e2b8a76b0540580f43edba6ec21c6cfTyler Gunn * Valid values: {@link VideoProfile#STATE_BIDIRECTIONAL}, 35787b73f370e2b8a76b0540580f43edba6ec21c6cfTyler Gunn * {@link VideoProfile#STATE_AUDIO_ONLY}, 35887b73f370e2b8a76b0540580f43edba6ec21c6cfTyler Gunn * {@link VideoProfile#STATE_TX_ENABLED}, 35987b73f370e2b8a76b0540580f43edba6ec21c6cfTyler Gunn * {@link VideoProfile#STATE_RX_ENABLED}. 360aa07df84f279a87ad6370758c9d792a660f2cebbTyler Gunn * 361aa07df84f279a87ad6370758c9d792a660f2cebbTyler Gunn * @param callId The unique ID of the call to set the video state for. 362aa07df84f279a87ad6370758c9d792a660f2cebbTyler Gunn * @param videoState The video state. 363aa07df84f279a87ad6370758c9d792a660f2cebbTyler Gunn */ 364aa07df84f279a87ad6370758c9d792a660f2cebbTyler Gunn void setVideoState(String callId, int videoState) { 365aa07df84f279a87ad6370758c9d792a660f2cebbTyler Gunn Log.v(this, "setVideoState: %d", videoState); 366aa07df84f279a87ad6370758c9d792a660f2cebbTyler Gunn for (IConnectionServiceAdapter adapter : mAdapters) { 367aa07df84f279a87ad6370758c9d792a660f2cebbTyler Gunn try { 368aa07df84f279a87ad6370758c9d792a660f2cebbTyler Gunn adapter.setVideoState(callId, videoState); 369aa07df84f279a87ad6370758c9d792a660f2cebbTyler Gunn } catch (RemoteException ignored) { 370aa07df84f279a87ad6370758c9d792a660f2cebbTyler Gunn } 371aa07df84f279a87ad6370758c9d792a660f2cebbTyler Gunn } 372aa07df84f279a87ad6370758c9d792a660f2cebbTyler Gunn } 3732ab88cc313fc4af7fb9436e236cd3a5d1ac58478Sailesh Nepal 3747c7bc7f6917484250974c5da00af9ef756844b0aSantos Cordon void setConferenceableConnections(String callId, List<String> conferenceableCallIds) { 3757c7bc7f6917484250974c5da00af9ef756844b0aSantos Cordon Log.v(this, "setConferenceableConnections: %s, %s", callId, conferenceableCallIds); 3767c7bc7f6917484250974c5da00af9ef756844b0aSantos Cordon for (IConnectionServiceAdapter adapter : mAdapters) { 3777c7bc7f6917484250974c5da00af9ef756844b0aSantos Cordon try { 3787c7bc7f6917484250974c5da00af9ef756844b0aSantos Cordon adapter.setConferenceableConnections(callId, conferenceableCallIds); 3797c7bc7f6917484250974c5da00af9ef756844b0aSantos Cordon } catch (RemoteException ignored) { 3807c7bc7f6917484250974c5da00af9ef756844b0aSantos Cordon } 3817c7bc7f6917484250974c5da00af9ef756844b0aSantos Cordon } 3827c7bc7f6917484250974c5da00af9ef756844b0aSantos Cordon } 3834a57b9b59b74c97e559a301af0add13cd4c3331cTyler Gunn 3844a57b9b59b74c97e559a301af0add13cd4c3331cTyler Gunn /** 3854a57b9b59b74c97e559a301af0add13cd4c3331cTyler Gunn * Informs telecom of an existing connection which was added by the {@link ConnectionService}. 3864a57b9b59b74c97e559a301af0add13cd4c3331cTyler Gunn * 3874a57b9b59b74c97e559a301af0add13cd4c3331cTyler Gunn * @param callId The unique ID of the call being added. 3884a57b9b59b74c97e559a301af0add13cd4c3331cTyler Gunn * @param connection The connection. 3894a57b9b59b74c97e559a301af0add13cd4c3331cTyler Gunn */ 3904a57b9b59b74c97e559a301af0add13cd4c3331cTyler Gunn void addExistingConnection(String callId, ParcelableConnection connection) { 3914a57b9b59b74c97e559a301af0add13cd4c3331cTyler Gunn Log.v(this, "addExistingConnection: %s", callId); 3924a57b9b59b74c97e559a301af0add13cd4c3331cTyler Gunn for (IConnectionServiceAdapter adapter : mAdapters) { 3934a57b9b59b74c97e559a301af0add13cd4c3331cTyler Gunn try { 3944a57b9b59b74c97e559a301af0add13cd4c3331cTyler Gunn adapter.addExistingConnection(callId, connection); 3954a57b9b59b74c97e559a301af0add13cd4c3331cTyler Gunn } catch (RemoteException ignored) { 3964a57b9b59b74c97e559a301af0add13cd4c3331cTyler Gunn } 3974a57b9b59b74c97e559a301af0add13cd4c3331cTyler Gunn } 3984a57b9b59b74c97e559a301af0add13cd4c3331cTyler Gunn } 3996b7f955c2d9b231660b8c54f8ef8e8e6ad802625Santos Cordon 4006b7f955c2d9b231660b8c54f8ef8e8e6ad802625Santos Cordon /** 4016b7f955c2d9b231660b8c54f8ef8e8e6ad802625Santos Cordon * Sets extras associated with a connection. 4026b7f955c2d9b231660b8c54f8ef8e8e6ad802625Santos Cordon * 4036b7f955c2d9b231660b8c54f8ef8e8e6ad802625Santos Cordon * @param callId The unique ID of the call. 4046b7f955c2d9b231660b8c54f8ef8e8e6ad802625Santos Cordon * @param extras The extras to associate with this call. 4056b7f955c2d9b231660b8c54f8ef8e8e6ad802625Santos Cordon */ 4066b7f955c2d9b231660b8c54f8ef8e8e6ad802625Santos Cordon void setExtras(String callId, Bundle extras) { 4076b7f955c2d9b231660b8c54f8ef8e8e6ad802625Santos Cordon Log.v(this, "setExtras: %s", extras); 4086b7f955c2d9b231660b8c54f8ef8e8e6ad802625Santos Cordon for (IConnectionServiceAdapter adapter : mAdapters) { 4096b7f955c2d9b231660b8c54f8ef8e8e6ad802625Santos Cordon try { 4106b7f955c2d9b231660b8c54f8ef8e8e6ad802625Santos Cordon adapter.setExtras(callId, extras); 4116b7f955c2d9b231660b8c54f8ef8e8e6ad802625Santos Cordon } catch (RemoteException ignored) { 4126b7f955c2d9b231660b8c54f8ef8e8e6ad802625Santos Cordon } 4136b7f955c2d9b231660b8c54f8ef8e8e6ad802625Santos Cordon } 4146b7f955c2d9b231660b8c54f8ef8e8e6ad802625Santos Cordon } 415bd1eb1f105e99d55fe87d758e8eafbe55a221a30Tyler Gunn 416bd1eb1f105e99d55fe87d758e8eafbe55a221a30Tyler Gunn /** 417bd1eb1f105e99d55fe87d758e8eafbe55a221a30Tyler Gunn * Informs Telecom of a connection level event. 418bd1eb1f105e99d55fe87d758e8eafbe55a221a30Tyler Gunn * 419bd1eb1f105e99d55fe87d758e8eafbe55a221a30Tyler Gunn * @param callId The unique ID of the call. 420bd1eb1f105e99d55fe87d758e8eafbe55a221a30Tyler Gunn * @param event The event. 421876dbfb4767da4a2ba5459d5b78fb6eb55e4516fTyler Gunn * @param extras Extras associated with the event. 422bd1eb1f105e99d55fe87d758e8eafbe55a221a30Tyler Gunn */ 423876dbfb4767da4a2ba5459d5b78fb6eb55e4516fTyler Gunn void onConnectionEvent(String callId, String event, Bundle extras) { 424bd1eb1f105e99d55fe87d758e8eafbe55a221a30Tyler Gunn Log.v(this, "onConnectionEvent: %s", event); 425bd1eb1f105e99d55fe87d758e8eafbe55a221a30Tyler Gunn for (IConnectionServiceAdapter adapter : mAdapters) { 426bd1eb1f105e99d55fe87d758e8eafbe55a221a30Tyler Gunn try { 427876dbfb4767da4a2ba5459d5b78fb6eb55e4516fTyler Gunn adapter.onConnectionEvent(callId, event, extras); 428bd1eb1f105e99d55fe87d758e8eafbe55a221a30Tyler Gunn } catch (RemoteException ignored) { 429bd1eb1f105e99d55fe87d758e8eafbe55a221a30Tyler Gunn } 430bd1eb1f105e99d55fe87d758e8eafbe55a221a30Tyler Gunn } 431bd1eb1f105e99d55fe87d758e8eafbe55a221a30Tyler Gunn } 432bb69b0c2d821a9806fb00037284c399cbc78277dBen Gilad} 433