diff options
Diffstat (limited to 'framework/java/android/bluetooth/BluetoothHeadsetClient.java')
-rw-r--r-- | framework/java/android/bluetooth/BluetoothHeadsetClient.java | 399 |
1 files changed, 187 insertions, 212 deletions
diff --git a/framework/java/android/bluetooth/BluetoothHeadsetClient.java b/framework/java/android/bluetooth/BluetoothHeadsetClient.java index 544b3b95db..c775cd739e 100644 --- a/framework/java/android/bluetooth/BluetoothHeadsetClient.java +++ b/framework/java/android/bluetooth/BluetoothHeadsetClient.java @@ -28,7 +28,6 @@ import android.util.Log; import java.util.ArrayList; import java.util.List; -import java.util.UUID; /** * Public API to control Hands Free Profile (HFP role only). @@ -38,7 +37,7 @@ import java.util.UUID; * <p> * * @hide - * */ + */ public final class BluetoothHeadsetClient implements BluetoothProfile { private static final String TAG = "BluetoothHeadsetClient"; private static final boolean DBG = true; @@ -71,7 +70,7 @@ public final class BluetoothHeadsetClient implements BluetoothProfile { * and not supported ones are <strong>not</strong> being sent at all.</p> */ public static final String ACTION_CONNECTION_STATE_CHANGED = - "android.bluetooth.headsetclient.profile.action.CONNECTION_STATE_CHANGED"; + "android.bluetooth.headsetclient.profile.action.CONNECTION_STATE_CHANGED"; /** * Intent sent whenever audio state changes. @@ -89,7 +88,7 @@ public final class BluetoothHeadsetClient implements BluetoothProfile { * indicating wide band speech support.</p> */ public static final String ACTION_AUDIO_STATE_CHANGED = - "android.bluetooth.headsetclient.profile.action.AUDIO_STATE_CHANGED"; + "android.bluetooth.headsetclient.profile.action.AUDIO_STATE_CHANGED"; /** * Intent sending updates of the Audio Gateway state. @@ -146,7 +145,7 @@ public final class BluetoothHeadsetClient implements BluetoothProfile { /** * Extra with information if connected audio is WBS. * <p>Possible values: <code>true</code>, - * <code>false</code>.</p> + * <code>false</code>.</p> */ public static final String EXTRA_AUDIO_WBS = "android.bluetooth.headsetclient.extra.AUDIO_WBS"; @@ -154,7 +153,7 @@ public final class BluetoothHeadsetClient implements BluetoothProfile { /** * Extra for AG_EVENT indicates network status. * <p>Value: 0 - network unavailable, - * 1 - network available </p> + * 1 - network available </p> */ public static final String EXTRA_NETWORK_STATUS = "android.bluetooth.headsetclient.extra.NETWORK_STATUS"; @@ -167,7 +166,7 @@ public final class BluetoothHeadsetClient implements BluetoothProfile { /** * Extra for AG_EVENT intent indicates roaming state. * <p>Value: 0 - no roaming - * 1 - active roaming</p> + * 1 - active roaming</p> */ public static final String EXTRA_NETWORK_ROAMING = "android.bluetooth.headsetclient.extra.NETWORK_ROAMING"; @@ -186,16 +185,16 @@ public final class BluetoothHeadsetClient implements BluetoothProfile { /** * Extra for AG_EVENT intent indicates voice recognition state. * <p>Value: - * 0 - voice recognition stopped, - * 1 - voice recognition started.</p> + * 0 - voice recognition stopped, + * 1 - voice recognition started.</p> */ public static final String EXTRA_VOICE_RECOGNITION = "android.bluetooth.headsetclient.extra.VOICE_RECOGNITION"; /** * Extra for AG_EVENT intent indicates in band ring state. * <p>Value: - * 0 - in band ring tone not supported, or - * 1 - in band ring tone supported.</p> + * 0 - in band ring tone not supported, or + * 1 - in band ring tone supported.</p> */ public static final String EXTRA_IN_BAND_RING = "android.bluetooth.headsetclient.extra.IN_BAND_RING"; @@ -208,8 +207,8 @@ public final class BluetoothHeadsetClient implements BluetoothProfile { "android.bluetooth.headsetclient.extra.SUBSCRIBER_INFO"; /** - * Extra for AG_CALL_CHANGED intent indicates the - * {@link BluetoothHeadsetClientCall} object that has changed. + * Extra for AG_CALL_CHANGED intent indicates the + * {@link BluetoothHeadsetClientCall} object that has changed. */ public static final String EXTRA_CALL = "android.bluetooth.headsetclient.extra.CALL"; @@ -319,47 +318,47 @@ public final class BluetoothHeadsetClient implements BluetoothProfile { public final static int ACTION_RESULT_ERROR_CME = 7; /* Detailed CME error codes */ - public final static int CME_PHONE_FAILURE = 0; - public final static int CME_NO_CONNECTION_TO_PHONE = 1; - public final static int CME_OPERATION_NOT_ALLOWED = 3; - public final static int CME_OPERATION_NOT_SUPPORTED = 4; - public final static int CME_PHSIM_PIN_REQUIRED = 5; - public final static int CME_PHFSIM_PIN_REQUIRED = 6; - public final static int CME_PHFSIM_PUK_REQUIRED = 7; - public final static int CME_SIM_NOT_INSERTED = 10; - public final static int CME_SIM_PIN_REQUIRED = 11; - public final static int CME_SIM_PUK_REQUIRED = 12; - public final static int CME_SIM_FAILURE = 13; - public final static int CME_SIM_BUSY = 14; - public final static int CME_SIM_WRONG = 15; - public final static int CME_INCORRECT_PASSWORD = 16; - public final static int CME_SIM_PIN2_REQUIRED = 17; - public final static int CME_SIM_PUK2_REQUIRED = 18; - public final static int CME_MEMORY_FULL = 20; - public final static int CME_INVALID_INDEX = 21; - public final static int CME_NOT_FOUND = 22; - public final static int CME_MEMORY_FAILURE = 23; - public final static int CME_TEXT_STRING_TOO_LONG = 24; - public final static int CME_INVALID_CHARACTER_IN_TEXT_STRING = 25; - public final static int CME_DIAL_STRING_TOO_LONG = 26; - public final static int CME_INVALID_CHARACTER_IN_DIAL_STRING = 27; - public final static int CME_NO_NETWORK_SERVICE = 30; - public final static int CME_NETWORK_TIMEOUT = 31; - public final static int CME_EMERGENCY_SERVICE_ONLY = 32; - public final static int CME_NO_SIMULTANOUS_VOIP_CS_CALLS = 33; - public final static int CME_NOT_SUPPORTED_FOR_VOIP = 34; - public final static int CME_SIP_RESPONSE_CODE = 35; - public final static int CME_NETWORK_PERSONALIZATION_PIN_REQUIRED = 40; - public final static int CME_NETWORK_PERSONALIZATION_PUK_REQUIRED = 41; - public final static int CME_NETWORK_SUBSET_PERSONALIZATION_PIN_REQUIRED = 42; - public final static int CME_NETWORK_SUBSET_PERSONALIZATION_PUK_REQUIRED = 43; + public final static int CME_PHONE_FAILURE = 0; + public final static int CME_NO_CONNECTION_TO_PHONE = 1; + public final static int CME_OPERATION_NOT_ALLOWED = 3; + public final static int CME_OPERATION_NOT_SUPPORTED = 4; + public final static int CME_PHSIM_PIN_REQUIRED = 5; + public final static int CME_PHFSIM_PIN_REQUIRED = 6; + public final static int CME_PHFSIM_PUK_REQUIRED = 7; + public final static int CME_SIM_NOT_INSERTED = 10; + public final static int CME_SIM_PIN_REQUIRED = 11; + public final static int CME_SIM_PUK_REQUIRED = 12; + public final static int CME_SIM_FAILURE = 13; + public final static int CME_SIM_BUSY = 14; + public final static int CME_SIM_WRONG = 15; + public final static int CME_INCORRECT_PASSWORD = 16; + public final static int CME_SIM_PIN2_REQUIRED = 17; + public final static int CME_SIM_PUK2_REQUIRED = 18; + public final static int CME_MEMORY_FULL = 20; + public final static int CME_INVALID_INDEX = 21; + public final static int CME_NOT_FOUND = 22; + public final static int CME_MEMORY_FAILURE = 23; + public final static int CME_TEXT_STRING_TOO_LONG = 24; + public final static int CME_INVALID_CHARACTER_IN_TEXT_STRING = 25; + public final static int CME_DIAL_STRING_TOO_LONG = 26; + public final static int CME_INVALID_CHARACTER_IN_DIAL_STRING = 27; + public final static int CME_NO_NETWORK_SERVICE = 30; + public final static int CME_NETWORK_TIMEOUT = 31; + public final static int CME_EMERGENCY_SERVICE_ONLY = 32; + public final static int CME_NO_SIMULTANOUS_VOIP_CS_CALLS = 33; + public final static int CME_NOT_SUPPORTED_FOR_VOIP = 34; + public final static int CME_SIP_RESPONSE_CODE = 35; + public final static int CME_NETWORK_PERSONALIZATION_PIN_REQUIRED = 40; + public final static int CME_NETWORK_PERSONALIZATION_PUK_REQUIRED = 41; + public final static int CME_NETWORK_SUBSET_PERSONALIZATION_PIN_REQUIRED = 42; + public final static int CME_NETWORK_SUBSET_PERSONALIZATION_PUK_REQUIRED = 43; public final static int CME_SERVICE_PROVIDER_PERSONALIZATION_PIN_REQUIRED = 44; public final static int CME_SERVICE_PROVIDER_PERSONALIZATION_PUK_REQUIRED = 45; - public final static int CME_CORPORATE_PERSONALIZATION_PIN_REQUIRED = 46; - public final static int CME_CORPORATE_PERSONALIZATION_PUK_REQUIRED = 47; - public final static int CME_HIDDEN_KEY_REQUIRED = 48; - public final static int CME_EAP_NOT_SUPPORTED = 49; - public final static int CME_INCORRECT_PARAMETERS = 50; + public final static int CME_CORPORATE_PERSONALIZATION_PIN_REQUIRED = 46; + public final static int CME_CORPORATE_PERSONALIZATION_PUK_REQUIRED = 47; + public final static int CME_HIDDEN_KEY_REQUIRED = 48; + public final static int CME_EAP_NOT_SUPPORTED = 49; + public final static int CME_INCORRECT_PARAMETERS = 50; /* Action policy for other calls when accepting call */ public static final int CALL_ACCEPT_NONE = 0; @@ -377,30 +376,31 @@ public final class BluetoothHeadsetClient implements BluetoothProfile { public void onBluetoothStateChange(boolean up) { if (DBG) Log.d(TAG, "onBluetoothStateChange: up=" + up); if (!up) { - if (VDBG) Log.d(TAG,"Unbinding service..."); + if (VDBG) Log.d(TAG, "Unbinding service..."); synchronized (mConnection) { try { mService = null; mContext.unbindService(mConnection); } catch (Exception re) { - Log.e(TAG,"",re); + Log.e(TAG, "", re); } } } else { synchronized (mConnection) { try { if (mService == null) { - if (VDBG) Log.d(TAG,"Binding service..."); - Intent intent = new Intent(IBluetoothHeadsetClient.class.getName()); + if (VDBG) Log.d(TAG, "Binding service..."); + Intent intent = new Intent( + IBluetoothHeadsetClient.class.getName()); doBind(); } } catch (Exception re) { - Log.e(TAG,"",re); + Log.e(TAG, "", re); } } } } - }; + }; /** * Create a BluetoothHeadsetClient proxy object. @@ -415,7 +415,7 @@ public final class BluetoothHeadsetClient implements BluetoothProfile { try { mgr.registerStateChangeCallback(mBluetoothStateChangeCallback); } catch (RemoteException e) { - Log.e(TAG,"",e); + Log.e(TAG, "", e); } } @@ -427,7 +427,7 @@ public final class BluetoothHeadsetClient implements BluetoothProfile { ComponentName comp = intent.resolveSystemService(mContext.getPackageManager(), 0); intent.setComponent(comp); if (comp == null || !mContext.bindServiceAsUser(intent, mConnection, 0, - android.os.Process.myUserHandle())) { + android.os.Process.myUserHandle())) { Log.e(TAG, "Could not bind to Bluetooth Headset Client Service with " + intent); return false; } @@ -448,7 +448,7 @@ public final class BluetoothHeadsetClient implements BluetoothProfile { try { mgr.unregisterStateChangeCallback(mBluetoothStateChangeCallback); } catch (Exception e) { - Log.e(TAG,"",e); + Log.e(TAG, "", e); } } @@ -458,7 +458,7 @@ public final class BluetoothHeadsetClient implements BluetoothProfile { mService = null; mContext.unbindService(mConnection); } catch (Exception re) { - Log.e(TAG,"",re); + Log.e(TAG, "", re); } } } @@ -472,11 +472,9 @@ public final class BluetoothHeadsetClient implements BluetoothProfile { * second connection, this implementation will disconnect already connected * device automatically and will process the new one. * - * @param device a remote device we want connect to - * @return <code>true</code> if command has been issued successfully; - * <code>false</code> otherwise; - * upon completion HFP sends {@link #ACTION_CONNECTION_STATE_CHANGED} - * intent. + * @param device a remote device we want connect to + * @return <code>true</code> if command has been issued successfully; <code>false</code> + * otherwise; upon completion HFP sends {@link #ACTION_CONNECTION_STATE_CHANGED} intent. */ public boolean connect(BluetoothDevice device) { if (DBG) log("connect(" + device + ")"); @@ -496,11 +494,9 @@ public final class BluetoothHeadsetClient implements BluetoothProfile { /** * Disconnects remote device * - * @param device a remote device we want disconnect - * @return <code>true</code> if command has been issued successfully; - * <code>false</code> otherwise; - * upon completion HFP sends {@link #ACTION_CONNECTION_STATE_CHANGED} - * intent. + * @param device a remote device we want disconnect + * @return <code>true</code> if command has been issued successfully; <code>false</code> + * otherwise; upon completion HFP sends {@link #ACTION_CONNECTION_STATE_CHANGED} intent. */ public boolean disconnect(BluetoothDevice device) { if (DBG) log("disconnect(" + device + ")"); @@ -509,8 +505,8 @@ public final class BluetoothHeadsetClient implements BluetoothProfile { try { return mService.disconnect(device); } catch (RemoteException e) { - Log.e(TAG, Log.getStackTraceString(new Throwable())); - return false; + Log.e(TAG, Log.getStackTraceString(new Throwable())); + return false; } } if (mService == null) Log.w(TAG, "Proxy not attached to service"); @@ -540,10 +536,9 @@ public final class BluetoothHeadsetClient implements BluetoothProfile { /** * Returns list of remote devices in a particular state * - * @param states collection of states - * @return list of devices that state matches the states listed in - * <code>states</code>; empty list if nothing matches the - * <code>states</code> + * @param states collection of states + * @return list of devices that state matches the states listed in <code>states</code>; empty + * list if nothing matches the <code>states</code> */ @Override public List<BluetoothDevice> getDevicesMatchingConnectionStates(int[] states) { @@ -563,8 +558,8 @@ public final class BluetoothHeadsetClient implements BluetoothProfile { /** * Returns state of the <code>device</code> * - * @param device a remote device - * @return the state of connection of the device + * @param device a remote device + * @return the state of connection of the device */ @Override public int getConnectionState(BluetoothDevice device) { @@ -593,7 +588,7 @@ public final class BluetoothHeadsetClient implements BluetoothProfile { isValidDevice(device)) { if (priority != BluetoothProfile.PRIORITY_OFF && priority != BluetoothProfile.PRIORITY_ON) { - return false; + return false; } try { return mService.setPriority(device, priority); @@ -627,15 +622,13 @@ public final class BluetoothHeadsetClient implements BluetoothProfile { /** * Starts voice recognition. * - * @param device remote device - * @return <code>true</code> if command has been issued successfully; - * <code>false</code> otherwise; - * upon completion HFP sends {@link #ACTION_AG_EVENT} - * intent. + * @param device remote device + * @return <code>true</code> if command has been issued successfully; <code>false</code> + * otherwise; upon completion HFP sends {@link #ACTION_AG_EVENT} intent. * - * <p>Feature required for successful execution is being reported by: - * {@link #EXTRA_AG_FEATURE_VOICE_RECOGNITION}. - * This method invocation will fail silently when feature is not supported.</p> + * <p>Feature required for successful execution is being reported by: {@link + * #EXTRA_AG_FEATURE_VOICE_RECOGNITION}. This method invocation will fail silently when feature + * is not supported.</p> */ public boolean startVoiceRecognition(BluetoothDevice device) { if (DBG) log("startVoiceRecognition()"); @@ -644,7 +637,7 @@ public final class BluetoothHeadsetClient implements BluetoothProfile { try { return mService.startVoiceRecognition(device); } catch (RemoteException e) { - Log.e(TAG, Log.getStackTraceString(new Throwable())); + Log.e(TAG, Log.getStackTraceString(new Throwable())); } } if (mService == null) Log.w(TAG, "Proxy not attached to service"); @@ -654,15 +647,13 @@ public final class BluetoothHeadsetClient implements BluetoothProfile { /** * Stops voice recognition. * - * @param device remote device - * @return <code>true</code> if command has been issued successfully; - * <code>false</code> otherwise; - * upon completion HFP sends {@link #ACTION_AG_EVENT} - * intent. + * @param device remote device + * @return <code>true</code> if command has been issued successfully; <code>false</code> + * otherwise; upon completion HFP sends {@link #ACTION_AG_EVENT} intent. * - * <p>Feature required for successful execution is being reported by: - * {@link #EXTRA_AG_FEATURE_VOICE_RECOGNITION}. - * This method invocation will fail silently when feature is not supported.</p> + * <p>Feature required for successful execution is being reported by: {@link + * #EXTRA_AG_FEATURE_VOICE_RECOGNITION}. This method invocation will fail silently when feature + * is not supported.</p> */ public boolean stopVoiceRecognition(BluetoothDevice device) { if (DBG) log("stopVoiceRecognition()"); @@ -671,7 +662,7 @@ public final class BluetoothHeadsetClient implements BluetoothProfile { try { return mService.stopVoiceRecognition(device); } catch (RemoteException e) { - Log.e(TAG, Log.getStackTraceString(new Throwable())); + Log.e(TAG, Log.getStackTraceString(new Throwable())); } } if (mService == null) Log.w(TAG, "Proxy not attached to service"); @@ -681,8 +672,8 @@ public final class BluetoothHeadsetClient implements BluetoothProfile { /** * Returns list of all calls in any state. * - * @param device remote device - * @return list of calls; empty list if none call exists + * @param device remote device + * @return list of calls; empty list if none call exists */ public List<BluetoothHeadsetClientCall> getCurrentCalls(BluetoothDevice device) { if (DBG) log("getCurrentCalls()"); @@ -691,7 +682,7 @@ public final class BluetoothHeadsetClient implements BluetoothProfile { try { return mService.getCurrentCalls(device); } catch (RemoteException e) { - Log.e(TAG, Log.getStackTraceString(new Throwable())); + Log.e(TAG, Log.getStackTraceString(new Throwable())); } } if (mService == null) Log.w(TAG, "Proxy not attached to service"); @@ -701,9 +692,8 @@ public final class BluetoothHeadsetClient implements BluetoothProfile { /** * Returns list of current values of AG indicators. * - * @param device remote device - * @return bundle of AG indicators; null if device is not in - * CONNECTED state + * @param device remote device + * @return bundle of AG indicators; null if device is not in CONNECTED state */ public Bundle getCurrentAgEvents(BluetoothDevice device) { if (DBG) log("getCurrentCalls()"); @@ -712,7 +702,7 @@ public final class BluetoothHeadsetClient implements BluetoothProfile { try { return mService.getCurrentAgEvents(device); } catch (RemoteException e) { - Log.e(TAG, Log.getStackTraceString(new Throwable())); + Log.e(TAG, Log.getStackTraceString(new Throwable())); } } if (mService == null) Log.w(TAG, "Proxy not attached to service"); @@ -722,14 +712,11 @@ public final class BluetoothHeadsetClient implements BluetoothProfile { /** * Accepts a call * - * @param device remote device - * @param flag action policy while accepting a call. Possible values - * {@link #CALL_ACCEPT_NONE}, {@link #CALL_ACCEPT_HOLD}, - * {@link #CALL_ACCEPT_TERMINATE} - * @return <code>true</code> if command has been issued successfully; - * <code>false</code> otherwise; - * upon completion HFP sends {@link #ACTION_CALL_CHANGED} - * intent. + * @param device remote device + * @param flag action policy while accepting a call. Possible values {@link #CALL_ACCEPT_NONE}, + * {@link #CALL_ACCEPT_HOLD}, {@link #CALL_ACCEPT_TERMINATE} + * @return <code>true</code> if command has been issued successfully; <code>false</code> + * otherwise; upon completion HFP sends {@link #ACTION_CALL_CHANGED} intent. */ public boolean acceptCall(BluetoothDevice device, int flag) { if (DBG) log("acceptCall()"); @@ -738,7 +725,7 @@ public final class BluetoothHeadsetClient implements BluetoothProfile { try { return mService.acceptCall(device, flag); } catch (RemoteException e) { - Log.e(TAG, Log.getStackTraceString(new Throwable())); + Log.e(TAG, Log.getStackTraceString(new Throwable())); } } if (mService == null) Log.w(TAG, "Proxy not attached to service"); @@ -748,11 +735,9 @@ public final class BluetoothHeadsetClient implements BluetoothProfile { /** * Holds a call. * - * @param device remote device - * @return <code>true</code> if command has been issued successfully; - * <code>false</code> otherwise; - * upon completion HFP sends {@link #ACTION_CALL_CHANGED} - * intent. + * @param device remote device + * @return <code>true</code> if command has been issued successfully; <code>false</code> + * otherwise; upon completion HFP sends {@link #ACTION_CALL_CHANGED} intent. */ public boolean holdCall(BluetoothDevice device) { if (DBG) log("holdCall()"); @@ -761,7 +746,7 @@ public final class BluetoothHeadsetClient implements BluetoothProfile { try { return mService.holdCall(device); } catch (RemoteException e) { - Log.e(TAG, Log.getStackTraceString(new Throwable())); + Log.e(TAG, Log.getStackTraceString(new Throwable())); } } if (mService == null) Log.w(TAG, "Proxy not attached to service"); @@ -771,15 +756,13 @@ public final class BluetoothHeadsetClient implements BluetoothProfile { /** * Rejects a call. * - * @param device remote device - * @return <code>true</code> if command has been issued successfully; - * <code>false</code> otherwise; - * upon completion HFP sends {@link #ACTION_CALL_CHANGED} - * intent. + * @param device remote device + * @return <code>true</code> if command has been issued successfully; <code>false</code> + * otherwise; upon completion HFP sends {@link #ACTION_CALL_CHANGED} intent. * - * <p>Feature required for successful execution is being reported by: - * {@link #EXTRA_AG_FEATURE_REJECT_CALL}. - * This method invocation will fail silently when feature is not supported.</p> + * <p>Feature required for successful execution is being reported by: {@link + * #EXTRA_AG_FEATURE_REJECT_CALL}. This method invocation will fail silently when feature is not + * supported.</p> */ public boolean rejectCall(BluetoothDevice device) { if (DBG) log("rejectCall()"); @@ -788,7 +771,7 @@ public final class BluetoothHeadsetClient implements BluetoothProfile { try { return mService.rejectCall(device); } catch (RemoteException e) { - Log.e(TAG, Log.getStackTraceString(new Throwable())); + Log.e(TAG, Log.getStackTraceString(new Throwable())); } } if (mService == null) Log.w(TAG, "Proxy not attached to service"); @@ -800,18 +783,16 @@ public final class BluetoothHeadsetClient implements BluetoothProfile { * * Works only when Extended Call Control is supported by Audio Gateway. * - * @param device remote device - * @param call Handle of call obtained in {@link dial()} or obtained via - * {@link ACTION_CALL_CHANGED}. {@code call} may be null in which - * case we will hangup all active calls. - * @return <code>true</code> if command has been issued successfully; - * <code>false</code> otherwise; - * upon completion HFP sends {@link #ACTION_CALL_CHANGED} - * intent. + * @param device remote device + * @param call Handle of call obtained in {@link dial()} or obtained via {@link + * ACTION_CALL_CHANGED}. {@code call} may be null in which case we will hangup all active + * calls. + * @return <code>true</code> if command has been issued successfully; <code>false</code> + * otherwise; upon completion HFP sends {@link #ACTION_CALL_CHANGED} intent. * - * <p>Feature required for successful execution is being reported by: - * {@link #EXTRA_AG_FEATURE_ECC}. - * This method invocation will fail silently when feature is not supported.</p> + * <p>Feature required for successful execution is being reported by: {@link + * #EXTRA_AG_FEATURE_ECC}. This method invocation will fail silently when feature is not + * supported.</p> */ public boolean terminateCall(BluetoothDevice device, BluetoothHeadsetClientCall call) { if (DBG) log("terminateCall()"); @@ -820,7 +801,7 @@ public final class BluetoothHeadsetClient implements BluetoothProfile { try { return mService.terminateCall(device, call); } catch (RemoteException e) { - Log.e(TAG, Log.getStackTraceString(new Throwable())); + Log.e(TAG, Log.getStackTraceString(new Throwable())); } } if (mService == null) Log.w(TAG, "Proxy not attached to service"); @@ -832,16 +813,14 @@ public final class BluetoothHeadsetClient implements BluetoothProfile { * * Works only when Extended Call Control is supported by Audio Gateway. * - * @param device remote device - * @param index index of the call to connect in private mode - * @return <code>true</code> if command has been issued successfully; - * <code>false</code> otherwise; - * upon completion HFP sends {@link #ACTION_CALL_CHANGED} - * intent. + * @param device remote device + * @param index index of the call to connect in private mode + * @return <code>true</code> if command has been issued successfully; <code>false</code> + * otherwise; upon completion HFP sends {@link #ACTION_CALL_CHANGED} intent. * - * <p>Feature required for successful execution is being reported by: - * {@link #EXTRA_AG_FEATURE_ECC}. - * This method invocation will fail silently when feature is not supported.</p> + * <p>Feature required for successful execution is being reported by: {@link + * #EXTRA_AG_FEATURE_ECC}. This method invocation will fail silently when feature is not + * supported.</p> */ public boolean enterPrivateMode(BluetoothDevice device, int index) { if (DBG) log("enterPrivateMode()"); @@ -850,7 +829,7 @@ public final class BluetoothHeadsetClient implements BluetoothProfile { try { return mService.enterPrivateMode(device, index); } catch (RemoteException e) { - Log.e(TAG, Log.getStackTraceString(new Throwable())); + Log.e(TAG, Log.getStackTraceString(new Throwable())); } } if (mService == null) Log.w(TAG, "Proxy not attached to service"); @@ -862,15 +841,13 @@ public final class BluetoothHeadsetClient implements BluetoothProfile { * * That means connect other calls and disconnect. * - * @param device remote device - * @return <code>true</code> if command has been issued successfully; - * <code>false</code> otherwise; - * upon completion HFP sends {@link #ACTION_CALL_CHANGED} - * intent. + * @param device remote device + * @return <code>true</code> if command has been issued successfully; <code>false</code> + * otherwise; upon completion HFP sends {@link #ACTION_CALL_CHANGED} intent. * - * <p>Feature required for successful execution is being reported by: - * {@link #EXTRA_AG_FEATURE_MERGE_AND_DETACH}. - * This method invocation will fail silently when feature is not supported.</p> + * <p>Feature required for successful execution is being reported by: {@link + * #EXTRA_AG_FEATURE_MERGE_AND_DETACH}. This method invocation will fail silently when feature + * is not supported.</p> */ public boolean explicitCallTransfer(BluetoothDevice device) { if (DBG) log("explicitCallTransfer()"); @@ -879,7 +856,7 @@ public final class BluetoothHeadsetClient implements BluetoothProfile { try { return mService.explicitCallTransfer(device); } catch (RemoteException e) { - Log.e(TAG, Log.getStackTraceString(new Throwable())); + Log.e(TAG, Log.getStackTraceString(new Throwable())); } } if (mService == null) Log.w(TAG, "Proxy not attached to service"); @@ -889,14 +866,11 @@ public final class BluetoothHeadsetClient implements BluetoothProfile { /** * Places a call with specified number. * - * @param device remote device - * @param number valid phone number - * @return <code>{@link BluetoothHeadsetClientCall} call</code> if command has been - * issued successfully; - * <code>{@link null}</code> otherwise; - * upon completion HFP sends {@link #ACTION_CALL_CHANGED} - * intent in case of success; {@link #ACTION_RESULT} is sent - * otherwise; + * @param device remote device + * @param number valid phone number + * @return <code>{@link BluetoothHeadsetClientCall} call</code> if command has been issued + * successfully; <code>{@link null}</code> otherwise; upon completion HFP sends {@link + * #ACTION_CALL_CHANGED} intent in case of success; {@link #ACTION_RESULT} is sent otherwise; */ public BluetoothHeadsetClientCall dial(BluetoothDevice device, String number) { if (DBG) log("dial()"); @@ -905,7 +879,7 @@ public final class BluetoothHeadsetClient implements BluetoothProfile { try { return mService.dial(device, number); } catch (RemoteException e) { - Log.e(TAG, Log.getStackTraceString(new Throwable())); + Log.e(TAG, Log.getStackTraceString(new Throwable())); } } if (mService == null) Log.w(TAG, "Proxy not attached to service"); @@ -917,11 +891,10 @@ public final class BluetoothHeadsetClient implements BluetoothProfile { * * Possible code values : 0,1,2,3,4,5,6,7,8,9,A,B,C,D,*,# * - * @param device remote device - * @param code ASCII code - * @return <code>true</code> if command has been issued successfully; - * <code>false</code> otherwise; - * upon completion HFP sends {@link #ACTION_RESULT} intent; + * @param device remote device + * @param code ASCII code + * @return <code>true</code> if command has been issued successfully; <code>false</code> + * otherwise; upon completion HFP sends {@link #ACTION_RESULT} intent; */ public boolean sendDTMF(BluetoothDevice device, byte code) { if (DBG) log("sendDTMF()"); @@ -930,7 +903,7 @@ public final class BluetoothHeadsetClient implements BluetoothProfile { try { return mService.sendDTMF(device, code); } catch (RemoteException e) { - Log.e(TAG, Log.getStackTraceString(new Throwable())); + Log.e(TAG, Log.getStackTraceString(new Throwable())); } } if (mService == null) Log.w(TAG, "Proxy not attached to service"); @@ -940,15 +913,14 @@ public final class BluetoothHeadsetClient implements BluetoothProfile { /** * Get a number corresponding to last voice tag recorded on AG. * - * @param device remote device - * @return <code>true</code> if command has been issued successfully; - * <code>false</code> otherwise; - * upon completion HFP sends {@link #ACTION_LAST_VTAG} - * or {@link #ACTION_RESULT} intent; + * @param device remote device + * @return <code>true</code> if command has been issued successfully; <code>false</code> + * otherwise; upon completion HFP sends {@link #ACTION_LAST_VTAG} or {@link #ACTION_RESULT} + * intent; * - * <p>Feature required for successful execution is being reported by: - * {@link #EXTRA_AG_FEATURE_ATTACH_NUMBER_TO_VT}. - * This method invocation will fail silently when feature is not supported.</p> + * <p>Feature required for successful execution is being reported by: {@link + * #EXTRA_AG_FEATURE_ATTACH_NUMBER_TO_VT}. This method invocation will fail silently when + * feature is not supported.</p> */ public boolean getLastVoiceTagNumber(BluetoothDevice device) { if (DBG) log("getLastVoiceTagNumber()"); @@ -957,7 +929,7 @@ public final class BluetoothHeadsetClient implements BluetoothProfile { try { return mService.getLastVoiceTagNumber(device); } catch (RemoteException e) { - Log.e(TAG, Log.getStackTraceString(new Throwable())); + Log.e(TAG, Log.getStackTraceString(new Throwable())); } } if (mService == null) Log.w(TAG, "Proxy not attached to service"); @@ -974,7 +946,9 @@ public final class BluetoothHeadsetClient implements BluetoothProfile { if (mService != null && isEnabled()) { try { return mService.getAudioState(device); - } catch (RemoteException e) {Log.e(TAG, e.toString());} + } catch (RemoteException e) { + Log.e(TAG, e.toString()); + } } else { Log.w(TAG, "Proxy not attached to service"); if (DBG) Log.d(TAG, Log.getStackTraceString(new Throwable())); @@ -985,16 +959,18 @@ public final class BluetoothHeadsetClient implements BluetoothProfile { /** * Sets whether audio routing is allowed. * - * @param device remote device - * @param allowed if routing is allowed to the device - * Note: This is an internal function and shouldn't be exposed + * @param device remote device + * @param allowed if routing is allowed to the device Note: This is an internal function and + * shouldn't be exposed */ public void setAudioRouteAllowed(BluetoothDevice device, boolean allowed) { if (VDBG) log("setAudioRouteAllowed"); if (mService != null && isEnabled()) { try { mService.setAudioRouteAllowed(device, allowed); - } catch (RemoteException e) {Log.e(TAG, e.toString());} + } catch (RemoteException e) { + Log.e(TAG, e.toString()); + } } else { Log.w(TAG, "Proxy not attached to service"); if (DBG) Log.d(TAG, Log.getStackTraceString(new Throwable())); @@ -1003,16 +979,19 @@ public final class BluetoothHeadsetClient implements BluetoothProfile { /** * Returns whether audio routing is allowed. - * @param device remote device - * @return whether the command succeeded - * Note: This is an internal function and shouldn't be exposed + * + * @param device remote device + * @return whether the command succeeded Note: This is an internal function and shouldn't be + * exposed */ public boolean getAudioRouteAllowed(BluetoothDevice device) { if (VDBG) log("getAudioRouteAllowed"); if (mService != null && isEnabled()) { try { return mService.getAudioRouteAllowed(device); - } catch (RemoteException e) {Log.e(TAG, e.toString());} + } catch (RemoteException e) { + Log.e(TAG, e.toString()); + } } else { Log.w(TAG, "Proxy not attached to service"); if (DBG) Log.d(TAG, Log.getStackTraceString(new Throwable())); @@ -1025,11 +1004,9 @@ public final class BluetoothHeadsetClient implements BluetoothProfile { * * It setup SCO channel with remote connected Handsfree AG device. * - * @param device remote device - * @return <code>true</code> if command has been issued successfully; - * <code>false</code> otherwise; - * upon completion HFP sends {@link #ACTION_AUDIO_STATE_CHANGED} - * intent; + * @param device remote device + * @return <code>true</code> if command has been issued successfully; <code>false</code> + * otherwise; upon completion HFP sends {@link #ACTION_AUDIO_STATE_CHANGED} intent; */ public boolean connectAudio(BluetoothDevice device) { if (mService != null && isEnabled()) { @@ -1050,11 +1027,9 @@ public final class BluetoothHeadsetClient implements BluetoothProfile { * * It tears down the SCO channel from remote AG device. * - * @param device remote device - * @return <code>true</code> if command has been issued successfully; - * <code>false</code> otherwise; - * upon completion HFP sends {@link #ACTION_AUDIO_STATE_CHANGED} - * intent; + * @param device remote device + * @return <code>true</code> if command has been issued successfully; <code>false</code> + * otherwise; upon completion HFP sends {@link #ACTION_AUDIO_STATE_CHANGED} intent; */ public boolean disconnectAudio(BluetoothDevice device) { if (mService != null && isEnabled()) { @@ -1073,9 +1048,8 @@ public final class BluetoothHeadsetClient implements BluetoothProfile { /** * Get Audio Gateway features * - * @param device remote device - * @return bundle of AG features; null if no service or - * AG not connected + * @param device remote device + * @return bundle of AG features; null if no service or AG not connected */ public Bundle getCurrentAgFeatures(BluetoothDevice device) { if (mService != null && isEnabled()) { @@ -1103,6 +1077,7 @@ public final class BluetoothHeadsetClient implements BluetoothProfile { BluetoothHeadsetClient.this); } } + @Override public void onServiceDisconnected(ComponentName className) { if (DBG) Log.d(TAG, "Proxy object disconnected"); @@ -1114,15 +1089,15 @@ public final class BluetoothHeadsetClient implements BluetoothProfile { }; private boolean isEnabled() { - if (mAdapter.getState() == BluetoothAdapter.STATE_ON) return true; - return false; + if (mAdapter.getState() == BluetoothAdapter.STATE_ON) return true; + return false; } private boolean isValidDevice(BluetoothDevice device) { - if (device == null) return false; + if (device == null) return false; - if (BluetoothAdapter.checkBluetoothAddress(device.getAddress())) return true; - return false; + if (BluetoothAdapter.checkBluetoothAddress(device.getAddress())) return true; + return false; } private static void log(String msg) { |