Conference.java revision 32f24731604fd81289a39619bbc925b65184b505
1823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon/* 2823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon * Copyright (C) 2014 The Android Open Source Project 3823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon * 4823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon * Licensed under the Apache License, Version 2.0 (the "License"); 5823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon * you may not use this file except in compliance with the License. 6823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon * You may obtain a copy of the License at 7823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon * 8823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon * http://www.apache.org/licenses/LICENSE-2.0 9823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon * 10823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon * Unless required by applicable law or agreed to in writing, software 11823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon * distributed under the License is distributed on an "AS IS" BASIS, 12823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon * See the License for the specific language governing permissions and 14823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon * limitations under the License. 15823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon */ 16823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon 17ef9f6f957d897ea0ed82114185b8fa3fefd4917bTyler Gunnpackage android.telecom; 18823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon 195d2e4f20fee033a22fbadffb291c4e47f35b7633Santos Cordonimport android.annotation.SystemApi; 2007366813cdf3768dcd69a1f744023747564d654aRekha Kumarimport android.telecom.Connection.VideoProvider; 210e094d926c306c3667bcdf6f23c52cc7181f25f3Evan Charlton 2250e3506533478fa273cbc92c2919470d1889f1edIhab Awadimport java.util.ArrayList; 23823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordonimport java.util.Collections; 24823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordonimport java.util.List; 2507366813cdf3768dcd69a1f744023747564d654aRekha Kumarimport java.util.Locale; 26823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordonimport java.util.Set; 27823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordonimport java.util.concurrent.CopyOnWriteArrayList; 28823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordonimport java.util.concurrent.CopyOnWriteArraySet; 29823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon 30823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon/** 31823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon * Represents a conference call which can contain any number of {@link Connection} objects. 32823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon */ 33df2cbc8989e624cd6a1d732549ea4a4f00852508Tyler Gunnpublic abstract class Conference implements Conferenceable { 34823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon 35cd5d33c89f25b3bfe8989d55f05702d0970c13b4Tyler Gunn /** 36cd5d33c89f25b3bfe8989d55f05702d0970c13b4Tyler Gunn * Used to indicate that the conference connection time is not specified. If not specified, 37cd5d33c89f25b3bfe8989d55f05702d0970c13b4Tyler Gunn * Telecom will set the connect time. 38cd5d33c89f25b3bfe8989d55f05702d0970c13b4Tyler Gunn */ 39164a0acf53a3496c974a97ed35834e6195c14e4bJay Shrauner public static final long CONNECT_TIME_NOT_SPECIFIED = 0; 40cd5d33c89f25b3bfe8989d55f05702d0970c13b4Tyler Gunn 41823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon /** @hide */ 42823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon public abstract static class Listener { 43823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon public void onStateChanged(Conference conference, int oldState, int newState) {} 447f3d41fd124dd7c4a8b72c1d48df08a8ee7209ecAndrew Lee public void onDisconnected(Conference conference, DisconnectCause disconnectCause) {} 45823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon public void onConnectionAdded(Conference conference, Connection connection) {} 46823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon public void onConnectionRemoved(Conference conference, Connection connection) {} 4750e3506533478fa273cbc92c2919470d1889f1edIhab Awad public void onConferenceableConnectionsChanged( 4850e3506533478fa273cbc92c2919470d1889f1edIhab Awad Conference conference, List<Connection> conferenceableConnections) {} 49823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon public void onDestroyed(Conference conference) {} 505c9c86ec0f95d1f5e1aca212967f508fc736b895Ihab Awad public void onConnectionCapabilitiesChanged( 515c9c86ec0f95d1f5e1aca212967f508fc736b895Ihab Awad Conference conference, int connectionCapabilities) {} 5207366813cdf3768dcd69a1f744023747564d654aRekha Kumar public void onVideoStateChanged(Conference c, int videoState) { } 5307366813cdf3768dcd69a1f744023747564d654aRekha Kumar public void onVideoProviderChanged(Conference c, Connection.VideoProvider videoProvider) {} 54edc625f52e5db5d0cb3d60387218f8f8365167f7Andrew Lee public void onStatusHintsChanged(Conference conference, StatusHints statusHints) {} 55823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon } 56823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon 57823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon private final Set<Listener> mListeners = new CopyOnWriteArraySet<>(); 58823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon private final List<Connection> mChildConnections = new CopyOnWriteArrayList<>(); 59b8e85c74e5910a461078704048d67f82b216508cIhab Awad private final List<Connection> mUnmodifiableChildConnections = 60823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon Collections.unmodifiableList(mChildConnections); 6150e3506533478fa273cbc92c2919470d1889f1edIhab Awad private final List<Connection> mConferenceableConnections = new ArrayList<>(); 6250e3506533478fa273cbc92c2919470d1889f1edIhab Awad private final List<Connection> mUnmodifiableConferenceableConnections = 6350e3506533478fa273cbc92c2919470d1889f1edIhab Awad Collections.unmodifiableList(mConferenceableConnections); 64823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon 65164a0acf53a3496c974a97ed35834e6195c14e4bJay Shrauner private PhoneAccountHandle mPhoneAccount; 66a0d3ca9746143d669fe9384babb9e1b9fca33dcfYorke Lee private AudioState mAudioState; 67823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon private int mState = Connection.STATE_NEW; 687f3d41fd124dd7c4a8b72c1d48df08a8ee7209ecAndrew Lee private DisconnectCause mDisconnectCause; 695c9c86ec0f95d1f5e1aca212967f508fc736b895Ihab Awad private int mConnectionCapabilities; 70823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon private String mDisconnectMessage; 71cd5d33c89f25b3bfe8989d55f05702d0970c13b4Tyler Gunn private long mConnectTimeMillis = CONNECT_TIME_NOT_SPECIFIED; 72edc625f52e5db5d0cb3d60387218f8f8365167f7Andrew Lee private StatusHints mStatusHints; 73823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon 7450e3506533478fa273cbc92c2919470d1889f1edIhab Awad private final Connection.Listener mConnectionDeathListener = new Connection.Listener() { 7550e3506533478fa273cbc92c2919470d1889f1edIhab Awad @Override 7650e3506533478fa273cbc92c2919470d1889f1edIhab Awad public void onDestroyed(Connection c) { 7750e3506533478fa273cbc92c2919470d1889f1edIhab Awad if (mConferenceableConnections.remove(c)) { 7850e3506533478fa273cbc92c2919470d1889f1edIhab Awad fireOnConferenceableConnectionsChanged(); 7950e3506533478fa273cbc92c2919470d1889f1edIhab Awad } 8050e3506533478fa273cbc92c2919470d1889f1edIhab Awad } 8150e3506533478fa273cbc92c2919470d1889f1edIhab Awad }; 8250e3506533478fa273cbc92c2919470d1889f1edIhab Awad 8356fc25deec15a32ea5f37d7c8c82f16d1bf9d275Nancy Chen /** 8456fc25deec15a32ea5f37d7c8c82f16d1bf9d275Nancy Chen * Constructs a new Conference with a mandatory {@link PhoneAccountHandle} 8556fc25deec15a32ea5f37d7c8c82f16d1bf9d275Nancy Chen * 8656fc25deec15a32ea5f37d7c8c82f16d1bf9d275Nancy Chen * @param phoneAccount The {@code PhoneAccountHandle} associated with the conference. 8756fc25deec15a32ea5f37d7c8c82f16d1bf9d275Nancy Chen */ 88823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon public Conference(PhoneAccountHandle phoneAccount) { 89823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon mPhoneAccount = phoneAccount; 90823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon } 91823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon 9256fc25deec15a32ea5f37d7c8c82f16d1bf9d275Nancy Chen /** 9356fc25deec15a32ea5f37d7c8c82f16d1bf9d275Nancy Chen * Returns the {@link PhoneAccountHandle} the conference call is being placed through. 9456fc25deec15a32ea5f37d7c8c82f16d1bf9d275Nancy Chen * 9556fc25deec15a32ea5f37d7c8c82f16d1bf9d275Nancy Chen * @return A {@code PhoneAccountHandle} object representing the PhoneAccount of the conference. 9656fc25deec15a32ea5f37d7c8c82f16d1bf9d275Nancy Chen */ 97ea38cca14964a5ee658899b0bafbc48017d556cdNancy Chen public final PhoneAccountHandle getPhoneAccountHandle() { 98823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon return mPhoneAccount; 99823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon } 100823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon 10156fc25deec15a32ea5f37d7c8c82f16d1bf9d275Nancy Chen /** 10256fc25deec15a32ea5f37d7c8c82f16d1bf9d275Nancy Chen * Returns the list of connections currently associated with the conference call. 10356fc25deec15a32ea5f37d7c8c82f16d1bf9d275Nancy Chen * 10456fc25deec15a32ea5f37d7c8c82f16d1bf9d275Nancy Chen * @return A list of {@code Connection} objects which represent the children of the conference. 10556fc25deec15a32ea5f37d7c8c82f16d1bf9d275Nancy Chen */ 106823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon public final List<Connection> getConnections() { 107b8e85c74e5910a461078704048d67f82b216508cIhab Awad return mUnmodifiableChildConnections; 108823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon } 109823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon 11056fc25deec15a32ea5f37d7c8c82f16d1bf9d275Nancy Chen /** 11156fc25deec15a32ea5f37d7c8c82f16d1bf9d275Nancy Chen * Gets the state of the conference call. See {@link Connection} for valid values. 11256fc25deec15a32ea5f37d7c8c82f16d1bf9d275Nancy Chen * 11356fc25deec15a32ea5f37d7c8c82f16d1bf9d275Nancy Chen * @return A constant representing the state the conference call is currently in. 11456fc25deec15a32ea5f37d7c8c82f16d1bf9d275Nancy Chen */ 115823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon public final int getState() { 116823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon return mState; 117823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon } 118823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon 1195c9c86ec0f95d1f5e1aca212967f508fc736b895Ihab Awad /** 1205d2e4f20fee033a22fbadffb291c4e47f35b7633Santos Cordon * Returns the capabilities of the conference. See {@code CAPABILITY_*} constants in class 1215c9c86ec0f95d1f5e1aca212967f508fc736b895Ihab Awad * {@link Connection} for valid values. 1225c9c86ec0f95d1f5e1aca212967f508fc736b895Ihab Awad * 1235c9c86ec0f95d1f5e1aca212967f508fc736b895Ihab Awad * @return A bitmask of the capabilities of the conference call. 1245c9c86ec0f95d1f5e1aca212967f508fc736b895Ihab Awad */ 1255c9c86ec0f95d1f5e1aca212967f508fc736b895Ihab Awad public final int getConnectionCapabilities() { 1265c9c86ec0f95d1f5e1aca212967f508fc736b895Ihab Awad return mConnectionCapabilities; 1275c9c86ec0f95d1f5e1aca212967f508fc736b895Ihab Awad } 1285c9c86ec0f95d1f5e1aca212967f508fc736b895Ihab Awad 1295c9c86ec0f95d1f5e1aca212967f508fc736b895Ihab Awad /** 1305c9c86ec0f95d1f5e1aca212967f508fc736b895Ihab Awad * Whether the given capabilities support the specified capability. 1315c9c86ec0f95d1f5e1aca212967f508fc736b895Ihab Awad * 1325c9c86ec0f95d1f5e1aca212967f508fc736b895Ihab Awad * @param capabilities A capability bit field. 1335c9c86ec0f95d1f5e1aca212967f508fc736b895Ihab Awad * @param capability The capability to check capabilities for. 1345c9c86ec0f95d1f5e1aca212967f508fc736b895Ihab Awad * @return Whether the specified capability is supported. 1355c9c86ec0f95d1f5e1aca212967f508fc736b895Ihab Awad * @hide 1365c9c86ec0f95d1f5e1aca212967f508fc736b895Ihab Awad */ 1375c9c86ec0f95d1f5e1aca212967f508fc736b895Ihab Awad public static boolean can(int capabilities, int capability) { 1385c9c86ec0f95d1f5e1aca212967f508fc736b895Ihab Awad return (capabilities & capability) != 0; 1395c9c86ec0f95d1f5e1aca212967f508fc736b895Ihab Awad } 1405c9c86ec0f95d1f5e1aca212967f508fc736b895Ihab Awad 14156fc25deec15a32ea5f37d7c8c82f16d1bf9d275Nancy Chen /** 1425c9c86ec0f95d1f5e1aca212967f508fc736b895Ihab Awad * Whether the capabilities of this {@code Connection} supports the specified capability. 14356fc25deec15a32ea5f37d7c8c82f16d1bf9d275Nancy Chen * 1445c9c86ec0f95d1f5e1aca212967f508fc736b895Ihab Awad * @param capability The capability to check capabilities for. 1455c9c86ec0f95d1f5e1aca212967f508fc736b895Ihab Awad * @return Whether the specified capability is supported. 1465c9c86ec0f95d1f5e1aca212967f508fc736b895Ihab Awad * @hide 14756fc25deec15a32ea5f37d7c8c82f16d1bf9d275Nancy Chen */ 1485c9c86ec0f95d1f5e1aca212967f508fc736b895Ihab Awad public boolean can(int capability) { 1495c9c86ec0f95d1f5e1aca212967f508fc736b895Ihab Awad return can(mConnectionCapabilities, capability); 1505c9c86ec0f95d1f5e1aca212967f508fc736b895Ihab Awad } 1515c9c86ec0f95d1f5e1aca212967f508fc736b895Ihab Awad 1525c9c86ec0f95d1f5e1aca212967f508fc736b895Ihab Awad /** 1535c9c86ec0f95d1f5e1aca212967f508fc736b895Ihab Awad * Removes the specified capability from the set of capabilities of this {@code Conference}. 1545c9c86ec0f95d1f5e1aca212967f508fc736b895Ihab Awad * 1555c9c86ec0f95d1f5e1aca212967f508fc736b895Ihab Awad * @param capability The capability to remove from the set. 1565c9c86ec0f95d1f5e1aca212967f508fc736b895Ihab Awad * @hide 1575c9c86ec0f95d1f5e1aca212967f508fc736b895Ihab Awad */ 1585c9c86ec0f95d1f5e1aca212967f508fc736b895Ihab Awad public void removeCapability(int capability) { 1595c9c86ec0f95d1f5e1aca212967f508fc736b895Ihab Awad mConnectionCapabilities &= ~capability; 1605c9c86ec0f95d1f5e1aca212967f508fc736b895Ihab Awad } 1615c9c86ec0f95d1f5e1aca212967f508fc736b895Ihab Awad 1625c9c86ec0f95d1f5e1aca212967f508fc736b895Ihab Awad /** 1635c9c86ec0f95d1f5e1aca212967f508fc736b895Ihab Awad * Adds the specified capability to the set of capabilities of this {@code Conference}. 1645c9c86ec0f95d1f5e1aca212967f508fc736b895Ihab Awad * 1655c9c86ec0f95d1f5e1aca212967f508fc736b895Ihab Awad * @param capability The capability to add to the set. 1665c9c86ec0f95d1f5e1aca212967f508fc736b895Ihab Awad * @hide 1675c9c86ec0f95d1f5e1aca212967f508fc736b895Ihab Awad */ 1685c9c86ec0f95d1f5e1aca212967f508fc736b895Ihab Awad public void addCapability(int capability) { 1695c9c86ec0f95d1f5e1aca212967f508fc736b895Ihab Awad mConnectionCapabilities |= capability; 170823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon } 171823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon 172823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon /** 173a0d3ca9746143d669fe9384babb9e1b9fca33dcfYorke Lee * @return The audio state of the conference, describing how its audio is currently 174a0d3ca9746143d669fe9384babb9e1b9fca33dcfYorke Lee * being routed by the system. This is {@code null} if this Conference 175a0d3ca9746143d669fe9384babb9e1b9fca33dcfYorke Lee * does not directly know about its audio state. 176a0d3ca9746143d669fe9384babb9e1b9fca33dcfYorke Lee */ 177a0d3ca9746143d669fe9384babb9e1b9fca33dcfYorke Lee public final AudioState getAudioState() { 178a0d3ca9746143d669fe9384babb9e1b9fca33dcfYorke Lee return mAudioState; 179a0d3ca9746143d669fe9384babb9e1b9fca33dcfYorke Lee } 180a0d3ca9746143d669fe9384babb9e1b9fca33dcfYorke Lee 181a0d3ca9746143d669fe9384babb9e1b9fca33dcfYorke Lee /** 18207366813cdf3768dcd69a1f744023747564d654aRekha Kumar * Returns VideoProvider of the primary call. This can be null. 18307366813cdf3768dcd69a1f744023747564d654aRekha Kumar */ 18407366813cdf3768dcd69a1f744023747564d654aRekha Kumar public VideoProvider getVideoProvider() { 18507366813cdf3768dcd69a1f744023747564d654aRekha Kumar return null; 18607366813cdf3768dcd69a1f744023747564d654aRekha Kumar } 18707366813cdf3768dcd69a1f744023747564d654aRekha Kumar 18807366813cdf3768dcd69a1f744023747564d654aRekha Kumar /** 18907366813cdf3768dcd69a1f744023747564d654aRekha Kumar * Returns video state of the primary call. 19007366813cdf3768dcd69a1f744023747564d654aRekha Kumar */ 19107366813cdf3768dcd69a1f744023747564d654aRekha Kumar public int getVideoState() { 19207366813cdf3768dcd69a1f744023747564d654aRekha Kumar return VideoProfile.VideoState.AUDIO_ONLY; 19307366813cdf3768dcd69a1f744023747564d654aRekha Kumar } 19407366813cdf3768dcd69a1f744023747564d654aRekha Kumar 19507366813cdf3768dcd69a1f744023747564d654aRekha Kumar /** 196823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon * Invoked when the Conference and all it's {@link Connection}s should be disconnected. 197823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon */ 198823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon public void onDisconnect() {} 199823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon 200823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon /** 201823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon * Invoked when the specified {@link Connection} should be separated from the conference call. 202823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon * 203823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon * @param connection The connection to separate. 204823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon */ 205823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon public void onSeparate(Connection connection) {} 206823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon 207823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon /** 20850e3506533478fa273cbc92c2919470d1889f1edIhab Awad * Invoked when the specified {@link Connection} should merged with the conference call. 20950e3506533478fa273cbc92c2919470d1889f1edIhab Awad * 21050e3506533478fa273cbc92c2919470d1889f1edIhab Awad * @param connection The {@code Connection} to merge. 21150e3506533478fa273cbc92c2919470d1889f1edIhab Awad */ 21250e3506533478fa273cbc92c2919470d1889f1edIhab Awad public void onMerge(Connection connection) {} 21350e3506533478fa273cbc92c2919470d1889f1edIhab Awad 21450e3506533478fa273cbc92c2919470d1889f1edIhab Awad /** 215823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon * Invoked when the conference should be put on hold. 216823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon */ 217823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon public void onHold() {} 218823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon 219823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon /** 220823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon * Invoked when the conference should be moved from hold to active. 221823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon */ 222823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon public void onUnhold() {} 223823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon 224823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon /** 225a48680427e022ab6eb73277faac6c57831ee6ff9Santos Cordon * Invoked when the child calls should be merged. Only invoked if the conference contains the 2265c9c86ec0f95d1f5e1aca212967f508fc736b895Ihab Awad * capability {@link Connection#CAPABILITY_MERGE_CONFERENCE}. 227a48680427e022ab6eb73277faac6c57831ee6ff9Santos Cordon */ 228a48680427e022ab6eb73277faac6c57831ee6ff9Santos Cordon public void onMerge() {} 229a48680427e022ab6eb73277faac6c57831ee6ff9Santos Cordon 230a48680427e022ab6eb73277faac6c57831ee6ff9Santos Cordon /** 231a48680427e022ab6eb73277faac6c57831ee6ff9Santos Cordon * Invoked when the child calls should be swapped. Only invoked if the conference contains the 2325c9c86ec0f95d1f5e1aca212967f508fc736b895Ihab Awad * capability {@link Connection#CAPABILITY_SWAP_CONFERENCE}. 233a48680427e022ab6eb73277faac6c57831ee6ff9Santos Cordon */ 234a48680427e022ab6eb73277faac6c57831ee6ff9Santos Cordon public void onSwap() {} 235a48680427e022ab6eb73277faac6c57831ee6ff9Santos Cordon 236a48680427e022ab6eb73277faac6c57831ee6ff9Santos Cordon /** 237a0d3ca9746143d669fe9384babb9e1b9fca33dcfYorke Lee * Notifies this conference of a request to play a DTMF tone. 238a0d3ca9746143d669fe9384babb9e1b9fca33dcfYorke Lee * 239a0d3ca9746143d669fe9384babb9e1b9fca33dcfYorke Lee * @param c A DTMF character. 240a0d3ca9746143d669fe9384babb9e1b9fca33dcfYorke Lee */ 241a0d3ca9746143d669fe9384babb9e1b9fca33dcfYorke Lee public void onPlayDtmfTone(char c) {} 242a0d3ca9746143d669fe9384babb9e1b9fca33dcfYorke Lee 243a0d3ca9746143d669fe9384babb9e1b9fca33dcfYorke Lee /** 244a0d3ca9746143d669fe9384babb9e1b9fca33dcfYorke Lee * Notifies this conference of a request to stop any currently playing DTMF tones. 245a0d3ca9746143d669fe9384babb9e1b9fca33dcfYorke Lee */ 246a0d3ca9746143d669fe9384babb9e1b9fca33dcfYorke Lee public void onStopDtmfTone() {} 247a0d3ca9746143d669fe9384babb9e1b9fca33dcfYorke Lee 248a0d3ca9746143d669fe9384babb9e1b9fca33dcfYorke Lee /** 249a0d3ca9746143d669fe9384babb9e1b9fca33dcfYorke Lee * Notifies this conference that the {@link #getAudioState()} property has a new value. 250a0d3ca9746143d669fe9384babb9e1b9fca33dcfYorke Lee * 251a0d3ca9746143d669fe9384babb9e1b9fca33dcfYorke Lee * @param state The new call audio state. 252a0d3ca9746143d669fe9384babb9e1b9fca33dcfYorke Lee */ 253a0d3ca9746143d669fe9384babb9e1b9fca33dcfYorke Lee public void onAudioStateChanged(AudioState state) {} 254a0d3ca9746143d669fe9384babb9e1b9fca33dcfYorke Lee 255a0d3ca9746143d669fe9384babb9e1b9fca33dcfYorke Lee /** 25646f7f5dce42d645353a0f3eb0dbdd25b3a6c72fbAndrew Lee * Notifies this conference that a connection has been added to it. 25746f7f5dce42d645353a0f3eb0dbdd25b3a6c72fbAndrew Lee * 25846f7f5dce42d645353a0f3eb0dbdd25b3a6c72fbAndrew Lee * @param connection The newly added connection. 25946f7f5dce42d645353a0f3eb0dbdd25b3a6c72fbAndrew Lee */ 26046f7f5dce42d645353a0f3eb0dbdd25b3a6c72fbAndrew Lee public void onConnectionAdded(Connection connection) {} 26146f7f5dce42d645353a0f3eb0dbdd25b3a6c72fbAndrew Lee 26246f7f5dce42d645353a0f3eb0dbdd25b3a6c72fbAndrew Lee /** 263823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon * Sets state to be on hold. 264823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon */ 265823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon public final void setOnHold() { 266823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon setState(Connection.STATE_HOLDING); 267823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon } 268823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon 269823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon /** 270823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon * Sets state to be active. 271823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon */ 272823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon public final void setActive() { 273823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon setState(Connection.STATE_ACTIVE); 274823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon } 275823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon 276823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon /** 277823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon * Sets state to disconnected. 278823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon * 2797f3d41fd124dd7c4a8b72c1d48df08a8ee7209ecAndrew Lee * @param disconnectCause The reason for the disconnection, as described by 2807f3d41fd124dd7c4a8b72c1d48df08a8ee7209ecAndrew Lee * {@link android.telecom.DisconnectCause}. 281823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon */ 2827f3d41fd124dd7c4a8b72c1d48df08a8ee7209ecAndrew Lee public final void setDisconnected(DisconnectCause disconnectCause) { 2837f3d41fd124dd7c4a8b72c1d48df08a8ee7209ecAndrew Lee mDisconnectCause = disconnectCause;; 284823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon setState(Connection.STATE_DISCONNECTED); 285823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon for (Listener l : mListeners) { 2867f3d41fd124dd7c4a8b72c1d48df08a8ee7209ecAndrew Lee l.onDisconnected(this, mDisconnectCause); 287823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon } 288823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon } 289823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon 290823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon /** 2911cf14ac5dc5708fc31e6c987a5c7db465ff95533mike dooley * @return The {@link DisconnectCause} for this connection. 2921cf14ac5dc5708fc31e6c987a5c7db465ff95533mike dooley */ 2931cf14ac5dc5708fc31e6c987a5c7db465ff95533mike dooley public final DisconnectCause getDisconnectCause() { 2941cf14ac5dc5708fc31e6c987a5c7db465ff95533mike dooley return mDisconnectCause; 2951cf14ac5dc5708fc31e6c987a5c7db465ff95533mike dooley } 2961cf14ac5dc5708fc31e6c987a5c7db465ff95533mike dooley 2971cf14ac5dc5708fc31e6c987a5c7db465ff95533mike dooley /** 2985c9c86ec0f95d1f5e1aca212967f508fc736b895Ihab Awad * Sets the capabilities of a conference. See {@code CAPABILITY_*} constants of class 2995c9c86ec0f95d1f5e1aca212967f508fc736b895Ihab Awad * {@link Connection} for valid values. 30056fc25deec15a32ea5f37d7c8c82f16d1bf9d275Nancy Chen * 3015c9c86ec0f95d1f5e1aca212967f508fc736b895Ihab Awad * @param connectionCapabilities A bitmask of the {@code PhoneCapabilities} of the conference call. 302823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon */ 3035c9c86ec0f95d1f5e1aca212967f508fc736b895Ihab Awad public final void setConnectionCapabilities(int connectionCapabilities) { 3045c9c86ec0f95d1f5e1aca212967f508fc736b895Ihab Awad if (connectionCapabilities != mConnectionCapabilities) { 3055c9c86ec0f95d1f5e1aca212967f508fc736b895Ihab Awad mConnectionCapabilities = connectionCapabilities; 306823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon 307823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon for (Listener l : mListeners) { 3085c9c86ec0f95d1f5e1aca212967f508fc736b895Ihab Awad l.onConnectionCapabilitiesChanged(this, mConnectionCapabilities); 309823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon } 310823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon } 311823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon } 312823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon 313823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon /** 314823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon * Adds the specified connection as a child of this conference. 315823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon * 316823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon * @param connection The connection to add. 317823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon * @return True if the connection was successfully added. 318823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon */ 319a48680427e022ab6eb73277faac6c57831ee6ff9Santos Cordon public final boolean addConnection(Connection connection) { 32007366813cdf3768dcd69a1f744023747564d654aRekha Kumar Log.d(this, "Connection=%s, connection=", connection); 321823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon if (connection != null && !mChildConnections.contains(connection)) { 322823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon if (connection.setConference(this)) { 323823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon mChildConnections.add(connection); 32446f7f5dce42d645353a0f3eb0dbdd25b3a6c72fbAndrew Lee onConnectionAdded(connection); 325823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon for (Listener l : mListeners) { 326823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon l.onConnectionAdded(this, connection); 327823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon } 328823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon return true; 329823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon } 330823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon } 331823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon return false; 332823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon } 333823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon 334823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon /** 335823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon * Removes the specified connection as a child of this conference. 336823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon * 337823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon * @param connection The connection to remove. 338823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon */ 339a48680427e022ab6eb73277faac6c57831ee6ff9Santos Cordon public final void removeConnection(Connection connection) { 3400159ac0cfe20e8f85ee4150e64d91392850f8a3fSantos Cordon Log.d(this, "removing %s from %s", connection, mChildConnections); 341823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon if (connection != null && mChildConnections.remove(connection)) { 342823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon connection.resetConference(); 343823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon for (Listener l : mListeners) { 344823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon l.onConnectionRemoved(this, connection); 345823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon } 346823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon } 347823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon } 348823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon 349823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon /** 35050e3506533478fa273cbc92c2919470d1889f1edIhab Awad * Sets the connections with which this connection can be conferenced. 35150e3506533478fa273cbc92c2919470d1889f1edIhab Awad * 35250e3506533478fa273cbc92c2919470d1889f1edIhab Awad * @param conferenceableConnections The set of connections this connection can conference with. 35350e3506533478fa273cbc92c2919470d1889f1edIhab Awad */ 35450e3506533478fa273cbc92c2919470d1889f1edIhab Awad public final void setConferenceableConnections(List<Connection> conferenceableConnections) { 35550e3506533478fa273cbc92c2919470d1889f1edIhab Awad clearConferenceableList(); 35650e3506533478fa273cbc92c2919470d1889f1edIhab Awad for (Connection c : conferenceableConnections) { 35750e3506533478fa273cbc92c2919470d1889f1edIhab Awad // If statement checks for duplicates in input. It makes it N^2 but we're dealing with a 35850e3506533478fa273cbc92c2919470d1889f1edIhab Awad // small amount of items here. 35950e3506533478fa273cbc92c2919470d1889f1edIhab Awad if (!mConferenceableConnections.contains(c)) { 36050e3506533478fa273cbc92c2919470d1889f1edIhab Awad c.addConnectionListener(mConnectionDeathListener); 36150e3506533478fa273cbc92c2919470d1889f1edIhab Awad mConferenceableConnections.add(c); 36250e3506533478fa273cbc92c2919470d1889f1edIhab Awad } 36350e3506533478fa273cbc92c2919470d1889f1edIhab Awad } 36450e3506533478fa273cbc92c2919470d1889f1edIhab Awad fireOnConferenceableConnectionsChanged(); 36550e3506533478fa273cbc92c2919470d1889f1edIhab Awad } 36650e3506533478fa273cbc92c2919470d1889f1edIhab Awad 36707366813cdf3768dcd69a1f744023747564d654aRekha Kumar /** 36807366813cdf3768dcd69a1f744023747564d654aRekha Kumar * Set the video state for the conference. 36932f24731604fd81289a39619bbc925b65184b505Yorke Lee * Valid values: {@link VideoProfile#STATE_AUDIO_ONLY}, 37032f24731604fd81289a39619bbc925b65184b505Yorke Lee * {@link VideoProfile#STATE_BIDIRECTIONAL}, 37132f24731604fd81289a39619bbc925b65184b505Yorke Lee * {@link VideoProfile#STATE_TX_ENABLED}, 37232f24731604fd81289a39619bbc925b65184b505Yorke Lee * {@link VideoProfile#STATE_RX_ENABLED}. 37307366813cdf3768dcd69a1f744023747564d654aRekha Kumar * 37407366813cdf3768dcd69a1f744023747564d654aRekha Kumar * @param videoState The new video state. 37507366813cdf3768dcd69a1f744023747564d654aRekha Kumar */ 37607366813cdf3768dcd69a1f744023747564d654aRekha Kumar public final void setVideoState(Connection c, int videoState) { 37707366813cdf3768dcd69a1f744023747564d654aRekha Kumar Log.d(this, "setVideoState Conference: %s Connection: %s VideoState: %s", 37807366813cdf3768dcd69a1f744023747564d654aRekha Kumar this, c, videoState); 37907366813cdf3768dcd69a1f744023747564d654aRekha Kumar for (Listener l : mListeners) { 38007366813cdf3768dcd69a1f744023747564d654aRekha Kumar l.onVideoStateChanged(this, videoState); 38107366813cdf3768dcd69a1f744023747564d654aRekha Kumar } 38207366813cdf3768dcd69a1f744023747564d654aRekha Kumar } 38307366813cdf3768dcd69a1f744023747564d654aRekha Kumar 38407366813cdf3768dcd69a1f744023747564d654aRekha Kumar /** 38507366813cdf3768dcd69a1f744023747564d654aRekha Kumar * Sets the video connection provider. 38607366813cdf3768dcd69a1f744023747564d654aRekha Kumar * 38707366813cdf3768dcd69a1f744023747564d654aRekha Kumar * @param videoProvider The video provider. 38807366813cdf3768dcd69a1f744023747564d654aRekha Kumar */ 38907366813cdf3768dcd69a1f744023747564d654aRekha Kumar public final void setVideoProvider(Connection c, Connection.VideoProvider videoProvider) { 39007366813cdf3768dcd69a1f744023747564d654aRekha Kumar Log.d(this, "setVideoProvider Conference: %s Connection: %s VideoState: %s", 39107366813cdf3768dcd69a1f744023747564d654aRekha Kumar this, c, videoProvider); 39207366813cdf3768dcd69a1f744023747564d654aRekha Kumar for (Listener l : mListeners) { 39307366813cdf3768dcd69a1f744023747564d654aRekha Kumar l.onVideoProviderChanged(this, videoProvider); 39407366813cdf3768dcd69a1f744023747564d654aRekha Kumar } 39507366813cdf3768dcd69a1f744023747564d654aRekha Kumar } 39607366813cdf3768dcd69a1f744023747564d654aRekha Kumar 39750e3506533478fa273cbc92c2919470d1889f1edIhab Awad private final void fireOnConferenceableConnectionsChanged() { 39850e3506533478fa273cbc92c2919470d1889f1edIhab Awad for (Listener l : mListeners) { 39950e3506533478fa273cbc92c2919470d1889f1edIhab Awad l.onConferenceableConnectionsChanged(this, getConferenceableConnections()); 40050e3506533478fa273cbc92c2919470d1889f1edIhab Awad } 40150e3506533478fa273cbc92c2919470d1889f1edIhab Awad } 40250e3506533478fa273cbc92c2919470d1889f1edIhab Awad 40350e3506533478fa273cbc92c2919470d1889f1edIhab Awad /** 40450e3506533478fa273cbc92c2919470d1889f1edIhab Awad * Returns the connections with which this connection can be conferenced. 40550e3506533478fa273cbc92c2919470d1889f1edIhab Awad */ 40650e3506533478fa273cbc92c2919470d1889f1edIhab Awad public final List<Connection> getConferenceableConnections() { 40750e3506533478fa273cbc92c2919470d1889f1edIhab Awad return mUnmodifiableConferenceableConnections; 40850e3506533478fa273cbc92c2919470d1889f1edIhab Awad } 40950e3506533478fa273cbc92c2919470d1889f1edIhab Awad 41050e3506533478fa273cbc92c2919470d1889f1edIhab Awad /** 411ea38cca14964a5ee658899b0bafbc48017d556cdNancy Chen * Tears down the conference object and any of its current connections. 412823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon */ 413a48680427e022ab6eb73277faac6c57831ee6ff9Santos Cordon public final void destroy() { 414823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon Log.d(this, "destroying conference : %s", this); 415823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon // Tear down the children. 4160159ac0cfe20e8f85ee4150e64d91392850f8a3fSantos Cordon for (Connection connection : mChildConnections) { 417823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon Log.d(this, "removing connection %s", connection); 418823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon removeConnection(connection); 419823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon } 420823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon 421823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon // If not yet disconnected, set the conference call as disconnected first. 422823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon if (mState != Connection.STATE_DISCONNECTED) { 423823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon Log.d(this, "setting to disconnected"); 4247f3d41fd124dd7c4a8b72c1d48df08a8ee7209ecAndrew Lee setDisconnected(new DisconnectCause(DisconnectCause.LOCAL)); 425823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon } 426823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon 427823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon // ...and notify. 428823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon for (Listener l : mListeners) { 429823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon l.onDestroyed(this); 430823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon } 431823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon } 432823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon 433823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon /** 434823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon * Add a listener to be notified of a state change. 435823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon * 436823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon * @param listener The new listener. 437823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon * @return This conference. 438823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon * @hide 439823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon */ 440823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon public final Conference addListener(Listener listener) { 441823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon mListeners.add(listener); 442823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon return this; 443823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon } 444823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon 445823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon /** 446823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon * Removes the specified listener. 447823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon * 448823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon * @param listener The listener to remove. 449823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon * @return This conference. 450823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon * @hide 451823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon */ 452823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon public final Conference removeListener(Listener listener) { 453823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon mListeners.remove(listener); 454823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon return this; 455823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon } 456823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon 457a0d3ca9746143d669fe9384babb9e1b9fca33dcfYorke Lee /** 4584a57b9b59b74c97e559a301af0add13cd4c3331cTyler Gunn * Retrieves the primary connection associated with the conference. The primary connection is 4594a57b9b59b74c97e559a301af0add13cd4c3331cTyler Gunn * the connection from which the conference will retrieve its current state. 4604a57b9b59b74c97e559a301af0add13cd4c3331cTyler Gunn * 4614a57b9b59b74c97e559a301af0add13cd4c3331cTyler Gunn * @return The primary connection. 4625d2e4f20fee033a22fbadffb291c4e47f35b7633Santos Cordon * @hide 4634a57b9b59b74c97e559a301af0add13cd4c3331cTyler Gunn */ 4645d2e4f20fee033a22fbadffb291c4e47f35b7633Santos Cordon @SystemApi 4654055d648993c35be19487f7ab82e337197e25297Santos Cordon public Connection getPrimaryConnection() { 4664a57b9b59b74c97e559a301af0add13cd4c3331cTyler Gunn if (mUnmodifiableChildConnections == null || mUnmodifiableChildConnections.isEmpty()) { 4674a57b9b59b74c97e559a301af0add13cd4c3331cTyler Gunn return null; 4684a57b9b59b74c97e559a301af0add13cd4c3331cTyler Gunn } 4694a57b9b59b74c97e559a301af0add13cd4c3331cTyler Gunn return mUnmodifiableChildConnections.get(0); 4704a57b9b59b74c97e559a301af0add13cd4c3331cTyler Gunn } 4714a57b9b59b74c97e559a301af0add13cd4c3331cTyler Gunn 4724a57b9b59b74c97e559a301af0add13cd4c3331cTyler Gunn /** 4735d2e4f20fee033a22fbadffb291c4e47f35b7633Santos Cordon * @hide 4745d2e4f20fee033a22fbadffb291c4e47f35b7633Santos Cordon * @deprecated Use {@link #setConnectionTime}. 4755d2e4f20fee033a22fbadffb291c4e47f35b7633Santos Cordon */ 4765d2e4f20fee033a22fbadffb291c4e47f35b7633Santos Cordon @Deprecated 4775d2e4f20fee033a22fbadffb291c4e47f35b7633Santos Cordon @SystemApi 4785d2e4f20fee033a22fbadffb291c4e47f35b7633Santos Cordon public final void setConnectTimeMillis(long connectTimeMillis) { 4795d2e4f20fee033a22fbadffb291c4e47f35b7633Santos Cordon setConnectionTime(connectTimeMillis); 4805d2e4f20fee033a22fbadffb291c4e47f35b7633Santos Cordon } 4815d2e4f20fee033a22fbadffb291c4e47f35b7633Santos Cordon 4825d2e4f20fee033a22fbadffb291c4e47f35b7633Santos Cordon /** 4835d2e4f20fee033a22fbadffb291c4e47f35b7633Santos Cordon * Sets the connection start time of the {@code Conference}. 484cd5d33c89f25b3bfe8989d55f05702d0970c13b4Tyler Gunn * 4855d2e4f20fee033a22fbadffb291c4e47f35b7633Santos Cordon * @param connectionTimeMillis The connection time, in milliseconds. 486cd5d33c89f25b3bfe8989d55f05702d0970c13b4Tyler Gunn */ 4875d2e4f20fee033a22fbadffb291c4e47f35b7633Santos Cordon public final void setConnectionTime(long connectionTimeMillis) { 4885d2e4f20fee033a22fbadffb291c4e47f35b7633Santos Cordon mConnectTimeMillis = connectionTimeMillis; 489cd5d33c89f25b3bfe8989d55f05702d0970c13b4Tyler Gunn } 490cd5d33c89f25b3bfe8989d55f05702d0970c13b4Tyler Gunn 491cd5d33c89f25b3bfe8989d55f05702d0970c13b4Tyler Gunn /** 4925d2e4f20fee033a22fbadffb291c4e47f35b7633Santos Cordon * @hide 4935d2e4f20fee033a22fbadffb291c4e47f35b7633Santos Cordon * @deprecated Use {@link #getConnectionTime}. 4945d2e4f20fee033a22fbadffb291c4e47f35b7633Santos Cordon */ 4955d2e4f20fee033a22fbadffb291c4e47f35b7633Santos Cordon @Deprecated 4965d2e4f20fee033a22fbadffb291c4e47f35b7633Santos Cordon @SystemApi 4975d2e4f20fee033a22fbadffb291c4e47f35b7633Santos Cordon public final long getConnectTimeMillis() { 4985d2e4f20fee033a22fbadffb291c4e47f35b7633Santos Cordon return getConnectionTime(); 4995d2e4f20fee033a22fbadffb291c4e47f35b7633Santos Cordon } 5005d2e4f20fee033a22fbadffb291c4e47f35b7633Santos Cordon 5015d2e4f20fee033a22fbadffb291c4e47f35b7633Santos Cordon /** 5025d2e4f20fee033a22fbadffb291c4e47f35b7633Santos Cordon * Retrieves the connection start time of the {@code Conference}, if specified. A value of 503cd5d33c89f25b3bfe8989d55f05702d0970c13b4Tyler Gunn * {@link #CONNECT_TIME_NOT_SPECIFIED} indicates that Telecom should determine the start time 504cd5d33c89f25b3bfe8989d55f05702d0970c13b4Tyler Gunn * of the conference. 505cd5d33c89f25b3bfe8989d55f05702d0970c13b4Tyler Gunn * 5065d2e4f20fee033a22fbadffb291c4e47f35b7633Santos Cordon * @return The time at which the {@code Conference} was connected. 507cd5d33c89f25b3bfe8989d55f05702d0970c13b4Tyler Gunn */ 5085d2e4f20fee033a22fbadffb291c4e47f35b7633Santos Cordon public final long getConnectionTime() { 509cd5d33c89f25b3bfe8989d55f05702d0970c13b4Tyler Gunn return mConnectTimeMillis; 510cd5d33c89f25b3bfe8989d55f05702d0970c13b4Tyler Gunn } 511cd5d33c89f25b3bfe8989d55f05702d0970c13b4Tyler Gunn 512cd5d33c89f25b3bfe8989d55f05702d0970c13b4Tyler Gunn /** 513a0d3ca9746143d669fe9384babb9e1b9fca33dcfYorke Lee * Inform this Conference that the state of its audio output has been changed externally. 514a0d3ca9746143d669fe9384babb9e1b9fca33dcfYorke Lee * 515a0d3ca9746143d669fe9384babb9e1b9fca33dcfYorke Lee * @param state The new audio state. 516a0d3ca9746143d669fe9384babb9e1b9fca33dcfYorke Lee * @hide 517a0d3ca9746143d669fe9384babb9e1b9fca33dcfYorke Lee */ 518a0d3ca9746143d669fe9384babb9e1b9fca33dcfYorke Lee final void setAudioState(AudioState state) { 519a0d3ca9746143d669fe9384babb9e1b9fca33dcfYorke Lee Log.d(this, "setAudioState %s", state); 520a0d3ca9746143d669fe9384babb9e1b9fca33dcfYorke Lee mAudioState = state; 521a0d3ca9746143d669fe9384babb9e1b9fca33dcfYorke Lee onAudioStateChanged(state); 522a0d3ca9746143d669fe9384babb9e1b9fca33dcfYorke Lee } 523a0d3ca9746143d669fe9384babb9e1b9fca33dcfYorke Lee 524823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon private void setState(int newState) { 525823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon if (newState != Connection.STATE_ACTIVE && 526823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon newState != Connection.STATE_HOLDING && 527823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon newState != Connection.STATE_DISCONNECTED) { 528823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon Log.w(this, "Unsupported state transition for Conference call.", 529823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon Connection.stateToString(newState)); 530823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon return; 531823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon } 532823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon 533823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon if (mState != newState) { 534823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon int oldState = mState; 535823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon mState = newState; 536823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon for (Listener l : mListeners) { 537823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon l.onStateChanged(this, oldState, newState); 538823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon } 539823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon } 540823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon } 54150e3506533478fa273cbc92c2919470d1889f1edIhab Awad 54250e3506533478fa273cbc92c2919470d1889f1edIhab Awad private final void clearConferenceableList() { 54350e3506533478fa273cbc92c2919470d1889f1edIhab Awad for (Connection c : mConferenceableConnections) { 54450e3506533478fa273cbc92c2919470d1889f1edIhab Awad c.removeConnectionListener(mConnectionDeathListener); 54550e3506533478fa273cbc92c2919470d1889f1edIhab Awad } 54650e3506533478fa273cbc92c2919470d1889f1edIhab Awad mConferenceableConnections.clear(); 54750e3506533478fa273cbc92c2919470d1889f1edIhab Awad } 54807366813cdf3768dcd69a1f744023747564d654aRekha Kumar 54907366813cdf3768dcd69a1f744023747564d654aRekha Kumar @Override 55007366813cdf3768dcd69a1f744023747564d654aRekha Kumar public String toString() { 55107366813cdf3768dcd69a1f744023747564d654aRekha Kumar return String.format(Locale.US, 55207366813cdf3768dcd69a1f744023747564d654aRekha Kumar "[State: %s,Capabilites: %s, VideoState: %s, VideoProvider: %s, ThisObject %s]", 55307366813cdf3768dcd69a1f744023747564d654aRekha Kumar Connection.stateToString(mState), 55407366813cdf3768dcd69a1f744023747564d654aRekha Kumar Call.Details.capabilitiesToString(mConnectionCapabilities), 55507366813cdf3768dcd69a1f744023747564d654aRekha Kumar getVideoState(), 55607366813cdf3768dcd69a1f744023747564d654aRekha Kumar getVideoProvider(), 55707366813cdf3768dcd69a1f744023747564d654aRekha Kumar super.toString()); 55807366813cdf3768dcd69a1f744023747564d654aRekha Kumar } 5590f51da328d11f8709d99890a61d6b4021a2207a5Andrew Lee 560edc625f52e5db5d0cb3d60387218f8f8365167f7Andrew Lee /** 561edc625f52e5db5d0cb3d60387218f8f8365167f7Andrew Lee * Sets the label and icon status to display in the InCall UI. 562edc625f52e5db5d0cb3d60387218f8f8365167f7Andrew Lee * 563edc625f52e5db5d0cb3d60387218f8f8365167f7Andrew Lee * @param statusHints The status label and icon to set. 564edc625f52e5db5d0cb3d60387218f8f8365167f7Andrew Lee */ 565edc625f52e5db5d0cb3d60387218f8f8365167f7Andrew Lee public final void setStatusHints(StatusHints statusHints) { 566edc625f52e5db5d0cb3d60387218f8f8365167f7Andrew Lee mStatusHints = statusHints; 567edc625f52e5db5d0cb3d60387218f8f8365167f7Andrew Lee for (Listener l : mListeners) { 568edc625f52e5db5d0cb3d60387218f8f8365167f7Andrew Lee l.onStatusHintsChanged(this, statusHints); 569edc625f52e5db5d0cb3d60387218f8f8365167f7Andrew Lee } 570edc625f52e5db5d0cb3d60387218f8f8365167f7Andrew Lee } 571edc625f52e5db5d0cb3d60387218f8f8365167f7Andrew Lee 572edc625f52e5db5d0cb3d60387218f8f8365167f7Andrew Lee /** 573edc625f52e5db5d0cb3d60387218f8f8365167f7Andrew Lee * @return The status hints for this conference. 574edc625f52e5db5d0cb3d60387218f8f8365167f7Andrew Lee */ 575edc625f52e5db5d0cb3d60387218f8f8365167f7Andrew Lee public final StatusHints getStatusHints() { 576edc625f52e5db5d0cb3d60387218f8f8365167f7Andrew Lee return mStatusHints; 577edc625f52e5db5d0cb3d60387218f8f8365167f7Andrew Lee } 578823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon} 579