17aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta/* 27aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * Copyright (C) 2014 The Android Open Source Project 37aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * 47aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * Licensed under the Apache License, Version 2.0 (the "License"); 57aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * you may not use this file except in compliance with the License. 67aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * You may obtain a copy of the License at 77aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * 87aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * http://www.apache.org/licenses/LICENSE-2.0 97aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * 107aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * Unless required by applicable law or agreed to in writing, software 117aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * distributed under the License is distributed on an "AS IS" BASIS, 127aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 137aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * See the License for the specific language governing permissions and 147aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * limitations under the License. 157aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta */ 167aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta 177aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Guptapackage android.bluetooth; 187aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta 197aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Guptaimport android.content.ComponentName; 207aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Guptaimport android.content.Context; 217aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Guptaimport android.content.Intent; 227aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Guptaimport android.content.ServiceConnection; 237aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Guptaimport android.os.Bundle; 247aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Guptaimport android.os.IBinder; 257aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Guptaimport android.os.RemoteException; 267aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Guptaimport android.util.Log; 277aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta 287aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Guptaimport java.util.ArrayList; 297aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Guptaimport java.util.List; 307aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta 317aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta/** 327aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * Public API to control Hands Free Profile (HFP role only). 337aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * <p> 347aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * This class defines methods that shall be used by application to manage profile 357aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * connection, calls states and calls actions. 367aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * <p> 377aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * 387aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * @hide 397aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * */ 40cf916d34671f0ab6aad8de24c18e4dc96fb21941Mike Lockwoodpublic final class BluetoothHeadsetClient implements BluetoothProfile { 41cf916d34671f0ab6aad8de24c18e4dc96fb21941Mike Lockwood private static final String TAG = "BluetoothHeadsetClient"; 427aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta private static final boolean DBG = true; 437aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta private static final boolean VDBG = false; 447aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta 457aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta /** 467aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * Intent sent whenever connection to remote changes. 477aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * 487aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * <p>It includes two extras: 497aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * <code>BluetoothProfile.EXTRA_PREVIOUS_STATE</code> 507aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * and <code>BluetoothProfile.EXTRA_STATE</code>, which 517aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * are mandatory. 527aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * <p>There are also non mandatory feature extras: 537aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * {@link #EXTRA_AG_FEATURE_3WAY_CALLING}, 547aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * {@link #EXTRA_AG_FEATURE_VOICE_RECOGNITION}, 557aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * {@link #EXTRA_AG_FEATURE_ATTACH_NUMBER_TO_VT}, 567aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * {@link #EXTRA_AG_FEATURE_REJECT_CALL}, 577aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * {@link #EXTRA_AG_FEATURE_ECC}, 587aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * {@link #EXTRA_AG_FEATURE_RESPONSE_AND_HOLD}, 597aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * {@link #EXTRA_AG_FEATURE_ACCEPT_HELD_OR_WAITING_CALL}, 607aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * {@link #EXTRA_AG_FEATURE_RELEASE_HELD_OR_WAITING_CALL}, 617aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * {@link #EXTRA_AG_FEATURE_RELEASE_AND_ACCEPT}, 627aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * {@link #EXTRA_AG_FEATURE_MERGE}, 637aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * {@link #EXTRA_AG_FEATURE_MERGE_AND_DETACH}, 647aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * sent as boolean values only when <code>EXTRA_STATE</code> 657aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * is set to <code>STATE_CONNECTED</code>.</p> 667aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * 677aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * <p>Note that features supported by AG are being sent as 687aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * booleans with value <code>true</code>, 697aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * and not supported ones are <strong>not</strong> being sent at all.</p> 707aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta */ 717aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta public static final String ACTION_CONNECTION_STATE_CHANGED = 72cf916d34671f0ab6aad8de24c18e4dc96fb21941Mike Lockwood "android.bluetooth.headsetclient.profile.action.CONNECTION_STATE_CHANGED"; 737aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta 747aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta /** 757aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * Intent sent whenever audio state changes. 767aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * 777aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * <p>It includes two mandatory extras: 787aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * {@link BluetoothProfile.EXTRA_STATE}, 797aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * {@link BluetoothProfile.EXTRA_PREVIOUS_STATE}, 807aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * with possible values: 817aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * {@link #STATE_AUDIO_CONNECTING}, 827aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * {@link #STATE_AUDIO_CONNECTED}, 837aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * {@link #STATE_AUDIO_DISCONNECTED}</p> 847aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * <p>When <code>EXTRA_STATE</code> is set 857aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * to </code>STATE_AUDIO_CONNECTED</code>, 867aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * it also includes {@link #EXTRA_AUDIO_WBS} 877aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * indicating wide band speech support.</p> 887aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta */ 897aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta public static final String ACTION_AUDIO_STATE_CHANGED = 90cf916d34671f0ab6aad8de24c18e4dc96fb21941Mike Lockwood "android.bluetooth.headsetclient.profile.action.AUDIO_STATE_CHANGED"; 917aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta 927aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta /** 937aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * Intent sending updates of the Audio Gateway state. 947aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * Each extra is being sent only when value it 957aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * represents has been changed recently on AG. 967aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * <p>It can contain one or more of the following extras: 977aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * {@link #EXTRA_NETWORK_STATUS}, 987aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * {@link #EXTRA_NETWORK_SIGNAL_STRENGTH}, 997aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * {@link #EXTRA_NETWORK_ROAMING}, 1007aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * {@link #EXTRA_BATTERY_LEVEL}, 1017aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * {@link #EXTRA_OPERATOR_NAME}, 1027aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * {@link #EXTRA_VOICE_RECOGNITION}, 1037aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * {@link #EXTRA_IN_BAND_RING}</p> 1047aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta */ 1057aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta public static final String ACTION_AG_EVENT = 106cf916d34671f0ab6aad8de24c18e4dc96fb21941Mike Lockwood "android.bluetooth.headsetclient.profile.action.AG_EVENT"; 1077aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta 1087aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta /** 1097aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * Intent sent whenever state of a call changes. 1107aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * 1117aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * <p>It includes: 1127aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * {@link #EXTRA_CALL}, 113cf916d34671f0ab6aad8de24c18e4dc96fb21941Mike Lockwood * with value of {@link BluetoothHeadsetClientCall} instance, 1147aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * representing actual call state.</p> 1157aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta */ 1167aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta public static final String ACTION_CALL_CHANGED = 117cf916d34671f0ab6aad8de24c18e4dc96fb21941Mike Lockwood "android.bluetooth.headsetclient.profile.action.AG_CALL_CHANGED"; 1187aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta 1197aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta /** 1207aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * Intent that notifies about the result of the last issued action. 1217aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * Please note that not every action results in explicit action result code being sent. 1227aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * Instead other notifications about new Audio Gateway state might be sent, 1237aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * like <code>ACTION_AG_EVENT</code> with <code>EXTRA_VOICE_RECOGNITION</code> value 1247aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * when for example user started voice recognition from HF unit. 1257aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta */ 1267aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta public static final String ACTION_RESULT = 127cf916d34671f0ab6aad8de24c18e4dc96fb21941Mike Lockwood "android.bluetooth.headsetclient.profile.action.RESULT"; 1287aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta 1297aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta /** 1307aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * Intent that notifies about the number attached to the last voice tag 1317aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * recorded on AG. 1327aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * 1337aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * <p>It contains: 1347aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * {@link #EXTRA_NUMBER}, 1357aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * with a <code>String</code> value representing phone number.</p> 1367aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta */ 1377aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta public static final String ACTION_LAST_VTAG = 138cf916d34671f0ab6aad8de24c18e4dc96fb21941Mike Lockwood "android.bluetooth.headsetclient.profile.action.LAST_VTAG"; 1397aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta 1407aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta public static final int STATE_AUDIO_DISCONNECTED = 0; 1417aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta public static final int STATE_AUDIO_CONNECTING = 1; 1427aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta public static final int STATE_AUDIO_CONNECTED = 2; 1437aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta 1447aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta /** 1457aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * Extra with information if connected audio is WBS. 1467aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * <p>Possible values: <code>true</code>, 1477aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * <code>false</code>.</p> 1487aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta */ 1497aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta public static final String EXTRA_AUDIO_WBS = 150cf916d34671f0ab6aad8de24c18e4dc96fb21941Mike Lockwood "android.bluetooth.headsetclient.extra.AUDIO_WBS"; 1517aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta 1527aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta /** 1537aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * Extra for AG_EVENT indicates network status. 1547aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * <p>Value: 0 - network unavailable, 1557aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * 1 - network available </p> 1567aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta */ 1577aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta public static final String EXTRA_NETWORK_STATUS = 158cf916d34671f0ab6aad8de24c18e4dc96fb21941Mike Lockwood "android.bluetooth.headsetclient.extra.NETWORK_STATUS"; 1597aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta /** 1607aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * Extra for AG_EVENT intent indicates network signal strength. 1617aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * <p>Value: <code>Integer</code> representing signal strength.</p> 1627aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta */ 1637aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta public static final String EXTRA_NETWORK_SIGNAL_STRENGTH = 164cf916d34671f0ab6aad8de24c18e4dc96fb21941Mike Lockwood "android.bluetooth.headsetclient.extra.NETWORK_SIGNAL_STRENGTH"; 1657aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta /** 1667aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * Extra for AG_EVENT intent indicates roaming state. 1677aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * <p>Value: 0 - no roaming 1687aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * 1 - active roaming</p> 1697aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta */ 1707aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta public static final String EXTRA_NETWORK_ROAMING = 171cf916d34671f0ab6aad8de24c18e4dc96fb21941Mike Lockwood "android.bluetooth.headsetclient.extra.NETWORK_ROAMING"; 1727aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta /** 1737aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * Extra for AG_EVENT intent indicates the battery level. 1747aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * <p>Value: <code>Integer</code> representing signal strength.</p> 1757aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta */ 1767aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta public static final String EXTRA_BATTERY_LEVEL = 177cf916d34671f0ab6aad8de24c18e4dc96fb21941Mike Lockwood "android.bluetooth.headsetclient.extra.BATTERY_LEVEL"; 1787aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta /** 1797aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * Extra for AG_EVENT intent indicates operator name. 1807aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * <p>Value: <code>String</code> representing operator name.</p> 1817aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta */ 1827aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta public static final String EXTRA_OPERATOR_NAME = 183cf916d34671f0ab6aad8de24c18e4dc96fb21941Mike Lockwood "android.bluetooth.headsetclient.extra.OPERATOR_NAME"; 1847aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta /** 1857aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * Extra for AG_EVENT intent indicates voice recognition state. 1867aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * <p>Value: 1877aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * 0 - voice recognition stopped, 1887aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * 1 - voice recognition started.</p> 1897aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta */ 1907aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta public static final String EXTRA_VOICE_RECOGNITION = 191cf916d34671f0ab6aad8de24c18e4dc96fb21941Mike Lockwood "android.bluetooth.headsetclient.extra.VOICE_RECOGNITION"; 1927aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta /** 1937aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * Extra for AG_EVENT intent indicates in band ring state. 1947aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * <p>Value: 1957aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * 0 - in band ring tone not supported, or 1967aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * 1 - in band ring tone supported.</p> 1977aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta */ 1987aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta public static final String EXTRA_IN_BAND_RING = 199cf916d34671f0ab6aad8de24c18e4dc96fb21941Mike Lockwood "android.bluetooth.headsetclient.extra.IN_BAND_RING"; 2007aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta 2017aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta /** 2027aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * Extra for AG_EVENT intent indicates subscriber info. 2037aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * <p>Value: <code>String</code> containing subscriber information.</p> 2047aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta */ 2057aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta public static final String EXTRA_SUBSCRIBER_INFO = 206cf916d34671f0ab6aad8de24c18e4dc96fb21941Mike Lockwood "android.bluetooth.headsetclient.extra.SUBSCRIBER_INFO"; 2077aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta 2087aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta /** 2097aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * Extra for AG_CALL_CHANGED intent indicates the 210cf916d34671f0ab6aad8de24c18e4dc96fb21941Mike Lockwood * {@link BluetoothHeadsetClientCall} object that has changed. 2117aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta */ 2127aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta public static final String EXTRA_CALL = 213cf916d34671f0ab6aad8de24c18e4dc96fb21941Mike Lockwood "android.bluetooth.headsetclient.extra.CALL"; 2147aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta 2157aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta /** 2167aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * Extra for ACTION_LAST_VTAG intent. 2177aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * <p>Value: <code>String</code> representing phone number 2187aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * corresponding to last voice tag recorded on AG</p> 2197aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta */ 2207aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta public static final String EXTRA_NUMBER = 221cf916d34671f0ab6aad8de24c18e4dc96fb21941Mike Lockwood "android.bluetooth.headsetclient.extra.NUMBER"; 2227aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta 2237aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta /** 2247aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * Extra for ACTION_RESULT intent that shows the result code of 2257aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * last issued action. 2267aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * <p>Possible results: 2277aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * {@link #ACTION_RESULT_OK}, 2287aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * {@link #ACTION_RESULT_ERROR}, 2297aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * {@link #ACTION_RESULT_ERROR_NO_CARRIER}, 2307aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * {@link #ACTION_RESULT_ERROR_BUSY}, 2317aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * {@link #ACTION_RESULT_ERROR_NO_ANSWER}, 2327aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * {@link #ACTION_RESULT_ERROR_DELAYED}, 2337aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * {@link #ACTION_RESULT_ERROR_BLACKLISTED}, 2347aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * {@link #ACTION_RESULT_ERROR_CME}</p> 2357aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta */ 2367aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta public static final String EXTRA_RESULT_CODE = 237cf916d34671f0ab6aad8de24c18e4dc96fb21941Mike Lockwood "android.bluetooth.headsetclient.extra.RESULT_CODE"; 2387aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta 2397aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta /** 2407aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * Extra for ACTION_RESULT intent that shows the extended result code of 2417aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * last issued action. 2427aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * <p>Value: <code>Integer</code> - error code.</p> 2437aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta */ 2447aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta public static final String EXTRA_CME_CODE = 245cf916d34671f0ab6aad8de24c18e4dc96fb21941Mike Lockwood "android.bluetooth.headsetclient.extra.CME_CODE"; 2467aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta 2477aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta /* Extras for AG_FEATURES, extras type is boolean */ 2487aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta // TODO verify if all of those are actually useful 2497aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta /** 2507aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * AG feature: three way calling. 2517aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta */ 2527aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta public final static String EXTRA_AG_FEATURE_3WAY_CALLING = 253cf916d34671f0ab6aad8de24c18e4dc96fb21941Mike Lockwood "android.bluetooth.headsetclient.extra.EXTRA_AG_FEATURE_3WAY_CALLING"; 2547aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta /** 2557aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * AG feature: voice recognition. 2567aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta */ 2577aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta public final static String EXTRA_AG_FEATURE_VOICE_RECOGNITION = 258cf916d34671f0ab6aad8de24c18e4dc96fb21941Mike Lockwood "android.bluetooth.headsetclient.extra.EXTRA_AG_FEATURE_VOICE_RECOGNITION"; 2597aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta /** 2607aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * AG feature: fetching phone number for voice tagging procedure. 2617aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta */ 2627aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta public final static String EXTRA_AG_FEATURE_ATTACH_NUMBER_TO_VT = 263cf916d34671f0ab6aad8de24c18e4dc96fb21941Mike Lockwood "android.bluetooth.headsetclient.extra.EXTRA_AG_FEATURE_ATTACH_NUMBER_TO_VT"; 2647aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta /** 2657aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * AG feature: ability to reject incoming call. 2667aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta */ 2677aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta public final static String EXTRA_AG_FEATURE_REJECT_CALL = 268cf916d34671f0ab6aad8de24c18e4dc96fb21941Mike Lockwood "android.bluetooth.headsetclient.extra.EXTRA_AG_FEATURE_REJECT_CALL"; 2697aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta /** 2707aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * AG feature: enhanced call handling (terminate specific call, private consultation). 2717aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta */ 2727aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta public final static String EXTRA_AG_FEATURE_ECC = 273cf916d34671f0ab6aad8de24c18e4dc96fb21941Mike Lockwood "android.bluetooth.headsetclient.extra.EXTRA_AG_FEATURE_ECC"; 2747aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta /** 2757aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * AG feature: response and hold. 2767aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta */ 2777aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta public final static String EXTRA_AG_FEATURE_RESPONSE_AND_HOLD = 278cf916d34671f0ab6aad8de24c18e4dc96fb21941Mike Lockwood "android.bluetooth.headsetclient.extra.EXTRA_AG_FEATURE_RESPONSE_AND_HOLD"; 2797aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta /** 2807aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * AG call handling feature: accept held or waiting call in three way calling scenarios. 2817aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta */ 2827aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta public final static String EXTRA_AG_FEATURE_ACCEPT_HELD_OR_WAITING_CALL = 283cf916d34671f0ab6aad8de24c18e4dc96fb21941Mike Lockwood "android.bluetooth.headsetclient.extra.EXTRA_AG_FEATURE_ACCEPT_HELD_OR_WAITING_CALL"; 2847aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta /** 2857aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * AG call handling feature: release held or waiting call in three way calling scenarios. 2867aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta */ 2877aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta public final static String EXTRA_AG_FEATURE_RELEASE_HELD_OR_WAITING_CALL = 288cf916d34671f0ab6aad8de24c18e4dc96fb21941Mike Lockwood "android.bluetooth.headsetclient.extra.EXTRA_AG_FEATURE_RELEASE_HELD_OR_WAITING_CALL"; 2897aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta /** 2907aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * AG call handling feature: release active call and accept held or waiting call in three way 2917aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * calling scenarios. 2927aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta */ 2937aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta public final static String EXTRA_AG_FEATURE_RELEASE_AND_ACCEPT = 294cf916d34671f0ab6aad8de24c18e4dc96fb21941Mike Lockwood "android.bluetooth.headsetclient.extra.EXTRA_AG_FEATURE_RELEASE_AND_ACCEPT"; 2957aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta /** 2967aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * AG call handling feature: merge two calls, held and active - multi party conference mode. 2977aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta */ 2987aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta public final static String EXTRA_AG_FEATURE_MERGE = 299cf916d34671f0ab6aad8de24c18e4dc96fb21941Mike Lockwood "android.bluetooth.headsetclient.extra.EXTRA_AG_FEATURE_MERGE"; 3007aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta /** 3017aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * AG call handling feature: merge calls and disconnect from multi party 3027aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * conversation leaving peers connected to each other. 3037aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * Note that this feature needs to be supported by mobile network operator 3047aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * as it requires connection and billing transfer. 3057aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta */ 3067aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta public final static String EXTRA_AG_FEATURE_MERGE_AND_DETACH = 307cf916d34671f0ab6aad8de24c18e4dc96fb21941Mike Lockwood "android.bluetooth.headsetclient.extra.EXTRA_AG_FEATURE_MERGE_AND_DETACH"; 3087aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta 3097aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta /* Action result codes */ 3107aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta public final static int ACTION_RESULT_OK = 0; 3117aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta public final static int ACTION_RESULT_ERROR = 1; 3127aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta public final static int ACTION_RESULT_ERROR_NO_CARRIER = 2; 3137aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta public final static int ACTION_RESULT_ERROR_BUSY = 3; 3147aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta public final static int ACTION_RESULT_ERROR_NO_ANSWER = 4; 3157aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta public final static int ACTION_RESULT_ERROR_DELAYED = 5; 3167aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta public final static int ACTION_RESULT_ERROR_BLACKLISTED = 6; 3177aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta public final static int ACTION_RESULT_ERROR_CME = 7; 3187aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta 3197aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta /* Detailed CME error codes */ 3207aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta public final static int CME_PHONE_FAILURE = 0; 3217aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta public final static int CME_NO_CONNECTION_TO_PHONE = 1; 3227aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta public final static int CME_OPERATION_NOT_ALLOWED = 3; 3237aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta public final static int CME_OPERATION_NOT_SUPPORTED = 4; 3247aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta public final static int CME_PHSIM_PIN_REQUIRED = 5; 3257aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta public final static int CME_PHFSIM_PIN_REQUIRED = 6; 3267aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta public final static int CME_PHFSIM_PUK_REQUIRED = 7; 3277aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta public final static int CME_SIM_NOT_INSERTED = 10; 3287aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta public final static int CME_SIM_PIN_REQUIRED = 11; 3297aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta public final static int CME_SIM_PUK_REQUIRED = 12; 3307aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta public final static int CME_SIM_FAILURE = 13; 3317aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta public final static int CME_SIM_BUSY = 14; 3327aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta public final static int CME_SIM_WRONG = 15; 3337aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta public final static int CME_INCORRECT_PASSWORD = 16; 3347aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta public final static int CME_SIM_PIN2_REQUIRED = 17; 3357aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta public final static int CME_SIM_PUK2_REQUIRED = 18; 3367aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta public final static int CME_MEMORY_FULL = 20; 3377aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta public final static int CME_INVALID_INDEX = 21; 3387aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta public final static int CME_NOT_FOUND = 22; 3397aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta public final static int CME_MEMORY_FAILURE = 23; 3407aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta public final static int CME_TEXT_STRING_TOO_LONG = 24; 3417aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta public final static int CME_INVALID_CHARACTER_IN_TEXT_STRING = 25; 3427aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta public final static int CME_DIAL_STRING_TOO_LONG = 26; 3437aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta public final static int CME_INVALID_CHARACTER_IN_DIAL_STRING = 27; 3447aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta public final static int CME_NO_NETWORK_SERVICE = 30; 3457aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta public final static int CME_NETWORK_TIMEOUT = 31; 3467aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta public final static int CME_EMERGENCY_SERVICE_ONLY = 32; 3477aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta public final static int CME_NO_SIMULTANOUS_VOIP_CS_CALLS = 33; 3487aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta public final static int CME_NOT_SUPPORTED_FOR_VOIP = 34; 3497aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta public final static int CME_SIP_RESPONSE_CODE = 35; 3507aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta public final static int CME_NETWORK_PERSONALIZATION_PIN_REQUIRED = 40; 3517aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta public final static int CME_NETWORK_PERSONALIZATION_PUK_REQUIRED = 41; 3527aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta public final static int CME_NETWORK_SUBSET_PERSONALIZATION_PIN_REQUIRED = 42; 3537aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta public final static int CME_NETWORK_SUBSET_PERSONALIZATION_PUK_REQUIRED = 43; 3547aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta public final static int CME_SERVICE_PROVIDER_PERSONALIZATION_PIN_REQUIRED = 44; 3557aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta public final static int CME_SERVICE_PROVIDER_PERSONALIZATION_PUK_REQUIRED = 45; 3567aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta public final static int CME_CORPORATE_PERSONALIZATION_PIN_REQUIRED = 46; 3577aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta public final static int CME_CORPORATE_PERSONALIZATION_PUK_REQUIRED = 47; 3587aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta public final static int CME_HIDDEN_KEY_REQUIRED = 48; 3597aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta public final static int CME_EAP_NOT_SUPPORTED = 49; 3607aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta public final static int CME_INCORRECT_PARAMETERS = 50; 3617aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta 3627aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta /* Action policy for other calls when accepting call */ 3637aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta public static final int CALL_ACCEPT_NONE = 0; 3647aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta public static final int CALL_ACCEPT_HOLD = 1; 3657aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta public static final int CALL_ACCEPT_TERMINATE = 2; 3667aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta 3677aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta private Context mContext; 3687aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta private ServiceListener mServiceListener; 369cf916d34671f0ab6aad8de24c18e4dc96fb21941Mike Lockwood private IBluetoothHeadsetClient mService; 3707aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta private BluetoothAdapter mAdapter; 3717aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta 3727aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta final private IBluetoothStateChangeCallback mBluetoothStateChangeCallback = 3737aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta new IBluetoothStateChangeCallback.Stub() { 3747aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta @Override 3757aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta public void onBluetoothStateChange(boolean up) { 3767aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta if (DBG) Log.d(TAG, "onBluetoothStateChange: up=" + up); 3777aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta if (!up) { 3787aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta if (VDBG) Log.d(TAG,"Unbinding service..."); 3797aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta synchronized (mConnection) { 3807aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta try { 3817aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta mService = null; 3827aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta mContext.unbindService(mConnection); 3837aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta } catch (Exception re) { 3847aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta Log.e(TAG,"",re); 3857aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta } 3867aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta } 3877aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta } else { 3887aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta synchronized (mConnection) { 3897aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta try { 3907aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta if (mService == null) { 3917aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta if (VDBG) Log.d(TAG,"Binding service..."); 392cf916d34671f0ab6aad8de24c18e4dc96fb21941Mike Lockwood Intent intent = new Intent(IBluetoothHeadsetClient.class.getName()); 393cf916d34671f0ab6aad8de24c18e4dc96fb21941Mike Lockwood doBind(); 3947aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta } 3957aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta } catch (Exception re) { 3967aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta Log.e(TAG,"",re); 3977aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta } 3987aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta } 3997aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta } 4007aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta } 4017aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta }; 4027aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta 4037aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta /** 404cf916d34671f0ab6aad8de24c18e4dc96fb21941Mike Lockwood * Create a BluetoothHeadsetClient proxy object. 4057aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta */ 406cf916d34671f0ab6aad8de24c18e4dc96fb21941Mike Lockwood /*package*/ BluetoothHeadsetClient(Context context, ServiceListener l) { 4077aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta mContext = context; 4087aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta mServiceListener = l; 4097aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta mAdapter = BluetoothAdapter.getDefaultAdapter(); 4107aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta 4117aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta IBluetoothManager mgr = mAdapter.getBluetoothManager(); 4127aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta if (mgr != null) { 4137aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta try { 4147aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta mgr.registerStateChangeCallback(mBluetoothStateChangeCallback); 4157aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta } catch (RemoteException e) { 4167aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta Log.e(TAG,"",e); 4177aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta } 4187aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta } 4197aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta 420cf916d34671f0ab6aad8de24c18e4dc96fb21941Mike Lockwood doBind(); 421cf916d34671f0ab6aad8de24c18e4dc96fb21941Mike Lockwood } 422cf916d34671f0ab6aad8de24c18e4dc96fb21941Mike Lockwood 423cf916d34671f0ab6aad8de24c18e4dc96fb21941Mike Lockwood boolean doBind() { 424cf916d34671f0ab6aad8de24c18e4dc96fb21941Mike Lockwood Intent intent = new Intent(IBluetoothHeadsetClient.class.getName()); 425cf916d34671f0ab6aad8de24c18e4dc96fb21941Mike Lockwood ComponentName comp = intent.resolveSystemService(mContext.getPackageManager(), 0); 426cf916d34671f0ab6aad8de24c18e4dc96fb21941Mike Lockwood intent.setComponent(comp); 427cf916d34671f0ab6aad8de24c18e4dc96fb21941Mike Lockwood if (comp == null || !mContext.bindServiceAsUser(intent, mConnection, 0, 428cf916d34671f0ab6aad8de24c18e4dc96fb21941Mike Lockwood android.os.Process.myUserHandle())) { 429cf916d34671f0ab6aad8de24c18e4dc96fb21941Mike Lockwood Log.e(TAG, "Could not bind to Bluetooth Headset Client Service with " + intent); 430cf916d34671f0ab6aad8de24c18e4dc96fb21941Mike Lockwood return false; 4317aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta } 432cf916d34671f0ab6aad8de24c18e4dc96fb21941Mike Lockwood return true; 4337aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta } 4347aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta 4357aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta /** 4367aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * Close the connection to the backing service. 437cf916d34671f0ab6aad8de24c18e4dc96fb21941Mike Lockwood * Other public functions of BluetoothHeadsetClient will return default error 4387aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * results once close() has been called. Multiple invocations of close() 4397aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * are ok. 4407aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta */ 4417aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta /*package*/ void close() { 4427aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta if (VDBG) log("close()"); 4437aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta 4447aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta IBluetoothManager mgr = mAdapter.getBluetoothManager(); 4457aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta if (mgr != null) { 4467aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta try { 4477aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta mgr.unregisterStateChangeCallback(mBluetoothStateChangeCallback); 4487aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta } catch (Exception e) { 4497aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta Log.e(TAG,"",e); 4507aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta } 4517aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta } 4527aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta 4537aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta synchronized (mConnection) { 4547aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta if (mService != null) { 4557aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta try { 4567aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta mService = null; 4577aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta mContext.unbindService(mConnection); 4587aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta } catch (Exception re) { 4597aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta Log.e(TAG,"",re); 4607aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta } 4617aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta } 4627aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta } 4637aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta mServiceListener = null; 4647aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta } 4657aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta 4667aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta /** 4677aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * Connects to remote device. 4687aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * 4697aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * Currently, the system supports only 1 connection. So, in case of the 4707aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * second connection, this implementation will disconnect already connected 4717aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * device automatically and will process the new one. 4727aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * 4737aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * @param device a remote device we want connect to 4747aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * @return <code>true</code> if command has been issued successfully; 4757aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * <code>false</code> otherwise; 4767aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * upon completion HFP sends {@link #ACTION_CONNECTION_STATE_CHANGED} 4777aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * intent. 4787aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta */ 4797aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta public boolean connect(BluetoothDevice device) { 4807aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta if (DBG) log("connect(" + device + ")"); 4817aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta if (mService != null && isEnabled() && 4827aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta isValidDevice(device)) { 4837aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta try { 4847aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta return mService.connect(device); 4857aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta } catch (RemoteException e) { 4867aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta Log.e(TAG, Log.getStackTraceString(new Throwable())); 4877aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta return false; 4887aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta } 4897aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta } 4907aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta if (mService == null) Log.w(TAG, "Proxy not attached to service"); 4917aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta return false; 4927aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta } 4937aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta 4947aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta /** 4957aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * Disconnects remote device 4967aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * 4977aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * @param device a remote device we want disconnect 4987aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * @return <code>true</code> if command has been issued successfully; 4997aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * <code>false</code> otherwise; 5007aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * upon completion HFP sends {@link #ACTION_CONNECTION_STATE_CHANGED} 5017aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * intent. 5027aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta */ 5037aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta public boolean disconnect(BluetoothDevice device) { 5047aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta if (DBG) log("disconnect(" + device + ")"); 5057aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta if (mService != null && isEnabled() && 5067aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta isValidDevice(device)) { 5077aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta try { 5087aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta return mService.disconnect(device); 5097aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta } catch (RemoteException e) { 5107aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta Log.e(TAG, Log.getStackTraceString(new Throwable())); 5117aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta return false; 5127aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta } 5137aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta } 5147aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta if (mService == null) Log.w(TAG, "Proxy not attached to service"); 5157aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta return false; 5167aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta } 5177aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta 5187aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta /** 5197aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * Return the list of connected remote devices 5207aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * 5217aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * @return list of connected devices; empty list if nothing is connected. 5227aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta */ 5237aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta @Override 5247aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta public List<BluetoothDevice> getConnectedDevices() { 5257aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta if (VDBG) log("getConnectedDevices()"); 5267aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta if (mService != null && isEnabled()) { 5277aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta try { 5287aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta return mService.getConnectedDevices(); 5297aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta } catch (RemoteException e) { 5307aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta Log.e(TAG, Log.getStackTraceString(new Throwable())); 5317aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta return new ArrayList<BluetoothDevice>(); 5327aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta } 5337aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta } 5347aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta if (mService == null) Log.w(TAG, "Proxy not attached to service"); 5357aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta return new ArrayList<BluetoothDevice>(); 5367aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta } 5377aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta 5387aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta /** 5397aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * Returns list of remote devices in a particular state 5407aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * 5417aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * @param states collection of states 5427aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * @return list of devices that state matches the states listed in 5437aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * <code>states</code>; empty list if nothing matches the 5447aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * <code>states</code> 5457aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta */ 5467aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta @Override 5477aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta public List<BluetoothDevice> getDevicesMatchingConnectionStates(int[] states) { 5487aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta if (VDBG) log("getDevicesMatchingStates()"); 5497aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta if (mService != null && isEnabled()) { 5507aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta try { 5517aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta return mService.getDevicesMatchingConnectionStates(states); 5527aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta } catch (RemoteException e) { 5537aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta Log.e(TAG, Log.getStackTraceString(new Throwable())); 5547aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta return new ArrayList<BluetoothDevice>(); 5557aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta } 5567aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta } 5577aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta if (mService == null) Log.w(TAG, "Proxy not attached to service"); 5587aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta return new ArrayList<BluetoothDevice>(); 5597aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta } 5607aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta 5617aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta /** 5627aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * Returns state of the <code>device</code> 5637aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * 5647aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * @param device a remote device 5657aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * @return the state of connection of the device 5667aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta */ 5677aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta @Override 5687aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta public int getConnectionState(BluetoothDevice device) { 5697aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta if (VDBG) log("getConnectionState(" + device + ")"); 5707aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta if (mService != null && isEnabled() && 5717aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta isValidDevice(device)) { 5727aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta try { 5737aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta return mService.getConnectionState(device); 5747aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta } catch (RemoteException e) { 5757aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta Log.e(TAG, Log.getStackTraceString(new Throwable())); 5767aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta return BluetoothProfile.STATE_DISCONNECTED; 5777aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta } 5787aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta } 5797aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta if (mService == null) Log.w(TAG, "Proxy not attached to service"); 5807aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta return BluetoothProfile.STATE_DISCONNECTED; 5817aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta } 5827aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta 5837aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta /** 5847aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * Set priority of the profile 5857aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * 5867aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * The device should already be paired. 5877aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta */ 5887aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta public boolean setPriority(BluetoothDevice device, int priority) { 5897aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta if (DBG) log("setPriority(" + device + ", " + priority + ")"); 5907aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta if (mService != null && isEnabled() && 5917aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta isValidDevice(device)) { 5927aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta if (priority != BluetoothProfile.PRIORITY_OFF && 5937aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta priority != BluetoothProfile.PRIORITY_ON) { 5947aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta return false; 5957aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta } 5967aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta try { 5977aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta return mService.setPriority(device, priority); 5987aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta } catch (RemoteException e) { 5997aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta Log.e(TAG, Log.getStackTraceString(new Throwable())); 6007aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta return false; 6017aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta } 6027aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta } 6037aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta if (mService == null) Log.w(TAG, "Proxy not attached to service"); 6047aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta return false; 6057aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta } 6067aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta 6077aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta /** 6087aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * Get the priority of the profile. 6097aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta */ 6107aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta public int getPriority(BluetoothDevice device) { 6117aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta if (VDBG) log("getPriority(" + device + ")"); 6127aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta if (mService != null && isEnabled() && 6137aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta isValidDevice(device)) { 6147aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta try { 6157aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta return mService.getPriority(device); 6167aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta } catch (RemoteException e) { 6177aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta Log.e(TAG, Log.getStackTraceString(new Throwable())); 6187aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta return PRIORITY_OFF; 6197aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta } 6207aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta } 6217aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta if (mService == null) Log.w(TAG, "Proxy not attached to service"); 6227aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta return PRIORITY_OFF; 6237aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta } 6247aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta 6257aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta /** 6267aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * Starts voice recognition. 6277aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * 6287aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * @param device remote device 6297aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * @return <code>true</code> if command has been issued successfully; 6307aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * <code>false</code> otherwise; 6317aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * upon completion HFP sends {@link #ACTION_AG_EVENT} 6327aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * intent. 6337aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * 6347aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * <p>Feature required for successful execution is being reported by: 6357aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * {@link #EXTRA_AG_FEATURE_VOICE_RECOGNITION}. 6367aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * This method invocation will fail silently when feature is not supported.</p> 6377aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta */ 6387aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta public boolean startVoiceRecognition(BluetoothDevice device) { 6397aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta if (DBG) log("startVoiceRecognition()"); 6407aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta if (mService != null && isEnabled() && 6417aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta isValidDevice(device)) { 6427aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta try { 6437aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta return mService.startVoiceRecognition(device); 6447aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta } catch (RemoteException e) { 6457aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta Log.e(TAG, Log.getStackTraceString(new Throwable())); 6467aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta } 6477aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta } 6487aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta if (mService == null) Log.w(TAG, "Proxy not attached to service"); 6497aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta return false; 6507aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta } 6517aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta 6527aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta /** 6537aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * Stops voice recognition. 6547aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * 6557aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * @param device remote device 6567aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * @return <code>true</code> if command has been issued successfully; 6577aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * <code>false</code> otherwise; 6587aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * upon completion HFP sends {@link #ACTION_AG_EVENT} 6597aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * intent. 6607aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * 6617aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * <p>Feature required for successful execution is being reported by: 6627aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * {@link #EXTRA_AG_FEATURE_VOICE_RECOGNITION}. 6637aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * This method invocation will fail silently when feature is not supported.</p> 6647aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta */ 6657aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta public boolean stopVoiceRecognition(BluetoothDevice device) { 6667aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta if (DBG) log("stopVoiceRecognition()"); 6677aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta if (mService != null && isEnabled() && 6687aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta isValidDevice(device)) { 6697aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta try { 6707aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta return mService.stopVoiceRecognition(device); 6717aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta } catch (RemoteException e) { 6727aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta Log.e(TAG, Log.getStackTraceString(new Throwable())); 6737aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta } 6747aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta } 6757aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta if (mService == null) Log.w(TAG, "Proxy not attached to service"); 6767aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta return false; 6777aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta } 6787aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta 6797aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta /** 6807aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * Returns list of all calls in any state. 6817aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * 6827aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * @param device remote device 6837aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * @return list of calls; empty list if none call exists 6847aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta */ 685cf916d34671f0ab6aad8de24c18e4dc96fb21941Mike Lockwood public List<BluetoothHeadsetClientCall> getCurrentCalls(BluetoothDevice device) { 6867aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta if (DBG) log("getCurrentCalls()"); 6877aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta if (mService != null && isEnabled() && 6887aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta isValidDevice(device)) { 6897aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta try { 6907aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta return mService.getCurrentCalls(device); 6917aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta } catch (RemoteException e) { 6927aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta Log.e(TAG, Log.getStackTraceString(new Throwable())); 6937aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta } 6947aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta } 6957aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta if (mService == null) Log.w(TAG, "Proxy not attached to service"); 6967aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta return null; 6977aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta } 6987aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta 6997aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta /** 7007aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * Returns list of current values of AG indicators. 7017aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * 7027aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * @param device remote device 7037aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * @return bundle of AG indicators; null if device is not in 7047aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * CONNECTED state 7057aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta */ 7067aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta public Bundle getCurrentAgEvents(BluetoothDevice device) { 7077aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta if (DBG) log("getCurrentCalls()"); 7087aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta if (mService != null && isEnabled() && 7097aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta isValidDevice(device)) { 7107aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta try { 7117aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta return mService.getCurrentAgEvents(device); 7127aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta } catch (RemoteException e) { 7137aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta Log.e(TAG, Log.getStackTraceString(new Throwable())); 7147aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta } 7157aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta } 7167aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta if (mService == null) Log.w(TAG, "Proxy not attached to service"); 7177aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta return null; 7187aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta } 7197aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta 7207aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta /** 7217aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * Accepts a call 7227aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * 7237aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * @param device remote device 7247aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * @param flag action policy while accepting a call. Possible values 7257aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * {@link #CALL_ACCEPT_NONE}, {@link #CALL_ACCEPT_HOLD}, 7267aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * {@link #CALL_ACCEPT_TERMINATE} 7277aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * @return <code>true</code> if command has been issued successfully; 7287aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * <code>false</code> otherwise; 7297aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * upon completion HFP sends {@link #ACTION_CALL_CHANGED} 7307aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * intent. 7317aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta */ 7327aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta public boolean acceptCall(BluetoothDevice device, int flag) { 7337aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta if (DBG) log("acceptCall()"); 7347aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta if (mService != null && isEnabled() && 7357aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta isValidDevice(device)) { 7367aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta try { 7377aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta return mService.acceptCall(device, flag); 7387aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta } catch (RemoteException e) { 7397aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta Log.e(TAG, Log.getStackTraceString(new Throwable())); 7407aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta } 7417aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta } 7427aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta if (mService == null) Log.w(TAG, "Proxy not attached to service"); 7437aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta return false; 7447aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta } 7457aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta 7467aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta /** 7477aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * Holds a call. 7487aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * 7497aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * @param device remote device 7507aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * @return <code>true</code> if command has been issued successfully; 7517aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * <code>false</code> otherwise; 7527aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * upon completion HFP sends {@link #ACTION_CALL_CHANGED} 7537aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * intent. 7547aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta */ 7557aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta public boolean holdCall(BluetoothDevice device) { 7567aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta if (DBG) log("holdCall()"); 7577aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta if (mService != null && isEnabled() && 7587aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta isValidDevice(device)) { 7597aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta try { 7607aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta return mService.holdCall(device); 7617aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta } catch (RemoteException e) { 7627aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta Log.e(TAG, Log.getStackTraceString(new Throwable())); 7637aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta } 7647aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta } 7657aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta if (mService == null) Log.w(TAG, "Proxy not attached to service"); 7667aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta return false; 7677aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta } 7687aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta 7697aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta /** 7707aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * Rejects a call. 7717aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * 7727aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * @param device remote device 7737aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * @return <code>true</code> if command has been issued successfully; 7747aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * <code>false</code> otherwise; 7757aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * upon completion HFP sends {@link #ACTION_CALL_CHANGED} 7767aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * intent. 7777aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * 7787aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * <p>Feature required for successful execution is being reported by: 7797aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * {@link #EXTRA_AG_FEATURE_REJECT_CALL}. 7807aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * This method invocation will fail silently when feature is not supported.</p> 7817aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta */ 7827aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta public boolean rejectCall(BluetoothDevice device) { 7837aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta if (DBG) log("rejectCall()"); 7847aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta if (mService != null && isEnabled() && 7857aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta isValidDevice(device)) { 7867aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta try { 7877aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta return mService.rejectCall(device); 7887aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta } catch (RemoteException e) { 7897aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta Log.e(TAG, Log.getStackTraceString(new Throwable())); 7907aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta } 7917aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta } 7927aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta if (mService == null) Log.w(TAG, "Proxy not attached to service"); 7937aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta return false; 7947aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta } 7957aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta 7967aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta /** 7977aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * Terminates a specified call. 7987aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * 7997aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * Works only when Extended Call Control is supported by Audio Gateway. 8007aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * 8017aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * @param device remote device 8027aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * @param index index of the call to be terminated 8037aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * @return <code>true</code> if command has been issued successfully; 8047aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * <code>false</code> otherwise; 8057aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * upon completion HFP sends {@link #ACTION_CALL_CHANGED} 8067aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * intent. 8077aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * 8087aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * <p>Feature required for successful execution is being reported by: 8097aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * {@link #EXTRA_AG_FEATURE_ECC}. 8107aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * This method invocation will fail silently when feature is not supported.</p> 8117aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta */ 8127aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta public boolean terminateCall(BluetoothDevice device, int index) { 8137aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta if (DBG) log("terminateCall()"); 8147aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta if (mService != null && isEnabled() && 8157aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta isValidDevice(device)) { 8167aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta try { 8177aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta return mService.terminateCall(device, index); 8187aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta } catch (RemoteException e) { 8197aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta Log.e(TAG, Log.getStackTraceString(new Throwable())); 8207aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta } 8217aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta } 8227aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta if (mService == null) Log.w(TAG, "Proxy not attached to service"); 8237aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta return false; 8247aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta } 8257aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta 8267aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta /** 8277aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * Enters private mode with a specified call. 8287aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * 8297aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * Works only when Extended Call Control is supported by Audio Gateway. 8307aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * 8317aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * @param device remote device 8327aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * @param index index of the call to connect in private mode 8337aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * @return <code>true</code> if command has been issued successfully; 8347aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * <code>false</code> otherwise; 8357aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * upon completion HFP sends {@link #ACTION_CALL_CHANGED} 8367aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * intent. 8377aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * 8387aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * <p>Feature required for successful execution is being reported by: 8397aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * {@link #EXTRA_AG_FEATURE_ECC}. 8407aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * This method invocation will fail silently when feature is not supported.</p> 8417aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta */ 8427aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta public boolean enterPrivateMode(BluetoothDevice device, int index) { 8437aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta if (DBG) log("enterPrivateMode()"); 8447aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta if (mService != null && isEnabled() && 8457aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta isValidDevice(device)) { 8467aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta try { 8477aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta return mService.enterPrivateMode(device, index); 8487aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta } catch (RemoteException e) { 8497aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta Log.e(TAG, Log.getStackTraceString(new Throwable())); 8507aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta } 8517aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta } 8527aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta if (mService == null) Log.w(TAG, "Proxy not attached to service"); 8537aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta return false; 8547aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta } 8557aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta 8567aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta /** 8577aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * Performs explicit call transfer. 8587aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * 8597aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * That means connect other calls and disconnect. 8607aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * 8617aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * @param device remote device 8627aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * @return <code>true</code> if command has been issued successfully; 8637aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * <code>false</code> otherwise; 8647aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * upon completion HFP sends {@link #ACTION_CALL_CHANGED} 8657aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * intent. 8667aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * 8677aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * <p>Feature required for successful execution is being reported by: 8687aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * {@link #EXTRA_AG_FEATURE_MERGE_AND_DETACH}. 8697aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * This method invocation will fail silently when feature is not supported.</p> 8707aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta */ 8717aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta public boolean explicitCallTransfer(BluetoothDevice device) { 8727aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta if (DBG) log("explicitCallTransfer()"); 8737aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta if (mService != null && isEnabled() && 8747aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta isValidDevice(device)) { 8757aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta try { 8767aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta return mService.explicitCallTransfer(device); 8777aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta } catch (RemoteException e) { 8787aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta Log.e(TAG, Log.getStackTraceString(new Throwable())); 8797aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta } 8807aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta } 8817aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta if (mService == null) Log.w(TAG, "Proxy not attached to service"); 8827aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta return false; 8837aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta } 8847aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta 8857aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta /** 8867aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * Redials last number from Audio Gateway. 8877aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * 8887aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * @param device remote device 8897aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * @return <code>true</code> if command has been issued successfully; 8907aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * <code>false</code> otherwise; 8917aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * upon completion HFP sends {@link #ACTION_CALL_CHANGED} 8927aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * intent in case of success; {@link #ACTION_RESULT} is sent 8937aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * otherwise; 8947aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta */ 8957aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta public boolean redial(BluetoothDevice device) { 8967aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta if (DBG) log("redial()"); 8977aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta if (mService != null && isEnabled() && 8987aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta isValidDevice(device)) { 8997aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta try { 9007aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta return mService.redial(device); 9017aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta } catch (RemoteException e) { 9027aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta Log.e(TAG, Log.getStackTraceString(new Throwable())); 9037aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta } 9047aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta } 9057aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta if (mService == null) Log.w(TAG, "Proxy not attached to service"); 9067aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta return false; 9077aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta } 9087aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta 9097aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta /** 9107aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * Places a call with specified number. 9117aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * 9127aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * @param device remote device 9137aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * @param number valid phone number 9147aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * @return <code>true</code> if command has been issued successfully; 9157aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * <code>false</code> otherwise; 9167aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * upon completion HFP sends {@link #ACTION_CALL_CHANGED} 9177aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * intent in case of success; {@link #ACTION_RESULT} is sent 9187aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * otherwise; 9197aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta */ 9207aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta public boolean dial(BluetoothDevice device, String number) { 9217aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta if (DBG) log("dial()"); 9227aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta if (mService != null && isEnabled() && 9237aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta isValidDevice(device)) { 9247aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta try { 9257aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta return mService.dial(device, number); 9267aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta } catch (RemoteException e) { 9277aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta Log.e(TAG, Log.getStackTraceString(new Throwable())); 9287aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta } 9297aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta } 9307aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta if (mService == null) Log.w(TAG, "Proxy not attached to service"); 9317aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta return false; 9327aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta } 9337aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta 9347aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta /** 9357aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * Places a call to the number under specified memory location. 9367aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * 9377aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * @param device remote device 9387aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * @param location valid memory location 9397aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * @return <code>true</code> if command has been issued successfully; 9407aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * <code>false</code> otherwise; 9417aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * upon completion HFP sends {@link #ACTION_CALL_CHANGED} 9427aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * intent in case of success; {@link #ACTION_RESULT} is sent 9437aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * otherwise; 9447aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta */ 9457aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta public boolean dialMemory(BluetoothDevice device, int location) { 9467aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta if (DBG) log("dialMemory()"); 9477aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta if (mService != null && isEnabled() && 9487aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta isValidDevice(device)) { 9497aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta try { 9507aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta return mService.dialMemory(device, location); 9517aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta } catch (RemoteException e) { 9527aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta Log.e(TAG, Log.getStackTraceString(new Throwable())); 9537aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta } 9547aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta } 9557aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta if (mService == null) Log.w(TAG, "Proxy not attached to service"); 9567aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta return false; 9577aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta } 9587aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta 9597aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta /** 9607aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * Sends DTMF code. 9617aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * 9627aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * Possible code values : 0,1,2,3,4,5,6,7,8,9,A,B,C,D,*,# 9637aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * 9647aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * @param device remote device 9657aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * @param code ASCII code 9667aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * @return <code>true</code> if command has been issued successfully; 9677aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * <code>false</code> otherwise; 9687aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * upon completion HFP sends {@link #ACTION_RESULT} intent; 9697aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta */ 9707aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta public boolean sendDTMF(BluetoothDevice device, byte code) { 9717aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta if (DBG) log("sendDTMF()"); 9727aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta if (mService != null && isEnabled() && 9737aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta isValidDevice(device)) { 9747aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta try { 9757aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta return mService.sendDTMF(device, code); 9767aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta } catch (RemoteException e) { 9777aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta Log.e(TAG, Log.getStackTraceString(new Throwable())); 9787aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta } 9797aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta } 9807aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta if (mService == null) Log.w(TAG, "Proxy not attached to service"); 9817aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta return false; 9827aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta } 9837aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta 9847aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta /** 9857aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * Get a number corresponding to last voice tag recorded on AG. 9867aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * 9877aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * @param device remote device 9887aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * @return <code>true</code> if command has been issued successfully; 9897aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * <code>false</code> otherwise; 9907aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * upon completion HFP sends {@link #ACTION_LAST_VTAG} 9917aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * or {@link #ACTION_RESULT} intent; 9927aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * 9937aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * <p>Feature required for successful execution is being reported by: 9947aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * {@link #EXTRA_AG_FEATURE_ATTACH_NUMBER_TO_VT}. 9957aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * This method invocation will fail silently when feature is not supported.</p> 9967aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta */ 9977aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta public boolean getLastVoiceTagNumber(BluetoothDevice device) { 9987aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta if (DBG) log("getLastVoiceTagNumber()"); 9997aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta if (mService != null && isEnabled() && 10007aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta isValidDevice(device)) { 10017aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta try { 10027aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta return mService.getLastVoiceTagNumber(device); 10037aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta } catch (RemoteException e) { 10047aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta Log.e(TAG, Log.getStackTraceString(new Throwable())); 10057aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta } 10067aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta } 10077aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta if (mService == null) Log.w(TAG, "Proxy not attached to service"); 10087aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta return false; 10097aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta } 10107aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta 10117aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta /** 10127aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * Accept the incoming connection. 10137aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta */ 10147aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta public boolean acceptIncomingConnect(BluetoothDevice device) { 10157aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta if (DBG) log("acceptIncomingConnect"); 10167aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta if (mService != null && isEnabled()) { 10177aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta try { 10187aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta return mService.acceptIncomingConnect(device); 10197aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta } catch (RemoteException e) {Log.e(TAG, e.toString());} 10207aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta } else { 10217aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta Log.w(TAG, "Proxy not attached to service"); 10227aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta if (DBG) Log.d(TAG, Log.getStackTraceString(new Throwable())); 10237aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta } 10247aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta return false; 10257aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta } 10267aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta 10277aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta /** 10287aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * Reject the incoming connection. 10297aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta */ 10307aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta public boolean rejectIncomingConnect(BluetoothDevice device) { 10317aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta if (DBG) log("rejectIncomingConnect"); 10327aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta if (mService != null) { 10337aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta try { 10347aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta return mService.rejectIncomingConnect(device); 10357aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta } catch (RemoteException e) {Log.e(TAG, e.toString());} 10367aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta } else { 10377aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta Log.w(TAG, "Proxy not attached to service"); 10387aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta if (DBG) Log.d(TAG, Log.getStackTraceString(new Throwable())); 10397aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta } 10407aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta return false; 10417aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta } 10427aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta 10437aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta /** 10447aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * Returns current audio state of Audio Gateway. 10457aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * 10467aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * Note: This is an internal function and shouldn't be exposed 10477aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta */ 10487aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta public int getAudioState(BluetoothDevice device) { 10497aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta if (VDBG) log("getAudioState"); 10507aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta if (mService != null && isEnabled()) { 10517aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta try { 10527aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta return mService.getAudioState(device); 10537aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta } catch (RemoteException e) {Log.e(TAG, e.toString());} 10547aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta } else { 10557aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta Log.w(TAG, "Proxy not attached to service"); 10567aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta if (DBG) Log.d(TAG, Log.getStackTraceString(new Throwable())); 10577aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta } 1058cf916d34671f0ab6aad8de24c18e4dc96fb21941Mike Lockwood return BluetoothHeadsetClient.STATE_AUDIO_DISCONNECTED; 10597aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta } 10607aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta 10617aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta /** 1062dc133826225ea61c71f4a2131956e48ed2b0611aBryce Lee * Sets whether audio routing is allowed. 1063dc133826225ea61c71f4a2131956e48ed2b0611aBryce Lee * 1064dc133826225ea61c71f4a2131956e48ed2b0611aBryce Lee * Note: This is an internal function and shouldn't be exposed 1065dc133826225ea61c71f4a2131956e48ed2b0611aBryce Lee */ 1066dc133826225ea61c71f4a2131956e48ed2b0611aBryce Lee public void setAudioRouteAllowed(boolean allowed) { 1067dc133826225ea61c71f4a2131956e48ed2b0611aBryce Lee if (VDBG) log("setAudioRouteAllowed"); 1068dc133826225ea61c71f4a2131956e48ed2b0611aBryce Lee if (mService != null && isEnabled()) { 1069dc133826225ea61c71f4a2131956e48ed2b0611aBryce Lee try { 1070dc133826225ea61c71f4a2131956e48ed2b0611aBryce Lee mService.setAudioRouteAllowed(allowed); 1071dc133826225ea61c71f4a2131956e48ed2b0611aBryce Lee } catch (RemoteException e) {Log.e(TAG, e.toString());} 1072dc133826225ea61c71f4a2131956e48ed2b0611aBryce Lee } else { 1073dc133826225ea61c71f4a2131956e48ed2b0611aBryce Lee Log.w(TAG, "Proxy not attached to service"); 1074dc133826225ea61c71f4a2131956e48ed2b0611aBryce Lee if (DBG) Log.d(TAG, Log.getStackTraceString(new Throwable())); 1075dc133826225ea61c71f4a2131956e48ed2b0611aBryce Lee } 1076dc133826225ea61c71f4a2131956e48ed2b0611aBryce Lee } 1077dc133826225ea61c71f4a2131956e48ed2b0611aBryce Lee 1078dc133826225ea61c71f4a2131956e48ed2b0611aBryce Lee /** 1079dc133826225ea61c71f4a2131956e48ed2b0611aBryce Lee * Returns whether audio routing is allowed. 1080dc133826225ea61c71f4a2131956e48ed2b0611aBryce Lee * 1081dc133826225ea61c71f4a2131956e48ed2b0611aBryce Lee * Note: This is an internal function and shouldn't be exposed 1082dc133826225ea61c71f4a2131956e48ed2b0611aBryce Lee */ 1083dc133826225ea61c71f4a2131956e48ed2b0611aBryce Lee public boolean getAudioRouteAllowed() { 1084dc133826225ea61c71f4a2131956e48ed2b0611aBryce Lee if (VDBG) log("getAudioRouteAllowed"); 1085dc133826225ea61c71f4a2131956e48ed2b0611aBryce Lee if (mService != null && isEnabled()) { 1086dc133826225ea61c71f4a2131956e48ed2b0611aBryce Lee try { 1087dc133826225ea61c71f4a2131956e48ed2b0611aBryce Lee return mService.getAudioRouteAllowed(); 1088dc133826225ea61c71f4a2131956e48ed2b0611aBryce Lee } catch (RemoteException e) {Log.e(TAG, e.toString());} 1089dc133826225ea61c71f4a2131956e48ed2b0611aBryce Lee } else { 1090dc133826225ea61c71f4a2131956e48ed2b0611aBryce Lee Log.w(TAG, "Proxy not attached to service"); 1091dc133826225ea61c71f4a2131956e48ed2b0611aBryce Lee if (DBG) Log.d(TAG, Log.getStackTraceString(new Throwable())); 1092dc133826225ea61c71f4a2131956e48ed2b0611aBryce Lee } 1093dc133826225ea61c71f4a2131956e48ed2b0611aBryce Lee return false; 1094dc133826225ea61c71f4a2131956e48ed2b0611aBryce Lee } 1095dc133826225ea61c71f4a2131956e48ed2b0611aBryce Lee 1096dc133826225ea61c71f4a2131956e48ed2b0611aBryce Lee /** 10977aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * Initiates a connection of audio channel. 10987aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * 10997aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * It setup SCO channel with remote connected Handsfree AG device. 11007aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * 11017aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * @return <code>true</code> if command has been issued successfully; 11027aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * <code>false</code> otherwise; 11037aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * upon completion HFP sends {@link #ACTION_AUDIO_STATE_CHANGED} 11047aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * intent; 11057aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta */ 11067aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta public boolean connectAudio() { 11077aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta if (mService != null && isEnabled()) { 11087aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta try { 11097aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta return mService.connectAudio(); 11107aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta } catch (RemoteException e) { 11117aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta Log.e(TAG, e.toString()); 11127aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta } 11137aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta } else { 11147aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta Log.w(TAG, "Proxy not attached to service"); 11157aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta if (DBG) Log.d(TAG, Log.getStackTraceString(new Throwable())); 11167aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta } 11177aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta return false; 11187aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta } 11197aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta 11207aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta /** 11217aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * Disconnects audio channel. 11227aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * 11237aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * It tears down the SCO channel from remote AG device. 11247aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * 11257aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * @return <code>true</code> if command has been issued successfully; 11267aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * <code>false</code> otherwise; 11277aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * upon completion HFP sends {@link #ACTION_AUDIO_STATE_CHANGED} 11287aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * intent; 11297aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta */ 11307aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta public boolean disconnectAudio() { 11317aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta if (mService != null && isEnabled()) { 11327aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta try { 11337aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta return mService.disconnectAudio(); 11347aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta } catch (RemoteException e) { 11357aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta Log.e(TAG, e.toString()); 11367aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta } 11377aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta } else { 11387aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta Log.w(TAG, "Proxy not attached to service"); 11397aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta if (DBG) Log.d(TAG, Log.getStackTraceString(new Throwable())); 11407aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta } 11417aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta return false; 11427aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta } 11437aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta 11447aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta /** 11457aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * Get Audio Gateway features 11467aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * 11477aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * @param device remote device 11487aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * @return bundle of AG features; null if no service or 11497aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta * AG not connected 11507aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta */ 11517aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta public Bundle getCurrentAgFeatures(BluetoothDevice device) { 11527aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta if (mService != null && isEnabled()) { 11537aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta try { 11547aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta return mService.getCurrentAgFeatures(device); 11557aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta } catch (RemoteException e) { 11567aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta Log.e(TAG, e.toString()); 11577aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta } 11587aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta } else { 11597aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta Log.w(TAG, "Proxy not attached to service"); 11607aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta if (DBG) Log.d(TAG, Log.getStackTraceString(new Throwable())); 11617aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta } 11627aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta return null; 11637aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta } 11647aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta 11657aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta 11667aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta private ServiceConnection mConnection = new ServiceConnection() { 11677aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta @Override 11687aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta public void onServiceConnected(ComponentName className, IBinder service) { 11697aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta if (DBG) Log.d(TAG, "Proxy object connected"); 1170cf916d34671f0ab6aad8de24c18e4dc96fb21941Mike Lockwood mService = IBluetoothHeadsetClient.Stub.asInterface(service); 11717aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta 11727aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta if (mServiceListener != null) { 1173cf916d34671f0ab6aad8de24c18e4dc96fb21941Mike Lockwood mServiceListener.onServiceConnected(BluetoothProfile.HEADSET_CLIENT, 1174cf916d34671f0ab6aad8de24c18e4dc96fb21941Mike Lockwood BluetoothHeadsetClient.this); 11757aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta } 11767aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta } 11777aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta @Override 11787aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta public void onServiceDisconnected(ComponentName className) { 11797aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta if (DBG) Log.d(TAG, "Proxy object disconnected"); 11807aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta mService = null; 11817aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta if (mServiceListener != null) { 1182cf916d34671f0ab6aad8de24c18e4dc96fb21941Mike Lockwood mServiceListener.onServiceDisconnected(BluetoothProfile.HEADSET_CLIENT); 11837aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta } 11847aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta } 11857aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta }; 11867aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta 11877aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta private boolean isEnabled() { 11887aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta if (mAdapter.getState() == BluetoothAdapter.STATE_ON) return true; 11897aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta return false; 11907aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta } 11917aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta 11927aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta private boolean isValidDevice(BluetoothDevice device) { 11937aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta if (device == null) return false; 11947aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta 11957aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta if (BluetoothAdapter.checkBluetoothAddress(device.getAddress())) return true; 11967aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta return false; 11977aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta } 11987aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta 11997aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta private static void log(String msg) { 12007aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta Log.d(TAG, msg); 12017aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta } 12027aca90fcc0175ab44613bb3e4f3f13fc4a688fa5Hemant Gupta} 1203