summaryrefslogtreecommitdiff
path: root/framework/java/android/bluetooth/BluetoothHeadset.java
diff options
context:
space:
mode:
Diffstat (limited to 'framework/java/android/bluetooth/BluetoothHeadset.java')
-rw-r--r--framework/java/android/bluetooth/BluetoothHeadset.java259
1 files changed, 129 insertions, 130 deletions
diff --git a/framework/java/android/bluetooth/BluetoothHeadset.java b/framework/java/android/bluetooth/BluetoothHeadset.java
index c84643fc46..be1ce63cad 100644
--- a/framework/java/android/bluetooth/BluetoothHeadset.java
+++ b/framework/java/android/bluetooth/BluetoothHeadset.java
@@ -56,9 +56,9 @@ public final class BluetoothHeadset implements BluetoothProfile {
*
* <p>This intent will have 3 extras:
* <ul>
- * <li> {@link #EXTRA_STATE} - The current state of the profile. </li>
- * <li> {@link #EXTRA_PREVIOUS_STATE}- The previous state of the profile. </li>
- * <li> {@link BluetoothDevice#EXTRA_DEVICE} - The remote device. </li>
+ * <li> {@link #EXTRA_STATE} - The current state of the profile. </li>
+ * <li> {@link #EXTRA_PREVIOUS_STATE}- The previous state of the profile. </li>
+ * <li> {@link BluetoothDevice#EXTRA_DEVICE} - The remote device. </li>
* </ul>
* <p>{@link #EXTRA_STATE} or {@link #EXTRA_PREVIOUS_STATE} can be any of
* {@link #STATE_DISCONNECTED}, {@link #STATE_CONNECTING},
@@ -69,7 +69,7 @@ public final class BluetoothHeadset implements BluetoothProfile {
*/
@SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
public static final String ACTION_CONNECTION_STATE_CHANGED =
- "android.bluetooth.headset.profile.action.CONNECTION_STATE_CHANGED";
+ "android.bluetooth.headset.profile.action.CONNECTION_STATE_CHANGED";
/**
* Intent used to broadcast the change in the Audio Connection state of the
@@ -77,9 +77,9 @@ public final class BluetoothHeadset implements BluetoothProfile {
*
* <p>This intent will have 3 extras:
* <ul>
- * <li> {@link #EXTRA_STATE} - The current state of the profile. </li>
- * <li> {@link #EXTRA_PREVIOUS_STATE}- The previous state of the profile. </li>
- * <li> {@link BluetoothDevice#EXTRA_DEVICE} - The remote device. </li>
+ * <li> {@link #EXTRA_STATE} - The current state of the profile. </li>
+ * <li> {@link #EXTRA_PREVIOUS_STATE}- The previous state of the profile. </li>
+ * <li> {@link BluetoothDevice#EXTRA_DEVICE} - The remote device. </li>
* </ul>
* <p>{@link #EXTRA_STATE} or {@link #EXTRA_PREVIOUS_STATE} can be any of
* {@link #STATE_AUDIO_CONNECTED}, {@link #STATE_AUDIO_DISCONNECTED},
@@ -89,7 +89,7 @@ public final class BluetoothHeadset implements BluetoothProfile {
*/
@SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
public static final String ACTION_AUDIO_STATE_CHANGED =
- "android.bluetooth.headset.profile.action.AUDIO_STATE_CHANGED";
+ "android.bluetooth.headset.profile.action.AUDIO_STATE_CHANGED";
/**
@@ -98,19 +98,19 @@ public final class BluetoothHeadset implements BluetoothProfile {
*
* <p>This intent will have 4 extras and 1 category.
* <ul>
- * <li> {@link BluetoothDevice#EXTRA_DEVICE} - The remote Bluetooth Device
- * </li>
- * <li> {@link #EXTRA_VENDOR_SPECIFIC_HEADSET_EVENT_CMD} - The vendor
- * specific command </li>
- * <li> {@link #EXTRA_VENDOR_SPECIFIC_HEADSET_EVENT_CMD_TYPE} - The AT
- * command type which can be one of {@link #AT_CMD_TYPE_READ},
- * {@link #AT_CMD_TYPE_TEST}, or {@link #AT_CMD_TYPE_SET},
- * {@link #AT_CMD_TYPE_BASIC},{@link #AT_CMD_TYPE_ACTION}. </li>
- * <li> {@link #EXTRA_VENDOR_SPECIFIC_HEADSET_EVENT_ARGS} - Command
- * arguments. </li>
+ * <li> {@link BluetoothDevice#EXTRA_DEVICE} - The remote Bluetooth Device
+ * </li>
+ * <li> {@link #EXTRA_VENDOR_SPECIFIC_HEADSET_EVENT_CMD} - The vendor
+ * specific command </li>
+ * <li> {@link #EXTRA_VENDOR_SPECIFIC_HEADSET_EVENT_CMD_TYPE} - The AT
+ * command type which can be one of {@link #AT_CMD_TYPE_READ},
+ * {@link #AT_CMD_TYPE_TEST}, or {@link #AT_CMD_TYPE_SET},
+ * {@link #AT_CMD_TYPE_BASIC},{@link #AT_CMD_TYPE_ACTION}. </li>
+ * <li> {@link #EXTRA_VENDOR_SPECIFIC_HEADSET_EVENT_ARGS} - Command
+ * arguments. </li>
* </ul>
*
- *<p> The category is the Company ID of the vendor defining the
+ * <p> The category is the Company ID of the vendor defining the
* vendor-specific command. {@link BluetoothAssignedNumbers}
*
* For example, for Plantronics specific events
@@ -118,9 +118,9 @@ public final class BluetoothHeadset implements BluetoothProfile {
*
* <p> For example, an AT+XEVENT=foo,3 will get translated into
* <ul>
- * <li> EXTRA_VENDOR_SPECIFIC_HEADSET_EVENT_CMD = +XEVENT </li>
- * <li> EXTRA_VENDOR_SPECIFIC_HEADSET_EVENT_CMD_TYPE = AT_CMD_TYPE_SET </li>
- * <li> EXTRA_VENDOR_SPECIFIC_HEADSET_EVENT_ARGS = foo, 3 </li>
+ * <li> EXTRA_VENDOR_SPECIFIC_HEADSET_EVENT_CMD = +XEVENT </li>
+ * <li> EXTRA_VENDOR_SPECIFIC_HEADSET_EVENT_CMD_TYPE = AT_CMD_TYPE_SET </li>
+ * <li> EXTRA_VENDOR_SPECIFIC_HEADSET_EVENT_ARGS = foo, 3 </li>
* </ul>
* <p>Requires {@link android.Manifest.permission#BLUETOOTH} permission
* to receive.
@@ -191,7 +191,7 @@ public final class BluetoothHeadset implements BluetoothProfile {
* The intent category to be used with {@link #ACTION_VENDOR_SPECIFIC_HEADSET_EVENT}
* for the companyId
*/
- public static final String VENDOR_SPECIFIC_HEADSET_EVENT_COMPANY_ID_CATEGORY =
+ public static final String VENDOR_SPECIFIC_HEADSET_EVENT_COMPANY_ID_CATEGORY =
"android.bluetooth.headset.intent.category.companyid";
/**
@@ -201,12 +201,14 @@ public final class BluetoothHeadset implements BluetoothProfile {
/**
* A vendor-specific AT command
+ *
* @hide
*/
public static final String VENDOR_SPECIFIC_HEADSET_EVENT_XAPL = "+XAPL";
/**
* A vendor-specific AT command
+ *
* @hide
*/
public static final String VENDOR_SPECIFIC_HEADSET_EVENT_IPHONEACCEV = "+IPHONEACCEV";
@@ -214,18 +216,21 @@ public final class BluetoothHeadset implements BluetoothProfile {
/**
* Battery level indicator associated with
* {@link #VENDOR_SPECIFIC_HEADSET_EVENT_IPHONEACCEV}
+ *
* @hide
*/
public static final int VENDOR_SPECIFIC_HEADSET_EVENT_IPHONEACCEV_BATTERY_LEVEL = 1;
/**
* A vendor-specific AT command
+ *
* @hide
*/
public static final String VENDOR_SPECIFIC_HEADSET_EVENT_XEVENT = "+XEVENT";
/**
* Battery level indicator associated with {@link #VENDOR_SPECIFIC_HEADSET_EVENT_XEVENT}
+ *
* @hide
*/
public static final String VENDOR_SPECIFIC_HEADSET_EVENT_XEVENT_BATTERY_LEVEL = "BATTERY";
@@ -258,17 +263,18 @@ public final class BluetoothHeadset implements BluetoothProfile {
*
* <p>This intent will have 3 extras:
* <ul>
- * <li> {@link #EXTRA_HF_INDICATORS_IND_ID} - The Assigned number of headset Indicator which
- * is supported by the headset ( as indicated by AT+BIND command in the SLC
- * sequence) or whose value is changed (indicated by AT+BIEV command) </li>
- * <li> {@link #EXTRA_HF_INDICATORS_IND_VALUE} - Updated value of headset indicator. </li>
- * <li> {@link BluetoothDevice#EXTRA_DEVICE} - Remote device. </li>
+ * <li> {@link #EXTRA_HF_INDICATORS_IND_ID} - The Assigned number of headset Indicator which
+ * is supported by the headset ( as indicated by AT+BIND command in the SLC
+ * sequence) or whose value is changed (indicated by AT+BIEV command) </li>
+ * <li> {@link #EXTRA_HF_INDICATORS_IND_VALUE} - Updated value of headset indicator. </li>
+ * <li> {@link BluetoothDevice#EXTRA_DEVICE} - Remote device. </li>
* </ul>
* <p>{@link #EXTRA_HF_INDICATORS_IND_ID} is defined by Bluetooth SIG and each of the indicators
- * are given an assigned number. Below shows the assigned number of Indicator added so far
+ * are given an assigned number. Below shows the assigned number of Indicator added so far
* - Enhanced Safety - 1, Valid Values: 0 - Disabled, 1 - Enabled
* - Battery Level - 2, Valid Values: 0~100 - Remaining level of Battery
* <p>Requires {@link android.Manifest.permission#BLUETOOTH} permission to receive.
+ *
* @hide
*/
public static final String ACTION_HF_INDICATORS_VALUE_CHANGED =
@@ -278,6 +284,7 @@ public final class BluetoothHeadset implements BluetoothProfile {
* A int extra field in {@link #ACTION_HF_INDICATORS_VALUE_CHANGED}
* intents that contains the assigned number of the headset indicator as defined by
* Bluetooth SIG that is being sent. Value range is 0-65535 as defined in HFP 1.7
+ *
* @hide
*/
public static final String EXTRA_HF_INDICATORS_IND_ID =
@@ -286,6 +293,7 @@ public final class BluetoothHeadset implements BluetoothProfile {
/**
* A int extra field in {@link #ACTION_HF_INDICATORS_VALUE_CHANGED}
* intents that contains the value of the Headset indicator that is being sent.
+ *
* @hide
*/
public static final String EXTRA_HF_INDICATORS_IND_VALUE =
@@ -301,27 +309,27 @@ public final class BluetoothHeadset implements BluetoothProfile {
private IBluetoothHeadset mService;
private BluetoothAdapter mAdapter;
- final private IBluetoothStateChangeCallback mBluetoothStateChangeCallback =
+ private final IBluetoothStateChangeCallback mBluetoothStateChangeCallback =
new IBluetoothStateChangeCallback.Stub() {
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...");
doUnbind();
} else {
synchronized (mConnection) {
try {
if (mService == null) {
- if (VDBG) Log.d(TAG,"Binding service...");
+ if (VDBG) Log.d(TAG, "Binding service...");
doBind();
}
} catch (Exception re) {
- Log.e(TAG,"",re);
+ Log.e(TAG, "", re);
}
}
}
}
- };
+ };
/**
* Create a BluetoothHeadset proxy object.
@@ -336,7 +344,7 @@ public final class BluetoothHeadset implements BluetoothProfile {
try {
mgr.registerStateChangeCallback(mBluetoothStateChangeCallback);
} catch (RemoteException e) {
- Log.e(TAG,"",e);
+ Log.e(TAG, "", e);
}
}
@@ -360,7 +368,7 @@ public final class BluetoothHeadset implements BluetoothProfile {
mAdapter.getBluetoothManager().unbindBluetoothProfileService(
BluetoothProfile.HEADSET, mConnection);
} catch (RemoteException e) {
- Log.e(TAG,"Unable to unbind HeadsetService", e);
+ Log.e(TAG, "Unable to unbind HeadsetService", e);
}
}
}
@@ -380,7 +388,7 @@ public final class BluetoothHeadset implements BluetoothProfile {
try {
mgr.unregisterStateChangeCallback(mBluetoothStateChangeCallback);
} catch (Exception e) {
- Log.e(TAG,"",e);
+ Log.e(TAG, "", e);
}
}
mServiceListener = null;
@@ -405,14 +413,12 @@ public final class BluetoothHeadset implements BluetoothProfile {
* permission.
*
* @param device Remote Bluetooth Device
- * @return false on immediate error,
- * true otherwise
+ * @return false on immediate error, true otherwise
* @hide
*/
public boolean connect(BluetoothDevice device) {
if (DBG) log("connect(" + device + ")");
- if (mService != null && isEnabled() &&
- isValidDevice(device)) {
+ if (mService != null && isEnabled() && isValidDevice(device)) {
try {
return mService.connect(device);
} catch (RemoteException e) {
@@ -446,19 +452,17 @@ public final class BluetoothHeadset implements BluetoothProfile {
* permission.
*
* @param device Remote Bluetooth Device
- * @return false on immediate error,
- * true otherwise
+ * @return false on immediate error, true otherwise
* @hide
*/
public boolean disconnect(BluetoothDevice device) {
if (DBG) log("disconnect(" + device + ")");
- if (mService != null && isEnabled() &&
- isValidDevice(device)) {
+ if (mService != null && isEnabled() && isValidDevice(device)) {
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");
@@ -468,6 +472,7 @@ public final class BluetoothHeadset implements BluetoothProfile {
/**
* {@inheritDoc}
*/
+ @Override
public List<BluetoothDevice> getConnectedDevices() {
if (VDBG) log("getConnectedDevices()");
if (mService != null && isEnabled()) {
@@ -485,6 +490,7 @@ public final class BluetoothHeadset implements BluetoothProfile {
/**
* {@inheritDoc}
*/
+ @Override
public List<BluetoothDevice> getDevicesMatchingConnectionStates(int[] states) {
if (VDBG) log("getDevicesMatchingStates()");
if (mService != null && isEnabled()) {
@@ -502,10 +508,10 @@ public final class BluetoothHeadset implements BluetoothProfile {
/**
* {@inheritDoc}
*/
+ @Override
public int getConnectionState(BluetoothDevice device) {
if (VDBG) log("getConnectionState(" + device + ")");
- if (mService != null && isEnabled() &&
- isValidDevice(device)) {
+ if (mService != null && isEnabled() && isValidDevice(device)) {
try {
return mService.getConnectionState(device);
} catch (RemoteException e) {
@@ -521,7 +527,7 @@ public final class BluetoothHeadset implements BluetoothProfile {
* Set priority of the profile
*
* <p> The device should already be paired.
- * Priority can be one of {@link #PRIORITY_ON} or
+ * Priority can be one of {@link #PRIORITY_ON} or
* {@link #PRIORITY_OFF},
*
* <p>Requires {@link android.Manifest.permission#BLUETOOTH_ADMIN}
@@ -534,11 +540,10 @@ public final class BluetoothHeadset implements BluetoothProfile {
*/
public boolean setPriority(BluetoothDevice device, int priority) {
if (DBG) log("setPriority(" + device + ", " + priority + ")");
- if (mService != null && isEnabled() &&
- isValidDevice(device)) {
- if (priority != BluetoothProfile.PRIORITY_OFF &&
- priority != BluetoothProfile.PRIORITY_ON) {
- return false;
+ if (mService != null && isEnabled() && isValidDevice(device)) {
+ if (priority != BluetoothProfile.PRIORITY_OFF
+ && priority != BluetoothProfile.PRIORITY_ON) {
+ return false;
}
try {
return mService.setPriority(device, priority);
@@ -566,8 +571,7 @@ public final class BluetoothHeadset implements BluetoothProfile {
*/
public int getPriority(BluetoothDevice device) {
if (VDBG) log("getPriority(" + device + ")");
- if (mService != null && isEnabled() &&
- isValidDevice(device)) {
+ if (mService != null && isEnabled() && isValidDevice(device)) {
try {
return mService.getPriority(device);
} catch (RemoteException e) {
@@ -596,18 +600,16 @@ public final class BluetoothHeadset implements BluetoothProfile {
* <p>Requires {@link android.Manifest.permission#BLUETOOTH} permission.
*
* @param device Bluetooth headset
- * @return false if there is no headset connected of if the
- * connected headset doesn't support voice recognition
- * or on error, true otherwise
+ * @return false if there is no headset connected of if the connected headset doesn't support
+ * voice recognition or on error, true otherwise
*/
public boolean startVoiceRecognition(BluetoothDevice device) {
if (DBG) log("startVoiceRecognition()");
- if (mService != null && isEnabled() &&
- isValidDevice(device)) {
+ if (mService != null && isEnabled() && isValidDevice(device)) {
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");
@@ -621,17 +623,15 @@ public final class BluetoothHeadset implements BluetoothProfile {
* <p>Requires {@link android.Manifest.permission#BLUETOOTH} permission.
*
* @param device Bluetooth headset
- * @return false if there is no headset connected
- * or on error, true otherwise
+ * @return false if there is no headset connected or on error, true otherwise
*/
public boolean stopVoiceRecognition(BluetoothDevice device) {
if (DBG) log("stopVoiceRecognition()");
- if (mService != null && isEnabled() &&
- isValidDevice(device)) {
+ if (mService != null && isEnabled() && isValidDevice(device)) {
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");
@@ -644,17 +644,15 @@ public final class BluetoothHeadset implements BluetoothProfile {
* <p>Requires {@link android.Manifest.permission#BLUETOOTH} permission.
*
* @param device Bluetooth headset
- * @return true if SCO is connected,
- * false otherwise or on error
+ * @return true if SCO is connected, false otherwise or on error
*/
public boolean isAudioConnected(BluetoothDevice device) {
if (VDBG) log("isAudioConnected()");
- if (mService != null && isEnabled() &&
- isValidDevice(device)) {
+ if (mService != null && isEnabled() && isValidDevice(device)) {
try {
- return mService.isAudioConnected(device);
+ return mService.isAudioConnected(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");
@@ -671,18 +669,16 @@ public final class BluetoothHeadset implements BluetoothProfile {
* rule of thumb, each AT command prevents the CPU from sleeping for 500 ms
*
* @param device the bluetooth headset.
- * @return monotonically increasing battery usage hint, or a negative error
- * code on error
+ * @return monotonically increasing battery usage hint, or a negative error code on error
* @hide
*/
public int getBatteryUsageHint(BluetoothDevice device) {
if (VDBG) log("getBatteryUsageHint()");
- if (mService != null && isEnabled() &&
- isValidDevice(device)) {
+ if (mService != null && isEnabled() && isValidDevice(device)) {
try {
return mService.getBatteryUsageHint(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");
@@ -711,7 +707,9 @@ public final class BluetoothHeadset implements BluetoothProfile {
if (mService != null && isEnabled()) {
try {
return mService.acceptIncomingConnect(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()));
@@ -721,6 +719,7 @@ public final class BluetoothHeadset implements BluetoothProfile {
/**
* Reject the incoming connection.
+ *
* @hide
*/
public boolean rejectIncomingConnect(BluetoothDevice device) {
@@ -728,7 +727,9 @@ public final class BluetoothHeadset implements BluetoothProfile {
if (mService != null) {
try {
return mService.rejectIncomingConnect(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()));
@@ -747,7 +748,9 @@ public final class BluetoothHeadset implements BluetoothProfile {
if (mService != null && !isDisabled()) {
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()));
@@ -763,7 +766,6 @@ public final class BluetoothHeadset implements BluetoothProfile {
* Note: This is an internal function and shouldn't be exposed
*
* @param allowed {@code true} if the profile can reroute audio, {@code false} otherwise.
- *
* @hide
*/
public void setAudioRouteAllowed(boolean allowed) {
@@ -771,7 +773,9 @@ public final class BluetoothHeadset implements BluetoothProfile {
if (mService != null && isEnabled()) {
try {
mService.setAudioRouteAllowed(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()));
@@ -789,7 +793,9 @@ public final class BluetoothHeadset implements BluetoothProfile {
if (mService != null && isEnabled()) {
try {
return mService.getAudioRouteAllowed();
- } 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()));
@@ -800,9 +806,8 @@ public final class BluetoothHeadset implements BluetoothProfile {
/**
* Force SCO audio to be opened regardless any other restrictions
*
- * @param forced Whether or not SCO audio connection should be forced:
- * True to force SCO audio
- * False to use SCO audio in normal manner
+ * @param forced Whether or not SCO audio connection should be forced: True to force SCO audio
+ * False to use SCO audio in normal manner
* @hide
*/
public void setForceScoAudio(boolean forced) {
@@ -811,7 +816,7 @@ public final class BluetoothHeadset implements BluetoothProfile {
try {
mService.setForceScoAudio(forced);
} catch (RemoteException e) {
- Log.e(TAG, e.toString());
+ Log.e(TAG, e.toString());
}
} else {
Log.w(TAG, "Proxy not attached to service");
@@ -824,17 +829,16 @@ public final class BluetoothHeadset implements BluetoothProfile {
*
* <p>Requires {@link android.Manifest.permission#BLUETOOTH} permission.
*
- * @return true if SCO is connected,
- * false otherwise or on error
+ * @return true if SCO is connected, false otherwise or on error
* @hide
*/
public boolean isAudioOn() {
if (VDBG) log("isAudioOn()");
if (mService != null && isEnabled()) {
try {
- return mService.isAudioOn();
+ return mService.isAudioOn();
} 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");
@@ -846,9 +850,8 @@ public final class BluetoothHeadset implements BluetoothProfile {
* Initiates a connection of headset audio.
* It setup SCO channel with remote connected headset device.
*
- * @return true if successful
- * false if there was some error such as
- * there is no connected headset
+ * @return true if successful false if there was some error such as there is no connected
+ * headset
* @hide
*/
public boolean connectAudio() {
@@ -869,9 +872,8 @@ public final class BluetoothHeadset implements BluetoothProfile {
* Initiates a disconnection of headset audio.
* It tears down the SCO channel from remote headset device.
*
- * @return true if successful
- * false if there was some error such as
- * there is no connected SCO channel
+ * @return true if successful false if there was some error such as there is no connected SCO
+ * channel
* @hide
*/
public boolean disconnectAudio() {
@@ -946,7 +948,7 @@ public final class BluetoothHeadset implements BluetoothProfile {
* @hide
*/
public void phoneStateChanged(int numActive, int numHeld, int callState, String number,
- int type) {
+ int type) {
if (mService != null && isEnabled()) {
try {
mService.phoneStateChanged(numActive, numHeld, callState, number, type);
@@ -965,7 +967,7 @@ public final class BluetoothHeadset implements BluetoothProfile {
* @hide
*/
public void clccResponse(int index, int direction, int status, int mode, boolean mpty,
- String number, int type) {
+ String number, int type) {
if (mService != null && isEnabled()) {
try {
mService.clccResponse(index, direction, status, mode, mpty, number, type);
@@ -981,9 +983,9 @@ public final class BluetoothHeadset implements BluetoothProfile {
/**
* Sends a vendor-specific unsolicited result code to the headset.
*
- * <p>The actual string to be sent is <code>command + ": " + arg</code>.
- * For example, if {@code command} is {@link #VENDOR_RESULT_CODE_COMMAND_ANDROID} and {@code arg}
- * is {@code "0"}, the string <code>"+ANDROID: 0"</code> will be sent.
+ * <p>The actual string to be sent is <code>command + ": " + arg</code>. For example, if {@code
+ * command} is {@link #VENDOR_RESULT_CODE_COMMAND_ANDROID} and {@code arg} is {@code "0"}, the
+ * string <code>"+ANDROID: 0"</code> will be sent.
*
* <p>Currently only {@link #VENDOR_RESULT_CODE_COMMAND_ANDROID} is allowed as {@code command}.
*
@@ -993,7 +995,7 @@ public final class BluetoothHeadset implements BluetoothProfile {
* @param command A vendor-specific command.
* @param arg The argument that will be attached to the command.
* @return {@code false} if there is no headset connected, or if the command is not an allowed
- * vendor-specific unsolicited result code, or on error. {@code true} otherwise.
+ * vendor-specific unsolicited result code, or on error. {@code true} otherwise.
* @throws IllegalArgumentException if {@code command} is {@code null}.
*/
public boolean sendVendorSpecificResultCode(BluetoothDevice device, String command,
@@ -1004,8 +1006,7 @@ public final class BluetoothHeadset implements BluetoothProfile {
if (command == null) {
throw new IllegalArgumentException("command is null");
}
- if (mService != null && isEnabled() &&
- isValidDevice(device)) {
+ if (mService != null && isEnabled() && isValidDevice(device)) {
try {
return mService.sendVendorSpecificResultCode(device, command, arg);
} catch (RemoteException e) {
@@ -1021,9 +1022,8 @@ public final class BluetoothHeadset implements BluetoothProfile {
/**
* enable WBS codec setting.
*
- * @return true if successful
- * false if there was some error such as
- * there is no connected headset
+ * @return true if successful false if there was some error such as there is no connected
+ * headset
* @hide
*/
public boolean enableWBS() {
@@ -1043,9 +1043,8 @@ public final class BluetoothHeadset implements BluetoothProfile {
/**
* disable WBS codec settting. It set NBS codec.
*
- * @return true if successful
- * false if there was some error such as
- * there is no connected headset
+ * @return true if successful false if there was some error such as there is no connected
+ * headset
* @hide
*/
public boolean disableWBS() {
@@ -1065,8 +1064,7 @@ public final class BluetoothHeadset implements BluetoothProfile {
/**
* check if in-band ringing is supported for this platform.
*
- * @return true if in-band ringing is supported
- * false if in-band ringing is not supported
+ * @return true if in-band ringing is supported false if in-band ringing is not supported
* @hide
*/
public static boolean isInbandRingingSupported(Context context) {
@@ -1078,16 +1076,16 @@ public final class BluetoothHeadset implements BluetoothProfile {
* Send Headset the BIND response from AG to report change in the status of the
* HF indicators to the headset
*
- * @param ind_id Assigned Number of the indicator (defined by SIG)
- * @param ind_status
- * possible values- false-Indicator is disabled, no value changes shall be sent for this indicator
- * true-Indicator is enabled, value changes may be sent for this indicator
+ * @param indId Assigned Number of the indicator (defined by SIG)
+ * @param indStatus possible values- false-Indicator is disabled, no value changes shall be
+ * sent for this indicator true-Indicator is enabled, value changes may be sent for this
+ * indicator
* @hide
*/
- public void bindResponse(int ind_id, boolean ind_status) {
+ public void bindResponse(int indId, boolean indStatus) {
if (mService != null && isEnabled()) {
try {
- mService.bindResponse(ind_id, ind_status);
+ mService.bindResponse(indId, indStatus);
} catch (RemoteException e) {
Log.e(TAG, e.toString());
}
@@ -1097,8 +1095,8 @@ public final class BluetoothHeadset implements BluetoothProfile {
}
}
- private final IBluetoothProfileServiceConnection mConnection
- = new IBluetoothProfileServiceConnection.Stub() {
+ private final IBluetoothProfileServiceConnection mConnection =
+ new IBluetoothProfileServiceConnection.Stub() {
@Override
public void onServiceConnected(ComponentName className, IBinder service) {
if (DBG) Log.d(TAG, "Proxy object connected");
@@ -1106,6 +1104,7 @@ public final class BluetoothHeadset implements BluetoothProfile {
mHandler.sendMessage(mHandler.obtainMessage(
MESSAGE_HEADSET_SERVICE_CONNECTED));
}
+
@Override
public void onServiceDisconnected(ComponentName className) {
if (DBG) Log.d(TAG, "Proxy object disconnected");
@@ -1116,20 +1115,20 @@ public final class BluetoothHeadset 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 isDisabled() {
- if (mAdapter.getState() == BluetoothAdapter.STATE_OFF) return true;
- return false;
+ if (mAdapter.getState() == BluetoothAdapter.STATE_OFF) 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) {