153b84fe2dc796ef172d7c0f4b9bdc177cdeb0c0fSantos Cordon/* 253b84fe2dc796ef172d7c0f4b9bdc177cdeb0c0fSantos Cordon * Copyright (C) 2014 The Android Open Source Project 353b84fe2dc796ef172d7c0f4b9bdc177cdeb0c0fSantos Cordon * 453b84fe2dc796ef172d7c0f4b9bdc177cdeb0c0fSantos Cordon * Licensed under the Apache License, Version 2.0 (the "License"); 553b84fe2dc796ef172d7c0f4b9bdc177cdeb0c0fSantos Cordon * you may not use this file except in compliance with the License. 653b84fe2dc796ef172d7c0f4b9bdc177cdeb0c0fSantos Cordon * You may obtain a copy of the License at 753b84fe2dc796ef172d7c0f4b9bdc177cdeb0c0fSantos Cordon * 853b84fe2dc796ef172d7c0f4b9bdc177cdeb0c0fSantos Cordon * http://www.apache.org/licenses/LICENSE-2.0 953b84fe2dc796ef172d7c0f4b9bdc177cdeb0c0fSantos Cordon * 1053b84fe2dc796ef172d7c0f4b9bdc177cdeb0c0fSantos Cordon * Unless required by applicable law or agreed to in writing, software 1153b84fe2dc796ef172d7c0f4b9bdc177cdeb0c0fSantos Cordon * distributed under the License is distributed on an "AS IS" BASIS, 1253b84fe2dc796ef172d7c0f4b9bdc177cdeb0c0fSantos Cordon * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1353b84fe2dc796ef172d7c0f4b9bdc177cdeb0c0fSantos Cordon * See the License for the specific language governing permissions and 1453b84fe2dc796ef172d7c0f4b9bdc177cdeb0c0fSantos Cordon * limitations under the License. 1553b84fe2dc796ef172d7c0f4b9bdc177cdeb0c0fSantos Cordon */ 1653b84fe2dc796ef172d7c0f4b9bdc177cdeb0c0fSantos Cordon 1753b84fe2dc796ef172d7c0f4b9bdc177cdeb0c0fSantos Cordonpackage com.android.services.telephony; 1853b84fe2dc796ef172d7c0f4b9bdc177cdeb0c0fSantos Cordon 194d45d1cf58a2003378fd35912d6d73a00001bf06Tyler Gunnimport android.telecom.Conference; 204d45d1cf58a2003378fd35912d6d73a00001bf06Tyler Gunnimport android.telecom.Connection; 214d45d1cf58a2003378fd35912d6d73a00001bf06Tyler Gunnimport android.telecom.PhoneAccountHandle; 2253b84fe2dc796ef172d7c0f4b9bdc177cdeb0c0fSantos Cordon 2353b84fe2dc796ef172d7c0f4b9bdc177cdeb0c0fSantos Cordonimport com.android.internal.telephony.Call; 2453b84fe2dc796ef172d7c0f4b9bdc177cdeb0c0fSantos Cordonimport com.android.internal.telephony.CallStateException; 253197ea821dcdee1c30549f850b99c2cfc7f668cbIhab Awadimport com.android.internal.telephony.Phone; 2653b84fe2dc796ef172d7c0f4b9bdc177cdeb0c0fSantos Cordon 2753b84fe2dc796ef172d7c0f4b9bdc177cdeb0c0fSantos Cordonimport java.util.List; 2853b84fe2dc796ef172d7c0f4b9bdc177cdeb0c0fSantos Cordon 2953b84fe2dc796ef172d7c0f4b9bdc177cdeb0c0fSantos Cordon/** 30e0579cd4fe5ff4236d9684de1af27ef49564828cAndrew Lee * TelephonyConnection-based conference call for GSM conferences and IMS conferences (which may 31e0579cd4fe5ff4236d9684de1af27ef49564828cAndrew Lee * be either GSM-based or CDMA-based). 3253b84fe2dc796ef172d7c0f4b9bdc177cdeb0c0fSantos Cordon */ 336e1d56a1d4e51b2b889f61fe3e46f535ee6d45f8Pengquan Mengpublic class TelephonyConference extends Conference implements Holdable { 346e1d56a1d4e51b2b889f61fe3e46f535ee6d45f8Pengquan Meng 356e1d56a1d4e51b2b889f61fe3e46f535ee6d45f8Pengquan Meng private boolean mIsHoldable; 3653b84fe2dc796ef172d7c0f4b9bdc177cdeb0c0fSantos Cordon 37e0579cd4fe5ff4236d9684de1af27ef49564828cAndrew Lee public TelephonyConference(PhoneAccountHandle phoneAccount) { 3853b84fe2dc796ef172d7c0f4b9bdc177cdeb0c0fSantos Cordon super(phoneAccount); 393cc8121590b5b05af65a9aeaa8948834e4983adcIhab Awad setConnectionCapabilities( 403cc8121590b5b05af65a9aeaa8948834e4983adcIhab Awad Connection.CAPABILITY_SUPPORT_HOLD | 413cc8121590b5b05af65a9aeaa8948834e4983adcIhab Awad Connection.CAPABILITY_HOLD | 423cc8121590b5b05af65a9aeaa8948834e4983adcIhab Awad Connection.CAPABILITY_MUTE | 433cc8121590b5b05af65a9aeaa8948834e4983adcIhab Awad Connection.CAPABILITY_MANAGE_CONFERENCE); 4453b84fe2dc796ef172d7c0f4b9bdc177cdeb0c0fSantos Cordon setActive(); 456e1d56a1d4e51b2b889f61fe3e46f535ee6d45f8Pengquan Meng mIsHoldable = true; 4653b84fe2dc796ef172d7c0f4b9bdc177cdeb0c0fSantos Cordon } 4753b84fe2dc796ef172d7c0f4b9bdc177cdeb0c0fSantos Cordon 4853b84fe2dc796ef172d7c0f4b9bdc177cdeb0c0fSantos Cordon /** 4953b84fe2dc796ef172d7c0f4b9bdc177cdeb0c0fSantos Cordon * Invoked when the Conference and all it's {@link Connection}s should be disconnected. 5053b84fe2dc796ef172d7c0f4b9bdc177cdeb0c0fSantos Cordon */ 5153b84fe2dc796ef172d7c0f4b9bdc177cdeb0c0fSantos Cordon @Override 5253b84fe2dc796ef172d7c0f4b9bdc177cdeb0c0fSantos Cordon public void onDisconnect() { 5353b84fe2dc796ef172d7c0f4b9bdc177cdeb0c0fSantos Cordon for (Connection connection : getConnections()) { 542c248f38ac4c7fefc50fb9c595b6cbf2798c0632Tyler Gunn if (disconnectCall(connection)) { 552c248f38ac4c7fefc50fb9c595b6cbf2798c0632Tyler Gunn break; 562c248f38ac4c7fefc50fb9c595b6cbf2798c0632Tyler Gunn } 572c248f38ac4c7fefc50fb9c595b6cbf2798c0632Tyler Gunn } 582c248f38ac4c7fefc50fb9c595b6cbf2798c0632Tyler Gunn } 592c248f38ac4c7fefc50fb9c595b6cbf2798c0632Tyler Gunn 602c248f38ac4c7fefc50fb9c595b6cbf2798c0632Tyler Gunn /** 612c248f38ac4c7fefc50fb9c595b6cbf2798c0632Tyler Gunn * Disconnect the underlying Telephony Call for a connection. 622c248f38ac4c7fefc50fb9c595b6cbf2798c0632Tyler Gunn * 632c248f38ac4c7fefc50fb9c595b6cbf2798c0632Tyler Gunn * @param connection The connection. 642c248f38ac4c7fefc50fb9c595b6cbf2798c0632Tyler Gunn * @return {@code True} if the call was disconnected. 652c248f38ac4c7fefc50fb9c595b6cbf2798c0632Tyler Gunn */ 662c248f38ac4c7fefc50fb9c595b6cbf2798c0632Tyler Gunn private boolean disconnectCall(Connection connection) { 672c248f38ac4c7fefc50fb9c595b6cbf2798c0632Tyler Gunn Call call = getMultipartyCallForConnection(connection, "onDisconnect"); 682c248f38ac4c7fefc50fb9c595b6cbf2798c0632Tyler Gunn if (call != null) { 692c248f38ac4c7fefc50fb9c595b6cbf2798c0632Tyler Gunn Log.d(this, "Found multiparty call to hangup for conference."); 702c248f38ac4c7fefc50fb9c595b6cbf2798c0632Tyler Gunn try { 712c248f38ac4c7fefc50fb9c595b6cbf2798c0632Tyler Gunn call.hangup(); 722c248f38ac4c7fefc50fb9c595b6cbf2798c0632Tyler Gunn return true; 732c248f38ac4c7fefc50fb9c595b6cbf2798c0632Tyler Gunn } catch (CallStateException e) { 742c248f38ac4c7fefc50fb9c595b6cbf2798c0632Tyler Gunn Log.e(this, e, "Exception thrown trying to hangup conference"); 7553b84fe2dc796ef172d7c0f4b9bdc177cdeb0c0fSantos Cordon } 7653b84fe2dc796ef172d7c0f4b9bdc177cdeb0c0fSantos Cordon } 772c248f38ac4c7fefc50fb9c595b6cbf2798c0632Tyler Gunn return false; 7853b84fe2dc796ef172d7c0f4b9bdc177cdeb0c0fSantos Cordon } 7953b84fe2dc796ef172d7c0f4b9bdc177cdeb0c0fSantos Cordon 8053b84fe2dc796ef172d7c0f4b9bdc177cdeb0c0fSantos Cordon /** 8153b84fe2dc796ef172d7c0f4b9bdc177cdeb0c0fSantos Cordon * Invoked when the specified {@link Connection} should be separated from the conference call. 8253b84fe2dc796ef172d7c0f4b9bdc177cdeb0c0fSantos Cordon * 8353b84fe2dc796ef172d7c0f4b9bdc177cdeb0c0fSantos Cordon * @param connection The connection to separate. 8453b84fe2dc796ef172d7c0f4b9bdc177cdeb0c0fSantos Cordon */ 8553b84fe2dc796ef172d7c0f4b9bdc177cdeb0c0fSantos Cordon @Override 8653b84fe2dc796ef172d7c0f4b9bdc177cdeb0c0fSantos Cordon public void onSeparate(Connection connection) { 8753b84fe2dc796ef172d7c0f4b9bdc177cdeb0c0fSantos Cordon com.android.internal.telephony.Connection radioConnection = 88b4edaf1c5ff88460e4b3d8161e390567ce4cef34Tyler Gunn getOriginalConnection(connection); 8953b84fe2dc796ef172d7c0f4b9bdc177cdeb0c0fSantos Cordon try { 9053b84fe2dc796ef172d7c0f4b9bdc177cdeb0c0fSantos Cordon radioConnection.separate(); 9153b84fe2dc796ef172d7c0f4b9bdc177cdeb0c0fSantos Cordon } catch (CallStateException e) { 9253b84fe2dc796ef172d7c0f4b9bdc177cdeb0c0fSantos Cordon Log.e(this, e, "Exception thrown trying to separate a conference call"); 9353b84fe2dc796ef172d7c0f4b9bdc177cdeb0c0fSantos Cordon } 9453b84fe2dc796ef172d7c0f4b9bdc177cdeb0c0fSantos Cordon } 953197ea821dcdee1c30549f850b99c2cfc7f668cbIhab Awad 963197ea821dcdee1c30549f850b99c2cfc7f668cbIhab Awad @Override 973197ea821dcdee1c30549f850b99c2cfc7f668cbIhab Awad public void onMerge(Connection connection) { 983197ea821dcdee1c30549f850b99c2cfc7f668cbIhab Awad try { 993197ea821dcdee1c30549f850b99c2cfc7f668cbIhab Awad Phone phone = ((TelephonyConnection) connection).getPhone(); 1003197ea821dcdee1c30549f850b99c2cfc7f668cbIhab Awad if (phone != null) { 1013197ea821dcdee1c30549f850b99c2cfc7f668cbIhab Awad phone.conference(); 1023197ea821dcdee1c30549f850b99c2cfc7f668cbIhab Awad } 1033197ea821dcdee1c30549f850b99c2cfc7f668cbIhab Awad } catch (CallStateException e) { 1043197ea821dcdee1c30549f850b99c2cfc7f668cbIhab Awad Log.e(this, e, "Exception thrown trying to merge call into a conference"); 1053197ea821dcdee1c30549f850b99c2cfc7f668cbIhab Awad } 1063197ea821dcdee1c30549f850b99c2cfc7f668cbIhab Awad } 10753b84fe2dc796ef172d7c0f4b9bdc177cdeb0c0fSantos Cordon 10853b84fe2dc796ef172d7c0f4b9bdc177cdeb0c0fSantos Cordon /** 10953b84fe2dc796ef172d7c0f4b9bdc177cdeb0c0fSantos Cordon * Invoked when the conference should be put on hold. 11053b84fe2dc796ef172d7c0f4b9bdc177cdeb0c0fSantos Cordon */ 11153b84fe2dc796ef172d7c0f4b9bdc177cdeb0c0fSantos Cordon @Override 11253b84fe2dc796ef172d7c0f4b9bdc177cdeb0c0fSantos Cordon public void onHold() { 113e0579cd4fe5ff4236d9684de1af27ef49564828cAndrew Lee final TelephonyConnection connection = getFirstConnection(); 114293b7bbbc7fb53fe62cd64a40324e11088153398Yorke Lee if (connection != null) { 115293b7bbbc7fb53fe62cd64a40324e11088153398Yorke Lee connection.performHold(); 11653b84fe2dc796ef172d7c0f4b9bdc177cdeb0c0fSantos Cordon } 11753b84fe2dc796ef172d7c0f4b9bdc177cdeb0c0fSantos Cordon } 11853b84fe2dc796ef172d7c0f4b9bdc177cdeb0c0fSantos Cordon 11953b84fe2dc796ef172d7c0f4b9bdc177cdeb0c0fSantos Cordon /** 12053b84fe2dc796ef172d7c0f4b9bdc177cdeb0c0fSantos Cordon * Invoked when the conference should be moved from hold to active. 12153b84fe2dc796ef172d7c0f4b9bdc177cdeb0c0fSantos Cordon */ 12253b84fe2dc796ef172d7c0f4b9bdc177cdeb0c0fSantos Cordon @Override 12353b84fe2dc796ef172d7c0f4b9bdc177cdeb0c0fSantos Cordon public void onUnhold() { 124e0579cd4fe5ff4236d9684de1af27ef49564828cAndrew Lee final TelephonyConnection connection = getFirstConnection(); 125293b7bbbc7fb53fe62cd64a40324e11088153398Yorke Lee if (connection != null) { 126293b7bbbc7fb53fe62cd64a40324e11088153398Yorke Lee connection.performUnhold(); 127293b7bbbc7fb53fe62cd64a40324e11088153398Yorke Lee } 128293b7bbbc7fb53fe62cd64a40324e11088153398Yorke Lee } 129293b7bbbc7fb53fe62cd64a40324e11088153398Yorke Lee 130293b7bbbc7fb53fe62cd64a40324e11088153398Yorke Lee @Override 131293b7bbbc7fb53fe62cd64a40324e11088153398Yorke Lee public void onPlayDtmfTone(char c) { 132e0579cd4fe5ff4236d9684de1af27ef49564828cAndrew Lee final TelephonyConnection connection = getFirstConnection(); 133293b7bbbc7fb53fe62cd64a40324e11088153398Yorke Lee if (connection != null) { 134293b7bbbc7fb53fe62cd64a40324e11088153398Yorke Lee connection.onPlayDtmfTone(c); 135293b7bbbc7fb53fe62cd64a40324e11088153398Yorke Lee } 136293b7bbbc7fb53fe62cd64a40324e11088153398Yorke Lee } 137293b7bbbc7fb53fe62cd64a40324e11088153398Yorke Lee 138293b7bbbc7fb53fe62cd64a40324e11088153398Yorke Lee @Override 139293b7bbbc7fb53fe62cd64a40324e11088153398Yorke Lee public void onStopDtmfTone() { 140e0579cd4fe5ff4236d9684de1af27ef49564828cAndrew Lee final TelephonyConnection connection = getFirstConnection(); 141293b7bbbc7fb53fe62cd64a40324e11088153398Yorke Lee if (connection != null) { 142293b7bbbc7fb53fe62cd64a40324e11088153398Yorke Lee connection.onStopDtmfTone(); 14353b84fe2dc796ef172d7c0f4b9bdc177cdeb0c0fSantos Cordon } 14453b84fe2dc796ef172d7c0f4b9bdc177cdeb0c0fSantos Cordon } 14553b84fe2dc796ef172d7c0f4b9bdc177cdeb0c0fSantos Cordon 146b4edaf1c5ff88460e4b3d8161e390567ce4cef34Tyler Gunn @Override 14709bb16f9d7e4ffa790132285d9e8583ebe4af0feAndrew Lee public void onConnectionAdded(Connection connection) { 14809bb16f9d7e4ffa790132285d9e8583ebe4af0feAndrew Lee // If the conference was an IMS connection currently or before, disable MANAGE_CONFERENCE 14909bb16f9d7e4ffa790132285d9e8583ebe4af0feAndrew Lee // as the default behavior. If there is a conference event package, this may be overridden. 150ad6f3dce3b32d69fb2a353753163358f88708405Tyler Gunn // If a conference event package was received, do not attempt to remove manage conference. 151ad6f3dce3b32d69fb2a353753163358f88708405Tyler Gunn if (connection instanceof TelephonyConnection && 1522c248f38ac4c7fefc50fb9c595b6cbf2798c0632Tyler Gunn ((TelephonyConnection) connection).wasImsConnection()) { 1533cc8121590b5b05af65a9aeaa8948834e4983adcIhab Awad removeCapability(Connection.CAPABILITY_MANAGE_CONFERENCE); 15409bb16f9d7e4ffa790132285d9e8583ebe4af0feAndrew Lee } 15509bb16f9d7e4ffa790132285d9e8583ebe4af0feAndrew Lee } 15609bb16f9d7e4ffa790132285d9e8583ebe4af0feAndrew Lee 15709bb16f9d7e4ffa790132285d9e8583ebe4af0feAndrew Lee @Override 158b4edaf1c5ff88460e4b3d8161e390567ce4cef34Tyler Gunn public Connection getPrimaryConnection() { 1592c248f38ac4c7fefc50fb9c595b6cbf2798c0632Tyler Gunn 1602c248f38ac4c7fefc50fb9c595b6cbf2798c0632Tyler Gunn List<Connection> connections = getConnections(); 1612c248f38ac4c7fefc50fb9c595b6cbf2798c0632Tyler Gunn if (connections == null || connections.isEmpty()) { 1622c248f38ac4c7fefc50fb9c595b6cbf2798c0632Tyler Gunn return null; 1632c248f38ac4c7fefc50fb9c595b6cbf2798c0632Tyler Gunn } 1642c248f38ac4c7fefc50fb9c595b6cbf2798c0632Tyler Gunn 165b4edaf1c5ff88460e4b3d8161e390567ce4cef34Tyler Gunn // Default to the first connection. 1662c248f38ac4c7fefc50fb9c595b6cbf2798c0632Tyler Gunn Connection primaryConnection = connections.get(0); 167b4edaf1c5ff88460e4b3d8161e390567ce4cef34Tyler Gunn 168b4edaf1c5ff88460e4b3d8161e390567ce4cef34Tyler Gunn // Otherwise look for a connection where the radio connection states it is multiparty. 1692c248f38ac4c7fefc50fb9c595b6cbf2798c0632Tyler Gunn for (Connection connection : connections) { 170b4edaf1c5ff88460e4b3d8161e390567ce4cef34Tyler Gunn com.android.internal.telephony.Connection radioConnection = 171b4edaf1c5ff88460e4b3d8161e390567ce4cef34Tyler Gunn getOriginalConnection(connection); 172b4edaf1c5ff88460e4b3d8161e390567ce4cef34Tyler Gunn 173b4edaf1c5ff88460e4b3d8161e390567ce4cef34Tyler Gunn if (radioConnection != null && radioConnection.isMultiparty()) { 174b4edaf1c5ff88460e4b3d8161e390567ce4cef34Tyler Gunn primaryConnection = connection; 175b4edaf1c5ff88460e4b3d8161e390567ce4cef34Tyler Gunn break; 176b4edaf1c5ff88460e4b3d8161e390567ce4cef34Tyler Gunn } 177b4edaf1c5ff88460e4b3d8161e390567ce4cef34Tyler Gunn } 178b4edaf1c5ff88460e4b3d8161e390567ce4cef34Tyler Gunn 179b4edaf1c5ff88460e4b3d8161e390567ce4cef34Tyler Gunn return primaryConnection; 180b4edaf1c5ff88460e4b3d8161e390567ce4cef34Tyler Gunn } 181b4edaf1c5ff88460e4b3d8161e390567ce4cef34Tyler Gunn 1826e1d56a1d4e51b2b889f61fe3e46f535ee6d45f8Pengquan Meng @Override 1836e1d56a1d4e51b2b889f61fe3e46f535ee6d45f8Pengquan Meng public void setHoldable(boolean isHoldable) { 1846e1d56a1d4e51b2b889f61fe3e46f535ee6d45f8Pengquan Meng mIsHoldable = isHoldable; 1856e1d56a1d4e51b2b889f61fe3e46f535ee6d45f8Pengquan Meng if (!mIsHoldable) { 1866e1d56a1d4e51b2b889f61fe3e46f535ee6d45f8Pengquan Meng removeCapability(Connection.CAPABILITY_HOLD); 1876e1d56a1d4e51b2b889f61fe3e46f535ee6d45f8Pengquan Meng } else { 1886e1d56a1d4e51b2b889f61fe3e46f535ee6d45f8Pengquan Meng addCapability(Connection.CAPABILITY_HOLD); 1896e1d56a1d4e51b2b889f61fe3e46f535ee6d45f8Pengquan Meng } 1906e1d56a1d4e51b2b889f61fe3e46f535ee6d45f8Pengquan Meng } 1916e1d56a1d4e51b2b889f61fe3e46f535ee6d45f8Pengquan Meng 1926e1d56a1d4e51b2b889f61fe3e46f535ee6d45f8Pengquan Meng @Override 1936e1d56a1d4e51b2b889f61fe3e46f535ee6d45f8Pengquan Meng public boolean isChildHoldable() { 1946e1d56a1d4e51b2b889f61fe3e46f535ee6d45f8Pengquan Meng // The conference should not be a child of other conference. 1956e1d56a1d4e51b2b889f61fe3e46f535ee6d45f8Pengquan Meng return false; 1966e1d56a1d4e51b2b889f61fe3e46f535ee6d45f8Pengquan Meng } 1976e1d56a1d4e51b2b889f61fe3e46f535ee6d45f8Pengquan Meng 19853b84fe2dc796ef172d7c0f4b9bdc177cdeb0c0fSantos Cordon private Call getMultipartyCallForConnection(Connection connection, String tag) { 19953b84fe2dc796ef172d7c0f4b9bdc177cdeb0c0fSantos Cordon com.android.internal.telephony.Connection radioConnection = 200b4edaf1c5ff88460e4b3d8161e390567ce4cef34Tyler Gunn getOriginalConnection(connection); 20153b84fe2dc796ef172d7c0f4b9bdc177cdeb0c0fSantos Cordon if (radioConnection != null) { 20253b84fe2dc796ef172d7c0f4b9bdc177cdeb0c0fSantos Cordon Call call = radioConnection.getCall(); 20353b84fe2dc796ef172d7c0f4b9bdc177cdeb0c0fSantos Cordon if (call != null && call.isMultiparty()) { 20453b84fe2dc796ef172d7c0f4b9bdc177cdeb0c0fSantos Cordon return call; 20553b84fe2dc796ef172d7c0f4b9bdc177cdeb0c0fSantos Cordon } 20653b84fe2dc796ef172d7c0f4b9bdc177cdeb0c0fSantos Cordon } 20753b84fe2dc796ef172d7c0f4b9bdc177cdeb0c0fSantos Cordon return null; 20853b84fe2dc796ef172d7c0f4b9bdc177cdeb0c0fSantos Cordon } 20953b84fe2dc796ef172d7c0f4b9bdc177cdeb0c0fSantos Cordon 2102c248f38ac4c7fefc50fb9c595b6cbf2798c0632Tyler Gunn protected com.android.internal.telephony.Connection getOriginalConnection( 211b4edaf1c5ff88460e4b3d8161e390567ce4cef34Tyler Gunn Connection connection) { 21253b84fe2dc796ef172d7c0f4b9bdc177cdeb0c0fSantos Cordon 213e0579cd4fe5ff4236d9684de1af27ef49564828cAndrew Lee if (connection instanceof TelephonyConnection) { 214e0579cd4fe5ff4236d9684de1af27ef49564828cAndrew Lee return ((TelephonyConnection) connection).getOriginalConnection(); 21553b84fe2dc796ef172d7c0f4b9bdc177cdeb0c0fSantos Cordon } else { 21653b84fe2dc796ef172d7c0f4b9bdc177cdeb0c0fSantos Cordon return null; 21753b84fe2dc796ef172d7c0f4b9bdc177cdeb0c0fSantos Cordon } 21853b84fe2dc796ef172d7c0f4b9bdc177cdeb0c0fSantos Cordon } 219293b7bbbc7fb53fe62cd64a40324e11088153398Yorke Lee 220e0579cd4fe5ff4236d9684de1af27ef49564828cAndrew Lee private TelephonyConnection getFirstConnection() { 221293b7bbbc7fb53fe62cd64a40324e11088153398Yorke Lee final List<Connection> connections = getConnections(); 222293b7bbbc7fb53fe62cd64a40324e11088153398Yorke Lee if (connections.isEmpty()) { 223293b7bbbc7fb53fe62cd64a40324e11088153398Yorke Lee return null; 224293b7bbbc7fb53fe62cd64a40324e11088153398Yorke Lee } 225e0579cd4fe5ff4236d9684de1af27ef49564828cAndrew Lee return (TelephonyConnection) connections.get(0); 226293b7bbbc7fb53fe62cd64a40324e11088153398Yorke Lee } 22753b84fe2dc796ef172d7c0f4b9bdc177cdeb0c0fSantos Cordon} 228