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 19dee56a8a79f9daa1e597f5d4f399d3a5feedcac4Tyler Gunnimport android.annotation.NonNull; 206b7f955c2d9b231660b8c54f8ef8e8e6ad802625Santos Cordonimport android.annotation.Nullable; 215d2e4f20fee033a22fbadffb291c4e47f35b7633Santos Cordonimport android.annotation.SystemApi; 226b7f955c2d9b231660b8c54f8ef8e8e6ad802625Santos Cordonimport android.os.Bundle; 2307366813cdf3768dcd69a1f744023747564d654aRekha Kumarimport android.telecom.Connection.VideoProvider; 24dee56a8a79f9daa1e597f5d4f399d3a5feedcac4Tyler Gunnimport android.util.ArraySet; 250e094d926c306c3667bcdf6f23c52cc7181f25f3Evan Charlton 2650e3506533478fa273cbc92c2919470d1889f1edIhab Awadimport java.util.ArrayList; 27823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordonimport java.util.Collections; 28823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordonimport java.util.List; 2907366813cdf3768dcd69a1f744023747564d654aRekha Kumarimport java.util.Locale; 30823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordonimport java.util.Set; 31823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordonimport java.util.concurrent.CopyOnWriteArrayList; 32823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordonimport java.util.concurrent.CopyOnWriteArraySet; 33823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon 34823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon/** 35823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon * Represents a conference call which can contain any number of {@link Connection} objects. 36823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon */ 37abfcfdc0444c48dd161e425c8417dab87de1cb69Yorke Leepublic abstract class Conference extends Conferenceable { 38823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon 39cd5d33c89f25b3bfe8989d55f05702d0970c13b4Tyler Gunn /** 40cd5d33c89f25b3bfe8989d55f05702d0970c13b4Tyler Gunn * Used to indicate that the conference connection time is not specified. If not specified, 41cd5d33c89f25b3bfe8989d55f05702d0970c13b4Tyler Gunn * Telecom will set the connect time. 42cd5d33c89f25b3bfe8989d55f05702d0970c13b4Tyler Gunn */ 43164a0acf53a3496c974a97ed35834e6195c14e4bJay Shrauner public static final long CONNECT_TIME_NOT_SPECIFIED = 0; 44cd5d33c89f25b3bfe8989d55f05702d0970c13b4Tyler Gunn 45823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon /** @hide */ 46823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon public abstract static class Listener { 47823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon public void onStateChanged(Conference conference, int oldState, int newState) {} 487f3d41fd124dd7c4a8b72c1d48df08a8ee7209ecAndrew Lee public void onDisconnected(Conference conference, DisconnectCause disconnectCause) {} 49823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon public void onConnectionAdded(Conference conference, Connection connection) {} 50823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon public void onConnectionRemoved(Conference conference, Connection connection) {} 5150e3506533478fa273cbc92c2919470d1889f1edIhab Awad public void onConferenceableConnectionsChanged( 5250e3506533478fa273cbc92c2919470d1889f1edIhab Awad Conference conference, List<Connection> conferenceableConnections) {} 53823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon public void onDestroyed(Conference conference) {} 545c9c86ec0f95d1f5e1aca212967f508fc736b895Ihab Awad public void onConnectionCapabilitiesChanged( 555c9c86ec0f95d1f5e1aca212967f508fc736b895Ihab Awad Conference conference, int connectionCapabilities) {} 56720c664401081ca00e56c7eef12641ae792da530Tyler Gunn public void onConnectionPropertiesChanged( 57720c664401081ca00e56c7eef12641ae792da530Tyler Gunn Conference conference, int connectionProperties) {} 5807366813cdf3768dcd69a1f744023747564d654aRekha Kumar public void onVideoStateChanged(Conference c, int videoState) { } 5907366813cdf3768dcd69a1f744023747564d654aRekha Kumar public void onVideoProviderChanged(Conference c, Connection.VideoProvider videoProvider) {} 60edc625f52e5db5d0cb3d60387218f8f8365167f7Andrew Lee public void onStatusHintsChanged(Conference conference, StatusHints statusHints) {} 61dee56a8a79f9daa1e597f5d4f399d3a5feedcac4Tyler Gunn public void onExtrasChanged(Conference c, Bundle extras) {} 62dee56a8a79f9daa1e597f5d4f399d3a5feedcac4Tyler Gunn public void onExtrasRemoved(Conference c, List<String> keys) {} 63823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon } 64823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon 65823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon private final Set<Listener> mListeners = new CopyOnWriteArraySet<>(); 66823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon private final List<Connection> mChildConnections = new CopyOnWriteArrayList<>(); 67b8e85c74e5910a461078704048d67f82b216508cIhab Awad private final List<Connection> mUnmodifiableChildConnections = 68823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon Collections.unmodifiableList(mChildConnections); 6950e3506533478fa273cbc92c2919470d1889f1edIhab Awad private final List<Connection> mConferenceableConnections = new ArrayList<>(); 7050e3506533478fa273cbc92c2919470d1889f1edIhab Awad private final List<Connection> mUnmodifiableConferenceableConnections = 7150e3506533478fa273cbc92c2919470d1889f1edIhab Awad Collections.unmodifiableList(mConferenceableConnections); 72823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon 736714030083b1d8ec5b2df6dfef08034d0d30c2feJack Yu private String mTelecomCallId; 74164a0acf53a3496c974a97ed35834e6195c14e4bJay Shrauner private PhoneAccountHandle mPhoneAccount; 754af5935c71f1e31ef1aec27661c4ef60545a0924Yorke Lee private CallAudioState mCallAudioState; 76823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon private int mState = Connection.STATE_NEW; 777f3d41fd124dd7c4a8b72c1d48df08a8ee7209ecAndrew Lee private DisconnectCause mDisconnectCause; 785c9c86ec0f95d1f5e1aca212967f508fc736b895Ihab Awad private int mConnectionCapabilities; 79720c664401081ca00e56c7eef12641ae792da530Tyler Gunn private int mConnectionProperties; 80823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon private String mDisconnectMessage; 81cd5d33c89f25b3bfe8989d55f05702d0970c13b4Tyler Gunn private long mConnectTimeMillis = CONNECT_TIME_NOT_SPECIFIED; 82edc625f52e5db5d0cb3d60387218f8f8365167f7Andrew Lee private StatusHints mStatusHints; 836b7f955c2d9b231660b8c54f8ef8e8e6ad802625Santos Cordon private Bundle mExtras; 84dee56a8a79f9daa1e597f5d4f399d3a5feedcac4Tyler Gunn private Set<String> mPreviousExtraKeys; 854fa6a01898be85999e12b62bb52debb838e1bd0cBrad Ebinger private final Object mExtrasLock = new Object(); 86823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon 8750e3506533478fa273cbc92c2919470d1889f1edIhab Awad private final Connection.Listener mConnectionDeathListener = new Connection.Listener() { 8850e3506533478fa273cbc92c2919470d1889f1edIhab Awad @Override 8950e3506533478fa273cbc92c2919470d1889f1edIhab Awad public void onDestroyed(Connection c) { 9050e3506533478fa273cbc92c2919470d1889f1edIhab Awad if (mConferenceableConnections.remove(c)) { 9150e3506533478fa273cbc92c2919470d1889f1edIhab Awad fireOnConferenceableConnectionsChanged(); 9250e3506533478fa273cbc92c2919470d1889f1edIhab Awad } 9350e3506533478fa273cbc92c2919470d1889f1edIhab Awad } 9450e3506533478fa273cbc92c2919470d1889f1edIhab Awad }; 9550e3506533478fa273cbc92c2919470d1889f1edIhab Awad 9656fc25deec15a32ea5f37d7c8c82f16d1bf9d275Nancy Chen /** 9756fc25deec15a32ea5f37d7c8c82f16d1bf9d275Nancy Chen * Constructs a new Conference with a mandatory {@link PhoneAccountHandle} 9856fc25deec15a32ea5f37d7c8c82f16d1bf9d275Nancy Chen * 9956fc25deec15a32ea5f37d7c8c82f16d1bf9d275Nancy Chen * @param phoneAccount The {@code PhoneAccountHandle} associated with the conference. 10056fc25deec15a32ea5f37d7c8c82f16d1bf9d275Nancy Chen */ 101823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon public Conference(PhoneAccountHandle phoneAccount) { 102823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon mPhoneAccount = phoneAccount; 103823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon } 104823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon 10556fc25deec15a32ea5f37d7c8c82f16d1bf9d275Nancy Chen /** 1066714030083b1d8ec5b2df6dfef08034d0d30c2feJack Yu * Returns the telecom internal call ID associated with this conference. 1076714030083b1d8ec5b2df6dfef08034d0d30c2feJack Yu * 1086714030083b1d8ec5b2df6dfef08034d0d30c2feJack Yu * @return The telecom call ID. 1096714030083b1d8ec5b2df6dfef08034d0d30c2feJack Yu * @hide 1106714030083b1d8ec5b2df6dfef08034d0d30c2feJack Yu */ 1116714030083b1d8ec5b2df6dfef08034d0d30c2feJack Yu public final String getTelecomCallId() { 1126714030083b1d8ec5b2df6dfef08034d0d30c2feJack Yu return mTelecomCallId; 1136714030083b1d8ec5b2df6dfef08034d0d30c2feJack Yu } 1146714030083b1d8ec5b2df6dfef08034d0d30c2feJack Yu 1156714030083b1d8ec5b2df6dfef08034d0d30c2feJack Yu /** 1166714030083b1d8ec5b2df6dfef08034d0d30c2feJack Yu * Sets the telecom internal call ID associated with this conference. 1176714030083b1d8ec5b2df6dfef08034d0d30c2feJack Yu * 1186714030083b1d8ec5b2df6dfef08034d0d30c2feJack Yu * @param telecomCallId The telecom call ID. 1196714030083b1d8ec5b2df6dfef08034d0d30c2feJack Yu * @hide 1206714030083b1d8ec5b2df6dfef08034d0d30c2feJack Yu */ 1216714030083b1d8ec5b2df6dfef08034d0d30c2feJack Yu public final void setTelecomCallId(String telecomCallId) { 1226714030083b1d8ec5b2df6dfef08034d0d30c2feJack Yu mTelecomCallId = telecomCallId; 1236714030083b1d8ec5b2df6dfef08034d0d30c2feJack Yu } 1246714030083b1d8ec5b2df6dfef08034d0d30c2feJack Yu 1256714030083b1d8ec5b2df6dfef08034d0d30c2feJack Yu /** 12656fc25deec15a32ea5f37d7c8c82f16d1bf9d275Nancy Chen * Returns the {@link PhoneAccountHandle} the conference call is being placed through. 12756fc25deec15a32ea5f37d7c8c82f16d1bf9d275Nancy Chen * 12856fc25deec15a32ea5f37d7c8c82f16d1bf9d275Nancy Chen * @return A {@code PhoneAccountHandle} object representing the PhoneAccount of the conference. 12956fc25deec15a32ea5f37d7c8c82f16d1bf9d275Nancy Chen */ 130ea38cca14964a5ee658899b0bafbc48017d556cdNancy Chen public final PhoneAccountHandle getPhoneAccountHandle() { 131823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon return mPhoneAccount; 132823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon } 133823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon 13456fc25deec15a32ea5f37d7c8c82f16d1bf9d275Nancy Chen /** 13556fc25deec15a32ea5f37d7c8c82f16d1bf9d275Nancy Chen * Returns the list of connections currently associated with the conference call. 13656fc25deec15a32ea5f37d7c8c82f16d1bf9d275Nancy Chen * 13756fc25deec15a32ea5f37d7c8c82f16d1bf9d275Nancy Chen * @return A list of {@code Connection} objects which represent the children of the conference. 13856fc25deec15a32ea5f37d7c8c82f16d1bf9d275Nancy Chen */ 139823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon public final List<Connection> getConnections() { 140b8e85c74e5910a461078704048d67f82b216508cIhab Awad return mUnmodifiableChildConnections; 141823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon } 142823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon 14356fc25deec15a32ea5f37d7c8c82f16d1bf9d275Nancy Chen /** 14456fc25deec15a32ea5f37d7c8c82f16d1bf9d275Nancy Chen * Gets the state of the conference call. See {@link Connection} for valid values. 14556fc25deec15a32ea5f37d7c8c82f16d1bf9d275Nancy Chen * 14656fc25deec15a32ea5f37d7c8c82f16d1bf9d275Nancy Chen * @return A constant representing the state the conference call is currently in. 14756fc25deec15a32ea5f37d7c8c82f16d1bf9d275Nancy Chen */ 148823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon public final int getState() { 149823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon return mState; 150823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon } 151823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon 1525c9c86ec0f95d1f5e1aca212967f508fc736b895Ihab Awad /** 1535d2e4f20fee033a22fbadffb291c4e47f35b7633Santos Cordon * Returns the capabilities of the conference. See {@code CAPABILITY_*} constants in class 1545c9c86ec0f95d1f5e1aca212967f508fc736b895Ihab Awad * {@link Connection} for valid values. 1555c9c86ec0f95d1f5e1aca212967f508fc736b895Ihab Awad * 1565c9c86ec0f95d1f5e1aca212967f508fc736b895Ihab Awad * @return A bitmask of the capabilities of the conference call. 1575c9c86ec0f95d1f5e1aca212967f508fc736b895Ihab Awad */ 1585c9c86ec0f95d1f5e1aca212967f508fc736b895Ihab Awad public final int getConnectionCapabilities() { 1595c9c86ec0f95d1f5e1aca212967f508fc736b895Ihab Awad return mConnectionCapabilities; 1605c9c86ec0f95d1f5e1aca212967f508fc736b895Ihab Awad } 1615c9c86ec0f95d1f5e1aca212967f508fc736b895Ihab Awad 1625c9c86ec0f95d1f5e1aca212967f508fc736b895Ihab Awad /** 163720c664401081ca00e56c7eef12641ae792da530Tyler Gunn * Returns the properties of the conference. See {@code PROPERTY_*} constants in class 164720c664401081ca00e56c7eef12641ae792da530Tyler Gunn * {@link Connection} for valid values. 165720c664401081ca00e56c7eef12641ae792da530Tyler Gunn * 166720c664401081ca00e56c7eef12641ae792da530Tyler Gunn * @return A bitmask of the properties of the conference call. 1671bf206b766654ea9c4e9bc7a703a9d5f1d30ab72Tyler Gunn * @hide 168720c664401081ca00e56c7eef12641ae792da530Tyler Gunn */ 169720c664401081ca00e56c7eef12641ae792da530Tyler Gunn public final int getConnectionProperties() { 170720c664401081ca00e56c7eef12641ae792da530Tyler Gunn return mConnectionProperties; 171720c664401081ca00e56c7eef12641ae792da530Tyler Gunn } 172720c664401081ca00e56c7eef12641ae792da530Tyler Gunn 173720c664401081ca00e56c7eef12641ae792da530Tyler Gunn /** 1745c9c86ec0f95d1f5e1aca212967f508fc736b895Ihab Awad * Whether the given capabilities support the specified capability. 1755c9c86ec0f95d1f5e1aca212967f508fc736b895Ihab Awad * 1765c9c86ec0f95d1f5e1aca212967f508fc736b895Ihab Awad * @param capabilities A capability bit field. 1775c9c86ec0f95d1f5e1aca212967f508fc736b895Ihab Awad * @param capability The capability to check capabilities for. 1785c9c86ec0f95d1f5e1aca212967f508fc736b895Ihab Awad * @return Whether the specified capability is supported. 1795c9c86ec0f95d1f5e1aca212967f508fc736b895Ihab Awad * @hide 1805c9c86ec0f95d1f5e1aca212967f508fc736b895Ihab Awad */ 1815c9c86ec0f95d1f5e1aca212967f508fc736b895Ihab Awad public static boolean can(int capabilities, int capability) { 1825c9c86ec0f95d1f5e1aca212967f508fc736b895Ihab Awad return (capabilities & capability) != 0; 1835c9c86ec0f95d1f5e1aca212967f508fc736b895Ihab Awad } 1845c9c86ec0f95d1f5e1aca212967f508fc736b895Ihab Awad 18556fc25deec15a32ea5f37d7c8c82f16d1bf9d275Nancy Chen /** 1865c9c86ec0f95d1f5e1aca212967f508fc736b895Ihab Awad * Whether the capabilities of this {@code Connection} supports the specified capability. 18756fc25deec15a32ea5f37d7c8c82f16d1bf9d275Nancy Chen * 1885c9c86ec0f95d1f5e1aca212967f508fc736b895Ihab Awad * @param capability The capability to check capabilities for. 1895c9c86ec0f95d1f5e1aca212967f508fc736b895Ihab Awad * @return Whether the specified capability is supported. 1905c9c86ec0f95d1f5e1aca212967f508fc736b895Ihab Awad * @hide 19156fc25deec15a32ea5f37d7c8c82f16d1bf9d275Nancy Chen */ 1925c9c86ec0f95d1f5e1aca212967f508fc736b895Ihab Awad public boolean can(int capability) { 1935c9c86ec0f95d1f5e1aca212967f508fc736b895Ihab Awad return can(mConnectionCapabilities, capability); 1945c9c86ec0f95d1f5e1aca212967f508fc736b895Ihab Awad } 1955c9c86ec0f95d1f5e1aca212967f508fc736b895Ihab Awad 1965c9c86ec0f95d1f5e1aca212967f508fc736b895Ihab Awad /** 1975c9c86ec0f95d1f5e1aca212967f508fc736b895Ihab Awad * Removes the specified capability from the set of capabilities of this {@code Conference}. 1985c9c86ec0f95d1f5e1aca212967f508fc736b895Ihab Awad * 1995c9c86ec0f95d1f5e1aca212967f508fc736b895Ihab Awad * @param capability The capability to remove from the set. 2005c9c86ec0f95d1f5e1aca212967f508fc736b895Ihab Awad * @hide 2015c9c86ec0f95d1f5e1aca212967f508fc736b895Ihab Awad */ 2025c9c86ec0f95d1f5e1aca212967f508fc736b895Ihab Awad public void removeCapability(int capability) { 203a0f46a9e7d445852e1746594f0e90ea985f7d5bfOmkar Kolangade int newCapabilities = mConnectionCapabilities; 204a0f46a9e7d445852e1746594f0e90ea985f7d5bfOmkar Kolangade newCapabilities &= ~capability; 205a0f46a9e7d445852e1746594f0e90ea985f7d5bfOmkar Kolangade 206a0f46a9e7d445852e1746594f0e90ea985f7d5bfOmkar Kolangade setConnectionCapabilities(newCapabilities); 2075c9c86ec0f95d1f5e1aca212967f508fc736b895Ihab Awad } 2085c9c86ec0f95d1f5e1aca212967f508fc736b895Ihab Awad 2095c9c86ec0f95d1f5e1aca212967f508fc736b895Ihab Awad /** 2105c9c86ec0f95d1f5e1aca212967f508fc736b895Ihab Awad * Adds the specified capability to the set of capabilities of this {@code Conference}. 2115c9c86ec0f95d1f5e1aca212967f508fc736b895Ihab Awad * 2125c9c86ec0f95d1f5e1aca212967f508fc736b895Ihab Awad * @param capability The capability to add to the set. 2135c9c86ec0f95d1f5e1aca212967f508fc736b895Ihab Awad * @hide 2145c9c86ec0f95d1f5e1aca212967f508fc736b895Ihab Awad */ 2155c9c86ec0f95d1f5e1aca212967f508fc736b895Ihab Awad public void addCapability(int capability) { 216a0f46a9e7d445852e1746594f0e90ea985f7d5bfOmkar Kolangade int newCapabilities = mConnectionCapabilities; 217a0f46a9e7d445852e1746594f0e90ea985f7d5bfOmkar Kolangade newCapabilities |= capability; 218a0f46a9e7d445852e1746594f0e90ea985f7d5bfOmkar Kolangade 219a0f46a9e7d445852e1746594f0e90ea985f7d5bfOmkar Kolangade setConnectionCapabilities(newCapabilities); 220823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon } 221823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon 222823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon /** 223a0d3ca9746143d669fe9384babb9e1b9fca33dcfYorke Lee * @return The audio state of the conference, describing how its audio is currently 224a0d3ca9746143d669fe9384babb9e1b9fca33dcfYorke Lee * being routed by the system. This is {@code null} if this Conference 225a0d3ca9746143d669fe9384babb9e1b9fca33dcfYorke Lee * does not directly know about its audio state. 2264af5935c71f1e31ef1aec27661c4ef60545a0924Yorke Lee * @deprecated Use {@link #getCallAudioState()} instead. 2274af5935c71f1e31ef1aec27661c4ef60545a0924Yorke Lee * @hide 228a0d3ca9746143d669fe9384babb9e1b9fca33dcfYorke Lee */ 2294af5935c71f1e31ef1aec27661c4ef60545a0924Yorke Lee @Deprecated 2304af5935c71f1e31ef1aec27661c4ef60545a0924Yorke Lee @SystemApi 231a0d3ca9746143d669fe9384babb9e1b9fca33dcfYorke Lee public final AudioState getAudioState() { 2324af5935c71f1e31ef1aec27661c4ef60545a0924Yorke Lee return new AudioState(mCallAudioState); 2334af5935c71f1e31ef1aec27661c4ef60545a0924Yorke Lee } 2344af5935c71f1e31ef1aec27661c4ef60545a0924Yorke Lee 2354af5935c71f1e31ef1aec27661c4ef60545a0924Yorke Lee /** 2364af5935c71f1e31ef1aec27661c4ef60545a0924Yorke Lee * @return The audio state of the conference, describing how its audio is currently 2374af5935c71f1e31ef1aec27661c4ef60545a0924Yorke Lee * being routed by the system. This is {@code null} if this Conference 2384af5935c71f1e31ef1aec27661c4ef60545a0924Yorke Lee * does not directly know about its audio state. 2394af5935c71f1e31ef1aec27661c4ef60545a0924Yorke Lee */ 2404af5935c71f1e31ef1aec27661c4ef60545a0924Yorke Lee public final CallAudioState getCallAudioState() { 2414af5935c71f1e31ef1aec27661c4ef60545a0924Yorke Lee return mCallAudioState; 242a0d3ca9746143d669fe9384babb9e1b9fca33dcfYorke Lee } 243a0d3ca9746143d669fe9384babb9e1b9fca33dcfYorke Lee 244a0d3ca9746143d669fe9384babb9e1b9fca33dcfYorke Lee /** 24507366813cdf3768dcd69a1f744023747564d654aRekha Kumar * Returns VideoProvider of the primary call. This can be null. 24607366813cdf3768dcd69a1f744023747564d654aRekha Kumar */ 24707366813cdf3768dcd69a1f744023747564d654aRekha Kumar public VideoProvider getVideoProvider() { 24807366813cdf3768dcd69a1f744023747564d654aRekha Kumar return null; 24907366813cdf3768dcd69a1f744023747564d654aRekha Kumar } 25007366813cdf3768dcd69a1f744023747564d654aRekha Kumar 25107366813cdf3768dcd69a1f744023747564d654aRekha Kumar /** 25207366813cdf3768dcd69a1f744023747564d654aRekha Kumar * Returns video state of the primary call. 25307366813cdf3768dcd69a1f744023747564d654aRekha Kumar */ 25407366813cdf3768dcd69a1f744023747564d654aRekha Kumar public int getVideoState() { 25587b73f370e2b8a76b0540580f43edba6ec21c6cfTyler Gunn return VideoProfile.STATE_AUDIO_ONLY; 25607366813cdf3768dcd69a1f744023747564d654aRekha Kumar } 25707366813cdf3768dcd69a1f744023747564d654aRekha Kumar 25807366813cdf3768dcd69a1f744023747564d654aRekha Kumar /** 259823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon * Invoked when the Conference and all it's {@link Connection}s should be disconnected. 260823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon */ 261823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon public void onDisconnect() {} 262823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon 263823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon /** 264823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon * Invoked when the specified {@link Connection} should be separated from the conference call. 265823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon * 266823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon * @param connection The connection to separate. 267823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon */ 268823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon public void onSeparate(Connection connection) {} 269823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon 270823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon /** 27150e3506533478fa273cbc92c2919470d1889f1edIhab Awad * Invoked when the specified {@link Connection} should merged with the conference call. 27250e3506533478fa273cbc92c2919470d1889f1edIhab Awad * 27350e3506533478fa273cbc92c2919470d1889f1edIhab Awad * @param connection The {@code Connection} to merge. 27450e3506533478fa273cbc92c2919470d1889f1edIhab Awad */ 27550e3506533478fa273cbc92c2919470d1889f1edIhab Awad public void onMerge(Connection connection) {} 27650e3506533478fa273cbc92c2919470d1889f1edIhab Awad 27750e3506533478fa273cbc92c2919470d1889f1edIhab Awad /** 278823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon * Invoked when the conference should be put on hold. 279823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon */ 280823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon public void onHold() {} 281823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon 282823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon /** 283823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon * Invoked when the conference should be moved from hold to active. 284823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon */ 285823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon public void onUnhold() {} 286823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon 287823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon /** 288a48680427e022ab6eb73277faac6c57831ee6ff9Santos Cordon * Invoked when the child calls should be merged. Only invoked if the conference contains the 2895c9c86ec0f95d1f5e1aca212967f508fc736b895Ihab Awad * capability {@link Connection#CAPABILITY_MERGE_CONFERENCE}. 290a48680427e022ab6eb73277faac6c57831ee6ff9Santos Cordon */ 291a48680427e022ab6eb73277faac6c57831ee6ff9Santos Cordon public void onMerge() {} 292a48680427e022ab6eb73277faac6c57831ee6ff9Santos Cordon 293a48680427e022ab6eb73277faac6c57831ee6ff9Santos Cordon /** 294a48680427e022ab6eb73277faac6c57831ee6ff9Santos Cordon * Invoked when the child calls should be swapped. Only invoked if the conference contains the 2955c9c86ec0f95d1f5e1aca212967f508fc736b895Ihab Awad * capability {@link Connection#CAPABILITY_SWAP_CONFERENCE}. 296a48680427e022ab6eb73277faac6c57831ee6ff9Santos Cordon */ 297a48680427e022ab6eb73277faac6c57831ee6ff9Santos Cordon public void onSwap() {} 298a48680427e022ab6eb73277faac6c57831ee6ff9Santos Cordon 299a48680427e022ab6eb73277faac6c57831ee6ff9Santos Cordon /** 300a0d3ca9746143d669fe9384babb9e1b9fca33dcfYorke Lee * Notifies this conference of a request to play a DTMF tone. 301a0d3ca9746143d669fe9384babb9e1b9fca33dcfYorke Lee * 302a0d3ca9746143d669fe9384babb9e1b9fca33dcfYorke Lee * @param c A DTMF character. 303a0d3ca9746143d669fe9384babb9e1b9fca33dcfYorke Lee */ 304a0d3ca9746143d669fe9384babb9e1b9fca33dcfYorke Lee public void onPlayDtmfTone(char c) {} 305a0d3ca9746143d669fe9384babb9e1b9fca33dcfYorke Lee 306a0d3ca9746143d669fe9384babb9e1b9fca33dcfYorke Lee /** 307a0d3ca9746143d669fe9384babb9e1b9fca33dcfYorke Lee * Notifies this conference of a request to stop any currently playing DTMF tones. 308a0d3ca9746143d669fe9384babb9e1b9fca33dcfYorke Lee */ 309a0d3ca9746143d669fe9384babb9e1b9fca33dcfYorke Lee public void onStopDtmfTone() {} 310a0d3ca9746143d669fe9384babb9e1b9fca33dcfYorke Lee 311a0d3ca9746143d669fe9384babb9e1b9fca33dcfYorke Lee /** 312a0d3ca9746143d669fe9384babb9e1b9fca33dcfYorke Lee * Notifies this conference that the {@link #getAudioState()} property has a new value. 313a0d3ca9746143d669fe9384babb9e1b9fca33dcfYorke Lee * 314a0d3ca9746143d669fe9384babb9e1b9fca33dcfYorke Lee * @param state The new call audio state. 3154af5935c71f1e31ef1aec27661c4ef60545a0924Yorke Lee * @deprecated Use {@link #onCallAudioStateChanged(CallAudioState)} instead. 3164af5935c71f1e31ef1aec27661c4ef60545a0924Yorke Lee * @hide 317a0d3ca9746143d669fe9384babb9e1b9fca33dcfYorke Lee */ 3184af5935c71f1e31ef1aec27661c4ef60545a0924Yorke Lee @SystemApi 3194af5935c71f1e31ef1aec27661c4ef60545a0924Yorke Lee @Deprecated 320a0d3ca9746143d669fe9384babb9e1b9fca33dcfYorke Lee public void onAudioStateChanged(AudioState state) {} 321a0d3ca9746143d669fe9384babb9e1b9fca33dcfYorke Lee 322a0d3ca9746143d669fe9384babb9e1b9fca33dcfYorke Lee /** 3234af5935c71f1e31ef1aec27661c4ef60545a0924Yorke Lee * Notifies this conference that the {@link #getCallAudioState()} property has a new value. 3244af5935c71f1e31ef1aec27661c4ef60545a0924Yorke Lee * 3254af5935c71f1e31ef1aec27661c4ef60545a0924Yorke Lee * @param state The new call audio state. 3264af5935c71f1e31ef1aec27661c4ef60545a0924Yorke Lee */ 3274af5935c71f1e31ef1aec27661c4ef60545a0924Yorke Lee public void onCallAudioStateChanged(CallAudioState state) {} 3284af5935c71f1e31ef1aec27661c4ef60545a0924Yorke Lee 3294af5935c71f1e31ef1aec27661c4ef60545a0924Yorke Lee /** 33046f7f5dce42d645353a0f3eb0dbdd25b3a6c72fbAndrew Lee * Notifies this conference that a connection has been added to it. 33146f7f5dce42d645353a0f3eb0dbdd25b3a6c72fbAndrew Lee * 33246f7f5dce42d645353a0f3eb0dbdd25b3a6c72fbAndrew Lee * @param connection The newly added connection. 33346f7f5dce42d645353a0f3eb0dbdd25b3a6c72fbAndrew Lee */ 33446f7f5dce42d645353a0f3eb0dbdd25b3a6c72fbAndrew Lee public void onConnectionAdded(Connection connection) {} 33546f7f5dce42d645353a0f3eb0dbdd25b3a6c72fbAndrew Lee 33646f7f5dce42d645353a0f3eb0dbdd25b3a6c72fbAndrew Lee /** 337823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon * Sets state to be on hold. 338823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon */ 339823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon public final void setOnHold() { 340823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon setState(Connection.STATE_HOLDING); 341823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon } 342823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon 343823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon /** 344d46595a673eba0df624d9d92b6f981e3483e0d20Tyler Gunn * Sets state to be dialing. 345d46595a673eba0df624d9d92b6f981e3483e0d20Tyler Gunn */ 346d46595a673eba0df624d9d92b6f981e3483e0d20Tyler Gunn public final void setDialing() { 347d46595a673eba0df624d9d92b6f981e3483e0d20Tyler Gunn setState(Connection.STATE_DIALING); 348d46595a673eba0df624d9d92b6f981e3483e0d20Tyler Gunn } 349d46595a673eba0df624d9d92b6f981e3483e0d20Tyler Gunn 350d46595a673eba0df624d9d92b6f981e3483e0d20Tyler Gunn /** 351823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon * Sets state to be active. 352823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon */ 353823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon public final void setActive() { 354823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon setState(Connection.STATE_ACTIVE); 355823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon } 356823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon 357823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon /** 358823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon * Sets state to disconnected. 359823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon * 3607f3d41fd124dd7c4a8b72c1d48df08a8ee7209ecAndrew Lee * @param disconnectCause The reason for the disconnection, as described by 3617f3d41fd124dd7c4a8b72c1d48df08a8ee7209ecAndrew Lee * {@link android.telecom.DisconnectCause}. 362823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon */ 3637f3d41fd124dd7c4a8b72c1d48df08a8ee7209ecAndrew Lee public final void setDisconnected(DisconnectCause disconnectCause) { 3647f3d41fd124dd7c4a8b72c1d48df08a8ee7209ecAndrew Lee mDisconnectCause = disconnectCause;; 365823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon setState(Connection.STATE_DISCONNECTED); 366823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon for (Listener l : mListeners) { 3677f3d41fd124dd7c4a8b72c1d48df08a8ee7209ecAndrew Lee l.onDisconnected(this, mDisconnectCause); 368823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon } 369823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon } 370823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon 371823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon /** 3721cf14ac5dc5708fc31e6c987a5c7db465ff95533mike dooley * @return The {@link DisconnectCause} for this connection. 3731cf14ac5dc5708fc31e6c987a5c7db465ff95533mike dooley */ 3741cf14ac5dc5708fc31e6c987a5c7db465ff95533mike dooley public final DisconnectCause getDisconnectCause() { 3751cf14ac5dc5708fc31e6c987a5c7db465ff95533mike dooley return mDisconnectCause; 3761cf14ac5dc5708fc31e6c987a5c7db465ff95533mike dooley } 3771cf14ac5dc5708fc31e6c987a5c7db465ff95533mike dooley 3781cf14ac5dc5708fc31e6c987a5c7db465ff95533mike dooley /** 3795c9c86ec0f95d1f5e1aca212967f508fc736b895Ihab Awad * Sets the capabilities of a conference. See {@code CAPABILITY_*} constants of class 3805c9c86ec0f95d1f5e1aca212967f508fc736b895Ihab Awad * {@link Connection} for valid values. 38156fc25deec15a32ea5f37d7c8c82f16d1bf9d275Nancy Chen * 382720c664401081ca00e56c7eef12641ae792da530Tyler Gunn * @param connectionCapabilities A bitmask of the {@code Capabilities} of the conference call. 383823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon */ 3845c9c86ec0f95d1f5e1aca212967f508fc736b895Ihab Awad public final void setConnectionCapabilities(int connectionCapabilities) { 3855c9c86ec0f95d1f5e1aca212967f508fc736b895Ihab Awad if (connectionCapabilities != mConnectionCapabilities) { 3865c9c86ec0f95d1f5e1aca212967f508fc736b895Ihab Awad mConnectionCapabilities = connectionCapabilities; 387823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon 388823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon for (Listener l : mListeners) { 3895c9c86ec0f95d1f5e1aca212967f508fc736b895Ihab Awad l.onConnectionCapabilitiesChanged(this, mConnectionCapabilities); 390823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon } 391823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon } 392823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon } 393823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon 394823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon /** 395720c664401081ca00e56c7eef12641ae792da530Tyler Gunn * Sets the properties of a conference. See {@code PROPERTY_*} constants of class 396720c664401081ca00e56c7eef12641ae792da530Tyler Gunn * {@link Connection} for valid values. 397720c664401081ca00e56c7eef12641ae792da530Tyler Gunn * 398720c664401081ca00e56c7eef12641ae792da530Tyler Gunn * @param connectionProperties A bitmask of the {@code Properties} of the conference call. 3991bf206b766654ea9c4e9bc7a703a9d5f1d30ab72Tyler Gunn * @hide 400720c664401081ca00e56c7eef12641ae792da530Tyler Gunn */ 401720c664401081ca00e56c7eef12641ae792da530Tyler Gunn public final void setConnectionProperties(int connectionProperties) { 402720c664401081ca00e56c7eef12641ae792da530Tyler Gunn if (connectionProperties != mConnectionProperties) { 403720c664401081ca00e56c7eef12641ae792da530Tyler Gunn mConnectionProperties = connectionProperties; 404720c664401081ca00e56c7eef12641ae792da530Tyler Gunn 405720c664401081ca00e56c7eef12641ae792da530Tyler Gunn for (Listener l : mListeners) { 406720c664401081ca00e56c7eef12641ae792da530Tyler Gunn l.onConnectionPropertiesChanged(this, mConnectionProperties); 407720c664401081ca00e56c7eef12641ae792da530Tyler Gunn } 408720c664401081ca00e56c7eef12641ae792da530Tyler Gunn } 409720c664401081ca00e56c7eef12641ae792da530Tyler Gunn } 410720c664401081ca00e56c7eef12641ae792da530Tyler Gunn 411720c664401081ca00e56c7eef12641ae792da530Tyler Gunn /** 412823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon * Adds the specified connection as a child of this conference. 413823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon * 414823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon * @param connection The connection to add. 415823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon * @return True if the connection was successfully added. 416823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon */ 417a48680427e022ab6eb73277faac6c57831ee6ff9Santos Cordon public final boolean addConnection(Connection connection) { 41807366813cdf3768dcd69a1f744023747564d654aRekha Kumar Log.d(this, "Connection=%s, connection=", connection); 419823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon if (connection != null && !mChildConnections.contains(connection)) { 420823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon if (connection.setConference(this)) { 421823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon mChildConnections.add(connection); 42246f7f5dce42d645353a0f3eb0dbdd25b3a6c72fbAndrew Lee onConnectionAdded(connection); 423823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon for (Listener l : mListeners) { 424823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon l.onConnectionAdded(this, connection); 425823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon } 426823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon return true; 427823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon } 428823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon } 429823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon return false; 430823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon } 431823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon 432823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon /** 433823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon * Removes the specified connection as a child of this conference. 434823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon * 435823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon * @param connection The connection to remove. 436823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon */ 437a48680427e022ab6eb73277faac6c57831ee6ff9Santos Cordon public final void removeConnection(Connection connection) { 4380159ac0cfe20e8f85ee4150e64d91392850f8a3fSantos Cordon Log.d(this, "removing %s from %s", connection, mChildConnections); 439823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon if (connection != null && mChildConnections.remove(connection)) { 440823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon connection.resetConference(); 441823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon for (Listener l : mListeners) { 442823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon l.onConnectionRemoved(this, connection); 443823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon } 444823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon } 445823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon } 446823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon 447823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon /** 44850e3506533478fa273cbc92c2919470d1889f1edIhab Awad * Sets the connections with which this connection can be conferenced. 44950e3506533478fa273cbc92c2919470d1889f1edIhab Awad * 45050e3506533478fa273cbc92c2919470d1889f1edIhab Awad * @param conferenceableConnections The set of connections this connection can conference with. 45150e3506533478fa273cbc92c2919470d1889f1edIhab Awad */ 45250e3506533478fa273cbc92c2919470d1889f1edIhab Awad public final void setConferenceableConnections(List<Connection> conferenceableConnections) { 45350e3506533478fa273cbc92c2919470d1889f1edIhab Awad clearConferenceableList(); 45450e3506533478fa273cbc92c2919470d1889f1edIhab Awad for (Connection c : conferenceableConnections) { 45550e3506533478fa273cbc92c2919470d1889f1edIhab Awad // If statement checks for duplicates in input. It makes it N^2 but we're dealing with a 45650e3506533478fa273cbc92c2919470d1889f1edIhab Awad // small amount of items here. 45750e3506533478fa273cbc92c2919470d1889f1edIhab Awad if (!mConferenceableConnections.contains(c)) { 45850e3506533478fa273cbc92c2919470d1889f1edIhab Awad c.addConnectionListener(mConnectionDeathListener); 45950e3506533478fa273cbc92c2919470d1889f1edIhab Awad mConferenceableConnections.add(c); 46050e3506533478fa273cbc92c2919470d1889f1edIhab Awad } 46150e3506533478fa273cbc92c2919470d1889f1edIhab Awad } 46250e3506533478fa273cbc92c2919470d1889f1edIhab Awad fireOnConferenceableConnectionsChanged(); 46350e3506533478fa273cbc92c2919470d1889f1edIhab Awad } 46450e3506533478fa273cbc92c2919470d1889f1edIhab Awad 46507366813cdf3768dcd69a1f744023747564d654aRekha Kumar /** 46607366813cdf3768dcd69a1f744023747564d654aRekha Kumar * Set the video state for the conference. 46732f24731604fd81289a39619bbc925b65184b505Yorke Lee * Valid values: {@link VideoProfile#STATE_AUDIO_ONLY}, 46832f24731604fd81289a39619bbc925b65184b505Yorke Lee * {@link VideoProfile#STATE_BIDIRECTIONAL}, 46932f24731604fd81289a39619bbc925b65184b505Yorke Lee * {@link VideoProfile#STATE_TX_ENABLED}, 47032f24731604fd81289a39619bbc925b65184b505Yorke Lee * {@link VideoProfile#STATE_RX_ENABLED}. 47107366813cdf3768dcd69a1f744023747564d654aRekha Kumar * 47207366813cdf3768dcd69a1f744023747564d654aRekha Kumar * @param videoState The new video state. 47307366813cdf3768dcd69a1f744023747564d654aRekha Kumar */ 47407366813cdf3768dcd69a1f744023747564d654aRekha Kumar public final void setVideoState(Connection c, int videoState) { 47507366813cdf3768dcd69a1f744023747564d654aRekha Kumar Log.d(this, "setVideoState Conference: %s Connection: %s VideoState: %s", 47607366813cdf3768dcd69a1f744023747564d654aRekha Kumar this, c, videoState); 47707366813cdf3768dcd69a1f744023747564d654aRekha Kumar for (Listener l : mListeners) { 47807366813cdf3768dcd69a1f744023747564d654aRekha Kumar l.onVideoStateChanged(this, videoState); 47907366813cdf3768dcd69a1f744023747564d654aRekha Kumar } 48007366813cdf3768dcd69a1f744023747564d654aRekha Kumar } 48107366813cdf3768dcd69a1f744023747564d654aRekha Kumar 48207366813cdf3768dcd69a1f744023747564d654aRekha Kumar /** 48307366813cdf3768dcd69a1f744023747564d654aRekha Kumar * Sets the video connection provider. 48407366813cdf3768dcd69a1f744023747564d654aRekha Kumar * 48507366813cdf3768dcd69a1f744023747564d654aRekha Kumar * @param videoProvider The video provider. 48607366813cdf3768dcd69a1f744023747564d654aRekha Kumar */ 48707366813cdf3768dcd69a1f744023747564d654aRekha Kumar public final void setVideoProvider(Connection c, Connection.VideoProvider videoProvider) { 48807366813cdf3768dcd69a1f744023747564d654aRekha Kumar Log.d(this, "setVideoProvider Conference: %s Connection: %s VideoState: %s", 48907366813cdf3768dcd69a1f744023747564d654aRekha Kumar this, c, videoProvider); 49007366813cdf3768dcd69a1f744023747564d654aRekha Kumar for (Listener l : mListeners) { 49107366813cdf3768dcd69a1f744023747564d654aRekha Kumar l.onVideoProviderChanged(this, videoProvider); 49207366813cdf3768dcd69a1f744023747564d654aRekha Kumar } 49307366813cdf3768dcd69a1f744023747564d654aRekha Kumar } 49407366813cdf3768dcd69a1f744023747564d654aRekha Kumar 49550e3506533478fa273cbc92c2919470d1889f1edIhab Awad private final void fireOnConferenceableConnectionsChanged() { 49650e3506533478fa273cbc92c2919470d1889f1edIhab Awad for (Listener l : mListeners) { 49750e3506533478fa273cbc92c2919470d1889f1edIhab Awad l.onConferenceableConnectionsChanged(this, getConferenceableConnections()); 49850e3506533478fa273cbc92c2919470d1889f1edIhab Awad } 49950e3506533478fa273cbc92c2919470d1889f1edIhab Awad } 50050e3506533478fa273cbc92c2919470d1889f1edIhab Awad 50150e3506533478fa273cbc92c2919470d1889f1edIhab Awad /** 50250e3506533478fa273cbc92c2919470d1889f1edIhab Awad * Returns the connections with which this connection can be conferenced. 50350e3506533478fa273cbc92c2919470d1889f1edIhab Awad */ 50450e3506533478fa273cbc92c2919470d1889f1edIhab Awad public final List<Connection> getConferenceableConnections() { 50550e3506533478fa273cbc92c2919470d1889f1edIhab Awad return mUnmodifiableConferenceableConnections; 50650e3506533478fa273cbc92c2919470d1889f1edIhab Awad } 50750e3506533478fa273cbc92c2919470d1889f1edIhab Awad 50850e3506533478fa273cbc92c2919470d1889f1edIhab Awad /** 509ea38cca14964a5ee658899b0bafbc48017d556cdNancy Chen * Tears down the conference object and any of its current connections. 510823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon */ 511a48680427e022ab6eb73277faac6c57831ee6ff9Santos Cordon public final void destroy() { 512823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon Log.d(this, "destroying conference : %s", this); 513823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon // Tear down the children. 5140159ac0cfe20e8f85ee4150e64d91392850f8a3fSantos Cordon for (Connection connection : mChildConnections) { 515823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon Log.d(this, "removing connection %s", connection); 516823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon removeConnection(connection); 517823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon } 518823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon 519823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon // If not yet disconnected, set the conference call as disconnected first. 520823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon if (mState != Connection.STATE_DISCONNECTED) { 521823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon Log.d(this, "setting to disconnected"); 5227f3d41fd124dd7c4a8b72c1d48df08a8ee7209ecAndrew Lee setDisconnected(new DisconnectCause(DisconnectCause.LOCAL)); 523823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon } 524823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon 525823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon // ...and notify. 526823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon for (Listener l : mListeners) { 527823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon l.onDestroyed(this); 528823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon } 529823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon } 530823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon 531823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon /** 532823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon * Add a listener to be notified of a state change. 533823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon * 534823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon * @param listener The new listener. 535823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon * @return This conference. 536823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon * @hide 537823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon */ 538823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon public final Conference addListener(Listener listener) { 539823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon mListeners.add(listener); 540823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon return this; 541823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon } 542823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon 543823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon /** 544823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon * Removes the specified listener. 545823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon * 546823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon * @param listener The listener to remove. 547823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon * @return This conference. 548823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon * @hide 549823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon */ 550823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon public final Conference removeListener(Listener listener) { 551823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon mListeners.remove(listener); 552823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon return this; 553823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon } 554823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon 555a0d3ca9746143d669fe9384babb9e1b9fca33dcfYorke Lee /** 5564a57b9b59b74c97e559a301af0add13cd4c3331cTyler Gunn * Retrieves the primary connection associated with the conference. The primary connection is 5574a57b9b59b74c97e559a301af0add13cd4c3331cTyler Gunn * the connection from which the conference will retrieve its current state. 5584a57b9b59b74c97e559a301af0add13cd4c3331cTyler Gunn * 5594a57b9b59b74c97e559a301af0add13cd4c3331cTyler Gunn * @return The primary connection. 5605d2e4f20fee033a22fbadffb291c4e47f35b7633Santos Cordon * @hide 5614a57b9b59b74c97e559a301af0add13cd4c3331cTyler Gunn */ 5625d2e4f20fee033a22fbadffb291c4e47f35b7633Santos Cordon @SystemApi 5634055d648993c35be19487f7ab82e337197e25297Santos Cordon public Connection getPrimaryConnection() { 5644a57b9b59b74c97e559a301af0add13cd4c3331cTyler Gunn if (mUnmodifiableChildConnections == null || mUnmodifiableChildConnections.isEmpty()) { 5654a57b9b59b74c97e559a301af0add13cd4c3331cTyler Gunn return null; 5664a57b9b59b74c97e559a301af0add13cd4c3331cTyler Gunn } 5674a57b9b59b74c97e559a301af0add13cd4c3331cTyler Gunn return mUnmodifiableChildConnections.get(0); 5684a57b9b59b74c97e559a301af0add13cd4c3331cTyler Gunn } 5694a57b9b59b74c97e559a301af0add13cd4c3331cTyler Gunn 5704a57b9b59b74c97e559a301af0add13cd4c3331cTyler Gunn /** 5715d2e4f20fee033a22fbadffb291c4e47f35b7633Santos Cordon * @hide 5725d2e4f20fee033a22fbadffb291c4e47f35b7633Santos Cordon * @deprecated Use {@link #setConnectionTime}. 5735d2e4f20fee033a22fbadffb291c4e47f35b7633Santos Cordon */ 5745d2e4f20fee033a22fbadffb291c4e47f35b7633Santos Cordon @Deprecated 5755d2e4f20fee033a22fbadffb291c4e47f35b7633Santos Cordon @SystemApi 5765d2e4f20fee033a22fbadffb291c4e47f35b7633Santos Cordon public final void setConnectTimeMillis(long connectTimeMillis) { 5775d2e4f20fee033a22fbadffb291c4e47f35b7633Santos Cordon setConnectionTime(connectTimeMillis); 5785d2e4f20fee033a22fbadffb291c4e47f35b7633Santos Cordon } 5795d2e4f20fee033a22fbadffb291c4e47f35b7633Santos Cordon 5805d2e4f20fee033a22fbadffb291c4e47f35b7633Santos Cordon /** 5815d2e4f20fee033a22fbadffb291c4e47f35b7633Santos Cordon * Sets the connection start time of the {@code Conference}. 582cd5d33c89f25b3bfe8989d55f05702d0970c13b4Tyler Gunn * 5835d2e4f20fee033a22fbadffb291c4e47f35b7633Santos Cordon * @param connectionTimeMillis The connection time, in milliseconds. 584cd5d33c89f25b3bfe8989d55f05702d0970c13b4Tyler Gunn */ 5855d2e4f20fee033a22fbadffb291c4e47f35b7633Santos Cordon public final void setConnectionTime(long connectionTimeMillis) { 5865d2e4f20fee033a22fbadffb291c4e47f35b7633Santos Cordon mConnectTimeMillis = connectionTimeMillis; 587cd5d33c89f25b3bfe8989d55f05702d0970c13b4Tyler Gunn } 588cd5d33c89f25b3bfe8989d55f05702d0970c13b4Tyler Gunn 589cd5d33c89f25b3bfe8989d55f05702d0970c13b4Tyler Gunn /** 5905d2e4f20fee033a22fbadffb291c4e47f35b7633Santos Cordon * @hide 5915d2e4f20fee033a22fbadffb291c4e47f35b7633Santos Cordon * @deprecated Use {@link #getConnectionTime}. 5925d2e4f20fee033a22fbadffb291c4e47f35b7633Santos Cordon */ 5935d2e4f20fee033a22fbadffb291c4e47f35b7633Santos Cordon @Deprecated 5945d2e4f20fee033a22fbadffb291c4e47f35b7633Santos Cordon @SystemApi 5955d2e4f20fee033a22fbadffb291c4e47f35b7633Santos Cordon public final long getConnectTimeMillis() { 5965d2e4f20fee033a22fbadffb291c4e47f35b7633Santos Cordon return getConnectionTime(); 5975d2e4f20fee033a22fbadffb291c4e47f35b7633Santos Cordon } 5985d2e4f20fee033a22fbadffb291c4e47f35b7633Santos Cordon 5995d2e4f20fee033a22fbadffb291c4e47f35b7633Santos Cordon /** 6005d2e4f20fee033a22fbadffb291c4e47f35b7633Santos Cordon * Retrieves the connection start time of the {@code Conference}, if specified. A value of 601cd5d33c89f25b3bfe8989d55f05702d0970c13b4Tyler Gunn * {@link #CONNECT_TIME_NOT_SPECIFIED} indicates that Telecom should determine the start time 602cd5d33c89f25b3bfe8989d55f05702d0970c13b4Tyler Gunn * of the conference. 603cd5d33c89f25b3bfe8989d55f05702d0970c13b4Tyler Gunn * 6045d2e4f20fee033a22fbadffb291c4e47f35b7633Santos Cordon * @return The time at which the {@code Conference} was connected. 605cd5d33c89f25b3bfe8989d55f05702d0970c13b4Tyler Gunn */ 6065d2e4f20fee033a22fbadffb291c4e47f35b7633Santos Cordon public final long getConnectionTime() { 607cd5d33c89f25b3bfe8989d55f05702d0970c13b4Tyler Gunn return mConnectTimeMillis; 608cd5d33c89f25b3bfe8989d55f05702d0970c13b4Tyler Gunn } 609cd5d33c89f25b3bfe8989d55f05702d0970c13b4Tyler Gunn 610cd5d33c89f25b3bfe8989d55f05702d0970c13b4Tyler Gunn /** 611a0d3ca9746143d669fe9384babb9e1b9fca33dcfYorke Lee * Inform this Conference that the state of its audio output has been changed externally. 612a0d3ca9746143d669fe9384babb9e1b9fca33dcfYorke Lee * 613a0d3ca9746143d669fe9384babb9e1b9fca33dcfYorke Lee * @param state The new audio state. 614a0d3ca9746143d669fe9384babb9e1b9fca33dcfYorke Lee * @hide 615a0d3ca9746143d669fe9384babb9e1b9fca33dcfYorke Lee */ 6164af5935c71f1e31ef1aec27661c4ef60545a0924Yorke Lee final void setCallAudioState(CallAudioState state) { 6174af5935c71f1e31ef1aec27661c4ef60545a0924Yorke Lee Log.d(this, "setCallAudioState %s", state); 6184af5935c71f1e31ef1aec27661c4ef60545a0924Yorke Lee mCallAudioState = state; 6194af5935c71f1e31ef1aec27661c4ef60545a0924Yorke Lee onAudioStateChanged(getAudioState()); 6204af5935c71f1e31ef1aec27661c4ef60545a0924Yorke Lee onCallAudioStateChanged(state); 621a0d3ca9746143d669fe9384babb9e1b9fca33dcfYorke Lee } 622a0d3ca9746143d669fe9384babb9e1b9fca33dcfYorke Lee 623823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon private void setState(int newState) { 624823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon if (newState != Connection.STATE_ACTIVE && 625823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon newState != Connection.STATE_HOLDING && 626823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon newState != Connection.STATE_DISCONNECTED) { 627823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon Log.w(this, "Unsupported state transition for Conference call.", 628823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon Connection.stateToString(newState)); 629823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon return; 630823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon } 631823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon 632823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon if (mState != newState) { 633823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon int oldState = mState; 634823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon mState = newState; 635823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon for (Listener l : mListeners) { 636823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon l.onStateChanged(this, oldState, newState); 637823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon } 638823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon } 639823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon } 64050e3506533478fa273cbc92c2919470d1889f1edIhab Awad 64150e3506533478fa273cbc92c2919470d1889f1edIhab Awad private final void clearConferenceableList() { 64250e3506533478fa273cbc92c2919470d1889f1edIhab Awad for (Connection c : mConferenceableConnections) { 64350e3506533478fa273cbc92c2919470d1889f1edIhab Awad c.removeConnectionListener(mConnectionDeathListener); 64450e3506533478fa273cbc92c2919470d1889f1edIhab Awad } 64550e3506533478fa273cbc92c2919470d1889f1edIhab Awad mConferenceableConnections.clear(); 64650e3506533478fa273cbc92c2919470d1889f1edIhab Awad } 64707366813cdf3768dcd69a1f744023747564d654aRekha Kumar 64807366813cdf3768dcd69a1f744023747564d654aRekha Kumar @Override 64907366813cdf3768dcd69a1f744023747564d654aRekha Kumar public String toString() { 65007366813cdf3768dcd69a1f744023747564d654aRekha Kumar return String.format(Locale.US, 65107366813cdf3768dcd69a1f744023747564d654aRekha Kumar "[State: %s,Capabilites: %s, VideoState: %s, VideoProvider: %s, ThisObject %s]", 65207366813cdf3768dcd69a1f744023747564d654aRekha Kumar Connection.stateToString(mState), 65307366813cdf3768dcd69a1f744023747564d654aRekha Kumar Call.Details.capabilitiesToString(mConnectionCapabilities), 65407366813cdf3768dcd69a1f744023747564d654aRekha Kumar getVideoState(), 65507366813cdf3768dcd69a1f744023747564d654aRekha Kumar getVideoProvider(), 65607366813cdf3768dcd69a1f744023747564d654aRekha Kumar super.toString()); 65707366813cdf3768dcd69a1f744023747564d654aRekha Kumar } 6580f51da328d11f8709d99890a61d6b4021a2207a5Andrew Lee 659edc625f52e5db5d0cb3d60387218f8f8365167f7Andrew Lee /** 660edc625f52e5db5d0cb3d60387218f8f8365167f7Andrew Lee * Sets the label and icon status to display in the InCall UI. 661edc625f52e5db5d0cb3d60387218f8f8365167f7Andrew Lee * 662edc625f52e5db5d0cb3d60387218f8f8365167f7Andrew Lee * @param statusHints The status label and icon to set. 663edc625f52e5db5d0cb3d60387218f8f8365167f7Andrew Lee */ 664edc625f52e5db5d0cb3d60387218f8f8365167f7Andrew Lee public final void setStatusHints(StatusHints statusHints) { 665edc625f52e5db5d0cb3d60387218f8f8365167f7Andrew Lee mStatusHints = statusHints; 666edc625f52e5db5d0cb3d60387218f8f8365167f7Andrew Lee for (Listener l : mListeners) { 667edc625f52e5db5d0cb3d60387218f8f8365167f7Andrew Lee l.onStatusHintsChanged(this, statusHints); 668edc625f52e5db5d0cb3d60387218f8f8365167f7Andrew Lee } 669edc625f52e5db5d0cb3d60387218f8f8365167f7Andrew Lee } 670edc625f52e5db5d0cb3d60387218f8f8365167f7Andrew Lee 671edc625f52e5db5d0cb3d60387218f8f8365167f7Andrew Lee /** 672edc625f52e5db5d0cb3d60387218f8f8365167f7Andrew Lee * @return The status hints for this conference. 673edc625f52e5db5d0cb3d60387218f8f8365167f7Andrew Lee */ 674edc625f52e5db5d0cb3d60387218f8f8365167f7Andrew Lee public final StatusHints getStatusHints() { 675edc625f52e5db5d0cb3d60387218f8f8365167f7Andrew Lee return mStatusHints; 676edc625f52e5db5d0cb3d60387218f8f8365167f7Andrew Lee } 6776b7f955c2d9b231660b8c54f8ef8e8e6ad802625Santos Cordon 6786b7f955c2d9b231660b8c54f8ef8e8e6ad802625Santos Cordon /** 679dee56a8a79f9daa1e597f5d4f399d3a5feedcac4Tyler Gunn * Replaces all the extras associated with this {@code Conference}. 680dee56a8a79f9daa1e597f5d4f399d3a5feedcac4Tyler Gunn * <p> 681dee56a8a79f9daa1e597f5d4f399d3a5feedcac4Tyler Gunn * New or existing keys are replaced in the {@code Conference} extras. Keys which are no longer 682dee56a8a79f9daa1e597f5d4f399d3a5feedcac4Tyler Gunn * in the new extras, but were present the last time {@code setExtras} was called are removed. 683dee56a8a79f9daa1e597f5d4f399d3a5feedcac4Tyler Gunn * <p> 684dee56a8a79f9daa1e597f5d4f399d3a5feedcac4Tyler Gunn * No assumptions should be made as to how an In-Call UI or service will handle these extras. 6856b7f955c2d9b231660b8c54f8ef8e8e6ad802625Santos Cordon * Keys should be fully qualified (e.g., com.example.MY_EXTRA) to avoid conflicts. 6866b7f955c2d9b231660b8c54f8ef8e8e6ad802625Santos Cordon * 687dee56a8a79f9daa1e597f5d4f399d3a5feedcac4Tyler Gunn * @param extras The extras associated with this {@code Conference}. 6886b7f955c2d9b231660b8c54f8ef8e8e6ad802625Santos Cordon */ 6896b7f955c2d9b231660b8c54f8ef8e8e6ad802625Santos Cordon public final void setExtras(@Nullable Bundle extras) { 6904fa6a01898be85999e12b62bb52debb838e1bd0cBrad Ebinger // Keeping putExtras and removeExtras in the same lock so that this operation happens as a 6914fa6a01898be85999e12b62bb52debb838e1bd0cBrad Ebinger // block instead of letting other threads put/remove while this method is running. 6924fa6a01898be85999e12b62bb52debb838e1bd0cBrad Ebinger synchronized (mExtrasLock) { 6934fa6a01898be85999e12b62bb52debb838e1bd0cBrad Ebinger // Add/replace any new or changed extras values. 6944fa6a01898be85999e12b62bb52debb838e1bd0cBrad Ebinger putExtras(extras); 6954fa6a01898be85999e12b62bb52debb838e1bd0cBrad Ebinger // If we have used "setExtras" in the past, compare the key set from the last invocation 6964fa6a01898be85999e12b62bb52debb838e1bd0cBrad Ebinger // to the current one and remove any keys that went away. 6974fa6a01898be85999e12b62bb52debb838e1bd0cBrad Ebinger if (mPreviousExtraKeys != null) { 6984fa6a01898be85999e12b62bb52debb838e1bd0cBrad Ebinger List<String> toRemove = new ArrayList<String>(); 6994fa6a01898be85999e12b62bb52debb838e1bd0cBrad Ebinger for (String oldKey : mPreviousExtraKeys) { 7004fa6a01898be85999e12b62bb52debb838e1bd0cBrad Ebinger if (extras == null || !extras.containsKey(oldKey)) { 7014fa6a01898be85999e12b62bb52debb838e1bd0cBrad Ebinger toRemove.add(oldKey); 7024fa6a01898be85999e12b62bb52debb838e1bd0cBrad Ebinger } 703dee56a8a79f9daa1e597f5d4f399d3a5feedcac4Tyler Gunn } 704dee56a8a79f9daa1e597f5d4f399d3a5feedcac4Tyler Gunn 7054fa6a01898be85999e12b62bb52debb838e1bd0cBrad Ebinger if (!toRemove.isEmpty()) { 7064fa6a01898be85999e12b62bb52debb838e1bd0cBrad Ebinger removeExtras(toRemove); 7074fa6a01898be85999e12b62bb52debb838e1bd0cBrad Ebinger } 708dee56a8a79f9daa1e597f5d4f399d3a5feedcac4Tyler Gunn } 709dee56a8a79f9daa1e597f5d4f399d3a5feedcac4Tyler Gunn 7104fa6a01898be85999e12b62bb52debb838e1bd0cBrad Ebinger // Track the keys the last time set called setExtras. This way, the next time setExtras 7114fa6a01898be85999e12b62bb52debb838e1bd0cBrad Ebinger // is called we can see if the caller has removed any extras values. 7124fa6a01898be85999e12b62bb52debb838e1bd0cBrad Ebinger if (mPreviousExtraKeys == null) { 7134fa6a01898be85999e12b62bb52debb838e1bd0cBrad Ebinger mPreviousExtraKeys = new ArraySet<String>(); 7144fa6a01898be85999e12b62bb52debb838e1bd0cBrad Ebinger } 7154fa6a01898be85999e12b62bb52debb838e1bd0cBrad Ebinger mPreviousExtraKeys.clear(); 7164fa6a01898be85999e12b62bb52debb838e1bd0cBrad Ebinger if (extras != null) { 7174fa6a01898be85999e12b62bb52debb838e1bd0cBrad Ebinger mPreviousExtraKeys.addAll(extras.keySet()); 7184fa6a01898be85999e12b62bb52debb838e1bd0cBrad Ebinger } 719a8fb8aba7ce464a9d42f4e4ac42f76aa90d050e9Tyler Gunn } 720dee56a8a79f9daa1e597f5d4f399d3a5feedcac4Tyler Gunn } 721dee56a8a79f9daa1e597f5d4f399d3a5feedcac4Tyler Gunn 722dee56a8a79f9daa1e597f5d4f399d3a5feedcac4Tyler Gunn /** 723dee56a8a79f9daa1e597f5d4f399d3a5feedcac4Tyler Gunn * Adds some extras to this {@link Conference}. Existing keys are replaced and new ones are 724dee56a8a79f9daa1e597f5d4f399d3a5feedcac4Tyler Gunn * added. 725dee56a8a79f9daa1e597f5d4f399d3a5feedcac4Tyler Gunn * <p> 726dee56a8a79f9daa1e597f5d4f399d3a5feedcac4Tyler Gunn * No assumptions should be made as to how an In-Call UI or service will handle these extras. 727dee56a8a79f9daa1e597f5d4f399d3a5feedcac4Tyler Gunn * Keys should be fully qualified (e.g., com.example.MY_EXTRA) to avoid conflicts. 728dee56a8a79f9daa1e597f5d4f399d3a5feedcac4Tyler Gunn * 729dee56a8a79f9daa1e597f5d4f399d3a5feedcac4Tyler Gunn * @param extras The extras to add. 7301bf206b766654ea9c4e9bc7a703a9d5f1d30ab72Tyler Gunn * @hide 731dee56a8a79f9daa1e597f5d4f399d3a5feedcac4Tyler Gunn */ 732dee56a8a79f9daa1e597f5d4f399d3a5feedcac4Tyler Gunn public final void putExtras(@NonNull Bundle extras) { 733dee56a8a79f9daa1e597f5d4f399d3a5feedcac4Tyler Gunn if (extras == null) { 734dee56a8a79f9daa1e597f5d4f399d3a5feedcac4Tyler Gunn return; 735dee56a8a79f9daa1e597f5d4f399d3a5feedcac4Tyler Gunn } 736dee56a8a79f9daa1e597f5d4f399d3a5feedcac4Tyler Gunn 7374fa6a01898be85999e12b62bb52debb838e1bd0cBrad Ebinger // Creating a Bundle clone so we don't have to synchronize on mExtrasLock while calling 7384fa6a01898be85999e12b62bb52debb838e1bd0cBrad Ebinger // onExtrasChanged. 7394fa6a01898be85999e12b62bb52debb838e1bd0cBrad Ebinger Bundle listenersBundle; 7404fa6a01898be85999e12b62bb52debb838e1bd0cBrad Ebinger synchronized (mExtrasLock) { 7414fa6a01898be85999e12b62bb52debb838e1bd0cBrad Ebinger if (mExtras == null) { 7424fa6a01898be85999e12b62bb52debb838e1bd0cBrad Ebinger mExtras = new Bundle(); 7434fa6a01898be85999e12b62bb52debb838e1bd0cBrad Ebinger } 7444fa6a01898be85999e12b62bb52debb838e1bd0cBrad Ebinger mExtras.putAll(extras); 7454fa6a01898be85999e12b62bb52debb838e1bd0cBrad Ebinger listenersBundle = new Bundle(mExtras); 746dee56a8a79f9daa1e597f5d4f399d3a5feedcac4Tyler Gunn } 747dee56a8a79f9daa1e597f5d4f399d3a5feedcac4Tyler Gunn 7486b7f955c2d9b231660b8c54f8ef8e8e6ad802625Santos Cordon for (Listener l : mListeners) { 7494fa6a01898be85999e12b62bb52debb838e1bd0cBrad Ebinger l.onExtrasChanged(this, new Bundle(listenersBundle)); 7506b7f955c2d9b231660b8c54f8ef8e8e6ad802625Santos Cordon } 7516b7f955c2d9b231660b8c54f8ef8e8e6ad802625Santos Cordon } 7526b7f955c2d9b231660b8c54f8ef8e8e6ad802625Santos Cordon 7536b7f955c2d9b231660b8c54f8ef8e8e6ad802625Santos Cordon /** 754dee56a8a79f9daa1e597f5d4f399d3a5feedcac4Tyler Gunn * Adds a boolean extra to this {@link Conference}. 755dee56a8a79f9daa1e597f5d4f399d3a5feedcac4Tyler Gunn * 756dee56a8a79f9daa1e597f5d4f399d3a5feedcac4Tyler Gunn * @param key The extra key. 757dee56a8a79f9daa1e597f5d4f399d3a5feedcac4Tyler Gunn * @param value The value. 758dee56a8a79f9daa1e597f5d4f399d3a5feedcac4Tyler Gunn * @hide 759dee56a8a79f9daa1e597f5d4f399d3a5feedcac4Tyler Gunn */ 760dee56a8a79f9daa1e597f5d4f399d3a5feedcac4Tyler Gunn public final void putExtra(String key, boolean value) { 761dee56a8a79f9daa1e597f5d4f399d3a5feedcac4Tyler Gunn Bundle newExtras = new Bundle(); 762dee56a8a79f9daa1e597f5d4f399d3a5feedcac4Tyler Gunn newExtras.putBoolean(key, value); 763dee56a8a79f9daa1e597f5d4f399d3a5feedcac4Tyler Gunn putExtras(newExtras); 764dee56a8a79f9daa1e597f5d4f399d3a5feedcac4Tyler Gunn } 765dee56a8a79f9daa1e597f5d4f399d3a5feedcac4Tyler Gunn 766dee56a8a79f9daa1e597f5d4f399d3a5feedcac4Tyler Gunn /** 767dee56a8a79f9daa1e597f5d4f399d3a5feedcac4Tyler Gunn * Adds an integer extra to this {@link Conference}. 768dee56a8a79f9daa1e597f5d4f399d3a5feedcac4Tyler Gunn * 769dee56a8a79f9daa1e597f5d4f399d3a5feedcac4Tyler Gunn * @param key The extra key. 770dee56a8a79f9daa1e597f5d4f399d3a5feedcac4Tyler Gunn * @param value The value. 771dee56a8a79f9daa1e597f5d4f399d3a5feedcac4Tyler Gunn * @hide 772dee56a8a79f9daa1e597f5d4f399d3a5feedcac4Tyler Gunn */ 773dee56a8a79f9daa1e597f5d4f399d3a5feedcac4Tyler Gunn public final void putExtra(String key, int value) { 774dee56a8a79f9daa1e597f5d4f399d3a5feedcac4Tyler Gunn Bundle newExtras = new Bundle(); 775dee56a8a79f9daa1e597f5d4f399d3a5feedcac4Tyler Gunn newExtras.putInt(key, value); 776dee56a8a79f9daa1e597f5d4f399d3a5feedcac4Tyler Gunn putExtras(newExtras); 777dee56a8a79f9daa1e597f5d4f399d3a5feedcac4Tyler Gunn } 778dee56a8a79f9daa1e597f5d4f399d3a5feedcac4Tyler Gunn 779dee56a8a79f9daa1e597f5d4f399d3a5feedcac4Tyler Gunn /** 780dee56a8a79f9daa1e597f5d4f399d3a5feedcac4Tyler Gunn * Adds a string extra to this {@link Conference}. 781dee56a8a79f9daa1e597f5d4f399d3a5feedcac4Tyler Gunn * 782dee56a8a79f9daa1e597f5d4f399d3a5feedcac4Tyler Gunn * @param key The extra key. 783dee56a8a79f9daa1e597f5d4f399d3a5feedcac4Tyler Gunn * @param value The value. 784dee56a8a79f9daa1e597f5d4f399d3a5feedcac4Tyler Gunn * @hide 785dee56a8a79f9daa1e597f5d4f399d3a5feedcac4Tyler Gunn */ 786dee56a8a79f9daa1e597f5d4f399d3a5feedcac4Tyler Gunn public final void putExtra(String key, String value) { 787dee56a8a79f9daa1e597f5d4f399d3a5feedcac4Tyler Gunn Bundle newExtras = new Bundle(); 788dee56a8a79f9daa1e597f5d4f399d3a5feedcac4Tyler Gunn newExtras.putString(key, value); 789dee56a8a79f9daa1e597f5d4f399d3a5feedcac4Tyler Gunn putExtras(newExtras); 790dee56a8a79f9daa1e597f5d4f399d3a5feedcac4Tyler Gunn } 791dee56a8a79f9daa1e597f5d4f399d3a5feedcac4Tyler Gunn 792dee56a8a79f9daa1e597f5d4f399d3a5feedcac4Tyler Gunn /** 793dee56a8a79f9daa1e597f5d4f399d3a5feedcac4Tyler Gunn * Removes an extra from this {@link Conference}. 794dee56a8a79f9daa1e597f5d4f399d3a5feedcac4Tyler Gunn * 795dee56a8a79f9daa1e597f5d4f399d3a5feedcac4Tyler Gunn * @param keys The key of the extra key to remove. 7961bf206b766654ea9c4e9bc7a703a9d5f1d30ab72Tyler Gunn * @hide 797dee56a8a79f9daa1e597f5d4f399d3a5feedcac4Tyler Gunn */ 798dee56a8a79f9daa1e597f5d4f399d3a5feedcac4Tyler Gunn public final void removeExtras(List<String> keys) { 799dee56a8a79f9daa1e597f5d4f399d3a5feedcac4Tyler Gunn if (keys == null || keys.isEmpty()) { 800dee56a8a79f9daa1e597f5d4f399d3a5feedcac4Tyler Gunn return; 801dee56a8a79f9daa1e597f5d4f399d3a5feedcac4Tyler Gunn } 802dee56a8a79f9daa1e597f5d4f399d3a5feedcac4Tyler Gunn 8034fa6a01898be85999e12b62bb52debb838e1bd0cBrad Ebinger synchronized (mExtrasLock) { 8044fa6a01898be85999e12b62bb52debb838e1bd0cBrad Ebinger if (mExtras != null) { 8054fa6a01898be85999e12b62bb52debb838e1bd0cBrad Ebinger for (String key : keys) { 8064fa6a01898be85999e12b62bb52debb838e1bd0cBrad Ebinger mExtras.remove(key); 8074fa6a01898be85999e12b62bb52debb838e1bd0cBrad Ebinger } 808dee56a8a79f9daa1e597f5d4f399d3a5feedcac4Tyler Gunn } 809dee56a8a79f9daa1e597f5d4f399d3a5feedcac4Tyler Gunn } 810dee56a8a79f9daa1e597f5d4f399d3a5feedcac4Tyler Gunn 8114fa6a01898be85999e12b62bb52debb838e1bd0cBrad Ebinger List<String> unmodifiableKeys = Collections.unmodifiableList(keys); 812dee56a8a79f9daa1e597f5d4f399d3a5feedcac4Tyler Gunn for (Listener l : mListeners) { 8134fa6a01898be85999e12b62bb52debb838e1bd0cBrad Ebinger l.onExtrasRemoved(this, unmodifiableKeys); 814dee56a8a79f9daa1e597f5d4f399d3a5feedcac4Tyler Gunn } 815dee56a8a79f9daa1e597f5d4f399d3a5feedcac4Tyler Gunn } 816dee56a8a79f9daa1e597f5d4f399d3a5feedcac4Tyler Gunn 817dee56a8a79f9daa1e597f5d4f399d3a5feedcac4Tyler Gunn /** 818dee56a8a79f9daa1e597f5d4f399d3a5feedcac4Tyler Gunn * Returns the extras associated with this conference. 819dee56a8a79f9daa1e597f5d4f399d3a5feedcac4Tyler Gunn * 820dee56a8a79f9daa1e597f5d4f399d3a5feedcac4Tyler Gunn * @return The extras associated with this connection. 8216b7f955c2d9b231660b8c54f8ef8e8e6ad802625Santos Cordon */ 8226b7f955c2d9b231660b8c54f8ef8e8e6ad802625Santos Cordon public final Bundle getExtras() { 8236b7f955c2d9b231660b8c54f8ef8e8e6ad802625Santos Cordon return mExtras; 8246b7f955c2d9b231660b8c54f8ef8e8e6ad802625Santos Cordon } 825dee56a8a79f9daa1e597f5d4f399d3a5feedcac4Tyler Gunn 826dee56a8a79f9daa1e597f5d4f399d3a5feedcac4Tyler Gunn /** 827dee56a8a79f9daa1e597f5d4f399d3a5feedcac4Tyler Gunn * Notifies this {@link Conference} of a change to the extras made outside the 828dee56a8a79f9daa1e597f5d4f399d3a5feedcac4Tyler Gunn * {@link ConnectionService}. 829dee56a8a79f9daa1e597f5d4f399d3a5feedcac4Tyler Gunn * <p> 830dee56a8a79f9daa1e597f5d4f399d3a5feedcac4Tyler Gunn * These extras changes can originate from Telecom itself, or from an {@link InCallService} via 831dee56a8a79f9daa1e597f5d4f399d3a5feedcac4Tyler Gunn * {@link android.telecom.Call#putExtras(Bundle)}, and 832dee56a8a79f9daa1e597f5d4f399d3a5feedcac4Tyler Gunn * {@link Call#removeExtras(List)}. 833dee56a8a79f9daa1e597f5d4f399d3a5feedcac4Tyler Gunn * 834dee56a8a79f9daa1e597f5d4f399d3a5feedcac4Tyler Gunn * @param extras The new extras bundle. 8351bf206b766654ea9c4e9bc7a703a9d5f1d30ab72Tyler Gunn * @hide 836dee56a8a79f9daa1e597f5d4f399d3a5feedcac4Tyler Gunn */ 837dee56a8a79f9daa1e597f5d4f399d3a5feedcac4Tyler Gunn public void onExtrasChanged(Bundle extras) {} 838dee56a8a79f9daa1e597f5d4f399d3a5feedcac4Tyler Gunn 839dee56a8a79f9daa1e597f5d4f399d3a5feedcac4Tyler Gunn /** 840dee56a8a79f9daa1e597f5d4f399d3a5feedcac4Tyler Gunn * Handles a change to extras received from Telecom. 841dee56a8a79f9daa1e597f5d4f399d3a5feedcac4Tyler Gunn * 842dee56a8a79f9daa1e597f5d4f399d3a5feedcac4Tyler Gunn * @param extras The new extras. 843dee56a8a79f9daa1e597f5d4f399d3a5feedcac4Tyler Gunn * @hide 844dee56a8a79f9daa1e597f5d4f399d3a5feedcac4Tyler Gunn */ 845dee56a8a79f9daa1e597f5d4f399d3a5feedcac4Tyler Gunn final void handleExtrasChanged(Bundle extras) { 8464fa6a01898be85999e12b62bb52debb838e1bd0cBrad Ebinger Bundle b = null; 8474fa6a01898be85999e12b62bb52debb838e1bd0cBrad Ebinger synchronized (mExtrasLock) { 8484fa6a01898be85999e12b62bb52debb838e1bd0cBrad Ebinger mExtras = extras; 8494fa6a01898be85999e12b62bb52debb838e1bd0cBrad Ebinger if (mExtras != null) { 8504fa6a01898be85999e12b62bb52debb838e1bd0cBrad Ebinger b = new Bundle(mExtras); 8514fa6a01898be85999e12b62bb52debb838e1bd0cBrad Ebinger } 8524fa6a01898be85999e12b62bb52debb838e1bd0cBrad Ebinger } 8534fa6a01898be85999e12b62bb52debb838e1bd0cBrad Ebinger onExtrasChanged(b); 854dee56a8a79f9daa1e597f5d4f399d3a5feedcac4Tyler Gunn } 855823fd3c79dd4f762bbc778e0ce9e2204b6d3d454Santos Cordon} 856