1b8e85c74e5910a461078704048d67f82b216508cIhab Awad/* 2b8e85c74e5910a461078704048d67f82b216508cIhab Awad * Copyright (C) 2014 The Android Open Source Project 3b8e85c74e5910a461078704048d67f82b216508cIhab Awad * 4b8e85c74e5910a461078704048d67f82b216508cIhab Awad * Licensed under the Apache License, Version 2.0 (the "License"); 5b8e85c74e5910a461078704048d67f82b216508cIhab Awad * you may not use this file except in compliance with the License. 6b8e85c74e5910a461078704048d67f82b216508cIhab Awad * You may obtain a copy of the License at 7b8e85c74e5910a461078704048d67f82b216508cIhab Awad * 8b8e85c74e5910a461078704048d67f82b216508cIhab Awad * http://www.apache.org/licenses/LICENSE-2.0 9b8e85c74e5910a461078704048d67f82b216508cIhab Awad * 10b8e85c74e5910a461078704048d67f82b216508cIhab Awad * Unless required by applicable law or agreed to in writing, software 11b8e85c74e5910a461078704048d67f82b216508cIhab Awad * distributed under the License is distributed on an "AS IS" BASIS, 12b8e85c74e5910a461078704048d67f82b216508cIhab Awad * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13b8e85c74e5910a461078704048d67f82b216508cIhab Awad * See the License for the specific language governing permissions and 14b8e85c74e5910a461078704048d67f82b216508cIhab Awad * limitations under the License. 15b8e85c74e5910a461078704048d67f82b216508cIhab Awad */ 16b8e85c74e5910a461078704048d67f82b216508cIhab Awad 17ef9f6f957d897ea0ed82114185b8fa3fefd4917bTyler Gunnpackage android.telecom; 18b8e85c74e5910a461078704048d67f82b216508cIhab Awad 19ef9f6f957d897ea0ed82114185b8fa3fefd4917bTyler Gunnimport com.android.internal.telecom.IConnectionService; 20b8e85c74e5910a461078704048d67f82b216508cIhab Awad 216b7f955c2d9b231660b8c54f8ef8e8e6ad802625Santos Cordonimport android.annotation.Nullable; 224af5935c71f1e31ef1aec27661c4ef60545a0924Yorke Leeimport android.annotation.SystemApi; 236b7f955c2d9b231660b8c54f8ef8e8e6ad802625Santos Cordonimport android.os.Bundle; 24011728fc3a4368b601844d225d1f37bf48ea5735Andrew Leeimport android.os.Handler; 25b8e85c74e5910a461078704048d67f82b216508cIhab Awadimport android.os.RemoteException; 26b8e85c74e5910a461078704048d67f82b216508cIhab Awad 2750e3506533478fa273cbc92c2919470d1889f1edIhab Awadimport java.util.ArrayList; 28b8e85c74e5910a461078704048d67f82b216508cIhab Awadimport java.util.Collections; 29b8e85c74e5910a461078704048d67f82b216508cIhab Awadimport java.util.List; 30b8e85c74e5910a461078704048d67f82b216508cIhab Awadimport java.util.Set; 31b8e85c74e5910a461078704048d67f82b216508cIhab Awadimport java.util.concurrent.CopyOnWriteArrayList; 32b8e85c74e5910a461078704048d67f82b216508cIhab Awadimport java.util.concurrent.CopyOnWriteArraySet; 33b8e85c74e5910a461078704048d67f82b216508cIhab Awad 34b8e85c74e5910a461078704048d67f82b216508cIhab Awad/** 35895d4b8f63389b79974dfd3e36f1ab10b5ceb4dcSantos Cordon * A conference provided to a {@link ConnectionService} by another {@code ConnectionService} through 36895d4b8f63389b79974dfd3e36f1ab10b5ceb4dcSantos Cordon * {@link ConnectionService#conferenceRemoteConnections}. Once created, a {@code RemoteConference} 37895d4b8f63389b79974dfd3e36f1ab10b5ceb4dcSantos Cordon * can be used to control the conference call or monitor changes through 38895d4b8f63389b79974dfd3e36f1ab10b5ceb4dcSantos Cordon * {@link RemoteConnection.Callback}. 39b804f8d8ff2de6fa83d59949915ab118bbe00ccfSantos Cordon * 40b804f8d8ff2de6fa83d59949915ab118bbe00ccfSantos Cordon * @see ConnectionService#onRemoteConferenceAdded 41b8e85c74e5910a461078704048d67f82b216508cIhab Awad */ 42b8e85c74e5910a461078704048d67f82b216508cIhab Awadpublic final class RemoteConference { 43b8e85c74e5910a461078704048d67f82b216508cIhab Awad 44895d4b8f63389b79974dfd3e36f1ab10b5ceb4dcSantos Cordon /** 45895d4b8f63389b79974dfd3e36f1ab10b5ceb4dcSantos Cordon * Callback base class for {@link RemoteConference}. 46895d4b8f63389b79974dfd3e36f1ab10b5ceb4dcSantos Cordon */ 471d834f51df5396653ce669e614f9e7ef2cbd4a06Nancy Chen public abstract static class Callback { 48895d4b8f63389b79974dfd3e36f1ab10b5ceb4dcSantos Cordon /** 49895d4b8f63389b79974dfd3e36f1ab10b5ceb4dcSantos Cordon * Invoked when the state of this {@code RemoteConferece} has changed. See 50895d4b8f63389b79974dfd3e36f1ab10b5ceb4dcSantos Cordon * {@link #getState()}. 51895d4b8f63389b79974dfd3e36f1ab10b5ceb4dcSantos Cordon * 52895d4b8f63389b79974dfd3e36f1ab10b5ceb4dcSantos Cordon * @param conference The {@code RemoteConference} invoking this method. 53895d4b8f63389b79974dfd3e36f1ab10b5ceb4dcSantos Cordon * @param oldState The previous state of the {@code RemoteConference}. 54895d4b8f63389b79974dfd3e36f1ab10b5ceb4dcSantos Cordon * @param newState The new state of the {@code RemoteConference}. 55895d4b8f63389b79974dfd3e36f1ab10b5ceb4dcSantos Cordon */ 56b8e85c74e5910a461078704048d67f82b216508cIhab Awad public void onStateChanged(RemoteConference conference, int oldState, int newState) {} 57895d4b8f63389b79974dfd3e36f1ab10b5ceb4dcSantos Cordon 58895d4b8f63389b79974dfd3e36f1ab10b5ceb4dcSantos Cordon /** 59895d4b8f63389b79974dfd3e36f1ab10b5ceb4dcSantos Cordon * Invoked when this {@code RemoteConference} is disconnected. 60895d4b8f63389b79974dfd3e36f1ab10b5ceb4dcSantos Cordon * 61895d4b8f63389b79974dfd3e36f1ab10b5ceb4dcSantos Cordon * @param conference The {@code RemoteConference} invoking this method. 62895d4b8f63389b79974dfd3e36f1ab10b5ceb4dcSantos Cordon * @param disconnectCause The ({@see DisconnectCause}) associated with this failed 63895d4b8f63389b79974dfd3e36f1ab10b5ceb4dcSantos Cordon * conference. 64895d4b8f63389b79974dfd3e36f1ab10b5ceb4dcSantos Cordon */ 657f3d41fd124dd7c4a8b72c1d48df08a8ee7209ecAndrew Lee public void onDisconnected(RemoteConference conference, DisconnectCause disconnectCause) {} 66895d4b8f63389b79974dfd3e36f1ab10b5ceb4dcSantos Cordon 67895d4b8f63389b79974dfd3e36f1ab10b5ceb4dcSantos Cordon /** 68895d4b8f63389b79974dfd3e36f1ab10b5ceb4dcSantos Cordon * Invoked when a {@link RemoteConnection} is added to the conference call. 69895d4b8f63389b79974dfd3e36f1ab10b5ceb4dcSantos Cordon * 70895d4b8f63389b79974dfd3e36f1ab10b5ceb4dcSantos Cordon * @param conference The {@code RemoteConference} invoking this method. 71895d4b8f63389b79974dfd3e36f1ab10b5ceb4dcSantos Cordon * @param connection The {@link RemoteConnection} being added. 72895d4b8f63389b79974dfd3e36f1ab10b5ceb4dcSantos Cordon */ 73b8e85c74e5910a461078704048d67f82b216508cIhab Awad public void onConnectionAdded(RemoteConference conference, RemoteConnection connection) {} 74895d4b8f63389b79974dfd3e36f1ab10b5ceb4dcSantos Cordon 75895d4b8f63389b79974dfd3e36f1ab10b5ceb4dcSantos Cordon /** 76895d4b8f63389b79974dfd3e36f1ab10b5ceb4dcSantos Cordon * Invoked when a {@link RemoteConnection} is removed from the conference call. 77895d4b8f63389b79974dfd3e36f1ab10b5ceb4dcSantos Cordon * 78895d4b8f63389b79974dfd3e36f1ab10b5ceb4dcSantos Cordon * @param conference The {@code RemoteConference} invoking this method. 79895d4b8f63389b79974dfd3e36f1ab10b5ceb4dcSantos Cordon * @param connection The {@link RemoteConnection} being removed. 80895d4b8f63389b79974dfd3e36f1ab10b5ceb4dcSantos Cordon */ 81b8e85c74e5910a461078704048d67f82b216508cIhab Awad public void onConnectionRemoved(RemoteConference conference, RemoteConnection connection) {} 82895d4b8f63389b79974dfd3e36f1ab10b5ceb4dcSantos Cordon 83895d4b8f63389b79974dfd3e36f1ab10b5ceb4dcSantos Cordon /** 84895d4b8f63389b79974dfd3e36f1ab10b5ceb4dcSantos Cordon * Indicates that the call capabilities of this {@code RemoteConference} have changed. 85895d4b8f63389b79974dfd3e36f1ab10b5ceb4dcSantos Cordon * See {@link #getConnectionCapabilities()}. 86895d4b8f63389b79974dfd3e36f1ab10b5ceb4dcSantos Cordon * 87895d4b8f63389b79974dfd3e36f1ab10b5ceb4dcSantos Cordon * @param conference The {@code RemoteConference} invoking this method. 88895d4b8f63389b79974dfd3e36f1ab10b5ceb4dcSantos Cordon * @param connectionCapabilities The new capabilities of the {@code RemoteConference}. 89895d4b8f63389b79974dfd3e36f1ab10b5ceb4dcSantos Cordon */ 905c9c86ec0f95d1f5e1aca212967f508fc736b895Ihab Awad public void onConnectionCapabilitiesChanged( 915c9c86ec0f95d1f5e1aca212967f508fc736b895Ihab Awad RemoteConference conference, 925c9c86ec0f95d1f5e1aca212967f508fc736b895Ihab Awad int connectionCapabilities) {} 93895d4b8f63389b79974dfd3e36f1ab10b5ceb4dcSantos Cordon 94895d4b8f63389b79974dfd3e36f1ab10b5ceb4dcSantos Cordon /** 95720c664401081ca00e56c7eef12641ae792da530Tyler Gunn * Indicates that the call properties of this {@code RemoteConference} have changed. 96720c664401081ca00e56c7eef12641ae792da530Tyler Gunn * See {@link #getConnectionProperties()}. 97720c664401081ca00e56c7eef12641ae792da530Tyler Gunn * 98720c664401081ca00e56c7eef12641ae792da530Tyler Gunn * @param conference The {@code RemoteConference} invoking this method. 99720c664401081ca00e56c7eef12641ae792da530Tyler Gunn * @param connectionProperties The new properties of the {@code RemoteConference}. 100720c664401081ca00e56c7eef12641ae792da530Tyler Gunn */ 101720c664401081ca00e56c7eef12641ae792da530Tyler Gunn public void onConnectionPropertiesChanged( 102720c664401081ca00e56c7eef12641ae792da530Tyler Gunn RemoteConference conference, 103720c664401081ca00e56c7eef12641ae792da530Tyler Gunn int connectionProperties) {} 104720c664401081ca00e56c7eef12641ae792da530Tyler Gunn 105720c664401081ca00e56c7eef12641ae792da530Tyler Gunn 106720c664401081ca00e56c7eef12641ae792da530Tyler Gunn /** 107895d4b8f63389b79974dfd3e36f1ab10b5ceb4dcSantos Cordon * Invoked when the set of {@link RemoteConnection}s which can be added to this conference 108895d4b8f63389b79974dfd3e36f1ab10b5ceb4dcSantos Cordon * call have changed. 109895d4b8f63389b79974dfd3e36f1ab10b5ceb4dcSantos Cordon * 110895d4b8f63389b79974dfd3e36f1ab10b5ceb4dcSantos Cordon * @param conference The {@code RemoteConference} invoking this method. 111895d4b8f63389b79974dfd3e36f1ab10b5ceb4dcSantos Cordon * @param conferenceableConnections The list of conferenceable {@link RemoteConnection}s. 112895d4b8f63389b79974dfd3e36f1ab10b5ceb4dcSantos Cordon */ 11350e3506533478fa273cbc92c2919470d1889f1edIhab Awad public void onConferenceableConnectionsChanged( 11450e3506533478fa273cbc92c2919470d1889f1edIhab Awad RemoteConference conference, 11550e3506533478fa273cbc92c2919470d1889f1edIhab Awad List<RemoteConnection> conferenceableConnections) {} 116895d4b8f63389b79974dfd3e36f1ab10b5ceb4dcSantos Cordon 117895d4b8f63389b79974dfd3e36f1ab10b5ceb4dcSantos Cordon /** 118895d4b8f63389b79974dfd3e36f1ab10b5ceb4dcSantos Cordon * Indicates that this {@code RemoteConference} has been destroyed. No further requests 119895d4b8f63389b79974dfd3e36f1ab10b5ceb4dcSantos Cordon * should be made to the {@code RemoteConference}, and references to it should be cleared. 120895d4b8f63389b79974dfd3e36f1ab10b5ceb4dcSantos Cordon * 121895d4b8f63389b79974dfd3e36f1ab10b5ceb4dcSantos Cordon * @param conference The {@code RemoteConference} invoking this method. 122895d4b8f63389b79974dfd3e36f1ab10b5ceb4dcSantos Cordon */ 123b8e85c74e5910a461078704048d67f82b216508cIhab Awad public void onDestroyed(RemoteConference conference) {} 124895d4b8f63389b79974dfd3e36f1ab10b5ceb4dcSantos Cordon 125895d4b8f63389b79974dfd3e36f1ab10b5ceb4dcSantos Cordon /** 126895d4b8f63389b79974dfd3e36f1ab10b5ceb4dcSantos Cordon * Handles changes to the {@code RemoteConference} extras. 127895d4b8f63389b79974dfd3e36f1ab10b5ceb4dcSantos Cordon * 128895d4b8f63389b79974dfd3e36f1ab10b5ceb4dcSantos Cordon * @param conference The {@code RemoteConference} invoking this method. 129895d4b8f63389b79974dfd3e36f1ab10b5ceb4dcSantos Cordon * @param extras The extras containing other information associated with the conference. 130895d4b8f63389b79974dfd3e36f1ab10b5ceb4dcSantos Cordon */ 1316b7f955c2d9b231660b8c54f8ef8e8e6ad802625Santos Cordon public void onExtrasChanged(RemoteConference conference, @Nullable Bundle extras) {} 132b8e85c74e5910a461078704048d67f82b216508cIhab Awad } 133b8e85c74e5910a461078704048d67f82b216508cIhab Awad 134b8e85c74e5910a461078704048d67f82b216508cIhab Awad private final String mId; 135b8e85c74e5910a461078704048d67f82b216508cIhab Awad private final IConnectionService mConnectionService; 136b8e85c74e5910a461078704048d67f82b216508cIhab Awad 137011728fc3a4368b601844d225d1f37bf48ea5735Andrew Lee private final Set<CallbackRecord<Callback>> mCallbackRecords = new CopyOnWriteArraySet<>(); 138b8e85c74e5910a461078704048d67f82b216508cIhab Awad private final List<RemoteConnection> mChildConnections = new CopyOnWriteArrayList<>(); 139b8e85c74e5910a461078704048d67f82b216508cIhab Awad private final List<RemoteConnection> mUnmodifiableChildConnections = 140b8e85c74e5910a461078704048d67f82b216508cIhab Awad Collections.unmodifiableList(mChildConnections); 14150e3506533478fa273cbc92c2919470d1889f1edIhab Awad private final List<RemoteConnection> mConferenceableConnections = new ArrayList<>(); 14250e3506533478fa273cbc92c2919470d1889f1edIhab Awad private final List<RemoteConnection> mUnmodifiableConferenceableConnections = 14350e3506533478fa273cbc92c2919470d1889f1edIhab Awad Collections.unmodifiableList(mConferenceableConnections); 144b8e85c74e5910a461078704048d67f82b216508cIhab Awad 145b8e85c74e5910a461078704048d67f82b216508cIhab Awad private int mState = Connection.STATE_NEW; 1467f3d41fd124dd7c4a8b72c1d48df08a8ee7209ecAndrew Lee private DisconnectCause mDisconnectCause; 1475c9c86ec0f95d1f5e1aca212967f508fc736b895Ihab Awad private int mConnectionCapabilities; 148720c664401081ca00e56c7eef12641ae792da530Tyler Gunn private int mConnectionProperties; 1496b7f955c2d9b231660b8c54f8ef8e8e6ad802625Santos Cordon private Bundle mExtras; 150b8e85c74e5910a461078704048d67f82b216508cIhab Awad 151b804f8d8ff2de6fa83d59949915ab118bbe00ccfSantos Cordon /** @hide */ 152b8e85c74e5910a461078704048d67f82b216508cIhab Awad RemoteConference(String id, IConnectionService connectionService) { 153b8e85c74e5910a461078704048d67f82b216508cIhab Awad mId = id; 154b8e85c74e5910a461078704048d67f82b216508cIhab Awad mConnectionService = connectionService; 155b8e85c74e5910a461078704048d67f82b216508cIhab Awad } 156b8e85c74e5910a461078704048d67f82b216508cIhab Awad 157b804f8d8ff2de6fa83d59949915ab118bbe00ccfSantos Cordon /** @hide */ 158b8e85c74e5910a461078704048d67f82b216508cIhab Awad String getId() { 159b8e85c74e5910a461078704048d67f82b216508cIhab Awad return mId; 160b8e85c74e5910a461078704048d67f82b216508cIhab Awad } 161b8e85c74e5910a461078704048d67f82b216508cIhab Awad 162b804f8d8ff2de6fa83d59949915ab118bbe00ccfSantos Cordon /** @hide */ 163b8e85c74e5910a461078704048d67f82b216508cIhab Awad void setDestroyed() { 164b8e85c74e5910a461078704048d67f82b216508cIhab Awad for (RemoteConnection connection : mChildConnections) { 165b8e85c74e5910a461078704048d67f82b216508cIhab Awad connection.setConference(null); 166b8e85c74e5910a461078704048d67f82b216508cIhab Awad } 167011728fc3a4368b601844d225d1f37bf48ea5735Andrew Lee for (CallbackRecord<Callback> record : mCallbackRecords) { 168011728fc3a4368b601844d225d1f37bf48ea5735Andrew Lee final RemoteConference conference = this; 169011728fc3a4368b601844d225d1f37bf48ea5735Andrew Lee final Callback callback = record.getCallback(); 170011728fc3a4368b601844d225d1f37bf48ea5735Andrew Lee record.getHandler().post(new Runnable() { 171011728fc3a4368b601844d225d1f37bf48ea5735Andrew Lee @Override 172011728fc3a4368b601844d225d1f37bf48ea5735Andrew Lee public void run() { 173011728fc3a4368b601844d225d1f37bf48ea5735Andrew Lee callback.onDestroyed(conference); 174011728fc3a4368b601844d225d1f37bf48ea5735Andrew Lee } 175011728fc3a4368b601844d225d1f37bf48ea5735Andrew Lee }); 176b8e85c74e5910a461078704048d67f82b216508cIhab Awad } 177b8e85c74e5910a461078704048d67f82b216508cIhab Awad } 178b8e85c74e5910a461078704048d67f82b216508cIhab Awad 179b804f8d8ff2de6fa83d59949915ab118bbe00ccfSantos Cordon /** @hide */ 180011728fc3a4368b601844d225d1f37bf48ea5735Andrew Lee void setState(final int newState) { 181b8e85c74e5910a461078704048d67f82b216508cIhab Awad if (newState != Connection.STATE_ACTIVE && 182b8e85c74e5910a461078704048d67f82b216508cIhab Awad newState != Connection.STATE_HOLDING && 183b8e85c74e5910a461078704048d67f82b216508cIhab Awad newState != Connection.STATE_DISCONNECTED) { 184b8e85c74e5910a461078704048d67f82b216508cIhab Awad Log.w(this, "Unsupported state transition for Conference call.", 185b8e85c74e5910a461078704048d67f82b216508cIhab Awad Connection.stateToString(newState)); 186b8e85c74e5910a461078704048d67f82b216508cIhab Awad return; 187b8e85c74e5910a461078704048d67f82b216508cIhab Awad } 188b8e85c74e5910a461078704048d67f82b216508cIhab Awad 189b8e85c74e5910a461078704048d67f82b216508cIhab Awad if (mState != newState) { 190011728fc3a4368b601844d225d1f37bf48ea5735Andrew Lee final int oldState = mState; 191b8e85c74e5910a461078704048d67f82b216508cIhab Awad mState = newState; 192011728fc3a4368b601844d225d1f37bf48ea5735Andrew Lee for (CallbackRecord<Callback> record : mCallbackRecords) { 193011728fc3a4368b601844d225d1f37bf48ea5735Andrew Lee final RemoteConference conference = this; 194011728fc3a4368b601844d225d1f37bf48ea5735Andrew Lee final Callback callback = record.getCallback(); 195011728fc3a4368b601844d225d1f37bf48ea5735Andrew Lee record.getHandler().post(new Runnable() { 196011728fc3a4368b601844d225d1f37bf48ea5735Andrew Lee @Override 197011728fc3a4368b601844d225d1f37bf48ea5735Andrew Lee public void run() { 198011728fc3a4368b601844d225d1f37bf48ea5735Andrew Lee callback.onStateChanged(conference, oldState, newState); 199011728fc3a4368b601844d225d1f37bf48ea5735Andrew Lee } 200011728fc3a4368b601844d225d1f37bf48ea5735Andrew Lee }); 201b8e85c74e5910a461078704048d67f82b216508cIhab Awad } 202b8e85c74e5910a461078704048d67f82b216508cIhab Awad } 203b8e85c74e5910a461078704048d67f82b216508cIhab Awad } 204b8e85c74e5910a461078704048d67f82b216508cIhab Awad 205b804f8d8ff2de6fa83d59949915ab118bbe00ccfSantos Cordon /** @hide */ 206011728fc3a4368b601844d225d1f37bf48ea5735Andrew Lee void addConnection(final RemoteConnection connection) { 207b8e85c74e5910a461078704048d67f82b216508cIhab Awad if (!mChildConnections.contains(connection)) { 208b8e85c74e5910a461078704048d67f82b216508cIhab Awad mChildConnections.add(connection); 209b8e85c74e5910a461078704048d67f82b216508cIhab Awad connection.setConference(this); 210011728fc3a4368b601844d225d1f37bf48ea5735Andrew Lee for (CallbackRecord<Callback> record : mCallbackRecords) { 211011728fc3a4368b601844d225d1f37bf48ea5735Andrew Lee final RemoteConference conference = this; 212011728fc3a4368b601844d225d1f37bf48ea5735Andrew Lee final Callback callback = record.getCallback(); 213011728fc3a4368b601844d225d1f37bf48ea5735Andrew Lee record.getHandler().post(new Runnable() { 214011728fc3a4368b601844d225d1f37bf48ea5735Andrew Lee @Override 215011728fc3a4368b601844d225d1f37bf48ea5735Andrew Lee public void run() { 216011728fc3a4368b601844d225d1f37bf48ea5735Andrew Lee callback.onConnectionAdded(conference, connection); 217011728fc3a4368b601844d225d1f37bf48ea5735Andrew Lee } 218011728fc3a4368b601844d225d1f37bf48ea5735Andrew Lee }); 219b8e85c74e5910a461078704048d67f82b216508cIhab Awad } 220b8e85c74e5910a461078704048d67f82b216508cIhab Awad } 221b8e85c74e5910a461078704048d67f82b216508cIhab Awad } 222b8e85c74e5910a461078704048d67f82b216508cIhab Awad 223b804f8d8ff2de6fa83d59949915ab118bbe00ccfSantos Cordon /** @hide */ 224011728fc3a4368b601844d225d1f37bf48ea5735Andrew Lee void removeConnection(final RemoteConnection connection) { 225b8e85c74e5910a461078704048d67f82b216508cIhab Awad if (mChildConnections.contains(connection)) { 226b8e85c74e5910a461078704048d67f82b216508cIhab Awad mChildConnections.remove(connection); 227b8e85c74e5910a461078704048d67f82b216508cIhab Awad connection.setConference(null); 228011728fc3a4368b601844d225d1f37bf48ea5735Andrew Lee for (CallbackRecord<Callback> record : mCallbackRecords) { 229011728fc3a4368b601844d225d1f37bf48ea5735Andrew Lee final RemoteConference conference = this; 230011728fc3a4368b601844d225d1f37bf48ea5735Andrew Lee final Callback callback = record.getCallback(); 231011728fc3a4368b601844d225d1f37bf48ea5735Andrew Lee record.getHandler().post(new Runnable() { 232011728fc3a4368b601844d225d1f37bf48ea5735Andrew Lee @Override 233011728fc3a4368b601844d225d1f37bf48ea5735Andrew Lee public void run() { 234011728fc3a4368b601844d225d1f37bf48ea5735Andrew Lee callback.onConnectionRemoved(conference, connection); 235011728fc3a4368b601844d225d1f37bf48ea5735Andrew Lee } 236011728fc3a4368b601844d225d1f37bf48ea5735Andrew Lee }); 237b8e85c74e5910a461078704048d67f82b216508cIhab Awad } 238b8e85c74e5910a461078704048d67f82b216508cIhab Awad } 239b8e85c74e5910a461078704048d67f82b216508cIhab Awad } 240b8e85c74e5910a461078704048d67f82b216508cIhab Awad 241b804f8d8ff2de6fa83d59949915ab118bbe00ccfSantos Cordon /** @hide */ 242011728fc3a4368b601844d225d1f37bf48ea5735Andrew Lee void setConnectionCapabilities(final int connectionCapabilities) { 2435c9c86ec0f95d1f5e1aca212967f508fc736b895Ihab Awad if (mConnectionCapabilities != connectionCapabilities) { 2445c9c86ec0f95d1f5e1aca212967f508fc736b895Ihab Awad mConnectionCapabilities = connectionCapabilities; 245011728fc3a4368b601844d225d1f37bf48ea5735Andrew Lee for (CallbackRecord<Callback> record : mCallbackRecords) { 246011728fc3a4368b601844d225d1f37bf48ea5735Andrew Lee final RemoteConference conference = this; 247011728fc3a4368b601844d225d1f37bf48ea5735Andrew Lee final Callback callback = record.getCallback(); 248011728fc3a4368b601844d225d1f37bf48ea5735Andrew Lee record.getHandler().post(new Runnable() { 249011728fc3a4368b601844d225d1f37bf48ea5735Andrew Lee @Override 250011728fc3a4368b601844d225d1f37bf48ea5735Andrew Lee public void run() { 251011728fc3a4368b601844d225d1f37bf48ea5735Andrew Lee callback.onConnectionCapabilitiesChanged( 252011728fc3a4368b601844d225d1f37bf48ea5735Andrew Lee conference, mConnectionCapabilities); 253011728fc3a4368b601844d225d1f37bf48ea5735Andrew Lee } 254011728fc3a4368b601844d225d1f37bf48ea5735Andrew Lee }); 255b8e85c74e5910a461078704048d67f82b216508cIhab Awad } 256b8e85c74e5910a461078704048d67f82b216508cIhab Awad } 257b8e85c74e5910a461078704048d67f82b216508cIhab Awad } 258b8e85c74e5910a461078704048d67f82b216508cIhab Awad 25950e3506533478fa273cbc92c2919470d1889f1edIhab Awad /** @hide */ 260720c664401081ca00e56c7eef12641ae792da530Tyler Gunn void setConnectionProperties(final int connectionProperties) { 261720c664401081ca00e56c7eef12641ae792da530Tyler Gunn if (mConnectionProperties != connectionProperties) { 262720c664401081ca00e56c7eef12641ae792da530Tyler Gunn mConnectionProperties = connectionProperties; 263720c664401081ca00e56c7eef12641ae792da530Tyler Gunn for (CallbackRecord<Callback> record : mCallbackRecords) { 264720c664401081ca00e56c7eef12641ae792da530Tyler Gunn final RemoteConference conference = this; 265720c664401081ca00e56c7eef12641ae792da530Tyler Gunn final Callback callback = record.getCallback(); 266720c664401081ca00e56c7eef12641ae792da530Tyler Gunn record.getHandler().post(new Runnable() { 267720c664401081ca00e56c7eef12641ae792da530Tyler Gunn @Override 268720c664401081ca00e56c7eef12641ae792da530Tyler Gunn public void run() { 269720c664401081ca00e56c7eef12641ae792da530Tyler Gunn callback.onConnectionPropertiesChanged( 270720c664401081ca00e56c7eef12641ae792da530Tyler Gunn conference, mConnectionProperties); 271720c664401081ca00e56c7eef12641ae792da530Tyler Gunn } 272720c664401081ca00e56c7eef12641ae792da530Tyler Gunn }); 273720c664401081ca00e56c7eef12641ae792da530Tyler Gunn } 274720c664401081ca00e56c7eef12641ae792da530Tyler Gunn } 275720c664401081ca00e56c7eef12641ae792da530Tyler Gunn } 276720c664401081ca00e56c7eef12641ae792da530Tyler Gunn 277720c664401081ca00e56c7eef12641ae792da530Tyler Gunn /** @hide */ 27850e3506533478fa273cbc92c2919470d1889f1edIhab Awad void setConferenceableConnections(List<RemoteConnection> conferenceableConnections) { 27950e3506533478fa273cbc92c2919470d1889f1edIhab Awad mConferenceableConnections.clear(); 28050e3506533478fa273cbc92c2919470d1889f1edIhab Awad mConferenceableConnections.addAll(conferenceableConnections); 281011728fc3a4368b601844d225d1f37bf48ea5735Andrew Lee for (CallbackRecord<Callback> record : mCallbackRecords) { 282011728fc3a4368b601844d225d1f37bf48ea5735Andrew Lee final RemoteConference conference = this; 283011728fc3a4368b601844d225d1f37bf48ea5735Andrew Lee final Callback callback = record.getCallback(); 284011728fc3a4368b601844d225d1f37bf48ea5735Andrew Lee record.getHandler().post(new Runnable() { 285011728fc3a4368b601844d225d1f37bf48ea5735Andrew Lee @Override 286011728fc3a4368b601844d225d1f37bf48ea5735Andrew Lee public void run() { 287011728fc3a4368b601844d225d1f37bf48ea5735Andrew Lee callback.onConferenceableConnectionsChanged( 288011728fc3a4368b601844d225d1f37bf48ea5735Andrew Lee conference, mUnmodifiableConferenceableConnections); 289011728fc3a4368b601844d225d1f37bf48ea5735Andrew Lee } 290011728fc3a4368b601844d225d1f37bf48ea5735Andrew Lee }); 29150e3506533478fa273cbc92c2919470d1889f1edIhab Awad } 29250e3506533478fa273cbc92c2919470d1889f1edIhab Awad } 29350e3506533478fa273cbc92c2919470d1889f1edIhab Awad 294b804f8d8ff2de6fa83d59949915ab118bbe00ccfSantos Cordon /** @hide */ 295011728fc3a4368b601844d225d1f37bf48ea5735Andrew Lee void setDisconnected(final DisconnectCause disconnectCause) { 296b8e85c74e5910a461078704048d67f82b216508cIhab Awad if (mState != Connection.STATE_DISCONNECTED) { 2977f3d41fd124dd7c4a8b72c1d48df08a8ee7209ecAndrew Lee mDisconnectCause = disconnectCause; 298b8e85c74e5910a461078704048d67f82b216508cIhab Awad setState(Connection.STATE_DISCONNECTED); 299011728fc3a4368b601844d225d1f37bf48ea5735Andrew Lee for (CallbackRecord<Callback> record : mCallbackRecords) { 300011728fc3a4368b601844d225d1f37bf48ea5735Andrew Lee final RemoteConference conference = this; 301011728fc3a4368b601844d225d1f37bf48ea5735Andrew Lee final Callback callback = record.getCallback(); 302011728fc3a4368b601844d225d1f37bf48ea5735Andrew Lee record.getHandler().post(new Runnable() { 303011728fc3a4368b601844d225d1f37bf48ea5735Andrew Lee @Override 304011728fc3a4368b601844d225d1f37bf48ea5735Andrew Lee public void run() { 305011728fc3a4368b601844d225d1f37bf48ea5735Andrew Lee callback.onDisconnected(conference, disconnectCause); 306011728fc3a4368b601844d225d1f37bf48ea5735Andrew Lee } 307011728fc3a4368b601844d225d1f37bf48ea5735Andrew Lee }); 308b8e85c74e5910a461078704048d67f82b216508cIhab Awad } 309b8e85c74e5910a461078704048d67f82b216508cIhab Awad } 310b8e85c74e5910a461078704048d67f82b216508cIhab Awad } 311b8e85c74e5910a461078704048d67f82b216508cIhab Awad 3126b7f955c2d9b231660b8c54f8ef8e8e6ad802625Santos Cordon /** @hide */ 313dee56a8a79f9daa1e597f5d4f399d3a5feedcac4Tyler Gunn void putExtras(final Bundle extras) { 3142282bb97e78ea87ff322ecf12563ab0120af2b28Tyler Gunn if (extras == null) { 3152282bb97e78ea87ff322ecf12563ab0120af2b28Tyler Gunn return; 3162282bb97e78ea87ff322ecf12563ab0120af2b28Tyler Gunn } 317dee56a8a79f9daa1e597f5d4f399d3a5feedcac4Tyler Gunn if (mExtras == null) { 318dee56a8a79f9daa1e597f5d4f399d3a5feedcac4Tyler Gunn mExtras = new Bundle(); 319dee56a8a79f9daa1e597f5d4f399d3a5feedcac4Tyler Gunn } 320dee56a8a79f9daa1e597f5d4f399d3a5feedcac4Tyler Gunn mExtras.putAll(extras); 321dee56a8a79f9daa1e597f5d4f399d3a5feedcac4Tyler Gunn 322dee56a8a79f9daa1e597f5d4f399d3a5feedcac4Tyler Gunn notifyExtrasChanged(); 323dee56a8a79f9daa1e597f5d4f399d3a5feedcac4Tyler Gunn } 324dee56a8a79f9daa1e597f5d4f399d3a5feedcac4Tyler Gunn 325dee56a8a79f9daa1e597f5d4f399d3a5feedcac4Tyler Gunn /** @hide */ 326dee56a8a79f9daa1e597f5d4f399d3a5feedcac4Tyler Gunn void removeExtras(List<String> keys) { 327dee56a8a79f9daa1e597f5d4f399d3a5feedcac4Tyler Gunn if (mExtras == null || keys == null || keys.isEmpty()) { 328dee56a8a79f9daa1e597f5d4f399d3a5feedcac4Tyler Gunn return; 329dee56a8a79f9daa1e597f5d4f399d3a5feedcac4Tyler Gunn } 330dee56a8a79f9daa1e597f5d4f399d3a5feedcac4Tyler Gunn for (String key : keys) { 331dee56a8a79f9daa1e597f5d4f399d3a5feedcac4Tyler Gunn mExtras.remove(key); 332dee56a8a79f9daa1e597f5d4f399d3a5feedcac4Tyler Gunn } 333dee56a8a79f9daa1e597f5d4f399d3a5feedcac4Tyler Gunn 334dee56a8a79f9daa1e597f5d4f399d3a5feedcac4Tyler Gunn notifyExtrasChanged(); 335dee56a8a79f9daa1e597f5d4f399d3a5feedcac4Tyler Gunn } 336dee56a8a79f9daa1e597f5d4f399d3a5feedcac4Tyler Gunn 337dee56a8a79f9daa1e597f5d4f399d3a5feedcac4Tyler Gunn private void notifyExtrasChanged() { 3386b7f955c2d9b231660b8c54f8ef8e8e6ad802625Santos Cordon for (CallbackRecord<Callback> record : mCallbackRecords) { 3396b7f955c2d9b231660b8c54f8ef8e8e6ad802625Santos Cordon final RemoteConference conference = this; 3406b7f955c2d9b231660b8c54f8ef8e8e6ad802625Santos Cordon final Callback callback = record.getCallback(); 3416b7f955c2d9b231660b8c54f8ef8e8e6ad802625Santos Cordon record.getHandler().post(new Runnable() { 3426b7f955c2d9b231660b8c54f8ef8e8e6ad802625Santos Cordon @Override 3436b7f955c2d9b231660b8c54f8ef8e8e6ad802625Santos Cordon public void run() { 344dee56a8a79f9daa1e597f5d4f399d3a5feedcac4Tyler Gunn callback.onExtrasChanged(conference, mExtras); 3456b7f955c2d9b231660b8c54f8ef8e8e6ad802625Santos Cordon } 3466b7f955c2d9b231660b8c54f8ef8e8e6ad802625Santos Cordon }); 3476b7f955c2d9b231660b8c54f8ef8e8e6ad802625Santos Cordon } 3486b7f955c2d9b231660b8c54f8ef8e8e6ad802625Santos Cordon } 3496b7f955c2d9b231660b8c54f8ef8e8e6ad802625Santos Cordon 350b804f8d8ff2de6fa83d59949915ab118bbe00ccfSantos Cordon /** 351b804f8d8ff2de6fa83d59949915ab118bbe00ccfSantos Cordon * Returns the list of {@link RemoteConnection}s contained in this conference. 352b804f8d8ff2de6fa83d59949915ab118bbe00ccfSantos Cordon * 353b804f8d8ff2de6fa83d59949915ab118bbe00ccfSantos Cordon * @return A list of child connections. 354b804f8d8ff2de6fa83d59949915ab118bbe00ccfSantos Cordon */ 355b8e85c74e5910a461078704048d67f82b216508cIhab Awad public final List<RemoteConnection> getConnections() { 356b8e85c74e5910a461078704048d67f82b216508cIhab Awad return mUnmodifiableChildConnections; 357b8e85c74e5910a461078704048d67f82b216508cIhab Awad } 358b8e85c74e5910a461078704048d67f82b216508cIhab Awad 359b804f8d8ff2de6fa83d59949915ab118bbe00ccfSantos Cordon /** 360b804f8d8ff2de6fa83d59949915ab118bbe00ccfSantos Cordon * Gets the state of the conference call. See {@link Connection} for valid values. 361b804f8d8ff2de6fa83d59949915ab118bbe00ccfSantos Cordon * 362b804f8d8ff2de6fa83d59949915ab118bbe00ccfSantos Cordon * @return A constant representing the state the conference call is currently in. 363b804f8d8ff2de6fa83d59949915ab118bbe00ccfSantos Cordon */ 364b8e85c74e5910a461078704048d67f82b216508cIhab Awad public final int getState() { 365b8e85c74e5910a461078704048d67f82b216508cIhab Awad return mState; 366b8e85c74e5910a461078704048d67f82b216508cIhab Awad } 367b8e85c74e5910a461078704048d67f82b216508cIhab Awad 368b804f8d8ff2de6fa83d59949915ab118bbe00ccfSantos Cordon /** 369b804f8d8ff2de6fa83d59949915ab118bbe00ccfSantos Cordon * Returns the capabilities of the conference. See {@code CAPABILITY_*} constants in class 370b804f8d8ff2de6fa83d59949915ab118bbe00ccfSantos Cordon * {@link Connection} for valid values. 371b804f8d8ff2de6fa83d59949915ab118bbe00ccfSantos Cordon * 372b804f8d8ff2de6fa83d59949915ab118bbe00ccfSantos Cordon * @return A bitmask of the capabilities of the conference call. 373b804f8d8ff2de6fa83d59949915ab118bbe00ccfSantos Cordon */ 3745c9c86ec0f95d1f5e1aca212967f508fc736b895Ihab Awad public final int getConnectionCapabilities() { 3755c9c86ec0f95d1f5e1aca212967f508fc736b895Ihab Awad return mConnectionCapabilities; 376b8e85c74e5910a461078704048d67f82b216508cIhab Awad } 377b8e85c74e5910a461078704048d67f82b216508cIhab Awad 378b804f8d8ff2de6fa83d59949915ab118bbe00ccfSantos Cordon /** 379720c664401081ca00e56c7eef12641ae792da530Tyler Gunn * Returns the properties of the conference. See {@code PROPERTY_*} constants in class 380720c664401081ca00e56c7eef12641ae792da530Tyler Gunn * {@link Connection} for valid values. 381720c664401081ca00e56c7eef12641ae792da530Tyler Gunn * 382720c664401081ca00e56c7eef12641ae792da530Tyler Gunn * @return A bitmask of the properties of the conference call. 383720c664401081ca00e56c7eef12641ae792da530Tyler Gunn */ 384720c664401081ca00e56c7eef12641ae792da530Tyler Gunn public final int getConnectionProperties() { 385720c664401081ca00e56c7eef12641ae792da530Tyler Gunn return mConnectionProperties; 386720c664401081ca00e56c7eef12641ae792da530Tyler Gunn } 387720c664401081ca00e56c7eef12641ae792da530Tyler Gunn 388720c664401081ca00e56c7eef12641ae792da530Tyler Gunn /** 3896b7f955c2d9b231660b8c54f8ef8e8e6ad802625Santos Cordon * Obtain the extras associated with this {@code RemoteConnection}. 3906b7f955c2d9b231660b8c54f8ef8e8e6ad802625Santos Cordon * 3916b7f955c2d9b231660b8c54f8ef8e8e6ad802625Santos Cordon * @return The extras for this connection. 3926b7f955c2d9b231660b8c54f8ef8e8e6ad802625Santos Cordon */ 3936b7f955c2d9b231660b8c54f8ef8e8e6ad802625Santos Cordon public final Bundle getExtras() { 3946b7f955c2d9b231660b8c54f8ef8e8e6ad802625Santos Cordon return mExtras; 3956b7f955c2d9b231660b8c54f8ef8e8e6ad802625Santos Cordon } 3966b7f955c2d9b231660b8c54f8ef8e8e6ad802625Santos Cordon 3976b7f955c2d9b231660b8c54f8ef8e8e6ad802625Santos Cordon /** 398b804f8d8ff2de6fa83d59949915ab118bbe00ccfSantos Cordon * Disconnects the conference call as well as the child {@link RemoteConnection}s. 399b804f8d8ff2de6fa83d59949915ab118bbe00ccfSantos Cordon */ 400b8e85c74e5910a461078704048d67f82b216508cIhab Awad public void disconnect() { 401b8e85c74e5910a461078704048d67f82b216508cIhab Awad try { 402b32d4f8b5cd5b9c2415e291896b83267e1b4d5feBrad Ebinger mConnectionService.disconnect(mId, null /*Session.Info*/); 403b8e85c74e5910a461078704048d67f82b216508cIhab Awad } catch (RemoteException e) { 404b8e85c74e5910a461078704048d67f82b216508cIhab Awad } 405b8e85c74e5910a461078704048d67f82b216508cIhab Awad } 406b8e85c74e5910a461078704048d67f82b216508cIhab Awad 407b804f8d8ff2de6fa83d59949915ab118bbe00ccfSantos Cordon /** 408b804f8d8ff2de6fa83d59949915ab118bbe00ccfSantos Cordon * Removes the specified {@link RemoteConnection} from the conference. This causes the 409b804f8d8ff2de6fa83d59949915ab118bbe00ccfSantos Cordon * {@link RemoteConnection} to become a standalone connection. This is a no-op if the 410b804f8d8ff2de6fa83d59949915ab118bbe00ccfSantos Cordon * {@link RemoteConnection} does not belong to this conference. 411b804f8d8ff2de6fa83d59949915ab118bbe00ccfSantos Cordon * 412b804f8d8ff2de6fa83d59949915ab118bbe00ccfSantos Cordon * @param connection The remote-connection to remove. 413b804f8d8ff2de6fa83d59949915ab118bbe00ccfSantos Cordon */ 414b8e85c74e5910a461078704048d67f82b216508cIhab Awad public void separate(RemoteConnection connection) { 415b8e85c74e5910a461078704048d67f82b216508cIhab Awad if (mChildConnections.contains(connection)) { 416b8e85c74e5910a461078704048d67f82b216508cIhab Awad try { 417b32d4f8b5cd5b9c2415e291896b83267e1b4d5feBrad Ebinger mConnectionService.splitFromConference(connection.getId(), null /*Session.Info*/); 418b8e85c74e5910a461078704048d67f82b216508cIhab Awad } catch (RemoteException e) { 419b8e85c74e5910a461078704048d67f82b216508cIhab Awad } 420b8e85c74e5910a461078704048d67f82b216508cIhab Awad } 421b8e85c74e5910a461078704048d67f82b216508cIhab Awad } 422b8e85c74e5910a461078704048d67f82b216508cIhab Awad 423b804f8d8ff2de6fa83d59949915ab118bbe00ccfSantos Cordon /** 424b804f8d8ff2de6fa83d59949915ab118bbe00ccfSantos Cordon * Merges all {@link RemoteConnection}s of this conference into a single call. This should be 425b804f8d8ff2de6fa83d59949915ab118bbe00ccfSantos Cordon * invoked only if the conference contains the capability 426b804f8d8ff2de6fa83d59949915ab118bbe00ccfSantos Cordon * {@link Connection#CAPABILITY_MERGE_CONFERENCE}, otherwise it is a no-op. The presence of said 427b804f8d8ff2de6fa83d59949915ab118bbe00ccfSantos Cordon * capability indicates that the connections of this conference, despite being part of the 428b804f8d8ff2de6fa83d59949915ab118bbe00ccfSantos Cordon * same conference object, are yet to have their audio streams merged; this is a common pattern 429b804f8d8ff2de6fa83d59949915ab118bbe00ccfSantos Cordon * for CDMA conference calls, but the capability is not used for GSM and SIP conference calls. 430b804f8d8ff2de6fa83d59949915ab118bbe00ccfSantos Cordon * Invoking this method will cause the unmerged child connections to merge their audio 431b804f8d8ff2de6fa83d59949915ab118bbe00ccfSantos Cordon * streams. 432b804f8d8ff2de6fa83d59949915ab118bbe00ccfSantos Cordon */ 43395ea5765dca757c8c9f0445eba6735dac996c62bmike dooley public void merge() { 43495ea5765dca757c8c9f0445eba6735dac996c62bmike dooley try { 435b32d4f8b5cd5b9c2415e291896b83267e1b4d5feBrad Ebinger mConnectionService.mergeConference(mId, null /*Session.Info*/); 43695ea5765dca757c8c9f0445eba6735dac996c62bmike dooley } catch (RemoteException e) { 43795ea5765dca757c8c9f0445eba6735dac996c62bmike dooley } 43895ea5765dca757c8c9f0445eba6735dac996c62bmike dooley } 43995ea5765dca757c8c9f0445eba6735dac996c62bmike dooley 440b804f8d8ff2de6fa83d59949915ab118bbe00ccfSantos Cordon /** 441b804f8d8ff2de6fa83d59949915ab118bbe00ccfSantos Cordon * Swaps the active audio stream between the conference's child {@link RemoteConnection}s. 442b804f8d8ff2de6fa83d59949915ab118bbe00ccfSantos Cordon * This should be invoked only if the conference contains the capability 443b804f8d8ff2de6fa83d59949915ab118bbe00ccfSantos Cordon * {@link Connection#CAPABILITY_SWAP_CONFERENCE}, otherwise it is a no-op. This is only used by 444b804f8d8ff2de6fa83d59949915ab118bbe00ccfSantos Cordon * {@link ConnectionService}s that create conferences for connections that do not yet have 445b804f8d8ff2de6fa83d59949915ab118bbe00ccfSantos Cordon * their audio streams merged; this is a common pattern for CDMA conference calls, but the 446b804f8d8ff2de6fa83d59949915ab118bbe00ccfSantos Cordon * capability is not used for GSM and SIP conference calls. Invoking this method will change the 447b804f8d8ff2de6fa83d59949915ab118bbe00ccfSantos Cordon * active audio stream to a different child connection. 448b804f8d8ff2de6fa83d59949915ab118bbe00ccfSantos Cordon */ 44995ea5765dca757c8c9f0445eba6735dac996c62bmike dooley public void swap() { 45095ea5765dca757c8c9f0445eba6735dac996c62bmike dooley try { 451b32d4f8b5cd5b9c2415e291896b83267e1b4d5feBrad Ebinger mConnectionService.swapConference(mId, null /*Session.Info*/); 45295ea5765dca757c8c9f0445eba6735dac996c62bmike dooley } catch (RemoteException e) { 45395ea5765dca757c8c9f0445eba6735dac996c62bmike dooley } 45495ea5765dca757c8c9f0445eba6735dac996c62bmike dooley } 45595ea5765dca757c8c9f0445eba6735dac996c62bmike dooley 456b804f8d8ff2de6fa83d59949915ab118bbe00ccfSantos Cordon /** 457b804f8d8ff2de6fa83d59949915ab118bbe00ccfSantos Cordon * Puts the conference on hold. 458b804f8d8ff2de6fa83d59949915ab118bbe00ccfSantos Cordon */ 459b8e85c74e5910a461078704048d67f82b216508cIhab Awad public void hold() { 460b8e85c74e5910a461078704048d67f82b216508cIhab Awad try { 461b32d4f8b5cd5b9c2415e291896b83267e1b4d5feBrad Ebinger mConnectionService.hold(mId, null /*Session.Info*/); 462b8e85c74e5910a461078704048d67f82b216508cIhab Awad } catch (RemoteException e) { 463b8e85c74e5910a461078704048d67f82b216508cIhab Awad } 464b8e85c74e5910a461078704048d67f82b216508cIhab Awad } 465b8e85c74e5910a461078704048d67f82b216508cIhab Awad 466b804f8d8ff2de6fa83d59949915ab118bbe00ccfSantos Cordon /** 467b804f8d8ff2de6fa83d59949915ab118bbe00ccfSantos Cordon * Unholds the conference call. 468b804f8d8ff2de6fa83d59949915ab118bbe00ccfSantos Cordon */ 469b8e85c74e5910a461078704048d67f82b216508cIhab Awad public void unhold() { 470b8e85c74e5910a461078704048d67f82b216508cIhab Awad try { 471b32d4f8b5cd5b9c2415e291896b83267e1b4d5feBrad Ebinger mConnectionService.unhold(mId, null /*Session.Info*/); 472b8e85c74e5910a461078704048d67f82b216508cIhab Awad } catch (RemoteException e) { 473b8e85c74e5910a461078704048d67f82b216508cIhab Awad } 474b8e85c74e5910a461078704048d67f82b216508cIhab Awad } 475b8e85c74e5910a461078704048d67f82b216508cIhab Awad 476b804f8d8ff2de6fa83d59949915ab118bbe00ccfSantos Cordon /** 477b804f8d8ff2de6fa83d59949915ab118bbe00ccfSantos Cordon * Returns the {@link DisconnectCause} for the conference if it is in the state 478b804f8d8ff2de6fa83d59949915ab118bbe00ccfSantos Cordon * {@link Connection#STATE_DISCONNECTED}. If the conference is not disconnected, this will 479b804f8d8ff2de6fa83d59949915ab118bbe00ccfSantos Cordon * return null. 480b804f8d8ff2de6fa83d59949915ab118bbe00ccfSantos Cordon * 481b804f8d8ff2de6fa83d59949915ab118bbe00ccfSantos Cordon * @return The disconnect cause. 482b804f8d8ff2de6fa83d59949915ab118bbe00ccfSantos Cordon */ 4837f3d41fd124dd7c4a8b72c1d48df08a8ee7209ecAndrew Lee public DisconnectCause getDisconnectCause() { 484b8e85c74e5910a461078704048d67f82b216508cIhab Awad return mDisconnectCause; 485b8e85c74e5910a461078704048d67f82b216508cIhab Awad } 486b8e85c74e5910a461078704048d67f82b216508cIhab Awad 487b804f8d8ff2de6fa83d59949915ab118bbe00ccfSantos Cordon /** 488b804f8d8ff2de6fa83d59949915ab118bbe00ccfSantos Cordon * Requests that the conference start playing the specified DTMF tone. 489b804f8d8ff2de6fa83d59949915ab118bbe00ccfSantos Cordon * 490b804f8d8ff2de6fa83d59949915ab118bbe00ccfSantos Cordon * @param digit The digit for which to play a DTMF tone. 491b804f8d8ff2de6fa83d59949915ab118bbe00ccfSantos Cordon */ 49258bacc513c5e665c62e7d82cc6f39196b4ff4302Yorke Lee public void playDtmfTone(char digit) { 49358bacc513c5e665c62e7d82cc6f39196b4ff4302Yorke Lee try { 494b32d4f8b5cd5b9c2415e291896b83267e1b4d5feBrad Ebinger mConnectionService.playDtmfTone(mId, digit, null /*Session.Info*/); 49558bacc513c5e665c62e7d82cc6f39196b4ff4302Yorke Lee } catch (RemoteException e) { 49658bacc513c5e665c62e7d82cc6f39196b4ff4302Yorke Lee } 49758bacc513c5e665c62e7d82cc6f39196b4ff4302Yorke Lee } 49858bacc513c5e665c62e7d82cc6f39196b4ff4302Yorke Lee 499b804f8d8ff2de6fa83d59949915ab118bbe00ccfSantos Cordon /** 500b804f8d8ff2de6fa83d59949915ab118bbe00ccfSantos Cordon * Stops the most recent request to play a DTMF tone. 501b804f8d8ff2de6fa83d59949915ab118bbe00ccfSantos Cordon * 502b804f8d8ff2de6fa83d59949915ab118bbe00ccfSantos Cordon * @see #playDtmfTone 503b804f8d8ff2de6fa83d59949915ab118bbe00ccfSantos Cordon */ 50458bacc513c5e665c62e7d82cc6f39196b4ff4302Yorke Lee public void stopDtmfTone() { 50558bacc513c5e665c62e7d82cc6f39196b4ff4302Yorke Lee try { 506b32d4f8b5cd5b9c2415e291896b83267e1b4d5feBrad Ebinger mConnectionService.stopDtmfTone(mId, null /*Session.Info*/); 50758bacc513c5e665c62e7d82cc6f39196b4ff4302Yorke Lee } catch (RemoteException e) { 50858bacc513c5e665c62e7d82cc6f39196b4ff4302Yorke Lee } 50958bacc513c5e665c62e7d82cc6f39196b4ff4302Yorke Lee } 51058bacc513c5e665c62e7d82cc6f39196b4ff4302Yorke Lee 511b804f8d8ff2de6fa83d59949915ab118bbe00ccfSantos Cordon /** 512b804f8d8ff2de6fa83d59949915ab118bbe00ccfSantos Cordon * Request to change the conference's audio routing to the specified state. The specified state 513b804f8d8ff2de6fa83d59949915ab118bbe00ccfSantos Cordon * can include audio routing (Bluetooth, Speaker, etc) and muting state. 514b804f8d8ff2de6fa83d59949915ab118bbe00ccfSantos Cordon * 515b804f8d8ff2de6fa83d59949915ab118bbe00ccfSantos Cordon * @see android.telecom.AudioState 5164af5935c71f1e31ef1aec27661c4ef60545a0924Yorke Lee * @deprecated Use {@link #setCallAudioState(CallAudioState)} instead. 5174af5935c71f1e31ef1aec27661c4ef60545a0924Yorke Lee * @hide 518b804f8d8ff2de6fa83d59949915ab118bbe00ccfSantos Cordon */ 5194af5935c71f1e31ef1aec27661c4ef60545a0924Yorke Lee @SystemApi 5204af5935c71f1e31ef1aec27661c4ef60545a0924Yorke Lee @Deprecated 52158bacc513c5e665c62e7d82cc6f39196b4ff4302Yorke Lee public void setAudioState(AudioState state) { 5224af5935c71f1e31ef1aec27661c4ef60545a0924Yorke Lee setCallAudioState(new CallAudioState(state)); 5234af5935c71f1e31ef1aec27661c4ef60545a0924Yorke Lee } 5244af5935c71f1e31ef1aec27661c4ef60545a0924Yorke Lee 5254af5935c71f1e31ef1aec27661c4ef60545a0924Yorke Lee /** 5264af5935c71f1e31ef1aec27661c4ef60545a0924Yorke Lee * Request to change the conference's audio routing to the specified state. The specified state 5274af5935c71f1e31ef1aec27661c4ef60545a0924Yorke Lee * can include audio routing (Bluetooth, Speaker, etc) and muting state. 5284af5935c71f1e31ef1aec27661c4ef60545a0924Yorke Lee */ 5294af5935c71f1e31ef1aec27661c4ef60545a0924Yorke Lee public void setCallAudioState(CallAudioState state) { 53058bacc513c5e665c62e7d82cc6f39196b4ff4302Yorke Lee try { 531b32d4f8b5cd5b9c2415e291896b83267e1b4d5feBrad Ebinger mConnectionService.onCallAudioStateChanged(mId, state, null /*Session.Info*/); 53258bacc513c5e665c62e7d82cc6f39196b4ff4302Yorke Lee } catch (RemoteException e) { 53358bacc513c5e665c62e7d82cc6f39196b4ff4302Yorke Lee } 53458bacc513c5e665c62e7d82cc6f39196b4ff4302Yorke Lee } 53558bacc513c5e665c62e7d82cc6f39196b4ff4302Yorke Lee 5364af5935c71f1e31ef1aec27661c4ef60545a0924Yorke Lee 537b804f8d8ff2de6fa83d59949915ab118bbe00ccfSantos Cordon /** 538b804f8d8ff2de6fa83d59949915ab118bbe00ccfSantos Cordon * Returns a list of independent connections that can me merged with this conference. 539b804f8d8ff2de6fa83d59949915ab118bbe00ccfSantos Cordon * 540b804f8d8ff2de6fa83d59949915ab118bbe00ccfSantos Cordon * @return A list of conferenceable connections. 541b804f8d8ff2de6fa83d59949915ab118bbe00ccfSantos Cordon */ 54250e3506533478fa273cbc92c2919470d1889f1edIhab Awad public List<RemoteConnection> getConferenceableConnections() { 54350e3506533478fa273cbc92c2919470d1889f1edIhab Awad return mUnmodifiableConferenceableConnections; 54450e3506533478fa273cbc92c2919470d1889f1edIhab Awad } 54550e3506533478fa273cbc92c2919470d1889f1edIhab Awad 546b804f8d8ff2de6fa83d59949915ab118bbe00ccfSantos Cordon /** 547b804f8d8ff2de6fa83d59949915ab118bbe00ccfSantos Cordon * Register a callback through which to receive state updates for this conference. 548b804f8d8ff2de6fa83d59949915ab118bbe00ccfSantos Cordon * 549b804f8d8ff2de6fa83d59949915ab118bbe00ccfSantos Cordon * @param callback The callback to notify of state changes. 550b804f8d8ff2de6fa83d59949915ab118bbe00ccfSantos Cordon */ 551100e293fa8021caed956597daa4e01cb19be1c33Andrew Lee public final void registerCallback(Callback callback) { 552011728fc3a4368b601844d225d1f37bf48ea5735Andrew Lee registerCallback(callback, new Handler()); 553011728fc3a4368b601844d225d1f37bf48ea5735Andrew Lee } 554011728fc3a4368b601844d225d1f37bf48ea5735Andrew Lee 555b804f8d8ff2de6fa83d59949915ab118bbe00ccfSantos Cordon /** 556b804f8d8ff2de6fa83d59949915ab118bbe00ccfSantos Cordon * Registers a callback through which to receive state updates for this conference. 557b804f8d8ff2de6fa83d59949915ab118bbe00ccfSantos Cordon * Callbacks will be notified using the specified handler, if provided. 558b804f8d8ff2de6fa83d59949915ab118bbe00ccfSantos Cordon * 559b804f8d8ff2de6fa83d59949915ab118bbe00ccfSantos Cordon * @param callback The callback to notify of state changes. 560b804f8d8ff2de6fa83d59949915ab118bbe00ccfSantos Cordon * @param handler The handler on which to execute the callbacks. 561b804f8d8ff2de6fa83d59949915ab118bbe00ccfSantos Cordon */ 562011728fc3a4368b601844d225d1f37bf48ea5735Andrew Lee public final void registerCallback(Callback callback, Handler handler) { 563011728fc3a4368b601844d225d1f37bf48ea5735Andrew Lee unregisterCallback(callback); 564011728fc3a4368b601844d225d1f37bf48ea5735Andrew Lee if (callback != null && handler != null) { 565011728fc3a4368b601844d225d1f37bf48ea5735Andrew Lee mCallbackRecords.add(new CallbackRecord(callback, handler)); 566011728fc3a4368b601844d225d1f37bf48ea5735Andrew Lee } 567b8e85c74e5910a461078704048d67f82b216508cIhab Awad } 568b8e85c74e5910a461078704048d67f82b216508cIhab Awad 569b804f8d8ff2de6fa83d59949915ab118bbe00ccfSantos Cordon /** 570b804f8d8ff2de6fa83d59949915ab118bbe00ccfSantos Cordon * Unregisters a previously registered callback. 571b804f8d8ff2de6fa83d59949915ab118bbe00ccfSantos Cordon * 572b804f8d8ff2de6fa83d59949915ab118bbe00ccfSantos Cordon * @see #registerCallback 573b804f8d8ff2de6fa83d59949915ab118bbe00ccfSantos Cordon * 574b804f8d8ff2de6fa83d59949915ab118bbe00ccfSantos Cordon * @param callback The callback to unregister. 575b804f8d8ff2de6fa83d59949915ab118bbe00ccfSantos Cordon */ 576100e293fa8021caed956597daa4e01cb19be1c33Andrew Lee public final void unregisterCallback(Callback callback) { 577011728fc3a4368b601844d225d1f37bf48ea5735Andrew Lee if (callback != null) { 578011728fc3a4368b601844d225d1f37bf48ea5735Andrew Lee for (CallbackRecord<Callback> record : mCallbackRecords) { 579011728fc3a4368b601844d225d1f37bf48ea5735Andrew Lee if (record.getCallback() == callback) { 580011728fc3a4368b601844d225d1f37bf48ea5735Andrew Lee mCallbackRecords.remove(record); 581011728fc3a4368b601844d225d1f37bf48ea5735Andrew Lee break; 582011728fc3a4368b601844d225d1f37bf48ea5735Andrew Lee } 583011728fc3a4368b601844d225d1f37bf48ea5735Andrew Lee } 584011728fc3a4368b601844d225d1f37bf48ea5735Andrew Lee } 585b8e85c74e5910a461078704048d67f82b216508cIhab Awad } 586b8e85c74e5910a461078704048d67f82b216508cIhab Awad} 587