Fix checkstyle errors (1/2)
* Automatic style corrections through IDE
Bug: 63596319
Test: make checkbuild, no manual changes, no functional changes
Change-Id: I2397d55abc34c9b7a9b748bec6137778df3421a7
diff --git a/framework/java/android/bluetooth/BluetoothA2dp.java b/framework/java/android/bluetooth/BluetoothA2dp.java
index c58eaa1..7d6879d 100644
--- a/framework/java/android/bluetooth/BluetoothA2dp.java
+++ b/framework/java/android/bluetooth/BluetoothA2dp.java
@@ -42,7 +42,7 @@
* This class provides the public APIs to control the Bluetooth A2DP
* profile.
*
- *<p>BluetoothA2dp is a proxy object for controlling the Bluetooth A2DP
+ * <p>BluetoothA2dp is a proxy object for controlling the Bluetooth A2DP
* Service via IPC. Use {@link BluetoothAdapter#getProfileProxy} to get
* the BluetoothA2dp proxy object.
*
@@ -60,9 +60,9 @@
*
* <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
@@ -74,7 +74,7 @@
*/
@SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
public static final String ACTION_CONNECTION_STATE_CHANGED =
- "android.bluetooth.a2dp.profile.action.CONNECTION_STATE_CHANGED";
+ "android.bluetooth.a2dp.profile.action.CONNECTION_STATE_CHANGED";
/**
* Intent used to broadcast the change in the Playing state of the A2DP
@@ -82,9 +82,9 @@
*
* <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
@@ -95,12 +95,12 @@
*/
@SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
public static final String ACTION_PLAYING_STATE_CHANGED =
- "android.bluetooth.a2dp.profile.action.PLAYING_STATE_CHANGED";
+ "android.bluetooth.a2dp.profile.action.PLAYING_STATE_CHANGED";
/** @hide */
@SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
public static final String ACTION_AVRCP_CONNECTION_STATE_CHANGED =
- "android.bluetooth.a2dp.profile.action.AVRCP_CONNECTION_STATE_CHANGED";
+ "android.bluetooth.a2dp.profile.action.AVRCP_CONNECTION_STATE_CHANGED";
/**
* Intent used to broadcast the change in the Audio Codec state of the
@@ -108,9 +108,9 @@
*
* <p>This intent will have 2 extras:
* <ul>
- * <li> {@link BluetoothCodecStatus#EXTRA_CODEC_STATUS} - The codec status. </li>
- * <li> {@link BluetoothDevice#EXTRA_DEVICE} - The remote device if the device is currently
- * connected, otherwise it is not included.</li>
+ * <li> {@link BluetoothCodecStatus#EXTRA_CODEC_STATUS} - The codec status. </li>
+ * <li> {@link BluetoothDevice#EXTRA_DEVICE} - The remote device if the device is currently
+ * connected, otherwise it is not included.</li>
* </ul>
*
* <p>Requires {@link android.Manifest.permission#BLUETOOTH} permission to
@@ -120,58 +120,71 @@
*/
@SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
public static final String ACTION_CODEC_CONFIG_CHANGED =
- "android.bluetooth.a2dp.profile.action.CODEC_CONFIG_CHANGED";
+ "android.bluetooth.a2dp.profile.action.CODEC_CONFIG_CHANGED";
/**
* A2DP sink device is streaming music. This state can be one of
* {@link #EXTRA_STATE} or {@link #EXTRA_PREVIOUS_STATE} of
* {@link #ACTION_PLAYING_STATE_CHANGED} intent.
*/
- public static final int STATE_PLAYING = 10;
+ public static final int STATE_PLAYING = 10;
/**
* A2DP sink device is NOT streaming music. This state can be one of
* {@link #EXTRA_STATE} or {@link #EXTRA_PREVIOUS_STATE} of
* {@link #ACTION_PLAYING_STATE_CHANGED} intent.
*/
- public static final int STATE_NOT_PLAYING = 11;
+ public static final int STATE_NOT_PLAYING = 11;
/**
* We don't have a stored preference for whether or not the given A2DP sink device supports
* optional codecs.
- * @hide */
+ *
+ * @hide
+ */
public static final int OPTIONAL_CODECS_SUPPORT_UNKNOWN = -1;
/**
* The given A2DP sink device does not support optional codecs.
- * @hide */
+ *
+ * @hide
+ */
public static final int OPTIONAL_CODECS_NOT_SUPPORTED = 0;
/**
* The given A2DP sink device does support optional codecs.
- * @hide */
+ *
+ * @hide
+ */
public static final int OPTIONAL_CODECS_SUPPORTED = 1;
/**
* We don't have a stored preference for whether optional codecs should be enabled or disabled
* for the given A2DP device.
- * @hide */
+ *
+ * @hide
+ */
public static final int OPTIONAL_CODECS_PREF_UNKNOWN = -1;
/**
* Optional codecs should be disabled for the given A2DP device.
- * @hide */
+ *
+ * @hide
+ */
public static final int OPTIONAL_CODECS_PREF_DISABLED = 0;
/**
- * Optional codecs should be enabled for the given A2DP device.
- * @hide */
+ * Optional codecs should be enabled for the given A2DP device.
+ *
+ * @hide
+ */
public static final int OPTIONAL_CODECS_PREF_ENABLED = 1;
private Context mContext;
private ServiceListener mServiceListener;
private final ReentrantReadWriteLock mServiceLock = new ReentrantReadWriteLock();
- @GuardedBy("mServiceLock") private IBluetoothA2dp mService;
+ @GuardedBy("mServiceLock")
+ private IBluetoothA2dp mService;
private BluetoothAdapter mAdapter;
final private IBluetoothStateChangeCallback mBluetoothStateChangeCallback =
@@ -193,21 +206,21 @@
try {
mServiceLock.readLock().lock();
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);
} finally {
mServiceLock.readLock().unlock();
}
}
}
- };
+ };
+
/**
* Create a BluetoothA2dp proxy object for interacting with the local
* Bluetooth A2DP service.
- *
*/
/*package*/ BluetoothA2dp(Context context, ServiceListener l) {
mContext = context;
@@ -218,7 +231,7 @@
try {
mgr.registerStateChangeCallback(mBluetoothStateChangeCallback);
} catch (RemoteException e) {
- Log.e(TAG,"",e);
+ Log.e(TAG, "", e);
}
}
@@ -244,7 +257,7 @@
try {
mgr.unregisterStateChangeCallback(mBluetoothStateChangeCallback);
} catch (Exception e) {
- Log.e(TAG,"",e);
+ Log.e(TAG, "", e);
}
}
@@ -265,6 +278,7 @@
// The empty finalize needs to be kept or the
// cts signature tests would fail.
}
+
/**
* Initiate connection to a profile of the remote bluetooth device.
*
@@ -283,8 +297,7 @@
* 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) {
@@ -292,7 +305,7 @@
try {
mServiceLock.readLock().lock();
if (mService != null && isEnabled() &&
- isValidDevice(device)) {
+ isValidDevice(device)) {
return mService.connect(device);
}
if (mService == null) Log.w(TAG, "Proxy not attached to service");
@@ -327,8 +340,7 @@
* 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) {
@@ -336,7 +348,7 @@
try {
mServiceLock.readLock().lock();
if (mService != null && isEnabled() &&
- isValidDevice(device)) {
+ isValidDevice(device)) {
return mService.disconnect(device);
}
if (mService == null) Log.w(TAG, "Proxy not attached to service");
@@ -397,7 +409,7 @@
try {
mServiceLock.readLock().lock();
if (mService != null && isEnabled()
- && isValidDevice(device)) {
+ && isValidDevice(device)) {
return mService.getConnectionState(device);
}
if (mService == null) Log.w(TAG, "Proxy not attached to service");
@@ -414,7 +426,7 @@
* Set priority of the profile
*
* <p> The device should already be paired.
- * Priority can be one of {@link #PRIORITY_ON} orgetBluetoothManager
+ * Priority can be one of {@link #PRIORITY_ON} orgetBluetoothManager
* {@link #PRIORITY_OFF},
*
* <p>Requires {@link android.Manifest.permission#BLUETOOTH_ADMIN}
@@ -430,9 +442,9 @@
try {
mServiceLock.readLock().lock();
if (mService != null && isEnabled()
- && isValidDevice(device)) {
+ && isValidDevice(device)) {
if (priority != BluetoothProfile.PRIORITY_OFF &&
- priority != BluetoothProfile.PRIORITY_ON) {
+ priority != BluetoothProfile.PRIORITY_ON) {
return false;
}
return mService.setPriority(device, priority);
@@ -464,7 +476,7 @@
try {
mServiceLock.readLock().lock();
if (mService != null && isEnabled()
- && isValidDevice(device)) {
+ && isValidDevice(device)) {
return mService.getPriority(device);
}
if (mService == null) Log.w(TAG, "Proxy not attached to service");
@@ -560,7 +572,7 @@
try {
mServiceLock.readLock().lock();
if (mService != null && isEnabled()
- && isValidDevice(device)) {
+ && isValidDevice(device)) {
return mService.isA2dpPlaying(device);
}
if (mService == null) Log.w(TAG, "Proxy not attached to service");
@@ -577,6 +589,7 @@
* This function checks if the remote device is an AVCRP
* target and thus whether we should send volume keys
* changes or not.
+ *
* @hide
*/
public boolean shouldSendVolumeKeys(BluetoothDevice device) {
@@ -584,7 +597,7 @@
ParcelUuid[] uuids = device.getUuids();
if (uuids == null) return false;
- for (ParcelUuid uuid: uuids) {
+ for (ParcelUuid uuid : uuids) {
if (BluetoothUuid.isAvrcpTarget(uuid)) {
return true;
}
@@ -691,8 +704,7 @@
*
* @param device The device to check
* @return one of OPTIONAL_CODECS_SUPPORT_UNKNOWN, OPTIONAL_CODECS_NOT_SUPPORTED, or
- * OPTIONAL_CODECS_SUPPORTED.
- *
+ * OPTIONAL_CODECS_SUPPORTED.
* @hide
*/
public int supportsOptionalCodecs(BluetoothDevice device) {
@@ -716,8 +728,7 @@
*
* @param device The device in question.
* @return one of OPTIONAL_CODECS_PREF_UNKNOWN, OPTIONAL_CODECS_PREF_ENABLED, or
- * OPTIONAL_CODECS_PREF_DISABLED.
- *
+ * OPTIONAL_CODECS_PREF_DISABLED.
* @hide
*/
public int getOptionalCodecsEnabled(BluetoothDevice device) {
@@ -741,8 +752,8 @@
*
* @param device The device to set this preference for.
* @param value Whether the optional codecs should be enabled for this device. This should be
- * one of OPTIONAL_CODECS_PREF_UNKNOWN, OPTIONAL_CODECS_PREF_ENABLED, or
- * OPTIONAL_CODECS_PREF_DISABLED.
+ * one of OPTIONAL_CODECS_PREF_UNKNOWN, OPTIONAL_CODECS_PREF_ENABLED, or
+ * OPTIONAL_CODECS_PREF_DISABLED.
* @hide
*/
public void setOptionalCodecsEnabled(BluetoothDevice device, int value) {
@@ -772,24 +783,25 @@
* Helper for converting a state to a string.
*
* For debug use only - strings are not internationalized.
+ *
* @hide
*/
public static String stateToString(int state) {
switch (state) {
- case STATE_DISCONNECTED:
- return "disconnected";
- case STATE_CONNECTING:
- return "connecting";
- case STATE_CONNECTED:
- return "connected";
- case STATE_DISCONNECTING:
- return "disconnecting";
- case STATE_PLAYING:
- return "playing";
- case STATE_NOT_PLAYING:
- return "not playing";
- default:
- return "<unknown state " + state + ">";
+ case STATE_DISCONNECTED:
+ return "disconnected";
+ case STATE_CONNECTING:
+ return "connecting";
+ case STATE_CONNECTED:
+ return "connected";
+ case STATE_DISCONNECTING:
+ return "disconnecting";
+ case STATE_PLAYING:
+ return "playing";
+ case STATE_NOT_PLAYING:
+ return "not playing";
+ default:
+ return "<unknown state " + state + ">";
}
}
@@ -807,6 +819,7 @@
mServiceListener.onServiceConnected(BluetoothProfile.A2DP, BluetoothA2dp.this);
}
}
+
public void onServiceDisconnected(ComponentName className) {
if (DBG) Log.d(TAG, "Proxy object disconnected");
try {
@@ -822,18 +835,18 @@
};
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) {
- Log.d(TAG, msg);
+ Log.d(TAG, msg);
}
}
diff --git a/framework/java/android/bluetooth/BluetoothA2dpSink.java b/framework/java/android/bluetooth/BluetoothA2dpSink.java
index 9dfc4b4..78dab1b2 100755
--- a/framework/java/android/bluetooth/BluetoothA2dpSink.java
+++ b/framework/java/android/bluetooth/BluetoothA2dpSink.java
@@ -32,7 +32,7 @@
* This class provides the public APIs to control the Bluetooth A2DP Sink
* profile.
*
- *<p>BluetoothA2dpSink is a proxy object for controlling the Bluetooth A2DP Sink
+ * <p>BluetoothA2dpSink is a proxy object for controlling the Bluetooth A2DP Sink
* Service via IPC. Use {@link BluetoothAdapter#getProfileProxy} to get
* the BluetoothA2dpSink proxy object.
*
@@ -49,9 +49,9 @@
*
* <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
@@ -62,7 +62,7 @@
* receive.
*/
public static final String ACTION_CONNECTION_STATE_CHANGED =
- "android.bluetooth.a2dp-sink.profile.action.CONNECTION_STATE_CHANGED";
+ "android.bluetooth.a2dp-sink.profile.action.CONNECTION_STATE_CHANGED";
/**
* Intent used to broadcast the change in the Playing state of the A2DP Sink
@@ -70,9 +70,9 @@
*
* <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
@@ -82,21 +82,21 @@
* receive.
*/
public static final String ACTION_PLAYING_STATE_CHANGED =
- "android.bluetooth.a2dp-sink.profile.action.PLAYING_STATE_CHANGED";
+ "android.bluetooth.a2dp-sink.profile.action.PLAYING_STATE_CHANGED";
/**
* A2DP sink device is streaming music. This state can be one of
* {@link #EXTRA_STATE} or {@link #EXTRA_PREVIOUS_STATE} of
* {@link #ACTION_PLAYING_STATE_CHANGED} intent.
*/
- public static final int STATE_PLAYING = 10;
+ public static final int STATE_PLAYING = 10;
/**
* A2DP sink device is NOT streaming music. This state can be one of
* {@link #EXTRA_STATE} or {@link #EXTRA_PREVIOUS_STATE} of
* {@link #ACTION_PLAYING_STATE_CHANGED} intent.
*/
- public static final int STATE_NOT_PLAYING = 11;
+ public static final int STATE_NOT_PLAYING = 11;
/**
* Intent used to broadcast the change in the Playing state of the A2DP Sink
@@ -104,15 +104,15 @@
*
* <p>This intent will have 3 extras:
* <ul>
- * <li> {@link #EXTRA_AUDIO_CONFIG} - The audio configuration for the remote device. </li>
- * <li> {@link BluetoothDevice#EXTRA_DEVICE} - The remote device. </li>
+ * <li> {@link #EXTRA_AUDIO_CONFIG} - The audio configuration for the remote device. </li>
+ * <li> {@link BluetoothDevice#EXTRA_DEVICE} - The remote device. </li>
* </ul>
*
* <p>Requires {@link android.Manifest.permission#BLUETOOTH} permission to
* receive.
*/
public static final String ACTION_AUDIO_CONFIG_CHANGED =
- "android.bluetooth.a2dp-sink.profile.action.AUDIO_CONFIG_CHANGED";
+ "android.bluetooth.a2dp-sink.profile.action.AUDIO_CONFIG_CHANGED";
/**
* Extra for the {@link #ACTION_AUDIO_CONFIG_CHANGED} intent.
@@ -133,33 +133,33 @@
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...");
+ if (VDBG) Log.d(TAG, "Binding service...");
doBind();
}
} catch (Exception re) {
- Log.e(TAG,"",re);
+ Log.e(TAG, "", re);
}
}
}
}
- };
+ };
+
/**
* Create a BluetoothA2dp proxy object for interacting with the local
* Bluetooth A2DP service.
- *
*/
/*package*/ BluetoothA2dpSink(Context context, ServiceListener l) {
mContext = context;
@@ -170,7 +170,7 @@
try {
mgr.registerStateChangeCallback(mBluetoothStateChangeCallback);
} catch (RemoteException e) {
- Log.e(TAG,"",e);
+ Log.e(TAG, "", e);
}
}
@@ -196,7 +196,7 @@
try {
mgr.unregisterStateChangeCallback(mBluetoothStateChangeCallback);
} catch (Exception e) {
- Log.e(TAG,"",e);
+ Log.e(TAG, "", e);
}
}
@@ -206,7 +206,7 @@
mService = null;
mContext.unbindService(mConnection);
} catch (Exception re) {
- Log.e(TAG,"",re);
+ Log.e(TAG, "", re);
}
}
}
@@ -215,6 +215,7 @@
public void finalize() {
close();
}
+
/**
* Initiate connection to a profile of the remote bluetooth device.
*
@@ -233,14 +234,13 @@
* 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)) {
+ isValidDevice(device)) {
try {
return mService.connect(device);
} catch (RemoteException e) {
@@ -274,14 +274,13 @@
* 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)) {
+ isValidDevice(device)) {
try {
return mService.disconnect(device);
} catch (RemoteException e) {
@@ -333,7 +332,7 @@
public int getConnectionState(BluetoothDevice device) {
if (VDBG) log("getState(" + device + ")");
if (mService != null && isEnabled()
- && isValidDevice(device)) {
+ && isValidDevice(device)) {
try {
return mService.getConnectionState(device);
} catch (RemoteException e) {
@@ -356,10 +355,10 @@
*
* {@see BluetoothAudioConfig}
*/
- public BluetoothAudioConfig getAudioConfig(BluetoothDevice device) {
+ public BluetoothAudioConfig getAudioConfig(BluetoothDevice device) {
if (VDBG) log("getAudioConfig(" + device + ")");
if (mService != null && isEnabled()
- && isValidDevice(device)) {
+ && isValidDevice(device)) {
try {
return mService.getAudioConfig(device);
} catch (RemoteException e) {
@@ -375,7 +374,7 @@
* Set priority of the profile
*
* <p> The device should already be paired.
- * Priority can be one of {@link #PRIORITY_ON} orgetBluetoothManager
+ * Priority can be one of {@link #PRIORITY_ON} orgetBluetoothManager
* {@link #PRIORITY_OFF},
*
* <p>Requires {@link android.Manifest.permission#BLUETOOTH_ADMIN}
@@ -389,20 +388,20 @@
public boolean setPriority(BluetoothDevice device, int priority) {
if (DBG) log("setPriority(" + device + ", " + priority + ")");
if (mService != null && isEnabled()
- && isValidDevice(device)) {
+ && isValidDevice(device)) {
if (priority != BluetoothProfile.PRIORITY_OFF &&
- priority != BluetoothProfile.PRIORITY_ON){
+ priority != BluetoothProfile.PRIORITY_ON) {
return false;
}
try {
return mService.setPriority(device, priority);
} catch (RemoteException e) {
- Log.e(TAG, "Stack:" + Log.getStackTraceString(new Throwable()));
- return false;
+ Log.e(TAG, "Stack:" + Log.getStackTraceString(new Throwable()));
+ return false;
}
}
if (mService == null) Log.w(TAG, "Proxy not attached to service");
- return false;
+ return false;
}
/**
@@ -421,7 +420,7 @@
public int getPriority(BluetoothDevice device) {
if (VDBG) log("getPriority(" + device + ")");
if (mService != null && isEnabled()
- && isValidDevice(device)) {
+ && isValidDevice(device)) {
try {
return mService.getPriority(device);
} catch (RemoteException e) {
@@ -442,7 +441,7 @@
*/
public boolean isA2dpPlaying(BluetoothDevice device) {
if (mService != null && isEnabled()
- && isValidDevice(device)) {
+ && isValidDevice(device)) {
try {
return mService.isA2dpPlaying(device);
} catch (RemoteException e) {
@@ -458,24 +457,25 @@
* Helper for converting a state to a string.
*
* For debug use only - strings are not internationalized.
+ *
* @hide
*/
public static String stateToString(int state) {
switch (state) {
- case STATE_DISCONNECTED:
- return "disconnected";
- case STATE_CONNECTING:
- return "connecting";
- case STATE_CONNECTED:
- return "connected";
- case STATE_DISCONNECTING:
- return "disconnecting";
- case STATE_PLAYING:
- return "playing";
- case STATE_NOT_PLAYING:
- return "not playing";
- default:
- return "<unknown state " + state + ">";
+ case STATE_DISCONNECTED:
+ return "disconnected";
+ case STATE_CONNECTING:
+ return "connecting";
+ case STATE_CONNECTED:
+ return "connected";
+ case STATE_DISCONNECTING:
+ return "disconnecting";
+ case STATE_PLAYING:
+ return "playing";
+ case STATE_NOT_PLAYING:
+ return "not playing";
+ default:
+ return "<unknown state " + state + ">";
}
}
@@ -489,6 +489,7 @@
BluetoothA2dpSink.this);
}
}
+
public void onServiceDisconnected(ComponentName className) {
if (DBG) Log.d(TAG, "Proxy object disconnected");
mService = null;
@@ -499,18 +500,18 @@
};
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) {
- Log.d(TAG, msg);
+ Log.d(TAG, msg);
}
}
diff --git a/framework/java/android/bluetooth/BluetoothActivityEnergyInfo.java b/framework/java/android/bluetooth/BluetoothActivityEnergyInfo.java
index 84f6060..da2aba7 100644
--- a/framework/java/android/bluetooth/BluetoothActivityEnergyInfo.java
+++ b/framework/java/android/bluetooth/BluetoothActivityEnergyInfo.java
@@ -25,6 +25,7 @@
* Record of energy and activity information from controller and
* underlying bt stack state.Timestamp the record with system
* time
+ *
* @hide
*/
public final class BluetoothActivityEnergyInfo implements Parcelable {
@@ -42,7 +43,7 @@
public static final int BT_STACK_STATE_STATE_IDLE = 3;
public BluetoothActivityEnergyInfo(long timestamp, int stackState,
- long txTime, long rxTime, long idleTime, long energyUsed) {
+ long txTime, long rxTime, long idleTime, long energyUsed) {
mTimestamp = timestamp;
mBluetoothStackState = stackState;
mControllerTxTimeMs = txTime;
@@ -65,26 +66,26 @@
@Override
public String toString() {
return "BluetoothActivityEnergyInfo{"
- + " mTimestamp=" + mTimestamp
- + " mBluetoothStackState=" + mBluetoothStackState
- + " mControllerTxTimeMs=" + mControllerTxTimeMs
- + " mControllerRxTimeMs=" + mControllerRxTimeMs
- + " mControllerIdleTimeMs=" + mControllerIdleTimeMs
- + " mControllerEnergyUsed=" + mControllerEnergyUsed
- + " mUidTraffic=" + Arrays.toString(mUidTraffic)
- + " }";
+ + " mTimestamp=" + mTimestamp
+ + " mBluetoothStackState=" + mBluetoothStackState
+ + " mControllerTxTimeMs=" + mControllerTxTimeMs
+ + " mControllerRxTimeMs=" + mControllerRxTimeMs
+ + " mControllerIdleTimeMs=" + mControllerIdleTimeMs
+ + " mControllerEnergyUsed=" + mControllerEnergyUsed
+ + " mUidTraffic=" + Arrays.toString(mUidTraffic)
+ + " }";
}
public static final Parcelable.Creator<BluetoothActivityEnergyInfo> CREATOR =
new Parcelable.Creator<BluetoothActivityEnergyInfo>() {
- public BluetoothActivityEnergyInfo createFromParcel(Parcel in) {
- return new BluetoothActivityEnergyInfo(in);
- }
+ public BluetoothActivityEnergyInfo createFromParcel(Parcel in) {
+ return new BluetoothActivityEnergyInfo(in);
+ }
- public BluetoothActivityEnergyInfo[] newArray(int size) {
- return new BluetoothActivityEnergyInfo[size];
- }
- };
+ public BluetoothActivityEnergyInfo[] newArray(int size) {
+ return new BluetoothActivityEnergyInfo[size];
+ }
+ };
@SuppressWarnings("unchecked")
public void writeToParcel(Parcel out, int flags) {
@@ -131,6 +132,7 @@
/**
* product of current(mA), voltage(V) and time(ms)
+ *
* @return energy used
*/
public long getControllerEnergyUsed() {
@@ -156,8 +158,8 @@
* @return if the record is valid
*/
public boolean isValid() {
- return ((mControllerTxTimeMs >=0) &&
- (mControllerRxTimeMs >=0) &&
- (mControllerIdleTimeMs >=0));
+ return ((mControllerTxTimeMs >= 0) &&
+ (mControllerRxTimeMs >= 0) &&
+ (mControllerIdleTimeMs >= 0));
}
}
diff --git a/framework/java/android/bluetooth/BluetoothAdapter.java b/framework/java/android/bluetooth/BluetoothAdapter.java
index fc3a724..1b9ce88 100644
--- a/framework/java/android/bluetooth/BluetoothAdapter.java
+++ b/framework/java/android/bluetooth/BluetoothAdapter.java
@@ -80,7 +80,7 @@
* {@link #getBondedDevices()}; start device discovery with
* {@link #startDiscovery()}; or create a {@link BluetoothServerSocket} to
* listen for incoming connection requests with
- * {@link #listenUsingRfcommWithServiceRecord(String,UUID)}; or start a scan for
+ * {@link #listenUsingRfcommWithServiceRecord(String, UUID)}; or start a scan for
* Bluetooth LE devices with {@link #startLeScan(LeScanCallback callback)}.
* </p>
* <p>This class is thread safe.</p>
@@ -92,7 +92,7 @@
* <div class="special reference">
* <h3>Developer Guides</h3>
* <p>
- * For more information about using Bluetooth, read the <a href=
+ * For more information about using Bluetooth, read the <a href=
* "{@docRoot}guide/topics/connectivity/bluetooth.html">Bluetooth</a> developer
* guide.
* </p>
@@ -161,7 +161,8 @@
@IntDef({STATE_OFF, STATE_TURNING_ON, STATE_ON, STATE_TURNING_OFF, STATE_BLE_TURNING_ON,
STATE_BLE_ON, STATE_BLE_TURNING_OFF})
@Retention(RetentionPolicy.SOURCE)
- public @interface AdapterState {}
+ public @interface AdapterState {
+ }
/**
* Indicates the local Bluetooth adapter is off.
@@ -185,36 +186,48 @@
/**
* Indicates the local Bluetooth adapter is turning Bluetooth LE mode on.
+ *
* @hide
*/
public static final int STATE_BLE_TURNING_ON = 14;
/**
* Indicates the local Bluetooth adapter is in LE only mode.
+ *
* @hide
*/
public static final int STATE_BLE_ON = 15;
/**
* Indicates the local Bluetooth adapter is turning off LE only mode.
+ *
* @hide
*/
public static final int STATE_BLE_TURNING_OFF = 16;
/**
* Human-readable string helper for AdapterState
+ *
* @hide
*/
public static String nameForState(@AdapterState int state) {
- switch(state) {
- case STATE_OFF: return "OFF";
- case STATE_TURNING_ON: return "TURNING_ON";
- case STATE_ON: return "ON";
- case STATE_TURNING_OFF: return "TURNING_OFF";
- case STATE_BLE_TURNING_ON: return "BLE_TURNING_ON";
- case STATE_BLE_ON: return "BLE_ON";
- case STATE_BLE_TURNING_OFF: return "BLE_TURNING_OFF";
- default: return "?!?!? (" + state + ")";
+ switch (state) {
+ case STATE_OFF:
+ return "OFF";
+ case STATE_TURNING_ON:
+ return "TURNING_ON";
+ case STATE_ON:
+ return "ON";
+ case STATE_TURNING_OFF:
+ return "TURNING_OFF";
+ case STATE_BLE_TURNING_ON:
+ return "BLE_TURNING_ON";
+ case STATE_BLE_ON:
+ return "BLE_ON";
+ case STATE_BLE_TURNING_OFF:
+ return "BLE_TURNING_OFF";
+ default:
+ return "?!?!? (" + state + ")";
}
}
@@ -346,7 +359,8 @@
/** @hide */
@IntDef({SCAN_MODE_NONE, SCAN_MODE_CONNECTABLE, SCAN_MODE_CONNECTABLE_DISCOVERABLE})
@Retention(RetentionPolicy.SOURCE)
- public @interface ScanMode {}
+ public @interface ScanMode {
+ }
/**
* Indicates that both inquiry scan and page scan are disabled on the local
@@ -439,7 +453,7 @@
*/
@SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
public static final String ACTION_CONNECTION_STATE_CHANGED =
- "android.bluetooth.adapter.action.CONNECTION_STATE_CHANGED";
+ "android.bluetooth.adapter.action.CONNECTION_STATE_CHANGED";
/**
* Extra used by {@link #ACTION_CONNECTION_STATE_CHANGED}
@@ -447,7 +461,7 @@
* This extra represents the current connection state.
*/
public static final String EXTRA_CONNECTION_STATE =
- "android.bluetooth.adapter.extra.CONNECTION_STATE";
+ "android.bluetooth.adapter.extra.CONNECTION_STATE";
/**
* Extra used by {@link #ACTION_CONNECTION_STATE_CHANGED}
@@ -455,15 +469,16 @@
* This extra represents the previous connection state.
*/
public static final String EXTRA_PREVIOUS_CONNECTION_STATE =
- "android.bluetooth.adapter.extra.PREVIOUS_CONNECTION_STATE";
+ "android.bluetooth.adapter.extra.PREVIOUS_CONNECTION_STATE";
/**
* Broadcast Action: The Bluetooth adapter state has changed in LE only mode.
+ *
* @hide
*/
@SystemApi
public static final String ACTION_BLE_STATE_CHANGED =
- "android.bluetooth.adapter.action.BLE_STATE_CHANGED";
+ "android.bluetooth.adapter.action.BLE_STATE_CHANGED";
/**
* Intent used to broadcast the change in the Bluetooth address
@@ -477,7 +492,7 @@
* @hide
*/
public static final String ACTION_BLUETOOTH_ADDRESS_CHANGED =
- "android.bluetooth.adapter.action.BLUETOOTH_ADDRESS_CHANGED";
+ "android.bluetooth.adapter.action.BLUETOOTH_ADDRESS_CHANGED";
/**
* Used as a String extra field in {@link
@@ -487,7 +502,7 @@
* @hide
*/
public static final String EXTRA_BLUETOOTH_ADDRESS =
- "android.bluetooth.adapter.extra.BLUETOOTH_ADDRESS";
+ "android.bluetooth.adapter.extra.BLUETOOTH_ADDRESS";
/**
* Broadcast Action: The notifys Bluetooth ACL connected event. This will be
@@ -497,10 +512,11 @@
*
* This is counterpart of {@link BluetoothDevice#ACTION_ACL_CONNECTED} which
* works in Bluetooth state STATE_ON
+ *
* @hide
*/
public static final String ACTION_BLE_ACL_CONNECTED =
- "android.bluetooth.adapter.action.BLE_ACL_CONNECTED";
+ "android.bluetooth.adapter.action.BLE_ACL_CONNECTED";
/**
* Broadcast Action: The notifys Bluetooth ACL connected event. This will be
@@ -510,17 +526,18 @@
*
* This is counterpart of {@link BluetoothDevice#ACTION_ACL_DISCONNECTED} which
* works in Bluetooth state STATE_ON
+ *
* @hide
*/
public static final String ACTION_BLE_ACL_DISCONNECTED =
- "android.bluetooth.adapter.action.BLE_ACL_DISCONNECTED";
+ "android.bluetooth.adapter.action.BLE_ACL_DISCONNECTED";
/** The profile is in disconnected state */
- public static final int STATE_DISCONNECTED = 0;
+ public static final int STATE_DISCONNECTED = 0;
/** The profile is in connecting state */
- public static final int STATE_CONNECTING = 1;
+ public static final int STATE_CONNECTING = 1;
/** The profile is in connected state */
- public static final int STATE_CONNECTED = 2;
+ public static final int STATE_CONNECTED = 2;
/** The profile is in disconnecting state */
public static final int STATE_DISCONNECTING = 3;
@@ -529,14 +546,17 @@
private final IBinder mToken;
- /** When creating a ServerSocket using listenUsingRfcommOn() or
- * listenUsingL2capOn() use SOCKET_CHANNEL_AUTO_STATIC to create
- * a ServerSocket that auto assigns a channel number to the first
- * bluetooth socket.
- * The channel number assigned to this first Bluetooth Socket will
- * be stored in the ServerSocket, and reused for subsequent Bluetooth
- * sockets.
- * @hide */
+ /**
+ * When creating a ServerSocket using listenUsingRfcommOn() or
+ * listenUsingL2capOn() use SOCKET_CHANNEL_AUTO_STATIC to create
+ * a ServerSocket that auto assigns a channel number to the first
+ * bluetooth socket.
+ * The channel number assigned to this first Bluetooth Socket will
+ * be stored in the ServerSocket, and reused for subsequent Bluetooth
+ * sockets.
+ *
+ * @hide
+ */
public static final int SOCKET_CHANNEL_AUTO_STATIC_NO_SDP = -2;
@@ -555,7 +575,7 @@
private final IBluetoothManager mManagerService;
private IBluetooth mService;
private final ReentrantReadWriteLock mServiceLock =
- new ReentrantReadWriteLock();
+ new ReentrantReadWriteLock();
private final Object mLock = new Object();
private final Map<LeScanCallback, ScanCallback> mLeScanClients;
@@ -566,8 +586,9 @@
* could be extended to support more. This will always return the default
* adapter.
* </p>
- * @return the default local adapter, or null if Bluetooth is not supported
- * on this hardware platform
+ *
+ * @return the default local adapter, or null if Bluetooth is not supported on this hardware
+ * platform
*/
public static synchronized BluetoothAdapter getDefaultAdapter() {
if (sAdapter == null) {
@@ -648,7 +669,7 @@
*/
public BluetoothLeAdvertiser getBluetoothLeAdvertiser() {
if (!getLeAccess()) return null;
- synchronized(mLock) {
+ synchronized (mLock) {
if (sBluetoothLeAdvertiser == null) {
sBluetoothLeAdvertiser = new BluetoothLeAdvertiser(mManagerService);
}
@@ -663,22 +684,25 @@
* <p>
* Use {@link #isLePeriodicAdvertisingSupported()} to check whether LE Periodic Advertising is
* supported on this device before calling this method.
+ *
* @hide
*/
public PeriodicAdvertisingManager getPeriodicAdvertisingManager() {
- if (!getLeAccess())
- return null;
-
- if (!isLePeriodicAdvertisingSupported())
- return null;
-
- synchronized (mLock) {
- if (sPeriodicAdvertisingManager == null) {
- sPeriodicAdvertisingManager =
- new PeriodicAdvertisingManager(mManagerService);
+ if (!getLeAccess()) {
+ return null;
}
- }
- return sPeriodicAdvertisingManager;
+
+ if (!isLePeriodicAdvertisingSupported()) {
+ return null;
+ }
+
+ synchronized (mLock) {
+ if (sPeriodicAdvertisingManager == null) {
+ sPeriodicAdvertisingManager =
+ new PeriodicAdvertisingManager(mManagerService);
+ }
+ }
+ return sPeriodicAdvertisingManager;
}
/**
@@ -686,7 +710,7 @@
*/
public BluetoothLeScanner getBluetoothLeScanner() {
if (!getLeAccess()) return null;
- synchronized(mLock) {
+ synchronized (mLock) {
if (sBluetoothLeScanner == null) {
sBluetoothLeScanner = new BluetoothLeScanner(mManagerService);
}
@@ -725,9 +749,9 @@
*/
@SystemApi
public boolean isLeEnabled() {
- final int state = getLeState();
- if (DBG) Log.d(TAG, "isLeEnabled(): " + BluetoothAdapter.nameForState(state));
- return (state == BluetoothAdapter.STATE_ON || state == BluetoothAdapter.STATE_BLE_ON);
+ final int state = getLeState();
+ if (DBG) Log.d(TAG, "isLeEnabled(): " + BluetoothAdapter.nameForState(state));
+ return (state == BluetoothAdapter.STATE_ON || state == BluetoothAdapter.STATE_BLE_ON);
}
/**
@@ -752,8 +776,7 @@
* immediate problem that will prevent the QAdapter from being turned off -
* such as the QAadapter already being turned off.
*
- * @return true to indicate success, or false on
- * immediate error
+ * @return true to indicate success, or false on immediate error
* @hide
*/
@SystemApi
@@ -763,7 +786,7 @@
int state = getLeState();
if (state == BluetoothAdapter.STATE_ON || state == BluetoothAdapter.STATE_BLE_ON) {
String packageName = ActivityThread.currentPackageName();
- if (DBG) Log.d (TAG, "disableBLE(): de-registering " + packageName);
+ if (DBG) Log.d(TAG, "disableBLE(): de-registering " + packageName);
try {
mManagerService.updateBleAppCount(mToken, false, packageName);
} catch (RemoteException e) {
@@ -772,7 +795,7 @@
return true;
}
- if (DBG) Log.d (TAG, "disableBLE(): Already disabled");
+ if (DBG) Log.d(TAG, "disableBLE(): Already disabled");
return false;
}
@@ -804,8 +827,7 @@
* states, It includes all the classic Bluetooth Adapter states along with
* internal BLE only states
*
- * @return true to indicate Bluetooth LE will be available, or false on
- * immediate error
+ * @return true to indicate Bluetooth LE will be available, or false on immediate error
* @hide
*/
@SystemApi
@@ -856,12 +878,19 @@
// Consider all internal states as OFF
if (state == BluetoothAdapter.STATE_BLE_ON
- || state == BluetoothAdapter.STATE_BLE_TURNING_ON
- || state == BluetoothAdapter.STATE_BLE_TURNING_OFF) {
- if (VDBG) Log.d(TAG, "Consider " + BluetoothAdapter.nameForState(state) + " state as OFF");
+ || state == BluetoothAdapter.STATE_BLE_TURNING_ON
+ || state == BluetoothAdapter.STATE_BLE_TURNING_OFF) {
+ if (VDBG) {
+ Log.d(TAG,
+ "Consider " + BluetoothAdapter.nameForState(state) + " state as OFF");
+ }
state = BluetoothAdapter.STATE_OFF;
}
- if (VDBG) Log.d(TAG, "" + hashCode() + ": getState(). Returning " + BluetoothAdapter.nameForState(state));
+ if (VDBG) {
+ Log.d(TAG,
+ "" + hashCode() + ": getState(). Returning " + BluetoothAdapter.nameForState(
+ state));
+ }
return state;
}
@@ -897,16 +926,16 @@
mServiceLock.readLock().unlock();
}
- if (VDBG) Log.d(TAG,"getLeState() returning " + BluetoothAdapter.nameForState(state));
+ if (VDBG) Log.d(TAG, "getLeState() returning " + BluetoothAdapter.nameForState(state));
return state;
}
boolean getLeAccess() {
- if (getLeState() == STATE_ON)
+ if (getLeState() == STATE_ON) {
return true;
-
- else if (getLeState() == STATE_BLE_ON)
+ } else if (getLeState() == STATE_BLE_ON) {
return true; // TODO: FILTER SYSTEM APPS HERE <--
+ }
return false;
}
@@ -933,8 +962,7 @@
* immediate problem that will prevent the adapter from being turned on -
* such as Airplane mode, or the adapter is already turned on.
*
- * @return true to indicate adapter startup has begun, or false on
- * immediate error
+ * @return true to indicate adapter startup has begun, or false on immediate error
*/
@RequiresPermission(Manifest.permission.BLUETOOTH_ADMIN)
public boolean enable() {
@@ -944,7 +972,9 @@
}
try {
return mManagerService.enable(ActivityThread.currentPackageName());
- } catch (RemoteException e) {Log.e(TAG, "", e);}
+ } catch (RemoteException e) {
+ Log.e(TAG, "", e);
+ }
return false;
}
@@ -967,14 +997,15 @@
* immediate problem that will prevent the adapter from being turned off -
* such as the adapter already being turned off.
*
- * @return true to indicate adapter shutdown has begun, or false on
- * immediate error
+ * @return true to indicate adapter shutdown has begun, or false on immediate error
*/
@RequiresPermission(Manifest.permission.BLUETOOTH_ADMIN)
public boolean disable() {
try {
return mManagerService.disable(ActivityThread.currentPackageName(), true);
- } catch (RemoteException e) {Log.e(TAG, "", e);}
+ } catch (RemoteException e) {
+ Log.e(TAG, "", e);
+ }
return false;
}
@@ -984,15 +1015,16 @@
* <p>Requires the {@link android.Manifest.permission#BLUETOOTH_ADMIN}
* permission
*
- * @return true to indicate adapter shutdown has begun, or false on
- * immediate error
+ * @return true to indicate adapter shutdown has begun, or false on immediate error
* @hide
*/
public boolean disable(boolean persist) {
try {
return mManagerService.disable(ActivityThread.currentPackageName(), persist);
- } catch (RemoteException e) {Log.e(TAG, "", e);}
+ } catch (RemoteException e) {
+ Log.e(TAG, "", e);
+ }
return false;
}
@@ -1006,7 +1038,9 @@
public String getAddress() {
try {
return mManagerService.getAddress();
- } catch (RemoteException e) {Log.e(TAG, "", e);}
+ } catch (RemoteException e) {
+ Log.e(TAG, "", e);
+ }
return null;
}
@@ -1020,7 +1054,9 @@
public String getName() {
try {
return mManagerService.getName();
- } catch (RemoteException e) {Log.e(TAG, "", e);}
+ } catch (RemoteException e) {
+ Log.e(TAG, "", e);
+ }
return null;
}
@@ -1031,7 +1067,6 @@
* permission
*
* @return true to indicate that the config file was successfully cleared
- *
* @hide
*/
public boolean factoryReset() {
@@ -1082,7 +1117,7 @@
* to get the updated value.
*
* @param name a valid Bluetooth name
- * @return true if the name was set, false otherwise
+ * @return true if the name was set, false otherwise
*/
@RequiresPermission(Manifest.permission.BLUETOOTH_ADMIN)
public boolean setName(String name) {
@@ -1151,9 +1186,9 @@
* </code>instead.
*
* @param mode valid scan mode
- * @param duration time in seconds to apply scan mode, only used for
- * {@link #SCAN_MODE_CONNECTABLE_DISCOVERABLE}
- * @return true if the scan mode was set, false otherwise
+ * @param duration time in seconds to apply scan mode, only used for {@link
+ * #SCAN_MODE_CONNECTABLE_DISCOVERABLE}
+ * @return true if the scan mode was set, false otherwise
* @hide
*/
public boolean setScanMode(@ScanMode int mode, int duration) {
@@ -1205,9 +1240,10 @@
/**
* Get the end time of the latest remote device discovery process.
- * @return the latest time that the bluetooth adapter was/will be in discovery mode,
- * in milliseconds since the epoch.
- * This time can be in the future if {@link #startDiscovery()} has been called recently.
+ *
+ * @return the latest time that the bluetooth adapter was/will be in discovery mode, in
+ * milliseconds since the epoch. This time can be in the future if {@link #startDiscovery()} has
+ * been called recently.
* @hide
*/
public long getDiscoveryEndMillis() {
@@ -1517,13 +1553,13 @@
* Return the record of {@link BluetoothActivityEnergyInfo} object that
* has the activity and energy info. This can be used to ascertain what
* the controller has been up to, since the last sample.
- * @param updateType Type of info, cached vs refreshed.
*
- * @return a record with {@link BluetoothActivityEnergyInfo} or null if
- * report is unavailable or unsupported
- * @deprecated use the asynchronous
- * {@link #requestControllerActivityEnergyInfo(ResultReceiver)} instead.
+ * @param updateType Type of info, cached vs refreshed.
+ * @return a record with {@link BluetoothActivityEnergyInfo} or null if report is unavailable or
+ * unsupported
* @hide
+ * @deprecated use the asynchronous {@link #requestControllerActivityEnergyInfo(ResultReceiver)}
+ * instead.
*/
@Deprecated
public BluetoothActivityEnergyInfo getControllerActivityEnergyInfo(int updateType) {
@@ -1599,11 +1635,11 @@
/**
* Gets the currently supported profiles by the adapter.
*
- *<p> This can be used to check whether a profile is supported before attempting
+ * <p> This can be used to check whether a profile is supported before attempting
* to connect to its respective proxy.
*
- * @return a list of integers indicating the ids of supported profiles as defined in
- * {@link BluetoothProfile}.
+ * @return a list of integers indicating the ids of supported profiles as defined in {@link
+ * BluetoothProfile}.
* @hide
*/
public List<Integer> getSupportedProfiles() {
@@ -1622,7 +1658,7 @@
}
}
} catch (RemoteException e) {
- Log.e(TAG, "getSupportedProfiles:", e);
+ Log.e(TAG, "getSupportedProfiles:", e);
}
return supportedProfiles;
}
@@ -1635,9 +1671,8 @@
* <p> Use this function along with {@link #ACTION_CONNECTION_STATE_CHANGED}
* intent to get the connection state of the adapter.
*
- * @return One of {@link #STATE_CONNECTED}, {@link #STATE_DISCONNECTED},
- * {@link #STATE_CONNECTING} or {@link #STATE_DISCONNECTED}
- *
+ * @return One of {@link #STATE_CONNECTED}, {@link #STATE_DISCONNECTED}, {@link
+ * #STATE_CONNECTING} or {@link #STATE_DISCONNECTED}
* @hide
*/
public int getConnectionState() {
@@ -1688,10 +1723,11 @@
* connections from a listening {@link BluetoothServerSocket}.
* <p>Valid RFCOMM channels are in range 1 to 30.
* <p>Requires {@link android.Manifest.permission#BLUETOOTH_ADMIN}
+ *
* @param channel RFCOMM channel to listen on
* @return a listening RFCOMM BluetoothServerSocket
- * @throws IOException on error, for example Bluetooth not available, or
- * insufficient permissions, or channel in use.
+ * @throws IOException on error, for example Bluetooth not available, or insufficient
+ * permissions, or channel in use.
* @hide
*/
public BluetoothServerSocket listenUsingRfcommOn(int channel) throws IOException {
@@ -1708,12 +1744,14 @@
* <p>Requires {@link android.Manifest.permission#BLUETOOTH_ADMIN}
* <p>To auto assign a channel without creating a SDP record use
* {@link SOCKET_CHANNEL_AUTO_STATIC_NO_SDP} as channel number.
+ *
* @param channel RFCOMM channel to listen on
- * @param mitm enforce man-in-the-middle protection for authentication.
- * @param min16DigitPin enforce a pin key length og minimum 16 digit for sec mode 2 connections.
+ * @param mitm enforce man-in-the-middle protection for authentication.
+ * @param min16DigitPin enforce a pin key length og minimum 16 digit for sec mode 2
+ * connections.
* @return a listening RFCOMM BluetoothServerSocket
- * @throws IOException on error, for example Bluetooth not available, or
- * insufficient permissions, or channel in use.
+ * @throws IOException on error, for example Bluetooth not available, or insufficient
+ * permissions, or channel in use.
* @hide
*/
public BluetoothServerSocket listenUsingRfcommOn(int channel, boolean mitm,
@@ -1749,11 +1787,12 @@
* closed, or if this application closes unexpectedly.
* <p>Use {@link BluetoothDevice#createRfcommSocketToServiceRecord} to
* connect to this socket from another device using the same {@link UUID}.
+ *
* @param name service name for SDP record
* @param uuid uuid for SDP record
* @return a listening RFCOMM BluetoothServerSocket
- * @throws IOException on error, for example Bluetooth not available, or
- * insufficient permissions, or channel in use.
+ * @throws IOException on error, for example Bluetooth not available, or insufficient
+ * permissions, or channel in use.
*/
@RequiresPermission(Manifest.permission.BLUETOOTH)
public BluetoothServerSocket listenUsingRfcommWithServiceRecord(String name, UUID uuid)
@@ -1780,11 +1819,12 @@
* closed, or if this application closes unexpectedly.
* <p>Use {@link BluetoothDevice#createRfcommSocketToServiceRecord} to
* connect to this socket from another device using the same {@link UUID}.
+ *
* @param name service name for SDP record
* @param uuid uuid for SDP record
* @return a listening RFCOMM BluetoothServerSocket
- * @throws IOException on error, for example Bluetooth not available, or
- * insufficient permissions, or channel in use.
+ * @throws IOException on error, for example Bluetooth not available, or insufficient
+ * permissions, or channel in use.
*/
@RequiresPermission(Manifest.permission.BLUETOOTH)
public BluetoothServerSocket listenUsingInsecureRfcommWithServiceRecord(String name, UUID uuid)
@@ -1792,7 +1832,7 @@
return createNewRfcommSocketAndRecord(name, uuid, false, false);
}
- /**
+ /**
* Create a listening, encrypted,
* RFCOMM Bluetooth socket with Service Record.
* <p>The link will be encrypted, but the link key is not required to be authenticated
@@ -1818,11 +1858,12 @@
* <p>Use {@link BluetoothDevice#createRfcommSocketToServiceRecord} to
* connect to this socket from another device using the same {@link UUID}.
* <p>Requires {@link android.Manifest.permission#BLUETOOTH}
+ *
* @param name service name for SDP record
* @param uuid uuid for SDP record
* @return a listening RFCOMM BluetoothServerSocket
- * @throws IOException on error, for example Bluetooth not available, or
- * insufficient permissions, or channel in use.
+ * @throws IOException on error, for example Bluetooth not available, or insufficient
+ * permissions, or channel in use.
* @hide
*/
public BluetoothServerSocket listenUsingEncryptedRfcommWithServiceRecord(
@@ -1835,7 +1876,7 @@
boolean auth, boolean encrypt) throws IOException {
BluetoothServerSocket socket;
socket = new BluetoothServerSocket(BluetoothSocket.TYPE_RFCOMM, auth,
- encrypt, new ParcelUuid(uuid));
+ encrypt, new ParcelUuid(uuid));
socket.setServiceName(name);
int errno = socket.mSocket.bindListen();
if (errno != 0) {
@@ -1850,16 +1891,17 @@
/**
* Construct an unencrypted, unauthenticated, RFCOMM server socket.
* Call #accept to retrieve connections to this socket.
+ *
* @return An RFCOMM BluetoothServerSocket
- * @throws IOException On error, for example Bluetooth not available, or
- * insufficient permissions.
+ * @throws IOException On error, for example Bluetooth not available, or insufficient
+ * permissions.
* @hide
*/
public BluetoothServerSocket listenUsingInsecureRfcommOn(int port) throws IOException {
BluetoothServerSocket socket = new BluetoothServerSocket(
BluetoothSocket.TYPE_RFCOMM, false, false, port);
int errno = socket.mSocket.bindListen();
- if(port == SOCKET_CHANNEL_AUTO_STATIC_NO_SDP) {
+ if (port == SOCKET_CHANNEL_AUTO_STATIC_NO_SDP) {
socket.setChannel(socket.mSocket.getPort());
}
if (errno != 0) {
@@ -1871,12 +1913,13 @@
return socket;
}
- /**
+ /**
* Construct an encrypted, RFCOMM server socket.
* Call #accept to retrieve connections to this socket.
+ *
* @return An RFCOMM BluetoothServerSocket
- * @throws IOException On error, for example Bluetooth not available, or
- * insufficient permissions.
+ * @throws IOException On error, for example Bluetooth not available, or insufficient
+ * permissions.
* @hide
*/
public BluetoothServerSocket listenUsingEncryptedRfcommOn(int port)
@@ -1884,7 +1927,7 @@
BluetoothServerSocket socket = new BluetoothServerSocket(
BluetoothSocket.TYPE_RFCOMM, false, true, port);
int errno = socket.mSocket.bindListen();
- if(port == SOCKET_CHANNEL_AUTO_STATIC_NO_SDP) {
+ if (port == SOCKET_CHANNEL_AUTO_STATIC_NO_SDP) {
socket.setChannel(socket.mSocket.getPort());
}
if (errno < 0) {
@@ -1899,9 +1942,10 @@
/**
* Construct a SCO server socket.
* Call #accept to retrieve connections to this socket.
+ *
* @return A SCO BluetoothServerSocket
- * @throws IOException On error, for example Bluetooth not available, or
- * insufficient permissions.
+ * @throws IOException On error, for example Bluetooth not available, or insufficient
+ * permissions.
* @hide
*/
public static BluetoothServerSocket listenUsingScoOn() throws IOException {
@@ -1921,12 +1965,14 @@
* Call #accept to retrieve connections to this socket.
* <p>To auto assign a port without creating a SDP record use
* {@link SOCKET_CHANNEL_AUTO_STATIC_NO_SDP} as port number.
- * @param port the PSM to listen on
- * @param mitm enforce man-in-the-middle protection for authentication.
- * @param min16DigitPin enforce a pin key length og minimum 16 digit for sec mode 2 connections.
+ *
+ * @param port the PSM to listen on
+ * @param mitm enforce man-in-the-middle protection for authentication.
+ * @param min16DigitPin enforce a pin key length og minimum 16 digit for sec mode 2
+ * connections.
* @return An L2CAP BluetoothServerSocket
- * @throws IOException On error, for example Bluetooth not available, or
- * insufficient permissions.
+ * @throws IOException On error, for example Bluetooth not available, or insufficient
+ * permissions.
* @hide
*/
public BluetoothServerSocket listenUsingL2capOn(int port, boolean mitm, boolean min16DigitPin)
@@ -1934,7 +1980,7 @@
BluetoothServerSocket socket = new BluetoothServerSocket(
BluetoothSocket.TYPE_L2CAP, true, true, port, mitm, min16DigitPin);
int errno = socket.mSocket.bindListen();
- if(port == SOCKET_CHANNEL_AUTO_STATIC_NO_SDP) {
+ if (port == SOCKET_CHANNEL_AUTO_STATIC_NO_SDP) {
socket.setChannel(socket.mSocket.getPort());
}
if (errno != 0) {
@@ -1951,10 +1997,11 @@
* Call #accept to retrieve connections to this socket.
* <p>To auto assign a port without creating a SDP record use
* {@link SOCKET_CHANNEL_AUTO_STATIC_NO_SDP} as port number.
- * @param port the PSM to listen on
+ *
+ * @param port the PSM to listen on
* @return An L2CAP BluetoothServerSocket
- * @throws IOException On error, for example Bluetooth not available, or
- * insufficient permissions.
+ * @throws IOException On error, for example Bluetooth not available, or insufficient
+ * permissions.
* @hide
*/
public BluetoothServerSocket listenUsingL2capOn(int port) throws IOException {
@@ -1967,17 +2014,18 @@
* Call #accept to retrieve connections to this socket.
* <p>To auto assign a port without creating a SDP record use
* {@link SOCKET_CHANNEL_AUTO_STATIC_NO_SDP} as port number.
- * @param port the PSM to listen on
+ *
+ * @param port the PSM to listen on
* @return An L2CAP BluetoothServerSocket
- * @throws IOException On error, for example Bluetooth not available, or
- * insufficient permissions.
+ * @throws IOException On error, for example Bluetooth not available, or insufficient
+ * permissions.
* @hide
*/
public BluetoothServerSocket listenUsingInsecureL2capOn(int port) throws IOException {
BluetoothServerSocket socket = new BluetoothServerSocket(
BluetoothSocket.TYPE_L2CAP, false, false, port, false, false);
int errno = socket.mSocket.bindListen();
- if(port == SOCKET_CHANNEL_AUTO_STATIC_NO_SDP) {
+ if (port == SOCKET_CHANNEL_AUTO_STATIC_NO_SDP) {
socket.setChannel(socket.mSocket.getPort());
}
if (errno != 0) {
@@ -1995,7 +2043,6 @@
* <p>Requires {@link android.Manifest.permission#BLUETOOTH}
*
* @return Pair<byte[], byte[]> of Hash and Randomizer
- *
* @hide
*/
public Pair<byte[], byte[]> readOutOfBandData() {
@@ -2013,13 +2060,13 @@
*
* @param context Context of the application
* @param listener The service Listener for connection callbacks.
- * @param profile The Bluetooth profile; either {@link BluetoothProfile#HEALTH},
- * {@link BluetoothProfile#HEADSET}, {@link BluetoothProfile#A2DP}.
- * {@link BluetoothProfile#GATT} or {@link BluetoothProfile#GATT_SERVER}.
+ * @param profile The Bluetooth profile; either {@link BluetoothProfile#HEALTH}, {@link
+ * BluetoothProfile#HEADSET}, {@link BluetoothProfile#A2DP}. {@link BluetoothProfile#GATT} or
+ * {@link BluetoothProfile#GATT_SERVER}.
* @return true on success, false on error
*/
public boolean getProfileProxy(Context context, BluetoothProfile.ServiceListener listener,
- int profile) {
+ int profile) {
if (context == null || listener == null) return false;
if (profile == BluetoothProfile.HEADSET) {
@@ -2082,59 +2129,59 @@
switch (profile) {
case BluetoothProfile.HEADSET:
- BluetoothHeadset headset = (BluetoothHeadset)proxy;
+ BluetoothHeadset headset = (BluetoothHeadset) proxy;
headset.close();
break;
case BluetoothProfile.A2DP:
- BluetoothA2dp a2dp = (BluetoothA2dp)proxy;
+ BluetoothA2dp a2dp = (BluetoothA2dp) proxy;
a2dp.close();
break;
case BluetoothProfile.A2DP_SINK:
- BluetoothA2dpSink a2dpSink = (BluetoothA2dpSink)proxy;
+ BluetoothA2dpSink a2dpSink = (BluetoothA2dpSink) proxy;
a2dpSink.close();
break;
case BluetoothProfile.AVRCP_CONTROLLER:
- BluetoothAvrcpController avrcp = (BluetoothAvrcpController)proxy;
+ BluetoothAvrcpController avrcp = (BluetoothAvrcpController) proxy;
avrcp.close();
break;
case BluetoothProfile.INPUT_DEVICE:
- BluetoothInputDevice iDev = (BluetoothInputDevice)proxy;
+ BluetoothInputDevice iDev = (BluetoothInputDevice) proxy;
iDev.close();
break;
case BluetoothProfile.PAN:
- BluetoothPan pan = (BluetoothPan)proxy;
+ BluetoothPan pan = (BluetoothPan) proxy;
pan.close();
break;
case BluetoothProfile.HEALTH:
- BluetoothHealth health = (BluetoothHealth)proxy;
+ BluetoothHealth health = (BluetoothHealth) proxy;
health.close();
break;
- case BluetoothProfile.GATT:
- BluetoothGatt gatt = (BluetoothGatt)proxy;
+ case BluetoothProfile.GATT:
+ BluetoothGatt gatt = (BluetoothGatt) proxy;
gatt.close();
break;
case BluetoothProfile.GATT_SERVER:
- BluetoothGattServer gattServer = (BluetoothGattServer)proxy;
+ BluetoothGattServer gattServer = (BluetoothGattServer) proxy;
gattServer.close();
break;
case BluetoothProfile.MAP:
- BluetoothMap map = (BluetoothMap)proxy;
+ BluetoothMap map = (BluetoothMap) proxy;
map.close();
break;
case BluetoothProfile.HEADSET_CLIENT:
- BluetoothHeadsetClient headsetClient = (BluetoothHeadsetClient)proxy;
+ BluetoothHeadsetClient headsetClient = (BluetoothHeadsetClient) proxy;
headsetClient.close();
break;
case BluetoothProfile.SAP:
- BluetoothSap sap = (BluetoothSap)proxy;
+ BluetoothSap sap = (BluetoothSap) proxy;
sap.close();
break;
case BluetoothProfile.PBAP_CLIENT:
- BluetoothPbapClient pbapClient = (BluetoothPbapClient)proxy;
+ BluetoothPbapClient pbapClient = (BluetoothPbapClient) proxy;
pbapClient.close();
break;
case BluetoothProfile.MAP_CLIENT:
- BluetoothMapClient mapClient = (BluetoothMapClient)proxy;
+ BluetoothMapClient mapClient = (BluetoothMapClient) proxy;
mapClient.close();
break;
case BluetoothProfile.INPUT_HOST:
@@ -2145,75 +2192,78 @@
}
final private IBluetoothManagerCallback mManagerCallback =
- new IBluetoothManagerCallback.Stub() {
- public void onBluetoothServiceUp(IBluetooth bluetoothService) {
- if (DBG) Log.d(TAG, "onBluetoothServiceUp: " + bluetoothService);
+ new IBluetoothManagerCallback.Stub() {
+ public void onBluetoothServiceUp(IBluetooth bluetoothService) {
+ if (DBG) Log.d(TAG, "onBluetoothServiceUp: " + bluetoothService);
- mServiceLock.writeLock().lock();
- mService = bluetoothService;
- mServiceLock.writeLock().unlock();
-
- synchronized (mProxyServiceStateCallbacks) {
- for (IBluetoothManagerCallback cb : mProxyServiceStateCallbacks ) {
- try {
- if (cb != null) {
- cb.onBluetoothServiceUp(bluetoothService);
- } else {
- Log.d(TAG, "onBluetoothServiceUp: cb is null!");
- }
- } catch (Exception e) {
- Log.e(TAG,"",e);
- }
- }
- }
- }
-
- public void onBluetoothServiceDown() {
- if (DBG) Log.d(TAG, "onBluetoothServiceDown: " + mService);
-
- try {
mServiceLock.writeLock().lock();
- mService = null;
- if (mLeScanClients != null) mLeScanClients.clear();
- if (sBluetoothLeAdvertiser != null) sBluetoothLeAdvertiser.cleanup();
- if (sBluetoothLeScanner != null) sBluetoothLeScanner.cleanup();
- } finally {
+ mService = bluetoothService;
mServiceLock.writeLock().unlock();
- }
- synchronized (mProxyServiceStateCallbacks) {
- for (IBluetoothManagerCallback cb : mProxyServiceStateCallbacks ){
- try {
- if (cb != null) {
- cb.onBluetoothServiceDown();
- } else {
- Log.d(TAG, "onBluetoothServiceDown: cb is null!");
+ synchronized (mProxyServiceStateCallbacks) {
+ for (IBluetoothManagerCallback cb : mProxyServiceStateCallbacks) {
+ try {
+ if (cb != null) {
+ cb.onBluetoothServiceUp(bluetoothService);
+ } else {
+ Log.d(TAG, "onBluetoothServiceUp: cb is null!");
+ }
+ } catch (Exception e) {
+ Log.e(TAG, "", e);
}
- } catch (Exception e) {
- Log.e(TAG,"",e);
}
}
}
- }
- public void onBrEdrDown() {
- if (VDBG) Log.i(TAG, "onBrEdrDown: " + mService);
- }
- };
+ public void onBluetoothServiceDown() {
+ if (DBG) Log.d(TAG, "onBluetoothServiceDown: " + mService);
+
+ try {
+ mServiceLock.writeLock().lock();
+ mService = null;
+ if (mLeScanClients != null) mLeScanClients.clear();
+ if (sBluetoothLeAdvertiser != null) sBluetoothLeAdvertiser.cleanup();
+ if (sBluetoothLeScanner != null) sBluetoothLeScanner.cleanup();
+ } finally {
+ mServiceLock.writeLock().unlock();
+ }
+
+ synchronized (mProxyServiceStateCallbacks) {
+ for (IBluetoothManagerCallback cb : mProxyServiceStateCallbacks) {
+ try {
+ if (cb != null) {
+ cb.onBluetoothServiceDown();
+ } else {
+ Log.d(TAG, "onBluetoothServiceDown: cb is null!");
+ }
+ } catch (Exception e) {
+ Log.e(TAG, "", e);
+ }
+ }
+ }
+ }
+
+ public void onBrEdrDown() {
+ if (VDBG) Log.i(TAG, "onBrEdrDown: " + mService);
+ }
+ };
/**
* Enable the Bluetooth Adapter, but don't auto-connect devices
* and don't persist state. Only for use by system applications.
+ *
* @hide
*/
public boolean enableNoAutoConnect() {
- if (isEnabled() == true){
+ if (isEnabled() == true) {
if (DBG) Log.d(TAG, "enableNoAutoConnect(): BT already enabled!");
return true;
}
try {
return mManagerService.enableNoAutoConnect(ActivityThread.currentPackageName());
- } catch (RemoteException e) {Log.e(TAG, "", e);}
+ } catch (RemoteException e) {
+ Log.e(TAG, "", e);
+ }
return false;
}
@@ -2247,7 +2297,7 @@
* @hide
*/
public boolean changeApplicationBluetoothState(boolean on,
- BluetoothStateChangeCallback callback) {
+ BluetoothStateChangeCallback callback) {
return false;
}
@@ -2305,28 +2355,29 @@
for (int i = 0; i < ADDRESS_LENGTH; i++) {
char c = address.charAt(i);
switch (i % 3) {
- case 0:
- case 1:
- if ((c >= '0' && c <= '9') || (c >= 'A' && c <= 'F')) {
- // hex character, OK
- break;
- }
- return false;
- case 2:
- if (c == ':') {
- break; // OK
- }
- return false;
+ case 0:
+ case 1:
+ if ((c >= '0' && c <= '9') || (c >= 'A' && c <= 'F')) {
+ // hex character, OK
+ break;
+ }
+ return false;
+ case 2:
+ if (c == ':') {
+ break; // OK
+ }
+ return false;
}
}
return true;
}
/*package*/ IBluetoothManager getBluetoothManager() {
- return mManagerService;
+ return mManagerService;
}
- final private ArrayList<IBluetoothManagerCallback> mProxyServiceStateCallbacks = new ArrayList<IBluetoothManagerCallback>();
+ final private ArrayList<IBluetoothManagerCallback> mProxyServiceStateCallbacks =
+ new ArrayList<IBluetoothManagerCallback>();
/*package*/ IBluetooth getBluetoothService(IBluetoothManagerCallback cb) {
synchronized (mProxyServiceStateCallbacks) {
@@ -2357,10 +2408,9 @@
* by the {@link BluetoothAdapter#startLeScan} function.
*
* @param device Identifies the remote device
- * @param rssi The RSSI value for the remote device as reported by the
- * Bluetooth hardware. 0 if no RSSI value is available.
- * @param scanRecord The content of the advertisement record offered by
- * the remote device.
+ * @param rssi The RSSI value for the remote device as reported by the Bluetooth hardware. 0
+ * if no RSSI value is available.
+ * @param scanRecord The content of the advertisement record offered by the remote device.
*/
public void onLeScan(BluetoothDevice device, int rssi, byte[] scanRecord);
}
@@ -2374,7 +2424,7 @@
* @param callback the callback LE scan results are delivered
* @return true, if the scan was started successfully
* @deprecated use {@link BluetoothLeScanner#startScan(List, ScanSettings, ScanCallback)}
- * instead.
+ * instead.
*/
@Deprecated
@RequiresPermission(Manifest.permission.BLUETOOTH_ADMIN)
@@ -2393,7 +2443,7 @@
* @param callback the callback LE scan results are delivered
* @return true, if the scan was started successfully
* @deprecated use {@link BluetoothLeScanner#startScan(List, ScanSettings, ScanCallback)}
- * instead.
+ * instead.
*/
@Deprecated
@RequiresPermission(Manifest.permission.BLUETOOTH_ADMIN)
@@ -2409,7 +2459,7 @@
return false;
}
- synchronized(mLeScanClients) {
+ synchronized (mLeScanClients) {
if (mLeScanClients.containsKey(callback)) {
if (DBG) Log.e(TAG, "LE Scan has already started");
return false;
@@ -2450,8 +2500,8 @@
}
};
ScanSettings settings = new ScanSettings.Builder()
- .setCallbackType(ScanSettings.CALLBACK_TYPE_ALL_MATCHES)
- .setScanMode(ScanSettings.SCAN_MODE_LOW_LATENCY).build();
+ .setCallbackType(ScanSettings.CALLBACK_TYPE_ALL_MATCHES)
+ .setScanMode(ScanSettings.SCAN_MODE_LOW_LATENCY).build();
List<ScanFilter> filters = new ArrayList<ScanFilter>();
if (serviceUuids != null && serviceUuids.length > 0) {
@@ -2467,7 +2517,7 @@
return true;
} catch (RemoteException e) {
- Log.e(TAG,"",e);
+ Log.e(TAG, "", e);
}
}
return false;
@@ -2476,8 +2526,8 @@
/**
* Stops an ongoing Bluetooth LE device scan.
*
- * @param callback used to identify which scan to stop
- * must be the same handle used to start the scan
+ * @param callback used to identify which scan to stop must be the same handle used to start the
+ * scan
* @deprecated Use {@link BluetoothLeScanner#stopScan(ScanCallback)} instead.
*/
@Deprecated
diff --git a/framework/java/android/bluetooth/BluetoothAssignedNumbers.java b/framework/java/android/bluetooth/BluetoothAssignedNumbers.java
index 124bdc1..41a34e0 100644
--- a/framework/java/android/bluetooth/BluetoothAssignedNumbers.java
+++ b/framework/java/android/bluetooth/BluetoothAssignedNumbers.java
@@ -20,9 +20,9 @@
* Bluetooth Assigned Numbers.
* <p>
* For now we only include Company ID values.
- * @see <a href="https://www.bluetooth.org/technical/assignednumbers/identifiers.htm">
- * The Official Bluetooth SIG Member Website | Company Identifiers</a>
*
+ * @see <a href="https://www.bluetooth.org/technical/assignednumbers/identifiers.htm"> The Official
+ * Bluetooth SIG Member Website | Company Identifiers</a>
*/
public class BluetoothAssignedNumbers {
diff --git a/framework/java/android/bluetooth/BluetoothAudioConfig.java b/framework/java/android/bluetooth/BluetoothAudioConfig.java
index 03176b9..238bf84 100644
--- a/framework/java/android/bluetooth/BluetoothAudioConfig.java
+++ b/framework/java/android/bluetooth/BluetoothAudioConfig.java
@@ -41,7 +41,7 @@
@Override
public boolean equals(Object o) {
if (o instanceof BluetoothAudioConfig) {
- BluetoothAudioConfig bac = (BluetoothAudioConfig)o;
+ BluetoothAudioConfig bac = (BluetoothAudioConfig) o;
return (bac.mSampleRate == mSampleRate &&
bac.mChannelConfig == mChannelConfig &&
bac.mAudioFormat == mAudioFormat);
@@ -66,16 +66,17 @@
public static final Parcelable.Creator<BluetoothAudioConfig> CREATOR =
new Parcelable.Creator<BluetoothAudioConfig>() {
- public BluetoothAudioConfig createFromParcel(Parcel in) {
- int sampleRate = in.readInt();
- int channelConfig = in.readInt();
- int audioFormat = in.readInt();
- return new BluetoothAudioConfig(sampleRate, channelConfig, audioFormat);
- }
- public BluetoothAudioConfig[] newArray(int size) {
- return new BluetoothAudioConfig[size];
- }
- };
+ public BluetoothAudioConfig createFromParcel(Parcel in) {
+ int sampleRate = in.readInt();
+ int channelConfig = in.readInt();
+ int audioFormat = in.readInt();
+ return new BluetoothAudioConfig(sampleRate, channelConfig, audioFormat);
+ }
+
+ public BluetoothAudioConfig[] newArray(int size) {
+ return new BluetoothAudioConfig[size];
+ }
+ };
public void writeToParcel(Parcel out, int flags) {
out.writeInt(mSampleRate);
@@ -85,6 +86,7 @@
/**
* Returns the sample rate in samples per second
+ *
* @return sample rate
*/
public int getSampleRate() {
@@ -94,6 +96,7 @@
/**
* Returns the channel configuration (either {@link android.media.AudioFormat#CHANNEL_IN_MONO}
* or {@link android.media.AudioFormat#CHANNEL_IN_STEREO})
+ *
* @return channel configuration
*/
public int getChannelConfig() {
@@ -103,6 +106,7 @@
/**
* Returns the channel audio format (either {@link android.media.AudioFormat#ENCODING_PCM_16BIT}
* or {@link android.media.AudioFormat#ENCODING_PCM_8BIT}
+ *
* @return audio format
*/
public int getAudioFormat() {
diff --git a/framework/java/android/bluetooth/BluetoothAvrcp.java b/framework/java/android/bluetooth/BluetoothAvrcp.java
index 44fe1b7..1a4c759 100644
--- a/framework/java/android/bluetooth/BluetoothAvrcp.java
+++ b/framework/java/android/bluetooth/BluetoothAvrcp.java
@@ -26,68 +26,68 @@
/*
* State flags for Passthrough commands
*/
- public static final int PASSTHROUGH_STATE_PRESS = 0;
- public static final int PASSTHROUGH_STATE_RELEASE = 1;
+ public static final int PASSTHROUGH_STATE_PRESS = 0;
+ public static final int PASSTHROUGH_STATE_RELEASE = 1;
/*
* Operation IDs for Passthrough commands
*/
- public static final int PASSTHROUGH_ID_SELECT = 0x00; /* select */
- public static final int PASSTHROUGH_ID_UP = 0x01; /* up */
- public static final int PASSTHROUGH_ID_DOWN = 0x02; /* down */
- public static final int PASSTHROUGH_ID_LEFT = 0x03; /* left */
- public static final int PASSTHROUGH_ID_RIGHT = 0x04; /* right */
- public static final int PASSTHROUGH_ID_RIGHT_UP = 0x05; /* right-up */
- public static final int PASSTHROUGH_ID_RIGHT_DOWN = 0x06; /* right-down */
- public static final int PASSTHROUGH_ID_LEFT_UP = 0x07; /* left-up */
- public static final int PASSTHROUGH_ID_LEFT_DOWN = 0x08; /* left-down */
- public static final int PASSTHROUGH_ID_ROOT_MENU = 0x09; /* root menu */
- public static final int PASSTHROUGH_ID_SETUP_MENU = 0x0A; /* setup menu */
- public static final int PASSTHROUGH_ID_CONT_MENU = 0x0B; /* contents menu */
- public static final int PASSTHROUGH_ID_FAV_MENU = 0x0C; /* favorite menu */
- public static final int PASSTHROUGH_ID_EXIT = 0x0D; /* exit */
- public static final int PASSTHROUGH_ID_0 = 0x20; /* 0 */
- public static final int PASSTHROUGH_ID_1 = 0x21; /* 1 */
- public static final int PASSTHROUGH_ID_2 = 0x22; /* 2 */
- public static final int PASSTHROUGH_ID_3 = 0x23; /* 3 */
- public static final int PASSTHROUGH_ID_4 = 0x24; /* 4 */
- public static final int PASSTHROUGH_ID_5 = 0x25; /* 5 */
- public static final int PASSTHROUGH_ID_6 = 0x26; /* 6 */
- public static final int PASSTHROUGH_ID_7 = 0x27; /* 7 */
- public static final int PASSTHROUGH_ID_8 = 0x28; /* 8 */
- public static final int PASSTHROUGH_ID_9 = 0x29; /* 9 */
- public static final int PASSTHROUGH_ID_DOT = 0x2A; /* dot */
- public static final int PASSTHROUGH_ID_ENTER = 0x2B; /* enter */
- public static final int PASSTHROUGH_ID_CLEAR = 0x2C; /* clear */
- public static final int PASSTHROUGH_ID_CHAN_UP = 0x30; /* channel up */
- public static final int PASSTHROUGH_ID_CHAN_DOWN = 0x31; /* channel down */
- public static final int PASSTHROUGH_ID_PREV_CHAN = 0x32; /* previous channel */
- public static final int PASSTHROUGH_ID_SOUND_SEL = 0x33; /* sound select */
- public static final int PASSTHROUGH_ID_INPUT_SEL = 0x34; /* input select */
- public static final int PASSTHROUGH_ID_DISP_INFO = 0x35; /* display information */
- public static final int PASSTHROUGH_ID_HELP = 0x36; /* help */
- public static final int PASSTHROUGH_ID_PAGE_UP = 0x37; /* page up */
- public static final int PASSTHROUGH_ID_PAGE_DOWN = 0x38; /* page down */
- public static final int PASSTHROUGH_ID_POWER = 0x40; /* power */
- public static final int PASSTHROUGH_ID_VOL_UP = 0x41; /* volume up */
- public static final int PASSTHROUGH_ID_VOL_DOWN = 0x42; /* volume down */
- public static final int PASSTHROUGH_ID_MUTE = 0x43; /* mute */
- public static final int PASSTHROUGH_ID_PLAY = 0x44; /* play */
- public static final int PASSTHROUGH_ID_STOP = 0x45; /* stop */
- public static final int PASSTHROUGH_ID_PAUSE = 0x46; /* pause */
- public static final int PASSTHROUGH_ID_RECORD = 0x47; /* record */
- public static final int PASSTHROUGH_ID_REWIND = 0x48; /* rewind */
- public static final int PASSTHROUGH_ID_FAST_FOR = 0x49; /* fast forward */
- public static final int PASSTHROUGH_ID_EJECT = 0x4A; /* eject */
- public static final int PASSTHROUGH_ID_FORWARD = 0x4B; /* forward */
- public static final int PASSTHROUGH_ID_BACKWARD = 0x4C; /* backward */
- public static final int PASSTHROUGH_ID_ANGLE = 0x50; /* angle */
- public static final int PASSTHROUGH_ID_SUBPICT = 0x51; /* subpicture */
- public static final int PASSTHROUGH_ID_F1 = 0x71; /* F1 */
- public static final int PASSTHROUGH_ID_F2 = 0x72; /* F2 */
- public static final int PASSTHROUGH_ID_F3 = 0x73; /* F3 */
- public static final int PASSTHROUGH_ID_F4 = 0x74; /* F4 */
- public static final int PASSTHROUGH_ID_F5 = 0x75; /* F5 */
- public static final int PASSTHROUGH_ID_VENDOR = 0x7E; /* vendor unique */
+ public static final int PASSTHROUGH_ID_SELECT = 0x00; /* select */
+ public static final int PASSTHROUGH_ID_UP = 0x01; /* up */
+ public static final int PASSTHROUGH_ID_DOWN = 0x02; /* down */
+ public static final int PASSTHROUGH_ID_LEFT = 0x03; /* left */
+ public static final int PASSTHROUGH_ID_RIGHT = 0x04; /* right */
+ public static final int PASSTHROUGH_ID_RIGHT_UP = 0x05; /* right-up */
+ public static final int PASSTHROUGH_ID_RIGHT_DOWN = 0x06; /* right-down */
+ public static final int PASSTHROUGH_ID_LEFT_UP = 0x07; /* left-up */
+ public static final int PASSTHROUGH_ID_LEFT_DOWN = 0x08; /* left-down */
+ public static final int PASSTHROUGH_ID_ROOT_MENU = 0x09; /* root menu */
+ public static final int PASSTHROUGH_ID_SETUP_MENU = 0x0A; /* setup menu */
+ public static final int PASSTHROUGH_ID_CONT_MENU = 0x0B; /* contents menu */
+ public static final int PASSTHROUGH_ID_FAV_MENU = 0x0C; /* favorite menu */
+ public static final int PASSTHROUGH_ID_EXIT = 0x0D; /* exit */
+ public static final int PASSTHROUGH_ID_0 = 0x20; /* 0 */
+ public static final int PASSTHROUGH_ID_1 = 0x21; /* 1 */
+ public static final int PASSTHROUGH_ID_2 = 0x22; /* 2 */
+ public static final int PASSTHROUGH_ID_3 = 0x23; /* 3 */
+ public static final int PASSTHROUGH_ID_4 = 0x24; /* 4 */
+ public static final int PASSTHROUGH_ID_5 = 0x25; /* 5 */
+ public static final int PASSTHROUGH_ID_6 = 0x26; /* 6 */
+ public static final int PASSTHROUGH_ID_7 = 0x27; /* 7 */
+ public static final int PASSTHROUGH_ID_8 = 0x28; /* 8 */
+ public static final int PASSTHROUGH_ID_9 = 0x29; /* 9 */
+ public static final int PASSTHROUGH_ID_DOT = 0x2A; /* dot */
+ public static final int PASSTHROUGH_ID_ENTER = 0x2B; /* enter */
+ public static final int PASSTHROUGH_ID_CLEAR = 0x2C; /* clear */
+ public static final int PASSTHROUGH_ID_CHAN_UP = 0x30; /* channel up */
+ public static final int PASSTHROUGH_ID_CHAN_DOWN = 0x31; /* channel down */
+ public static final int PASSTHROUGH_ID_PREV_CHAN = 0x32; /* previous channel */
+ public static final int PASSTHROUGH_ID_SOUND_SEL = 0x33; /* sound select */
+ public static final int PASSTHROUGH_ID_INPUT_SEL = 0x34; /* input select */
+ public static final int PASSTHROUGH_ID_DISP_INFO = 0x35; /* display information */
+ public static final int PASSTHROUGH_ID_HELP = 0x36; /* help */
+ public static final int PASSTHROUGH_ID_PAGE_UP = 0x37; /* page up */
+ public static final int PASSTHROUGH_ID_PAGE_DOWN = 0x38; /* page down */
+ public static final int PASSTHROUGH_ID_POWER = 0x40; /* power */
+ public static final int PASSTHROUGH_ID_VOL_UP = 0x41; /* volume up */
+ public static final int PASSTHROUGH_ID_VOL_DOWN = 0x42; /* volume down */
+ public static final int PASSTHROUGH_ID_MUTE = 0x43; /* mute */
+ public static final int PASSTHROUGH_ID_PLAY = 0x44; /* play */
+ public static final int PASSTHROUGH_ID_STOP = 0x45; /* stop */
+ public static final int PASSTHROUGH_ID_PAUSE = 0x46; /* pause */
+ public static final int PASSTHROUGH_ID_RECORD = 0x47; /* record */
+ public static final int PASSTHROUGH_ID_REWIND = 0x48; /* rewind */
+ public static final int PASSTHROUGH_ID_FAST_FOR = 0x49; /* fast forward */
+ public static final int PASSTHROUGH_ID_EJECT = 0x4A; /* eject */
+ public static final int PASSTHROUGH_ID_FORWARD = 0x4B; /* forward */
+ public static final int PASSTHROUGH_ID_BACKWARD = 0x4C; /* backward */
+ public static final int PASSTHROUGH_ID_ANGLE = 0x50; /* angle */
+ public static final int PASSTHROUGH_ID_SUBPICT = 0x51; /* subpicture */
+ public static final int PASSTHROUGH_ID_F1 = 0x71; /* F1 */
+ public static final int PASSTHROUGH_ID_F2 = 0x72; /* F2 */
+ public static final int PASSTHROUGH_ID_F3 = 0x73; /* F3 */
+ public static final int PASSTHROUGH_ID_F4 = 0x74; /* F4 */
+ public static final int PASSTHROUGH_ID_F5 = 0x75; /* F5 */
+ public static final int PASSTHROUGH_ID_VENDOR = 0x7E; /* vendor unique */
public static final int PASSTHROUGH_KEYPRESSED_RELEASE = 0x80;
}
diff --git a/framework/java/android/bluetooth/BluetoothAvrcpController.java b/framework/java/android/bluetooth/BluetoothAvrcpController.java
index 0261b1b..1a0ae14 100644
--- a/framework/java/android/bluetooth/BluetoothAvrcpController.java
+++ b/framework/java/android/bluetooth/BluetoothAvrcpController.java
@@ -20,8 +20,6 @@
import android.content.Context;
import android.content.Intent;
import android.content.ServiceConnection;
-import android.media.MediaMetadata;
-import android.media.session.PlaybackState;
import android.os.Binder;
import android.os.IBinder;
import android.os.RemoteException;
@@ -34,7 +32,7 @@
* This class provides the public APIs to control the Bluetooth AVRCP Controller. It currently
* supports player information, playback support and track metadata.
*
- *<p>BluetoothAvrcpController is a proxy object for controlling the Bluetooth AVRCP
+ * <p>BluetoothAvrcpController is a proxy object for controlling the Bluetooth AVRCP
* Service via IPC. Use {@link BluetoothAdapter#getProfileProxy} to get
* the BluetoothAvrcpController proxy object.
*
@@ -51,9 +49,9 @@
*
* <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
@@ -64,19 +62,19 @@
* receive.
*/
public static final String ACTION_CONNECTION_STATE_CHANGED =
- "android.bluetooth.avrcp-controller.profile.action.CONNECTION_STATE_CHANGED";
+ "android.bluetooth.avrcp-controller.profile.action.CONNECTION_STATE_CHANGED";
/**
* Intent used to broadcast the change in player application setting state on AVRCP AG.
*
* <p>This intent will have the following extras:
* <ul>
- * <li> {@link #EXTRA_PLAYER_SETTING} - {@link BluetoothAvrcpPlayerSettings} containing the
- * most recent player setting. </li>
+ * <li> {@link #EXTRA_PLAYER_SETTING} - {@link BluetoothAvrcpPlayerSettings} containing the
+ * most recent player setting. </li>
* </ul>
*/
public static final String ACTION_PLAYER_SETTING =
- "android.bluetooth.avrcp-controller.profile.action.PLAYER_SETTING";
+ "android.bluetooth.avrcp-controller.profile.action.PLAYER_SETTING";
public static final String EXTRA_PLAYER_SETTING =
"android.bluetooth.avrcp-controller.profile.extra.PLAYER_SETTING";
@@ -87,38 +85,37 @@
private BluetoothAdapter mAdapter;
final private 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...");
- synchronized (mConnection) {
- try {
- mService = null;
- mContext.unbindService(mConnection);
- } catch (Exception re) {
- Log.e(TAG,"",re);
- }
- }
- } else {
- synchronized (mConnection) {
- try {
- if (mService == null) {
- if (VDBG) Log.d(TAG,"Binding service...");
- doBind();
+ 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...");
+ synchronized (mConnection) {
+ try {
+ mService = null;
+ mContext.unbindService(mConnection);
+ } catch (Exception re) {
+ Log.e(TAG, "", re);
}
- } catch (Exception re) {
- Log.e(TAG,"",re);
+ }
+ } else {
+ synchronized (mConnection) {
+ try {
+ if (mService == null) {
+ if (VDBG) Log.d(TAG, "Binding service...");
+ doBind();
+ }
+ } catch (Exception re) {
+ Log.e(TAG, "", re);
+ }
}
}
}
- }
- };
+ };
/**
* Create a BluetoothAvrcpController proxy object for interacting with the local
* Bluetooth AVRCP service.
- *
*/
/*package*/ BluetoothAvrcpController(Context context, ServiceListener l) {
mContext = context;
@@ -129,7 +126,7 @@
try {
mgr.registerStateChangeCallback(mBluetoothStateChangeCallback);
} catch (RemoteException e) {
- Log.e(TAG,"",e);
+ Log.e(TAG, "", e);
}
}
@@ -155,7 +152,7 @@
try {
mgr.unregisterStateChangeCallback(mBluetoothStateChangeCallback);
} catch (Exception e) {
- Log.e(TAG,"",e);
+ Log.e(TAG, "", e);
}
}
@@ -165,7 +162,7 @@
mService = null;
mContext.unbindService(mConnection);
} catch (Exception re) {
- Log.e(TAG,"",re);
+ Log.e(TAG, "", re);
}
}
}
@@ -215,7 +212,7 @@
public int getConnectionState(BluetoothDevice device) {
if (VDBG) log("getState(" + device + ")");
if (mService != null && isEnabled()
- && isValidDevice(device)) {
+ && isValidDevice(device)) {
try {
return mService.getConnectionState(device);
} catch (RemoteException e) {
@@ -269,7 +266,8 @@
* possible keycode values: next_grp, previous_grp defined above
*/
public void sendGroupNavigationCmd(BluetoothDevice device, int keyCode, int keyState) {
- Log.d(TAG, "sendGroupNavigationCmd dev = " + device + " key " + keyCode + " State = " + keyState);
+ Log.d(TAG, "sendGroupNavigationCmd dev = " + device + " key " + keyCode + " State = "
+ + keyState);
if (mService != null && isEnabled()) {
try {
mService.sendGroupNavigationCmd(device, keyCode, keyState);
@@ -292,6 +290,7 @@
BluetoothAvrcpController.this);
}
}
+
public void onServiceDisconnected(ComponentName className) {
if (DBG) Log.d(TAG, "Proxy object disconnected");
mService = null;
@@ -302,18 +301,18 @@
};
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) {
- Log.d(TAG, msg);
+ Log.d(TAG, msg);
}
}
diff --git a/framework/java/android/bluetooth/BluetoothAvrcpPlayerSettings.java b/framework/java/android/bluetooth/BluetoothAvrcpPlayerSettings.java
index 927cb56..036d36d 100644
--- a/framework/java/android/bluetooth/BluetoothAvrcpPlayerSettings.java
+++ b/framework/java/android/bluetooth/BluetoothAvrcpPlayerSettings.java
@@ -34,22 +34,22 @@
/**
* Equalizer setting.
*/
- public static final int SETTING_EQUALIZER = 0x01;
+ public static final int SETTING_EQUALIZER = 0x01;
/**
* Repeat setting.
*/
- public static final int SETTING_REPEAT = 0x02;
+ public static final int SETTING_REPEAT = 0x02;
/**
* Shuffle setting.
*/
- public static final int SETTING_SHUFFLE = 0x04;
+ public static final int SETTING_SHUFFLE = 0x04;
/**
* Scan mode setting.
*/
- public static final int SETTING_SCAN = 0x08;
+ public static final int SETTING_SCAN = 0x08;
/**
* Invalid state.
@@ -84,14 +84,14 @@
*
* Applies to {@link SETTING_REPEAT}, {@link SETTING_SHUFFLE} and {@link SETTING_SCAN}.
*/
- public static final int STATE_ALL_TRACK = 0x03;
+ public static final int STATE_ALL_TRACK = 0x03;
/**
* Group repeat/shuffle.
*
* Applies to {@link SETTING_REPEAT}, {@link SETTING_SHUFFLE} and {@link SETTING_SCAN}.
*/
- public static final int STATE_GROUP = 0x04;
+ public static final int STATE_GROUP = 0x04;
/**
* List of supported settings ORed.
@@ -157,6 +157,7 @@
* Add a setting value.
*
* The setting must be part of possible settings in {@link getSettings()}.
+ *
* @param setting setting config.
* @param value value for the setting.
* @throws IllegalStateException if the setting is not supported.
@@ -173,6 +174,7 @@
* Get a setting value.
*
* The setting must be part of possible settings in {@link getSettings()}.
+ *
* @param setting setting config.
* @return value value for the setting.
* @throws IllegalStateException if the setting is not supported.
diff --git a/framework/java/android/bluetooth/BluetoothClass.java b/framework/java/android/bluetooth/BluetoothClass.java
index 4a38287..2f6a793 100755
--- a/framework/java/android/bluetooth/BluetoothClass.java
+++ b/framework/java/android/bluetooth/BluetoothClass.java
@@ -51,6 +51,7 @@
public final class BluetoothClass implements Parcelable {
/**
* Legacy error value. Applications should use null instead.
+ *
* @hide
*/
public static final int ERROR = 0xFF000000;
@@ -65,7 +66,7 @@
@Override
public boolean equals(Object o) {
if (o instanceof BluetoothClass) {
- return mClass == ((BluetoothClass)o).mClass;
+ return mClass == ((BluetoothClass) o).mClass;
}
return false;
}
@@ -86,13 +87,14 @@
public static final Parcelable.Creator<BluetoothClass> CREATOR =
new Parcelable.Creator<BluetoothClass>() {
- public BluetoothClass createFromParcel(Parcel in) {
- return new BluetoothClass(in.readInt());
- }
- public BluetoothClass[] newArray(int size) {
- return new BluetoothClass[size];
- }
- };
+ public BluetoothClass createFromParcel(Parcel in) {
+ return new BluetoothClass(in.readInt());
+ }
+
+ public BluetoothClass[] newArray(int size) {
+ return new BluetoothClass[size];
+ }
+ };
public void writeToParcel(Parcel out, int flags) {
out.writeInt(mClass);
@@ -103,17 +105,17 @@
* <p>Each {@link BluetoothClass} encodes zero or more service classes.
*/
public static final class Service {
- private static final int BITMASK = 0xFFE000;
+ private static final int BITMASK = 0xFFE000;
public static final int LIMITED_DISCOVERABILITY = 0x002000;
- public static final int POSITIONING = 0x010000;
- public static final int NETWORKING = 0x020000;
- public static final int RENDER = 0x040000;
- public static final int CAPTURE = 0x080000;
- public static final int OBJECT_TRANSFER = 0x100000;
- public static final int AUDIO = 0x200000;
- public static final int TELEPHONY = 0x400000;
- public static final int INFORMATION = 0x800000;
+ public static final int POSITIONING = 0x010000;
+ public static final int NETWORKING = 0x020000;
+ public static final int RENDER = 0x040000;
+ public static final int CAPTURE = 0x080000;
+ public static final int OBJECT_TRANSFER = 0x100000;
+ public static final int AUDIO = 0x200000;
+ public static final int TELEPHONY = 0x400000;
+ public static final int INFORMATION = 0x800000;
}
/**
@@ -141,91 +143,91 @@
* <p>See {@link BluetoothClass.Service} for service class constants.
*/
public static class Device {
- private static final int BITMASK = 0x1FFC;
+ private static final int BITMASK = 0x1FFC;
/**
* Defines all major device class constants.
* <p>See {@link BluetoothClass.Device} for minor classes.
*/
public static class Major {
- private static final int BITMASK = 0x1F00;
+ private static final int BITMASK = 0x1F00;
- public static final int MISC = 0x0000;
- public static final int COMPUTER = 0x0100;
- public static final int PHONE = 0x0200;
- public static final int NETWORKING = 0x0300;
- public static final int AUDIO_VIDEO = 0x0400;
- public static final int PERIPHERAL = 0x0500;
- public static final int IMAGING = 0x0600;
- public static final int WEARABLE = 0x0700;
- public static final int TOY = 0x0800;
- public static final int HEALTH = 0x0900;
- public static final int UNCATEGORIZED = 0x1F00;
+ public static final int MISC = 0x0000;
+ public static final int COMPUTER = 0x0100;
+ public static final int PHONE = 0x0200;
+ public static final int NETWORKING = 0x0300;
+ public static final int AUDIO_VIDEO = 0x0400;
+ public static final int PERIPHERAL = 0x0500;
+ public static final int IMAGING = 0x0600;
+ public static final int WEARABLE = 0x0700;
+ public static final int TOY = 0x0800;
+ public static final int HEALTH = 0x0900;
+ public static final int UNCATEGORIZED = 0x1F00;
}
// Devices in the COMPUTER major class
- public static final int COMPUTER_UNCATEGORIZED = 0x0100;
- public static final int COMPUTER_DESKTOP = 0x0104;
- public static final int COMPUTER_SERVER = 0x0108;
- public static final int COMPUTER_LAPTOP = 0x010C;
- public static final int COMPUTER_HANDHELD_PC_PDA = 0x0110;
- public static final int COMPUTER_PALM_SIZE_PC_PDA = 0x0114;
- public static final int COMPUTER_WEARABLE = 0x0118;
+ public static final int COMPUTER_UNCATEGORIZED = 0x0100;
+ public static final int COMPUTER_DESKTOP = 0x0104;
+ public static final int COMPUTER_SERVER = 0x0108;
+ public static final int COMPUTER_LAPTOP = 0x010C;
+ public static final int COMPUTER_HANDHELD_PC_PDA = 0x0110;
+ public static final int COMPUTER_PALM_SIZE_PC_PDA = 0x0114;
+ public static final int COMPUTER_WEARABLE = 0x0118;
// Devices in the PHONE major class
- public static final int PHONE_UNCATEGORIZED = 0x0200;
- public static final int PHONE_CELLULAR = 0x0204;
- public static final int PHONE_CORDLESS = 0x0208;
- public static final int PHONE_SMART = 0x020C;
- public static final int PHONE_MODEM_OR_GATEWAY = 0x0210;
- public static final int PHONE_ISDN = 0x0214;
+ public static final int PHONE_UNCATEGORIZED = 0x0200;
+ public static final int PHONE_CELLULAR = 0x0204;
+ public static final int PHONE_CORDLESS = 0x0208;
+ public static final int PHONE_SMART = 0x020C;
+ public static final int PHONE_MODEM_OR_GATEWAY = 0x0210;
+ public static final int PHONE_ISDN = 0x0214;
// Minor classes for the AUDIO_VIDEO major class
- public static final int AUDIO_VIDEO_UNCATEGORIZED = 0x0400;
- public static final int AUDIO_VIDEO_WEARABLE_HEADSET = 0x0404;
- public static final int AUDIO_VIDEO_HANDSFREE = 0x0408;
+ public static final int AUDIO_VIDEO_UNCATEGORIZED = 0x0400;
+ public static final int AUDIO_VIDEO_WEARABLE_HEADSET = 0x0404;
+ public static final int AUDIO_VIDEO_HANDSFREE = 0x0408;
//public static final int AUDIO_VIDEO_RESERVED = 0x040C;
- public static final int AUDIO_VIDEO_MICROPHONE = 0x0410;
- public static final int AUDIO_VIDEO_LOUDSPEAKER = 0x0414;
- public static final int AUDIO_VIDEO_HEADPHONES = 0x0418;
- public static final int AUDIO_VIDEO_PORTABLE_AUDIO = 0x041C;
- public static final int AUDIO_VIDEO_CAR_AUDIO = 0x0420;
- public static final int AUDIO_VIDEO_SET_TOP_BOX = 0x0424;
- public static final int AUDIO_VIDEO_HIFI_AUDIO = 0x0428;
- public static final int AUDIO_VIDEO_VCR = 0x042C;
- public static final int AUDIO_VIDEO_VIDEO_CAMERA = 0x0430;
- public static final int AUDIO_VIDEO_CAMCORDER = 0x0434;
- public static final int AUDIO_VIDEO_VIDEO_MONITOR = 0x0438;
+ public static final int AUDIO_VIDEO_MICROPHONE = 0x0410;
+ public static final int AUDIO_VIDEO_LOUDSPEAKER = 0x0414;
+ public static final int AUDIO_VIDEO_HEADPHONES = 0x0418;
+ public static final int AUDIO_VIDEO_PORTABLE_AUDIO = 0x041C;
+ public static final int AUDIO_VIDEO_CAR_AUDIO = 0x0420;
+ public static final int AUDIO_VIDEO_SET_TOP_BOX = 0x0424;
+ public static final int AUDIO_VIDEO_HIFI_AUDIO = 0x0428;
+ public static final int AUDIO_VIDEO_VCR = 0x042C;
+ public static final int AUDIO_VIDEO_VIDEO_CAMERA = 0x0430;
+ public static final int AUDIO_VIDEO_CAMCORDER = 0x0434;
+ public static final int AUDIO_VIDEO_VIDEO_MONITOR = 0x0438;
public static final int AUDIO_VIDEO_VIDEO_DISPLAY_AND_LOUDSPEAKER = 0x043C;
- public static final int AUDIO_VIDEO_VIDEO_CONFERENCING = 0x0440;
+ public static final int AUDIO_VIDEO_VIDEO_CONFERENCING = 0x0440;
//public static final int AUDIO_VIDEO_RESERVED = 0x0444;
- public static final int AUDIO_VIDEO_VIDEO_GAMING_TOY = 0x0448;
+ public static final int AUDIO_VIDEO_VIDEO_GAMING_TOY = 0x0448;
// Devices in the WEARABLE major class
- public static final int WEARABLE_UNCATEGORIZED = 0x0700;
- public static final int WEARABLE_WRIST_WATCH = 0x0704;
- public static final int WEARABLE_PAGER = 0x0708;
- public static final int WEARABLE_JACKET = 0x070C;
- public static final int WEARABLE_HELMET = 0x0710;
- public static final int WEARABLE_GLASSES = 0x0714;
+ public static final int WEARABLE_UNCATEGORIZED = 0x0700;
+ public static final int WEARABLE_WRIST_WATCH = 0x0704;
+ public static final int WEARABLE_PAGER = 0x0708;
+ public static final int WEARABLE_JACKET = 0x070C;
+ public static final int WEARABLE_HELMET = 0x0710;
+ public static final int WEARABLE_GLASSES = 0x0714;
// Devices in the TOY major class
- public static final int TOY_UNCATEGORIZED = 0x0800;
- public static final int TOY_ROBOT = 0x0804;
- public static final int TOY_VEHICLE = 0x0808;
- public static final int TOY_DOLL_ACTION_FIGURE = 0x080C;
- public static final int TOY_CONTROLLER = 0x0810;
- public static final int TOY_GAME = 0x0814;
+ public static final int TOY_UNCATEGORIZED = 0x0800;
+ public static final int TOY_ROBOT = 0x0804;
+ public static final int TOY_VEHICLE = 0x0808;
+ public static final int TOY_DOLL_ACTION_FIGURE = 0x080C;
+ public static final int TOY_CONTROLLER = 0x0810;
+ public static final int TOY_GAME = 0x0814;
// Devices in the HEALTH major class
- public static final int HEALTH_UNCATEGORIZED = 0x0900;
- public static final int HEALTH_BLOOD_PRESSURE = 0x0904;
- public static final int HEALTH_THERMOMETER = 0x0908;
- public static final int HEALTH_WEIGHING = 0x090C;
- public static final int HEALTH_GLUCOSE = 0x0910;
- public static final int HEALTH_PULSE_OXIMETER = 0x0914;
- public static final int HEALTH_PULSE_RATE = 0x0918;
- public static final int HEALTH_DATA_DISPLAY = 0x091C;
+ public static final int HEALTH_UNCATEGORIZED = 0x0900;
+ public static final int HEALTH_BLOOD_PRESSURE = 0x0904;
+ public static final int HEALTH_THERMOMETER = 0x0908;
+ public static final int HEALTH_WEIGHING = 0x090C;
+ public static final int HEALTH_GLUCOSE = 0x0910;
+ public static final int HEALTH_PULSE_OXIMETER = 0x0914;
+ public static final int HEALTH_PULSE_RATE = 0x0918;
+ public static final int HEALTH_DATA_DISPLAY = 0x091C;
// Devices in PERIPHERAL major class
/**
@@ -235,15 +237,15 @@
/**
* @hide
*/
- public static final int PERIPHERAL_KEYBOARD = 0x0540;
+ public static final int PERIPHERAL_KEYBOARD = 0x0540;
/**
* @hide
*/
- public static final int PERIPHERAL_POINTING = 0x0580;
+ public static final int PERIPHERAL_POINTING = 0x0580;
/**
* @hide
*/
- public static final int PERIPHERAL_KEYBOARD_POINTING = 0x05C0;
+ public static final int PERIPHERAL_KEYBOARD_POINTING = 0x05C0;
}
/**
@@ -291,6 +293,7 @@
* This is a simple heuristic that tries to guess if a device with the
* given class bits might support specified profile. It is not accurate for all
* devices. It tries to err on the side of false positives.
+ *
* @param profile The profile to be checked
* @return True if this device might support specified profile.
* @hide
@@ -322,7 +325,7 @@
switch (getDeviceClass()) {
case Device.AUDIO_VIDEO_HIFI_AUDIO:
case Device.AUDIO_VIDEO_SET_TOP_BOX:
- case Device.AUDIO_VIDEO_VCR :
+ case Device.AUDIO_VIDEO_VCR:
return true;
default:
return false;
@@ -367,7 +370,7 @@
}
} else if (profile == PROFILE_HID) {
return (getDeviceClass() & Device.Major.PERIPHERAL) == Device.Major.PERIPHERAL;
- } else if (profile == PROFILE_PANU || profile == PROFILE_NAP){
+ } else if (profile == PROFILE_PANU || profile == PROFILE_NAP) {
// No good way to distinguish between the two, based on class bits.
if (hasService(Service.NETWORKING)) {
return true;
diff --git a/framework/java/android/bluetooth/BluetoothCodecConfig.java b/framework/java/android/bluetooth/BluetoothCodecConfig.java
index d5e1429..1e463f7 100644
--- a/framework/java/android/bluetooth/BluetoothCodecConfig.java
+++ b/framework/java/android/bluetooth/BluetoothCodecConfig.java
@@ -32,12 +32,12 @@
// Add an entry for each source codec here.
// NOTE: The values should be same as those listed in the following file:
// hardware/libhardware/include/hardware/bt_av.h
- public static final int SOURCE_CODEC_TYPE_SBC = 0;
- public static final int SOURCE_CODEC_TYPE_AAC = 1;
- public static final int SOURCE_CODEC_TYPE_APTX = 2;
+ public static final int SOURCE_CODEC_TYPE_SBC = 0;
+ public static final int SOURCE_CODEC_TYPE_AAC = 1;
+ public static final int SOURCE_CODEC_TYPE_APTX = 2;
public static final int SOURCE_CODEC_TYPE_APTX_HD = 3;
- public static final int SOURCE_CODEC_TYPE_LDAC = 4;
- public static final int SOURCE_CODEC_TYPE_MAX = 5;
+ public static final int SOURCE_CODEC_TYPE_LDAC = 4;
+ public static final int SOURCE_CODEC_TYPE_MAX = 5;
public static final int SOURCE_CODEC_TYPE_INVALID = 1000 * 1000;
@@ -45,21 +45,21 @@
public static final int CODEC_PRIORITY_DEFAULT = 0;
public static final int CODEC_PRIORITY_HIGHEST = 1000 * 1000;
- public static final int SAMPLE_RATE_NONE = 0;
- public static final int SAMPLE_RATE_44100 = 0x1 << 0;
- public static final int SAMPLE_RATE_48000 = 0x1 << 1;
- public static final int SAMPLE_RATE_88200 = 0x1 << 2;
- public static final int SAMPLE_RATE_96000 = 0x1 << 3;
+ public static final int SAMPLE_RATE_NONE = 0;
+ public static final int SAMPLE_RATE_44100 = 0x1 << 0;
+ public static final int SAMPLE_RATE_48000 = 0x1 << 1;
+ public static final int SAMPLE_RATE_88200 = 0x1 << 2;
+ public static final int SAMPLE_RATE_96000 = 0x1 << 3;
public static final int SAMPLE_RATE_176400 = 0x1 << 4;
public static final int SAMPLE_RATE_192000 = 0x1 << 5;
public static final int BITS_PER_SAMPLE_NONE = 0;
- public static final int BITS_PER_SAMPLE_16 = 0x1 << 0;
- public static final int BITS_PER_SAMPLE_24 = 0x1 << 1;
- public static final int BITS_PER_SAMPLE_32 = 0x1 << 2;
+ public static final int BITS_PER_SAMPLE_16 = 0x1 << 0;
+ public static final int BITS_PER_SAMPLE_24 = 0x1 << 1;
+ public static final int BITS_PER_SAMPLE_32 = 0x1 << 2;
- public static final int CHANNEL_MODE_NONE = 0;
- public static final int CHANNEL_MODE_MONO = 0x1 << 0;
+ public static final int CHANNEL_MODE_NONE = 0;
+ public static final int CHANNEL_MODE_MONO = 0x1 << 0;
public static final int CHANNEL_MODE_STEREO = 0x1 << 1;
private final int mCodecType;
@@ -73,10 +73,10 @@
private final long mCodecSpecific4;
public BluetoothCodecConfig(int codecType, int codecPriority,
- int sampleRate, int bitsPerSample,
- int channelMode, long codecSpecific1,
- long codecSpecific2, long codecSpecific3,
- long codecSpecific4) {
+ int sampleRate, int bitsPerSample,
+ int channelMode, long codecSpecific1,
+ long codecSpecific2, long codecSpecific3,
+ long codecSpecific4) {
mCodecType = codecType;
mCodecPriority = codecPriority;
mSampleRate = sampleRate;
@@ -91,7 +91,7 @@
@Override
public boolean equals(Object o) {
if (o instanceof BluetoothCodecConfig) {
- BluetoothCodecConfig other = (BluetoothCodecConfig)o;
+ BluetoothCodecConfig other = (BluetoothCodecConfig) o;
return (other.mCodecType == mCodecType &&
other.mCodecPriority == mCodecPriority &&
other.mSampleRate == mSampleRate &&
@@ -108,32 +108,30 @@
@Override
public int hashCode() {
return Objects.hash(mCodecType, mCodecPriority, mSampleRate,
- mBitsPerSample, mChannelMode, mCodecSpecific1,
- mCodecSpecific2, mCodecSpecific3, mCodecSpecific4);
+ mBitsPerSample, mChannelMode, mCodecSpecific1,
+ mCodecSpecific2, mCodecSpecific3, mCodecSpecific4);
}
/**
* Checks whether the object contains valid codec configuration.
*
- * @return true if the object contains valid codec configuration,
- * otherwise false.
+ * @return true if the object contains valid codec configuration, otherwise false.
*/
public boolean isValid() {
return (mSampleRate != SAMPLE_RATE_NONE) &&
- (mBitsPerSample != BITS_PER_SAMPLE_NONE) &&
- (mChannelMode != CHANNEL_MODE_NONE);
+ (mBitsPerSample != BITS_PER_SAMPLE_NONE) &&
+ (mChannelMode != CHANNEL_MODE_NONE);
}
/**
* Adds capability string to an existing string.
*
- * @param prevStr the previous string with the capabilities. Can be
- * a null pointer.
+ * @param prevStr the previous string with the capabilities. Can be a null pointer.
* @param capStr the capability string to append to prevStr argument.
* @return the result string in the form "prevStr|capStr".
*/
private static String appendCapabilityToString(String prevStr,
- String capStr) {
+ String capStr) {
if (prevStr == null) {
return capStr;
}
@@ -191,18 +189,18 @@
}
return "{codecName:" + getCodecName() +
- ",mCodecType:" + mCodecType +
- ",mCodecPriority:" + mCodecPriority +
- ",mSampleRate:" + String.format("0x%x", mSampleRate) +
- "(" + sampleRateStr + ")" +
- ",mBitsPerSample:" + String.format("0x%x", mBitsPerSample) +
- "(" + bitsPerSampleStr + ")" +
- ",mChannelMode:" + String.format("0x%x", mChannelMode) +
- "(" + channelModeStr + ")" +
- ",mCodecSpecific1:" + mCodecSpecific1 +
- ",mCodecSpecific2:" + mCodecSpecific2 +
- ",mCodecSpecific3:" + mCodecSpecific3 +
- ",mCodecSpecific4:" + mCodecSpecific4 + "}";
+ ",mCodecType:" + mCodecType +
+ ",mCodecPriority:" + mCodecPriority +
+ ",mSampleRate:" + String.format("0x%x", mSampleRate) +
+ "(" + sampleRateStr + ")" +
+ ",mBitsPerSample:" + String.format("0x%x", mBitsPerSample) +
+ "(" + bitsPerSampleStr + ")" +
+ ",mChannelMode:" + String.format("0x%x", mChannelMode) +
+ "(" + channelModeStr + ")" +
+ ",mCodecSpecific1:" + mCodecSpecific1 +
+ ",mCodecSpecific2:" + mCodecSpecific2 +
+ ",mCodecSpecific3:" + mCodecSpecific3 +
+ ",mCodecSpecific4:" + mCodecSpecific4 + "}";
}
public int describeContents() {
@@ -211,26 +209,27 @@
public static final Parcelable.Creator<BluetoothCodecConfig> CREATOR =
new Parcelable.Creator<BluetoothCodecConfig>() {
- public BluetoothCodecConfig createFromParcel(Parcel in) {
- final int codecType = in.readInt();
- final int codecPriority = in.readInt();
- final int sampleRate = in.readInt();
- final int bitsPerSample = in.readInt();
- final int channelMode = in.readInt();
- final long codecSpecific1 = in.readLong();
- final long codecSpecific2 = in.readLong();
- final long codecSpecific3 = in.readLong();
- final long codecSpecific4 = in.readLong();
- return new BluetoothCodecConfig(codecType, codecPriority,
- sampleRate, bitsPerSample,
- channelMode, codecSpecific1,
- codecSpecific2, codecSpecific3,
- codecSpecific4);
- }
- public BluetoothCodecConfig[] newArray(int size) {
- return new BluetoothCodecConfig[size];
- }
- };
+ public BluetoothCodecConfig createFromParcel(Parcel in) {
+ final int codecType = in.readInt();
+ final int codecPriority = in.readInt();
+ final int sampleRate = in.readInt();
+ final int bitsPerSample = in.readInt();
+ final int channelMode = in.readInt();
+ final long codecSpecific1 = in.readLong();
+ final long codecSpecific2 = in.readLong();
+ final long codecSpecific3 = in.readLong();
+ final long codecSpecific4 = in.readLong();
+ return new BluetoothCodecConfig(codecType, codecPriority,
+ sampleRate, bitsPerSample,
+ channelMode, codecSpecific1,
+ codecSpecific2, codecSpecific3,
+ codecSpecific4);
+ }
+
+ public BluetoothCodecConfig[] newArray(int size) {
+ return new BluetoothCodecConfig[size];
+ }
+ };
public void writeToParcel(Parcel out, int flags) {
out.writeInt(mCodecType);
@@ -251,20 +250,20 @@
*/
public String getCodecName() {
switch (mCodecType) {
- case SOURCE_CODEC_TYPE_SBC:
- return "SBC";
- case SOURCE_CODEC_TYPE_AAC:
- return "AAC";
- case SOURCE_CODEC_TYPE_APTX:
- return "aptX";
- case SOURCE_CODEC_TYPE_APTX_HD:
- return "aptX HD";
- case SOURCE_CODEC_TYPE_LDAC:
- return "LDAC";
- case SOURCE_CODEC_TYPE_INVALID:
- return "INVALID CODEC";
- default:
- break;
+ case SOURCE_CODEC_TYPE_SBC:
+ return "SBC";
+ case SOURCE_CODEC_TYPE_AAC:
+ return "AAC";
+ case SOURCE_CODEC_TYPE_APTX:
+ return "aptX";
+ case SOURCE_CODEC_TYPE_APTX_HD:
+ return "aptX HD";
+ case SOURCE_CODEC_TYPE_LDAC:
+ return "LDAC";
+ case SOURCE_CODEC_TYPE_INVALID:
+ return "INVALID CODEC";
+ default:
+ break;
}
return "UNKNOWN CODEC(" + mCodecType + ")";
}
diff --git a/framework/java/android/bluetooth/BluetoothCodecStatus.java b/framework/java/android/bluetooth/BluetoothCodecStatus.java
index c8cd8d1..61e2941 100644
--- a/framework/java/android/bluetooth/BluetoothCodecStatus.java
+++ b/framework/java/android/bluetooth/BluetoothCodecStatus.java
@@ -38,15 +38,15 @@
* profile.
*/
public static final String EXTRA_CODEC_STATUS =
- "android.bluetooth.codec.extra.CODEC_STATUS";
+ "android.bluetooth.codec.extra.CODEC_STATUS";
private final BluetoothCodecConfig mCodecConfig;
private final BluetoothCodecConfig[] mCodecsLocalCapabilities;
private final BluetoothCodecConfig[] mCodecsSelectableCapabilities;
public BluetoothCodecStatus(BluetoothCodecConfig codecConfig,
- BluetoothCodecConfig[] codecsLocalCapabilities,
- BluetoothCodecConfig[] codecsSelectableCapabilities) {
+ BluetoothCodecConfig[] codecsLocalCapabilities,
+ BluetoothCodecConfig[] codecsSelectableCapabilities) {
mCodecConfig = codecConfig;
mCodecsLocalCapabilities = codecsLocalCapabilities;
mCodecsSelectableCapabilities = codecsSelectableCapabilities;
@@ -55,12 +55,12 @@
@Override
public boolean equals(Object o) {
if (o instanceof BluetoothCodecStatus) {
- BluetoothCodecStatus other = (BluetoothCodecStatus)o;
+ BluetoothCodecStatus other = (BluetoothCodecStatus) o;
return (Objects.equals(other.mCodecConfig, mCodecConfig) &&
Objects.equals(other.mCodecsLocalCapabilities,
- mCodecsLocalCapabilities) &&
+ mCodecsLocalCapabilities) &&
Objects.equals(other.mCodecsSelectableCapabilities,
- mCodecsSelectableCapabilities));
+ mCodecsSelectableCapabilities));
}
return false;
}
@@ -68,15 +68,15 @@
@Override
public int hashCode() {
return Objects.hash(mCodecConfig, mCodecsLocalCapabilities,
- mCodecsLocalCapabilities);
+ mCodecsLocalCapabilities);
}
@Override
public String toString() {
return "{mCodecConfig:" + mCodecConfig +
- ",mCodecsLocalCapabilities:" + Arrays.toString(mCodecsLocalCapabilities) +
- ",mCodecsSelectableCapabilities:" + Arrays.toString(mCodecsSelectableCapabilities) +
- "}";
+ ",mCodecsLocalCapabilities:" + Arrays.toString(mCodecsLocalCapabilities) +
+ ",mCodecsSelectableCapabilities:" + Arrays.toString(mCodecsSelectableCapabilities) +
+ "}";
}
public int describeContents() {
@@ -85,19 +85,23 @@
public static final Parcelable.Creator<BluetoothCodecStatus> CREATOR =
new Parcelable.Creator<BluetoothCodecStatus>() {
- public BluetoothCodecStatus createFromParcel(Parcel in) {
- final BluetoothCodecConfig codecConfig = in.readTypedObject(BluetoothCodecConfig.CREATOR);
- final BluetoothCodecConfig[] codecsLocalCapabilities = in.createTypedArray(BluetoothCodecConfig.CREATOR);
- final BluetoothCodecConfig[] codecsSelectableCapabilities = in.createTypedArray(BluetoothCodecConfig.CREATOR);
+ public BluetoothCodecStatus createFromParcel(Parcel in) {
+ final BluetoothCodecConfig codecConfig = in.readTypedObject(
+ BluetoothCodecConfig.CREATOR);
+ final BluetoothCodecConfig[] codecsLocalCapabilities = in.createTypedArray(
+ BluetoothCodecConfig.CREATOR);
+ final BluetoothCodecConfig[] codecsSelectableCapabilities = in.createTypedArray(
+ BluetoothCodecConfig.CREATOR);
- return new BluetoothCodecStatus(codecConfig,
- codecsLocalCapabilities,
- codecsSelectableCapabilities);
- }
- public BluetoothCodecStatus[] newArray(int size) {
- return new BluetoothCodecStatus[size];
- }
- };
+ return new BluetoothCodecStatus(codecConfig,
+ codecsLocalCapabilities,
+ codecsSelectableCapabilities);
+ }
+
+ public BluetoothCodecStatus[] newArray(int size) {
+ return new BluetoothCodecStatus[size];
+ }
+ };
public void writeToParcel(Parcel out, int flags) {
out.writeTypedObject(mCodecConfig, 0);
diff --git a/framework/java/android/bluetooth/BluetoothDevice.java b/framework/java/android/bluetooth/BluetoothDevice.java
index a206b53..537d913 100644
--- a/framework/java/android/bluetooth/BluetoothDevice.java
+++ b/framework/java/android/bluetooth/BluetoothDevice.java
@@ -23,10 +23,9 @@
import android.annotation.SystemApi;
import android.content.Context;
import android.os.Handler;
-import android.os.Looper;
import android.os.Parcel;
-import android.os.Parcelable;
import android.os.ParcelUuid;
+import android.os.Parcelable;
import android.os.Process;
import android.os.RemoteException;
import android.util.Log;
@@ -101,7 +100,7 @@
* <p>Requires {@link android.Manifest.permission#BLUETOOTH} and
* {@link android.Manifest.permission#ACCESS_COARSE_LOCATION} to receive.
*/
- // TODO: Change API to not broadcast RSSI if not available (incoming connection)
+ // TODO: Change API to not broadcast RSSI if not available (incoming connection)
@SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
public static final String ACTION_FOUND =
"android.bluetooth.device.action.FOUND";
@@ -112,6 +111,7 @@
* found in the current discovery.
* <p>Always contains the extra field {@link #EXTRA_DEVICE}.
* <p>Requires {@link android.Manifest.permission#BLUETOOTH} to receive.
+ *
* @hide
*/
@SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
@@ -208,6 +208,7 @@
* <p>Always contains the extra fields {@link #EXTRA_DEVICE} and {@link
* #EXTRA_BATTERY_LEVEL}.
* <p>Requires {@link android.Manifest.permission#BLUETOOTH} to receive.
+ *
* @hide
*/
@SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
@@ -219,6 +220,7 @@
* intent. It contains the most recently retrieved battery level information
* ranging from 0% to 100% for a remote device, {@link #BATTERY_LEVEL_UNKNOWN}
* when the valid is unknown or there is an error
+ *
* @hide
*/
public static final String EXTRA_BATTERY_LEVEL =
@@ -226,6 +228,7 @@
/**
* Used as the unknown value for {@link #EXTRA_BATTERY_LEVEL} and {@link #getBatteryLevel()}
+ *
* @hide
*/
public static final int BATTERY_LEVEL_UNKNOWN = -1;
@@ -300,6 +303,7 @@
/**
* Used as an int extra field in {@link #ACTION_PAIRING_REQUEST}
* intents for unbond reason.
+ *
* @hide
*/
public static final String EXTRA_REASON = "android.bluetooth.device.extra.REASON";
@@ -368,6 +372,7 @@
* device.
* <p>Always contains the extra field {@link #EXTRA_DEVICE}.
* <p>Requires {@link android.Manifest.permission#BLUETOOTH} to receive.
+ *
* @hide
*/
//TODO: is this actually useful?
@@ -405,26 +410,28 @@
/**
* Used as an extra field in {@link #ACTION_CONNECTION_ACCESS_REQUEST} intent.
+ *
* @hide
*/
public static final String EXTRA_ACCESS_REQUEST_TYPE =
- "android.bluetooth.device.extra.ACCESS_REQUEST_TYPE";
+ "android.bluetooth.device.extra.ACCESS_REQUEST_TYPE";
- /**@hide*/
+ /** @hide */
public static final int REQUEST_TYPE_PROFILE_CONNECTION = 1;
- /**@hide*/
+ /** @hide */
public static final int REQUEST_TYPE_PHONEBOOK_ACCESS = 2;
- /**@hide*/
+ /** @hide */
public static final int REQUEST_TYPE_MESSAGE_ACCESS = 3;
- /**@hide*/
+ /** @hide */
public static final int REQUEST_TYPE_SIM_ACCESS = 4;
/**
* Used as an extra field in {@link #ACTION_CONNECTION_ACCESS_REQUEST} intents,
* Contains package name to return reply intent to.
+ *
* @hide
*/
public static final String EXTRA_PACKAGE_NAME = "android.bluetooth.device.extra.PACKAGE_NAME";
@@ -432,34 +439,38 @@
/**
* Used as an extra field in {@link #ACTION_CONNECTION_ACCESS_REQUEST} intents,
* Contains class name to return reply intent to.
+ *
* @hide
*/
public static final String EXTRA_CLASS_NAME = "android.bluetooth.device.extra.CLASS_NAME";
/**
* Used as an extra field in {@link #ACTION_CONNECTION_ACCESS_REPLY} intent.
+ *
* @hide
*/
public static final String EXTRA_CONNECTION_ACCESS_RESULT =
- "android.bluetooth.device.extra.CONNECTION_ACCESS_RESULT";
+ "android.bluetooth.device.extra.CONNECTION_ACCESS_RESULT";
- /**@hide*/
+ /** @hide */
public static final int CONNECTION_ACCESS_YES = 1;
- /**@hide*/
+ /** @hide */
public static final int CONNECTION_ACCESS_NO = 2;
/**
* Used as an extra field in {@link #ACTION_CONNECTION_ACCESS_REPLY} intents,
* Contains boolean to indicate if the allowed response is once-for-all so that
* next request will be granted without asking user again.
+ *
* @hide
*/
public static final String EXTRA_ALWAYS_ALLOWED =
- "android.bluetooth.device.extra.ALWAYS_ALLOWED";
+ "android.bluetooth.device.extra.ALWAYS_ALLOWED";
/**
* A bond attempt succeeded
+ *
* @hide
*/
public static final int BOND_SUCCESS = 0;
@@ -467,6 +478,7 @@
/**
* A bond attempt failed because pins did not match, or remote device did
* not respond to pin request in time
+ *
* @hide
*/
public static final int UNBOND_REASON_AUTH_FAILED = 1;
@@ -474,36 +486,42 @@
/**
* A bond attempt failed because the other side explicitly rejected
* bonding
+ *
* @hide
*/
public static final int UNBOND_REASON_AUTH_REJECTED = 2;
/**
* A bond attempt failed because we canceled the bonding process
+ *
* @hide
*/
public static final int UNBOND_REASON_AUTH_CANCELED = 3;
/**
* A bond attempt failed because we could not contact the remote device
+ *
* @hide
*/
public static final int UNBOND_REASON_REMOTE_DEVICE_DOWN = 4;
/**
* A bond attempt failed because a discovery is in progress
+ *
* @hide
*/
public static final int UNBOND_REASON_DISCOVERY_IN_PROGRESS = 5;
/**
* A bond attempt failed because of authentication timeout
+ *
* @hide
*/
public static final int UNBOND_REASON_AUTH_TIMEOUT = 6;
/**
* A bond attempt failed because of repeated attempts
+ *
* @hide
*/
public static final int UNBOND_REASON_REPEATED_ATTEMPTS = 7;
@@ -511,12 +529,14 @@
/**
* A bond attempt failed because we received an Authentication Cancel
* by remote end
+ *
* @hide
*/
public static final int UNBOND_REASON_REMOTE_AUTH_CANCELED = 8;
/**
* An existing bond was explicitly revoked
+ *
* @hide
*/
public static final int UNBOND_REASON_REMOVED = 9;
@@ -529,6 +549,7 @@
/**
* The user will be prompted to enter a passkey
+ *
* @hide
*/
public static final int PAIRING_VARIANT_PASSKEY = 1;
@@ -541,6 +562,7 @@
/**
* The user will be prompted to accept or deny the incoming pairing request
+ *
* @hide
*/
public static final int PAIRING_VARIANT_CONSENT = 3;
@@ -548,6 +570,7 @@
/**
* The user will be prompted to enter the passkey displayed on remote device
* This is used for Bluetooth 2.1 pairing.
+ *
* @hide
*/
public static final int PAIRING_VARIANT_DISPLAY_PASSKEY = 4;
@@ -555,12 +578,14 @@
/**
* The user will be prompted to enter the PIN displayed on remote device.
* This is used for Bluetooth 2.0 pairing.
+ *
* @hide
*/
public static final int PAIRING_VARIANT_DISPLAY_PIN = 5;
/**
* The user will be prompted to accept or deny the OOB pairing request
+ *
* @hide
*/
public static final int PAIRING_VARIANT_OOB_CONSENT = 6;
@@ -568,6 +593,7 @@
/**
* The user will be prompted to enter a 16 digit pin or
* an app will enter a 16 digit pin for user.
+ *
* @hide
*/
public static final int PAIRING_VARIANT_PIN_16_DIGITS = 7;
@@ -581,7 +607,7 @@
/** @hide */
public static final String EXTRA_SDP_RECORD =
- "android.bluetooth.device.extra.SDP_RECORD";
+ "android.bluetooth.device.extra.SDP_RECORD";
/** @hide */
public static final String EXTRA_SDP_SEARCH_STATUS =
@@ -589,6 +615,7 @@
/**
* For {@link #getPhonebookAccessPermission}, {@link #setPhonebookAccessPermission},
* {@link #getMessageAccessPermission} and {@link #setMessageAccessPermission}.
+ *
* @hide
*/
public static final int ACCESS_UNKNOWN = 0;
@@ -596,6 +623,7 @@
/**
* For {@link #getPhonebookAccessPermission}, {@link #setPhonebookAccessPermission},
* {@link #getMessageAccessPermission} and {@link #setMessageAccessPermission}.
+ *
* @hide
*/
public static final int ACCESS_ALLOWED = 1;
@@ -603,13 +631,14 @@
/**
* For {@link #getPhonebookAccessPermission}, {@link #setPhonebookAccessPermission},
* {@link #getMessageAccessPermission} and {@link #setMessageAccessPermission}.
+ *
* @hide
*/
public static final int ACCESS_REJECTED = 2;
- /**
- * No preferrence of physical transport for GATT connections to remote dual-mode devices
- */
+ /**
+ * No preferrence of physical transport for GATT connections to remote dual-mode devices
+ */
public static final int TRANSPORT_AUTO = 0;
/**
@@ -676,7 +705,7 @@
/** @hide */
public static final String EXTRA_MAS_INSTANCE =
- "android.bluetooth.device.extra.MAS_INSTANCE";
+ "android.bluetooth.device.extra.MAS_INSTANCE";
/**
* Lazy initialization. Guaranteed final after first object constructed, or
@@ -687,7 +716,8 @@
private final String mAddress;
- /*package*/ static IBluetooth getService() {
+ /*package*/
+ static IBluetooth getService() {
synchronized (BluetoothDevice.class) {
if (sService == null) {
BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter();
@@ -709,21 +739,22 @@
}
public void onBluetoothServiceDown()
- throws RemoteException {
+ throws RemoteException {
synchronized (BluetoothDevice.class) {
sService = null;
}
}
- public void onBrEdrDown()
- {
+ public void onBrEdrDown() {
if (DBG) Log.d(TAG, "onBrEdrDown: reached BLE ON state");
}
};
+
/**
* Create a new BluetoothDevice
* Bluetooth MAC address must be upper case, such as "00:11:22:33:AA:BB",
* and is validated in this constructor.
+ *
* @param address valid Bluetooth MAC address
* @throws RuntimeException Bluetooth is not available on this platform
* @throws IllegalArgumentException address is invalid
@@ -741,7 +772,7 @@
@Override
public boolean equals(Object o) {
if (o instanceof BluetoothDevice) {
- return mAddress.equals(((BluetoothDevice)o).getAddress());
+ return mAddress.equals(((BluetoothDevice) o).getAddress());
}
return false;
}
@@ -757,6 +788,7 @@
* "00:11:22:AA:BB:CC". However, you should always use {@link #getAddress}
* if you explicitly require the Bluetooth hardware address in case the
* {@link #toString} representation changes in the future.
+ *
* @return string representation of this BluetoothDevice
*/
@Override
@@ -770,13 +802,14 @@
public static final Parcelable.Creator<BluetoothDevice> CREATOR =
new Parcelable.Creator<BluetoothDevice>() {
- public BluetoothDevice createFromParcel(Parcel in) {
- return new BluetoothDevice(in.readString());
- }
- public BluetoothDevice[] newArray(int size) {
- return new BluetoothDevice[size];
- }
- };
+ public BluetoothDevice createFromParcel(Parcel in) {
+ return new BluetoothDevice(in.readString());
+ }
+
+ public BluetoothDevice[] newArray(int size) {
+ return new BluetoothDevice[size];
+ }
+ };
public void writeToParcel(Parcel out, int flags) {
out.writeString(mAddress);
@@ -785,6 +818,7 @@
/**
* Returns the hardware address of this BluetoothDevice.
* <p> For example, "00:11:22:AA:BB:CC".
+ *
* @return Bluetooth hardware address as string
*/
public String getAddress() {
@@ -809,16 +843,17 @@
}
try {
return sService.getRemoteName(this);
- } catch (RemoteException e) {Log.e(TAG, "", e);}
+ } catch (RemoteException e) {
+ Log.e(TAG, "", e);
+ }
return null;
}
/**
* Get the Bluetooth device type of the remote device.
*
- * @return the device type {@link #DEVICE_TYPE_CLASSIC}, {@link #DEVICE_TYPE_LE}
- * {@link #DEVICE_TYPE_DUAL}.
- * {@link #DEVICE_TYPE_UNKNOWN} if it's not available
+ * @return the device type {@link #DEVICE_TYPE_CLASSIC}, {@link #DEVICE_TYPE_LE} {@link
+ * #DEVICE_TYPE_DUAL}. {@link #DEVICE_TYPE_UNKNOWN} if it's not available
*/
@RequiresPermission(Manifest.permission.BLUETOOTH)
public int getType() {
@@ -828,7 +863,9 @@
}
try {
return sService.getRemoteType(this);
- } catch (RemoteException e) {Log.e(TAG, "", e);}
+ } catch (RemoteException e) {
+ Log.e(TAG, "", e);
+ }
return DEVICE_TYPE_UNKNOWN;
}
@@ -846,7 +883,9 @@
}
try {
return sService.getRemoteAlias(this);
- } catch (RemoteException e) {Log.e(TAG, "", e);}
+ } catch (RemoteException e) {
+ Log.e(TAG, "", e);
+ }
return null;
}
@@ -867,18 +906,20 @@
}
try {
return sService.setRemoteAlias(this, alias);
- } catch (RemoteException e) {Log.e(TAG, "", e);}
+ } catch (RemoteException e) {
+ Log.e(TAG, "", e);
+ }
return false;
}
/**
* Get the Bluetooth alias of the remote device.
* If Alias is null, get the Bluetooth name instead.
- * @see #getAlias()
- * @see #getName()
*
* @return the Bluetooth alias, or null if no alias or there was a problem
* @hide
+ * @see #getAlias()
+ * @see #getName()
*/
public String getAliasName() {
String name = getAlias();
@@ -893,8 +934,8 @@
* <p>Requires {@link android.Manifest.permission#BLUETOOTH}
*
* @return Battery level in percents from 0 to 100, or {@link #BATTERY_LEVEL_UNKNOWN} if
- * Bluetooth is disabled, or device is disconnected, or does not have any battery
- * reporting service, or return value is invalid
+ * Bluetooth is disabled, or device is disconnected, or does not have any battery reporting
+ * service, or return value is invalid
* @hide
*/
@RequiresPermission(Manifest.permission.BLUETOOTH)
@@ -905,7 +946,9 @@
}
try {
return sService.getBatteryLevel(this);
- } catch (RemoteException e) {Log.e(TAG, "", e);}
+ } catch (RemoteException e) {
+ Log.e(TAG, "", e);
+ }
return BATTERY_LEVEL_UNKNOWN;
}
@@ -930,7 +973,9 @@
" called by pid: " + Process.myPid() +
" tid: " + Process.myTid());
return sService.createBond(this, TRANSPORT_AUTO);
- } catch (RemoteException e) {Log.e(TAG, "", e);}
+ } catch (RemoteException e) {
+ Log.e(TAG, "", e);
+ }
return false;
}
@@ -955,8 +1000,7 @@
Log.e(TAG, "BT not enabled. Cannot create bond to Remote Device");
return false;
}
- if (TRANSPORT_AUTO > transport || transport > TRANSPORT_LE)
- {
+ if (TRANSPORT_AUTO > transport || transport > TRANSPORT_LE) {
throw new IllegalArgumentException(transport + " is not a valid Bluetooth transport");
}
try {
@@ -964,7 +1008,9 @@
" called by pid: " + Process.myPid() +
" tid: " + Process.myTid());
return sService.createBond(this, transport);
- } catch (RemoteException e) {Log.e(TAG, "", e);}
+ } catch (RemoteException e) {
+ Log.e(TAG, "", e);
+ }
return false;
}
@@ -984,13 +1030,14 @@
* @param transport - Transport to use
* @param oobData - Out Of Band data
* @return false on immediate error, true if bonding will begin
- *
* @hide
*/
public boolean createBondOutOfBand(int transport, OobData oobData) {
try {
return sService.createBondOutOfBand(this, transport, oobData);
- } catch (RemoteException e) {Log.e(TAG, "", e);}
+ } catch (RemoteException e) {
+ Log.e(TAG, "", e);
+ }
return false;
}
@@ -998,7 +1045,9 @@
public boolean isBondingInitiatedLocally() {
try {
return sService.isBondingInitiatedLocally(this);
- } catch (RemoteException e) {Log.e(TAG, "", e);}
+ } catch (RemoteException e) {
+ Log.e(TAG, "", e);
+ }
return false;
}
@@ -1012,16 +1061,15 @@
* @param hash Simple Secure pairing hash
* @param randomizer The random key obtained using OOB
* @return false on error; true otherwise
- *
* @hide
*/
public boolean setDeviceOutOfBandData(byte[] hash, byte[] randomizer) {
- //TODO(BT)
+ //TODO(BT)
/*
try {
return sService.setDeviceOutOfBandData(this, hash, randomizer);
} catch (RemoteException e) {Log.e(TAG, "", e);} */
- return false;
+ return false;
}
/**
@@ -1041,7 +1089,9 @@
" called by pid: " + Process.myPid() +
" tid: " + Process.myTid());
return sService.cancelBondProcess(this);
- } catch (RemoteException e) {Log.e(TAG, "", e);}
+ } catch (RemoteException e) {
+ Log.e(TAG, "", e);
+ }
return false;
}
@@ -1065,7 +1115,9 @@
" called by pid: " + Process.myPid() +
" tid: " + Process.myTid());
return sService.removeBond(this);
- } catch (RemoteException e) {Log.e(TAG, "", e);}
+ } catch (RemoteException e) {
+ Log.e(TAG, "", e);
+ }
return false;
}
@@ -1086,12 +1138,13 @@
}
try {
return sService.getBondState(this);
- } catch (RemoteException e) {Log.e(TAG, "", e);}
- catch (NullPointerException npe) {
+ } catch (RemoteException e) {
+ Log.e(TAG, "", e);
+ } catch (NullPointerException npe) {
// Handle case where bluetooth service proxy
// is already null.
- Log.e(TAG, "NullPointerException for getBondState() of device ("+
- getAddress()+")", npe);
+ Log.e(TAG, "NullPointerException for getBondState() of device (" +
+ getAddress() + ")", npe);
}
return BOND_NONE;
}
@@ -1154,7 +1207,9 @@
int classInt = sService.getRemoteClass(this);
if (classInt == BluetoothClass.ERROR) return null;
return new BluetoothClass(classInt);
- } catch (RemoteException e) {Log.e(TAG, "", e);}
+ } catch (RemoteException e) {
+ Log.e(TAG, "", e);
+ }
return null;
}
@@ -1166,37 +1221,37 @@
* UUIDs are returned.
* <p>Use {@link #fetchUuidsWithSdp} if fresh UUIDs are desired.
*
- * @return the supported features (UUIDs) of the remote device,
- * or null on error
+ * @return the supported features (UUIDs) of the remote device, or null on error
*/
@RequiresPermission(Manifest.permission.BLUETOOTH)
- public ParcelUuid[] getUuids() {
- if (sService == null || isBluetoothEnabled() == false) {
+ public ParcelUuid[] getUuids() {
+ if (sService == null || isBluetoothEnabled() == false) {
Log.e(TAG, "BT not enabled. Cannot get remote device Uuids");
- return null;
- }
+ return null;
+ }
try {
return sService.getRemoteUuids(this);
- } catch (RemoteException e) {Log.e(TAG, "", e);}
+ } catch (RemoteException e) {
+ Log.e(TAG, "", e);
+ }
return null;
}
- /**
- * Perform a service discovery on the remote device to get the UUIDs supported.
- *
- * <p>This API is asynchronous and {@link #ACTION_UUID} intent is sent,
- * with the UUIDs supported by the remote end. If there is an error
- * in getting the SDP records or if the process takes a long time,
- * {@link #ACTION_UUID} intent is sent with the UUIDs that is currently
- * present in the cache. Clients should use the {@link #getUuids} to get UUIDs
- * if service discovery is not to be performed.
- *
- * @return False if the sanity check fails, True if the process
- * of initiating an ACL connection to the remote device
- * was started.
- */
- @RequiresPermission(Manifest.permission.BLUETOOTH)
- public boolean fetchUuidsWithSdp() {
+ /**
+ * Perform a service discovery on the remote device to get the UUIDs supported.
+ *
+ * <p>This API is asynchronous and {@link #ACTION_UUID} intent is sent,
+ * with the UUIDs supported by the remote end. If there is an error
+ * in getting the SDP records or if the process takes a long time,
+ * {@link #ACTION_UUID} intent is sent with the UUIDs that is currently
+ * present in the cache. Clients should use the {@link #getUuids} to get UUIDs
+ * if service discovery is not to be performed.
+ *
+ * @return False if the sanity check fails, True if the process of initiating an ACL connection
+ * to the remote device was started.
+ */
+ @RequiresPermission(Manifest.permission.BLUETOOTH)
+ public boolean fetchUuidsWithSdp() {
IBluetooth service = sService;
if (service == null || isBluetoothEnabled() == false) {
Log.e(TAG, "BT not enabled. Cannot fetchUuidsWithSdp");
@@ -1204,48 +1259,51 @@
}
try {
return service.fetchRemoteUuids(this);
- } catch (RemoteException e) {Log.e(TAG, "", e);}
- return false;
+ } catch (RemoteException e) {
+ Log.e(TAG, "", e);
+ }
+ return false;
}
- /**
- * Perform a service discovery on the remote device to get the SDP records associated
- * with the specified UUID.
- *
- * <p>This API is asynchronous and {@link #ACTION_SDP_RECORD} intent is sent,
- * with the SDP records found on the remote end. If there is an error
- * in getting the SDP records or if the process takes a long time,
- * {@link #ACTION_SDP_RECORD} intent is sent with an status value in
- * {@link #EXTRA_SDP_SEARCH_STATUS} different from 0.
- * Detailed status error codes can be found by members of the Bluetooth package in
- * the AbstractionLayer class.
- * <p>Requires {@link android.Manifest.permission#BLUETOOTH}.
- * The SDP record data will be stored in the intent as {@link #EXTRA_SDP_RECORD}.
- * The object type will match one of the SdpXxxRecord types, depending on the UUID searched
- * for.
- *
- * @return False if the sanity check fails, True if the process
- * of initiating an ACL connection to the remote device
- * was started.
- */
- /** @hide */
- public boolean sdpSearch(ParcelUuid uuid) {
- if (sService == null) {
- Log.e(TAG, "BT not enabled. Cannot query remote device sdp records");
- return false;
- }
- try {
- return sService.sdpSearch(this,uuid);
- } catch (RemoteException e) {Log.e(TAG, "", e);}
- return false;
- }
+ /**
+ * Perform a service discovery on the remote device to get the SDP records associated
+ * with the specified UUID.
+ *
+ * <p>This API is asynchronous and {@link #ACTION_SDP_RECORD} intent is sent,
+ * with the SDP records found on the remote end. If there is an error
+ * in getting the SDP records or if the process takes a long time,
+ * {@link #ACTION_SDP_RECORD} intent is sent with an status value in
+ * {@link #EXTRA_SDP_SEARCH_STATUS} different from 0.
+ * Detailed status error codes can be found by members of the Bluetooth package in
+ * the AbstractionLayer class.
+ * <p>Requires {@link android.Manifest.permission#BLUETOOTH}.
+ * The SDP record data will be stored in the intent as {@link #EXTRA_SDP_RECORD}.
+ * The object type will match one of the SdpXxxRecord types, depending on the UUID searched
+ * for.
+ *
+ * @return False if the sanity check fails, True if the process
+ * of initiating an ACL connection to the remote device
+ * was started.
+ */
+ /** @hide */
+ public boolean sdpSearch(ParcelUuid uuid) {
+ if (sService == null) {
+ Log.e(TAG, "BT not enabled. Cannot query remote device sdp records");
+ return false;
+ }
+ try {
+ return sService.sdpSearch(this, uuid);
+ } catch (RemoteException e) {
+ Log.e(TAG, "", e);
+ }
+ return false;
+ }
/**
* Set the pin during pairing when the pairing method is {@link #PAIRING_VARIANT_PIN}
* <p>Requires {@link android.Manifest.permission#BLUETOOTH_ADMIN}.
*
- * @return true pin has been set
- * false for error
+ * @return true pin has been set false for error
*/
public boolean setPin(byte[] pin) {
if (sService == null) {
@@ -1254,7 +1312,9 @@
}
try {
return sService.setPin(this, true, pin.length, pin);
- } catch (RemoteException e) {Log.e(TAG, "", e);}
+ } catch (RemoteException e) {
+ Log.e(TAG, "", e);
+ }
return false;
}
@@ -1271,8 +1331,7 @@
/**
* Confirm passkey for {@link #PAIRING_VARIANT_PASSKEY_CONFIRMATION} pairing.
*
- * @return true confirmation has been sent out
- * false for error
+ * @return true confirmation has been sent out false for error
*/
@RequiresPermission(Manifest.permission.BLUETOOTH_PRIVILEGED)
public boolean setPairingConfirmation(boolean confirm) {
@@ -1282,7 +1341,9 @@
}
try {
return sService.setPairingConfirmation(this, confirm);
- } catch (RemoteException e) {Log.e(TAG, "", e);}
+ } catch (RemoteException e) {
+ Log.e(TAG, "", e);
+ }
return false;
}
@@ -1293,7 +1354,7 @@
try {
return sService.setRemoteOutOfBandData(this);
} catch (RemoteException e) {Log.e(TAG, "", e);}*/
- return false;
+ return false;
}
/** @hide */
@@ -1304,7 +1365,9 @@
}
try {
return sService.cancelBondProcess(this);
- } catch (RemoteException e) {Log.e(TAG, "", e);}
+ } catch (RemoteException e) {
+ Log.e(TAG, "", e);
+ }
return false;
}
@@ -1318,19 +1381,20 @@
return false;
}
- boolean isBluetoothEnabled() {
- boolean ret = false;
- BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter();
- if (adapter != null && adapter.isEnabled() == true) {
- ret = true;
- }
- return ret;
- }
+ boolean isBluetoothEnabled() {
+ boolean ret = false;
+ BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter();
+ if (adapter != null && adapter.isEnabled() == true) {
+ ret = true;
+ }
+ return ret;
+ }
/**
* Requires {@link android.Manifest.permission#BLUETOOTH}.
- * @return Whether the phonebook access is allowed to this device. Can be
- * {@link #ACCESS_UNKNOWN}, {@link #ACCESS_ALLOWED} or {@link #ACCESS_REJECTED}.
+ *
+ * @return Whether the phonebook access is allowed to this device. Can be {@link
+ * #ACCESS_UNKNOWN}, {@link #ACCESS_ALLOWED} or {@link #ACCESS_REJECTED}.
* @hide
*/
public int getPhonebookAccessPermission() {
@@ -1348,8 +1412,9 @@
/**
* Sets whether the phonebook access is allowed to this device.
* <p>Requires {@link android.Manifest.permission#BLUETOOTH_PRIVILEGED}.
- * @param value Can be {@link #ACCESS_UNKNOWN}, {@link #ACCESS_ALLOWED} or
- * {@link #ACCESS_REJECTED}.
+ *
+ * @param value Can be {@link #ACCESS_UNKNOWN}, {@link #ACCESS_ALLOWED} or {@link
+ * #ACCESS_REJECTED}.
* @return Whether the value has been successfully set.
* @hide
*/
@@ -1367,8 +1432,9 @@
/**
* Requires {@link android.Manifest.permission#BLUETOOTH}.
- * @return Whether the message access is allowed to this device. Can be
- * {@link #ACCESS_UNKNOWN}, {@link #ACCESS_ALLOWED} or {@link #ACCESS_REJECTED}.
+ *
+ * @return Whether the message access is allowed to this device. Can be {@link #ACCESS_UNKNOWN},
+ * {@link #ACCESS_ALLOWED} or {@link #ACCESS_REJECTED}.
* @hide
*/
public int getMessageAccessPermission() {
@@ -1386,8 +1452,9 @@
/**
* Sets whether the message access is allowed to this device.
* <p>Requires {@link android.Manifest.permission#BLUETOOTH_PRIVILEGED}.
- * @param value Can be {@link #ACCESS_UNKNOWN}, {@link #ACCESS_ALLOWED} or
- * {@link #ACCESS_REJECTED}.
+ *
+ * @param value Can be {@link #ACCESS_UNKNOWN}, {@link #ACCESS_ALLOWED} or {@link
+ * #ACCESS_REJECTED}.
* @return Whether the value has been successfully set.
* @hide
*/
@@ -1405,8 +1472,9 @@
/**
* Requires {@link android.Manifest.permission#BLUETOOTH}.
- * @return Whether the Sim access is allowed to this device. Can be
- * {@link #ACCESS_UNKNOWN}, {@link #ACCESS_ALLOWED} or {@link #ACCESS_REJECTED}.
+ *
+ * @return Whether the Sim access is allowed to this device. Can be {@link #ACCESS_UNKNOWN},
+ * {@link #ACCESS_ALLOWED} or {@link #ACCESS_REJECTED}.
* @hide
*/
public int getSimAccessPermission() {
@@ -1424,8 +1492,9 @@
/**
* Sets whether the Sim access is allowed to this device.
* <p>Requires {@link android.Manifest.permission#BLUETOOTH_PRIVILEGED}.
- * @param value Can be {@link #ACCESS_UNKNOWN}, {@link #ACCESS_ALLOWED} or
- * {@link #ACCESS_REJECTED}.
+ *
+ * @param value Can be {@link #ACCESS_UNKNOWN}, {@link #ACCESS_ALLOWED} or {@link
+ * #ACCESS_REJECTED}.
* @return Whether the value has been successfully set.
* @hide
*/
@@ -1462,8 +1531,8 @@
*
* @param channel RFCOMM channel to connect to
* @return a RFCOMM BluetoothServerSocket ready for an outgoing connection
- * @throws IOException on error, for example Bluetooth not available, or
- * insufficient permissions
+ * @throws IOException on error, for example Bluetooth not available, or insufficient
+ * permissions
* @hide
*/
public BluetoothSocket createRfcommSocket(int channel) throws IOException {
@@ -1496,8 +1565,8 @@
*
* @param channel L2cap PSM/channel to connect to
* @return a RFCOMM BluetoothServerSocket ready for an outgoing connection
- * @throws IOException on error, for example Bluetooth not available, or
- * insufficient permissions
+ * @throws IOException on error, for example Bluetooth not available, or insufficient
+ * permissions
* @hide
*/
public BluetoothSocket createL2capSocket(int channel) throws IOException {
@@ -1517,8 +1586,8 @@
*
* @param channel L2cap PSM/channel to connect to
* @return a RFCOMM BluetoothServerSocket ready for an outgoing connection
- * @throws IOException on error, for example Bluetooth not available, or
- * insufficient permissions
+ * @throws IOException on error, for example Bluetooth not available, or insufficient
+ * permissions
* @hide
*/
public BluetoothSocket createInsecureL2capSocket(int channel) throws IOException {
@@ -1553,8 +1622,8 @@
*
* @param uuid service record uuid to lookup RFCOMM channel
* @return a RFCOMM BluetoothServerSocket ready for an outgoing connection
- * @throws IOException on error, for example Bluetooth not available, or
- * insufficient permissions
+ * @throws IOException on error, for example Bluetooth not available, or insufficient
+ * permissions
*/
@RequiresPermission(Manifest.permission.BLUETOOTH)
public BluetoothSocket createRfcommSocketToServiceRecord(UUID uuid) throws IOException {
@@ -1591,8 +1660,8 @@
*
* @param uuid service record uuid to lookup RFCOMM channel
* @return a RFCOMM BluetoothServerSocket ready for an outgoing connection
- * @throws IOException on error, for example Bluetooth not available, or
- * insufficient permissions
+ * @throws IOException on error, for example Bluetooth not available, or insufficient
+ * permissions
*/
@RequiresPermission(Manifest.permission.BLUETOOTH)
public BluetoothSocket createInsecureRfcommSocketToServiceRecord(UUID uuid) throws IOException {
@@ -1612,10 +1681,10 @@
* socket will not be encrypted.
* <p>Requires {@link android.Manifest.permission#BLUETOOTH_ADMIN}
*
- * @param port remote port
+ * @param port remote port
* @return An RFCOMM BluetoothSocket
- * @throws IOException On error, for example Bluetooth not available, or
- * insufficient permissions.
+ * @throws IOException On error, for example Bluetooth not available, or insufficient
+ * permissions.
* @hide
*/
public BluetoothSocket createInsecureRfcommSocket(int port) throws IOException {
@@ -1634,8 +1703,8 @@
* <p>Requires {@link android.Manifest.permission#BLUETOOTH_ADMIN}
*
* @return a SCO BluetoothSocket
- * @throws IOException on error, for example Bluetooth not available, or
- * insufficient permissions.
+ * @throws IOException on error, for example Bluetooth not available, or insufficient
+ * permissions.
* @hide
*/
public BluetoothSocket createScoSocket() throws IOException {
@@ -1651,9 +1720,9 @@
* Check that a pin is valid and convert to byte array.
*
* Bluetooth pin's are 1 to 16 bytes of UTF-8 characters.
+ *
* @param pin pin as java String
- * @return the pin code as a UTF-8 byte array, or null if it is an invalid
- * Bluetooth pin.
+ * @return the pin code as a UTF-8 byte array, or null if it is an invalid Bluetooth pin.
* @hide
*/
public static byte[] convertPinToBytes(String pin) {
@@ -1679,15 +1748,15 @@
* as any further GATT client operations.
* The method returns a BluetoothGatt instance. You can use BluetoothGatt to conduct
* GATT client operations.
+ *
* @param callback GATT callback handler that will receive asynchronous callbacks.
- * @param autoConnect Whether to directly connect to the remote device (false)
- * or to automatically connect as soon as the remote
- * device becomes available (true).
+ * @param autoConnect Whether to directly connect to the remote device (false) or to
+ * automatically connect as soon as the remote device becomes available (true).
* @throws IllegalArgumentException if callback is null
*/
public BluetoothGatt connectGatt(Context context, boolean autoConnect,
- BluetoothGattCallback callback) {
- return (connectGatt(context, autoConnect,callback, TRANSPORT_AUTO));
+ BluetoothGattCallback callback) {
+ return (connectGatt(context, autoConnect, callback, TRANSPORT_AUTO));
}
/**
@@ -1696,18 +1765,18 @@
* as any further GATT client operations.
* The method returns a BluetoothGatt instance. You can use BluetoothGatt to conduct
* GATT client operations.
+ *
* @param callback GATT callback handler that will receive asynchronous callbacks.
- * @param autoConnect Whether to directly connect to the remote device (false)
- * or to automatically connect as soon as the remote
- * device becomes available (true).
- * @param transport preferred transport for GATT connections to remote dual-mode devices
- * {@link BluetoothDevice#TRANSPORT_AUTO} or
- * {@link BluetoothDevice#TRANSPORT_BREDR} or {@link BluetoothDevice#TRANSPORT_LE}
+ * @param autoConnect Whether to directly connect to the remote device (false) or to
+ * automatically connect as soon as the remote device becomes available (true).
+ * @param transport preferred transport for GATT connections to remote dual-mode devices {@link
+ * BluetoothDevice#TRANSPORT_AUTO} or {@link BluetoothDevice#TRANSPORT_BREDR} or {@link
+ * BluetoothDevice#TRANSPORT_LE}
* @throws IllegalArgumentException if callback is null
*/
public BluetoothGatt connectGatt(Context context, boolean autoConnect,
- BluetoothGattCallback callback, int transport) {
- return (connectGatt(context, autoConnect,callback, transport, PHY_LE_1M_MASK));
+ BluetoothGattCallback callback, int transport) {
+ return (connectGatt(context, autoConnect, callback, transport, PHY_LE_1M_MASK));
}
/**
@@ -1716,22 +1785,22 @@
* as any further GATT client operations.
* The method returns a BluetoothGatt instance. You can use BluetoothGatt to conduct
* GATT client operations.
+ *
* @param callback GATT callback handler that will receive asynchronous callbacks.
- * @param autoConnect Whether to directly connect to the remote device (false)
- * or to automatically connect as soon as the remote
- * device becomes available (true).
- * @param transport preferred transport for GATT connections to remote dual-mode devices
- * {@link BluetoothDevice#TRANSPORT_AUTO} or
- * {@link BluetoothDevice#TRANSPORT_BREDR} or {@link BluetoothDevice#TRANSPORT_LE}
- * @param phy preferred PHY for connections to remote LE device. Bitwise OR of any of
- * {@link BluetoothDevice#PHY_LE_1M_MASK}, {@link BluetoothDevice#PHY_LE_2M_MASK},
- * and {@link BluetoothDevice#PHY_LE_CODED_MASK}. This option does not take effect
- * if {@code autoConnect} is set to true.
+ * @param autoConnect Whether to directly connect to the remote device (false) or to
+ * automatically connect as soon as the remote device becomes available (true).
+ * @param transport preferred transport for GATT connections to remote dual-mode devices {@link
+ * BluetoothDevice#TRANSPORT_AUTO} or {@link BluetoothDevice#TRANSPORT_BREDR} or {@link
+ * BluetoothDevice#TRANSPORT_LE}
+ * @param phy preferred PHY for connections to remote LE device. Bitwise OR of any of {@link
+ * BluetoothDevice#PHY_LE_1M_MASK}, {@link BluetoothDevice#PHY_LE_2M_MASK}, and {@link
+ * BluetoothDevice#PHY_LE_CODED_MASK}. This option does not take effect if {@code autoConnect}
+ * is set to true.
* @throws NullPointerException if callback is null
*/
public BluetoothGatt connectGatt(Context context, boolean autoConnect,
- BluetoothGattCallback callback, int transport, int phy) {
- return connectGatt(context, autoConnect,callback, transport, phy, null);
+ BluetoothGattCallback callback, int transport, int phy) {
+ return connectGatt(context, autoConnect, callback, transport, phy, null);
}
/**
@@ -1740,24 +1809,24 @@
* as any further GATT client operations.
* The method returns a BluetoothGatt instance. You can use BluetoothGatt to conduct
* GATT client operations.
+ *
* @param callback GATT callback handler that will receive asynchronous callbacks.
- * @param autoConnect Whether to directly connect to the remote device (false)
- * or to automatically connect as soon as the remote
- * device becomes available (true).
- * @param transport preferred transport for GATT connections to remote dual-mode devices
- * {@link BluetoothDevice#TRANSPORT_AUTO} or
- * {@link BluetoothDevice#TRANSPORT_BREDR} or {@link BluetoothDevice#TRANSPORT_LE}
- * @param phy preferred PHY for connections to remote LE device. Bitwise OR of any of
- * {@link BluetoothDevice#PHY_LE_1M_MASK}, {@link BluetoothDevice#PHY_LE_2M_MASK},
- * an d{@link BluetoothDevice#PHY_LE_CODED_MASK}. This option does not take effect
- * if {@code autoConnect} is set to true.
- * @param handler The handler to use for the callback. If {@code null}, callbacks will happen
- * on an un-specified background thread.
+ * @param autoConnect Whether to directly connect to the remote device (false) or to
+ * automatically connect as soon as the remote device becomes available (true).
+ * @param transport preferred transport for GATT connections to remote dual-mode devices {@link
+ * BluetoothDevice#TRANSPORT_AUTO} or {@link BluetoothDevice#TRANSPORT_BREDR} or {@link
+ * BluetoothDevice#TRANSPORT_LE}
+ * @param phy preferred PHY for connections to remote LE device. Bitwise OR of any of {@link
+ * BluetoothDevice#PHY_LE_1M_MASK}, {@link BluetoothDevice#PHY_LE_2M_MASK}, an d{@link
+ * BluetoothDevice#PHY_LE_CODED_MASK}. This option does not take effect if {@code autoConnect}
+ * is set to true.
+ * @param handler The handler to use for the callback. If {@code null}, callbacks will happen on
+ * an un-specified background thread.
* @throws NullPointerException if callback is null
*/
public BluetoothGatt connectGatt(Context context, boolean autoConnect,
- BluetoothGattCallback callback, int transport, int phy,
- Handler handler) {
+ BluetoothGattCallback callback, int transport, int phy,
+ Handler handler) {
return connectGatt(context, autoConnect, callback, transport, false, phy, handler);
}
@@ -1767,31 +1836,32 @@
* as any further GATT client operations.
* The method returns a BluetoothGatt instance. You can use BluetoothGatt to conduct
* GATT client operations.
+ *
* @param callback GATT callback handler that will receive asynchronous callbacks.
- * @param autoConnect Whether to directly connect to the remote device (false)
- * or to automatically connect as soon as the remote
- * device becomes available (true).
- * @param transport preferred transport for GATT connections to remote dual-mode devices
- * {@link BluetoothDevice#TRANSPORT_AUTO} or
- * {@link BluetoothDevice#TRANSPORT_BREDR} or {@link BluetoothDevice#TRANSPORT_LE}
+ * @param autoConnect Whether to directly connect to the remote device (false) or to
+ * automatically connect as soon as the remote device becomes available (true).
+ * @param transport preferred transport for GATT connections to remote dual-mode devices {@link
+ * BluetoothDevice#TRANSPORT_AUTO} or {@link BluetoothDevice#TRANSPORT_BREDR} or {@link
+ * BluetoothDevice#TRANSPORT_LE}
* @param opportunistic Whether this GATT client is opportunistic. An opportunistic GATT client
- * does not hold a GATT connection. It automatically disconnects when no
- * other GATT connections are active for the remote device.
- * @param phy preferred PHY for connections to remote LE device. Bitwise OR of any of
- * {@link BluetoothDevice#PHY_LE_1M_MASK}, {@link BluetoothDevice#PHY_LE_2M_MASK},
- * an d{@link BluetoothDevice#PHY_LE_CODED_MASK}. This option does not take effect
- * if {@code autoConnect} is set to true.
- * @param handler The handler to use for the callback. If {@code null}, callbacks will happen
- * on an un-specified background thread.
+ * does not hold a GATT connection. It automatically disconnects when no other GATT connections
+ * are active for the remote device.
+ * @param phy preferred PHY for connections to remote LE device. Bitwise OR of any of {@link
+ * BluetoothDevice#PHY_LE_1M_MASK}, {@link BluetoothDevice#PHY_LE_2M_MASK}, an d{@link
+ * BluetoothDevice#PHY_LE_CODED_MASK}. This option does not take effect if {@code autoConnect}
+ * is set to true.
+ * @param handler The handler to use for the callback. If {@code null}, callbacks will happen on
+ * an un-specified background thread.
* @return A BluetoothGatt instance. You can use BluetoothGatt to conduct GATT client
- * operations.
+ * operations.
* @hide
*/
public BluetoothGatt connectGatt(Context context, boolean autoConnect,
- BluetoothGattCallback callback, int transport,
- boolean opportunistic, int phy, Handler handler) {
- if (callback == null)
+ BluetoothGattCallback callback, int transport,
+ boolean opportunistic, int phy, Handler handler) {
+ if (callback == null) {
throw new NullPointerException("callback is null");
+ }
// TODO(Bluetooth) check whether platform support BLE
// Do the check here or in GattServer?
@@ -1806,7 +1876,9 @@
BluetoothGatt gatt = new BluetoothGatt(iGatt, this, transport, opportunistic, phy);
gatt.connect(autoConnect, callback, handler);
return gatt;
- } catch (RemoteException e) {Log.e(TAG, "", e);}
+ } catch (RemoteException e) {
+ Log.e(TAG, "", e);
+ }
return null;
}
}
diff --git a/framework/java/android/bluetooth/BluetoothDevicePicker.java b/framework/java/android/bluetooth/BluetoothDevicePicker.java
index c794be2..09b0a80 100644
--- a/framework/java/android/bluetooth/BluetoothDevicePicker.java
+++ b/framework/java/android/bluetooth/BluetoothDevicePicker.java
@@ -48,11 +48,11 @@
* This intent contains below extra data:
* - {@link #EXTRA_NEED_AUTH} (boolean): if need authentication
* - {@link #EXTRA_FILTER_TYPE} (int): what kinds of device should be
- * listed
+ * listed
* - {@link #EXTRA_LAUNCH_PACKAGE} (string): where(which package) this
- * intent come from
+ * intent come from
* - {@link #EXTRA_LAUNCH_CLASS} (string): where(which class) this intent
- * come from
+ * come from
*/
@SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
public static final String ACTION_LAUNCH =
@@ -64,8 +64,10 @@
public static final int FILTER_TYPE_AUDIO = 1;
/** Ask device picker to show BT devices that support Object Transfer */
public static final int FILTER_TYPE_TRANSFER = 2;
- /** Ask device picker to show BT devices that support
- * Personal Area Networking User (PANU) profile*/
+ /**
+ * Ask device picker to show BT devices that support
+ * Personal Area Networking User (PANU) profile
+ */
public static final int FILTER_TYPE_PANU = 3;
/** Ask device picker to show BT devices that support Network Access Point (NAP) profile */
public static final int FILTER_TYPE_NAP = 4;
diff --git a/framework/java/android/bluetooth/BluetoothGatt.java b/framework/java/android/bluetooth/BluetoothGatt.java
index 678159b..8a3650c 100644
--- a/framework/java/android/bluetooth/BluetoothGatt.java
+++ b/framework/java/android/bluetooth/BluetoothGatt.java
@@ -118,18 +118,21 @@
/**
* No authentication required.
+ *
* @hide
*/
/*package*/ static final int AUTHENTICATION_NONE = 0;
/**
* Authentication requested; no man-in-the-middle protection required.
+ *
* @hide
*/
/*package*/ static final int AUTHENTICATION_NO_MITM = 1;
/**
* Authentication with man-in-the-middle protection requested.
+ *
* @hide
*/
/*package*/ static final int AUTHENTICATION_MITM = 2;
@@ -138,498 +141,536 @@
* Bluetooth GATT callbacks. Overrides the default BluetoothGattCallback implementation.
*/
private final IBluetoothGattCallback mBluetoothGattCallback =
- new IBluetoothGattCallback.Stub() {
- /**
- * Application interface registered - app is ready to go
- * @hide
- */
- @Override
- public void onClientRegistered(int status, int clientIf) {
- if (DBG) Log.d(TAG, "onClientRegistered() - status=" + status
- + " clientIf=" + clientIf);
- if (VDBG) {
- synchronized(mStateLock) {
- if (mConnState != CONN_STATE_CONNECTING) {
- Log.e(TAG, "Bad connection state: " + mConnState);
+ new IBluetoothGattCallback.Stub() {
+ /**
+ * Application interface registered - app is ready to go
+ * @hide
+ */
+ @Override
+ public void onClientRegistered(int status, int clientIf) {
+ if (DBG) {
+ Log.d(TAG, "onClientRegistered() - status=" + status
+ + " clientIf=" + clientIf);
+ }
+ if (VDBG) {
+ synchronized (mStateLock) {
+ if (mConnState != CONN_STATE_CONNECTING) {
+ Log.e(TAG, "Bad connection state: " + mConnState);
+ }
}
}
+ mClientIf = clientIf;
+ if (status != GATT_SUCCESS) {
+ runOrQueueCallback(new Runnable() {
+ @Override
+ public void run() {
+ if (mCallback != null) {
+ mCallback.onConnectionStateChange(BluetoothGatt.this,
+ GATT_FAILURE,
+ BluetoothProfile.STATE_DISCONNECTED);
+ }
+ }
+ });
+
+ synchronized (mStateLock) {
+ mConnState = CONN_STATE_IDLE;
+ }
+ return;
+ }
+ try {
+ mService.clientConnect(mClientIf, mDevice.getAddress(),
+ !mAutoConnect, mTransport, mOpportunistic,
+ mPhy); // autoConnect is inverse of "isDirect"
+ } catch (RemoteException e) {
+ Log.e(TAG, "", e);
+ }
}
- mClientIf = clientIf;
- if (status != GATT_SUCCESS) {
+
+ /**
+ * Phy update callback
+ * @hide
+ */
+ @Override
+ public void onPhyUpdate(String address, int txPhy, int rxPhy, int status) {
+ if (DBG) {
+ Log.d(TAG, "onPhyUpdate() - status=" + status
+ + " address=" + address + " txPhy=" + txPhy + " rxPhy=" + rxPhy);
+ }
+ if (!address.equals(mDevice.getAddress())) {
+ return;
+ }
+
runOrQueueCallback(new Runnable() {
@Override
public void run() {
if (mCallback != null) {
- mCallback.onConnectionStateChange(BluetoothGatt.this, GATT_FAILURE,
- BluetoothProfile.STATE_DISCONNECTED);
+ mCallback.onPhyUpdate(BluetoothGatt.this, txPhy, rxPhy, status);
+ }
+ }
+ });
+ }
+
+ /**
+ * Phy read callback
+ * @hide
+ */
+ @Override
+ public void onPhyRead(String address, int txPhy, int rxPhy, int status) {
+ if (DBG) {
+ Log.d(TAG, "onPhyRead() - status=" + status
+ + " address=" + address + " txPhy=" + txPhy + " rxPhy=" + rxPhy);
+ }
+ if (!address.equals(mDevice.getAddress())) {
+ return;
+ }
+
+ runOrQueueCallback(new Runnable() {
+ @Override
+ public void run() {
+ if (mCallback != null) {
+ mCallback.onPhyRead(BluetoothGatt.this, txPhy, rxPhy, status);
+ }
+ }
+ });
+ }
+
+ /**
+ * Client connection state changed
+ * @hide
+ */
+ @Override
+ public void onClientConnectionState(int status, int clientIf,
+ boolean connected, String address) {
+ if (DBG) {
+ Log.d(TAG, "onClientConnectionState() - status=" + status
+ + " clientIf=" + clientIf + " device=" + address);
+ }
+ if (!address.equals(mDevice.getAddress())) {
+ return;
+ }
+ int profileState = connected ? BluetoothProfile.STATE_CONNECTED :
+ BluetoothProfile.STATE_DISCONNECTED;
+
+ runOrQueueCallback(new Runnable() {
+ @Override
+ public void run() {
+ if (mCallback != null) {
+ mCallback.onConnectionStateChange(BluetoothGatt.this, status,
+ profileState);
}
}
});
- synchronized(mStateLock) {
- mConnState = CONN_STATE_IDLE;
- }
- return;
- }
- try {
- mService.clientConnect(mClientIf, mDevice.getAddress(),
- !mAutoConnect, mTransport, mOpportunistic, mPhy); // autoConnect is inverse of "isDirect"
- } catch (RemoteException e) {
- Log.e(TAG,"",e);
- }
- }
-
- /**
- * Phy update callback
- * @hide
- */
- @Override
- public void onPhyUpdate(String address, int txPhy, int rxPhy, int status) {
- if (DBG) Log.d(TAG, "onPhyUpdate() - status=" + status
- + " address=" + address + " txPhy=" + txPhy + " rxPhy=" + rxPhy);
- if (!address.equals(mDevice.getAddress())) {
- return;
- }
-
- runOrQueueCallback(new Runnable() {
- @Override
- public void run() {
- if (mCallback != null) {
- mCallback.onPhyUpdate(BluetoothGatt.this, txPhy, rxPhy, status);
- }
- }
- });
- }
-
- /**
- * Phy read callback
- * @hide
- */
- @Override
- public void onPhyRead(String address, int txPhy, int rxPhy, int status) {
- if (DBG) Log.d(TAG, "onPhyRead() - status=" + status
- + " address=" + address + " txPhy=" + txPhy + " rxPhy=" + rxPhy);
- if (!address.equals(mDevice.getAddress())) {
- return;
- }
-
- runOrQueueCallback(new Runnable() {
- @Override
- public void run() {
- if (mCallback != null) {
- mCallback.onPhyRead(BluetoothGatt.this, txPhy, rxPhy, status);
- }
- }
- });
- }
-
- /**
- * Client connection state changed
- * @hide
- */
- @Override
- public void onClientConnectionState(int status, int clientIf,
- boolean connected, String address) {
- if (DBG) Log.d(TAG, "onClientConnectionState() - status=" + status
- + " clientIf=" + clientIf + " device=" + address);
- if (!address.equals(mDevice.getAddress())) {
- return;
- }
- int profileState = connected ? BluetoothProfile.STATE_CONNECTED :
- BluetoothProfile.STATE_DISCONNECTED;
-
- runOrQueueCallback(new Runnable() {
- @Override
- public void run() {
- if (mCallback != null) {
- mCallback.onConnectionStateChange(BluetoothGatt.this, status,
- profileState);
- }
- }
- });
-
- synchronized(mStateLock) {
- if (connected) {
- mConnState = CONN_STATE_CONNECTED;
- } else {
- mConnState = CONN_STATE_IDLE;
- }
- }
-
- synchronized(mDeviceBusy) {
- mDeviceBusy = false;
- }
- }
-
- /**
- * Remote search has been completed.
- * The internal object structure should now reflect the state
- * of the remote device database. Let the application know that
- * we are done at this point.
- * @hide
- */
- @Override
- public void onSearchComplete(String address, List<BluetoothGattService> services,
- int status) {
- if (DBG) Log.d(TAG, "onSearchComplete() = Device=" + address + " Status=" + status);
- if (!address.equals(mDevice.getAddress())) {
- return;
- }
-
- for (BluetoothGattService s : services) {
- //services we receive don't have device set properly.
- s.setDevice(mDevice);
- }
-
- mServices.addAll(services);
-
- // Fix references to included services, as they doesn't point to right objects.
- for (BluetoothGattService fixedService : mServices) {
- ArrayList<BluetoothGattService> includedServices =
- new ArrayList(fixedService.getIncludedServices());
- fixedService.getIncludedServices().clear();
-
- for(BluetoothGattService brokenRef : includedServices) {
- BluetoothGattService includedService = getService(mDevice,
- brokenRef.getUuid(), brokenRef.getInstanceId(), brokenRef.getType());
- if (includedService != null) {
- fixedService.addIncludedService(includedService);
+ synchronized (mStateLock) {
+ if (connected) {
+ mConnState = CONN_STATE_CONNECTED;
} else {
- Log.e(TAG, "Broken GATT database: can't find included service.");
+ mConnState = CONN_STATE_IDLE;
}
}
+
+ synchronized (mDeviceBusy) {
+ mDeviceBusy = false;
+ }
}
- runOrQueueCallback(new Runnable() {
- @Override
- public void run() {
- if (mCallback != null) {
- mCallback.onServicesDiscovered(BluetoothGatt.this, status);
- }
+ /**
+ * Remote search has been completed.
+ * The internal object structure should now reflect the state
+ * of the remote device database. Let the application know that
+ * we are done at this point.
+ * @hide
+ */
+ @Override
+ public void onSearchComplete(String address, List<BluetoothGattService> services,
+ int status) {
+ if (DBG) {
+ Log.d(TAG,
+ "onSearchComplete() = Device=" + address + " Status=" + status);
}
- });
- }
-
- /**
- * Remote characteristic has been read.
- * Updates the internal value.
- * @hide
- */
- @Override
- public void onCharacteristicRead(String address, int status, int handle, byte[] value) {
- if (VDBG) Log.d(TAG, "onCharacteristicRead() - Device=" + address
- + " handle=" + handle + " Status=" + status);
-
- if (!address.equals(mDevice.getAddress())) {
- return;
- }
-
- synchronized(mDeviceBusy) {
- mDeviceBusy = false;
- }
-
- if ((status == GATT_INSUFFICIENT_AUTHENTICATION
- || status == GATT_INSUFFICIENT_ENCRYPTION)
- && (mAuthRetryState != AUTH_RETRY_STATE_MITM)) {
- try {
- final int authReq = (mAuthRetryState == AUTH_RETRY_STATE_IDLE) ?
- AUTHENTICATION_NO_MITM : AUTHENTICATION_MITM;
- mService.readCharacteristic(mClientIf, address, handle, authReq);
- mAuthRetryState++;
+ if (!address.equals(mDevice.getAddress())) {
return;
- } catch (RemoteException e) {
- Log.e(TAG,"",e);
}
- }
- mAuthRetryState = AUTH_RETRY_STATE_IDLE;
+ for (BluetoothGattService s : services) {
+ //services we receive don't have device set properly.
+ s.setDevice(mDevice);
+ }
- BluetoothGattCharacteristic characteristic = getCharacteristicById(mDevice, handle);
- if (characteristic == null) {
- Log.w(TAG, "onCharacteristicRead() failed to find characteristic!");
- return;
- }
+ mServices.addAll(services);
- if (status == 0) characteristic.setValue(value);
+ // Fix references to included services, as they doesn't point to right objects.
+ for (BluetoothGattService fixedService : mServices) {
+ ArrayList<BluetoothGattService> includedServices =
+ new ArrayList(fixedService.getIncludedServices());
+ fixedService.getIncludedServices().clear();
- runOrQueueCallback(new Runnable() {
- @Override
- public void run() {
- if (mCallback != null) {
- mCallback.onCharacteristicRead(BluetoothGatt.this, characteristic,
- status);
+ for (BluetoothGattService brokenRef : includedServices) {
+ BluetoothGattService includedService = getService(mDevice,
+ brokenRef.getUuid(), brokenRef.getInstanceId(),
+ brokenRef.getType());
+ if (includedService != null) {
+ fixedService.addIncludedService(includedService);
+ } else {
+ Log.e(TAG, "Broken GATT database: can't find included service.");
+ }
}
}
- });
- }
- /**
- * Characteristic has been written to the remote device.
- * Let the app know how we did...
- * @hide
- */
- @Override
- public void onCharacteristicWrite(String address, int status, int handle) {
- if (VDBG) Log.d(TAG, "onCharacteristicWrite() - Device=" + address
- + " handle=" + handle + " Status=" + status);
-
- if (!address.equals(mDevice.getAddress())) {
- return;
+ runOrQueueCallback(new Runnable() {
+ @Override
+ public void run() {
+ if (mCallback != null) {
+ mCallback.onServicesDiscovered(BluetoothGatt.this, status);
+ }
+ }
+ });
}
- synchronized(mDeviceBusy) {
- mDeviceBusy = false;
- }
+ /**
+ * Remote characteristic has been read.
+ * Updates the internal value.
+ * @hide
+ */
+ @Override
+ public void onCharacteristicRead(String address, int status, int handle,
+ byte[] value) {
+ if (VDBG) {
+ Log.d(TAG, "onCharacteristicRead() - Device=" + address
+ + " handle=" + handle + " Status=" + status);
+ }
- BluetoothGattCharacteristic characteristic = getCharacteristicById(mDevice, handle);
- if (characteristic == null) return;
-
- if ((status == GATT_INSUFFICIENT_AUTHENTICATION
- || status == GATT_INSUFFICIENT_ENCRYPTION)
- && (mAuthRetryState != AUTH_RETRY_STATE_MITM)) {
- try {
- final int authReq = (mAuthRetryState == AUTH_RETRY_STATE_IDLE) ?
- AUTHENTICATION_NO_MITM : AUTHENTICATION_MITM;
- mService.writeCharacteristic(mClientIf, address, handle,
- characteristic.getWriteType(), authReq, characteristic.getValue());
- mAuthRetryState++;
+ if (!address.equals(mDevice.getAddress())) {
return;
- } catch (RemoteException e) {
- Log.e(TAG,"",e);
}
- }
- mAuthRetryState = AUTH_RETRY_STATE_IDLE;
+ synchronized (mDeviceBusy) {
+ mDeviceBusy = false;
+ }
- runOrQueueCallback(new Runnable() {
- @Override
- public void run() {
- if (mCallback != null) {
- mCallback.onCharacteristicWrite(BluetoothGatt.this, characteristic,
- status);
+ if ((status == GATT_INSUFFICIENT_AUTHENTICATION
+ || status == GATT_INSUFFICIENT_ENCRYPTION)
+ && (mAuthRetryState != AUTH_RETRY_STATE_MITM)) {
+ try {
+ final int authReq = (mAuthRetryState == AUTH_RETRY_STATE_IDLE) ?
+ AUTHENTICATION_NO_MITM : AUTHENTICATION_MITM;
+ mService.readCharacteristic(mClientIf, address, handle, authReq);
+ mAuthRetryState++;
+ return;
+ } catch (RemoteException e) {
+ Log.e(TAG, "", e);
}
}
- });
- }
- /**
- * Remote characteristic has been updated.
- * Updates the internal value.
- * @hide
- */
- @Override
- public void onNotify(String address, int handle, byte[] value) {
- if (VDBG) Log.d(TAG, "onNotify() - Device=" + address + " handle=" + handle);
+ mAuthRetryState = AUTH_RETRY_STATE_IDLE;
- if (!address.equals(mDevice.getAddress())) {
- return;
- }
-
- BluetoothGattCharacteristic characteristic = getCharacteristicById(mDevice, handle);
- if (characteristic == null) return;
-
- characteristic.setValue(value);
-
- runOrQueueCallback(new Runnable() {
- @Override
- public void run() {
- if (mCallback != null) {
- mCallback.onCharacteristicChanged(BluetoothGatt.this, characteristic);
- }
- }
- });
- }
-
- /**
- * Descriptor has been read.
- * @hide
- */
- @Override
- public void onDescriptorRead(String address, int status, int handle, byte[] value) {
- if (VDBG) Log.d(TAG, "onDescriptorRead() - Device=" + address + " handle=" + handle);
-
- if (!address.equals(mDevice.getAddress())) {
- return;
- }
-
- synchronized(mDeviceBusy) {
- mDeviceBusy = false;
- }
-
- BluetoothGattDescriptor descriptor = getDescriptorById(mDevice, handle);
- if (descriptor == null) return;
-
- if (status == 0) descriptor.setValue(value);
-
- if ((status == GATT_INSUFFICIENT_AUTHENTICATION
- || status == GATT_INSUFFICIENT_ENCRYPTION)
- && (mAuthRetryState != AUTH_RETRY_STATE_MITM)) {
- try {
- final int authReq = (mAuthRetryState == AUTH_RETRY_STATE_IDLE) ?
- AUTHENTICATION_NO_MITM : AUTHENTICATION_MITM;
- mService.readDescriptor(mClientIf, address, handle, authReq);
- mAuthRetryState++;
+ BluetoothGattCharacteristic characteristic = getCharacteristicById(mDevice,
+ handle);
+ if (characteristic == null) {
+ Log.w(TAG, "onCharacteristicRead() failed to find characteristic!");
return;
- } catch (RemoteException e) {
- Log.e(TAG,"",e);
}
- }
- mAuthRetryState = AUTH_RETRY_STATE_IDLE;
+ if (status == 0) characteristic.setValue(value);
- runOrQueueCallback(new Runnable() {
- @Override
- public void run() {
- if (mCallback != null) {
- mCallback.onDescriptorRead(BluetoothGatt.this, descriptor, status);
+ runOrQueueCallback(new Runnable() {
+ @Override
+ public void run() {
+ if (mCallback != null) {
+ mCallback.onCharacteristicRead(BluetoothGatt.this, characteristic,
+ status);
+ }
}
+ });
+ }
+
+ /**
+ * Characteristic has been written to the remote device.
+ * Let the app know how we did...
+ * @hide
+ */
+ @Override
+ public void onCharacteristicWrite(String address, int status, int handle) {
+ if (VDBG) {
+ Log.d(TAG, "onCharacteristicWrite() - Device=" + address
+ + " handle=" + handle + " Status=" + status);
}
- });
- }
- /**
- * Descriptor write operation complete.
- * @hide
- */
- @Override
- public void onDescriptorWrite(String address, int status, int handle) {
- if (VDBG) Log.d(TAG, "onDescriptorWrite() - Device=" + address + " handle=" + handle);
-
- if (!address.equals(mDevice.getAddress())) {
- return;
- }
-
- synchronized(mDeviceBusy) {
- mDeviceBusy = false;
- }
-
- BluetoothGattDescriptor descriptor = getDescriptorById(mDevice, handle);
- if (descriptor == null) return;
-
- if ((status == GATT_INSUFFICIENT_AUTHENTICATION
- || status == GATT_INSUFFICIENT_ENCRYPTION)
- && (mAuthRetryState != AUTH_RETRY_STATE_MITM)) {
- try {
- final int authReq = (mAuthRetryState == AUTH_RETRY_STATE_IDLE) ?
- AUTHENTICATION_NO_MITM : AUTHENTICATION_MITM;
- mService.writeDescriptor(mClientIf, address, handle,
- authReq, descriptor.getValue());
- mAuthRetryState++;
+ if (!address.equals(mDevice.getAddress())) {
return;
- } catch (RemoteException e) {
- Log.e(TAG,"",e);
}
- }
- mAuthRetryState = AUTH_RETRY_STATE_IDLE;
+ synchronized (mDeviceBusy) {
+ mDeviceBusy = false;
+ }
- runOrQueueCallback(new Runnable() {
- @Override
- public void run() {
- if (mCallback != null) {
- mCallback.onDescriptorWrite(BluetoothGatt.this, descriptor, status);
+ BluetoothGattCharacteristic characteristic = getCharacteristicById(mDevice,
+ handle);
+ if (characteristic == null) return;
+
+ if ((status == GATT_INSUFFICIENT_AUTHENTICATION
+ || status == GATT_INSUFFICIENT_ENCRYPTION)
+ && (mAuthRetryState != AUTH_RETRY_STATE_MITM)) {
+ try {
+ final int authReq = (mAuthRetryState == AUTH_RETRY_STATE_IDLE) ?
+ AUTHENTICATION_NO_MITM : AUTHENTICATION_MITM;
+ mService.writeCharacteristic(mClientIf, address, handle,
+ characteristic.getWriteType(), authReq,
+ characteristic.getValue());
+ mAuthRetryState++;
+ return;
+ } catch (RemoteException e) {
+ Log.e(TAG, "", e);
}
}
- });
- }
- /**
- * Prepared write transaction completed (or aborted)
- * @hide
- */
- @Override
- public void onExecuteWrite(String address, int status) {
- if (VDBG) Log.d(TAG, "onExecuteWrite() - Device=" + address
- + " status=" + status);
- if (!address.equals(mDevice.getAddress())) {
- return;
+ mAuthRetryState = AUTH_RETRY_STATE_IDLE;
+
+ runOrQueueCallback(new Runnable() {
+ @Override
+ public void run() {
+ if (mCallback != null) {
+ mCallback.onCharacteristicWrite(BluetoothGatt.this, characteristic,
+ status);
+ }
+ }
+ });
}
- synchronized(mDeviceBusy) {
- mDeviceBusy = false;
+ /**
+ * Remote characteristic has been updated.
+ * Updates the internal value.
+ * @hide
+ */
+ @Override
+ public void onNotify(String address, int handle, byte[] value) {
+ if (VDBG) Log.d(TAG, "onNotify() - Device=" + address + " handle=" + handle);
+
+ if (!address.equals(mDevice.getAddress())) {
+ return;
+ }
+
+ BluetoothGattCharacteristic characteristic = getCharacteristicById(mDevice,
+ handle);
+ if (characteristic == null) return;
+
+ characteristic.setValue(value);
+
+ runOrQueueCallback(new Runnable() {
+ @Override
+ public void run() {
+ if (mCallback != null) {
+ mCallback.onCharacteristicChanged(BluetoothGatt.this,
+ characteristic);
+ }
+ }
+ });
}
- runOrQueueCallback(new Runnable() {
- @Override
- public void run() {
- if (mCallback != null) {
- mCallback.onReliableWriteCompleted(BluetoothGatt.this, status);
+ /**
+ * Descriptor has been read.
+ * @hide
+ */
+ @Override
+ public void onDescriptorRead(String address, int status, int handle, byte[] value) {
+ if (VDBG) {
+ Log.d(TAG,
+ "onDescriptorRead() - Device=" + address + " handle=" + handle);
+ }
+
+ if (!address.equals(mDevice.getAddress())) {
+ return;
+ }
+
+ synchronized (mDeviceBusy) {
+ mDeviceBusy = false;
+ }
+
+ BluetoothGattDescriptor descriptor = getDescriptorById(mDevice, handle);
+ if (descriptor == null) return;
+
+ if (status == 0) descriptor.setValue(value);
+
+ if ((status == GATT_INSUFFICIENT_AUTHENTICATION
+ || status == GATT_INSUFFICIENT_ENCRYPTION)
+ && (mAuthRetryState != AUTH_RETRY_STATE_MITM)) {
+ try {
+ final int authReq = (mAuthRetryState == AUTH_RETRY_STATE_IDLE) ?
+ AUTHENTICATION_NO_MITM : AUTHENTICATION_MITM;
+ mService.readDescriptor(mClientIf, address, handle, authReq);
+ mAuthRetryState++;
+ return;
+ } catch (RemoteException e) {
+ Log.e(TAG, "", e);
}
}
- });
- }
- /**
- * Remote device RSSI has been read
- * @hide
- */
- @Override
- public void onReadRemoteRssi(String address, int rssi, int status) {
- if (VDBG) Log.d(TAG, "onReadRemoteRssi() - Device=" + address +
- " rssi=" + rssi + " status=" + status);
- if (!address.equals(mDevice.getAddress())) {
- return;
- }
- runOrQueueCallback(new Runnable() {
- @Override
- public void run() {
- if (mCallback != null) {
- mCallback.onReadRemoteRssi(BluetoothGatt.this, rssi, status);
+ mAuthRetryState = AUTH_RETRY_STATE_IDLE;
+
+ runOrQueueCallback(new Runnable() {
+ @Override
+ public void run() {
+ if (mCallback != null) {
+ mCallback.onDescriptorRead(BluetoothGatt.this, descriptor, status);
+ }
}
- }
- });
- }
-
- /**
- * Callback invoked when the MTU for a given connection changes
- * @hide
- */
- @Override
- public void onConfigureMTU(String address, int mtu, int status) {
- if (DBG) Log.d(TAG, "onConfigureMTU() - Device=" + address +
- " mtu=" + mtu + " status=" + status);
- if (!address.equals(mDevice.getAddress())) {
- return;
+ });
}
- runOrQueueCallback(new Runnable() {
- @Override
- public void run() {
- if (mCallback != null) {
- mCallback.onMtuChanged(BluetoothGatt.this, mtu, status);
+ /**
+ * Descriptor write operation complete.
+ * @hide
+ */
+ @Override
+ public void onDescriptorWrite(String address, int status, int handle) {
+ if (VDBG) {
+ Log.d(TAG,
+ "onDescriptorWrite() - Device=" + address + " handle=" + handle);
+ }
+
+ if (!address.equals(mDevice.getAddress())) {
+ return;
+ }
+
+ synchronized (mDeviceBusy) {
+ mDeviceBusy = false;
+ }
+
+ BluetoothGattDescriptor descriptor = getDescriptorById(mDevice, handle);
+ if (descriptor == null) return;
+
+ if ((status == GATT_INSUFFICIENT_AUTHENTICATION
+ || status == GATT_INSUFFICIENT_ENCRYPTION)
+ && (mAuthRetryState != AUTH_RETRY_STATE_MITM)) {
+ try {
+ final int authReq = (mAuthRetryState == AUTH_RETRY_STATE_IDLE) ?
+ AUTHENTICATION_NO_MITM : AUTHENTICATION_MITM;
+ mService.writeDescriptor(mClientIf, address, handle,
+ authReq, descriptor.getValue());
+ mAuthRetryState++;
+ return;
+ } catch (RemoteException e) {
+ Log.e(TAG, "", e);
}
}
- });
- }
- /**
- * Callback invoked when the given connection is updated
- * @hide
- */
- @Override
- public void onConnectionUpdated(String address, int interval, int latency,
- int timeout, int status) {
- if (DBG) Log.d(TAG, "onConnectionUpdated() - Device=" + address +
- " interval=" + interval + " latency=" + latency +
- " timeout=" + timeout + " status=" + status);
- if (!address.equals(mDevice.getAddress())) {
- return;
+ mAuthRetryState = AUTH_RETRY_STATE_IDLE;
+
+ runOrQueueCallback(new Runnable() {
+ @Override
+ public void run() {
+ if (mCallback != null) {
+ mCallback.onDescriptorWrite(BluetoothGatt.this, descriptor, status);
+ }
+ }
+ });
}
- runOrQueueCallback(new Runnable() {
- @Override
- public void run() {
- if (mCallback != null) {
- mCallback.onConnectionUpdated(BluetoothGatt.this, interval, latency,
- timeout, status);
- }
+ /**
+ * Prepared write transaction completed (or aborted)
+ * @hide
+ */
+ @Override
+ public void onExecuteWrite(String address, int status) {
+ if (VDBG) {
+ Log.d(TAG, "onExecuteWrite() - Device=" + address
+ + " status=" + status);
}
- });
- }
- };
+ if (!address.equals(mDevice.getAddress())) {
+ return;
+ }
+
+ synchronized (mDeviceBusy) {
+ mDeviceBusy = false;
+ }
+
+ runOrQueueCallback(new Runnable() {
+ @Override
+ public void run() {
+ if (mCallback != null) {
+ mCallback.onReliableWriteCompleted(BluetoothGatt.this, status);
+ }
+ }
+ });
+ }
+
+ /**
+ * Remote device RSSI has been read
+ * @hide
+ */
+ @Override
+ public void onReadRemoteRssi(String address, int rssi, int status) {
+ if (VDBG) {
+ Log.d(TAG, "onReadRemoteRssi() - Device=" + address +
+ " rssi=" + rssi + " status=" + status);
+ }
+ if (!address.equals(mDevice.getAddress())) {
+ return;
+ }
+ runOrQueueCallback(new Runnable() {
+ @Override
+ public void run() {
+ if (mCallback != null) {
+ mCallback.onReadRemoteRssi(BluetoothGatt.this, rssi, status);
+ }
+ }
+ });
+ }
+
+ /**
+ * Callback invoked when the MTU for a given connection changes
+ * @hide
+ */
+ @Override
+ public void onConfigureMTU(String address, int mtu, int status) {
+ if (DBG) {
+ Log.d(TAG, "onConfigureMTU() - Device=" + address +
+ " mtu=" + mtu + " status=" + status);
+ }
+ if (!address.equals(mDevice.getAddress())) {
+ return;
+ }
+
+ runOrQueueCallback(new Runnable() {
+ @Override
+ public void run() {
+ if (mCallback != null) {
+ mCallback.onMtuChanged(BluetoothGatt.this, mtu, status);
+ }
+ }
+ });
+ }
+
+ /**
+ * Callback invoked when the given connection is updated
+ * @hide
+ */
+ @Override
+ public void onConnectionUpdated(String address, int interval, int latency,
+ int timeout, int status) {
+ if (DBG) {
+ Log.d(TAG, "onConnectionUpdated() - Device=" + address +
+ " interval=" + interval + " latency=" + latency +
+ " timeout=" + timeout + " status=" + status);
+ }
+ if (!address.equals(mDevice.getAddress())) {
+ return;
+ }
+
+ runOrQueueCallback(new Runnable() {
+ @Override
+ public void run() {
+ if (mCallback != null) {
+ mCallback.onConnectionUpdated(BluetoothGatt.this, interval, latency,
+ timeout, status);
+ }
+ }
+ });
+ }
+ };
/*package*/ BluetoothGatt(IBluetoothGatt iGatt, BluetoothDevice device,
- int transport, boolean opportunistic, int phy) {
+ int transport, boolean opportunistic, int phy) {
mService = iGatt;
mDevice = device;
mTransport = transport;
@@ -657,15 +698,16 @@
/**
* Returns a service by UUID, instance and type.
+ *
* @hide
*/
/*package*/ BluetoothGattService getService(BluetoothDevice device, UUID uuid,
- int instanceId, int type) {
- for(BluetoothGattService svc : mServices) {
+ int instanceId, int type) {
+ for (BluetoothGattService svc : mServices) {
if (svc.getDevice().equals(device) &&
- svc.getType() == type &&
- svc.getInstanceId() == instanceId &&
- svc.getUuid().equals(uuid)) {
+ svc.getType() == type &&
+ svc.getInstanceId() == instanceId &&
+ svc.getUuid().equals(uuid)) {
return svc;
}
}
@@ -675,13 +717,16 @@
/**
* Returns a characteristic with id equal to instanceId.
+ *
* @hide
*/
- /*package*/ BluetoothGattCharacteristic getCharacteristicById(BluetoothDevice device, int instanceId) {
- for(BluetoothGattService svc : mServices) {
- for(BluetoothGattCharacteristic charac : svc.getCharacteristics()) {
- if (charac.getInstanceId() == instanceId)
+ /*package*/ BluetoothGattCharacteristic getCharacteristicById(BluetoothDevice device,
+ int instanceId) {
+ for (BluetoothGattService svc : mServices) {
+ for (BluetoothGattCharacteristic charac : svc.getCharacteristics()) {
+ if (charac.getInstanceId() == instanceId) {
return charac;
+ }
}
}
return null;
@@ -689,14 +734,16 @@
/**
* Returns a descriptor with id equal to instanceId.
+ *
* @hide
*/
/*package*/ BluetoothGattDescriptor getDescriptorById(BluetoothDevice device, int instanceId) {
- for(BluetoothGattService svc : mServices) {
- for(BluetoothGattCharacteristic charac : svc.getCharacteristics()) {
- for(BluetoothGattDescriptor desc : charac.getDescriptors()) {
- if (desc.getInstanceId() == instanceId)
+ for (BluetoothGattService svc : mServices) {
+ for (BluetoothGattCharacteristic charac : svc.getCharacteristics()) {
+ for (BluetoothGattDescriptor desc : charac.getDescriptors()) {
+ if (desc.getInstanceId() == instanceId) {
return desc;
+ }
}
}
}
@@ -709,13 +756,13 @@
*/
private void runOrQueueCallback(final Runnable cb) {
if (mHandler == null) {
- try {
- cb.run();
- } catch (Exception ex) {
- Log.w(TAG, "Unhandled exception in callback", ex);
- }
+ try {
+ cb.run();
+ } catch (Exception ex) {
+ Log.w(TAG, "Unhandled exception in callback", ex);
+ }
} else {
- mHandler.post(cb);
+ mHandler.post(cb);
}
}
@@ -728,8 +775,8 @@
* <p>Requires {@link android.Manifest.permission#BLUETOOTH} permission.
*
* @param callback GATT callback handler that will receive asynchronous callbacks.
- * @return If true, the callback will be called to notify success or failure,
- * false on immediate error
+ * @return If true, the callback will be called to notify success or failure, false on immediate
+ * error
*/
private boolean registerApp(BluetoothGattCallback callback, Handler handler) {
if (DBG) Log.d(TAG, "registerApp()");
@@ -743,7 +790,7 @@
try {
mService.registerClient(new ParcelUuid(uuid), mBluetoothGattCallback);
} catch (RemoteException e) {
- Log.e(TAG,"",e);
+ Log.e(TAG, "", e);
return false;
}
@@ -762,7 +809,7 @@
mService.unregisterClient(mClientIf);
mClientIf = 0;
} catch (RemoteException e) {
- Log.e(TAG,"",e);
+ Log.e(TAG, "", e);
}
}
@@ -784,15 +831,17 @@
* <p>Requires {@link android.Manifest.permission#BLUETOOTH} permission.
*
* @param device Remote device to connect to
- * @param autoConnect Whether to directly connect to the remote device (false)
- * or to automatically connect as soon as the remote
- * device becomes available (true).
+ * @param autoConnect Whether to directly connect to the remote device (false) or to
+ * automatically connect as soon as the remote device becomes available (true).
* @return true, if the connection attempt was initiated successfully
*/
/*package*/ boolean connect(Boolean autoConnect, BluetoothGattCallback callback,
- Handler handler) {
- if (DBG) Log.d(TAG, "connect() - device: " + mDevice.getAddress() + ", auto: " + autoConnect);
- synchronized(mStateLock) {
+ Handler handler) {
+ if (DBG) {
+ Log.d(TAG,
+ "connect() - device: " + mDevice.getAddress() + ", auto: " + autoConnect);
+ }
+ synchronized (mStateLock) {
if (mConnState != CONN_STATE_IDLE) {
throw new IllegalStateException("Not idle");
}
@@ -802,7 +851,7 @@
mAutoConnect = autoConnect;
if (!registerApp(callback, handler)) {
- synchronized(mStateLock) {
+ synchronized (mStateLock) {
mConnState = CONN_STATE_IDLE;
}
Log.e(TAG, "Failed to register callback");
@@ -826,7 +875,7 @@
try {
mService.clientDisconnect(mClientIf, mDevice.getAddress());
} catch (RemoteException e) {
- Log.e(TAG,"",e);
+ Log.e(TAG, "", e);
}
}
@@ -845,7 +894,7 @@
mOpportunistic, mPhy); // autoConnect is inverse of "isDirect"
return true;
} catch (RemoteException e) {
- Log.e(TAG,"",e);
+ Log.e(TAG, "", e);
return false;
}
}
@@ -858,22 +907,22 @@
* {@link BluetoothGattCallback#onPhyUpdate} will be triggered as a result of this call, even
* if no PHY change happens. It is also triggered when remote device updates the PHY.
*
- * @param txPhy preferred transmitter PHY. Bitwise OR of any of
- * {@link BluetoothDevice#PHY_LE_1M_MASK}, {@link BluetoothDevice#PHY_LE_2M_MASK},
- * and {@link BluetoothDevice#PHY_LE_CODED_MASK}.
- * @param rxPhy preferred receiver PHY. Bitwise OR of any of
- * {@link BluetoothDevice#PHY_LE_1M_MASK}, {@link BluetoothDevice#PHY_LE_2M_MASK},
- * and {@link BluetoothDevice#PHY_LE_CODED_MASK}.
+ * @param txPhy preferred transmitter PHY. Bitwise OR of any of {@link
+ * BluetoothDevice#PHY_LE_1M_MASK}, {@link BluetoothDevice#PHY_LE_2M_MASK}, and {@link
+ * BluetoothDevice#PHY_LE_CODED_MASK}.
+ * @param rxPhy preferred receiver PHY. Bitwise OR of any of {@link
+ * BluetoothDevice#PHY_LE_1M_MASK}, {@link BluetoothDevice#PHY_LE_2M_MASK}, and {@link
+ * BluetoothDevice#PHY_LE_CODED_MASK}.
* @param phyOptions preferred coding to use when transmitting on the LE Coded PHY. Can be one
- * of {@link BluetoothDevice#PHY_OPTION_NO_PREFERRED},
- * {@link BluetoothDevice#PHY_OPTION_S2} or {@link BluetoothDevice#PHY_OPTION_S8}
+ * of {@link BluetoothDevice#PHY_OPTION_NO_PREFERRED}, {@link BluetoothDevice#PHY_OPTION_S2} or
+ * {@link BluetoothDevice#PHY_OPTION_S8}
*/
public void setPreferredPhy(int txPhy, int rxPhy, int phyOptions) {
try {
mService.clientSetPreferredPhy(mClientIf, mDevice.getAddress(), txPhy, rxPhy,
- phyOptions);
+ phyOptions);
} catch (RemoteException e) {
- Log.e(TAG,"",e);
+ Log.e(TAG, "", e);
}
}
@@ -885,7 +934,7 @@
try {
mService.clientReadPhy(mClientIf, mDevice.getAddress());
} catch (RemoteException e) {
- Log.e(TAG,"",e);
+ Log.e(TAG, "", e);
}
}
@@ -920,7 +969,7 @@
try {
mService.discoverServices(mClientIf, mDevice.getAddress());
} catch (RemoteException e) {
- Log.e(TAG,"",e);
+ Log.e(TAG, "", e);
return false;
}
@@ -960,8 +1009,8 @@
*
* <p>Requires {@link android.Manifest.permission#BLUETOOTH} permission.
*
- * @return List of services on the remote device. Returns an empty list
- * if service discovery has not yet been performed.
+ * @return List of services on the remote device. Returns an empty list if service discovery has
+ * not yet been performed.
*/
public List<BluetoothGattService> getServices() {
List<BluetoothGattService> result =
@@ -989,13 +1038,13 @@
* <p>Requires {@link android.Manifest.permission#BLUETOOTH} permission.
*
* @param uuid UUID of the requested service
- * @return BluetoothGattService if supported, or null if the requested
- * service is not offered by the remote device.
+ * @return BluetoothGattService if supported, or null if the requested service is not offered by
+ * the remote device.
*/
public BluetoothGattService getService(UUID uuid) {
for (BluetoothGattService service : mServices) {
if (service.getDevice().equals(mDevice) &&
- service.getUuid().equals(uuid)) {
+ service.getUuid().equals(uuid)) {
return service;
}
}
@@ -1017,7 +1066,9 @@
*/
public boolean readCharacteristic(BluetoothGattCharacteristic characteristic) {
if ((characteristic.getProperties() &
- BluetoothGattCharacteristic.PROPERTY_READ) == 0) return false;
+ BluetoothGattCharacteristic.PROPERTY_READ) == 0) {
+ return false;
+ }
if (VDBG) Log.d(TAG, "readCharacteristic() - uuid: " + characteristic.getUuid());
if (mService == null || mClientIf == 0) return false;
@@ -1028,16 +1079,16 @@
BluetoothDevice device = service.getDevice();
if (device == null) return false;
- synchronized(mDeviceBusy) {
+ synchronized (mDeviceBusy) {
if (mDeviceBusy) return false;
mDeviceBusy = true;
}
try {
mService.readCharacteristic(mClientIf, device.getAddress(),
- characteristic.getInstanceId(), AUTHENTICATION_NONE);
+ characteristic.getInstanceId(), AUTHENTICATION_NONE);
} catch (RemoteException e) {
- Log.e(TAG,"",e);
+ Log.e(TAG, "", e);
mDeviceBusy = false;
return false;
}
@@ -1062,16 +1113,16 @@
if (VDBG) Log.d(TAG, "readUsingCharacteristicUuid() - uuid: " + uuid);
if (mService == null || mClientIf == 0) return false;
- synchronized(mDeviceBusy) {
+ synchronized (mDeviceBusy) {
if (mDeviceBusy) return false;
mDeviceBusy = true;
}
try {
mService.readUsingCharacteristicUuid(mClientIf, mDevice.getAddress(),
- new ParcelUuid(uuid), startHandle, endHandle, AUTHENTICATION_NONE);
+ new ParcelUuid(uuid), startHandle, endHandle, AUTHENTICATION_NONE);
} catch (RemoteException e) {
- Log.e(TAG,"",e);
+ Log.e(TAG, "", e);
mDeviceBusy = false;
return false;
}
@@ -1094,8 +1145,10 @@
*/
public boolean writeCharacteristic(BluetoothGattCharacteristic characteristic) {
if ((characteristic.getProperties() & BluetoothGattCharacteristic.PROPERTY_WRITE) == 0
- && (characteristic.getProperties() &
- BluetoothGattCharacteristic.PROPERTY_WRITE_NO_RESPONSE) == 0) return false;
+ && (characteristic.getProperties() &
+ BluetoothGattCharacteristic.PROPERTY_WRITE_NO_RESPONSE) == 0) {
+ return false;
+ }
if (VDBG) Log.d(TAG, "writeCharacteristic() - uuid: " + characteristic.getUuid());
if (mService == null || mClientIf == 0 || characteristic.getValue() == null) return false;
@@ -1106,17 +1159,17 @@
BluetoothDevice device = service.getDevice();
if (device == null) return false;
- synchronized(mDeviceBusy) {
+ synchronized (mDeviceBusy) {
if (mDeviceBusy) return false;
mDeviceBusy = true;
}
try {
mService.writeCharacteristic(mClientIf, device.getAddress(),
- characteristic.getInstanceId(), characteristic.getWriteType(),
- AUTHENTICATION_NONE, characteristic.getValue());
+ characteristic.getInstanceId(), characteristic.getWriteType(),
+ AUTHENTICATION_NONE, characteristic.getValue());
} catch (RemoteException e) {
- Log.e(TAG,"",e);
+ Log.e(TAG, "", e);
mDeviceBusy = false;
return false;
}
@@ -1149,16 +1202,16 @@
BluetoothDevice device = service.getDevice();
if (device == null) return false;
- synchronized(mDeviceBusy) {
+ synchronized (mDeviceBusy) {
if (mDeviceBusy) return false;
mDeviceBusy = true;
}
try {
mService.readDescriptor(mClientIf, device.getAddress(),
- descriptor.getInstanceId(), AUTHENTICATION_NONE);
+ descriptor.getInstanceId(), AUTHENTICATION_NONE);
} catch (RemoteException e) {
- Log.e(TAG,"",e);
+ Log.e(TAG, "", e);
mDeviceBusy = false;
return false;
}
@@ -1190,16 +1243,16 @@
BluetoothDevice device = service.getDevice();
if (device == null) return false;
- synchronized(mDeviceBusy) {
+ synchronized (mDeviceBusy) {
if (mDeviceBusy) return false;
mDeviceBusy = true;
}
try {
mService.writeDescriptor(mClientIf, device.getAddress(), descriptor.getInstanceId(),
- AUTHENTICATION_NONE, descriptor.getValue());
+ AUTHENTICATION_NONE, descriptor.getValue());
} catch (RemoteException e) {
- Log.e(TAG,"",e);
+ Log.e(TAG, "", e);
mDeviceBusy = false;
return false;
}
@@ -1234,7 +1287,7 @@
try {
mService.beginReliableWrite(mClientIf, mDevice.getAddress());
} catch (RemoteException e) {
- Log.e(TAG,"",e);
+ Log.e(TAG, "", e);
return false;
}
@@ -1258,7 +1311,7 @@
if (VDBG) Log.d(TAG, "executeReliableWrite() - device: " + mDevice.getAddress());
if (mService == null || mClientIf == 0) return false;
- synchronized(mDeviceBusy) {
+ synchronized (mDeviceBusy) {
if (mDeviceBusy) return false;
mDeviceBusy = true;
}
@@ -1266,7 +1319,7 @@
try {
mService.endReliableWrite(mClientIf, mDevice.getAddress(), true);
} catch (RemoteException e) {
- Log.e(TAG,"",e);
+ Log.e(TAG, "", e);
mDeviceBusy = false;
return false;
}
@@ -1289,7 +1342,7 @@
try {
mService.endReliableWrite(mClientIf, mDevice.getAddress(), false);
} catch (RemoteException e) {
- Log.e(TAG,"",e);
+ Log.e(TAG, "", e);
}
}
@@ -1316,9 +1369,11 @@
* @return true, if the requested notification status was set successfully
*/
public boolean setCharacteristicNotification(BluetoothGattCharacteristic characteristic,
- boolean enable) {
- if (DBG) Log.d(TAG, "setCharacteristicNotification() - uuid: " + characteristic.getUuid()
- + " enable: " + enable);
+ boolean enable) {
+ if (DBG) {
+ Log.d(TAG, "setCharacteristicNotification() - uuid: " + characteristic.getUuid()
+ + " enable: " + enable);
+ }
if (mService == null || mClientIf == 0) return false;
BluetoothGattService service = characteristic.getService();
@@ -1329,9 +1384,9 @@
try {
mService.registerForNotification(mClientIf, device.getAddress(),
- characteristic.getInstanceId(), enable);
+ characteristic.getInstanceId(), enable);
} catch (RemoteException e) {
- Log.e(TAG,"",e);
+ Log.e(TAG, "", e);
return false;
}
@@ -1341,6 +1396,7 @@
/**
* Clears the internal cache and forces a refresh of the services from the
* remote device.
+ *
* @hide
*/
public boolean refresh() {
@@ -1350,7 +1406,7 @@
try {
mService.refreshDevice(mClientIf, mDevice.getAddress());
} catch (RemoteException e) {
- Log.e(TAG,"",e);
+ Log.e(TAG, "", e);
return false;
}
@@ -1374,7 +1430,7 @@
try {
mService.readRemoteRssi(mClientIf, mDevice.getAddress());
} catch (RemoteException e) {
- Log.e(TAG,"",e);
+ Log.e(TAG, "", e);
return false;
}
@@ -1396,14 +1452,16 @@
* @return true, if the new MTU value has been requested successfully
*/
public boolean requestMtu(int mtu) {
- if (DBG) Log.d(TAG, "configureMTU() - device: " + mDevice.getAddress()
- + " mtu: " + mtu);
+ if (DBG) {
+ Log.d(TAG, "configureMTU() - device: " + mDevice.getAddress()
+ + " mtu: " + mtu);
+ }
if (mService == null || mClientIf == 0) return false;
try {
mService.configureMTU(mClientIf, mDevice.getAddress(), mtu);
} catch (RemoteException e) {
- Log.e(TAG,"",e);
+ Log.e(TAG, "", e);
return false;
}
@@ -1416,16 +1474,14 @@
* <p>This function will send a connection parameter update request to the
* remote device.
*
- * @param connectionPriority Request a specific connection priority. Must be one of
- * {@link BluetoothGatt#CONNECTION_PRIORITY_BALANCED},
- * {@link BluetoothGatt#CONNECTION_PRIORITY_HIGH}
- * or {@link BluetoothGatt#CONNECTION_PRIORITY_LOW_POWER}.
- * @throws IllegalArgumentException If the parameters are outside of their
- * specified range.
+ * @param connectionPriority Request a specific connection priority. Must be one of {@link
+ * BluetoothGatt#CONNECTION_PRIORITY_BALANCED}, {@link BluetoothGatt#CONNECTION_PRIORITY_HIGH}
+ * or {@link BluetoothGatt#CONNECTION_PRIORITY_LOW_POWER}.
+ * @throws IllegalArgumentException If the parameters are outside of their specified range.
*/
public boolean requestConnectionPriority(int connectionPriority) {
if (connectionPriority < CONNECTION_PRIORITY_BALANCED ||
- connectionPriority > CONNECTION_PRIORITY_LOW_POWER) {
+ connectionPriority > CONNECTION_PRIORITY_LOW_POWER) {
throw new IllegalArgumentException("connectionPriority not within valid range");
}
@@ -1435,7 +1491,7 @@
try {
mService.connectionParameterUpdate(mClientIf, mDevice.getAddress(), connectionPriority);
} catch (RemoteException e) {
- Log.e(TAG,"",e);
+ Log.e(TAG, "", e);
return false;
}
@@ -1462,7 +1518,7 @@
@Override
public List<BluetoothDevice> getConnectedDevices() {
throw new UnsupportedOperationException
- ("Use BluetoothManager#getConnectedDevices instead.");
+ ("Use BluetoothManager#getConnectedDevices instead.");
}
/**
@@ -1475,6 +1531,6 @@
@Override
public List<BluetoothDevice> getDevicesMatchingConnectionStates(int[] states) {
throw new UnsupportedOperationException
- ("Use BluetoothManager#getDevicesMatchingConnectionStates instead.");
+ ("Use BluetoothManager#getDevicesMatchingConnectionStates instead.");
}
}
diff --git a/framework/java/android/bluetooth/BluetoothGattCallback.java b/framework/java/android/bluetooth/BluetoothGattCallback.java
index c6f82ff..cf82a33 100644
--- a/framework/java/android/bluetooth/BluetoothGattCallback.java
+++ b/framework/java/android/bluetooth/BluetoothGattCallback.java
@@ -19,19 +19,19 @@
/**
* This abstract class is used to implement {@link BluetoothGatt} callbacks.
*/
-public abstract class BluetoothGattCallback{
+public abstract class BluetoothGattCallback {
/**
* Callback triggered as result of {@link BluetoothGatt#setPreferredPhy}, or as a result of
* remote device changing the PHY.
*
* @param gatt GATT client
- * @param txPhy the transmitter PHY in use. One of {@link BluetoothDevice#PHY_LE_1M},
- * {@link BluetoothDevice#PHY_LE_2M}, and {@link BluetoothDevice#PHY_LE_CODED}.
- * @param rxPhy the receiver PHY in use. One of {@link BluetoothDevice#PHY_LE_1M},
- * {@link BluetoothDevice#PHY_LE_2M}, and {@link BluetoothDevice#PHY_LE_CODED}.
- * @param status Status of the PHY update operation.
- * {@link BluetoothGatt#GATT_SUCCESS} if the operation succeeds.
+ * @param txPhy the transmitter PHY in use. One of {@link BluetoothDevice#PHY_LE_1M}, {@link
+ * BluetoothDevice#PHY_LE_2M}, and {@link BluetoothDevice#PHY_LE_CODED}.
+ * @param rxPhy the receiver PHY in use. One of {@link BluetoothDevice#PHY_LE_1M}, {@link
+ * BluetoothDevice#PHY_LE_2M}, and {@link BluetoothDevice#PHY_LE_CODED}.
+ * @param status Status of the PHY update operation. {@link BluetoothGatt#GATT_SUCCESS} if the
+ * operation succeeds.
*/
public void onPhyUpdate(BluetoothGatt gatt, int txPhy, int rxPhy, int status) {
}
@@ -40,12 +40,12 @@
* Callback triggered as result of {@link BluetoothGatt#readPhy}
*
* @param gatt GATT client
- * @param txPhy the transmitter PHY in use. One of {@link BluetoothDevice#PHY_LE_1M},
- * {@link BluetoothDevice#PHY_LE_2M}, and {@link BluetoothDevice#PHY_LE_CODED}.
- * @param rxPhy the receiver PHY in use. One of {@link BluetoothDevice#PHY_LE_1M},
- * {@link BluetoothDevice#PHY_LE_2M}, and {@link BluetoothDevice#PHY_LE_CODED}.
- * @param status Status of the PHY read operation.
- * {@link BluetoothGatt#GATT_SUCCESS} if the operation succeeds.
+ * @param txPhy the transmitter PHY in use. One of {@link BluetoothDevice#PHY_LE_1M}, {@link
+ * BluetoothDevice#PHY_LE_2M}, and {@link BluetoothDevice#PHY_LE_CODED}.
+ * @param rxPhy the receiver PHY in use. One of {@link BluetoothDevice#PHY_LE_1M}, {@link
+ * BluetoothDevice#PHY_LE_2M}, and {@link BluetoothDevice#PHY_LE_CODED}.
+ * @param status Status of the PHY read operation. {@link BluetoothGatt#GATT_SUCCESS} if the
+ * operation succeeds.
*/
public void onPhyRead(BluetoothGatt gatt, int txPhy, int rxPhy, int status) {
}
@@ -55,14 +55,13 @@
* GATT server.
*
* @param gatt GATT client
- * @param status Status of the connect or disconnect operation.
- * {@link BluetoothGatt#GATT_SUCCESS} if the operation succeeds.
- * @param newState Returns the new connection state. Can be one of
- * {@link BluetoothProfile#STATE_DISCONNECTED} or
- * {@link BluetoothProfile#STATE_CONNECTED}
+ * @param status Status of the connect or disconnect operation. {@link
+ * BluetoothGatt#GATT_SUCCESS} if the operation succeeds.
+ * @param newState Returns the new connection state. Can be one of {@link
+ * BluetoothProfile#STATE_DISCONNECTED} or {@link BluetoothProfile#STATE_CONNECTED}
*/
public void onConnectionStateChange(BluetoothGatt gatt, int status,
- int newState) {
+ int newState) {
}
/**
@@ -70,8 +69,8 @@
* for the remote device have been updated, ie new services have been discovered.
*
* @param gatt GATT client invoked {@link BluetoothGatt#discoverServices}
- * @param status {@link BluetoothGatt#GATT_SUCCESS} if the remote device
- * has been explored successfully.
+ * @param status {@link BluetoothGatt#GATT_SUCCESS} if the remote device has been explored
+ * successfully.
*/
public void onServicesDiscovered(BluetoothGatt gatt, int status) {
}
@@ -80,13 +79,12 @@
* Callback reporting the result of a characteristic read operation.
*
* @param gatt GATT client invoked {@link BluetoothGatt#readCharacteristic}
- * @param characteristic Characteristic that was read from the associated
- * remote device.
- * @param status {@link BluetoothGatt#GATT_SUCCESS} if the read operation
- * was completed successfully.
+ * @param characteristic Characteristic that was read from the associated remote device.
+ * @param status {@link BluetoothGatt#GATT_SUCCESS} if the read operation was completed
+ * successfully.
*/
public void onCharacteristicRead(BluetoothGatt gatt, BluetoothGattCharacteristic characteristic,
- int status) {
+ int status) {
}
/**
@@ -99,58 +97,55 @@
* the application must abort the reliable write transaction.
*
* @param gatt GATT client invoked {@link BluetoothGatt#writeCharacteristic}
- * @param characteristic Characteristic that was written to the associated
- * remote device.
- * @param status The result of the write operation
- * {@link BluetoothGatt#GATT_SUCCESS} if the operation succeeds.
+ * @param characteristic Characteristic that was written to the associated remote device.
+ * @param status The result of the write operation {@link BluetoothGatt#GATT_SUCCESS} if the
+ * operation succeeds.
*/
public void onCharacteristicWrite(BluetoothGatt gatt,
- BluetoothGattCharacteristic characteristic, int status) {
+ BluetoothGattCharacteristic characteristic, int status) {
}
/**
* Callback triggered as a result of a remote characteristic notification.
*
* @param gatt GATT client the characteristic is associated with
- * @param characteristic Characteristic that has been updated as a result
- * of a remote notification event.
+ * @param characteristic Characteristic that has been updated as a result of a remote
+ * notification event.
*/
public void onCharacteristicChanged(BluetoothGatt gatt,
- BluetoothGattCharacteristic characteristic) {
+ BluetoothGattCharacteristic characteristic) {
}
/**
* Callback reporting the result of a descriptor read operation.
*
* @param gatt GATT client invoked {@link BluetoothGatt#readDescriptor}
- * @param descriptor Descriptor that was read from the associated
- * remote device.
- * @param status {@link BluetoothGatt#GATT_SUCCESS} if the read operation
- * was completed successfully
+ * @param descriptor Descriptor that was read from the associated remote device.
+ * @param status {@link BluetoothGatt#GATT_SUCCESS} if the read operation was completed
+ * successfully
*/
public void onDescriptorRead(BluetoothGatt gatt, BluetoothGattDescriptor descriptor,
- int status) {
+ int status) {
}
/**
* Callback indicating the result of a descriptor write operation.
*
* @param gatt GATT client invoked {@link BluetoothGatt#writeDescriptor}
- * @param descriptor Descriptor that was writte to the associated
- * remote device.
- * @param status The result of the write operation
- * {@link BluetoothGatt#GATT_SUCCESS} if the operation succeeds.
+ * @param descriptor Descriptor that was writte to the associated remote device.
+ * @param status The result of the write operation {@link BluetoothGatt#GATT_SUCCESS} if the
+ * operation succeeds.
*/
public void onDescriptorWrite(BluetoothGatt gatt, BluetoothGattDescriptor descriptor,
- int status) {
+ int status) {
}
/**
* Callback invoked when a reliable write transaction has been completed.
*
* @param gatt GATT client invoked {@link BluetoothGatt#executeReliableWrite}
- * @param status {@link BluetoothGatt#GATT_SUCCESS} if the reliable write
- * transaction was executed successfully
+ * @param status {@link BluetoothGatt#GATT_SUCCESS} if the reliable write transaction was
+ * executed successfully
*/
public void onReliableWriteCompleted(BluetoothGatt gatt, int status) {
}
@@ -186,17 +181,17 @@
* Callback indicating the connection parameters were updated.
*
* @param gatt GATT client involved
- * @param interval Connection interval used on this connection, 1.25ms unit. Valid
- * range is from 6 (7.5ms) to 3200 (4000ms).
- * @param latency Slave latency for the connection in number of connection events. Valid
- * range is from 0 to 499
- * @param timeout Supervision timeout for this connection, in 10ms unit. Valid range is
- * from 10 (0.1s) to 3200 (32s)
+ * @param interval Connection interval used on this connection, 1.25ms unit. Valid range is from
+ * 6 (7.5ms) to 3200 (4000ms).
+ * @param latency Slave latency for the connection in number of connection events. Valid range
+ * is from 0 to 499
+ * @param timeout Supervision timeout for this connection, in 10ms unit. Valid range is from 10
+ * (0.1s) to 3200 (32s)
* @param status {@link BluetoothGatt#GATT_SUCCESS} if the connection has been updated
- * successfully
+ * successfully
* @hide
*/
public void onConnectionUpdated(BluetoothGatt gatt, int interval, int latency, int timeout,
- int status) {
+ int status) {
}
}
diff --git a/framework/java/android/bluetooth/BluetoothGattCharacteristic.java b/framework/java/android/bluetooth/BluetoothGattCharacteristic.java
index 1cc2270..4816804 100644
--- a/framework/java/android/bluetooth/BluetoothGattCharacteristic.java
+++ b/framework/java/android/bluetooth/BluetoothGattCharacteristic.java
@@ -16,8 +16,9 @@
package android.bluetooth;
import android.os.Parcel;
-import android.os.Parcelable;
import android.os.ParcelUuid;
+import android.os.Parcelable;
+
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
@@ -171,30 +172,35 @@
/**
* The UUID of this characteristic.
+ *
* @hide
*/
protected UUID mUuid;
/**
* Instance ID for this characteristic.
+ *
* @hide
*/
protected int mInstance;
/**
* Characteristic properties.
+ *
* @hide
*/
protected int mProperties;
/**
* Characteristic permissions.
+ *
* @hide
*/
protected int mPermissions;
/**
* Key size (default = 16).
+ *
* @hide
*/
protected int mKeySize = 16;
@@ -202,18 +208,21 @@
/**
* Write type for this characteristic.
* See WRITE_TYPE_* constants.
+ *
* @hide
*/
protected int mWriteType;
/**
* Back-reference to the service this characteristic belongs to.
+ *
* @hide
*/
protected BluetoothGattService mService;
/**
* The cached value of this characteristic.
+ *
* @hide
*/
protected byte[] mValue;
@@ -237,26 +246,28 @@
/**
* Create a new BluetoothGattCharacteristic
+ *
* @hide
*/
/*package*/ BluetoothGattCharacteristic(BluetoothGattService service,
- UUID uuid, int instanceId,
- int properties, int permissions) {
+ UUID uuid, int instanceId,
+ int properties, int permissions) {
initCharacteristic(service, uuid, instanceId, properties, permissions);
}
/**
* Create a new BluetoothGattCharacteristic
+ *
* @hide
*/
public BluetoothGattCharacteristic(UUID uuid, int instanceId,
- int properties, int permissions) {
+ int properties, int permissions) {
initCharacteristic(null, uuid, instanceId, properties, permissions);
}
private void initCharacteristic(BluetoothGattService service,
- UUID uuid, int instanceId,
- int properties, int permissions) {
+ UUID uuid, int instanceId,
+ int properties, int permissions) {
mUuid = uuid;
mInstance = instanceId;
mProperties = properties;
@@ -301,7 +312,7 @@
};
private BluetoothGattCharacteristic(Parcel in) {
- mUuid = ((ParcelUuid)in.readParcelable(null)).getUuid();
+ mUuid = ((ParcelUuid) in.readParcelable(null)).getUuid();
mInstance = in.readInt();
mProperties = in.readInt();
mPermissions = in.readInt();
@@ -313,7 +324,7 @@
ArrayList<BluetoothGattDescriptor> descs =
in.createTypedArrayList(BluetoothGattDescriptor.CREATOR);
if (descs != null) {
- for (BluetoothGattDescriptor desc: descs) {
+ for (BluetoothGattDescriptor desc : descs) {
desc.setCharacteristic(this);
mDescriptors.add(desc);
}
@@ -322,6 +333,7 @@
/**
* Returns the desired key size.
+ *
* @hide
*/
public int getKeySize() {
@@ -343,12 +355,13 @@
/**
* Get a descriptor by UUID and isntance id.
+ *
* @hide
*/
/*package*/ BluetoothGattDescriptor getDescriptor(UUID uuid, int instanceId) {
- for(BluetoothGattDescriptor descriptor : mDescriptors) {
+ for (BluetoothGattDescriptor descriptor : mDescriptors) {
if (descriptor.getUuid().equals(uuid)
- && descriptor.getInstanceId() == instanceId) {
+ && descriptor.getInstanceId() == instanceId) {
return descriptor;
}
}
@@ -357,6 +370,7 @@
/**
* Returns the service this characteristic belongs to.
+ *
* @return The asscociated service
*/
public BluetoothGattService getService() {
@@ -365,6 +379,7 @@
/**
* Sets the service associated with this device.
+ *
* @hide
*/
/*package*/ void setService(BluetoothGattService service) {
@@ -394,6 +409,7 @@
/**
* Force the instance ID.
+ *
* @hide
*/
public void setInstanceId(int instanceId) {
@@ -437,11 +453,8 @@
* {@link BluetoothGatt#writeCharacteristic} function write this
* characteristic.
*
- * @param writeType The write type to for this characteristic. Can be one
- * of:
- * {@link #WRITE_TYPE_DEFAULT},
- * {@link #WRITE_TYPE_NO_RESPONSE} or
- * {@link #WRITE_TYPE_SIGNED}.
+ * @param writeType The write type to for this characteristic. Can be one of: {@link
+ * #WRITE_TYPE_DEFAULT}, {@link #WRITE_TYPE_NO_RESPONSE} or {@link #WRITE_TYPE_SIGNED}.
*/
public void setWriteType(int writeType) {
mWriteType = writeType;
@@ -449,6 +462,7 @@
/**
* Set the desired key size.
+ *
* @hide
*/
public void setKeySize(int keySize) {
@@ -468,11 +482,10 @@
* Returns a descriptor with a given UUID out of the list of
* descriptors for this characteristic.
*
- * @return GATT descriptor object or null if no descriptor with the
- * given UUID was found.
+ * @return GATT descriptor object or null if no descriptor with the given UUID was found.
*/
public BluetoothGattDescriptor getDescriptor(UUID uuid) {
- for(BluetoothGattDescriptor descriptor : mDescriptors) {
+ for (BluetoothGattDescriptor descriptor : mDescriptors) {
if (descriptor.getUuid().equals(uuid)) {
return descriptor;
}
@@ -503,11 +516,9 @@
* characteristic value at the given offset are interpreted to generate the
* return value.
*
- * @param formatType The format type used to interpret the characteristic
- * value.
+ * @param formatType The format type used to interpret the characteristic value.
* @param offset Offset at which the integer value can be found.
- * @return Cached value of the characteristic or null of offset exceeds
- * value size.
+ * @return Cached value of the characteristic or null of offset exceeds value size.
*/
public Integer getIntValue(int formatType, int offset) {
if ((offset + getTypeLen(formatType)) > mValue.length) return null;
@@ -517,21 +528,21 @@
return unsignedByteToInt(mValue[offset]);
case FORMAT_UINT16:
- return unsignedBytesToInt(mValue[offset], mValue[offset+1]);
+ return unsignedBytesToInt(mValue[offset], mValue[offset + 1]);
case FORMAT_UINT32:
- return unsignedBytesToInt(mValue[offset], mValue[offset+1],
- mValue[offset+2], mValue[offset+3]);
+ return unsignedBytesToInt(mValue[offset], mValue[offset + 1],
+ mValue[offset + 2], mValue[offset + 3]);
case FORMAT_SINT8:
return unsignedToSigned(unsignedByteToInt(mValue[offset]), 8);
case FORMAT_SINT16:
return unsignedToSigned(unsignedBytesToInt(mValue[offset],
- mValue[offset+1]), 16);
+ mValue[offset + 1]), 16);
case FORMAT_SINT32:
return unsignedToSigned(unsignedBytesToInt(mValue[offset],
- mValue[offset+1], mValue[offset+2], mValue[offset+3]), 32);
+ mValue[offset + 1], mValue[offset + 2], mValue[offset + 3]), 32);
}
return null;
@@ -541,22 +552,21 @@
* Return the stored value of this characteristic.
* <p>See {@link #getValue} for details.
*
- * @param formatType The format type used to interpret the characteristic
- * value.
+ * @param formatType The format type used to interpret the characteristic value.
* @param offset Offset at which the float value can be found.
- * @return Cached value of the characteristic at a given offset or null
- * if the requested offset exceeds the value size.
+ * @return Cached value of the characteristic at a given offset or null if the requested offset
+ * exceeds the value size.
*/
public Float getFloatValue(int formatType, int offset) {
if ((offset + getTypeLen(formatType)) > mValue.length) return null;
switch (formatType) {
case FORMAT_SFLOAT:
- return bytesToFloat(mValue[offset], mValue[offset+1]);
+ return bytesToFloat(mValue[offset], mValue[offset + 1]);
case FORMAT_FLOAT:
- return bytesToFloat(mValue[offset], mValue[offset+1],
- mValue[offset+2], mValue[offset+3]);
+ return bytesToFloat(mValue[offset], mValue[offset + 1],
+ mValue[offset + 2], mValue[offset + 3]);
}
return null;
@@ -572,7 +582,7 @@
public String getStringValue(int offset) {
if (mValue == null || offset > mValue.length) return null;
byte[] strBytes = new byte[mValue.length - offset];
- for (int i=0; i != (mValue.length-offset); ++i) strBytes[i] = mValue[offset+i];
+ for (int i = 0; i != (mValue.length - offset); ++i) strBytes[i] = mValue[offset + i];
return new String(strBytes);
}
@@ -585,8 +595,8 @@
* remote device.
*
* @param value New value for this characteristic
- * @return true if the locally stored value has been set, false if the
- * requested value could not be stored locally.
+ * @return true if the locally stored value has been set, false if the requested value could not
+ * be stored locally.
*/
public boolean setValue(byte[] value) {
mValue = value;
@@ -612,25 +622,25 @@
value = intToSignedBits(value, 8);
// Fall-through intended
case FORMAT_UINT8:
- mValue[offset] = (byte)(value & 0xFF);
+ mValue[offset] = (byte) (value & 0xFF);
break;
case FORMAT_SINT16:
value = intToSignedBits(value, 16);
// Fall-through intended
case FORMAT_UINT16:
- mValue[offset++] = (byte)(value & 0xFF);
- mValue[offset] = (byte)((value >> 8) & 0xFF);
+ mValue[offset++] = (byte) (value & 0xFF);
+ mValue[offset] = (byte) ((value >> 8) & 0xFF);
break;
case FORMAT_SINT32:
value = intToSignedBits(value, 32);
// Fall-through intended
case FORMAT_UINT32:
- mValue[offset++] = (byte)(value & 0xFF);
- mValue[offset++] = (byte)((value >> 8) & 0xFF);
- mValue[offset++] = (byte)((value >> 16) & 0xFF);
- mValue[offset] = (byte)((value >> 24) & 0xFF);
+ mValue[offset++] = (byte) (value & 0xFF);
+ mValue[offset++] = (byte) ((value >> 8) & 0xFF);
+ mValue[offset++] = (byte) ((value >> 16) & 0xFF);
+ mValue[offset] = (byte) ((value >> 24) & 0xFF);
break;
default:
@@ -644,7 +654,7 @@
* <p>See {@link #setValue(byte[])} for details.
*
* @param mantissa Mantissa for this characteristic
- * @param exponent exponent value for this characteristic
+ * @param exponent exponent value for this characteristic
* @param formatType Float format type used to transform the value parameter
* @param offset Offset at which the value should be placed
* @return true if the locally stored value has been set
@@ -658,18 +668,18 @@
case FORMAT_SFLOAT:
mantissa = intToSignedBits(mantissa, 12);
exponent = intToSignedBits(exponent, 4);
- mValue[offset++] = (byte)(mantissa & 0xFF);
- mValue[offset] = (byte)((mantissa >> 8) & 0x0F);
- mValue[offset] += (byte)((exponent & 0x0F) << 4);
+ mValue[offset++] = (byte) (mantissa & 0xFF);
+ mValue[offset] = (byte) ((mantissa >> 8) & 0x0F);
+ mValue[offset] += (byte) ((exponent & 0x0F) << 4);
break;
case FORMAT_FLOAT:
mantissa = intToSignedBits(mantissa, 24);
exponent = intToSignedBits(exponent, 8);
- mValue[offset++] = (byte)(mantissa & 0xFF);
- mValue[offset++] = (byte)((mantissa >> 8) & 0xFF);
- mValue[offset++] = (byte)((mantissa >> 16) & 0xFF);
- mValue[offset] += (byte)(exponent & 0xFF);
+ mValue[offset++] = (byte) (mantissa & 0xFF);
+ mValue[offset++] = (byte) ((mantissa >> 8) & 0xFF);
+ mValue[offset++] = (byte) ((mantissa >> 16) & 0xFF);
+ mValue[offset] += (byte) (exponent & 0xFF);
break;
default:
@@ -717,7 +727,7 @@
*/
private int unsignedBytesToInt(byte b0, byte b1, byte b2, byte b3) {
return (unsignedByteToInt(b0) + (unsignedByteToInt(b1) << 8))
- + (unsignedByteToInt(b2) << 16) + (unsignedByteToInt(b3) << 24);
+ + (unsignedByteToInt(b2) << 16) + (unsignedByteToInt(b3) << 24);
}
/**
@@ -725,9 +735,9 @@
*/
private float bytesToFloat(byte b0, byte b1) {
int mantissa = unsignedToSigned(unsignedByteToInt(b0)
- + ((unsignedByteToInt(b1) & 0x0F) << 8), 12);
+ + ((unsignedByteToInt(b1) & 0x0F) << 8), 12);
int exponent = unsignedToSigned(unsignedByteToInt(b1) >> 4, 4);
- return (float)(mantissa * Math.pow(10, exponent));
+ return (float) (mantissa * Math.pow(10, exponent));
}
/**
@@ -735,9 +745,9 @@
*/
private float bytesToFloat(byte b0, byte b1, byte b2, byte b3) {
int mantissa = unsignedToSigned(unsignedByteToInt(b0)
- + (unsignedByteToInt(b1) << 8)
- + (unsignedByteToInt(b2) << 16), 24);
- return (float)(mantissa * Math.pow(10, b3));
+ + (unsignedByteToInt(b1) << 8)
+ + (unsignedByteToInt(b2) << 16), 24);
+ return (float) (mantissa * Math.pow(10, b3));
}
/**
@@ -745,8 +755,8 @@
* signed value.
*/
private int unsignedToSigned(int unsigned, int size) {
- if ((unsigned & (1 << size-1)) != 0) {
- unsigned = -1 * ((1 << size-1) - (unsigned & ((1 << size-1) - 1)));
+ if ((unsigned & (1 << size - 1)) != 0) {
+ unsigned = -1 * ((1 << size - 1) - (unsigned & ((1 << size - 1) - 1)));
}
return unsigned;
}
@@ -756,7 +766,7 @@
*/
private int intToSignedBits(int i, int size) {
if (i < 0) {
- i = (1 << size-1) + (i & ((1 << size-1) - 1));
+ i = (1 << size - 1) + (i & ((1 << size - 1) - 1));
}
return i;
}
diff --git a/framework/java/android/bluetooth/BluetoothGattDescriptor.java b/framework/java/android/bluetooth/BluetoothGattDescriptor.java
index 1a4fa48..8f6eb68 100644
--- a/framework/java/android/bluetooth/BluetoothGattDescriptor.java
+++ b/framework/java/android/bluetooth/BluetoothGattDescriptor.java
@@ -17,8 +17,9 @@
package android.bluetooth;
import android.os.Parcel;
-import android.os.Parcelable;
import android.os.ParcelUuid;
+import android.os.Parcelable;
+
import java.util.UUID;
/**
@@ -89,30 +90,35 @@
/**
* The UUID of this descriptor.
+ *
* @hide
*/
protected UUID mUuid;
/**
* Instance ID for this descriptor.
+ *
* @hide
*/
protected int mInstance;
/**
* Permissions for this descriptor
+ *
* @hide
*/
protected int mPermissions;
/**
* Back-reference to the characteristic this descriptor belongs to.
+ *
* @hide
*/
protected BluetoothGattCharacteristic mCharacteristic;
/**
* The value for this descriptor.
+ *
* @hide
*/
protected byte[] mValue;
@@ -137,7 +143,7 @@
* @param permissions Permissions for this descriptor
*/
/*package*/ BluetoothGattDescriptor(BluetoothGattCharacteristic characteristic, UUID uuid,
- int instance, int permissions) {
+ int instance, int permissions) {
initDescriptor(characteristic, uuid, instance, permissions);
}
@@ -149,7 +155,7 @@
}
private void initDescriptor(BluetoothGattCharacteristic characteristic, UUID uuid,
- int instance, int permissions) {
+ int instance, int permissions) {
mCharacteristic = characteristic;
mUuid = uuid;
mInstance = instance;
@@ -181,13 +187,14 @@
};
private BluetoothGattDescriptor(Parcel in) {
- mUuid = ((ParcelUuid)in.readParcelable(null)).getUuid();
+ mUuid = ((ParcelUuid) in.readParcelable(null)).getUuid();
mInstance = in.readInt();
mPermissions = in.readInt();
}
/**
* Returns the characteristic this descriptor belongs to.
+ *
* @return The characteristic.
*/
public BluetoothGattCharacteristic getCharacteristic() {
@@ -196,6 +203,7 @@
/**
* Set the back-reference to the associated characteristic
+ *
* @hide
*/
/*package*/ void setCharacteristic(BluetoothGattCharacteristic characteristic) {
@@ -228,6 +236,7 @@
/**
* Force the instance ID.
+ *
* @hide
*/
public void setInstanceId(int instanceId) {
@@ -266,8 +275,8 @@
* remote device.
*
* @param value New value for this descriptor
- * @return true if the locally stored value has been set, false if the
- * requested value could not be stored locally.
+ * @return true if the locally stored value has been set, false if the requested value could not
+ * be stored locally.
*/
public boolean setValue(byte[] value) {
mValue = value;
diff --git a/framework/java/android/bluetooth/BluetoothGattIncludedService.java b/framework/java/android/bluetooth/BluetoothGattIncludedService.java
index 155dc57..2a42a78 100644
--- a/framework/java/android/bluetooth/BluetoothGattIncludedService.java
+++ b/framework/java/android/bluetooth/BluetoothGattIncludedService.java
@@ -16,14 +16,14 @@
package android.bluetooth;
import android.os.Parcel;
-import android.os.Parcelable;
import android.os.ParcelUuid;
-import java.util.ArrayList;
-import java.util.List;
+import android.os.Parcelable;
+
import java.util.UUID;
/**
* Represents a Bluetooth GATT Included Service
+ *
* @hide
*/
public class BluetoothGattIncludedService implements Parcelable {
@@ -60,7 +60,7 @@
out.writeParcelable(new ParcelUuid(mUuid), 0);
out.writeInt(mInstanceId);
out.writeInt(mServiceType);
- }
+ }
public static final Parcelable.Creator<BluetoothGattIncludedService> CREATOR
= new Parcelable.Creator<BluetoothGattIncludedService>() {
@@ -74,7 +74,7 @@
};
private BluetoothGattIncludedService(Parcel in) {
- mUuid = ((ParcelUuid)in.readParcelable(null)).getUuid();
+ mUuid = ((ParcelUuid) in.readParcelable(null)).getUuid();
mInstanceId = in.readInt();
mServiceType = in.readInt();
}
diff --git a/framework/java/android/bluetooth/BluetoothGattServer.java b/framework/java/android/bluetooth/BluetoothGattServer.java
index eddc278..7b86a17 100644
--- a/framework/java/android/bluetooth/BluetoothGattServer.java
+++ b/framework/java/android/bluetooth/BluetoothGattServer.java
@@ -16,10 +16,6 @@
package android.bluetooth;
-import android.bluetooth.BluetoothAdapter;
-import android.bluetooth.BluetoothDevice;
-import android.bluetooth.BluetoothProfile;
-import android.content.Context;
import android.os.ParcelUuid;
import android.os.RemoteException;
import android.util.Log;
@@ -60,300 +56,322 @@
* Bluetooth GATT interface callbacks
*/
private final IBluetoothGattServerCallback mBluetoothGattServerCallback =
- new IBluetoothGattServerCallback.Stub() {
- /**
- * Application interface registered - app is ready to go
- * @hide
- */
- @Override
- public void onServerRegistered(int status, int serverIf) {
- if (DBG) Log.d(TAG, "onServerRegistered() - status=" + status
- + " serverIf=" + serverIf);
- synchronized(mServerIfLock) {
- if (mCallback != null) {
- mServerIf = serverIf;
- mServerIfLock.notify();
- } else {
- // registration timeout
- Log.e(TAG, "onServerRegistered: mCallback is null");
+ new IBluetoothGattServerCallback.Stub() {
+ /**
+ * Application interface registered - app is ready to go
+ * @hide
+ */
+ @Override
+ public void onServerRegistered(int status, int serverIf) {
+ if (DBG) {
+ Log.d(TAG, "onServerRegistered() - status=" + status
+ + " serverIf=" + serverIf);
}
- }
- }
-
- /**
- * Server connection state changed
- * @hide
- */
- @Override
- public void onServerConnectionState(int status, int serverIf,
- boolean connected, String address) {
- if (DBG) Log.d(TAG, "onServerConnectionState() - status=" + status
- + " serverIf=" + serverIf + " device=" + address);
- try {
- mCallback.onConnectionStateChange(mAdapter.getRemoteDevice(address), status,
- connected ? BluetoothProfile.STATE_CONNECTED :
- BluetoothProfile.STATE_DISCONNECTED);
- } catch (Exception ex) {
- Log.w(TAG, "Unhandled exception in callback", ex);
- }
- }
-
- /**
- * Service has been added
- * @hide
- */
- @Override
- public void onServiceAdded(int status, BluetoothGattService service) {
- if (DBG) Log.d(TAG, "onServiceAdded() - handle=" + service.getInstanceId()
- + " uuid=" + service.getUuid() + " status=" + status);
-
- if (mPendingService == null)
- return;
-
- BluetoothGattService tmp = mPendingService;
- mPendingService = null;
-
- // Rewrite newly assigned handles to existing service.
- tmp.setInstanceId(service.getInstanceId());
- List<BluetoothGattCharacteristic> temp_chars = tmp.getCharacteristics();
- List<BluetoothGattCharacteristic> svc_chars = service.getCharacteristics();
- for (int i=0; i<svc_chars.size(); i++) {
- BluetoothGattCharacteristic temp_char = temp_chars.get(i);
- BluetoothGattCharacteristic svc_char = svc_chars.get(i);
-
- temp_char.setInstanceId(svc_char.getInstanceId());
-
- List<BluetoothGattDescriptor> temp_descs = temp_char.getDescriptors();
- List<BluetoothGattDescriptor> svc_descs = svc_char.getDescriptors();
- for (int j=0; j<svc_descs.size(); j++) {
- temp_descs.get(j).setInstanceId(svc_descs.get(j).getInstanceId());
+ synchronized (mServerIfLock) {
+ if (mCallback != null) {
+ mServerIf = serverIf;
+ mServerIfLock.notify();
+ } else {
+ // registration timeout
+ Log.e(TAG, "onServerRegistered: mCallback is null");
+ }
}
}
- mServices.add(tmp);
-
- try {
- mCallback.onServiceAdded((int)status, tmp);
- } catch (Exception ex) {
- Log.w(TAG, "Unhandled exception in callback", ex);
- }
- }
-
- /**
- * Remote client characteristic read request.
- * @hide
- */
- @Override
- public void onCharacteristicReadRequest(String address, int transId,
- int offset, boolean isLong, int handle) {
- if (VDBG) Log.d(TAG, "onCharacteristicReadRequest() - handle=" + handle);
-
- BluetoothDevice device = mAdapter.getRemoteDevice(address);
- BluetoothGattCharacteristic characteristic = getCharacteristicByHandle(handle);
- if (characteristic == null) {
- Log.w(TAG, "onCharacteristicReadRequest() no char for handle " + handle);
- return;
+ /**
+ * Server connection state changed
+ * @hide
+ */
+ @Override
+ public void onServerConnectionState(int status, int serverIf,
+ boolean connected, String address) {
+ if (DBG) {
+ Log.d(TAG, "onServerConnectionState() - status=" + status
+ + " serverIf=" + serverIf + " device=" + address);
+ }
+ try {
+ mCallback.onConnectionStateChange(mAdapter.getRemoteDevice(address), status,
+ connected ? BluetoothProfile.STATE_CONNECTED :
+ BluetoothProfile.STATE_DISCONNECTED);
+ } catch (Exception ex) {
+ Log.w(TAG, "Unhandled exception in callback", ex);
+ }
}
- try {
- mCallback.onCharacteristicReadRequest(device, transId, offset, characteristic);
- } catch (Exception ex) {
- Log.w(TAG, "Unhandled exception in callback", ex);
- }
- }
+ /**
+ * Service has been added
+ * @hide
+ */
+ @Override
+ public void onServiceAdded(int status, BluetoothGattService service) {
+ if (DBG) {
+ Log.d(TAG, "onServiceAdded() - handle=" + service.getInstanceId()
+ + " uuid=" + service.getUuid() + " status=" + status);
+ }
- /**
- * Remote client descriptor read request.
- * @hide
- */
- @Override
- public void onDescriptorReadRequest(String address, int transId,
- int offset, boolean isLong, int handle) {
- if (VDBG) Log.d(TAG, "onCharacteristicReadRequest() - handle=" + handle);
+ if (mPendingService == null) {
+ return;
+ }
- BluetoothDevice device = mAdapter.getRemoteDevice(address);
- BluetoothGattDescriptor descriptor = getDescriptorByHandle(handle);
- if (descriptor == null) {
- Log.w(TAG, "onDescriptorReadRequest() no desc for handle " + handle);
- return;
+ BluetoothGattService tmp = mPendingService;
+ mPendingService = null;
+
+ // Rewrite newly assigned handles to existing service.
+ tmp.setInstanceId(service.getInstanceId());
+ List<BluetoothGattCharacteristic> temp_chars = tmp.getCharacteristics();
+ List<BluetoothGattCharacteristic> svc_chars = service.getCharacteristics();
+ for (int i = 0; i < svc_chars.size(); i++) {
+ BluetoothGattCharacteristic temp_char = temp_chars.get(i);
+ BluetoothGattCharacteristic svc_char = svc_chars.get(i);
+
+ temp_char.setInstanceId(svc_char.getInstanceId());
+
+ List<BluetoothGattDescriptor> temp_descs = temp_char.getDescriptors();
+ List<BluetoothGattDescriptor> svc_descs = svc_char.getDescriptors();
+ for (int j = 0; j < svc_descs.size(); j++) {
+ temp_descs.get(j).setInstanceId(svc_descs.get(j).getInstanceId());
+ }
+ }
+
+ mServices.add(tmp);
+
+ try {
+ mCallback.onServiceAdded((int) status, tmp);
+ } catch (Exception ex) {
+ Log.w(TAG, "Unhandled exception in callback", ex);
+ }
}
- try {
- mCallback.onDescriptorReadRequest(device, transId, offset, descriptor);
- } catch (Exception ex) {
- Log.w(TAG, "Unhandled exception in callback", ex);
- }
- }
+ /**
+ * Remote client characteristic read request.
+ * @hide
+ */
+ @Override
+ public void onCharacteristicReadRequest(String address, int transId,
+ int offset, boolean isLong, int handle) {
+ if (VDBG) Log.d(TAG, "onCharacteristicReadRequest() - handle=" + handle);
- /**
- * Remote client characteristic write request.
- * @hide
- */
- @Override
- public void onCharacteristicWriteRequest(String address, int transId,
- int offset, int length, boolean isPrep, boolean needRsp,
- int handle, byte[] value) {
- if (VDBG) Log.d(TAG, "onCharacteristicWriteRequest() - handle=" + handle);
+ BluetoothDevice device = mAdapter.getRemoteDevice(address);
+ BluetoothGattCharacteristic characteristic = getCharacteristicByHandle(handle);
+ if (characteristic == null) {
+ Log.w(TAG, "onCharacteristicReadRequest() no char for handle " + handle);
+ return;
+ }
- BluetoothDevice device = mAdapter.getRemoteDevice(address);
- BluetoothGattCharacteristic characteristic = getCharacteristicByHandle(handle);
- if (characteristic == null) {
- Log.w(TAG, "onCharacteristicWriteRequest() no char for handle " + handle);
- return;
+ try {
+ mCallback.onCharacteristicReadRequest(device, transId, offset,
+ characteristic);
+ } catch (Exception ex) {
+ Log.w(TAG, "Unhandled exception in callback", ex);
+ }
}
- try {
- mCallback.onCharacteristicWriteRequest(device, transId, characteristic,
- isPrep, needRsp, offset, value);
- } catch (Exception ex) {
- Log.w(TAG, "Unhandled exception in callback", ex);
+ /**
+ * Remote client descriptor read request.
+ * @hide
+ */
+ @Override
+ public void onDescriptorReadRequest(String address, int transId,
+ int offset, boolean isLong, int handle) {
+ if (VDBG) Log.d(TAG, "onCharacteristicReadRequest() - handle=" + handle);
+
+ BluetoothDevice device = mAdapter.getRemoteDevice(address);
+ BluetoothGattDescriptor descriptor = getDescriptorByHandle(handle);
+ if (descriptor == null) {
+ Log.w(TAG, "onDescriptorReadRequest() no desc for handle " + handle);
+ return;
+ }
+
+ try {
+ mCallback.onDescriptorReadRequest(device, transId, offset, descriptor);
+ } catch (Exception ex) {
+ Log.w(TAG, "Unhandled exception in callback", ex);
+ }
}
- }
+ /**
+ * Remote client characteristic write request.
+ * @hide
+ */
+ @Override
+ public void onCharacteristicWriteRequest(String address, int transId,
+ int offset, int length, boolean isPrep, boolean needRsp,
+ int handle, byte[] value) {
+ if (VDBG) Log.d(TAG, "onCharacteristicWriteRequest() - handle=" + handle);
- /**
- * Remote client descriptor write request.
- * @hide
- */
- @Override
- public void onDescriptorWriteRequest(String address, int transId, int offset,
- int length, boolean isPrep, boolean needRsp, int handle, byte[] value) {
- if (VDBG) Log.d(TAG, "onDescriptorWriteRequest() - handle=" + handle);
+ BluetoothDevice device = mAdapter.getRemoteDevice(address);
+ BluetoothGattCharacteristic characteristic = getCharacteristicByHandle(handle);
+ if (characteristic == null) {
+ Log.w(TAG, "onCharacteristicWriteRequest() no char for handle " + handle);
+ return;
+ }
- BluetoothDevice device = mAdapter.getRemoteDevice(address);
- BluetoothGattDescriptor descriptor = getDescriptorByHandle(handle);
- if (descriptor == null) {
- Log.w(TAG, "onDescriptorWriteRequest() no desc for handle " + handle);
- return;
+ try {
+ mCallback.onCharacteristicWriteRequest(device, transId, characteristic,
+ isPrep, needRsp, offset, value);
+ } catch (Exception ex) {
+ Log.w(TAG, "Unhandled exception in callback", ex);
+ }
+
}
- try {
- mCallback.onDescriptorWriteRequest(device, transId, descriptor,
- isPrep, needRsp, offset, value);
- } catch (Exception ex) {
- Log.w(TAG, "Unhandled exception in callback", ex);
+ /**
+ * Remote client descriptor write request.
+ * @hide
+ */
+ @Override
+ public void onDescriptorWriteRequest(String address, int transId, int offset,
+ int length, boolean isPrep, boolean needRsp, int handle, byte[] value) {
+ if (VDBG) Log.d(TAG, "onDescriptorWriteRequest() - handle=" + handle);
+
+ BluetoothDevice device = mAdapter.getRemoteDevice(address);
+ BluetoothGattDescriptor descriptor = getDescriptorByHandle(handle);
+ if (descriptor == null) {
+ Log.w(TAG, "onDescriptorWriteRequest() no desc for handle " + handle);
+ return;
+ }
+
+ try {
+ mCallback.onDescriptorWriteRequest(device, transId, descriptor,
+ isPrep, needRsp, offset, value);
+ } catch (Exception ex) {
+ Log.w(TAG, "Unhandled exception in callback", ex);
+ }
}
- }
- /**
- * Execute pending writes.
- * @hide
- */
- @Override
- public void onExecuteWrite(String address, int transId,
- boolean execWrite) {
- if (DBG) Log.d(TAG, "onExecuteWrite() - "
- + "device=" + address + ", transId=" + transId
- + "execWrite=" + execWrite);
+ /**
+ * Execute pending writes.
+ * @hide
+ */
+ @Override
+ public void onExecuteWrite(String address, int transId,
+ boolean execWrite) {
+ if (DBG) {
+ Log.d(TAG, "onExecuteWrite() - "
+ + "device=" + address + ", transId=" + transId
+ + "execWrite=" + execWrite);
+ }
- BluetoothDevice device = mAdapter.getRemoteDevice(address);
- if (device == null) return;
+ BluetoothDevice device = mAdapter.getRemoteDevice(address);
+ if (device == null) return;
- try {
- mCallback.onExecuteWrite(device, transId, execWrite);
- } catch (Exception ex) {
- Log.w(TAG, "Unhandled exception in callback", ex);
+ try {
+ mCallback.onExecuteWrite(device, transId, execWrite);
+ } catch (Exception ex) {
+ Log.w(TAG, "Unhandled exception in callback", ex);
+ }
}
- }
- /**
- * A notification/indication has been sent.
- * @hide
- */
- @Override
- public void onNotificationSent(String address, int status) {
- if (VDBG) Log.d(TAG, "onNotificationSent() - "
- + "device=" + address + ", status=" + status);
+ /**
+ * A notification/indication has been sent.
+ * @hide
+ */
+ @Override
+ public void onNotificationSent(String address, int status) {
+ if (VDBG) {
+ Log.d(TAG, "onNotificationSent() - "
+ + "device=" + address + ", status=" + status);
+ }
- BluetoothDevice device = mAdapter.getRemoteDevice(address);
- if (device == null) return;
+ BluetoothDevice device = mAdapter.getRemoteDevice(address);
+ if (device == null) return;
- try {
- mCallback.onNotificationSent(device, status);
- } catch (Exception ex) {
- Log.w(TAG, "Unhandled exception: " + ex);
+ try {
+ mCallback.onNotificationSent(device, status);
+ } catch (Exception ex) {
+ Log.w(TAG, "Unhandled exception: " + ex);
+ }
}
- }
- /**
- * The MTU for a connection has changed
- * @hide
- */
- @Override
- public void onMtuChanged(String address, int mtu) {
- if (DBG) Log.d(TAG, "onMtuChanged() - "
- + "device=" + address + ", mtu=" + mtu);
+ /**
+ * The MTU for a connection has changed
+ * @hide
+ */
+ @Override
+ public void onMtuChanged(String address, int mtu) {
+ if (DBG) {
+ Log.d(TAG, "onMtuChanged() - "
+ + "device=" + address + ", mtu=" + mtu);
+ }
- BluetoothDevice device = mAdapter.getRemoteDevice(address);
- if (device == null) return;
+ BluetoothDevice device = mAdapter.getRemoteDevice(address);
+ if (device == null) return;
- try {
- mCallback.onMtuChanged(device, mtu);
- } catch (Exception ex) {
- Log.w(TAG, "Unhandled exception: " + ex);
+ try {
+ mCallback.onMtuChanged(device, mtu);
+ } catch (Exception ex) {
+ Log.w(TAG, "Unhandled exception: " + ex);
+ }
}
- }
- /**
- * The PHY for a connection was updated
- * @hide
- */
- @Override
- public void onPhyUpdate(String address, int txPhy, int rxPhy, int status) {
- if (DBG) Log.d(TAG, "onPhyUpdate() - " + "device=" + address + ", txPHy=" + txPhy
- + ", rxPHy=" + rxPhy);
+ /**
+ * The PHY for a connection was updated
+ * @hide
+ */
+ @Override
+ public void onPhyUpdate(String address, int txPhy, int rxPhy, int status) {
+ if (DBG) {
+ Log.d(TAG,
+ "onPhyUpdate() - " + "device=" + address + ", txPHy=" + txPhy
+ + ", rxPHy=" + rxPhy);
+ }
- BluetoothDevice device = mAdapter.getRemoteDevice(address);
- if (device == null) return;
+ BluetoothDevice device = mAdapter.getRemoteDevice(address);
+ if (device == null) return;
- try {
- mCallback.onPhyUpdate(device, txPhy, rxPhy, status);
- } catch (Exception ex) {
- Log.w(TAG, "Unhandled exception: " + ex);
+ try {
+ mCallback.onPhyUpdate(device, txPhy, rxPhy, status);
+ } catch (Exception ex) {
+ Log.w(TAG, "Unhandled exception: " + ex);
+ }
}
- }
- /**
- * The PHY for a connection was read
- * @hide
- */
- @Override
- public void onPhyRead(String address, int txPhy, int rxPhy, int status) {
- if (DBG) Log.d(TAG, "onPhyUpdate() - " + "device=" + address + ", txPHy=" + txPhy
- + ", rxPHy=" + rxPhy);
+ /**
+ * The PHY for a connection was read
+ * @hide
+ */
+ @Override
+ public void onPhyRead(String address, int txPhy, int rxPhy, int status) {
+ if (DBG) {
+ Log.d(TAG,
+ "onPhyUpdate() - " + "device=" + address + ", txPHy=" + txPhy
+ + ", rxPHy=" + rxPhy);
+ }
- BluetoothDevice device = mAdapter.getRemoteDevice(address);
- if (device == null) return;
+ BluetoothDevice device = mAdapter.getRemoteDevice(address);
+ if (device == null) return;
- try {
- mCallback.onPhyRead(device, txPhy, rxPhy, status);
- } catch (Exception ex) {
- Log.w(TAG, "Unhandled exception: " + ex);
+ try {
+ mCallback.onPhyRead(device, txPhy, rxPhy, status);
+ } catch (Exception ex) {
+ Log.w(TAG, "Unhandled exception: " + ex);
+ }
}
- }
- /**
- * Callback invoked when the given connection is updated
- * @hide
- */
- @Override
- public void onConnectionUpdated(String address, int interval, int latency,
- int timeout, int status) {
- if (DBG) Log.d(TAG, "onConnectionUpdated() - Device=" + address +
- " interval=" + interval + " latency=" + latency +
- " timeout=" + timeout + " status=" + status);
- BluetoothDevice device = mAdapter.getRemoteDevice(address);
- if (device == null) return;
+ /**
+ * Callback invoked when the given connection is updated
+ * @hide
+ */
+ @Override
+ public void onConnectionUpdated(String address, int interval, int latency,
+ int timeout, int status) {
+ if (DBG) {
+ Log.d(TAG, "onConnectionUpdated() - Device=" + address +
+ " interval=" + interval + " latency=" + latency +
+ " timeout=" + timeout + " status=" + status);
+ }
+ BluetoothDevice device = mAdapter.getRemoteDevice(address);
+ if (device == null) return;
- try {
- mCallback.onConnectionUpdated(device, interval, latency,
- timeout, status);
- } catch (Exception ex) {
- Log.w(TAG, "Unhandled exception: " + ex);
+ try {
+ mCallback.onConnectionUpdated(device, interval, latency,
+ timeout, status);
+ } catch (Exception ex) {
+ Log.w(TAG, "Unhandled exception: " + ex);
+ }
}
- }
- };
+ };
/**
* Create a BluetoothGattServer proxy object.
@@ -369,13 +387,15 @@
/**
* Returns a characteristic with given handle.
+ *
* @hide
*/
/*package*/ BluetoothGattCharacteristic getCharacteristicByHandle(int handle) {
- for(BluetoothGattService svc : mServices) {
- for(BluetoothGattCharacteristic charac : svc.getCharacteristics()) {
- if (charac.getInstanceId() == handle)
+ for (BluetoothGattService svc : mServices) {
+ for (BluetoothGattCharacteristic charac : svc.getCharacteristics()) {
+ if (charac.getInstanceId() == handle) {
return charac;
+ }
}
}
return null;
@@ -383,14 +403,16 @@
/**
* Returns a descriptor with given handle.
+ *
* @hide
*/
/*package*/ BluetoothGattDescriptor getDescriptorByHandle(int handle) {
- for(BluetoothGattService svc : mServices) {
- for(BluetoothGattCharacteristic charac : svc.getCharacteristics()) {
- for(BluetoothGattDescriptor desc : charac.getDescriptors()) {
- if (desc.getInstanceId() == handle)
+ for (BluetoothGattService svc : mServices) {
+ for (BluetoothGattCharacteristic charac : svc.getCharacteristics()) {
+ for (BluetoothGattDescriptor desc : charac.getDescriptors()) {
+ if (desc.getInstanceId() == handle) {
return desc;
+ }
}
}
}
@@ -416,10 +438,9 @@
*
* <p>Requires {@link android.Manifest.permission#BLUETOOTH} permission.
*
- * @param callback GATT callback handler that will receive asynchronous
- * callbacks.
- * @return true, the callback will be called to notify success or failure,
- * false on immediate error
+ * @param callback GATT callback handler that will receive asynchronous callbacks.
+ * @return true, the callback will be called to notify success or failure, false on immediate
+ * error
*/
/*package*/ boolean registerCallback(BluetoothGattServerCallback callback) {
if (DBG) Log.d(TAG, "registerCallback()");
@@ -430,7 +451,7 @@
UUID uuid = UUID.randomUUID();
if (DBG) Log.d(TAG, "registerCallback() - UUID=" + uuid);
- synchronized(mServerIfLock) {
+ synchronized (mServerIfLock) {
if (mCallback != null) {
Log.e(TAG, "App can register callback only once");
return false;
@@ -440,7 +461,7 @@
try {
mService.registerServer(new ParcelUuid(uuid), mBluetoothGattServerCallback);
} catch (RemoteException e) {
- Log.e(TAG,"",e);
+ Log.e(TAG, "", e);
mCallback = null;
return false;
}
@@ -473,19 +494,20 @@
mService.unregisterServer(mServerIf);
mServerIf = 0;
} catch (RemoteException e) {
- Log.e(TAG,"",e);
+ Log.e(TAG, "", e);
}
}
/**
* Returns a service by UUID, instance and type.
+ *
* @hide
*/
/*package*/ BluetoothGattService getService(UUID uuid, int instanceId, int type) {
- for(BluetoothGattService svc : mServices) {
+ for (BluetoothGattService svc : mServices) {
if (svc.getType() == type &&
- svc.getInstanceId() == instanceId &&
- svc.getUuid().equals(uuid)) {
+ svc.getInstanceId() == instanceId &&
+ svc.getUuid().equals(uuid)) {
return svc;
}
}
@@ -509,20 +531,22 @@
*
* <p>Requires {@link android.Manifest.permission#BLUETOOTH} permission.
*
- * @param autoConnect Whether to directly connect to the remote device (false)
- * or to automatically connect as soon as the remote
- * device becomes available (true).
+ * @param autoConnect Whether to directly connect to the remote device (false) or to
+ * automatically connect as soon as the remote device becomes available (true).
* @return true, if the connection attempt was initiated successfully
*/
public boolean connect(BluetoothDevice device, boolean autoConnect) {
- if (DBG) Log.d(TAG, "connect() - device: " + device.getAddress() + ", auto: " + autoConnect);
+ if (DBG) {
+ Log.d(TAG,
+ "connect() - device: " + device.getAddress() + ", auto: " + autoConnect);
+ }
if (mService == null || mServerIf == 0) return false;
try {
mService.serverConnect(mServerIf, device.getAddress(),
- autoConnect ? false : true,mTransport); // autoConnect is inverse of "isDirect"
+ autoConnect ? false : true, mTransport); // autoConnect is inverse of "isDirect"
} catch (RemoteException e) {
- Log.e(TAG,"",e);
+ Log.e(TAG, "", e);
return false;
}
@@ -544,35 +568,34 @@
try {
mService.serverDisconnect(mServerIf, device.getAddress());
} catch (RemoteException e) {
- Log.e(TAG,"",e);
+ Log.e(TAG, "", e);
}
}
/**
* Set the preferred connection PHY for this app. Please note that this is just a
* recommendation, whether the PHY change will happen depends on other applications peferences,
- * local and remote controller capabilities. Controller can override these settings.
- * <p>
- * {@link BluetoothGattServerCallback#onPhyUpdate} will be triggered as a result of this call, even
- * if no PHY change happens. It is also triggered when remote device updates the PHY.
+ * local and remote controller capabilities. Controller can override these settings. <p> {@link
+ * BluetoothGattServerCallback#onPhyUpdate} will be triggered as a result of this call, even if
+ * no PHY change happens. It is also triggered when remote device updates the PHY.
*
* @param device The remote device to send this response to
- * @param txPhy preferred transmitter PHY. Bitwise OR of any of
- * {@link BluetoothDevice#PHY_LE_1M_MASK}, {@link BluetoothDevice#PHY_LE_2M_MASK},
- * and {@link BluetoothDevice#PHY_LE_CODED_MASK}.
- * @param rxPhy preferred receiver PHY. Bitwise OR of any of
- * {@link BluetoothDevice#PHY_LE_1M_MASK}, {@link BluetoothDevice#PHY_LE_2M_MASK},
- * and {@link BluetoothDevice#PHY_LE_CODED_MASK}.
+ * @param txPhy preferred transmitter PHY. Bitwise OR of any of {@link
+ * BluetoothDevice#PHY_LE_1M_MASK}, {@link BluetoothDevice#PHY_LE_2M_MASK}, and {@link
+ * BluetoothDevice#PHY_LE_CODED_MASK}.
+ * @param rxPhy preferred receiver PHY. Bitwise OR of any of {@link
+ * BluetoothDevice#PHY_LE_1M_MASK}, {@link BluetoothDevice#PHY_LE_2M_MASK}, and {@link
+ * BluetoothDevice#PHY_LE_CODED_MASK}.
* @param phyOptions preferred coding to use when transmitting on the LE Coded PHY. Can be one
- * of {@link BluetoothDevice#PHY_OPTION_NO_PREFERRED},
- * {@link BluetoothDevice#PHY_OPTION_S2} or {@link BluetoothDevice#PHY_OPTION_S8}
+ * of {@link BluetoothDevice#PHY_OPTION_NO_PREFERRED}, {@link BluetoothDevice#PHY_OPTION_S2} or
+ * {@link BluetoothDevice#PHY_OPTION_S8}
*/
public void setPreferredPhy(BluetoothDevice device, int txPhy, int rxPhy, int phyOptions) {
try {
mService.serverSetPreferredPhy(mServerIf, device.getAddress(), txPhy, rxPhy,
- phyOptions);
+ phyOptions);
} catch (RemoteException e) {
- Log.e(TAG,"",e);
+ Log.e(TAG, "", e);
}
}
@@ -586,7 +609,7 @@
try {
mService.serverReadPhy(mServerIf, device.getAddress());
} catch (RemoteException e) {
- Log.e(TAG,"",e);
+ Log.e(TAG, "", e);
}
}
@@ -597,10 +620,10 @@
* is received by one of these callback methods:
*
* <ul>
- * <li>{@link BluetoothGattServerCallback#onCharacteristicReadRequest}
- * <li>{@link BluetoothGattServerCallback#onCharacteristicWriteRequest}
- * <li>{@link BluetoothGattServerCallback#onDescriptorReadRequest}
- * <li>{@link BluetoothGattServerCallback#onDescriptorWriteRequest}
+ * <li>{@link BluetoothGattServerCallback#onCharacteristicReadRequest}
+ * <li>{@link BluetoothGattServerCallback#onCharacteristicWriteRequest}
+ * <li>{@link BluetoothGattServerCallback#onDescriptorReadRequest}
+ * <li>{@link BluetoothGattServerCallback#onDescriptorWriteRequest}
* </ul>
*
* <p>Requires {@link android.Manifest.permission#BLUETOOTH} permission.
@@ -612,15 +635,15 @@
* @param value The value of the attribute that was read/written (optional)
*/
public boolean sendResponse(BluetoothDevice device, int requestId,
- int status, int offset, byte[] value) {
+ int status, int offset, byte[] value) {
if (VDBG) Log.d(TAG, "sendResponse() - device: " + device.getAddress());
if (mService == null || mServerIf == 0) return false;
try {
mService.sendResponse(mServerIf, device.getAddress(), requestId,
- status, offset, value);
+ status, offset, value);
} catch (RemoteException e) {
- Log.e(TAG,"",e);
+ Log.e(TAG, "", e);
return false;
}
return true;
@@ -639,13 +662,13 @@
*
* @param device The remote device to receive the notification/indication
* @param characteristic The local characteristic that has been updated
- * @param confirm true to request confirmation from the client (indication),
- * false to send a notification
- * @throws IllegalArgumentException
+ * @param confirm true to request confirmation from the client (indication), false to send a
+ * notification
* @return true, if the notification has been triggered successfully
+ * @throws IllegalArgumentException
*/
public boolean notifyCharacteristicChanged(BluetoothDevice device,
- BluetoothGattCharacteristic characteristic, boolean confirm) {
+ BluetoothGattCharacteristic characteristic, boolean confirm) {
if (VDBG) Log.d(TAG, "notifyCharacteristicChanged() - device: " + device.getAddress());
if (mService == null || mServerIf == 0) return false;
@@ -662,7 +685,7 @@
characteristic.getInstanceId(), confirm,
characteristic.getValue());
} catch (RemoteException e) {
- Log.e(TAG,"",e);
+ Log.e(TAG, "", e);
return false;
}
@@ -680,8 +703,7 @@
*
* <p>Requires {@link android.Manifest.permission#BLUETOOTH} permission.
*
- * @param service Service to be added to the list of services provided
- * by this device.
+ * @param service Service to be added to the list of services provided by this device.
* @return true, if the service has been added successfully
*/
public boolean addService(BluetoothGattService service) {
@@ -693,7 +715,7 @@
try {
mService.addService(mServerIf, service);
} catch (RemoteException e) {
- Log.e(TAG,"",e);
+ Log.e(TAG, "", e);
return false;
}
@@ -713,14 +735,14 @@
if (mService == null || mServerIf == 0) return false;
BluetoothGattService intService = getService(service.getUuid(),
- service.getInstanceId(), service.getType());
+ service.getInstanceId(), service.getType());
if (intService == null) return false;
try {
mService.removeService(mServerIf, service.getInstanceId());
mServices.remove(intService);
} catch (RemoteException e) {
- Log.e(TAG,"",e);
+ Log.e(TAG, "", e);
return false;
}
@@ -739,7 +761,7 @@
mService.clearServices(mServerIf);
mServices.clear();
} catch (RemoteException e) {
- Log.e(TAG,"",e);
+ Log.e(TAG, "", e);
}
}
@@ -751,8 +773,7 @@
*
* <p>Requires {@link android.Manifest.permission#BLUETOOTH} permission.
*
- * @return List of services. Returns an empty list
- * if no services have been added yet.
+ * @return List of services. Returns an empty list if no services have been added yet.
*/
public List<BluetoothGattService> getServices() {
return mServices;
@@ -768,8 +789,8 @@
* <p>Requires {@link android.Manifest.permission#BLUETOOTH} permission.
*
* @param uuid UUID of the requested service
- * @return BluetoothGattService if supported, or null if the requested
- * service is not offered by this device.
+ * @return BluetoothGattService if supported, or null if the requested service is not offered by
+ * this device.
*/
public BluetoothGattService getService(UUID uuid) {
for (BluetoothGattService service : mServices) {
@@ -802,7 +823,7 @@
@Override
public List<BluetoothDevice> getConnectedDevices() {
throw new UnsupportedOperationException
- ("Use BluetoothManager#getConnectedDevices instead.");
+ ("Use BluetoothManager#getConnectedDevices instead.");
}
/**
@@ -815,6 +836,6 @@
@Override
public List<BluetoothDevice> getDevicesMatchingConnectionStates(int[] states) {
throw new UnsupportedOperationException
- ("Use BluetoothManager#getDevicesMatchingConnectionStates instead.");
+ ("Use BluetoothManager#getDevicesMatchingConnectionStates instead.");
}
}
diff --git a/framework/java/android/bluetooth/BluetoothGattServerCallback.java b/framework/java/android/bluetooth/BluetoothGattServerCallback.java
index 02307bd..e72577d 100644
--- a/framework/java/android/bluetooth/BluetoothGattServerCallback.java
+++ b/framework/java/android/bluetooth/BluetoothGattServerCallback.java
@@ -16,8 +16,6 @@
package android.bluetooth;
-import android.bluetooth.BluetoothDevice;
-
/**
* This abstract class is used to implement {@link BluetoothGattServer} callbacks.
*/
@@ -28,19 +26,18 @@
*
* @param device Remote device that has been connected or disconnected.
* @param status Status of the connect or disconnect operation.
- * @param newState Returns the new connection state. Can be one of
- * {@link BluetoothProfile#STATE_DISCONNECTED} or
- * {@link BluetoothProfile#STATE_CONNECTED}
+ * @param newState Returns the new connection state. Can be one of {@link
+ * BluetoothProfile#STATE_DISCONNECTED} or {@link BluetoothProfile#STATE_CONNECTED}
*/
public void onConnectionStateChange(BluetoothDevice device, int status,
- int newState) {
+ int newState) {
}
/**
* Indicates whether a local service has been added successfully.
*
- * @param status Returns {@link BluetoothGatt#GATT_SUCCESS} if the service
- * was added successfully.
+ * @param status Returns {@link BluetoothGatt#GATT_SUCCESS} if the service was added
+ * successfully.
* @param service The service that has been added
*/
public void onServiceAdded(int status, BluetoothGattService service) {
@@ -58,7 +55,7 @@
* @param characteristic Characteristic to be read
*/
public void onCharacteristicReadRequest(BluetoothDevice device, int requestId,
- int offset, BluetoothGattCharacteristic characteristic) {
+ int offset, BluetoothGattCharacteristic characteristic) {
}
/**
@@ -70,16 +67,15 @@
* @param device The remote device that has requested the write operation
* @param requestId The Id of the request
* @param characteristic Characteristic to be written to.
- * @param preparedWrite true, if this write operation should be queued for
- * later execution.
+ * @param preparedWrite true, if this write operation should be queued for later execution.
* @param responseNeeded true, if the remote device requires a response
* @param offset The offset given for the value
* @param value The value the client wants to assign to the characteristic
*/
public void onCharacteristicWriteRequest(BluetoothDevice device, int requestId,
- BluetoothGattCharacteristic characteristic,
- boolean preparedWrite, boolean responseNeeded,
- int offset, byte[] value) {
+ BluetoothGattCharacteristic characteristic,
+ boolean preparedWrite, boolean responseNeeded,
+ int offset, byte[] value) {
}
/**
@@ -94,7 +90,7 @@
* @param descriptor Descriptor to be read
*/
public void onDescriptorReadRequest(BluetoothDevice device, int requestId,
- int offset, BluetoothGattDescriptor descriptor) {
+ int offset, BluetoothGattDescriptor descriptor) {
}
/**
@@ -106,16 +102,15 @@
* @param device The remote device that has requested the write operation
* @param requestId The Id of the request
* @param descriptor Descriptor to be written to.
- * @param preparedWrite true, if this write operation should be queued for
- * later execution.
+ * @param preparedWrite true, if this write operation should be queued for later execution.
* @param responseNeeded true, if the remote device requires a response
* @param offset The offset given for the value
* @param value The value the client wants to assign to the descriptor
*/
public void onDescriptorWriteRequest(BluetoothDevice device, int requestId,
- BluetoothGattDescriptor descriptor,
- boolean preparedWrite, boolean responseNeeded,
- int offset, byte[] value) {
+ BluetoothGattDescriptor descriptor,
+ boolean preparedWrite, boolean responseNeeded,
+ int offset, byte[] value) {
}
/**
@@ -126,8 +121,7 @@
*
* @param device The remote device that has requested the write operations
* @param requestId The Id of the request
- * @param execute Whether the pending writes should be executed (true) or
- * cancelled (false)
+ * @param execute Whether the pending writes should be executed (true) or cancelled (false)
*/
public void onExecuteWrite(BluetoothDevice device, int requestId, boolean execute) {
}
@@ -163,12 +157,12 @@
* of remote device changing the PHY.
*
* @param device The remote device
- * @param txPhy the transmitter PHY in use. One of {@link BluetoothDevice#PHY_LE_1M},
- * {@link BluetoothDevice#PHY_LE_2M}, and {@link BluetoothDevice#PHY_LE_CODED}
- * @param rxPhy the receiver PHY in use. One of {@link BluetoothDevice#PHY_LE_1M},
- * {@link BluetoothDevice#PHY_LE_2M}, and {@link BluetoothDevice#PHY_LE_CODED}
- * @param status Status of the PHY update operation.
- * {@link BluetoothGatt#GATT_SUCCESS} if the operation succeeds.
+ * @param txPhy the transmitter PHY in use. One of {@link BluetoothDevice#PHY_LE_1M}, {@link
+ * BluetoothDevice#PHY_LE_2M}, and {@link BluetoothDevice#PHY_LE_CODED}
+ * @param rxPhy the receiver PHY in use. One of {@link BluetoothDevice#PHY_LE_1M}, {@link
+ * BluetoothDevice#PHY_LE_2M}, and {@link BluetoothDevice#PHY_LE_CODED}
+ * @param status Status of the PHY update operation. {@link BluetoothGatt#GATT_SUCCESS} if the
+ * operation succeeds.
*/
public void onPhyUpdate(BluetoothDevice device, int txPhy, int rxPhy, int status) {
}
@@ -177,12 +171,12 @@
* Callback triggered as result of {@link BluetoothGattServer#readPhy}
*
* @param device The remote device that requested the PHY read
- * @param txPhy the transmitter PHY in use. One of {@link BluetoothDevice#PHY_LE_1M},
- * {@link BluetoothDevice#PHY_LE_2M}, and {@link BluetoothDevice#PHY_LE_CODED}
- * @param rxPhy the receiver PHY in use. One of {@link BluetoothDevice#PHY_LE_1M},
- * {@link BluetoothDevice#PHY_LE_2M}, and {@link BluetoothDevice#PHY_LE_CODED}
- * @param status Status of the PHY read operation.
- * {@link BluetoothGatt#GATT_SUCCESS} if the operation succeeds.
+ * @param txPhy the transmitter PHY in use. One of {@link BluetoothDevice#PHY_LE_1M}, {@link
+ * BluetoothDevice#PHY_LE_2M}, and {@link BluetoothDevice#PHY_LE_CODED}
+ * @param rxPhy the receiver PHY in use. One of {@link BluetoothDevice#PHY_LE_1M}, {@link
+ * BluetoothDevice#PHY_LE_2M}, and {@link BluetoothDevice#PHY_LE_CODED}
+ * @param status Status of the PHY read operation. {@link BluetoothGatt#GATT_SUCCESS} if the
+ * operation succeeds.
*/
public void onPhyRead(BluetoothDevice device, int txPhy, int rxPhy, int status) {
}
@@ -191,18 +185,18 @@
* Callback indicating the connection parameters were updated.
*
* @param device The remote device involved
- * @param interval Connection interval used on this connection, 1.25ms unit. Valid
- * range is from 6 (7.5ms) to 3200 (4000ms).
- * @param latency Slave latency for the connection in number of connection events. Valid
- * range is from 0 to 499
- * @param timeout Supervision timeout for this connection, in 10ms unit. Valid range is
- * from 10 (0.1s) to 3200 (32s)
+ * @param interval Connection interval used on this connection, 1.25ms unit. Valid range is from
+ * 6 (7.5ms) to 3200 (4000ms).
+ * @param latency Slave latency for the connection in number of connection events. Valid range
+ * is from 0 to 499
+ * @param timeout Supervision timeout for this connection, in 10ms unit. Valid range is from 10
+ * (0.1s) to 3200 (32s)
* @param status {@link BluetoothGatt#GATT_SUCCESS} if the connection has been updated
- * successfully
+ * successfully
* @hide
*/
public void onConnectionUpdated(BluetoothDevice gatt, int interval, int latency, int timeout,
- int status) {
+ int status) {
}
}
diff --git a/framework/java/android/bluetooth/BluetoothGattService.java b/framework/java/android/bluetooth/BluetoothGattService.java
index c888a451..db820d8 100644
--- a/framework/java/android/bluetooth/BluetoothGattService.java
+++ b/framework/java/android/bluetooth/BluetoothGattService.java
@@ -16,8 +16,9 @@
package android.bluetooth;
import android.os.Parcel;
-import android.os.Parcelable;
import android.os.ParcelUuid;
+import android.os.Parcelable;
+
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
@@ -44,30 +45,35 @@
/**
* The remote device his service is associated with.
* This applies to client applications only.
+ *
* @hide
*/
protected BluetoothDevice mDevice;
/**
* The UUID of this service.
+ *
* @hide
*/
protected UUID mUuid;
/**
* Instance ID for this service.
+ *
* @hide
*/
protected int mInstanceId;
/**
* Handle counter override (for conformance testing).
+ *
* @hide
*/
protected int mHandles = 0;
/**
* Service type (Primary/Secondary).
+ *
* @hide
*/
protected int mServiceType;
@@ -93,8 +99,8 @@
*
* @param uuid The UUID for this service
* @param serviceType The type of this service,
- * {@link BluetoothGattService#SERVICE_TYPE_PRIMARY} or
- * {@link BluetoothGattService#SERVICE_TYPE_SECONDARY}
+ * {@link BluetoothGattService#SERVICE_TYPE_PRIMARY}
+ * or {@link BluetoothGattService#SERVICE_TYPE_SECONDARY}
*/
public BluetoothGattService(UUID uuid, int serviceType) {
mDevice = null;
@@ -107,10 +113,11 @@
/**
* Create a new BluetoothGattService
+ *
* @hide
*/
/*package*/ BluetoothGattService(BluetoothDevice device, UUID uuid,
- int instanceId, int serviceType) {
+ int instanceId, int serviceType) {
mDevice = device;
mUuid = uuid;
mInstanceId = instanceId;
@@ -121,6 +128,7 @@
/**
* Create a new BluetoothGattService
+ *
* @hide
*/
public BluetoothGattService(UUID uuid, int instanceId, int serviceType) {
@@ -148,12 +156,12 @@
ArrayList<BluetoothGattIncludedService> includedServices =
new ArrayList<BluetoothGattIncludedService>(mIncludedServices.size());
- for(BluetoothGattService s : mIncludedServices) {
+ for (BluetoothGattService s : mIncludedServices) {
includedServices.add(new BluetoothGattIncludedService(s.getUuid(),
- s.getInstanceId(), s.getType()));
+ s.getInstanceId(), s.getType()));
}
out.writeTypedList(includedServices);
- }
+ }
public static final Parcelable.Creator<BluetoothGattService> CREATOR
= new Parcelable.Creator<BluetoothGattService>() {
@@ -167,7 +175,7 @@
};
private BluetoothGattService(Parcel in) {
- mUuid = ((ParcelUuid)in.readParcelable(null)).getUuid();
+ mUuid = ((ParcelUuid) in.readParcelable(null)).getUuid();
mInstanceId = in.readInt();
mServiceType = in.readInt();
@@ -189,13 +197,14 @@
if (chrcs != null) {
for (BluetoothGattIncludedService isvc : inclSvcs) {
mIncludedServices.add(new BluetoothGattService(null, isvc.getUuid(),
- isvc.getInstanceId(), isvc.getType()));
+ isvc.getInstanceId(), isvc.getType()));
}
}
}
/**
* Returns the device associated with this service.
+ *
* @hide
*/
/*package*/ BluetoothDevice getDevice() {
@@ -204,6 +213,7 @@
/**
* Returns the device associated with this service.
+ *
* @hide
*/
/*package*/ void setDevice(BluetoothDevice device) {
@@ -237,19 +247,22 @@
/**
* Get characteristic by UUID and instanceId.
+ *
* @hide
*/
/*package*/ BluetoothGattCharacteristic getCharacteristic(UUID uuid, int instanceId) {
- for(BluetoothGattCharacteristic characteristic : mCharacteristics) {
+ for (BluetoothGattCharacteristic characteristic : mCharacteristics) {
if (uuid.equals(characteristic.getUuid())
- && characteristic.getInstanceId() == instanceId)
+ && characteristic.getInstanceId() == instanceId) {
return characteristic;
+ }
}
return null;
}
/**
* Force the instance ID.
+ *
* @hide
*/
public void setInstanceId(int instanceId) {
@@ -258,6 +271,7 @@
/**
* Get the handle count override (conformance testing.
+ *
* @hide
*/
/*package*/ int getHandles() {
@@ -267,6 +281,7 @@
/**
* Force the number of handles to reserve for this service.
* This is needed for conformance testing only.
+ *
* @hide
*/
public void setHandles(int handles) {
@@ -275,6 +290,7 @@
/**
* Add an included service to the internal map.
+ *
* @hide
*/
public void addIncludedService(BluetoothGattService includedService) {
@@ -313,8 +329,7 @@
/**
* Get the list of included GATT services for this service.
*
- * @return List of included services or empty list if no included services
- * were discovered.
+ * @return List of included services or empty list if no included services were discovered.
*/
public List<BluetoothGattService> getIncludedServices() {
return mIncludedServices;
@@ -341,30 +356,33 @@
* UUID, the first instance of a characteristic with the given UUID
* is returned.
*
- * @return GATT characteristic object or null if no characteristic with the
- * given UUID was found.
+ * @return GATT characteristic object or null if no characteristic with the given UUID was
+ * found.
*/
public BluetoothGattCharacteristic getCharacteristic(UUID uuid) {
- for(BluetoothGattCharacteristic characteristic : mCharacteristics) {
- if (uuid.equals(characteristic.getUuid()))
+ for (BluetoothGattCharacteristic characteristic : mCharacteristics) {
+ if (uuid.equals(characteristic.getUuid())) {
return characteristic;
+ }
}
return null;
}
/**
* Returns whether the uuid of the service should be advertised.
+ *
* @hide
*/
public boolean isAdvertisePreferred() {
- return mAdvertisePreferred;
+ return mAdvertisePreferred;
}
/**
* Set whether the service uuid should be advertised.
+ *
* @hide
*/
public void setAdvertisePreferred(boolean advertisePreferred) {
- this.mAdvertisePreferred = advertisePreferred;
+ this.mAdvertisePreferred = advertisePreferred;
}
}
diff --git a/framework/java/android/bluetooth/BluetoothHeadset.java b/framework/java/android/bluetooth/BluetoothHeadset.java
index c84643f..132f383 100644
--- a/framework/java/android/bluetooth/BluetoothHeadset.java
+++ b/framework/java/android/bluetooth/BluetoothHeadset.java
@@ -56,9 +56,9 @@
*
* <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 @@
*/
@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 @@
*
* <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 @@
*/
@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 @@
*
* <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 @@
*
* <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 @@
* 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 @@
/**
* 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 @@
/**
* 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 @@
*
* <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 @@
* 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 @@
/**
* 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 =
@@ -306,22 +314,22 @@
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 @@
try {
mgr.registerStateChangeCallback(mBluetoothStateChangeCallback);
} catch (RemoteException e) {
- Log.e(TAG,"",e);
+ Log.e(TAG, "", e);
}
}
@@ -360,7 +368,7 @@
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 @@
try {
mgr.unregisterStateChangeCallback(mBluetoothStateChangeCallback);
} catch (Exception e) {
- Log.e(TAG,"",e);
+ Log.e(TAG, "", e);
}
}
mServiceListener = null;
@@ -405,14 +413,13 @@
* 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)) {
+ isValidDevice(device)) {
try {
return mService.connect(device);
} catch (RemoteException e) {
@@ -446,19 +453,18 @@
* 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)) {
+ 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");
@@ -505,7 +511,7 @@
public int getConnectionState(BluetoothDevice device) {
if (VDBG) log("getConnectionState(" + device + ")");
if (mService != null && isEnabled() &&
- isValidDevice(device)) {
+ isValidDevice(device)) {
try {
return mService.getConnectionState(device);
} catch (RemoteException e) {
@@ -521,7 +527,7 @@
* 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}
@@ -535,10 +541,10 @@
public boolean setPriority(BluetoothDevice device, int priority) {
if (DBG) log("setPriority(" + device + ", " + priority + ")");
if (mService != null && isEnabled() &&
- isValidDevice(device)) {
+ isValidDevice(device)) {
if (priority != BluetoothProfile.PRIORITY_OFF &&
- priority != BluetoothProfile.PRIORITY_ON) {
- return false;
+ priority != BluetoothProfile.PRIORITY_ON) {
+ return false;
}
try {
return mService.setPriority(device, priority);
@@ -567,7 +573,7 @@
public int getPriority(BluetoothDevice device) {
if (VDBG) log("getPriority(" + device + ")");
if (mService != null && isEnabled() &&
- isValidDevice(device)) {
+ isValidDevice(device)) {
try {
return mService.getPriority(device);
} catch (RemoteException e) {
@@ -596,18 +602,17 @@
* <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)) {
+ 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 +626,16 @@
* <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)) {
+ 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 +648,16 @@
* <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)) {
+ 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 +674,17 @@
* 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)) {
+ 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 +713,9 @@
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 +725,7 @@
/**
* Reject the incoming connection.
+ *
* @hide
*/
public boolean rejectIncomingConnect(BluetoothDevice device) {
@@ -728,7 +733,9 @@
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 +754,9 @@
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 +772,6 @@
* 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 +779,9 @@
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 +799,9 @@
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 +812,8 @@
/**
* 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 +822,7 @@
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 +835,16 @@
*
* <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 +856,8 @@
* 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 +878,8 @@
* 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 +954,7 @@
* @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 +973,7 @@
* @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 +989,9 @@
/**
* 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 +1001,7 @@
* @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,
@@ -1021,9 +1029,8 @@
/**
* 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 +1050,8 @@
/**
* 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 +1071,7 @@
/**
* 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) {
@@ -1079,9 +1084,9 @@
* 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 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
* @hide
*/
public void bindResponse(int ind_id, boolean ind_status) {
@@ -1098,7 +1103,7 @@
}
private final IBluetoothProfileServiceConnection mConnection
- = new IBluetoothProfileServiceConnection.Stub() {
+ = new IBluetoothProfileServiceConnection.Stub() {
@Override
public void onServiceConnected(ComponentName className, IBinder service) {
if (DBG) Log.d(TAG, "Proxy object connected");
@@ -1106,6 +1111,7 @@
mHandler.sendMessage(mHandler.obtainMessage(
MESSAGE_HEADSET_SERVICE_CONNECTED));
}
+
@Override
public void onServiceDisconnected(ComponentName className) {
if (DBG) Log.d(TAG, "Proxy object disconnected");
@@ -1116,20 +1122,20 @@
};
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) {
diff --git a/framework/java/android/bluetooth/BluetoothHeadsetClient.java b/framework/java/android/bluetooth/BluetoothHeadsetClient.java
index 544b3b9..c775cd7 100644
--- a/framework/java/android/bluetooth/BluetoothHeadsetClient.java
+++ b/framework/java/android/bluetooth/BluetoothHeadsetClient.java
@@ -28,7 +28,6 @@
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 @@
* <p>
*
* @hide
- * */
+ */
public final class BluetoothHeadsetClient implements BluetoothProfile {
private static final String TAG = "BluetoothHeadsetClient";
private static final boolean DBG = true;
@@ -71,7 +70,7 @@
* 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 @@
* 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 @@
/**
* 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 @@
/**
* 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 @@
/**
* 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 @@
/**
* 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 @@
"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 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 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 @@
try {
mgr.registerStateChangeCallback(mBluetoothStateChangeCallback);
} catch (RemoteException e) {
- Log.e(TAG,"",e);
+ Log.e(TAG, "", e);
}
}
@@ -427,7 +427,7 @@
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 @@
try {
mgr.unregisterStateChangeCallback(mBluetoothStateChangeCallback);
} catch (Exception e) {
- Log.e(TAG,"",e);
+ Log.e(TAG, "", e);
}
}
@@ -458,7 +458,7 @@
mService = null;
mContext.unbindService(mConnection);
} catch (Exception re) {
- Log.e(TAG,"",re);
+ Log.e(TAG, "", re);
}
}
}
@@ -472,11 +472,9 @@
* 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 @@
/**
* 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 @@
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 @@
/**
* 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 @@
/**
* 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 @@
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 @@
/**
* 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 @@
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 @@
/**
* 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 @@
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 @@
/**
* 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 @@
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 @@
/**
* 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 @@
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 @@
/**
* 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 @@
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 @@
/**
* 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 @@
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 @@
/**
* 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 @@
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 @@
*
* 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 @@
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 @@
*
* 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 @@
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 @@
*
* 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 @@
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 @@
/**
* 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 @@
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 @@
*
* 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 @@
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 @@
/**
* 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 @@
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 @@
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 @@
/**
* 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 @@
/**
* 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 @@
*
* 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 @@
*
* 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 @@
/**
* 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 @@
BluetoothHeadsetClient.this);
}
}
+
@Override
public void onServiceDisconnected(ComponentName className) {
if (DBG) Log.d(TAG, "Proxy object disconnected");
@@ -1114,15 +1089,15 @@
};
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) {
diff --git a/framework/java/android/bluetooth/BluetoothHeadsetClientCall.java b/framework/java/android/bluetooth/BluetoothHeadsetClientCall.java
index 420c079..949cda0 100644
--- a/framework/java/android/bluetooth/BluetoothHeadsetClientCall.java
+++ b/framework/java/android/bluetooth/BluetoothHeadsetClientCall.java
@@ -25,6 +25,7 @@
/**
* This class represents a single call, its state and properties.
* It implements {@link Parcelable} for inter-process message passing.
+ *
* @hide
*/
public final class BluetoothHeadsetClientCall implements Parcelable {
@@ -98,7 +99,7 @@
*
* <p>Note: This is an internal function and shouldn't be exposed</p>
*
- * @param state new call state.
+ * @param state new call state.
*/
public void setState(int state) {
mState = state;
@@ -109,7 +110,7 @@
*
* <p>Note: This is an internal function and shouldn't be exposed</p>
*
- * @param number String representing phone number.
+ * @param number String representing phone number.
*/
public void setNumber(String number) {
mNumber = number;
@@ -120,8 +121,7 @@
*
* <p>Note: This is an internal function and shouldn't be exposed</p>
*
- * @param multiParty if <code>true</code> sets this call as a part
- * of multi party conference.
+ * @param multiParty if <code>true</code> sets this call as a part of multi party conference.
*/
public void setMultiParty(boolean multiParty) {
mMultiParty = multiParty;
@@ -185,8 +185,7 @@
/**
* Checks if call is an active call in a conference mode (aka multi party).
*
- * @return <code>true</code> if call is a multi party call,
- * <code>false</code> otherwise.
+ * @return <code>true</code> if call is a multi party call, <code>false</code> otherwise.
*/
public boolean isMultiParty() {
return mMultiParty;
@@ -195,8 +194,7 @@
/**
* Checks if this call is an outgoing call.
*
- * @return <code>true</code> if its outgoing call,
- * <code>false</code> otherwise.
+ * @return <code>true</code> if its outgoing call, <code>false</code> otherwise.
*/
public boolean isOutgoing() {
return mOutgoing;
@@ -215,15 +213,33 @@
builder.append(mUUID);
builder.append(", mState: ");
switch (mState) {
- case CALL_STATE_ACTIVE: builder.append("ACTIVE"); break;
- case CALL_STATE_HELD: builder.append("HELD"); break;
- case CALL_STATE_DIALING: builder.append("DIALING"); break;
- case CALL_STATE_ALERTING: builder.append("ALERTING"); break;
- case CALL_STATE_INCOMING: builder.append("INCOMING"); break;
- case CALL_STATE_WAITING: builder.append("WAITING"); break;
- case CALL_STATE_HELD_BY_RESPONSE_AND_HOLD: builder.append("HELD_BY_RESPONSE_AND_HOLD"); break;
- case CALL_STATE_TERMINATED: builder.append("TERMINATED"); break;
- default: builder.append(mState); break;
+ case CALL_STATE_ACTIVE:
+ builder.append("ACTIVE");
+ break;
+ case CALL_STATE_HELD:
+ builder.append("HELD");
+ break;
+ case CALL_STATE_DIALING:
+ builder.append("DIALING");
+ break;
+ case CALL_STATE_ALERTING:
+ builder.append("ALERTING");
+ break;
+ case CALL_STATE_INCOMING:
+ builder.append("INCOMING");
+ break;
+ case CALL_STATE_WAITING:
+ builder.append("WAITING");
+ break;
+ case CALL_STATE_HELD_BY_RESPONSE_AND_HOLD:
+ builder.append("HELD_BY_RESPONSE_AND_HOLD");
+ break;
+ case CALL_STATE_TERMINATED:
+ builder.append("TERMINATED");
+ break;
+ default:
+ builder.append(mState);
+ break;
}
builder.append(", mNumber: ");
builder.append(loggable ? mNumber : mNumber.hashCode());
@@ -242,7 +258,7 @@
new Parcelable.Creator<BluetoothHeadsetClientCall>() {
@Override
public BluetoothHeadsetClientCall createFromParcel(Parcel in) {
- return new BluetoothHeadsetClientCall((BluetoothDevice)in.readParcelable(null),
+ return new BluetoothHeadsetClientCall((BluetoothDevice) in.readParcelable(null),
in.readInt(), UUID.fromString(in.readString()), in.readInt(),
in.readString(), in.readInt() == 1, in.readInt() == 1);
}
diff --git a/framework/java/android/bluetooth/BluetoothHealth.java b/framework/java/android/bluetooth/BluetoothHealth.java
index 8d77888..fa75906 100644
--- a/framework/java/android/bluetooth/BluetoothHealth.java
+++ b/framework/java/android/bluetooth/BluetoothHealth.java
@@ -36,24 +36,23 @@
* Service via IPC.
*
* <p> How to connect to a health device which is acting in the source role.
- * <li> Use {@link BluetoothAdapter#getProfileProxy} to get
- * the BluetoothHealth proxy object. </li>
- * <li> Create an {@link BluetoothHealth} callback and call
- * {@link #registerSinkAppConfiguration} to register an application
- * configuration </li>
- * <li> Pair with the remote device. This currently needs to be done manually
- * from Bluetooth Settings </li>
- * <li> Connect to a health device using {@link #connectChannelToSource}. Some
- * devices will connect the channel automatically. The {@link BluetoothHealth}
- * callback will inform the application of channel state change. </li>
- * <li> Use the file descriptor provided with a connected channel to read and
- * write data to the health channel. </li>
- * <li> The received data needs to be interpreted using a health manager which
- * implements the IEEE 11073-xxxxx specifications.
- * <li> When done, close the health channel by calling {@link #disconnectChannel}
- * and unregister the application configuration calling
- * {@link #unregisterAppConfiguration}
- *
+ * <li> Use {@link BluetoothAdapter#getProfileProxy} to get
+ * the BluetoothHealth proxy object. </li>
+ * <li> Create an {@link BluetoothHealth} callback and call
+ * {@link #registerSinkAppConfiguration} to register an application
+ * configuration </li>
+ * <li> Pair with the remote device. This currently needs to be done manually
+ * from Bluetooth Settings </li>
+ * <li> Connect to a health device using {@link #connectChannelToSource}. Some
+ * devices will connect the channel automatically. The {@link BluetoothHealth}
+ * callback will inform the application of channel state change. </li>
+ * <li> Use the file descriptor provided with a connected channel to read and
+ * write data to the health channel. </li>
+ * <li> The received data needs to be interpreted using a health manager which
+ * implements the IEEE 11073-xxxxx specifications.
+ * <li> When done, close the health channel by calling {@link #disconnectChannel}
+ * and unregister the application configuration calling
+ * {@link #unregisterAppConfiguration}
*/
public final class BluetoothHealth implements BluetoothProfile {
private static final String TAG = "BluetoothHealth";
@@ -103,29 +102,29 @@
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...");
+ if (VDBG) Log.d(TAG, "Binding service...");
doBind();
}
} catch (Exception re) {
- Log.e(TAG,"",re);
+ Log.e(TAG, "", re);
}
}
}
}
- };
+ };
/**
@@ -137,10 +136,10 @@
* <p>Requires {@link android.Manifest.permission#BLUETOOTH} permission.
*
* @param name The friendly name associated with the application or configuration.
- * @param dataType The dataType of the Source role of Health Profile to which
- * the sink wants to connect to.
- * @param callback A callback to indicate success or failure of the registration and
- * all operations done on this application configuration.
+ * @param dataType The dataType of the Source role of Health Profile to which the sink wants to
+ * connect to.
+ * @param callback A callback to indicate success or failure of the registration and all
+ * operations done on this application configuration.
* @return If true, callback will be called.
*/
public boolean registerSinkAppConfiguration(String name, int dataType,
@@ -161,9 +160,8 @@
*
* @param name The friendly name associated with the application or configuration.
* @param dataType The dataType of the Source role of Health Profile.
- * @param channelType The channel type. Will be one of
- * {@link #CHANNEL_TYPE_RELIABLE} or
- * {@link #CHANNEL_TYPE_STREAMING}
+ * @param channelType The channel type. Will be one of {@link #CHANNEL_TYPE_RELIABLE} or {@link
+ * #CHANNEL_TYPE_STREAMING}
* @param callback - A callback to indicate success or failure.
* @return If true, callback will be called.
* @hide
@@ -197,7 +195,7 @@
*
* <p>Requires {@link android.Manifest.permission#BLUETOOTH} permission.
*
- * @param config The health app configuration
+ * @param config The health app configuration
* @return Success or failure.
*/
public boolean unregisterAppConfiguration(BluetoothHealthAppConfiguration config) {
@@ -224,8 +222,8 @@
* <p>Requires {@link android.Manifest.permission#BLUETOOTH} permission.
*
* @param device The remote Bluetooth device.
- * @param config The application configuration which has been registered using
- * {@link #registerSinkAppConfiguration(String, int, BluetoothHealthCallback) }
+ * @param config The application configuration which has been registered using {@link
+ * #registerSinkAppConfiguration(String, int, BluetoothHealthCallback) }
* @return If true, the callback associated with the application config will be called.
*/
public boolean connectChannelToSource(BluetoothDevice device,
@@ -249,11 +247,11 @@
* This is an asynchronous call. If this function returns true, the callback
* associated with the application configuration will be called.
*
- *<p>Requires {@link android.Manifest.permission#BLUETOOTH} permission.
+ * <p>Requires {@link android.Manifest.permission#BLUETOOTH} permission.
*
* @param device The remote Bluetooth device.
- * @param config The application configuration which has been registered using
- * {@link #registerSinkAppConfiguration(String, int, BluetoothHealthCallback) }
+ * @param config The application configuration which has been registered using {@link
+ * #registerSinkAppConfiguration(String, int, BluetoothHealthCallback) }
* @return If true, the callback associated with the application config will be called.
* @hide
*/
@@ -278,11 +276,11 @@
* This is an asynchronous call. If this function returns true, the callback
* associated with the application configuration will be called.
*
- *<p>Requires {@link android.Manifest.permission#BLUETOOTH} permission.
+ * <p>Requires {@link android.Manifest.permission#BLUETOOTH} permission.
*
* @param device The remote Bluetooth device.
- * @param config The application configuration which has been registered using
- * {@link #registerSinkAppConfiguration(String, int, BluetoothHealthCallback) }
+ * @param config The application configuration which has been registered using {@link
+ * #registerSinkAppConfiguration(String, int, BluetoothHealthCallback) }
* @param channelId The channel id associated with the channel
* @return If true, the callback associated with the application config will be called.
*/
@@ -342,9 +340,8 @@
* local adapter.
*
* @param device Remote bluetooth device.
- * @return State of the profile connection. One of
- * {@link #STATE_CONNECTED}, {@link #STATE_CONNECTING},
- * {@link #STATE_DISCONNECTED}, {@link #STATE_DISCONNECTING}
+ * @return State of the profile connection. One of {@link #STATE_CONNECTED}, {@link
+ * #STATE_CONNECTING}, {@link #STATE_DISCONNECTED}, {@link #STATE_DISCONNECTING}
*/
@Override
public int getConnectionState(BluetoothDevice device) {
@@ -372,6 +369,7 @@
* state of the local Bluetooth adapter for this profile. This can be used
* by applications like status bar which would just like to know the state of the
* local adapter.
+ *
* @return List of devices. The list will be empty on error.
*/
@Override
@@ -401,9 +399,8 @@
* by applications like status bar which would just like to know the state of the
* local adapter.
*
- * @param states Array of states. States can be one of
- * {@link #STATE_CONNECTED}, {@link #STATE_CONNECTING},
- * {@link #STATE_DISCONNECTED}, {@link #STATE_DISCONNECTING},
+ * @param states Array of states. States can be one of {@link #STATE_CONNECTED}, {@link
+ * #STATE_CONNECTING}, {@link #STATE_DISCONNECTED}, {@link #STATE_DISCONNECTING},
* @return List of devices. The list will be empty on error.
*/
@Override
@@ -429,25 +426,25 @@
@Override
public void onHealthAppConfigurationStatusChange(BluetoothHealthAppConfiguration config,
- int status) {
- mCallback.onHealthAppConfigurationStatusChange(config, status);
+ int status) {
+ mCallback.onHealthAppConfigurationStatusChange(config, status);
}
@Override
public void onHealthChannelStateChange(BluetoothHealthAppConfiguration config,
- BluetoothDevice device, int prevState, int newState,
- ParcelFileDescriptor fd, int channelId) {
+ BluetoothDevice device, int prevState, int newState,
+ ParcelFileDescriptor fd, int channelId) {
mCallback.onHealthChannelStateChange(config, device, prevState, newState, fd,
- channelId);
+ channelId);
}
}
- /** Health Channel Connection State - Disconnected */
- public static final int STATE_CHANNEL_DISCONNECTED = 0;
+ /** Health Channel Connection State - Disconnected */
+ public static final int STATE_CHANNEL_DISCONNECTED = 0;
/** Health Channel Connection State - Connecting */
- public static final int STATE_CHANNEL_CONNECTING = 1;
+ public static final int STATE_CHANNEL_CONNECTING = 1;
/** Health Channel Connection State - Connected */
- public static final int STATE_CHANNEL_CONNECTED = 2;
+ public static final int STATE_CHANNEL_CONNECTED = 2;
/** Health Channel Connection State - Disconnecting */
public static final int STATE_CHANNEL_DISCONNECTING = 3;
@@ -477,7 +474,7 @@
try {
mgr.registerStateChangeCallback(mBluetoothStateChangeCallback);
} catch (RemoteException e) {
- Log.e(TAG,"",e);
+ Log.e(TAG, "", e);
}
}
@@ -503,7 +500,7 @@
try {
mgr.unregisterStateChangeCallback(mBluetoothStateChangeCallback);
} catch (Exception e) {
- Log.e(TAG,"",e);
+ Log.e(TAG, "", e);
}
}
@@ -513,7 +510,7 @@
mService = null;
mContext.unbindService(mConnection);
} catch (Exception re) {
- Log.e(TAG,"",re);
+ Log.e(TAG, "", re);
}
}
}
@@ -529,6 +526,7 @@
mServiceListener.onServiceConnected(BluetoothProfile.HEALTH, BluetoothHealth.this);
}
}
+
public void onServiceDisconnected(ComponentName className) {
if (DBG) Log.d(TAG, "Proxy object disconnected");
mService = null;
@@ -557,8 +555,8 @@
BluetoothHealthCallback callback) {
if (name == null || (role != SOURCE_ROLE && role != SINK_ROLE) ||
(channelType != CHANNEL_TYPE_RELIABLE &&
- channelType != CHANNEL_TYPE_STREAMING &&
- channelType != CHANNEL_TYPE_ANY) || callback == null) {
+ channelType != CHANNEL_TYPE_STREAMING &&
+ channelType != CHANNEL_TYPE_ANY) || callback == null) {
return false;
}
if (role == SOURCE_ROLE && channelType == CHANNEL_TYPE_ANY) return false;
diff --git a/framework/java/android/bluetooth/BluetoothHealthAppConfiguration.java b/framework/java/android/bluetooth/BluetoothHealthAppConfiguration.java
index 1717a1e..d406ac2 100644
--- a/framework/java/android/bluetooth/BluetoothHealthAppConfiguration.java
+++ b/framework/java/android/bluetooth/BluetoothHealthAppConfiguration.java
@@ -25,7 +25,6 @@
* the {@link BluetoothHealth} class. This class represents an application configuration
* that the Bluetooth Health third party application will register to communicate with the
* remote Bluetooth health device.
- *
*/
public final class BluetoothHealthAppConfiguration implements Parcelable {
private final String mName;
@@ -52,12 +51,11 @@
*
* @param name Friendly name associated with the application configuration
* @param dataType Data Type of the remote Bluetooth Health device
- * @param role {@link BluetoothHealth#SOURCE_ROLE} or
- * {@link BluetoothHealth#SINK_ROLE}
+ * @param role {@link BluetoothHealth#SOURCE_ROLE} or {@link BluetoothHealth#SINK_ROLE}
* @hide
*/
BluetoothHealthAppConfiguration(String name, int dataType, int role, int
- channelType) {
+ channelType) {
mName = name;
mDataType = dataType;
mRole = role;
@@ -92,8 +90,8 @@
@Override
public String toString() {
return "BluetoothHealthAppConfiguration [mName = " + mName +
- ",mDataType = " + mDataType + ", mRole = " + mRole + ",mChannelType = " +
- mChannelType + "]";
+ ",mDataType = " + mDataType + ", mRole = " + mRole + ",mChannelType = " +
+ mChannelType + "]";
}
public int describeContents() {
@@ -121,8 +119,7 @@
/**
* Return the role associated with this application configuration.
*
- * @return One of {@link BluetoothHealth#SOURCE_ROLE} or
- * {@link BluetoothHealth#SINK_ROLE}
+ * @return One of {@link BluetoothHealth#SOURCE_ROLE} or {@link BluetoothHealth#SINK_ROLE}
*/
public int getRole() {
return mRole;
@@ -131,9 +128,8 @@
/**
* Return the channel type associated with this application configuration.
*
- * @return One of {@link BluetoothHealth#CHANNEL_TYPE_RELIABLE} or
- * {@link BluetoothHealth#CHANNEL_TYPE_STREAMING} or
- * {@link BluetoothHealth#CHANNEL_TYPE_ANY}.
+ * @return One of {@link BluetoothHealth#CHANNEL_TYPE_RELIABLE} or {@link
+ * BluetoothHealth#CHANNEL_TYPE_STREAMING} or {@link BluetoothHealth#CHANNEL_TYPE_ANY}.
* @hide
*/
public int getChannelType() {
@@ -141,22 +137,22 @@
}
public static final Parcelable.Creator<BluetoothHealthAppConfiguration> CREATOR =
- new Parcelable.Creator<BluetoothHealthAppConfiguration>() {
- @Override
- public BluetoothHealthAppConfiguration createFromParcel(Parcel in) {
- String name = in.readString();
- int type = in.readInt();
- int role = in.readInt();
- int channelType = in.readInt();
- return new BluetoothHealthAppConfiguration(name, type, role,
- channelType);
- }
+ new Parcelable.Creator<BluetoothHealthAppConfiguration>() {
+ @Override
+ public BluetoothHealthAppConfiguration createFromParcel(Parcel in) {
+ String name = in.readString();
+ int type = in.readInt();
+ int role = in.readInt();
+ int channelType = in.readInt();
+ return new BluetoothHealthAppConfiguration(name, type, role,
+ channelType);
+ }
- @Override
- public BluetoothHealthAppConfiguration[] newArray(int size) {
- return new BluetoothHealthAppConfiguration[size];
- }
- };
+ @Override
+ public BluetoothHealthAppConfiguration[] newArray(int size) {
+ return new BluetoothHealthAppConfiguration[size];
+ }
+ };
public void writeToParcel(Parcel out, int flags) {
out.writeString(mName);
diff --git a/framework/java/android/bluetooth/BluetoothHealthCallback.java b/framework/java/android/bluetooth/BluetoothHealthCallback.java
index 128376f..198d06a 100644
--- a/framework/java/android/bluetooth/BluetoothHealthCallback.java
+++ b/framework/java/android/bluetooth/BluetoothHealthCallback.java
@@ -33,12 +33,11 @@
* <p> This callback is called on the binder thread (not on the UI thread)
*
* @param config Bluetooth Health app configuration
- * @param status Success or failure of the registration or unregistration
- * calls. Can be one of
- * {@link BluetoothHealth#APP_CONFIG_REGISTRATION_SUCCESS} or
- * {@link BluetoothHealth#APP_CONFIG_REGISTRATION_FAILURE} or
- * {@link BluetoothHealth#APP_CONFIG_UNREGISTRATION_SUCCESS} or
- * {@link BluetoothHealth#APP_CONFIG_UNREGISTRATION_FAILURE}
+ * @param status Success or failure of the registration or unregistration calls. Can be one of
+ * {@link BluetoothHealth#APP_CONFIG_REGISTRATION_SUCCESS} or {@link
+ * BluetoothHealth#APP_CONFIG_REGISTRATION_FAILURE} or
+ * {@link BluetoothHealth#APP_CONFIG_UNREGISTRATION_SUCCESS}
+ * or {@link BluetoothHealth#APP_CONFIG_UNREGISTRATION_FAILURE}
*/
@BinderThread
public void onHealthAppConfigurationStatusChange(BluetoothHealthAppConfiguration config,
@@ -57,15 +56,15 @@
* @param prevState The previous state of the channel
* @param newState The new state of the channel.
* @param fd The Parcel File Descriptor when the channel state is connected.
- * @param channelId The id associated with the channel. This id will be used
- * in future calls like when disconnecting the channel.
+ * @param channelId The id associated with the channel. This id will be used in future calls
+ * like when disconnecting the channel.
*/
@BinderThread
public void onHealthChannelStateChange(BluetoothHealthAppConfiguration config,
BluetoothDevice device, int prevState, int newState, ParcelFileDescriptor fd,
int channelId) {
Log.d(TAG, "onHealthChannelStateChange: " + config + "Device: " + device +
- "prevState:" + prevState + "newState:" + newState + "ParcelFd:" + fd +
- "ChannelId:" + channelId);
+ "prevState:" + prevState + "newState:" + newState + "ParcelFd:" + fd +
+ "ChannelId:" + channelId);
}
}
diff --git a/framework/java/android/bluetooth/BluetoothHidDeviceAppConfiguration.java b/framework/java/android/bluetooth/BluetoothHidDeviceAppConfiguration.java
index 05ba64e..2731935 100644
--- a/framework/java/android/bluetooth/BluetoothHidDeviceAppConfiguration.java
+++ b/framework/java/android/bluetooth/BluetoothHidDeviceAppConfiguration.java
@@ -49,19 +49,19 @@
}
public static final Parcelable.Creator<BluetoothHidDeviceAppConfiguration> CREATOR =
- new Parcelable.Creator<BluetoothHidDeviceAppConfiguration>() {
+ new Parcelable.Creator<BluetoothHidDeviceAppConfiguration>() {
- @Override
- public BluetoothHidDeviceAppConfiguration createFromParcel(Parcel in) {
- long hash = in.readLong();
- return new BluetoothHidDeviceAppConfiguration(hash);
- }
+ @Override
+ public BluetoothHidDeviceAppConfiguration createFromParcel(Parcel in) {
+ long hash = in.readLong();
+ return new BluetoothHidDeviceAppConfiguration(hash);
+ }
- @Override
- public BluetoothHidDeviceAppConfiguration[] newArray(int size) {
- return new BluetoothHidDeviceAppConfiguration[size];
- }
- };
+ @Override
+ public BluetoothHidDeviceAppConfiguration[] newArray(int size) {
+ return new BluetoothHidDeviceAppConfiguration[size];
+ }
+ };
@Override
public void writeToParcel(Parcel out, int flags) {
diff --git a/framework/java/android/bluetooth/BluetoothHidDeviceAppQosSettings.java b/framework/java/android/bluetooth/BluetoothHidDeviceAppQosSettings.java
index 0d6530c..d8880a2 100644
--- a/framework/java/android/bluetooth/BluetoothHidDeviceAppQosSettings.java
+++ b/framework/java/android/bluetooth/BluetoothHidDeviceAppQosSettings.java
@@ -19,8 +19,6 @@
import android.os.Parcel;
import android.os.Parcelable;
-import java.util.Random;
-
/** @hide */
public final class BluetoothHidDeviceAppQosSettings implements Parcelable {
@@ -63,21 +61,22 @@
}
public static final Parcelable.Creator<BluetoothHidDeviceAppQosSettings> CREATOR =
- new Parcelable.Creator<BluetoothHidDeviceAppQosSettings>() {
+ new Parcelable.Creator<BluetoothHidDeviceAppQosSettings>() {
- @Override
- public BluetoothHidDeviceAppQosSettings createFromParcel(Parcel in) {
+ @Override
+ public BluetoothHidDeviceAppQosSettings createFromParcel(Parcel in) {
- return new BluetoothHidDeviceAppQosSettings(in.readInt(), in.readInt(), in.readInt(),
- in.readInt(),
- in.readInt(), in.readInt());
- }
+ return new BluetoothHidDeviceAppQosSettings(in.readInt(), in.readInt(),
+ in.readInt(),
+ in.readInt(),
+ in.readInt(), in.readInt());
+ }
- @Override
- public BluetoothHidDeviceAppQosSettings[] newArray(int size) {
- return new BluetoothHidDeviceAppQosSettings[size];
- }
- };
+ @Override
+ public BluetoothHidDeviceAppQosSettings[] newArray(int size) {
+ return new BluetoothHidDeviceAppQosSettings[size];
+ }
+ };
@Override
public void writeToParcel(Parcel out, int flags) {
@@ -90,7 +89,7 @@
}
public int[] toArray() {
- return new int[] {
+ return new int[]{
serviceType, tokenRate, tokenBucketSize, peakBandwidth, latency, delayVariation
};
}
diff --git a/framework/java/android/bluetooth/BluetoothHidDeviceAppSdpSettings.java b/framework/java/android/bluetooth/BluetoothHidDeviceAppSdpSettings.java
index f9a2245..e17e785 100644
--- a/framework/java/android/bluetooth/BluetoothHidDeviceAppSdpSettings.java
+++ b/framework/java/android/bluetooth/BluetoothHidDeviceAppSdpSettings.java
@@ -19,8 +19,6 @@
import android.os.Parcel;
import android.os.Parcelable;
-import java.util.Random;
-
/** @hide */
public final class BluetoothHidDeviceAppSdpSettings implements Parcelable {
@@ -54,20 +52,20 @@
}
public static final Parcelable.Creator<BluetoothHidDeviceAppSdpSettings> CREATOR =
- new Parcelable.Creator<BluetoothHidDeviceAppSdpSettings>() {
+ new Parcelable.Creator<BluetoothHidDeviceAppSdpSettings>() {
- @Override
- public BluetoothHidDeviceAppSdpSettings createFromParcel(Parcel in) {
+ @Override
+ public BluetoothHidDeviceAppSdpSettings createFromParcel(Parcel in) {
- return new BluetoothHidDeviceAppSdpSettings(in.readString(), in.readString(),
- in.readString(), in.readByte(), in.createByteArray());
- }
+ return new BluetoothHidDeviceAppSdpSettings(in.readString(), in.readString(),
+ in.readString(), in.readByte(), in.createByteArray());
+ }
- @Override
- public BluetoothHidDeviceAppSdpSettings[] newArray(int size) {
- return new BluetoothHidDeviceAppSdpSettings[size];
- }
- };
+ @Override
+ public BluetoothHidDeviceAppSdpSettings[] newArray(int size) {
+ return new BluetoothHidDeviceAppSdpSettings[size];
+ }
+ };
@Override
public void writeToParcel(Parcel out, int flags) {
diff --git a/framework/java/android/bluetooth/BluetoothHidDeviceCallback.java b/framework/java/android/bluetooth/BluetoothHidDeviceCallback.java
index f519776..d50505c 100644
--- a/framework/java/android/bluetooth/BluetoothHidDeviceCallback.java
+++ b/framework/java/android/bluetooth/BluetoothHidDeviceCallback.java
@@ -33,16 +33,15 @@
* , but can be also unsolicited in case e.g. Bluetooth was turned off in
* which case application is unregistered automatically.
*
- * @param pluggedDevice {@link BluetoothDevice} object which represents host
- * that currently has Virtual Cable established with device. Only
- * valid when application is registered, can be <code>null</code>
- * .
- * @param config {@link BluetoothHidDeviceAppConfiguration} object which
- * represents token required to unregister application using
- * {@link BluetoothHidDevice#unregisterApp(BluetoothHidDeviceAppConfiguration)}
- * .
- * @param registered <code>true</code> if application is registered,
- * <code>false</code> otherwise.
+ * @param pluggedDevice {@link BluetoothDevice} object which represents host that currently has
+ * Virtual Cable established with device. Only valid when application is registered, can be
+ * <code>null</code> .
+ * @param config {@link BluetoothHidDeviceAppConfiguration} object which represents token
+ * required to unregister application using
+ * {@link BluetoothHidDevice#unregisterApp(BluetoothHidDeviceAppConfiguration)}
+ * .
+ * @param registered <code>true</code> if application is registered, <code>false</code>
+ * otherwise.
*/
public void onAppStatusChanged(BluetoothDevice pluggedDevice,
BluetoothHidDeviceAppConfiguration config, boolean registered) {
@@ -55,8 +54,8 @@
* Application can assume than Virtual Cable is established when called with
* {@link BluetoothProfile#STATE_CONNECTED} <code>state</code>.
*
- * @param device {@link BluetoothDevice} object representing host device
- * which connection state was changed.
+ * @param device {@link BluetoothDevice} object representing host device which connection state
+ * was changed.
* @param state Connection state as defined in {@link BluetoothProfile}.
*/
public void onConnectionStateChanged(BluetoothDevice device, int state) {
@@ -69,10 +68,9 @@
* {@link BluetoothHidDevice#replyReport(BluetoothDevice, byte, byte, byte[])}.
*
* @param type Requested Report Type.
- * @param id Requested Report Id, can be 0 if no Report Id are defined in
- * descriptor.
- * @param bufferSize Requested buffer size, application shall respond with
- * at least given number of bytes.
+ * @param id Requested Report Id, can be 0 if no Report Id are defined in descriptor.
+ * @param bufferSize Requested buffer size, application shall respond with at least given number
+ * of bytes.
*/
public void onGetReport(BluetoothDevice device, byte type, byte id, int bufferSize) {
Log.d(TAG, "onGetReport: device=" + device + " type=" + type + " id=" + id + " bufferSize="
diff --git a/framework/java/android/bluetooth/BluetoothInputDevice.java b/framework/java/android/bluetooth/BluetoothInputDevice.java
index a5a0243..a9b2e56 100644
--- a/framework/java/android/bluetooth/BluetoothInputDevice.java
+++ b/framework/java/android/bluetooth/BluetoothInputDevice.java
@@ -35,12 +35,13 @@
* This class provides the public APIs to control the Bluetooth Input
* Device Profile.
*
- *<p>BluetoothInputDevice is a proxy object for controlling the Bluetooth
+ * <p>BluetoothInputDevice is a proxy object for controlling the Bluetooth
* Service via IPC. Use {@link BluetoothAdapter#getProfileProxy} to get
* the BluetoothInputDevice proxy object.
*
- *<p>Each method is protected with its appropriate permission.
- *@hide
+ * <p>Each method is protected with its appropriate permission.
+ *
+ * @hide
*/
public final class BluetoothInputDevice implements BluetoothProfile {
private static final String TAG = "BluetoothInputDevice";
@@ -53,9 +54,9 @@
*
* <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
@@ -67,45 +68,46 @@
*/
@SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
public static final String ACTION_CONNECTION_STATE_CHANGED =
- "android.bluetooth.input.profile.action.CONNECTION_STATE_CHANGED";
+ "android.bluetooth.input.profile.action.CONNECTION_STATE_CHANGED";
/**
* @hide
*/
@SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
public static final String ACTION_PROTOCOL_MODE_CHANGED =
- "android.bluetooth.input.profile.action.PROTOCOL_MODE_CHANGED";
+ "android.bluetooth.input.profile.action.PROTOCOL_MODE_CHANGED";
/**
* @hide
*/
@SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
public static final String ACTION_HANDSHAKE =
- "android.bluetooth.input.profile.action.HANDSHAKE";
+ "android.bluetooth.input.profile.action.HANDSHAKE";
/**
* @hide
*/
@SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
public static final String ACTION_REPORT =
- "android.bluetooth.input.profile.action.REPORT";
+ "android.bluetooth.input.profile.action.REPORT";
/**
* @hide
*/
@SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
public static final String ACTION_VIRTUAL_UNPLUG_STATUS =
- "android.bluetooth.input.profile.action.VIRTUAL_UNPLUG_STATUS";
+ "android.bluetooth.input.profile.action.VIRTUAL_UNPLUG_STATUS";
/**
* @hide
*/
@SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
public static final String ACTION_IDLE_TIME_CHANGED =
- "android.bluetooth.input.profile.action.IDLE_TIME_CHANGED";
+ "android.bluetooth.input.profile.action.IDLE_TIME_CHANGED";
/**
* Return codes for the connect and disconnect Bluez / Dbus calls.
+ *
* @hide
*/
public static final int INPUT_DISCONNECT_FAILED_NOT_CONNECTED = 5000;
@@ -174,22 +176,26 @@
/**
* @hide
*/
- public static final String EXTRA_PROTOCOL_MODE = "android.bluetooth.BluetoothInputDevice.extra.PROTOCOL_MODE";
+ public static final String EXTRA_PROTOCOL_MODE =
+ "android.bluetooth.BluetoothInputDevice.extra.PROTOCOL_MODE";
/**
* @hide
*/
- public static final String EXTRA_REPORT_TYPE = "android.bluetooth.BluetoothInputDevice.extra.REPORT_TYPE";
+ public static final String EXTRA_REPORT_TYPE =
+ "android.bluetooth.BluetoothInputDevice.extra.REPORT_TYPE";
/**
* @hide
*/
- public static final String EXTRA_REPORT_ID = "android.bluetooth.BluetoothInputDevice.extra.REPORT_ID";
+ public static final String EXTRA_REPORT_ID =
+ "android.bluetooth.BluetoothInputDevice.extra.REPORT_ID";
/**
* @hide
*/
- public static final String EXTRA_REPORT_BUFFER_SIZE = "android.bluetooth.BluetoothInputDevice.extra.REPORT_BUFFER_SIZE";
+ public static final String EXTRA_REPORT_BUFFER_SIZE =
+ "android.bluetooth.BluetoothInputDevice.extra.REPORT_BUFFER_SIZE";
/**
* @hide
@@ -204,12 +210,14 @@
/**
* @hide
*/
- public static final String EXTRA_VIRTUAL_UNPLUG_STATUS = "android.bluetooth.BluetoothInputDevice.extra.VIRTUAL_UNPLUG_STATUS";
+ public static final String EXTRA_VIRTUAL_UNPLUG_STATUS =
+ "android.bluetooth.BluetoothInputDevice.extra.VIRTUAL_UNPLUG_STATUS";
/**
* @hide
*/
- public static final String EXTRA_IDLE_TIME = "android.bluetooth.BluetoothInputDevice.extra.IDLE_TIME";
+ public static final String EXTRA_IDLE_TIME =
+ "android.bluetooth.BluetoothInputDevice.extra.IDLE_TIME";
private Context mContext;
private ServiceListener mServiceListener;
@@ -221,34 +229,33 @@
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...");
+ if (VDBG) Log.d(TAG, "Binding service...");
doBind();
}
} catch (Exception re) {
- Log.e(TAG,"",re);
+ Log.e(TAG, "", re);
}
}
}
}
- };
+ };
/**
* Create a BluetoothInputDevice proxy object for interacting with the local
* Bluetooth Service which handles the InputDevice profile
- *
*/
/*package*/ BluetoothInputDevice(Context context, ServiceListener l) {
mContext = context;
@@ -260,7 +267,7 @@
try {
mgr.registerStateChangeCallback(mBluetoothStateChangeCallback);
} catch (RemoteException e) {
- Log.e(TAG,"",e);
+ Log.e(TAG, "", e);
}
}
@@ -286,7 +293,7 @@
try {
mgr.unregisterStateChangeCallback(mBluetoothStateChangeCallback);
} catch (Exception e) {
- Log.e(TAG,"",e);
+ Log.e(TAG, "", e);
}
}
@@ -296,9 +303,9 @@
mService = null;
mContext.unbindService(mConnection);
} catch (Exception re) {
- Log.e(TAG,"",re);
+ Log.e(TAG, "", re);
}
- }
+ }
}
mServiceListener = null;
}
@@ -319,8 +326,7 @@
* 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) {
@@ -359,8 +365,7 @@
* 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) {
@@ -432,7 +437,7 @@
* 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}
@@ -447,8 +452,8 @@
if (DBG) log("setPriority(" + device + ", " + priority + ")");
if (mService != null && isEnabled() && isValidDevice(device)) {
if (priority != BluetoothProfile.PRIORITY_OFF &&
- priority != BluetoothProfile.PRIORITY_ON) {
- return false;
+ priority != BluetoothProfile.PRIORITY_ON) {
+ return false;
}
try {
return mService.setPriority(device, priority);
@@ -494,9 +499,11 @@
mService = IBluetoothInputDevice.Stub.asInterface(Binder.allowBlocking(service));
if (mServiceListener != null) {
- mServiceListener.onServiceConnected(BluetoothProfile.INPUT_DEVICE, BluetoothInputDevice.this);
+ mServiceListener.onServiceConnected(BluetoothProfile.INPUT_DEVICE,
+ BluetoothInputDevice.this);
}
}
+
public void onServiceDisconnected(ComponentName className) {
if (DBG) Log.d(TAG, "Proxy object disconnected");
mService = null;
@@ -507,15 +514,15 @@
};
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;
}
@@ -525,8 +532,7 @@
* <p>Requires {@link android.Manifest.permission#BLUETOOTH_ADMIN} permission.
*
* @param device Remote Bluetooth Device
- * @return false on immediate error,
- * true otherwise
+ * @return false on immediate error, true otherwise
* @hide
*/
public boolean virtualUnplug(BluetoothDevice device) {
@@ -546,15 +552,14 @@
}
/**
- * Send Get_Protocol_Mode command to the connected HID input device.
- *
- * <p>Requires {@link android.Manifest.permission#BLUETOOTH_ADMIN} permission.
- *
- * @param device Remote Bluetooth Device
- * @return false on immediate error,
- *true otherwise
- * @hide
- */
+ * Send Get_Protocol_Mode command to the connected HID input device.
+ *
+ * <p>Requires {@link android.Manifest.permission#BLUETOOTH_ADMIN} permission.
+ *
+ * @param device Remote Bluetooth Device
+ * @return false on immediate error, true otherwise
+ * @hide
+ */
public boolean getProtocolMode(BluetoothDevice device) {
if (VDBG) log("getProtocolMode(" + device + ")");
if (mService != null && isEnabled() && isValidDevice(device)) {
@@ -566,7 +571,7 @@
}
}
if (mService == null) Log.w(TAG, "Proxy not attached to service");
- return false;
+ return false;
}
/**
@@ -575,8 +580,7 @@
* <p>Requires {@link android.Manifest.permission#BLUETOOTH_ADMIN} permission.
*
* @param device Remote Bluetooth Device
- * @return false on immediate error,
- * true otherwise
+ * @return false on immediate error, true otherwise
* @hide
*/
public boolean setProtocolMode(BluetoothDevice device, int protocolMode) {
@@ -602,12 +606,16 @@
* @param reportType Report type
* @param reportId Report ID
* @param bufferSize Report receiving buffer size
- * @return false on immediate error,
- * true otherwise
+ * @return false on immediate error, true otherwise
* @hide
*/
- public boolean getReport(BluetoothDevice device, byte reportType, byte reportId, int bufferSize) {
- if (VDBG) log("getReport(" + device + "), reportType=" + reportType + " reportId=" + reportId + "bufferSize=" + bufferSize);
+ public boolean getReport(BluetoothDevice device, byte reportType, byte reportId,
+ int bufferSize) {
+ if (VDBG) {
+ log(
+ "getReport(" + device + "), reportType=" + reportType + " reportId=" + reportId
+ + "bufferSize=" + bufferSize);
+ }
if (mService != null && isEnabled() && isValidDevice(device)) {
try {
return mService.getReport(device, reportType, reportId, bufferSize);
@@ -628,8 +636,7 @@
* @param device Remote Bluetooth Device
* @param reportType Report type
* @param report Report receiving buffer size
- * @return false on immediate error,
- * true otherwise
+ * @return false on immediate error, true otherwise
* @hide
*/
public boolean setReport(BluetoothDevice device, byte reportType, String report) {
@@ -653,8 +660,7 @@
*
* @param device Remote Bluetooth Device
* @param report Report to send
- * @return false on immediate error,
- * true otherwise
+ * @return false on immediate error, true otherwise
* @hide
*/
public boolean sendData(BluetoothDevice device, String report) {
@@ -677,8 +683,7 @@
* <p>Requires {@link android.Manifest.permission#BLUETOOTH_ADMIN} permission.
*
* @param device Remote Bluetooth Device
- * @return false on immediate error,
- * true otherwise
+ * @return false on immediate error, true otherwise
* @hide
*/
public boolean getIdleTime(BluetoothDevice device) {
@@ -702,8 +707,7 @@
*
* @param device Remote Bluetooth Device
* @param idleTime Idle time to be set on HID Device
- * @return false on immediate error,
- * true otherwise
+ * @return false on immediate error, true otherwise
* @hide
*/
public boolean setIdleTime(BluetoothDevice device, byte idleTime) {
@@ -721,6 +725,6 @@
}
private static void log(String msg) {
- Log.d(TAG, msg);
+ Log.d(TAG, msg);
}
}
diff --git a/framework/java/android/bluetooth/BluetoothInputHost.java b/framework/java/android/bluetooth/BluetoothInputHost.java
index 68d105f..0cdcd57 100644
--- a/framework/java/android/bluetooth/BluetoothInputHost.java
+++ b/framework/java/android/bluetooth/BluetoothInputHost.java
@@ -26,8 +26,8 @@
import android.os.RemoteException;
import android.util.Log;
-import java.util.Arrays;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.List;
/**
@@ -43,9 +43,9 @@
*
* <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
@@ -57,13 +57,12 @@
*/
@SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
public static final String ACTION_CONNECTION_STATE_CHANGED =
- "android.bluetooth.inputhost.profile.action.CONNECTION_STATE_CHANGED";
+ "android.bluetooth.inputhost.profile.action.CONNECTION_STATE_CHANGED";
/**
* Constants representing device subclass.
*
- * @see #registerApp(String, String, String, byte, byte[],
- * BluetoothHidDeviceCallback)
+ * @see #registerApp(String, String, String, byte, byte[], BluetoothHidDeviceCallback)
*/
public static final byte SUBCLASS1_NONE = (byte) 0x00;
public static final byte SUBCLASS1_KEYBOARD = (byte) 0x40;
@@ -118,7 +117,8 @@
private BluetoothAdapter mAdapter;
- private static class BluetoothHidDeviceCallbackWrapper extends IBluetoothHidDeviceCallback.Stub {
+ private static class BluetoothHidDeviceCallbackWrapper extends
+ IBluetoothHidDeviceCallback.Stub {
private BluetoothHidDeviceCallback mCallback;
@@ -164,36 +164,43 @@
}
final private IBluetoothStateChangeCallback mBluetoothStateChangeCallback =
- new IBluetoothStateChangeCallback.Stub() {
+ new IBluetoothStateChangeCallback.Stub() {
- public void onBluetoothStateChange(boolean up) {
- Log.d(TAG, "onBluetoothStateChange: up=" + up);
- synchronized (mConnection) {
- if (!up) {
- Log.d(TAG,"Unbinding service...");
- if (mService != null) {
- mService = null;
- try {
- mContext.unbindService(mConnection);
- } catch (IllegalArgumentException e) {
- Log.e(TAG,"onBluetoothStateChange: could not unbind service:", e);
+ public void onBluetoothStateChange(boolean up) {
+ Log.d(TAG, "onBluetoothStateChange: up=" + up);
+ synchronized (mConnection) {
+ if (!up) {
+ Log.d(TAG, "Unbinding service...");
+ if (mService != null) {
+ mService = null;
+ try {
+ mContext.unbindService(mConnection);
+ } catch (IllegalArgumentException e) {
+ Log.e(TAG, "onBluetoothStateChange: could not unbind service:",
+ e);
+ }
+ }
+ } else {
+ try {
+ if (mService == null) {
+ Log.d(TAG, "Binding HID Device service...");
+ doBind();
+ }
+ } catch (IllegalStateException e) {
+ Log.e(TAG,
+ "onBluetoothStateChange: could not bind to HID Dev "
+ + "service: ",
+ e);
+ } catch (SecurityException e) {
+ Log.e(TAG,
+ "onBluetoothStateChange: could not bind to HID Dev "
+ + "service: ",
+ e);
+ }
}
}
- } else {
- try {
- if (mService == null) {
- Log.d(TAG,"Binding HID Device service...");
- doBind();
- }
- } catch (IllegalStateException e) {
- Log.e(TAG,"onBluetoothStateChange: could not bind to HID Dev service: ", e);
- } catch (SecurityException e) {
- Log.e(TAG,"onBluetoothStateChange: could not bind to HID Dev service: ", e);
- }
}
- }
- }
- };
+ };
private ServiceConnection mConnection = new ServiceConnection() {
@@ -204,7 +211,7 @@
if (mServiceListener != null) {
mServiceListener.onServiceConnected(BluetoothProfile.INPUT_HOST,
- BluetoothInputHost.this);
+ BluetoothInputHost.this);
}
}
@@ -269,9 +276,9 @@
try {
mContext.unbindService(mConnection);
} catch (IllegalArgumentException e) {
- Log.e(TAG,"close: could not unbind HID Dev service: ", e);
+ Log.e(TAG, "close: could not unbind HID Dev service: ", e);
}
- }
+ }
}
mServiceListener = null;
@@ -341,14 +348,11 @@
* should be unregistered using
* {@link #unregisterApp(BluetoothHidDeviceAppConfiguration)}.
*
- * @param sdp {@link BluetoothHidDeviceAppSdpSettings} object of
- * HID Device SDP record.
- * @param inQos {@link BluetoothHidDeviceAppQosSettings} object of
- * Incoming QoS Settings.
- * @param outQos {@link BluetoothHidDeviceAppQosSettings} object of
- * Outgoing QoS Settings.
- * @param callback {@link BluetoothHidDeviceCallback} object to which
- * callback messages will be sent.
+ * @param sdp {@link BluetoothHidDeviceAppSdpSettings} object of HID Device SDP record.
+ * @param inQos {@link BluetoothHidDeviceAppQosSettings} object of Incoming QoS Settings.
+ * @param outQos {@link BluetoothHidDeviceAppQosSettings} object of Outgoing QoS Settings.
+ * @param callback {@link BluetoothHidDeviceCallback} object to which callback messages will be
+ * sent.
* @return
*/
public boolean registerApp(BluetoothHidDeviceAppSdpSettings sdp,
@@ -366,9 +370,9 @@
if (mService != null) {
try {
BluetoothHidDeviceAppConfiguration config =
- new BluetoothHidDeviceAppConfiguration();
+ new BluetoothHidDeviceAppConfiguration();
BluetoothHidDeviceCallbackWrapper cbw =
- new BluetoothHidDeviceCallbackWrapper(callback);
+ new BluetoothHidDeviceCallbackWrapper(callback);
result = mService.registerApp(config, sdp, inQos, outQos, cbw);
} catch (RemoteException e) {
Log.e(TAG, e.toString());
@@ -385,11 +389,10 @@
* new connections will be allowed until registered again using
* {@link #registerApp(String, String, String, byte, byte[], BluetoothHidDeviceCallback)}
*
- * @param config {@link BluetoothHidDeviceAppConfiguration} object as
- * obtained from
- * {@link BluetoothHidDeviceCallback#onAppStatusChanged(BluetoothDevice,
- * BluetoothHidDeviceAppConfiguration, boolean)}
- *
+ * @param config {@link BluetoothHidDeviceAppConfiguration} object as obtained from {@link
+ * BluetoothHidDeviceCallback#onAppStatusChanged(BluetoothDevice,
+ * BluetoothHidDeviceAppConfiguration,
+ * boolean)}
* @return
*/
public boolean unregisterApp(BluetoothHidDeviceAppConfiguration config) {
@@ -413,8 +416,8 @@
/**
* Sends report to remote host using interrupt channel.
*
- * @param id Report Id, as defined in descriptor. Can be 0 in case Report Id
- * are not defined in descriptor.
+ * @param id Report Id, as defined in descriptor. Can be 0 in case Report Id are not defined in
+ * descriptor.
* @param data Report data, not including Report Id.
* @return
*/
diff --git a/framework/java/android/bluetooth/BluetoothInputStream.java b/framework/java/android/bluetooth/BluetoothInputStream.java
index 03af953..062e4de 100644
--- a/framework/java/android/bluetooth/BluetoothInputStream.java
+++ b/framework/java/android/bluetooth/BluetoothInputStream.java
@@ -51,15 +51,14 @@
* stream is detected or an exception is thrown.
*
* @return the byte read or -1 if the end of stream has been reached.
- * @throws IOException
- * if the stream is closed or another IOException occurs.
+ * @throws IOException if the stream is closed or another IOException occurs.
* @since Android 1.5
*/
public int read() throws IOException {
byte b[] = new byte[1];
int ret = mSocket.read(b, 0, 1);
if (ret == 1) {
- return (int)b[0] & 0xff;
+ return (int) b[0] & 0xff;
} else {
return -1;
}
@@ -69,21 +68,14 @@
* Reads at most {@code length} bytes from this stream and stores them in
* the byte array {@code b} starting at {@code offset}.
*
- * @param b
- * the byte array in which to store the bytes read.
- * @param offset
- * the initial position in {@code buffer} to store the bytes
- * read from this stream.
- * @param length
- * the maximum number of bytes to store in {@code b}.
- * @return the number of bytes actually read or -1 if the end of the stream
- * has been reached.
- * @throws IndexOutOfBoundsException
- * if {@code offset < 0} or {@code length < 0}, or if
- * {@code offset + length} is greater than the length of
- * {@code b}.
- * @throws IOException
- * if the stream is closed or another IOException occurs.
+ * @param b the byte array in which to store the bytes read.
+ * @param offset the initial position in {@code buffer} to store the bytes read from this
+ * stream.
+ * @param length the maximum number of bytes to store in {@code b}.
+ * @return the number of bytes actually read or -1 if the end of the stream has been reached.
+ * @throws IndexOutOfBoundsException if {@code offset < 0} or {@code length < 0}, or if {@code
+ * offset + length} is greater than the length of {@code b}.
+ * @throws IOException if the stream is closed or another IOException occurs.
* @since Android 1.5
*/
public int read(byte[] b, int offset, int length) throws IOException {
diff --git a/framework/java/android/bluetooth/BluetoothManager.java b/framework/java/android/bluetooth/BluetoothManager.java
index bacce80..7e3bb05 100644
--- a/framework/java/android/bluetooth/BluetoothManager.java
+++ b/framework/java/android/bluetooth/BluetoothManager.java
@@ -86,17 +86,16 @@
*
* @param device Remote bluetooth device.
* @param profile GATT or GATT_SERVER
- * @return State of the profile connection. One of
- * {@link BluetoothProfile#STATE_CONNECTED}, {@link BluetoothProfile#STATE_CONNECTING},
- * {@link BluetoothProfile#STATE_DISCONNECTED},
- * {@link BluetoothProfile#STATE_DISCONNECTING}
+ * @return State of the profile connection. One of {@link BluetoothProfile#STATE_CONNECTED},
+ * {@link BluetoothProfile#STATE_CONNECTING}, {@link BluetoothProfile#STATE_DISCONNECTED},
+ * {@link BluetoothProfile#STATE_DISCONNECTING}
*/
@RequiresPermission(Manifest.permission.BLUETOOTH)
public int getConnectionState(BluetoothDevice device, int profile) {
- if (DBG) Log.d(TAG,"getConnectionState()");
+ if (DBG) Log.d(TAG, "getConnectionState()");
List<BluetoothDevice> connectedDevices = getConnectedDevices(profile);
- for(BluetoothDevice connectedDevice : connectedDevices) {
+ for (BluetoothDevice connectedDevice : connectedDevices) {
if (device.equals(connectedDevice)) {
return BluetoothProfile.STATE_CONNECTED;
}
@@ -120,7 +119,7 @@
*/
@RequiresPermission(Manifest.permission.BLUETOOTH)
public List<BluetoothDevice> getConnectedDevices(int profile) {
- if (DBG) Log.d(TAG,"getConnectedDevices");
+ if (DBG) Log.d(TAG, "getConnectedDevices");
if (profile != BluetoothProfile.GATT && profile != BluetoothProfile.GATT_SERVER) {
throw new IllegalArgumentException("Profile not supported: " + profile);
}
@@ -133,16 +132,15 @@
if (iGatt == null) return connectedDevices;
connectedDevices = iGatt.getDevicesMatchingConnectionStates(
- new int[] { BluetoothProfile.STATE_CONNECTED });
+ new int[]{BluetoothProfile.STATE_CONNECTED});
} catch (RemoteException e) {
- Log.e(TAG,"",e);
+ Log.e(TAG, "", e);
}
return connectedDevices;
}
/**
- *
* Get a list of devices that match any of the given connection
* states.
*
@@ -155,15 +153,14 @@
* to know the state of the local adapter.
*
* @param profile GATT or GATT_SERVER
- * @param states Array of states. States can be one of
- * {@link BluetoothProfile#STATE_CONNECTED}, {@link BluetoothProfile#STATE_CONNECTING},
- * {@link BluetoothProfile#STATE_DISCONNECTED},
- * {@link BluetoothProfile#STATE_DISCONNECTING},
+ * @param states Array of states. States can be one of {@link BluetoothProfile#STATE_CONNECTED},
+ * {@link BluetoothProfile#STATE_CONNECTING}, {@link BluetoothProfile#STATE_DISCONNECTED},
+ * {@link BluetoothProfile#STATE_DISCONNECTING},
* @return List of devices. The list will be empty on error.
*/
@RequiresPermission(Manifest.permission.BLUETOOTH)
public List<BluetoothDevice> getDevicesMatchingConnectionStates(int profile, int[] states) {
- if (DBG) Log.d(TAG,"getDevicesMatchingConnectionStates");
+ if (DBG) Log.d(TAG, "getDevicesMatchingConnectionStates");
if (profile != BluetoothProfile.GATT && profile != BluetoothProfile.GATT_SERVER) {
throw new IllegalArgumentException("Profile not supported: " + profile);
@@ -177,7 +174,7 @@
if (iGatt == null) return devices;
devices = iGatt.getDevicesMatchingConnectionStates(states);
} catch (RemoteException e) {
- Log.e(TAG,"",e);
+ Log.e(TAG, "", e);
}
return devices;
@@ -189,14 +186,15 @@
* as the results of any other GATT server operations.
* The method returns a BluetoothGattServer instance. You can use BluetoothGattServer
* to conduct GATT server operations.
+ *
* @param context App context
* @param callback GATT server callback handler that will receive asynchronous callbacks.
* @return BluetoothGattServer instance
*/
public BluetoothGattServer openGattServer(Context context,
- BluetoothGattServerCallback callback) {
+ BluetoothGattServerCallback callback) {
- return (openGattServer (context, callback, BluetoothDevice.TRANSPORT_AUTO));
+ return (openGattServer(context, callback, BluetoothDevice.TRANSPORT_AUTO));
}
/**
@@ -205,16 +203,17 @@
* as the results of any other GATT server operations.
* The method returns a BluetoothGattServer instance. You can use BluetoothGattServer
* to conduct GATT server operations.
+ *
* @param context App context
* @param callback GATT server callback handler that will receive asynchronous callbacks.
- * @param transport preferred transport for GATT connections to remote dual-mode devices
- * {@link BluetoothDevice#TRANSPORT_AUTO} or
- * {@link BluetoothDevice#TRANSPORT_BREDR} or {@link BluetoothDevice#TRANSPORT_LE}
+ * @param transport preferred transport for GATT connections to remote dual-mode devices {@link
+ * BluetoothDevice#TRANSPORT_AUTO} or {@link BluetoothDevice#TRANSPORT_BREDR} or {@link
+ * BluetoothDevice#TRANSPORT_LE}
* @return BluetoothGattServer instance
* @hide
*/
public BluetoothGattServer openGattServer(Context context,
- BluetoothGattServerCallback callback,int transport) {
+ BluetoothGattServerCallback callback, int transport) {
if (context == null || callback == null) {
throw new IllegalArgumentException("null parameter: " + context + " " + callback);
}
@@ -229,11 +228,11 @@
Log.e(TAG, "Fail to get GATT Server connection");
return null;
}
- BluetoothGattServer mGattServer = new BluetoothGattServer(iGatt,transport);
+ BluetoothGattServer mGattServer = new BluetoothGattServer(iGatt, transport);
Boolean regStatus = mGattServer.registerCallback(callback);
- return regStatus? mGattServer : null;
+ return regStatus ? mGattServer : null;
} catch (RemoteException e) {
- Log.e(TAG,"",e);
+ Log.e(TAG, "", e);
return null;
}
}
diff --git a/framework/java/android/bluetooth/BluetoothMap.java b/framework/java/android/bluetooth/BluetoothMap.java
index 2e73051ee..30c0d3c 100644
--- a/framework/java/android/bluetooth/BluetoothMap.java
+++ b/framework/java/android/bluetooth/BluetoothMap.java
@@ -16,19 +16,23 @@
package android.bluetooth;
-import java.util.List;
-import java.util.ArrayList;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.ServiceConnection;
-import android.os.*;
+import android.os.Binder;
+import android.os.IBinder;
+import android.os.RemoteException;
import android.util.Log;
+import java.util.ArrayList;
+import java.util.List;
+
/**
* This class provides the APIs to control the Bluetooth MAP
* Profile.
- *@hide
+ *
+ * @hide
*/
public final class BluetoothMap implements BluetoothProfile {
@@ -37,7 +41,7 @@
private static final boolean VDBG = false;
public static final String ACTION_CONNECTION_STATE_CHANGED =
- "android.bluetooth.map.profile.action.CONNECTION_STATE_CHANGED";
+ "android.bluetooth.map.profile.action.CONNECTION_STATE_CHANGED";
private IBluetoothMap mService;
private final Context mContext;
@@ -45,7 +49,7 @@
private BluetoothAdapter mAdapter;
/** There was an error trying to obtain the state */
- public static final int STATE_ERROR = -1;
+ public static final int STATE_ERROR = -1;
public static final int RESULT_FAILURE = 0;
public static final int RESULT_SUCCESS = 1;
@@ -57,29 +61,29 @@
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...");
+ if (VDBG) Log.d(TAG, "Binding service...");
doBind();
}
} catch (Exception re) {
- Log.e(TAG,"",re);
+ Log.e(TAG, "", re);
}
}
}
}
- };
+ };
/**
* Create a BluetoothMap proxy object.
@@ -94,7 +98,7 @@
try {
mgr.registerStateChangeCallback(mBluetoothStateChangeCallback);
} catch (RemoteException e) {
- Log.e(TAG,"",e);
+ Log.e(TAG, "", e);
}
}
doBind();
@@ -132,7 +136,7 @@
try {
mgr.unregisterStateChangeCallback(mBluetoothStateChangeCallback);
} catch (Exception e) {
- Log.e(TAG,"",e);
+ Log.e(TAG, "", e);
}
}
@@ -142,7 +146,7 @@
mService = null;
mContext.unbindService(mConnection);
} catch (Exception re) {
- Log.e(TAG,"",re);
+ Log.e(TAG, "", re);
}
}
}
@@ -151,15 +155,18 @@
/**
* Get the current state of the BluetoothMap service.
- * @return One of the STATE_ return codes, or STATE_ERROR if this proxy
- * object is currently not connected to the Map service.
+ *
+ * @return One of the STATE_ return codes, or STATE_ERROR if this proxy object is currently not
+ * connected to the Map service.
*/
public int getState() {
if (VDBG) log("getState()");
if (mService != null) {
try {
return mService.getState();
- } 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(Log.getStackTraceString(new Throwable()));
@@ -169,16 +176,18 @@
/**
* Get the currently connected remote Bluetooth device (PCE).
- * @return The remote Bluetooth device, or null if not in connected or
- * connecting state, or if this proxy object is not connected to
- * the Map service.
+ *
+ * @return The remote Bluetooth device, or null if not in connected or connecting state, or if
+ * this proxy object is not connected to the Map service.
*/
public BluetoothDevice getClient() {
if (VDBG) log("getClient()");
if (mService != null) {
try {
return mService.getClient();
- } 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(Log.getStackTraceString(new Throwable()));
@@ -196,7 +205,9 @@
if (mService != null) {
try {
return mService.isConnected(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(Log.getStackTraceString(new Throwable()));
@@ -217,18 +228,17 @@
* Initiate disconnect.
*
* @param device Remote Bluetooth Device
- * @return false on error,
- * true otherwise
+ * @return false on error, true otherwise
*/
public boolean disconnect(BluetoothDevice device) {
if (DBG) log("disconnect(" + device + ")");
if (mService != null && isEnabled() &&
- isValidDevice(device)) {
+ 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");
@@ -240,18 +250,19 @@
* This is a simple heuristic that tries to guess if a device with the
* given class bits might support Map. It is not accurate for all
* devices. It tries to err on the side of false positives.
+ *
* @return True if this device might support Map.
*/
public static boolean doesClassMatchSink(BluetoothClass btClass) {
// TODO optimize the rule
switch (btClass.getDeviceClass()) {
- case BluetoothClass.Device.COMPUTER_DESKTOP:
- case BluetoothClass.Device.COMPUTER_LAPTOP:
- case BluetoothClass.Device.COMPUTER_SERVER:
- case BluetoothClass.Device.COMPUTER_UNCATEGORIZED:
- return true;
- default:
- return false;
+ case BluetoothClass.Device.COMPUTER_DESKTOP:
+ case BluetoothClass.Device.COMPUTER_LAPTOP:
+ case BluetoothClass.Device.COMPUTER_SERVER:
+ case BluetoothClass.Device.COMPUTER_UNCATEGORIZED:
+ return true;
+ default:
+ return false;
}
}
@@ -301,7 +312,7 @@
public int getConnectionState(BluetoothDevice device) {
if (DBG) log("getConnectionState(" + device + ")");
if (mService != null && isEnabled() &&
- isValidDevice(device)) {
+ isValidDevice(device)) {
try {
return mService.getConnectionState(device);
} catch (RemoteException e) {
@@ -317,7 +328,7 @@
* 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},
*
* @param device Paired bluetooth device
@@ -327,10 +338,10 @@
public boolean setPriority(BluetoothDevice device, int priority) {
if (DBG) log("setPriority(" + device + ", " + priority + ")");
if (mService != null && isEnabled() &&
- isValidDevice(device)) {
+ isValidDevice(device)) {
if (priority != BluetoothProfile.PRIORITY_OFF &&
- priority != BluetoothProfile.PRIORITY_ON) {
- return false;
+ priority != BluetoothProfile.PRIORITY_ON) {
+ return false;
}
try {
return mService.setPriority(device, priority);
@@ -356,7 +367,7 @@
public int getPriority(BluetoothDevice device) {
if (VDBG) log("getPriority(" + device + ")");
if (mService != null && isEnabled() &&
- isValidDevice(device)) {
+ isValidDevice(device)) {
try {
return mService.getPriority(device);
} catch (RemoteException e) {
@@ -376,6 +387,7 @@
mServiceListener.onServiceConnected(BluetoothProfile.MAP, BluetoothMap.this);
}
}
+
public void onServiceDisconnected(ComponentName className) {
if (DBG) log("Proxy object disconnected");
mService = null;
@@ -389,17 +401,18 @@
Log.d(TAG, msg);
}
- private boolean isEnabled() {
+ private boolean isEnabled() {
BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter();
if (adapter != null && adapter.getState() == BluetoothAdapter.STATE_ON) return true;
log("Bluetooth is Not enabled");
return false;
}
- private boolean isValidDevice(BluetoothDevice device) {
- if (device == null) return false;
- if (BluetoothAdapter.checkBluetoothAddress(device.getAddress())) return true;
- return false;
+ private boolean isValidDevice(BluetoothDevice device) {
+ if (device == null) return false;
+
+ if (BluetoothAdapter.checkBluetoothAddress(device.getAddress())) return true;
+ return false;
}
diff --git a/framework/java/android/bluetooth/BluetoothMapClient.java b/framework/java/android/bluetooth/BluetoothMapClient.java
index ccab3cd..09dd5ad 100644
--- a/framework/java/android/bluetooth/BluetoothMapClient.java
+++ b/framework/java/android/bluetooth/BluetoothMapClient.java
@@ -347,10 +347,10 @@
*
* Send an SMS message to either the contacts primary number or the telephone number specified.
*
- * @param device Bluetooth device
- * @param contacts Uri[] of the contacts
- * @param message Message to be sent
- * @param sentIntent intent issued when message is sent
+ * @param device Bluetooth device
+ * @param contacts Uri[] of the contacts
+ * @param message Message to be sent
+ * @param sentIntent intent issued when message is sent
* @param deliveredIntent intent issued when message is delivered
* @return true if the message is enqueued, false on error
*/
@@ -393,7 +393,7 @@
mService = IBluetoothMapClient.Stub.asInterface(service);
if (mServiceListener != null) {
mServiceListener.onServiceConnected(BluetoothProfile.MAP_CLIENT,
- BluetoothMapClient.this);
+ BluetoothMapClient.this);
}
}
diff --git a/framework/java/android/bluetooth/BluetoothMasInstance.java b/framework/java/android/bluetooth/BluetoothMasInstance.java
index 4459e2c..8447282 100644
--- a/framework/java/android/bluetooth/BluetoothMasInstance.java
+++ b/framework/java/android/bluetooth/BluetoothMasInstance.java
@@ -36,7 +36,7 @@
@Override
public boolean equals(Object o) {
if (o instanceof BluetoothMasInstance) {
- return mId == ((BluetoothMasInstance)o).mId;
+ return mId == ((BluetoothMasInstance) o).mId;
}
return false;
}
@@ -58,14 +58,15 @@
public static final Parcelable.Creator<BluetoothMasInstance> CREATOR =
new Parcelable.Creator<BluetoothMasInstance>() {
- public BluetoothMasInstance createFromParcel(Parcel in) {
- return new BluetoothMasInstance(in.readInt(), in.readString(),
- in.readInt(), in.readInt());
- }
- public BluetoothMasInstance[] newArray(int size) {
- return new BluetoothMasInstance[size];
- }
- };
+ public BluetoothMasInstance createFromParcel(Parcel in) {
+ return new BluetoothMasInstance(in.readInt(), in.readString(),
+ in.readInt(), in.readInt());
+ }
+
+ public BluetoothMasInstance[] newArray(int size) {
+ return new BluetoothMasInstance[size];
+ }
+ };
public void writeToParcel(Parcel out, int flags) {
out.writeInt(mId);
@@ -75,10 +76,10 @@
}
public static final class MessageType {
- public static final int EMAIL = 0x01;
- public static final int SMS_GSM = 0x02;
+ public static final int EMAIL = 0x01;
+ public static final int SMS_GSM = 0x02;
public static final int SMS_CDMA = 0x04;
- public static final int MMS = 0x08;
+ public static final int MMS = 0x08;
}
public int getId() {
diff --git a/framework/java/android/bluetooth/BluetoothOutputStream.java b/framework/java/android/bluetooth/BluetoothOutputStream.java
index 117dd47..cecd3db 100644
--- a/framework/java/android/bluetooth/BluetoothOutputStream.java
+++ b/framework/java/android/bluetooth/BluetoothOutputStream.java
@@ -44,15 +44,13 @@
* Writes a single byte to this stream. Only the least significant byte of
* the integer {@code oneByte} is written to the stream.
*
- * @param oneByte
- * the byte to be written.
- * @throws IOException
- * if an error occurs while writing to this stream.
+ * @param oneByte the byte to be written.
+ * @throws IOException if an error occurs while writing to this stream.
* @since Android 1.0
*/
public void write(int oneByte) throws IOException {
byte b[] = new byte[1];
- b[0] = (byte)oneByte;
+ b[0] = (byte) oneByte;
mSocket.write(b, 0, 1);
}
@@ -60,19 +58,12 @@
* Writes {@code count} bytes from the byte array {@code buffer} starting
* at position {@code offset} to this stream.
*
- * @param b
- * the buffer to be written.
- * @param offset
- * the start position in {@code buffer} from where to get bytes.
- * @param count
- * the number of bytes from {@code buffer} to write to this
- * stream.
- * @throws IOException
- * if an error occurs while writing to this stream.
- * @throws IndexOutOfBoundsException
- * if {@code offset < 0} or {@code count < 0}, or if
- * {@code offset + count} is bigger than the length of
- * {@code buffer}.
+ * @param b the buffer to be written.
+ * @param offset the start position in {@code buffer} from where to get bytes.
+ * @param count the number of bytes from {@code buffer} to write to this stream.
+ * @throws IOException if an error occurs while writing to this stream.
+ * @throws IndexOutOfBoundsException if {@code offset < 0} or {@code count < 0}, or if {@code
+ * offset + count} is bigger than the length of {@code buffer}.
* @since Android 1.0
*/
public void write(byte[] b, int offset, int count) throws IOException {
@@ -84,15 +75,16 @@
}
mSocket.write(b, offset, count);
}
+
/**
* Wait until the data in sending queue is emptied. A polling version
* for flush implementation. Use it to ensure the writing data afterwards will
* be packed in the new RFCOMM frame.
- * @throws IOException
- * if an i/o error occurs.
+ *
+ * @throws IOException if an i/o error occurs.
* @since Android 4.2.3
*/
- public void flush() throws IOException {
+ public void flush() throws IOException {
mSocket.flush();
}
}
diff --git a/framework/java/android/bluetooth/BluetoothPan.java b/framework/java/android/bluetooth/BluetoothPan.java
index 2a026a9..4c00649 100644
--- a/framework/java/android/bluetooth/BluetoothPan.java
+++ b/framework/java/android/bluetooth/BluetoothPan.java
@@ -34,12 +34,13 @@
* This class provides the APIs to control the Bluetooth Pan
* Profile.
*
- *<p>BluetoothPan is a proxy object for controlling the Bluetooth
+ * <p>BluetoothPan is a proxy object for controlling the Bluetooth
* Service via IPC. Use {@link BluetoothAdapter#getProfileProxy} to get
* the BluetoothPan proxy object.
*
- *<p>Each method is protected with its appropriate permission.
- *@hide
+ * <p>Each method is protected with its appropriate permission.
+ *
+ * @hide
*/
public final class BluetoothPan implements BluetoothProfile {
private static final String TAG = "BluetoothPan";
@@ -52,11 +53,11 @@
*
* <p>This intent will have 4 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_LOCAL_ROLE} - Which local role the remote device is
- * bound to. </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>
+ * <li> {@link #EXTRA_LOCAL_ROLE} - Which local role the remote device is
+ * bound to. </li>
* </ul>
*
* <p>{@link #EXTRA_STATE} or {@link #EXTRA_PREVIOUS_STATE} can be any of
@@ -70,7 +71,7 @@
*/
@SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
public static final String ACTION_CONNECTION_STATE_CHANGED =
- "android.bluetooth.pan.profile.action.CONNECTION_STATE_CHANGED";
+ "android.bluetooth.pan.profile.action.CONNECTION_STATE_CHANGED";
/**
* Extra for {@link #ACTION_CONNECTION_STATE_CHANGED} intent
@@ -94,6 +95,7 @@
/**
* Return codes for the connect and disconnect Bluez / Dbus calls.
+ *
* @hide
*/
public static final int PAN_DISCONNECT_FAILED_NOT_CONNECTED = 1000;
@@ -126,7 +128,6 @@
/**
* Create a BluetoothPan proxy object for interacting with the local
* Bluetooth Service which handles the Pan profile
- *
*/
/*package*/ BluetoothPan(Context context, ServiceListener l) {
mContext = context;
@@ -135,7 +136,7 @@
try {
mAdapter.getBluetoothManager().registerStateChangeCallback(mStateChangeCallback);
} catch (RemoteException re) {
- Log.w(TAG,"Unable to register BluetoothStateChangeCallback",re);
+ Log.w(TAG, "Unable to register BluetoothStateChangeCallback", re);
}
if (VDBG) Log.d(TAG, "BluetoothPan() call bindService");
doBind();
@@ -161,7 +162,7 @@
try {
mgr.unregisterStateChangeCallback(mStateChangeCallback);
} catch (RemoteException re) {
- Log.w(TAG,"Unable to unregister BluetoothStateChangeCallback",re);
+ Log.w(TAG, "Unable to unregister BluetoothStateChangeCallback", re);
}
}
@@ -171,7 +172,7 @@
mPanService = null;
mContext.unbindService(mConnection);
} catch (Exception re) {
- Log.e(TAG,"",re);
+ Log.e(TAG, "", re);
}
}
}
@@ -182,38 +183,41 @@
close();
}
- final private IBluetoothStateChangeCallback mStateChangeCallback = new IBluetoothStateChangeCallback.Stub() {
+ final private IBluetoothStateChangeCallback mStateChangeCallback =
+ new IBluetoothStateChangeCallback.Stub() {
- @Override
- public void onBluetoothStateChange(boolean on) {
- // Handle enable request to bind again.
- Log.d(TAG, "onBluetoothStateChange on: " + on);
- if (on) {
- try {
- if (mPanService == null) {
- if (VDBG) Log.d(TAG, "onBluetoothStateChange calling doBind()");
- doBind();
- }
+ @Override
+ public void onBluetoothStateChange(boolean on) {
+ // Handle enable request to bind again.
+ Log.d(TAG, "onBluetoothStateChange on: " + on);
+ if (on) {
+ try {
+ if (mPanService == null) {
+ if (VDBG) Log.d(TAG, "onBluetoothStateChange calling doBind()");
+ doBind();
+ }
- } catch (IllegalStateException e) {
- Log.e(TAG,"onBluetoothStateChange: could not bind to PAN service: ", e);
+ } catch (IllegalStateException e) {
+ Log.e(TAG, "onBluetoothStateChange: could not bind to PAN service: ",
+ e);
- } catch (SecurityException e) {
- Log.e(TAG,"onBluetoothStateChange: could not bind to PAN service: ", e);
- }
- } else {
- if (VDBG) Log.d(TAG,"Unbinding service...");
- synchronized (mConnection) {
- try {
- mPanService = null;
- mContext.unbindService(mConnection);
- } catch (Exception re) {
- Log.e(TAG,"",re);
+ } catch (SecurityException e) {
+ Log.e(TAG, "onBluetoothStateChange: could not bind to PAN service: ",
+ e);
+ }
+ } else {
+ if (VDBG) Log.d(TAG, "Unbinding service...");
+ synchronized (mConnection) {
+ try {
+ mPanService = null;
+ mContext.unbindService(mConnection);
+ } catch (Exception re) {
+ Log.e(TAG, "", re);
+ }
+ }
}
}
- }
- }
- };
+ };
/**
* Initiate connection to a profile of the remote bluetooth device.
@@ -229,14 +233,13 @@
* 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 (mPanService != null && isEnabled() &&
- isValidDevice(device)) {
+ isValidDevice(device)) {
try {
return mPanService.connect(device);
} catch (RemoteException e) {
@@ -270,14 +273,13 @@
* 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 (mPanService != null && isEnabled() &&
- isValidDevice(device)) {
+ isValidDevice(device)) {
try {
return mPanService.disconnect(device);
} catch (RemoteException e) {
@@ -329,7 +331,7 @@
public int getConnectionState(BluetoothDevice device) {
if (VDBG) log("getState(" + device + ")");
if (mPanService != null && isEnabled()
- && isValidDevice(device)) {
+ && isValidDevice(device)) {
try {
return mPanService.getConnectionState(device);
} catch (RemoteException e) {
@@ -373,9 +375,10 @@
if (mServiceListener != null) {
mServiceListener.onServiceConnected(BluetoothProfile.PAN,
- BluetoothPan.this);
+ BluetoothPan.this);
}
}
+
public void onServiceDisconnected(ComponentName className) {
if (DBG) Log.d(TAG, "BluetoothPAN Proxy object disconnected");
mPanService = null;
@@ -386,18 +389,18 @@
};
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) {
- Log.d(TAG, msg);
+ Log.d(TAG, msg);
}
}
diff --git a/framework/java/android/bluetooth/BluetoothPbap.java b/framework/java/android/bluetooth/BluetoothPbap.java
index dc01fc7..fe7ce1d 100644
--- a/framework/java/android/bluetooth/BluetoothPbap.java
+++ b/framework/java/android/bluetooth/BluetoothPbap.java
@@ -20,8 +20,8 @@
import android.content.Context;
import android.content.Intent;
import android.content.ServiceConnection;
-import android.os.RemoteException;
import android.os.IBinder;
+import android.os.RemoteException;
import android.util.Log;
/**
@@ -55,17 +55,18 @@
/** int extra for PBAP_STATE_CHANGED_ACTION */
public static final String PBAP_STATE =
- "android.bluetooth.pbap.intent.PBAP_STATE";
+ "android.bluetooth.pbap.intent.PBAP_STATE";
/** int extra for PBAP_STATE_CHANGED_ACTION */
public static final String PBAP_PREVIOUS_STATE =
- "android.bluetooth.pbap.intent.PBAP_PREVIOUS_STATE";
+ "android.bluetooth.pbap.intent.PBAP_PREVIOUS_STATE";
- /** Indicates the state of a pbap connection state has changed.
- * This intent will always contain PBAP_STATE, PBAP_PREVIOUS_STATE and
- * BluetoothIntent.ADDRESS extras.
+ /**
+ * Indicates the state of a pbap connection state has changed.
+ * This intent will always contain PBAP_STATE, PBAP_PREVIOUS_STATE and
+ * BluetoothIntent.ADDRESS extras.
*/
public static final String PBAP_STATE_CHANGED_ACTION =
- "android.bluetooth.pbap.intent.action.PBAP_STATE_CHANGED";
+ "android.bluetooth.pbap.intent.action.PBAP_STATE_CHANGED";
private IBluetoothPbap mService;
private final Context mContext;
@@ -73,13 +74,13 @@
private BluetoothAdapter mAdapter;
/** There was an error trying to obtain the state */
- public static final int STATE_ERROR = -1;
+ public static final int STATE_ERROR = -1;
/** No client currently connected */
public static final int STATE_DISCONNECTED = 0;
/** Connection attempt in progress */
- public static final int STATE_CONNECTING = 1;
+ public static final int STATE_CONNECTING = 1;
/** Client is currently connected */
- public static final int STATE_CONNECTED = 2;
+ public static final int STATE_CONNECTED = 2;
public static final int RESULT_FAILURE = 0;
public static final int RESULT_SUCCESS = 1;
@@ -114,29 +115,29 @@
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...");
+ if (VDBG) Log.d(TAG, "Binding service...");
doBind();
}
} catch (Exception re) {
- Log.e(TAG,"",re);
+ Log.e(TAG, "", re);
}
}
}
}
- };
+ };
/**
* Create a BluetoothPbap proxy object.
@@ -150,7 +151,7 @@
try {
mgr.registerStateChangeCallback(mBluetoothStateChangeCallback);
} catch (RemoteException e) {
- Log.e(TAG,"",e);
+ Log.e(TAG, "", e);
}
}
doBind();
@@ -188,7 +189,7 @@
try {
mgr.unregisterStateChangeCallback(mBluetoothStateChangeCallback);
} catch (Exception e) {
- Log.e(TAG,"",e);
+ Log.e(TAG, "", e);
}
}
@@ -198,7 +199,7 @@
mService = null;
mContext.unbindService(mConnection);
} catch (Exception re) {
- Log.e(TAG,"",re);
+ Log.e(TAG, "", re);
}
}
}
@@ -207,15 +208,18 @@
/**
* Get the current state of the BluetoothPbap service.
- * @return One of the STATE_ return codes, or STATE_ERROR if this proxy
- * object is currently not connected to the Pbap service.
+ *
+ * @return One of the STATE_ return codes, or STATE_ERROR if this proxy object is currently not
+ * connected to the Pbap service.
*/
public int getState() {
if (VDBG) log("getState()");
if (mService != null) {
try {
return mService.getState();
- } 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(Log.getStackTraceString(new Throwable()));
@@ -225,16 +229,18 @@
/**
* Get the currently connected remote Bluetooth device (PCE).
- * @return The remote Bluetooth device, or null if not in connected or
- * connecting state, or if this proxy object is not connected to
- * the Pbap service.
+ *
+ * @return The remote Bluetooth device, or null if not in connected or connecting state, or if
+ * this proxy object is not connected to the Pbap service.
*/
public BluetoothDevice getClient() {
if (VDBG) log("getClient()");
if (mService != null) {
try {
return mService.getClient();
- } 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(Log.getStackTraceString(new Throwable()));
@@ -252,7 +258,9 @@
if (mService != null) {
try {
return mService.isConnected(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(Log.getStackTraceString(new Throwable()));
@@ -271,7 +279,9 @@
try {
mService.disconnect();
return true;
- } 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(Log.getStackTraceString(new Throwable()));
@@ -284,18 +294,19 @@
* This is a simple heuristic that tries to guess if a device with the
* given class bits might support PBAP. It is not accurate for all
* devices. It tries to err on the side of false positives.
+ *
* @return True if this device might support PBAP.
*/
public static boolean doesClassMatchSink(BluetoothClass btClass) {
// TODO optimize the rule
switch (btClass.getDeviceClass()) {
- case BluetoothClass.Device.COMPUTER_DESKTOP:
- case BluetoothClass.Device.COMPUTER_LAPTOP:
- case BluetoothClass.Device.COMPUTER_SERVER:
- case BluetoothClass.Device.COMPUTER_UNCATEGORIZED:
- return true;
- default:
- return false;
+ case BluetoothClass.Device.COMPUTER_DESKTOP:
+ case BluetoothClass.Device.COMPUTER_LAPTOP:
+ case BluetoothClass.Device.COMPUTER_SERVER:
+ case BluetoothClass.Device.COMPUTER_UNCATEGORIZED:
+ return true;
+ default:
+ return false;
}
}
@@ -307,6 +318,7 @@
mServiceListener.onServiceConnected(BluetoothPbap.this);
}
}
+
public void onServiceDisconnected(ComponentName className) {
if (DBG) log("Proxy object disconnected");
mService = null;
diff --git a/framework/java/android/bluetooth/BluetoothPbapClient.java b/framework/java/android/bluetooth/BluetoothPbapClient.java
index 9f00e1a..3d6d002 100644
--- a/framework/java/android/bluetooth/BluetoothPbapClient.java
+++ b/framework/java/android/bluetooth/BluetoothPbapClient.java
@@ -16,20 +16,22 @@
package android.bluetooth;
-import java.util.List;
-import java.util.ArrayList;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.ServiceConnection;
-import android.os.RemoteException;
import android.os.Binder;
import android.os.IBinder;
+import android.os.RemoteException;
import android.util.Log;
+import java.util.ArrayList;
+import java.util.List;
+
/**
* This class provides the APIs to control the Bluetooth PBAP Client Profile.
- *@hide
+ *
+ * @hide
*/
public final class BluetoothPbapClient implements BluetoothProfile {
@@ -38,7 +40,7 @@
private static final boolean VDBG = false;
public static final String ACTION_CONNECTION_STATE_CHANGED =
- "android.bluetooth.pbap.profile.action.CONNECTION_STATE_CHANGED";
+ "android.bluetooth.pbap.profile.action.CONNECTION_STATE_CHANGED";
private IBluetoothPbapClient mService;
private final Context mContext;
@@ -46,7 +48,7 @@
private BluetoothAdapter mAdapter;
/** There was an error trying to obtain the state */
- public static final int STATE_ERROR = -1;
+ public static final int STATE_ERROR = -1;
public static final int RESULT_FAILURE = 0;
public static final int RESULT_SUCCESS = 1;
@@ -61,14 +63,14 @@
}
if (!up) {
if (VDBG) {
- Log.d(TAG,"Unbinding service...");
+ 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 {
@@ -76,17 +78,17 @@
try {
if (mService == null) {
if (VDBG) {
- Log.d(TAG,"Binding service...");
+ Log.d(TAG, "Binding service...");
}
doBind();
}
} catch (Exception re) {
- Log.e(TAG,"",re);
+ Log.e(TAG, "", re);
}
}
}
}
- };
+ };
/**
* Create a BluetoothPbapClient proxy object.
@@ -103,7 +105,7 @@
try {
mgr.registerStateChangeCallback(mBluetoothStateChangeCallback);
} catch (RemoteException e) {
- Log.e(TAG,"",e);
+ Log.e(TAG, "", e);
}
}
doBind();
@@ -141,7 +143,7 @@
try {
mgr.unregisterStateChangeCallback(mBluetoothStateChangeCallback);
} catch (Exception e) {
- Log.e(TAG,"",e);
+ Log.e(TAG, "", e);
}
}
@@ -151,7 +153,7 @@
mService = null;
mContext.unbindService(mConnection);
} catch (Exception re) {
- Log.e(TAG,"",re);
+ Log.e(TAG, "", re);
}
}
}
@@ -163,9 +165,9 @@
* Upon successful connection to remote PBAP server the Client will
* attempt to automatically download the users phonebook and call log.
*
- * @param device a remote device we want connect to
- * @return <code>true</code> if command has been issued successfully;
- * <code>false</code> otherwise;
+ * @param device a remote device we want connect to
+ * @return <code>true</code> if command has been issued successfully; <code>false</code>
+ * otherwise;
*/
public boolean connect(BluetoothDevice device) {
if (DBG) {
@@ -189,20 +191,19 @@
* Initiate disconnect.
*
* @param device Remote Bluetooth Device
- * @return false on error,
- * true otherwise
+ * @return false on error, true otherwise
*/
public boolean disconnect(BluetoothDevice device) {
if (DBG) {
- log("disconnect(" + device + ")" + new Exception() );
+ log("disconnect(" + device + ")" + new Exception());
}
if (mService != null && isEnabled() && isValidDevice(device)) {
try {
mService.disconnect(device);
return true;
} catch (RemoteException e) {
- Log.e(TAG, Log.getStackTraceString(new Throwable()));
- return false;
+ Log.e(TAG, Log.getStackTraceString(new Throwable()));
+ return false;
}
}
if (mService == null) {
@@ -291,9 +292,11 @@
}
mService = IBluetoothPbapClient.Stub.asInterface(Binder.allowBlocking(service));
if (mServiceListener != null) {
- mServiceListener.onServiceConnected(BluetoothProfile.PBAP_CLIENT, BluetoothPbapClient.this);
+ mServiceListener.onServiceConnected(BluetoothProfile.PBAP_CLIENT,
+ BluetoothPbapClient.this);
}
}
+
public void onServiceDisconnected(ComponentName className) {
if (DBG) {
log("Proxy object disconnected");
@@ -319,20 +322,20 @@
}
private boolean isValidDevice(BluetoothDevice device) {
- if (device == null) {
- return false;
- }
- if (BluetoothAdapter.checkBluetoothAddress(device.getAddress())) {
- return true;
- }
- return false;
+ if (device == null) {
+ return false;
+ }
+ if (BluetoothAdapter.checkBluetoothAddress(device.getAddress())) {
+ return true;
+ }
+ return false;
}
/**
* 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},
*
* @param device Paired bluetooth device
@@ -344,10 +347,10 @@
log("setPriority(" + device + ", " + priority + ")");
}
if (mService != null && isEnabled() &&
- isValidDevice(device)) {
+ isValidDevice(device)) {
if (priority != BluetoothProfile.PRIORITY_OFF &&
- priority != BluetoothProfile.PRIORITY_ON) {
- return false;
+ priority != BluetoothProfile.PRIORITY_ON) {
+ return false;
}
try {
return mService.setPriority(device, priority);
diff --git a/framework/java/android/bluetooth/BluetoothProfile.java b/framework/java/android/bluetooth/BluetoothProfile.java
index c5b58e9..9192ec4 100644
--- a/framework/java/android/bluetooth/BluetoothProfile.java
+++ b/framework/java/android/bluetooth/BluetoothProfile.java
@@ -46,14 +46,14 @@
* Bluetooth device.
*/
public static final String EXTRA_PREVIOUS_STATE =
- "android.bluetooth.profile.extra.PREVIOUS_STATE";
+ "android.bluetooth.profile.extra.PREVIOUS_STATE";
/** The profile is in disconnected state */
- public static final int STATE_DISCONNECTED = 0;
+ public static final int STATE_DISCONNECTED = 0;
/** The profile is in connecting state */
- public static final int STATE_CONNECTING = 1;
+ public static final int STATE_CONNECTING = 1;
/** The profile is in connected state */
- public static final int STATE_CONNECTED = 2;
+ public static final int STATE_CONNECTED = 2;
/** The profile is in disconnecting state */
public static final int STATE_DISCONNECTING = 3;
@@ -74,18 +74,21 @@
/**
* Input Device Profile
+ *
* @hide
*/
public static final int INPUT_DEVICE = 4;
/**
* PAN Profile
+ *
* @hide
*/
public static final int PAN = 5;
/**
* PBAP
+ *
* @hide
*/
public static final int PBAP = 6;
@@ -102,6 +105,7 @@
/**
* MAP Profile
+ *
* @hide
*/
public static final int MAP = 9;
@@ -114,36 +118,42 @@
/**
* A2DP Sink Profile
+ *
* @hide
*/
public static final int A2DP_SINK = 11;
/**
* AVRCP Controller Profile
+ *
* @hide
*/
public static final int AVRCP_CONTROLLER = 12;
/**
* Headset Client - HFP HF Role
+ *
* @hide
*/
public static final int HEADSET_CLIENT = 16;
/**
* PBAP Client
+ *
* @hide
*/
public static final int PBAP_CLIENT = 17;
/**
* MAP Messaging Client Equipment (MCE)
+ *
* @hide
*/
public static final int MAP_CLIENT = 18;
/**
* Input Host
+ *
* @hide
*/
static public final int INPUT_HOST = 19;
@@ -151,6 +161,7 @@
/**
* Max profile ID. This value should be updated whenever a new profile is added to match
* the largest value assigned to a profile.
+ *
* @hide
*/
public static final int MAX_PROFILE_ID = 19;
@@ -158,13 +169,15 @@
/**
* Default priority for devices that we try to auto-connect to and
* and allow incoming connections for the profile
+ *
* @hide
**/
public static final int PRIORITY_AUTO_CONNECT = 1000;
/**
- * Default priority for devices that allow incoming
+ * Default priority for devices that allow incoming
* and outgoing connections for the profile
+ *
* @hide
**/
public static final int PRIORITY_ON = 100;
@@ -172,14 +185,16 @@
/**
* Default priority for devices that does not allow incoming
* connections and outgoing connections for the profile.
+ *
* @hide
**/
public static final int PRIORITY_OFF = 0;
/**
* Default priority when not set or when the device is unpaired
+ *
* @hide
- * */
+ */
public static final int PRIORITY_UNDEFINED = -1;
/**
@@ -199,9 +214,8 @@
* <p> If none of the devices match any of the given states,
* an empty list will be returned.
*
- * @param states Array of states. States can be one of
- * {@link #STATE_CONNECTED}, {@link #STATE_CONNECTING},
- * {@link #STATE_DISCONNECTED}, {@link #STATE_DISCONNECTING},
+ * @param states Array of states. States can be one of {@link #STATE_CONNECTED}, {@link
+ * #STATE_CONNECTING}, {@link #STATE_DISCONNECTED}, {@link #STATE_DISCONNECTING},
* @return List of devices. The list will be empty on error.
*/
@RequiresPermission(Manifest.permission.BLUETOOTH)
@@ -211,9 +225,8 @@
* Get the current connection state of the profile
*
* @param device Remote bluetooth device.
- * @return State of the profile connection. One of
- * {@link #STATE_CONNECTED}, {@link #STATE_CONNECTING},
- * {@link #STATE_DISCONNECTED}, {@link #STATE_DISCONNECTING}
+ * @return State of the profile connection. One of {@link #STATE_CONNECTED}, {@link
+ * #STATE_CONNECTING}, {@link #STATE_DISCONNECTED}, {@link #STATE_DISCONNECTING}
*/
@RequiresPermission(Manifest.permission.BLUETOOTH)
public int getConnectionState(BluetoothDevice device);
@@ -226,18 +239,18 @@
/**
* Called to notify the client when the proxy object has been
* connected to the service.
- * @param profile - One of {@link #HEALTH}, {@link #HEADSET} or
- * {@link #A2DP}
- * @param proxy - One of {@link BluetoothHealth}, {@link BluetoothHeadset} or
- * {@link BluetoothA2dp}
+ *
+ * @param profile - One of {@link #HEALTH}, {@link #HEADSET} or {@link #A2DP}
+ * @param proxy - One of {@link BluetoothHealth}, {@link BluetoothHeadset} or {@link
+ * BluetoothA2dp}
*/
public void onServiceConnected(int profile, BluetoothProfile proxy);
/**
* Called to notify the client that this proxy object has been
* disconnected from the service.
- * @param profile - One of {@link #HEALTH}, {@link #HEADSET} or
- * {@link #A2DP}
+ *
+ * @param profile - One of {@link #HEALTH}, {@link #HEADSET} or {@link #A2DP}
*/
public void onServiceDisconnected(int profile);
}
diff --git a/framework/java/android/bluetooth/BluetoothSap.java b/framework/java/android/bluetooth/BluetoothSap.java
index 89c1bf8..ea635b2 100644
--- a/framework/java/android/bluetooth/BluetoothSap.java
+++ b/framework/java/android/bluetooth/BluetoothSap.java
@@ -16,19 +16,18 @@
package android.bluetooth;
-import java.util.ArrayList;
-import java.util.List;
-
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.ServiceConnection;
-import android.os.RemoteException;
import android.os.Binder;
import android.os.IBinder;
-import android.os.ServiceManager;
+import android.os.RemoteException;
import android.util.Log;
+import java.util.ArrayList;
+import java.util.List;
+
/**
* This class provides the APIs to control the Bluetooth SIM
* Access Profile (SAP).
@@ -38,6 +37,7 @@
* the BluetoothSap proxy object.
*
* <p>Each method is protected with its appropriate permission.
+ *
* @hide
*/
public final class BluetoothSap implements BluetoothProfile {
@@ -51,9 +51,9 @@
*
* <p>This intent will have 4 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
@@ -62,10 +62,11 @@
*
* <p>Requires {@link android.Manifest.permission#BLUETOOTH} permission to
* receive.
+ *
* @hide
*/
public static final String ACTION_CONNECTION_STATE_CHANGED =
- "android.bluetooth.sap.profile.action.CONNECTION_STATE_CHANGED";
+ "android.bluetooth.sap.profile.action.CONNECTION_STATE_CHANGED";
private IBluetoothSap mService;
private final Context mContext;
@@ -74,18 +75,21 @@
/**
* There was an error trying to obtain the state.
+ *
* @hide
*/
public static final int STATE_ERROR = -1;
/**
* Connection state change succceeded.
+ *
* @hide
*/
public static final int RESULT_SUCCESS = 1;
/**
* Connection canceled before completion.
+ *
* @hide
*/
public static final int RESULT_CANCELED = 2;
@@ -95,29 +99,29 @@
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...");
+ if (VDBG) Log.d(TAG, "Binding service...");
doBind();
}
} catch (Exception re) {
- Log.e(TAG,"",re);
+ Log.e(TAG, "", re);
}
}
}
}
- };
+ };
/**
* Create a BluetoothSap proxy object.
@@ -132,7 +136,7 @@
try {
mgr.registerStateChangeCallback(mBluetoothStateChangeCallback);
} catch (RemoteException e) {
- Log.e(TAG,"",e);
+ Log.e(TAG, "", e);
}
}
doBind();
@@ -163,6 +167,7 @@
* Other public functions of BluetoothSap will return default error
* results once close() has been called. Multiple invocations of close()
* are ok.
+ *
* @hide
*/
public synchronized void close() {
@@ -171,7 +176,7 @@
try {
mgr.unregisterStateChangeCallback(mBluetoothStateChangeCallback);
} catch (Exception e) {
- Log.e(TAG,"",e);
+ Log.e(TAG, "", e);
}
}
@@ -181,7 +186,7 @@
mService = null;
mContext.unbindService(mConnection);
} catch (Exception re) {
- Log.e(TAG,"",re);
+ Log.e(TAG, "", re);
}
}
}
@@ -190,8 +195,9 @@
/**
* Get the current state of the BluetoothSap service.
- * @return One of the STATE_ return codes, or STATE_ERROR if this proxy
- * object is currently not connected to the Sap service.
+ *
+ * @return One of the STATE_ return codes, or STATE_ERROR if this proxy object is currently not
+ * connected to the Sap service.
* @hide
*/
public int getState() {
@@ -199,7 +205,9 @@
if (mService != null) {
try {
return mService.getState();
- } 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(Log.getStackTraceString(new Throwable()));
@@ -209,9 +217,9 @@
/**
* Get the currently connected remote Bluetooth device (PCE).
- * @return The remote Bluetooth device, or null if not in connected or
- * connecting state, or if this proxy object is not connected to
- * the Sap service.
+ *
+ * @return The remote Bluetooth device, or null if not in connected or connecting state, or if
+ * this proxy object is not connected to the Sap service.
* @hide
*/
public BluetoothDevice getClient() {
@@ -219,7 +227,9 @@
if (mService != null) {
try {
return mService.getClient();
- } 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(Log.getStackTraceString(new Throwable()));
@@ -231,6 +241,7 @@
* Returns true if the specified Bluetooth device is connected.
* Returns false if not connected, or if this proxy object is not
* currently connected to the Sap service.
+ *
* @hide
*/
public boolean isConnected(BluetoothDevice device) {
@@ -238,7 +249,9 @@
if (mService != null) {
try {
return mService.isConnected(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(Log.getStackTraceString(new Throwable()));
@@ -249,6 +262,7 @@
/**
* Initiate connection. Initiation of outgoing connections is not
* supported for SAP server.
+ *
* @hide
*/
public boolean connect(BluetoothDevice device) {
@@ -260,19 +274,18 @@
* Initiate disconnect.
*
* @param device Remote Bluetooth Device
- * @return false on error,
- * true otherwise
+ * @return false on error, true otherwise
* @hide
*/
public boolean disconnect(BluetoothDevice device) {
if (DBG) log("disconnect(" + device + ")");
if (mService != null && isEnabled() &&
- isValidDevice(device)) {
+ 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");
@@ -328,7 +341,7 @@
public int getConnectionState(BluetoothDevice device) {
if (DBG) log("getConnectionState(" + device + ")");
if (mService != null && isEnabled() &&
- isValidDevice(device)) {
+ isValidDevice(device)) {
try {
return mService.getConnectionState(device);
} catch (RemoteException e) {
@@ -353,10 +366,10 @@
public boolean setPriority(BluetoothDevice device, int priority) {
if (DBG) log("setPriority(" + device + ", " + priority + ")");
if (mService != null && isEnabled() &&
- isValidDevice(device)) {
+ isValidDevice(device)) {
if (priority != BluetoothProfile.PRIORITY_OFF &&
- priority != BluetoothProfile.PRIORITY_ON) {
- return false;
+ priority != BluetoothProfile.PRIORITY_ON) {
+ return false;
}
try {
return mService.setPriority(device, priority);
@@ -379,7 +392,7 @@
public int getPriority(BluetoothDevice device) {
if (VDBG) log("getPriority(" + device + ")");
if (mService != null && isEnabled() &&
- isValidDevice(device)) {
+ isValidDevice(device)) {
try {
return mService.getPriority(device);
} catch (RemoteException e) {
@@ -399,6 +412,7 @@
mServiceListener.onServiceConnected(BluetoothProfile.SAP, BluetoothSap.this);
}
}
+
public void onServiceDisconnected(ComponentName className) {
if (DBG) log("Proxy object disconnected");
mService = null;
@@ -415,19 +429,22 @@
private boolean isEnabled() {
BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter();
- if (adapter != null && adapter.getState() == BluetoothAdapter.STATE_ON)
+ if (adapter != null && adapter.getState() == BluetoothAdapter.STATE_ON) {
return true;
+ }
log("Bluetooth is Not enabled");
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;
}
}
diff --git a/framework/java/android/bluetooth/BluetoothServerSocket.java b/framework/java/android/bluetooth/BluetoothServerSocket.java
index 4860c93..7b438bd 100644
--- a/framework/java/android/bluetooth/BluetoothServerSocket.java
+++ b/framework/java/android/bluetooth/BluetoothServerSocket.java
@@ -75,12 +75,13 @@
/**
* Construct a socket for incoming connections.
- * @param type type of socket
- * @param auth require the remote device to be authenticated
+ *
+ * @param type type of socket
+ * @param auth require the remote device to be authenticated
* @param encrypt require the connection to be encrypted
- * @param port remote port
- * @throws IOException On error, for example Bluetooth not available, or
- * insufficient privileges
+ * @param port remote port
+ * @throws IOException On error, for example Bluetooth not available, or insufficient
+ * privileges
*/
/*package*/ BluetoothServerSocket(int type, boolean auth, boolean encrypt, int port)
throws IOException {
@@ -93,14 +94,15 @@
/**
* Construct a socket for incoming connections.
- * @param type type of socket
- * @param auth require the remote device to be authenticated
+ *
+ * @param type type of socket
+ * @param auth require the remote device to be authenticated
* @param encrypt require the connection to be encrypted
- * @param port remote port
- * @param mitm enforce man-in-the-middle protection for authentication.
+ * @param port remote port
+ * @param mitm enforce man-in-the-middle protection for authentication.
* @param min16DigitPin enforce a minimum length of 16 digits for a sec mode 2 connection
- * @throws IOException On error, for example Bluetooth not available, or
- * insufficient privileges
+ * @throws IOException On error, for example Bluetooth not available, or insufficient
+ * privileges
*/
/*package*/ BluetoothServerSocket(int type, boolean auth, boolean encrypt, int port,
boolean mitm, boolean min16DigitPin)
@@ -108,19 +110,20 @@
mChannel = port;
mSocket = new BluetoothSocket(type, -1, auth, encrypt, null, port, null, mitm,
min16DigitPin);
- if(port == BluetoothAdapter.SOCKET_CHANNEL_AUTO_STATIC_NO_SDP) {
+ if (port == BluetoothAdapter.SOCKET_CHANNEL_AUTO_STATIC_NO_SDP) {
mSocket.setExcludeSdp(true);
}
}
/**
* Construct a socket for incoming connections.
- * @param type type of socket
- * @param auth require the remote device to be authenticated
+ *
+ * @param type type of socket
+ * @param auth require the remote device to be authenticated
* @param encrypt require the connection to be encrypted
- * @param uuid uuid
- * @throws IOException On error, for example Bluetooth not available, or
- * insufficient privileges
+ * @param uuid uuid
+ * @throws IOException On error, for example Bluetooth not available, or insufficient
+ * privileges
*/
/*package*/ BluetoothServerSocket(int type, boolean auth, boolean encrypt, ParcelUuid uuid)
throws IOException {
@@ -136,9 +139,9 @@
* <p>Once this call returns, it can be called again to accept subsequent
* incoming connections.
* <p>{@link #close} can be used to abort this call from another thread.
+ *
* @return a connected {@link BluetoothSocket}
- * @throws IOException on error, for example this call was aborted, or
- * timeout
+ * @throws IOException on error, for example this call was aborted, or timeout
*/
public BluetoothSocket accept() throws IOException {
return accept(-1);
@@ -150,9 +153,9 @@
* <p>Once this call returns, it can be called again to accept subsequent
* incoming connections.
* <p>{@link #close} can be used to abort this call from another thread.
+ *
* @return a connected {@link BluetoothSocket}
- * @throws IOException on error, for example this call was aborted, or
- * timeout
+ * @throws IOException on error, for example this call was aborted, or timeout
*/
public BluetoothSocket accept(int timeout) throws IOException {
return mSocket.accept(timeout);
@@ -174,16 +177,19 @@
mSocket.close();
}
- /*package*/ synchronized void setCloseHandler(Handler handler, int message) {
+ /*package*/
+ synchronized void setCloseHandler(Handler handler, int message) {
mHandler = handler;
mMessage = message;
}
+
/*package*/ void setServiceName(String ServiceName) {
mSocket.setServiceName(ServiceName);
}
/**
* Returns the channel on which this socket is bound.
+ *
* @hide
*/
public int getChannel() {
@@ -199,10 +205,10 @@
* The bind operation should be conducted through this class
* and the resulting port should be kept in mChannel, and
* not set from BluetoothAdapter. */
- if(mSocket != null) {
- if(mSocket.getPort() != newChannel) {
- Log.w(TAG,"The port set is different that the underlying port. mSocket.getPort(): "
- + mSocket.getPort() + " requested newChannel: " + newChannel);
+ if (mSocket != null) {
+ if (mSocket.getPort() != newChannel) {
+ Log.w(TAG, "The port set is different that the underlying port. mSocket.getPort(): "
+ + mSocket.getPort() + " requested newChannel: " + newChannel);
}
}
mChannel = newChannel;
@@ -212,19 +218,16 @@
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("ServerSocket: Type: ");
- switch(mSocket.getConnectionType()) {
- case BluetoothSocket.TYPE_RFCOMM:
- {
+ switch (mSocket.getConnectionType()) {
+ case BluetoothSocket.TYPE_RFCOMM: {
sb.append("TYPE_RFCOMM");
break;
}
- case BluetoothSocket.TYPE_L2CAP:
- {
+ case BluetoothSocket.TYPE_L2CAP: {
sb.append("TYPE_L2CAP");
break;
}
- case BluetoothSocket.TYPE_SCO:
- {
+ case BluetoothSocket.TYPE_SCO: {
sb.append("TYPE_SCO");
break;
}
diff --git a/framework/java/android/bluetooth/BluetoothSocket.java b/framework/java/android/bluetooth/BluetoothSocket.java
index 6bf6aa0..a90dd82 100644
--- a/framework/java/android/bluetooth/BluetoothSocket.java
+++ b/framework/java/android/bluetooth/BluetoothSocket.java
@@ -16,25 +16,23 @@
package android.bluetooth;
-import android.os.ParcelUuid;
+import android.net.LocalSocket;
import android.os.ParcelFileDescriptor;
+import android.os.ParcelUuid;
import android.os.RemoteException;
import android.util.Log;
-import java.io.BufferedInputStream;
import java.io.Closeable;
import java.io.FileDescriptor;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
+import java.nio.ByteBuffer;
+import java.nio.ByteOrder;
import java.util.Arrays;
import java.util.Locale;
import java.util.UUID;
-import android.net.LocalSocket;
-import java.nio.Buffer;
-import java.nio.ByteOrder;
-import java.nio.ByteBuffer;
/**
* A connected or connecting Bluetooth socket.
*
@@ -106,9 +104,9 @@
/*package*/ static final int SEC_FLAG_ENCRYPT = 1;
/*package*/ static final int SEC_FLAG_AUTH = 1 << 1;
- /*package*/ static final int BTSOCK_FLAG_NO_SDP = 1 << 2;
- /*package*/ static final int SEC_FLAG_AUTH_MITM = 1 << 3;
- /*package*/ static final int SEC_FLAG_AUTH_16_DIGIT = 1 << 4;
+ /*package*/ static final int BTSOCK_FLAG_NO_SDP = 1 << 2;
+ /*package*/ static final int SEC_FLAG_AUTH_MITM = 1 << 3;
+ /*package*/ static final int SEC_FLAG_AUTH_16_DIGIT = 1 << 4;
private final int mType; /* one of TYPE_RFCOMM etc */
private BluetoothDevice mDevice; /* remote device */
@@ -151,15 +149,16 @@
/**
* Construct a BluetoothSocket.
- * @param type type of socket
- * @param fd fd to use for connected socket, or -1 for a new socket
- * @param auth require the remote device to be authenticated
+ *
+ * @param type type of socket
+ * @param fd fd to use for connected socket, or -1 for a new socket
+ * @param auth require the remote device to be authenticated
* @param encrypt require the connection to be encrypted
- * @param device remote device that this socket can connect to
- * @param port remote port
- * @param uuid SDP uuid
- * @throws IOException On error, for example Bluetooth not available, or
- * insufficient privileges
+ * @param device remote device that this socket can connect to
+ * @param port remote port
+ * @param uuid SDP uuid
+ * @throws IOException On error, for example Bluetooth not available, or insufficient
+ * privileges
*/
/*package*/ BluetoothSocket(int type, int fd, boolean auth, boolean encrypt,
BluetoothDevice device, int port, ParcelUuid uuid) throws IOException {
@@ -168,21 +167,22 @@
/**
* Construct a BluetoothSocket.
- * @param type type of socket
- * @param fd fd to use for connected socket, or -1 for a new socket
- * @param auth require the remote device to be authenticated
+ *
+ * @param type type of socket
+ * @param fd fd to use for connected socket, or -1 for a new socket
+ * @param auth require the remote device to be authenticated
* @param encrypt require the connection to be encrypted
- * @param device remote device that this socket can connect to
- * @param port remote port
- * @param uuid SDP uuid
- * @param mitm enforce man-in-the-middle protection.
+ * @param device remote device that this socket can connect to
+ * @param port remote port
+ * @param uuid SDP uuid
+ * @param mitm enforce man-in-the-middle protection.
* @param min16DigitPin enforce a minimum length of 16 digits for a sec mode 2 connection
- * @throws IOException On error, for example Bluetooth not available, or
- * insufficient privileges
+ * @throws IOException On error, for example Bluetooth not available, or insufficient
+ * privileges
*/
/*package*/ BluetoothSocket(int type, int fd, boolean auth, boolean encrypt,
BluetoothDevice device, int port, ParcelUuid uuid, boolean mitm, boolean min16DigitPin)
- throws IOException {
+ throws IOException {
if (VDBG) Log.d(TAG, "Creating new BluetoothSocket of type: " + type);
if (type == BluetoothSocket.TYPE_RFCOMM && uuid == null && fd == -1
&& port != BluetoothAdapter.SOCKET_CHANNEL_AUTO_STATIC_NO_SDP) {
@@ -190,9 +190,11 @@
throw new IOException("Invalid RFCOMM channel: " + port);
}
}
- if (uuid != null)
+ if (uuid != null) {
mUuid = uuid;
- else mUuid = new ParcelUuid(new UUID(0, 0));
+ } else {
+ mUuid = new ParcelUuid(new UUID(0, 0));
+ }
mType = type;
mAuth = auth;
mAuthMitm = mitm;
@@ -214,6 +216,7 @@
mInputStream = new BluetoothInputStream(this);
mOutputStream = new BluetoothOutputStream(this);
}
+
private BluetoothSocket(BluetoothSocket s) {
if (VDBG) Log.d(TAG, "Creating new Private BluetoothSocket of type: " + s.mType);
mUuid = s.mUuid;
@@ -231,12 +234,13 @@
mAuthMitm = s.mAuthMitm;
mMin16DigitPin = s.mMin16DigitPin;
}
+
private BluetoothSocket acceptSocket(String RemoteAddr) throws IOException {
BluetoothSocket as = new BluetoothSocket(this);
as.mSocketState = SocketState.CONNECTED;
FileDescriptor[] fds = mSocket.getAncillaryFileDescriptors();
if (DBG) Log.d(TAG, "socket fd passed by stack fds: " + Arrays.toString(fds));
- if(fds == null || fds.length != 1) {
+ if (fds == null || fds.length != 1) {
Log.e(TAG, "socket fd passed from stack failed, fds: " + Arrays.toString(fds));
as.close();
throw new IOException("bt socket acept failed");
@@ -250,16 +254,18 @@
as.mDevice = BluetoothAdapter.getDefaultAdapter().getRemoteDevice(RemoteAddr);
return as;
}
+
/**
* Construct a BluetoothSocket from address. Used by native code.
- * @param type type of socket
- * @param fd fd to use for connected socket, or -1 for a new socket
- * @param auth require the remote device to be authenticated
+ *
+ * @param type type of socket
+ * @param fd fd to use for connected socket, or -1 for a new socket
+ * @param auth require the remote device to be authenticated
* @param encrypt require the connection to be encrypted
* @param address remote device that this socket can connect to
- * @param port remote port
- * @throws IOException On error, for example Bluetooth not available, or
- * insufficient privileges
+ * @param port remote port
+ * @throws IOException On error, for example Bluetooth not available, or insufficient
+ * privileges
*/
private BluetoothSocket(int type, int fd, boolean auth, boolean encrypt, String address,
int port) throws IOException {
@@ -275,23 +281,30 @@
super.finalize();
}
}
+
private int getSecurityFlags() {
int flags = 0;
- if(mAuth)
+ if (mAuth) {
flags |= SEC_FLAG_AUTH;
- if(mEncrypt)
+ }
+ if (mEncrypt) {
flags |= SEC_FLAG_ENCRYPT;
- if(mExcludeSdp)
+ }
+ if (mExcludeSdp) {
flags |= BTSOCK_FLAG_NO_SDP;
- if(mAuthMitm)
+ }
+ if (mAuthMitm) {
flags |= SEC_FLAG_AUTH_MITM;
- if(mMin16DigitPin)
+ }
+ if (mMin16DigitPin) {
flags |= SEC_FLAG_AUTH_16_DIGIT;
+ }
return flags;
}
/**
* Get the remote device this socket is connecting, or connected, to.
+ *
* @return remote device
*/
public BluetoothDevice getRemoteDevice() {
@@ -303,6 +316,7 @@
* <p>The input stream will be returned even if the socket is not yet
* connected, but operations on that stream will throw IOException until
* the associated socket is connected.
+ *
* @return InputStream
*/
public InputStream getInputStream() throws IOException {
@@ -314,6 +328,7 @@
* <p>The output stream will be returned even if the socket is not yet
* connected, but operations on that stream will throw IOException until
* the associated socket is connected.
+ *
* @return OutputStream
*/
public OutputStream getOutputStream() throws IOException {
@@ -323,8 +338,8 @@
/**
* Get the connection status of this socket, ie, whether there is an active connection with
* remote device.
- * @return true if connected
- * false if not connected
+ *
+ * @return true if connected false if not connected
*/
public boolean isConnected() {
return mSocketState == SocketState.CONNECTED;
@@ -349,6 +364,7 @@
* {@link BluetoothAdapter#cancelDiscovery()} even if it
* did not directly request a discovery, just to be sure.
* <p>{@link #close} can be used to abort this call from another thread.
+ *
* @throws IOException on error, for example connection failure
*/
public void connect() throws IOException {
@@ -361,8 +377,7 @@
if (bluetoothProxy == null) throw new IOException("Bluetooth is off");
mPfd = bluetoothProxy.connectSocket(mDevice, mType,
mUuid, mPort, getSecurityFlags());
- synchronized(this)
- {
+ synchronized (this) {
if (DBG) Log.d(TAG, "connect(), SocketState: " + mSocketState + ", mPfd: " + mPfd);
if (mSocketState == SocketState.CLOSED) throw new IOException("socket closed");
if (mPfd == null) throw new IOException("bt socket connect failed");
@@ -372,14 +387,15 @@
mSocketOS = mSocket.getOutputStream();
}
int channel = readInt(mSocketIS);
- if (channel <= 0)
+ if (channel <= 0) {
throw new IOException("bt socket connect failed");
+ }
mPort = channel;
waitSocketSignal(mSocketIS);
- synchronized(this)
- {
- if (mSocketState == SocketState.CLOSED)
+ synchronized (this) {
+ if (mSocketState == SocketState.CLOSED) {
throw new IOException("bt socket closed");
+ }
mSocketState = SocketState.CONNECTED;
}
} catch (RemoteException e) {
@@ -410,11 +426,13 @@
// read out port number
try {
- synchronized(this) {
- if (DBG) Log.d(TAG, "bindListen(), SocketState: " + mSocketState + ", mPfd: " +
- mPfd);
- if(mSocketState != SocketState.INIT) return EBADFD;
- if(mPfd == null) return -1;
+ synchronized (this) {
+ if (DBG) {
+ Log.d(TAG, "bindListen(), SocketState: " + mSocketState + ", mPfd: " +
+ mPfd);
+ }
+ if (mSocketState != SocketState.INIT) return EBADFD;
+ if (mPfd == null) return -1;
FileDescriptor fd = mPfd.getFileDescriptor();
if (fd == null) {
Log.e(TAG, "bindListen(), null file descriptor");
@@ -429,9 +447,10 @@
}
if (DBG) Log.d(TAG, "bindListen(), readInt mSocketIS: " + mSocketIS);
int channel = readInt(mSocketIS);
- synchronized(this) {
- if(mSocketState == SocketState.INIT)
+ synchronized (this) {
+ if (mSocketState == SocketState.INIT) {
mSocketState = SocketState.LISTENING;
+ }
}
if (DBG) Log.d(TAG, "channel: " + channel);
if (mPort <= -1) {
@@ -455,19 +474,21 @@
/*package*/ BluetoothSocket accept(int timeout) throws IOException {
BluetoothSocket acceptedSocket;
- if (mSocketState != SocketState.LISTENING)
+ if (mSocketState != SocketState.LISTENING) {
throw new IOException("bt socket is not in listen state");
- if(timeout > 0) {
+ }
+ if (timeout > 0) {
Log.d(TAG, "accept() set timeout (ms):" + timeout);
- mSocket.setSoTimeout(timeout);
+ mSocket.setSoTimeout(timeout);
}
String RemoteAddr = waitSocketSignal(mSocketIS);
- if(timeout > 0)
+ if (timeout > 0) {
mSocket.setSoTimeout(0);
- synchronized(this)
- {
- if (mSocketState != SocketState.LISTENING)
+ }
+ synchronized (this) {
+ if (mSocketState != SocketState.LISTENING) {
throw new IOException("bt socket is not in listen state");
+ }
acceptedSocket = acceptSocket(RemoteAddr);
//quick drop the reference of the file handle
}
@@ -478,12 +499,13 @@
if (VDBG) Log.d(TAG, "available: " + mSocketIS);
return mSocketIS.available();
}
+
/**
* Wait until the data in sending queue is emptied. A polling version
* for flush implementation. Used to ensure the writing data afterwards will
* be packed in new RFCOMM frame.
- * @throws IOException
- * if an i/o error occurs.
+ *
+ * @throws IOException if an i/o error occurs.
*/
/*package*/ void flush() throws IOException {
if (mSocketOS == null) throw new IOException("flush is called on null OutputStream");
@@ -494,11 +516,12 @@
/*package*/ int read(byte[] b, int offset, int length) throws IOException {
int ret = 0;
if (VDBG) Log.d(TAG, "read in: " + mSocketIS + " len: " + length);
- if(mType == TYPE_L2CAP)
- {
+ if (mType == TYPE_L2CAP) {
int bytesToRead = length;
- if (VDBG) Log.v(TAG, "l2cap: read(): offset: " + offset + " length:" + length
- + "mL2capBuffer= " + mL2capBuffer);
+ if (VDBG) {
+ Log.v(TAG, "l2cap: read(): offset: " + offset + " length:" + length
+ + "mL2capBuffer= " + mL2capBuffer);
+ }
if (mL2capBuffer == null) {
createL2capRxBuffer();
}
@@ -511,16 +534,19 @@
if (bytesToRead > mL2capBuffer.remaining()) {
bytesToRead = mL2capBuffer.remaining();
}
- if(VDBG) Log.v(TAG, "get(): offset: " + offset
- + " bytesToRead: " + bytesToRead);
+ if (VDBG) {
+ Log.v(TAG, "get(): offset: " + offset
+ + " bytesToRead: " + bytesToRead);
+ }
mL2capBuffer.get(b, offset, bytesToRead);
ret = bytesToRead;
- }else {
+ } else {
if (VDBG) Log.v(TAG, "default: read(): offset: " + offset + " length:" + length);
ret = mSocketIS.read(b, offset, length);
}
- if (ret < 0)
+ if (ret < 0) {
throw new IOException("bt socket closed, read return: " + ret);
+ }
if (VDBG) Log.d(TAG, "read out: " + mSocketIS + " ret: " + ret);
return ret;
}
@@ -532,48 +558,49 @@
// splitting the write into multiple smaller writes.
// Rfcomm uses dynamic allocation, and should not have any bindings
// to the actual message length.
- if (VDBG) Log.d(TAG, "write: " + mSocketOS + " length: " + length);
- if (mType == TYPE_L2CAP) {
- if(length <= mMaxTxPacketSize) {
- mSocketOS.write(b, offset, length);
- } else {
- if(DBG) Log.w(TAG, "WARNING: Write buffer larger than L2CAP packet size!\n"
+ if (VDBG) Log.d(TAG, "write: " + mSocketOS + " length: " + length);
+ if (mType == TYPE_L2CAP) {
+ if (length <= mMaxTxPacketSize) {
+ mSocketOS.write(b, offset, length);
+ } else {
+ if (DBG) {
+ Log.w(TAG, "WARNING: Write buffer larger than L2CAP packet size!\n"
+ "Packet will be divided into SDU packets of size "
+ mMaxTxPacketSize);
- int tmpOffset = offset;
- int bytesToWrite = length;
- while (bytesToWrite > 0) {
- int tmpLength = (bytesToWrite > mMaxTxPacketSize)
- ? mMaxTxPacketSize
- : bytesToWrite;
- mSocketOS.write(b, tmpOffset, tmpLength);
- tmpOffset += tmpLength;
- bytesToWrite -= tmpLength;
- }
}
- } else {
- mSocketOS.write(b, offset, length);
+ int tmpOffset = offset;
+ int bytesToWrite = length;
+ while (bytesToWrite > 0) {
+ int tmpLength = (bytesToWrite > mMaxTxPacketSize)
+ ? mMaxTxPacketSize
+ : bytesToWrite;
+ mSocketOS.write(b, tmpOffset, tmpLength);
+ tmpOffset += tmpLength;
+ bytesToWrite -= tmpLength;
+ }
}
- // There is no good way to confirm since the entire process is asynchronous anyway
- if (VDBG) Log.d(TAG, "write out: " + mSocketOS + " length: " + length);
- return length;
+ } else {
+ mSocketOS.write(b, offset, length);
+ }
+ // There is no good way to confirm since the entire process is asynchronous anyway
+ if (VDBG) Log.d(TAG, "write out: " + mSocketOS + " length: " + length);
+ return length;
}
@Override
public void close() throws IOException {
Log.d(TAG, "close() this: " + this + ", channel: " + mPort +
- ", mSocketIS: " + mSocketIS + ", mSocketOS: " + mSocketOS +
- "mSocket: " + mSocket + ", mSocketState: " + mSocketState);
- if(mSocketState == SocketState.CLOSED)
+ ", mSocketIS: " + mSocketIS + ", mSocketOS: " + mSocketOS +
+ "mSocket: " + mSocket + ", mSocketState: " + mSocketState);
+ if (mSocketState == SocketState.CLOSED) {
return;
- else
- {
- synchronized(this)
- {
- if(mSocketState == SocketState.CLOSED)
+ } else {
+ synchronized (this) {
+ if (mSocketState == SocketState.CLOSED) {
return;
- mSocketState = SocketState.CLOSED;
- if(mSocket != null) {
+ }
+ mSocketState = SocketState.CLOSED;
+ if (mSocket != null) {
if (DBG) Log.d(TAG, "Closing mSocket: " + mSocket);
mSocket.shutdownInput();
mSocket.shutdownOutput();
@@ -584,7 +611,7 @@
mPfd.close();
mPfd = null;
}
- }
+ }
}
}
@@ -599,9 +626,10 @@
* Get the maximum supported Transmit packet size for the underlying transport.
* Use this to optimize the writes done to the output socket, to avoid sending
* half full packets.
+ *
* @return the maximum supported Transmit packet size for the underlying transport.
*/
- public int getMaxTransmitPacketSize(){
+ public int getMaxTransmitPacketSize() {
return mMaxTxPacketSize;
}
@@ -610,14 +638,16 @@
* Use this to optimize the reads done on the input stream, as any call to read
* will return a maximum of this amount of bytes - or for some transports a
* multiple of this value.
+ *
* @return the maximum supported Receive packet size for the underlying transport.
*/
- public int getMaxReceivePacketSize(){
+ public int getMaxReceivePacketSize() {
return mMaxRxPacketSize;
}
/**
* Get the type of the underlying connection.
+ *
* @return one of {@link #TYPE_RFCOMM}, {@link #TYPE_SCO} or {@link #TYPE_L2CAP}
*/
public int getConnectionType() {
@@ -627,67 +657,79 @@
/**
* Change if a SDP entry should be automatically created.
* Must be called before calling .bind, for the call to have any effect.
- * @param mExcludeSdp <li>TRUE - do not auto generate SDP record.
- * <li>FALSE - default - auto generate SPP SDP record.
+ *
+ * @param mExcludeSdp <li>TRUE - do not auto generate SDP record. <li>FALSE - default - auto
+ * generate SPP SDP record.
* @hide
*/
public void setExcludeSdp(boolean excludeSdp) {
this.mExcludeSdp = excludeSdp;
}
- private String convertAddr(final byte[] addr) {
+ private String convertAddr(final byte[] addr) {
return String.format(Locale.US, "%02X:%02X:%02X:%02X:%02X:%02X",
- addr[0] , addr[1], addr[2], addr[3] , addr[4], addr[5]);
+ addr[0], addr[1], addr[2], addr[3], addr[4], addr[5]);
}
+
private String waitSocketSignal(InputStream is) throws IOException {
- byte [] sig = new byte[SOCK_SIGNAL_SIZE];
+ byte[] sig = new byte[SOCK_SIGNAL_SIZE];
int ret = readAll(is, sig);
- if (VDBG) Log.d(TAG, "waitSocketSignal read " + SOCK_SIGNAL_SIZE +
- " bytes signal ret: " + ret);
+ if (VDBG) {
+ Log.d(TAG, "waitSocketSignal read " + SOCK_SIGNAL_SIZE +
+ " bytes signal ret: " + ret);
+ }
ByteBuffer bb = ByteBuffer.wrap(sig);
/* the struct in native is decorated with __attribute__((packed)), hence this is possible */
bb.order(ByteOrder.nativeOrder());
int size = bb.getShort();
- if(size != SOCK_SIGNAL_SIZE)
+ if (size != SOCK_SIGNAL_SIZE) {
throw new IOException("Connection failure, wrong signal size: " + size);
- byte [] addr = new byte[6];
+ }
+ byte[] addr = new byte[6];
bb.get(addr);
int channel = bb.getInt();
int status = bb.getInt();
mMaxTxPacketSize = (bb.getShort() & 0xffff); // Convert to unsigned value
mMaxRxPacketSize = (bb.getShort() & 0xffff); // Convert to unsigned value
String RemoteAddr = convertAddr(addr);
- if (VDBG) Log.d(TAG, "waitSocketSignal: sig size: " + size + ", remote addr: "
- + RemoteAddr + ", channel: " + channel + ", status: " + status
- + " MaxRxPktSize: " + mMaxRxPacketSize + " MaxTxPktSize: " + mMaxTxPacketSize);
- if(status != 0)
+ if (VDBG) {
+ Log.d(TAG, "waitSocketSignal: sig size: " + size + ", remote addr: "
+ + RemoteAddr + ", channel: " + channel + ", status: " + status
+ + " MaxRxPktSize: " + mMaxRxPacketSize + " MaxTxPktSize: " + mMaxTxPacketSize);
+ }
+ if (status != 0) {
throw new IOException("Connection failure, status: " + status);
+ }
return RemoteAddr;
}
- private void createL2capRxBuffer(){
- if(mType == TYPE_L2CAP) {
+ private void createL2capRxBuffer() {
+ if (mType == TYPE_L2CAP) {
// Allocate the buffer to use for reads.
- if(VDBG) Log.v(TAG, " Creating mL2capBuffer: mMaxPacketSize: " + mMaxRxPacketSize);
+ if (VDBG) Log.v(TAG, " Creating mL2capBuffer: mMaxPacketSize: " + mMaxRxPacketSize);
mL2capBuffer = ByteBuffer.wrap(new byte[mMaxRxPacketSize]);
- if(VDBG) Log.v(TAG, "mL2capBuffer.remaining()" + mL2capBuffer.remaining());
+ if (VDBG) Log.v(TAG, "mL2capBuffer.remaining()" + mL2capBuffer.remaining());
mL2capBuffer.limit(0); // Ensure we do a real read at the first read-request
- if(VDBG) Log.v(TAG, "mL2capBuffer.remaining() after limit(0):" +
- mL2capBuffer.remaining());
+ if (VDBG) {
+ Log.v(TAG, "mL2capBuffer.remaining() after limit(0):" +
+ mL2capBuffer.remaining());
+ }
}
}
private int readAll(InputStream is, byte[] b) throws IOException {
int left = b.length;
- while(left > 0) {
+ while (left > 0) {
int ret = is.read(b, b.length - left, left);
- if(ret <= 0)
- throw new IOException("read failed, socket might closed or timeout, read ret: "
- + ret);
+ if (ret <= 0) {
+ throw new IOException("read failed, socket might closed or timeout, read ret: "
+ + ret);
+ }
left -= ret;
- if(left != 0)
+ if (left != 0) {
Log.w(TAG, "readAll() looping, read partial size: " + (b.length - left) +
- ", expect size: " + b.length);
+ ", expect size: " + b.length);
+ }
}
return b.length;
}
@@ -704,7 +746,7 @@
private int fillL2capRxBuffer() throws IOException {
mL2capBuffer.rewind();
int ret = mSocketIS.read(mL2capBuffer.array());
- if(ret == -1) {
+ if (ret == -1) {
// reached end of stream - return -1
mL2capBuffer.limit(0);
return -1;
diff --git a/framework/java/android/bluetooth/BluetoothUuid.java b/framework/java/android/bluetooth/BluetoothUuid.java
index 243579a..3b49abd 100644
--- a/framework/java/android/bluetooth/BluetoothUuid.java
+++ b/framework/java/android/bluetooth/BluetoothUuid.java
@@ -25,9 +25,10 @@
import java.util.UUID;
/**
-* Static helper methods and constants to decode the ParcelUuid of remote devices.
-* @hide
-*/
+ * Static helper methods and constants to decode the ParcelUuid of remote devices.
+ *
+ * @hide
+ */
public final class BluetoothUuid {
/* See Bluetooth Assigned Numbers document - SDP section, to get the values of UUIDs
@@ -76,9 +77,9 @@
ParcelUuid.fromString("00001133-0000-1000-8000-00805F9B34FB");
public static final ParcelUuid MAS =
ParcelUuid.fromString("00001132-0000-1000-8000-00805F9B34FB");
- public static final ParcelUuid SAP =
+ public static final ParcelUuid SAP =
ParcelUuid.fromString("0000112D-0000-1000-8000-00805F9B34FB");
-
+
public static final ParcelUuid BASE_UUID =
ParcelUuid.fromString("00000000-0000-1000-8000-00805F9B34FB");
@@ -90,8 +91,8 @@
public static final int UUID_BYTES_128_BIT = 16;
public static final ParcelUuid[] RESERVED_UUIDS = {
- AudioSink, AudioSource, AdvAudioDist, HSP, Handsfree, AvrcpController, AvrcpTarget,
- ObexObjectPush, PANU, NAP, MAP, MNS, MAS, SAP};
+ AudioSink, AudioSource, AdvAudioDist, HSP, Handsfree, AvrcpController, AvrcpTarget,
+ ObexObjectPush, PANU, NAP, MAP, MNS, MAS, SAP};
public static boolean isAudioSource(ParcelUuid uuid) {
return uuid.equals(AudioSource);
@@ -136,15 +137,19 @@
public static boolean isBnep(ParcelUuid uuid) {
return uuid.equals(BNEP);
}
+
public static boolean isMap(ParcelUuid uuid) {
return uuid.equals(MAP);
}
+
public static boolean isMns(ParcelUuid uuid) {
return uuid.equals(MNS);
}
+
public static boolean isMas(ParcelUuid uuid) {
return uuid.equals(MAS);
}
+
public static boolean isSap(ParcelUuid uuid) {
return uuid.equals(SAP);
}
@@ -156,13 +161,15 @@
* @param uuid
*/
public static boolean isUuidPresent(ParcelUuid[] uuidArray, ParcelUuid uuid) {
- if ((uuidArray == null || uuidArray.length == 0) && uuid == null)
+ if ((uuidArray == null || uuidArray.length == 0) && uuid == null) {
return true;
+ }
- if (uuidArray == null)
+ if (uuidArray == null) {
return false;
+ }
- for (ParcelUuid element: uuidArray) {
+ for (ParcelUuid element : uuidArray) {
if (element.equals(uuid)) return true;
}
return false;
@@ -173,7 +180,6 @@
*
* @param uuidA - List of ParcelUuids
* @param uuidB - List of ParcelUuids
- *
*/
public static boolean containsAnyUuid(ParcelUuid[] uuidA, ParcelUuid[] uuidB) {
if (uuidA == null && uuidB == null) return true;
@@ -186,8 +192,8 @@
return uuidA.length == 0 ? true : false;
}
- HashSet<ParcelUuid> uuidSet = new HashSet<ParcelUuid> (Arrays.asList(uuidA));
- for (ParcelUuid uuid: uuidB) {
+ HashSet<ParcelUuid> uuidSet = new HashSet<ParcelUuid>(Arrays.asList(uuidA));
+ for (ParcelUuid uuid : uuidB) {
if (uuidSet.contains(uuid)) return true;
}
return false;
@@ -199,7 +205,6 @@
*
* @param uuidA - Array of ParcelUuidsA
* @param uuidB - Array of ParcelUuidsB
- *
*/
public static boolean containsAllUuids(ParcelUuid[] uuidA, ParcelUuid[] uuidB) {
if (uuidA == null && uuidB == null) return true;
@@ -210,8 +215,8 @@
if (uuidB == null) return true;
- HashSet<ParcelUuid> uuidSet = new HashSet<ParcelUuid> (Arrays.asList(uuidA));
- for (ParcelUuid uuid: uuidB) {
+ HashSet<ParcelUuid> uuidSet = new HashSet<ParcelUuid>(Arrays.asList(uuidA));
+ for (ParcelUuid uuid : uuidB) {
if (!uuidSet.contains(uuid)) return false;
}
return true;
@@ -221,13 +226,14 @@
* Extract the Service Identifier or the actual uuid from the Parcel Uuid.
* For example, if 0000110B-0000-1000-8000-00805F9B34FB is the parcel Uuid,
* this function will return 110B
+ *
* @param parcelUuid
* @return the service identifier.
*/
public static int getServiceIdentifierFromParcelUuid(ParcelUuid parcelUuid) {
UUID uuid = parcelUuid.getUuid();
long value = (uuid.getMostSignificantBits() & 0x0000FFFF00000000L) >>> 32;
- return (int)value;
+ return (int) value;
}
/**
@@ -264,7 +270,7 @@
shortUuid = uuidBytes[0] & 0xFF;
shortUuid += (uuidBytes[1] & 0xFF) << 8;
} else {
- shortUuid = uuidBytes[0] & 0xFF ;
+ shortUuid = uuidBytes[0] & 0xFF;
shortUuid += (uuidBytes[1] & 0xFF) << 8;
shortUuid += (uuidBytes[2] & 0xFF) << 16;
shortUuid += (uuidBytes[3] & 0xFF) << 24;
@@ -275,8 +281,8 @@
}
/**
- * Parse UUID to bytes. The returned value is shortest representation, a 16-bit, 32-bit or 128-bit UUID,
- * Note returned value is little endian (Bluetooth).
+ * Parse UUID to bytes. The returned value is shortest representation, a 16-bit, 32-bit or
+ * 128-bit UUID, Note returned value is little endian (Bluetooth).
*
* @param uuid uuid to parse.
* @return shortest representation of {@code uuid} as bytes.
@@ -290,18 +296,18 @@
if (is16BitUuid(uuid)) {
byte[] uuidBytes = new byte[UUID_BYTES_16_BIT];
int uuidVal = getServiceIdentifierFromParcelUuid(uuid);
- uuidBytes[0] = (byte)(uuidVal & 0xFF);
- uuidBytes[1] = (byte)((uuidVal & 0xFF00) >> 8);
+ uuidBytes[0] = (byte) (uuidVal & 0xFF);
+ uuidBytes[1] = (byte) ((uuidVal & 0xFF00) >> 8);
return uuidBytes;
}
if (is32BitUuid(uuid)) {
byte[] uuidBytes = new byte[UUID_BYTES_32_BIT];
int uuidVal = getServiceIdentifierFromParcelUuid(uuid);
- uuidBytes[0] = (byte)(uuidVal & 0xFF);
- uuidBytes[1] = (byte)((uuidVal & 0xFF00) >> 8);
- uuidBytes[2] = (byte)((uuidVal & 0xFF0000) >> 16);
- uuidBytes[3] = (byte)((uuidVal & 0xFF000000) >> 24);
+ uuidBytes[0] = (byte) (uuidVal & 0xFF);
+ uuidBytes[1] = (byte) ((uuidVal & 0xFF00) >> 8);
+ uuidBytes[2] = (byte) ((uuidVal & 0xFF0000) >> 16);
+ uuidBytes[3] = (byte) ((uuidVal & 0xFF000000) >> 24);
return uuidBytes;
}
diff --git a/framework/java/android/bluetooth/OobData.java b/framework/java/android/bluetooth/OobData.java
index 9e87230..505cc56 100644
--- a/framework/java/android/bluetooth/OobData.java
+++ b/framework/java/android/bluetooth/OobData.java
@@ -19,8 +19,6 @@
import android.os.Parcel;
import android.os.Parcelable;
-import android.util.Log;
-
/**
* Out Of Band Data for Bluetooth device pairing.
*
@@ -77,7 +75,8 @@
this.leSecureConnectionsRandom = leSecureConnectionsRandom;
}
- public OobData() { }
+ public OobData() {
+ }
private OobData(Parcel in) {
leBluetoothDeviceAddress = in.createByteArray();
diff --git a/framework/java/android/bluetooth/SdpMasRecord.java b/framework/java/android/bluetooth/SdpMasRecord.java
index fa164c0..b202e53 100644
--- a/framework/java/android/bluetooth/SdpMasRecord.java
+++ b/framework/java/android/bluetooth/SdpMasRecord.java
@@ -26,20 +26,21 @@
private final int mSupportedFeatures;
private final int mSupportedMessageTypes;
private final String mServiceName;
+
public static final class MessageType {
- public static final int EMAIL = 0x01;
- public static final int SMS_GSM = 0x02;
+ public static final int EMAIL = 0x01;
+ public static final int SMS_GSM = 0x02;
public static final int SMS_CDMA = 0x04;
- public static final int MMS = 0x08;
+ public static final int MMS = 0x08;
}
public SdpMasRecord(int mas_instance_id,
- int l2cap_psm,
- int rfcomm_channel_number,
- int profile_version,
- int supported_features,
- int supported_message_types,
- String service_name){
+ int l2cap_psm,
+ int rfcomm_channel_number,
+ int profile_version,
+ int supported_features,
+ int supported_message_types,
+ String service_name) {
this.mMasInstanceId = mas_instance_id;
this.mL2capPsm = l2cap_psm;
this.mRfcommChannelNumber = rfcomm_channel_number;
@@ -49,7 +50,7 @@
this.mServiceName = service_name;
}
- public SdpMasRecord(Parcel in){
+ public SdpMasRecord(Parcel in) {
this.mMasInstanceId = in.readInt();
this.mL2capPsm = in.readInt();
this.mRfcommChannelNumber = in.readInt();
@@ -58,6 +59,7 @@
this.mSupportedMessageTypes = in.readInt();
this.mServiceName = in.readString();
}
+
@Override
public int describeContents() {
// TODO Auto-generated method stub
@@ -87,11 +89,11 @@
public int getSupportedMessageTypes() {
return mSupportedMessageTypes;
}
-
+
public boolean msgSupported(int msg) {
return (mSupportedMessageTypes & msg) != 0;
}
-
+
public String getServiceName() {
return mServiceName;
}
@@ -108,29 +110,30 @@
dest.writeString(this.mServiceName);
}
+
@Override
- public String toString(){
+ public String toString() {
String ret = "Bluetooth MAS SDP Record:\n";
- if(mMasInstanceId != -1){
+ if (mMasInstanceId != -1) {
ret += "Mas Instance Id: " + mMasInstanceId + "\n";
}
- if(mRfcommChannelNumber != -1){
+ if (mRfcommChannelNumber != -1) {
ret += "RFCOMM Chan Number: " + mRfcommChannelNumber + "\n";
}
- if(mL2capPsm != -1){
+ if (mL2capPsm != -1) {
ret += "L2CAP PSM: " + mL2capPsm + "\n";
}
- if(mServiceName != null){
+ if (mServiceName != null) {
ret += "Service Name: " + mServiceName + "\n";
}
- if(mProfileVersion != -1){
+ if (mProfileVersion != -1) {
ret += "Profile version: " + mProfileVersion + "\n";
}
- if(mSupportedMessageTypes != -1){
+ if (mSupportedMessageTypes != -1) {
ret += "Supported msg types: " + mSupportedMessageTypes + "\n";
}
- if(mSupportedFeatures != -1){
+ if (mSupportedFeatures != -1) {
ret += "Supported features: " + mSupportedFeatures + "\n";
}
return ret;
@@ -140,6 +143,7 @@
public SdpMasRecord createFromParcel(Parcel in) {
return new SdpMasRecord(in);
}
+
public SdpRecord[] newArray(int size) {
return new SdpRecord[size];
}
diff --git a/framework/java/android/bluetooth/SdpMnsRecord.java b/framework/java/android/bluetooth/SdpMnsRecord.java
index c02bb5a..94ae635 100644
--- a/framework/java/android/bluetooth/SdpMnsRecord.java
+++ b/framework/java/android/bluetooth/SdpMnsRecord.java
@@ -29,7 +29,7 @@
int rfcomm_channel_number,
int profile_version,
int supported_features,
- String service_name){
+ String service_name) {
this.mL2capPsm = l2cap_psm;
this.mRfcommChannelNumber = rfcomm_channel_number;
this.mSupportedFeatures = supported_features;
@@ -37,13 +37,14 @@
this.mProfileVersion = profile_version;
}
- public SdpMnsRecord(Parcel in){
- this.mRfcommChannelNumber = in.readInt();
- this.mL2capPsm = in.readInt();
- this.mServiceName = in.readString();
- this.mSupportedFeatures = in.readInt();
- this.mProfileVersion = in.readInt();
+ public SdpMnsRecord(Parcel in) {
+ this.mRfcommChannelNumber = in.readInt();
+ this.mL2capPsm = in.readInt();
+ this.mServiceName = in.readString();
+ this.mSupportedFeatures = in.readInt();
+ this.mProfileVersion = in.readInt();
}
+
@Override
public int describeContents() {
// TODO Auto-generated method stub
@@ -80,23 +81,23 @@
dest.writeInt(mProfileVersion);
}
- public String toString(){
+ public String toString() {
String ret = "Bluetooth MNS SDP Record:\n";
- if(mRfcommChannelNumber != -1){
+ if (mRfcommChannelNumber != -1) {
ret += "RFCOMM Chan Number: " + mRfcommChannelNumber + "\n";
}
- if(mL2capPsm != -1){
+ if (mL2capPsm != -1) {
ret += "L2CAP PSM: " + mL2capPsm + "\n";
}
- if(mServiceName != null){
+ if (mServiceName != null) {
ret += "Service Name: " + mServiceName + "\n";
}
- if(mSupportedFeatures != -1){
+ if (mSupportedFeatures != -1) {
ret += "Supported features: " + mSupportedFeatures + "\n";
}
- if(mProfileVersion != -1){
- ret += "Profile_version: " + mProfileVersion+"\n";
+ if (mProfileVersion != -1) {
+ ret += "Profile_version: " + mProfileVersion + "\n";
}
return ret;
}
@@ -105,6 +106,7 @@
public SdpMnsRecord createFromParcel(Parcel in) {
return new SdpMnsRecord(in);
}
+
public SdpMnsRecord[] newArray(int size) {
return new SdpMnsRecord[size];
}
diff --git a/framework/java/android/bluetooth/SdpOppOpsRecord.java b/framework/java/android/bluetooth/SdpOppOpsRecord.java
index e0e4007..23e301c 100644
--- a/framework/java/android/bluetooth/SdpOppOpsRecord.java
+++ b/framework/java/android/bluetooth/SdpOppOpsRecord.java
@@ -14,14 +14,15 @@
*/
package android.bluetooth;
-import java.util.Arrays;
-
import android.os.Parcel;
import android.os.Parcelable;
+import java.util.Arrays;
+
/**
* Data representation of a Object Push Profile Server side SDP record.
*/
+
/** @hide */
public class SdpOppOpsRecord implements Parcelable {
@@ -67,13 +68,13 @@
return 0;
}
- public SdpOppOpsRecord(Parcel in){
+ public SdpOppOpsRecord(Parcel in) {
this.mRfcommChannel = in.readInt();
this.mL2capPsm = in.readInt();
this.mProfileVersion = in.readInt();
this.mServiceName = in.readString();
int arrayLength = in.readInt();
- if(arrayLength > 0) {
+ if (arrayLength > 0) {
byte[] bytes = new byte[arrayLength];
in.readByteArray(bytes);
this.mFormatsList = bytes;
@@ -88,7 +89,7 @@
dest.writeInt(mL2capPsm);
dest.writeInt(mProfileVersion);
dest.writeString(mServiceName);
- if(mFormatsList!= null && mFormatsList.length > 0) {
+ if (mFormatsList != null && mFormatsList.length > 0) {
dest.writeInt(mFormatsList.length);
dest.writeByteArray(mFormatsList);
} else {
@@ -96,7 +97,7 @@
}
}
- public String toString(){
+ public String toString() {
StringBuilder sb = new StringBuilder("Bluetooth OPP Server SDP Record:\n");
sb.append(" RFCOMM Chan Number: ").append(mRfcommChannel);
sb.append("\n L2CAP PSM: ").append(mL2capPsm);
@@ -110,6 +111,7 @@
public SdpOppOpsRecord createFromParcel(Parcel in) {
return new SdpOppOpsRecord(in);
}
+
public SdpOppOpsRecord[] newArray(int size) {
return new SdpOppOpsRecord[size];
}
diff --git a/framework/java/android/bluetooth/SdpPseRecord.java b/framework/java/android/bluetooth/SdpPseRecord.java
index 2c159cc..5885f17 100644
--- a/framework/java/android/bluetooth/SdpPseRecord.java
+++ b/framework/java/android/bluetooth/SdpPseRecord.java
@@ -32,7 +32,7 @@
int profile_version,
int supported_features,
int supported_repositories,
- String service_name){
+ String service_name) {
this.mL2capPsm = l2cap_psm;
this.mRfcommChannelNumber = rfcomm_channel_number;
this.mProfileVersion = profile_version;
@@ -41,14 +41,15 @@
this.mServiceName = service_name;
}
- public SdpPseRecord(Parcel in){
- this.mRfcommChannelNumber = in.readInt();
- this.mL2capPsm = in.readInt();
- this.mProfileVersion = in.readInt();
- this.mSupportedFeatures = in.readInt();
- this.mSupportedRepositories = in.readInt();
- this.mServiceName = in.readString();
+ public SdpPseRecord(Parcel in) {
+ this.mRfcommChannelNumber = in.readInt();
+ this.mL2capPsm = in.readInt();
+ this.mProfileVersion = in.readInt();
+ this.mSupportedFeatures = in.readInt();
+ this.mSupportedRepositories = in.readInt();
+ this.mServiceName = in.readString();
}
+
@Override
public int describeContents() {
// TODO Auto-generated method stub
@@ -78,6 +79,7 @@
public int getSupportedRepositories() {
return mSupportedRepositories;
}
+
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeInt(mRfcommChannelNumber);
@@ -89,25 +91,25 @@
}
- public String toString(){
+ public String toString() {
String ret = "Bluetooth MNS SDP Record:\n";
- if(mRfcommChannelNumber != -1){
+ if (mRfcommChannelNumber != -1) {
ret += "RFCOMM Chan Number: " + mRfcommChannelNumber + "\n";
}
- if(mL2capPsm != -1){
+ if (mL2capPsm != -1) {
ret += "L2CAP PSM: " + mL2capPsm + "\n";
}
- if(mProfileVersion != -1){
+ if (mProfileVersion != -1) {
ret += "profile version: " + mProfileVersion + "\n";
}
- if(mServiceName != null){
+ if (mServiceName != null) {
ret += "Service Name: " + mServiceName + "\n";
}
- if(mSupportedFeatures != -1){
+ if (mSupportedFeatures != -1) {
ret += "Supported features: " + mSupportedFeatures + "\n";
}
- if(mSupportedRepositories != -1){
+ if (mSupportedRepositories != -1) {
ret += "Supported repositories: " + mSupportedRepositories + "\n";
}
@@ -118,6 +120,7 @@
public SdpPseRecord createFromParcel(Parcel in) {
return new SdpPseRecord(in);
}
+
public SdpPseRecord[] newArray(int size) {
return new SdpPseRecord[size];
}
diff --git a/framework/java/android/bluetooth/SdpRecord.java b/framework/java/android/bluetooth/SdpRecord.java
index 6f1065e..714ecd8 100644
--- a/framework/java/android/bluetooth/SdpRecord.java
+++ b/framework/java/android/bluetooth/SdpRecord.java
@@ -21,7 +21,7 @@
import java.util.Arrays;
/** @hide */
-public class SdpRecord implements Parcelable{
+public class SdpRecord implements Parcelable {
private final byte[] mRawData;
private final int mRawSize;
@@ -32,12 +32,12 @@
+ ", rawSize=" + mRawSize + "]";
}
- public SdpRecord(int size_record, byte[] record){
+ public SdpRecord(int size_record, byte[] record) {
this.mRawData = record;
this.mRawSize = size_record;
}
- public SdpRecord(Parcel in){
+ public SdpRecord(Parcel in) {
this.mRawSize = in.readInt();
this.mRawData = new byte[mRawSize];
in.readByteArray(this.mRawData);
@@ -56,6 +56,7 @@
}
+
public static final Parcelable.Creator CREATOR = new Parcelable.Creator() {
public SdpRecord createFromParcel(Parcel in) {
return new SdpRecord(in);
diff --git a/framework/java/android/bluetooth/SdpSapsRecord.java b/framework/java/android/bluetooth/SdpSapsRecord.java
index 84a29b9..1904118 100644
--- a/framework/java/android/bluetooth/SdpSapsRecord.java
+++ b/framework/java/android/bluetooth/SdpSapsRecord.java
@@ -41,7 +41,7 @@
@Override
public int describeContents() {
- return 0;
+ return 0;
}
public int getRfcommCannelNumber() {
@@ -84,6 +84,7 @@
public SdpSapsRecord createFromParcel(Parcel in) {
return new SdpSapsRecord(in);
}
+
public SdpRecord[] newArray(int size) {
return new SdpRecord[size];
}
diff --git a/framework/java/android/bluetooth/UidTraffic.java b/framework/java/android/bluetooth/UidTraffic.java
index 78013cc..f74ac75 100644
--- a/framework/java/android/bluetooth/UidTraffic.java
+++ b/framework/java/android/bluetooth/UidTraffic.java
@@ -20,6 +20,7 @@
/**
* Record of data traffic (in bytes) by an application identified by its UID.
+ *
* @hide
*/
public class UidTraffic implements Cloneable, Parcelable {
diff --git a/framework/java/android/bluetooth/le/AdvertiseCallback.java b/framework/java/android/bluetooth/le/AdvertiseCallback.java
index 706f469..4fa8c4f 100644
--- a/framework/java/android/bluetooth/le/AdvertiseCallback.java
+++ b/framework/java/android/bluetooth/le/AdvertiseCallback.java
@@ -58,7 +58,7 @@
* that the advertising has been started successfully.
*
* @param settingsInEffect The actual settings used for advertising, which may be different from
- * what has been requested.
+ * what has been requested.
*/
public void onStartSuccess(AdvertiseSettings settingsInEffect) {
}
@@ -67,7 +67,7 @@
* Callback when advertising could not be started.
*
* @param errorCode Error code (see ADVERTISE_FAILED_* constants) for advertising start
- * failures.
+ * failures.
*/
public void onStartFailure(int errorCode) {
}
diff --git a/framework/java/android/bluetooth/le/AdvertiseData.java b/framework/java/android/bluetooth/le/AdvertiseData.java
index bde2d2f..7c506db 100644
--- a/framework/java/android/bluetooth/le/AdvertiseData.java
+++ b/framework/java/android/bluetooth/le/AdvertiseData.java
@@ -119,10 +119,11 @@
}
AdvertiseData other = (AdvertiseData) obj;
return Objects.equals(mServiceUuids, other.mServiceUuids) &&
- BluetoothLeUtils.equals(mManufacturerSpecificData, other.mManufacturerSpecificData) &&
+ BluetoothLeUtils.equals(mManufacturerSpecificData, other.mManufacturerSpecificData)
+ &&
BluetoothLeUtils.equals(mServiceData, other.mServiceData) &&
- mIncludeDeviceName == other.mIncludeDeviceName &&
- mIncludeTxPowerLevel == other.mIncludeTxPowerLevel;
+ mIncludeDeviceName == other.mIncludeDeviceName &&
+ mIncludeTxPowerLevel == other.mIncludeTxPowerLevel;
}
@Override
@@ -160,12 +161,12 @@
public static final Parcelable.Creator<AdvertiseData> CREATOR =
new Creator<AdvertiseData>() {
- @Override
+ @Override
public AdvertiseData[] newArray(int size) {
return new AdvertiseData[size];
}
- @Override
+ @Override
public AdvertiseData createFromParcel(Parcel in) {
Builder builder = new Builder();
ArrayList<ParcelUuid> uuids = in.createTypedArrayList(ParcelUuid.CREATOR);
@@ -222,7 +223,7 @@
* @param serviceDataUuid 16-bit UUID of the service the data is associated with
* @param serviceData Service data
* @throws IllegalArgumentException If the {@code serviceDataUuid} or {@code serviceData} is
- * empty.
+ * empty.
*/
public Builder addServiceData(ParcelUuid serviceDataUuid, byte[] serviceData) {
if (serviceDataUuid == null || serviceData == null) {
@@ -242,8 +243,8 @@
*
* @param manufacturerId Manufacturer ID assigned by Bluetooth SIG.
* @param manufacturerSpecificData Manufacturer specific data
- * @throws IllegalArgumentException If the {@code manufacturerId} is negative or
- * {@code manufacturerSpecificData} is null.
+ * @throws IllegalArgumentException If the {@code manufacturerId} is negative or {@code
+ * manufacturerSpecificData} is null.
*/
public Builder addManufacturerData(int manufacturerId, byte[] manufacturerSpecificData) {
if (manufacturerId < 0) {
diff --git a/framework/java/android/bluetooth/le/AdvertiseSettings.java b/framework/java/android/bluetooth/le/AdvertiseSettings.java
index 62c68a4..430f9bd 100644
--- a/framework/java/android/bluetooth/le/AdvertiseSettings.java
+++ b/framework/java/android/bluetooth/le/AdvertiseSettings.java
@@ -121,9 +121,9 @@
@Override
public String toString() {
return "Settings [mAdvertiseMode=" + mAdvertiseMode
- + ", mAdvertiseTxPowerLevel=" + mAdvertiseTxPowerLevel
- + ", mAdvertiseConnectable=" + mAdvertiseConnectable
- + ", mAdvertiseTimeoutMillis=" + mAdvertiseTimeoutMillis + "]";
+ + ", mAdvertiseTxPowerLevel=" + mAdvertiseTxPowerLevel
+ + ", mAdvertiseConnectable=" + mAdvertiseConnectable
+ + ", mAdvertiseTimeoutMillis=" + mAdvertiseTimeoutMillis + "]";
}
@Override
@@ -141,12 +141,12 @@
public static final Parcelable.Creator<AdvertiseSettings> CREATOR =
new Creator<AdvertiseSettings>() {
- @Override
+ @Override
public AdvertiseSettings[] newArray(int size) {
return new AdvertiseSettings[size];
}
- @Override
+ @Override
public AdvertiseSettings createFromParcel(Parcel in) {
return new AdvertiseSettings(in);
}
@@ -164,10 +164,10 @@
/**
* Set advertise mode to control the advertising power and latency.
*
- * @param advertiseMode Bluetooth LE Advertising mode, can only be one of
- * {@link AdvertiseSettings#ADVERTISE_MODE_LOW_POWER},
- * {@link AdvertiseSettings#ADVERTISE_MODE_BALANCED}, or
- * {@link AdvertiseSettings#ADVERTISE_MODE_LOW_LATENCY}.
+ * @param advertiseMode Bluetooth LE Advertising mode, can only be one of {@link
+ * AdvertiseSettings#ADVERTISE_MODE_LOW_POWER},
+ * {@link AdvertiseSettings#ADVERTISE_MODE_BALANCED},
+ * or {@link AdvertiseSettings#ADVERTISE_MODE_LOW_LATENCY}.
* @throws IllegalArgumentException If the advertiseMode is invalid.
*/
public Builder setAdvertiseMode(int advertiseMode) {
@@ -183,10 +183,10 @@
* Set advertise TX power level to control the transmission power level for the advertising.
*
* @param txPowerLevel Transmission power of Bluetooth LE Advertising, can only be one of
- * {@link AdvertiseSettings#ADVERTISE_TX_POWER_ULTRA_LOW},
- * {@link AdvertiseSettings#ADVERTISE_TX_POWER_LOW},
- * {@link AdvertiseSettings#ADVERTISE_TX_POWER_MEDIUM} or
- * {@link AdvertiseSettings#ADVERTISE_TX_POWER_HIGH}.
+ * {@link AdvertiseSettings#ADVERTISE_TX_POWER_ULTRA_LOW}, {@link
+ * AdvertiseSettings#ADVERTISE_TX_POWER_LOW},
+ * {@link AdvertiseSettings#ADVERTISE_TX_POWER_MEDIUM}
+ * or {@link AdvertiseSettings#ADVERTISE_TX_POWER_HIGH}.
* @throws IllegalArgumentException If the {@code txPowerLevel} is invalid.
*/
public Builder setTxPowerLevel(int txPowerLevel) {
@@ -201,8 +201,8 @@
/**
* Set whether the advertisement type should be connectable or non-connectable.
*
- * @param connectable Controls whether the advertisment type will be connectable (true)
- * or non-connectable (false).
+ * @param connectable Controls whether the advertisment type will be connectable (true) or
+ * non-connectable (false).
*/
public Builder setConnectable(boolean connectable) {
mConnectable = connectable;
@@ -211,14 +211,15 @@
/**
* Limit advertising to a given amount of time.
- * @param timeoutMillis Advertising time limit. May not exceed 180000 milliseconds.
- * A value of 0 will disable the time limit.
+ *
+ * @param timeoutMillis Advertising time limit. May not exceed 180000 milliseconds. A value
+ * of 0 will disable the time limit.
* @throws IllegalArgumentException If the provided timeout is over 180000 ms.
*/
public Builder setTimeout(int timeoutMillis) {
if (timeoutMillis < 0 || timeoutMillis > LIMITED_ADVERTISING_MAX_MILLIS) {
throw new IllegalArgumentException("timeoutMillis invalid (must be 0-"
- + LIMITED_ADVERTISING_MAX_MILLIS + " milliseconds)");
+ + LIMITED_ADVERTISING_MAX_MILLIS + " milliseconds)");
}
mTimeoutMillis = timeoutMillis;
return this;
diff --git a/framework/java/android/bluetooth/le/AdvertisingSet.java b/framework/java/android/bluetooth/le/AdvertisingSet.java
index 1bc211c..b1c122c 100644
--- a/framework/java/android/bluetooth/le/AdvertisingSet.java
+++ b/framework/java/android/bluetooth/le/AdvertisingSet.java
@@ -19,7 +19,6 @@
import android.bluetooth.BluetoothAdapter;
import android.bluetooth.IBluetoothGatt;
import android.bluetooth.IBluetoothManager;
-import android.bluetooth.le.IAdvertisingSetCallback;
import android.os.RemoteException;
import android.util.Log;
@@ -41,19 +40,19 @@
private int advertiserId;
/* package */ AdvertisingSet(int advertiserId,
- IBluetoothManager bluetoothManager) {
+ IBluetoothManager bluetoothManager) {
this.advertiserId = advertiserId;
try {
- this.gatt = bluetoothManager.getBluetoothGatt();
+ this.gatt = bluetoothManager.getBluetoothGatt();
} catch (RemoteException e) {
- Log.e(TAG, "Failed to get Bluetooth gatt - ", e);
- throw new IllegalStateException("Failed to get Bluetooth");
+ Log.e(TAG, "Failed to get Bluetooth gatt - ", e);
+ throw new IllegalStateException("Failed to get Bluetooth");
}
}
/* package */ void setAdvertiserId(int advertiserId) {
- this.advertiserId = advertiserId;
+ this.advertiserId = advertiserId;
}
/**
@@ -63,18 +62,17 @@
* Requires {@link android.Manifest.permission#BLUETOOTH_ADMIN}
*
* @param enable whether the advertising should be enabled (true), or disabled (false)
- * @param duration advertising duration, in 10ms unit. Valid range is from 1 (10ms) to
- * 65535 (655,350 ms)
+ * @param duration advertising duration, in 10ms unit. Valid range is from 1 (10ms) to 65535
+ * (655,350 ms)
* @param maxExtendedAdvertisingEvents maximum number of extended advertising events the
- * controller shall attempt to send prior to terminating the extended
- * advertising, even if the duration has not expired. Valid range is
- * from 1 to 255.
+ * controller shall attempt to send prior to terminating the extended advertising, even if the
+ * duration has not expired. Valid range is from 1 to 255.
*/
public void enableAdvertising(boolean enable, int duration,
int maxExtendedAdvertisingEvents) {
try {
gatt.enableAdvertisingSet(this.advertiserId, enable, duration,
- maxExtendedAdvertisingEvents);
+ maxExtendedAdvertisingEvents);
} catch (RemoteException e) {
Log.e(TAG, "remote exception - ", e);
}
@@ -87,11 +85,10 @@
* <p>
* Advertising data must be empty if non-legacy scannable advertising is used.
*
- * @param advertiseData Advertisement data to be broadcasted. Size must not exceed
- * {@link BluetoothAdapter#getLeMaximumAdvertisingDataLength}. If the
- * advertisement is connectable, three bytes will be added for flags. If the
- * update takes place when the advertising set is enabled, the data can be
- * maximum 251 bytes long.
+ * @param advertiseData Advertisement data to be broadcasted. Size must not exceed {@link
+ * BluetoothAdapter#getLeMaximumAdvertisingDataLength}. If the advertisement is connectable,
+ * three bytes will be added for flags. If the update takes place when the advertising set is
+ * enabled, the data can be maximum 251 bytes long.
*/
public void setAdvertisingData(AdvertiseData advertiseData) {
try {
@@ -107,9 +104,8 @@
* is delivered through {@code callback.onScanResponseDataSet()}.
*
* @param scanResponse Scan response associated with the advertisement data. Size must not
- * exceed {@link BluetoothAdapter#getLeMaximumAdvertisingDataLength}. If the
- * update takes place when the advertising set is enabled, the data can be
- * maximum 251 bytes long.
+ * exceed {@link BluetoothAdapter#getLeMaximumAdvertisingDataLength}. If the update takes place
+ * when the advertising set is enabled, the data can be maximum 251 bytes long.
*/
public void setScanResponseData(AdvertiseData scanResponse) {
try {
@@ -153,10 +149,9 @@
* immediately, the operation status is delivered through
* {@code callback.onPeriodicAdvertisingDataSet()}.
*
- * @param periodicData Periodic advertising data. Size must not exceed
- * {@link BluetoothAdapter#getLeMaximumAdvertisingDataLength}. If the
- * update takes place when the periodic advertising is enabled for this set,
- * the data can be maximum 251 bytes long.
+ * @param periodicData Periodic advertising data. Size must not exceed {@link
+ * BluetoothAdapter#getLeMaximumAdvertisingDataLength}. If the update takes place when the
+ * periodic advertising is enabled for this set, the data can be maximum 251 bytes long.
*/
public void setPeriodicAdvertisingData(AdvertiseData periodicData) {
try {
@@ -170,7 +165,8 @@
* Used to enable/disable periodic advertising. This method returns immediately, the operation
* status is delivered through {@code callback.onPeriodicAdvertisingEnable()}.
*
- * @param enable whether the periodic advertising should be enabled (true), or disabled (false).
+ * @param enable whether the periodic advertising should be enabled (true), or disabled
+ * (false).
*/
public void setPeriodicAdvertisingEnabled(boolean enable) {
try {
@@ -186,9 +182,10 @@
* should ever use it.
*
* This method requires {@link android.Manifest.permission#BLUETOOTH_PRIVILEGED} permission.
+ *
* @hide
*/
- public void getOwnAddress(){
+ public void getOwnAddress() {
try {
gatt.getOwnAddress(this.advertiserId);
} catch (RemoteException e) {
@@ -201,7 +198,7 @@
*
* @hide
*/
- public int getAdvertiserId(){
- return advertiserId;
+ public int getAdvertiserId() {
+ return advertiserId;
}
}
\ No newline at end of file
diff --git a/framework/java/android/bluetooth/le/AdvertisingSetCallback.java b/framework/java/android/bluetooth/le/AdvertisingSetCallback.java
index c3c16a4..fa502d3 100644
--- a/framework/java/android/bluetooth/le/AdvertisingSetCallback.java
+++ b/framework/java/android/bluetooth/le/AdvertisingSetCallback.java
@@ -16,8 +16,6 @@
package android.bluetooth.le;
-import android.bluetooth.BluetoothDevice;
-
/**
* Bluetooth LE advertising set callbacks, used to deliver advertising operation
* status.
@@ -65,7 +63,8 @@
* @param txPower tx power that will be used for this set.
* @param status Status of the operation.
*/
- public void onAdvertisingSetStarted(AdvertisingSet advertisingSet, int txPower, int status) {}
+ public void onAdvertisingSetStarted(AdvertisingSet advertisingSet, int txPower, int status) {
+ }
/**
* Callback triggered in response to {@link BluetoothLeAdvertiser#stopAdvertisingSet}
@@ -73,16 +72,19 @@
*
* @param advertisingSet The advertising set.
*/
- public void onAdvertisingSetStopped(AdvertisingSet advertisingSet) {}
+ public void onAdvertisingSetStopped(AdvertisingSet advertisingSet) {
+ }
/**
- * Callback triggered in response to {@link BluetoothLeAdvertiser#startAdvertisingSet} indicating
- * result of the operation. If status is ADVERTISE_SUCCESS, then advertising set is advertising.
+ * Callback triggered in response to {@link BluetoothLeAdvertiser#startAdvertisingSet}
+ * indicating result of the operation. If status is ADVERTISE_SUCCESS, then advertising set is
+ * advertising.
*
* @param advertisingSet The advertising set.
* @param status Status of the operation.
*/
- public void onAdvertisingEnabled(AdvertisingSet advertisingSet, boolean enable, int status) {}
+ public void onAdvertisingEnabled(AdvertisingSet advertisingSet, boolean enable, int status) {
+ }
/**
* Callback triggered in response to {@link AdvertisingSet#setAdvertisingData} indicating
@@ -91,7 +93,8 @@
* @param advertisingSet The advertising set.
* @param status Status of the operation.
*/
- public void onAdvertisingDataSet(AdvertisingSet advertisingSet, int status) {}
+ public void onAdvertisingDataSet(AdvertisingSet advertisingSet, int status) {
+ }
/**
* Callback triggered in response to {@link AdvertisingSet#setAdvertisingData} indicating
@@ -100,7 +103,8 @@
* @param advertisingSet The advertising set.
* @param status Status of the operation.
*/
- public void onScanResponseDataSet(AdvertisingSet advertisingSet, int status) {}
+ public void onScanResponseDataSet(AdvertisingSet advertisingSet, int status) {
+ }
/**
* Callback triggered in response to {@link AdvertisingSet#setAdvertisingParameters}
@@ -111,7 +115,8 @@
* @param status Status of the operation.
*/
public void onAdvertisingParametersUpdated(AdvertisingSet advertisingSet,
- int txPower, int status) {}
+ int txPower, int status) {
+ }
/**
* Callback triggered in response to {@link AdvertisingSet#setPeriodicAdvertisingParameters}
@@ -122,7 +127,8 @@
*/
public void
onPeriodicAdvertisingParametersUpdated(AdvertisingSet advertisingSet,
- int status) {}
+ int status) {
+ }
/**
* Callback triggered in response to {@link AdvertisingSet#setPeriodicAdvertisingData}
@@ -132,7 +138,8 @@
* @param status Status of the operation.
*/
public void onPeriodicAdvertisingDataSet(AdvertisingSet advertisingSet,
- int status) {}
+ int status) {
+ }
/**
* Callback triggered in response to {@link AdvertisingSet#setPeriodicAdvertisingEnabled}
@@ -142,7 +149,8 @@
* @param status Status of the operation.
*/
public void onPeriodicAdvertisingEnabled(AdvertisingSet advertisingSet, boolean enable,
- int status) {}
+ int status) {
+ }
/**
* Callback triggered in response to {@link AdvertisingSet#getOwnAddress()}
@@ -153,5 +161,6 @@
* @param address advertising set bluetooth address.
* @hide
*/
- public void onOwnAddressRead(AdvertisingSet advertisingSet, int addressType, String address) {}
+ public void onOwnAddressRead(AdvertisingSet advertisingSet, int addressType, String address) {
+ }
}
\ No newline at end of file
diff --git a/framework/java/android/bluetooth/le/AdvertisingSetParameters.java b/framework/java/android/bluetooth/le/AdvertisingSetParameters.java
index e9747d8..f795861 100644
--- a/framework/java/android/bluetooth/le/AdvertisingSetParameters.java
+++ b/framework/java/android/bluetooth/le/AdvertisingSetParameters.java
@@ -31,9 +31,9 @@
public final class AdvertisingSetParameters implements Parcelable {
/**
- * Advertise on low frequency, around every 1000ms. This is the default and
- * preferred advertising mode as it consumes the least power.
- */
+ * Advertise on low frequency, around every 1000ms. This is the default and
+ * preferred advertising mode as it consumes the least power.
+ */
public static final int INTERVAL_HIGH = 1600;
/**
@@ -108,9 +108,9 @@
private final int txPowerLevel;
private AdvertisingSetParameters(boolean connectable, boolean scannable, boolean isLegacy,
- boolean isAnonymous, boolean includeTxPower,
- int primaryPhy, int secondaryPhy,
- int interval, int txPowerLevel) {
+ boolean isAnonymous, boolean includeTxPower,
+ int primaryPhy, int secondaryPhy,
+ int interval, int txPowerLevel) {
this.connectable = connectable;
this.scannable = scannable;
this.isLegacy = isLegacy;
@@ -137,63 +137,81 @@
/**
* Returns whether the advertisement will be connectable.
*/
- public boolean isConnectable() { return connectable; }
+ public boolean isConnectable() {
+ return connectable;
+ }
/**
* Returns whether the advertisement will be scannable.
*/
- public boolean isScannable() { return scannable; }
+ public boolean isScannable() {
+ return scannable;
+ }
/**
* Returns whether the legacy advertisement will be used.
*/
- public boolean isLegacy() { return isLegacy; }
+ public boolean isLegacy() {
+ return isLegacy;
+ }
/**
* Returns whether the advertisement will be anonymous.
*/
- public boolean isAnonymous() { return isAnonymous; }
+ public boolean isAnonymous() {
+ return isAnonymous;
+ }
/**
* Returns whether the TX Power will be included.
*/
- public boolean includeTxPower() { return includeTxPower; }
+ public boolean includeTxPower() {
+ return includeTxPower;
+ }
/**
* Returns the primary advertising phy.
*/
- public int getPrimaryPhy() { return primaryPhy; }
+ public int getPrimaryPhy() {
+ return primaryPhy;
+ }
/**
* Returns the secondary advertising phy.
*/
- public int getSecondaryPhy() { return secondaryPhy; }
+ public int getSecondaryPhy() {
+ return secondaryPhy;
+ }
/**
* Returns the advertising interval.
*/
- public int getInterval() { return interval; }
+ public int getInterval() {
+ return interval;
+ }
/**
* Returns the TX power level for advertising.
*/
- public int getTxPowerLevel() { return txPowerLevel; }
+ public int getTxPowerLevel() {
+ return txPowerLevel;
+ }
@Override
public String toString() {
return "AdvertisingSetParameters [connectable=" + connectable
- + ", isLegacy=" + isLegacy
- + ", isAnonymous=" + isAnonymous
- + ", includeTxPower=" + includeTxPower
- + ", primaryPhy=" + primaryPhy
- + ", secondaryPhy=" + secondaryPhy
- + ", interval=" + interval
- + ", txPowerLevel=" + txPowerLevel + "]";
+ + ", isLegacy=" + isLegacy
+ + ", isAnonymous=" + isAnonymous
+ + ", includeTxPower=" + includeTxPower
+ + ", primaryPhy=" + primaryPhy
+ + ", secondaryPhy=" + secondaryPhy
+ + ", interval=" + interval
+ + ", txPowerLevel=" + txPowerLevel + "]";
}
@Override
public int describeContents() {
- return 0;
+ return 0;
}
@Override
@@ -210,17 +228,17 @@
}
public static final Parcelable.Creator<AdvertisingSetParameters> CREATOR =
- new Creator<AdvertisingSetParameters>() {
- @Override
- public AdvertisingSetParameters[] newArray(int size) {
- return new AdvertisingSetParameters[size];
- }
+ new Creator<AdvertisingSetParameters>() {
+ @Override
+ public AdvertisingSetParameters[] newArray(int size) {
+ return new AdvertisingSetParameters[size];
+ }
- @Override
- public AdvertisingSetParameters createFromParcel(Parcel in) {
- return new AdvertisingSetParameters(in);
- }
- };
+ @Override
+ public AdvertisingSetParameters createFromParcel(Parcel in) {
+ return new AdvertisingSetParameters(in);
+ }
+ };
/**
* Builder class for {@link AdvertisingSetParameters}.
@@ -242,8 +260,9 @@
* non-connectable.
* Legacy advertisements can be both connectable and scannable. Non-legacy
* advertisements can be only scannable or only connectable.
- * @param connectable Controls whether the advertisement type will be
- * connectable (true) or non-connectable (false).
+ *
+ * @param connectable Controls whether the advertisement type will be connectable (true) or
+ * non-connectable (false).
*/
public Builder setConnectable(boolean connectable) {
this.connectable = connectable;
@@ -254,8 +273,9 @@
* Set whether the advertisement type should be scannable.
* Legacy advertisements can be both connectable and scannable. Non-legacy
* advertisements can be only scannable or only connectable.
- * @param scannable Controls whether the advertisement type will be
- * scannable (true) or non-scannable (false).
+ *
+ * @param scannable Controls whether the advertisement type will be scannable (true) or
+ * non-scannable (false).
*/
public Builder setScannable(boolean scannable) {
this.scannable = scannable;
@@ -291,8 +311,7 @@
*
* This is used only if legacy mode is not used.
*
- * @param includeTxPower whether TX power should be included in extended
- * header
+ * @param includeTxPower whether TX power should be included in extended header
*/
public Builder setIncludeTxPower(boolean includeTxPower) {
this.includeTxPower = includeTxPower;
@@ -306,15 +325,15 @@
*
* Use {@link BluetoothAdapter#isLeCodedPhySupported} to determine if LE Coded PHY is
* supported on this device.
- * @param primaryPhy Primary advertising physical channel, can only be
- * {@link BluetoothDevice#PHY_LE_1M} or
- * {@link BluetoothDevice#PHY_LE_CODED}.
+ *
+ * @param primaryPhy Primary advertising physical channel, can only be {@link
+ * BluetoothDevice#PHY_LE_1M} or {@link BluetoothDevice#PHY_LE_CODED}.
* @throws IllegalArgumentException If the primaryPhy is invalid.
*/
public Builder setPrimaryPhy(int primaryPhy) {
if (primaryPhy != BluetoothDevice.PHY_LE_1M &&
- primaryPhy != BluetoothDevice.PHY_LE_CODED) {
- throw new IllegalArgumentException("bad primaryPhy " + primaryPhy);
+ primaryPhy != BluetoothDevice.PHY_LE_CODED) {
+ throw new IllegalArgumentException("bad primaryPhy " + primaryPhy);
}
this.primaryPhy = primaryPhy;
return this;
@@ -329,17 +348,16 @@
* {@link BluetoothAdapter#isLe2MPhySupported} to determine if LE Coded PHY or 2M PHY is
* supported on this device.
*
- * @param secondaryPhy Secondary advertising physical channel, can only be
- * one of {@link BluetoothDevice#PHY_LE_1M},
- * {@link BluetoothDevice#PHY_LE_2M} or
- * {@link BluetoothDevice#PHY_LE_CODED}.
+ * @param secondaryPhy Secondary advertising physical channel, can only be one of {@link
+ * BluetoothDevice#PHY_LE_1M}, {@link BluetoothDevice#PHY_LE_2M} or {@link
+ * BluetoothDevice#PHY_LE_CODED}.
* @throws IllegalArgumentException If the secondaryPhy is invalid.
*/
public Builder setSecondaryPhy(int secondaryPhy) {
if (secondaryPhy != BluetoothDevice.PHY_LE_1M &&
- secondaryPhy != BluetoothDevice.PHY_LE_2M &&
- secondaryPhy != BluetoothDevice.PHY_LE_CODED) {
- throw new IllegalArgumentException("bad secondaryPhy " + secondaryPhy);
+ secondaryPhy != BluetoothDevice.PHY_LE_2M &&
+ secondaryPhy != BluetoothDevice.PHY_LE_CODED) {
+ throw new IllegalArgumentException("bad secondaryPhy " + secondaryPhy);
}
this.secondaryPhy = secondaryPhy;
return this;
@@ -348,17 +366,15 @@
/**
* Set advertising interval.
*
- * @param interval Bluetooth LE Advertising interval, in 0.625ms unit. Valid
- * range is from 160 (100ms) to 16777215 (10,485.759375 s).
- * Recommended values are:
- * {@link AdvertisingSetParameters#INTERVAL_LOW},
- * {@link AdvertisingSetParameters#INTERVAL_MEDIUM}, or
- * {@link AdvertisingSetParameters#INTERVAL_HIGH}.
+ * @param interval Bluetooth LE Advertising interval, in 0.625ms unit. Valid range is from
+ * 160 (100ms) to 16777215 (10,485.759375 s). Recommended values are: {@link
+ * AdvertisingSetParameters#INTERVAL_LOW}, {@link AdvertisingSetParameters#INTERVAL_MEDIUM},
+ * or {@link AdvertisingSetParameters#INTERVAL_HIGH}.
* @throws IllegalArgumentException If the interval is invalid.
*/
public Builder setInterval(int interval) {
if (interval < INTERVAL_MIN || interval > INTERVAL_MAX) {
- throw new IllegalArgumentException("unknown interval " + interval);
+ throw new IllegalArgumentException("unknown interval " + interval);
}
this.interval = interval;
return this;
@@ -366,19 +382,19 @@
/**
* Set the transmission power level for the advertising.
- * @param txPowerLevel Transmission power of Bluetooth LE Advertising, in
- * dBm. The valid range is [-127, 1] Recommended values are:
- * {@link AdvertisingSetParameters#TX_POWER_ULTRA_LOW},
- * {@link AdvertisingSetParameters#TX_POWER_LOW},
- * {@link AdvertisingSetParameters#TX_POWER_MEDIUM}, or
- * {@link AdvertisingSetParameters#TX_POWER_HIGH}.
*
+ * @param txPowerLevel Transmission power of Bluetooth LE Advertising, in dBm. The valid
+ * range is [-127, 1] Recommended values are:
+ * {@link AdvertisingSetParameters#TX_POWER_ULTRA_LOW},
+ * {@link AdvertisingSetParameters#TX_POWER_LOW},
+ * {@link AdvertisingSetParameters#TX_POWER_MEDIUM},
+ * or {@link AdvertisingSetParameters#TX_POWER_HIGH}.
* @throws IllegalArgumentException If the {@code txPowerLevel} is invalid.
*/
public Builder setTxPowerLevel(int txPowerLevel) {
if (txPowerLevel < TX_POWER_MIN || txPowerLevel > TX_POWER_MAX) {
throw new IllegalArgumentException("unknown txPowerLevel " +
- txPowerLevel);
+ txPowerLevel);
}
this.txPowerLevel = txPowerLevel;
return this;
@@ -386,6 +402,7 @@
/**
* Build the {@link AdvertisingSetParameters} object.
+ *
* @throws IllegalStateException if invalid combination of parameters is used.
*/
public AdvertisingSetParameters build() {
@@ -396,28 +413,28 @@
if (connectable == true && scannable == false) {
throw new IllegalStateException(
- "Legacy advertisement can't be connectable and non-scannable");
+ "Legacy advertisement can't be connectable and non-scannable");
}
if (includeTxPower) {
throw new IllegalStateException(
- "Legacy advertising can't include TX power level in header");
+ "Legacy advertising can't include TX power level in header");
}
} else {
if (connectable && scannable) {
throw new IllegalStateException(
- "Advertising can't be both connectable and scannable");
+ "Advertising can't be both connectable and scannable");
}
if (isAnonymous && connectable) {
throw new IllegalStateException(
- "Advertising can't be both connectable and anonymous");
+ "Advertising can't be both connectable and anonymous");
}
}
return new AdvertisingSetParameters(connectable, scannable, isLegacy, isAnonymous,
- includeTxPower, primaryPhy,
- secondaryPhy, interval, txPowerLevel);
+ includeTxPower, primaryPhy,
+ secondaryPhy, interval, txPowerLevel);
}
}
}
\ No newline at end of file
diff --git a/framework/java/android/bluetooth/le/BluetoothLeAdvertiser.java b/framework/java/android/bluetooth/le/BluetoothLeAdvertiser.java
index 44c2667..08128de 100644
--- a/framework/java/android/bluetooth/le/BluetoothLeAdvertiser.java
+++ b/framework/java/android/bluetooth/le/BluetoothLeAdvertiser.java
@@ -18,7 +18,6 @@
import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothDevice;
-import android.bluetooth.BluetoothGatt;
import android.bluetooth.BluetoothUuid;
import android.bluetooth.IBluetoothGatt;
import android.bluetooth.IBluetoothManager;
@@ -31,7 +30,6 @@
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
-import java.util.UUID;
/**
* This class provides a way to perform Bluetooth LE advertise operations, such as starting and
@@ -152,13 +150,13 @@
int duration = 0;
int timeoutMillis = settings.getTimeout();
if (timeoutMillis > 0) {
- duration = (timeoutMillis < 10) ? 1 : timeoutMillis/10;
+ duration = (timeoutMillis < 10) ? 1 : timeoutMillis / 10;
}
AdvertisingSetCallback wrapped = wrapOldCallback(callback, settings);
mLegacyAdvertisers.put(callback, wrapped);
startAdvertisingSet(parameters.build(), advertiseData, scanResponse, null, null,
- duration, 0, wrapped);
+ duration, 0, wrapped);
}
}
@@ -166,7 +164,7 @@
return new AdvertisingSetCallback() {
@Override
public void onAdvertisingSetStarted(AdvertisingSet advertisingSet, int txPower,
- int status) {
+ int status) {
if (status != AdvertisingSetCallback.ADVERTISE_SUCCESS) {
postStartFailure(callback, status);
return;
@@ -178,10 +176,10 @@
/* Legacy advertiser is disabled on timeout */
@Override
public void onAdvertisingEnabled(AdvertisingSet advertisingSet, boolean enabled,
- int status) {
+ int status) {
if (enabled == true) {
Log.e(TAG, "Legacy advertiser should be only disabled on timeout," +
- " but was enabled!");
+ " but was enabled!");
return;
}
@@ -218,28 +216,28 @@
* method returns immediately, the operation status is delivered through
* {@code callback.onAdvertisingSetStarted()}.
* <p>
+ *
* @param parameters advertising set parameters.
- * @param advertiseData Advertisement data to be broadcasted. Size must not exceed
- * {@link BluetoothAdapter#getLeMaximumAdvertisingDataLength}. If the
- * advertisement is connectable, three bytes will be added for flags.
+ * @param advertiseData Advertisement data to be broadcasted. Size must not exceed {@link
+ * BluetoothAdapter#getLeMaximumAdvertisingDataLength}. If the advertisement is connectable,
+ * three bytes will be added for flags.
* @param scanResponse Scan response associated with the advertisement data. Size must not
- * exceed {@link BluetoothAdapter#getLeMaximumAdvertisingDataLength}.
+ * exceed {@link BluetoothAdapter#getLeMaximumAdvertisingDataLength}.
* @param periodicParameters periodic advertisng parameters. If null, periodic advertising will
- * not be started.
- * @param periodicData Periodic advertising data. Size must not exceed
- * {@link BluetoothAdapter#getLeMaximumAdvertisingDataLength}.
+ * not be started.
+ * @param periodicData Periodic advertising data. Size must not exceed {@link
+ * BluetoothAdapter#getLeMaximumAdvertisingDataLength}.
* @param callback Callback for advertising set.
* @throws IllegalArgumentException when any of the data parameter exceed the maximum allowable
- * size, or unsupported advertising PHY is selected, or when attempt to use
- * Periodic Advertising feature is made when it's not supported by the
- * controller.
+ * size, or unsupported advertising PHY is selected, or when attempt to use Periodic Advertising
+ * feature is made when it's not supported by the controller.
*/
public void startAdvertisingSet(AdvertisingSetParameters parameters,
- AdvertiseData advertiseData, AdvertiseData scanResponse,
- PeriodicAdvertisingParameters periodicParameters,
- AdvertiseData periodicData, AdvertisingSetCallback callback) {
- startAdvertisingSet(parameters, advertiseData, scanResponse, periodicParameters,
- periodicData, 0, 0, callback, new Handler(Looper.getMainLooper()));
+ AdvertiseData advertiseData, AdvertiseData scanResponse,
+ PeriodicAdvertisingParameters periodicParameters,
+ AdvertiseData periodicData, AdvertisingSetCallback callback) {
+ startAdvertisingSet(parameters, advertiseData, scanResponse, periodicParameters,
+ periodicData, 0, 0, callback, new Handler(Looper.getMainLooper()));
}
/**
@@ -247,30 +245,30 @@
* method returns immediately, the operation status is delivered through
* {@code callback.onAdvertisingSetStarted()}.
* <p>
+ *
* @param parameters advertising set parameters.
- * @param advertiseData Advertisement data to be broadcasted. Size must not exceed
- * {@link BluetoothAdapter#getLeMaximumAdvertisingDataLength}. If the
- * advertisement is connectable, three bytes will be added for flags.
+ * @param advertiseData Advertisement data to be broadcasted. Size must not exceed {@link
+ * BluetoothAdapter#getLeMaximumAdvertisingDataLength}. If the advertisement is connectable,
+ * three bytes will be added for flags.
* @param scanResponse Scan response associated with the advertisement data. Size must not
- * exceed {@link BluetoothAdapter#getLeMaximumAdvertisingDataLength}.
+ * exceed {@link BluetoothAdapter#getLeMaximumAdvertisingDataLength}.
* @param periodicParameters periodic advertisng parameters. If null, periodic advertising will
- * not be started.
- * @param periodicData Periodic advertising data. Size must not exceed
- * {@link BluetoothAdapter#getLeMaximumAdvertisingDataLength}.
+ * not be started.
+ * @param periodicData Periodic advertising data. Size must not exceed {@link
+ * BluetoothAdapter#getLeMaximumAdvertisingDataLength}.
* @param callback Callback for advertising set.
* @param handler thread upon which the callbacks will be invoked.
* @throws IllegalArgumentException when any of the data parameter exceed the maximum allowable
- * size, or unsupported advertising PHY is selected, or when attempt to use
- * Periodic Advertising feature is made when it's not supported by the
- * controller.
+ * size, or unsupported advertising PHY is selected, or when attempt to use Periodic Advertising
+ * feature is made when it's not supported by the controller.
*/
public void startAdvertisingSet(AdvertisingSetParameters parameters,
- AdvertiseData advertiseData, AdvertiseData scanResponse,
- PeriodicAdvertisingParameters periodicParameters,
- AdvertiseData periodicData, AdvertisingSetCallback callback,
- Handler handler) {
+ AdvertiseData advertiseData, AdvertiseData scanResponse,
+ PeriodicAdvertisingParameters periodicParameters,
+ AdvertiseData periodicData, AdvertisingSetCallback callback,
+ Handler handler) {
startAdvertisingSet(parameters, advertiseData, scanResponse, periodicParameters,
- periodicData, 0, 0, callback, handler);
+ periodicData, 0, 0, callback, handler);
}
/**
@@ -278,37 +276,36 @@
* method returns immediately, the operation status is delivered through
* {@code callback.onAdvertisingSetStarted()}.
* <p>
+ *
* @param parameters advertising set parameters.
- * @param advertiseData Advertisement data to be broadcasted. Size must not exceed
- * {@link BluetoothAdapter#getLeMaximumAdvertisingDataLength}. If the
- * advertisement is connectable, three bytes will be added for flags.
+ * @param advertiseData Advertisement data to be broadcasted. Size must not exceed {@link
+ * BluetoothAdapter#getLeMaximumAdvertisingDataLength}. If the advertisement is connectable,
+ * three bytes will be added for flags.
* @param scanResponse Scan response associated with the advertisement data. Size must not
- * exceed {@link BluetoothAdapter#getLeMaximumAdvertisingDataLength}.
+ * exceed {@link BluetoothAdapter#getLeMaximumAdvertisingDataLength}.
* @param periodicParameters periodic advertisng parameters. If null, periodic advertising will
- * not be started.
- * @param periodicData Periodic advertising data. Size must not exceed
- * {@link BluetoothAdapter#getLeMaximumAdvertisingDataLength}.
- * @param duration advertising duration, in 10ms unit. Valid range is from 1 (10ms) to
- * 65535 (655,350 ms). 0 means advertising should continue until stopped.
+ * not be started.
+ * @param periodicData Periodic advertising data. Size must not exceed {@link
+ * BluetoothAdapter#getLeMaximumAdvertisingDataLength}.
+ * @param duration advertising duration, in 10ms unit. Valid range is from 1 (10ms) to 65535
+ * (655,350 ms). 0 means advertising should continue until stopped.
* @param maxExtendedAdvertisingEvents maximum number of extended advertising events the
- * controller shall attempt to send prior to terminating the extended
- * advertising, even if the duration has not expired. Valid range is
- * from 1 to 255. 0 means no maximum.
+ * controller shall attempt to send prior to terminating the extended advertising, even if the
+ * duration has not expired. Valid range is from 1 to 255. 0 means no maximum.
* @param callback Callback for advertising set.
* @throws IllegalArgumentException when any of the data parameter exceed the maximum allowable
- * size, or unsupported advertising PHY is selected, or when attempt to use
- * Periodic Advertising feature is made when it's not supported by the
- * controller.
+ * size, or unsupported advertising PHY is selected, or when attempt to use Periodic Advertising
+ * feature is made when it's not supported by the controller.
*/
public void startAdvertisingSet(AdvertisingSetParameters parameters,
- AdvertiseData advertiseData, AdvertiseData scanResponse,
- PeriodicAdvertisingParameters periodicParameters,
- AdvertiseData periodicData, int duration,
- int maxExtendedAdvertisingEvents,
- AdvertisingSetCallback callback) {
+ AdvertiseData advertiseData, AdvertiseData scanResponse,
+ PeriodicAdvertisingParameters periodicParameters,
+ AdvertiseData periodicData, int duration,
+ int maxExtendedAdvertisingEvents,
+ AdvertisingSetCallback callback) {
startAdvertisingSet(parameters, advertiseData, scanResponse, periodicParameters,
- periodicData, duration, maxExtendedAdvertisingEvents, callback,
- new Handler(Looper.getMainLooper()));
+ periodicData, duration, maxExtendedAdvertisingEvents, callback,
+ new Handler(Looper.getMainLooper()));
}
/**
@@ -316,39 +313,39 @@
* method returns immediately, the operation status is delivered through
* {@code callback.onAdvertisingSetStarted()}.
* <p>
+ *
* @param parameters Advertising set parameters.
- * @param advertiseData Advertisement data to be broadcasted. Size must not exceed
- * {@link BluetoothAdapter#getLeMaximumAdvertisingDataLength}. If the
- * advertisement is connectable, three bytes will be added for flags.
+ * @param advertiseData Advertisement data to be broadcasted. Size must not exceed {@link
+ * BluetoothAdapter#getLeMaximumAdvertisingDataLength}. If the advertisement is connectable,
+ * three bytes will be added for flags.
* @param scanResponse Scan response associated with the advertisement data. Size must not
- * exceed {@link BluetoothAdapter#getLeMaximumAdvertisingDataLength}
+ * exceed {@link BluetoothAdapter#getLeMaximumAdvertisingDataLength}
* @param periodicParameters Periodic advertisng parameters. If null, periodic advertising will
- * not be started.
- * @param periodicData Periodic advertising data. Size must not exceed
- * {@link BluetoothAdapter#getLeMaximumAdvertisingDataLength}
- * @param duration advertising duration, in 10ms unit. Valid range is from 1 (10ms) to
- * 65535 (655,350 ms). 0 means advertising should continue until stopped.
+ * not be started.
+ * @param periodicData Periodic advertising data. Size must not exceed {@link
+ * BluetoothAdapter#getLeMaximumAdvertisingDataLength}
+ * @param duration advertising duration, in 10ms unit. Valid range is from 1 (10ms) to 65535
+ * (655,350 ms). 0 means advertising should continue until stopped.
* @param maxExtendedAdvertisingEvents maximum number of extended advertising events the
- * controller shall attempt to send prior to terminating the extended
- * advertising, even if the duration has not expired. Valid range is
- * from 1 to 255. 0 means no maximum.
+ * controller shall attempt to send prior to terminating the extended advertising, even if the
+ * duration has not expired. Valid range is from 1 to 255. 0 means no maximum.
* @param callback Callback for advertising set.
* @param handler Thread upon which the callbacks will be invoked.
* @throws IllegalArgumentException When any of the data parameter exceed the maximum allowable
- * size, or unsupported advertising PHY is selected, or when attempt to use
- * Periodic Advertising feature is made when it's not supported by the
- * controller, or when maxExtendedAdvertisingEvents is used on a controller
- * that doesn't support the LE Extended Advertising
+ * size, or unsupported advertising PHY is selected, or when attempt to use Periodic Advertising
+ * feature is made when it's not supported by the controller, or when
+ * maxExtendedAdvertisingEvents is used on a controller that doesn't support the LE Extended
+ * Advertising
*/
public void startAdvertisingSet(AdvertisingSetParameters parameters,
- AdvertiseData advertiseData, AdvertiseData scanResponse,
- PeriodicAdvertisingParameters periodicParameters,
- AdvertiseData periodicData, int duration,
- int maxExtendedAdvertisingEvents, AdvertisingSetCallback callback,
- Handler handler) {
+ AdvertiseData advertiseData, AdvertiseData scanResponse,
+ PeriodicAdvertisingParameters periodicParameters,
+ AdvertiseData periodicData, int duration,
+ int maxExtendedAdvertisingEvents, AdvertisingSetCallback callback,
+ Handler handler) {
BluetoothLeUtils.checkAdapterStateOn(mBluetoothAdapter);
if (callback == null) {
- throw new IllegalArgumentException("callback cannot be null");
+ throw new IllegalArgumentException("callback cannot be null");
}
boolean isConnectable = parameters.isConnectable();
@@ -370,7 +367,7 @@
}
if ((sphy == BluetoothDevice.PHY_LE_CODED && !supportCodedPhy)
- || (sphy == BluetoothDevice.PHY_LE_2M && !support2MPhy)) {
+ || (sphy == BluetoothDevice.PHY_LE_2M && !support2MPhy)) {
throw new IllegalArgumentException("Unsupported secondary PHY selected");
}
@@ -390,20 +387,20 @@
boolean supportPeriodic = mBluetoothAdapter.isLePeriodicAdvertisingSupported();
if (periodicParameters != null && !supportPeriodic) {
throw new IllegalArgumentException(
- "Controller does not support LE Periodic Advertising");
+ "Controller does not support LE Periodic Advertising");
}
}
if (maxExtendedAdvertisingEvents < 0 || maxExtendedAdvertisingEvents > 255) {
throw new IllegalArgumentException(
- "maxExtendedAdvertisingEvents out of range: " + maxExtendedAdvertisingEvents);
+ "maxExtendedAdvertisingEvents out of range: " + maxExtendedAdvertisingEvents);
}
if (maxExtendedAdvertisingEvents != 0 &&
- !mBluetoothAdapter.isLePeriodicAdvertisingSupported()) {
+ !mBluetoothAdapter.isLePeriodicAdvertisingSupported()) {
throw new IllegalArgumentException(
- "Can't use maxExtendedAdvertisingEvents with controller that don't support " +
- "LE Extended Advertising");
+ "Can't use maxExtendedAdvertisingEvents with controller that don't support " +
+ "LE Extended Advertising");
}
if (duration < 0 || duration > 65535) {
@@ -412,26 +409,28 @@
IBluetoothGatt gatt;
try {
- gatt = mBluetoothManager.getBluetoothGatt();
+ gatt = mBluetoothManager.getBluetoothGatt();
} catch (RemoteException e) {
- Log.e(TAG, "Failed to get Bluetooth gatt - ", e);
- postStartSetFailure(handler, callback, AdvertiseCallback.ADVERTISE_FAILED_INTERNAL_ERROR);
- return;
+ Log.e(TAG, "Failed to get Bluetooth gatt - ", e);
+ postStartSetFailure(handler, callback,
+ AdvertiseCallback.ADVERTISE_FAILED_INTERNAL_ERROR);
+ return;
}
IAdvertisingSetCallback wrapped = wrap(callback, handler);
if (mCallbackWrappers.putIfAbsent(callback, wrapped) != null) {
throw new IllegalArgumentException(
- "callback instance already associated with advertising");
+ "callback instance already associated with advertising");
}
try {
gatt.startAdvertisingSet(parameters, advertiseData, scanResponse, periodicParameters,
- periodicData, duration, maxExtendedAdvertisingEvents, wrapped);
+ periodicData, duration, maxExtendedAdvertisingEvents, wrapped);
} catch (RemoteException e) {
- Log.e(TAG, "Failed to start advertising set - ", e);
- postStartSetFailure(handler, callback, AdvertiseCallback.ADVERTISE_FAILED_INTERNAL_ERROR);
- return;
+ Log.e(TAG, "Failed to start advertising set - ", e);
+ postStartSetFailure(handler, callback,
+ AdvertiseCallback.ADVERTISE_FAILED_INTERNAL_ERROR);
+ return;
}
}
@@ -441,7 +440,7 @@
*/
public void stopAdvertisingSet(AdvertisingSetCallback callback) {
if (callback == null) {
- throw new IllegalArgumentException("callback cannot be null");
+ throw new IllegalArgumentException("callback cannot be null");
}
IAdvertisingSetCallback wrapped = mCallbackWrappers.remove(callback);
@@ -453,9 +452,9 @@
try {
gatt = mBluetoothManager.getBluetoothGatt();
gatt.stopAdvertisingSet(wrapped);
- } catch (RemoteException e) {
+ } catch (RemoteException e) {
Log.e(TAG, "Failed to stop advertising - ", e);
- }
+ }
}
/**
@@ -539,7 +538,7 @@
}
AdvertisingSet advertisingSet =
- new AdvertisingSet(advertiserId, mBluetoothManager);
+ new AdvertisingSet(advertiserId, mBluetoothManager);
mAdvertisingSets.put(advertiserId, advertisingSet);
callback.onAdvertisingSetStarted(advertisingSet, txPower, status);
}
@@ -650,13 +649,13 @@
}
private void postStartSetFailure(Handler handler, final AdvertisingSetCallback callback,
- final int error) {
+ final int error) {
handler.post(new Runnable() {
- @Override
- public void run() {
- callback.onAdvertisingSetStarted(null, 0, error);
- }
- });
+ @Override
+ public void run() {
+ callback.onAdvertisingSetStarted(null, 0, error);
+ }
+ });
}
private void postStartFailure(final AdvertiseCallback callback, final int error) {
diff --git a/framework/java/android/bluetooth/le/BluetoothLeScanner.java b/framework/java/android/bluetooth/le/BluetoothLeScanner.java
index 1eac395..41c4f5a 100644
--- a/framework/java/android/bluetooth/le/BluetoothLeScanner.java
+++ b/framework/java/android/bluetooth/le/BluetoothLeScanner.java
@@ -74,6 +74,7 @@
/**
* Optional extra indicating the callback type, which will be one of
* CALLBACK_TYPE_* constants in {@link ScanSettings}.
+ *
* @see ScanCallback#onScanResult(int, ScanResult)
*/
public static final String EXTRA_CALLBACK_TYPE = "android.bluetooth.le.extra.CALLBACK_TYPE";
@@ -162,13 +163,13 @@
* specify on behalf of which application(s) the work is being done.
*
* @param workSource {@link WorkSource} identifying the application(s) for which to blame for
- * the scan.
+ * the scan.
* @param callback Callback used to deliver scan results.
* @hide
*/
@SystemApi
@RequiresPermission(allOf = {
- Manifest.permission.BLUETOOTH_ADMIN, Manifest.permission.UPDATE_DEVICE_STATS })
+ Manifest.permission.BLUETOOTH_ADMIN, Manifest.permission.UPDATE_DEVICE_STATS})
public void startScanFromSource(final WorkSource workSource, final ScanCallback callback) {
startScanFromSource(null, new ScanSettings.Builder().build(), workSource, callback);
}
@@ -180,22 +181,22 @@
* @param filters {@link ScanFilter}s for finding exact BLE devices.
* @param settings Settings for the scan.
* @param workSource {@link WorkSource} identifying the application(s) for which to blame for
- * the scan.
+ * the scan.
* @param callback Callback used to deliver scan results.
* @hide
*/
@SystemApi
@RequiresPermission(allOf = {
- Manifest.permission.BLUETOOTH_ADMIN, Manifest.permission.UPDATE_DEVICE_STATS })
+ Manifest.permission.BLUETOOTH_ADMIN, Manifest.permission.UPDATE_DEVICE_STATS})
public void startScanFromSource(List<ScanFilter> filters, ScanSettings settings,
- final WorkSource workSource, final ScanCallback callback) {
+ final WorkSource workSource, final ScanCallback callback) {
startScan(filters, settings, workSource, callback, null, null);
}
private int startScan(List<ScanFilter> filters, ScanSettings settings,
- final WorkSource workSource, final ScanCallback callback,
- final PendingIntent callbackIntent,
- List<List<ResultStorageDescriptor>> resultStorages) {
+ final WorkSource workSource, final ScanCallback callback,
+ final PendingIntent callbackIntent,
+ List<List<ResultStorageDescriptor>> resultStorages) {
BluetoothLeUtils.checkAdapterStateOn(mBluetoothAdapter);
if (callback == null && callbackIntent == null) {
throw new IllegalArgumentException("callback is null");
@@ -218,11 +219,11 @@
}
if (!isSettingsConfigAllowedForScan(settings)) {
return postCallbackErrorOrReturn(callback,
- ScanCallback.SCAN_FAILED_FEATURE_UNSUPPORTED);
+ ScanCallback.SCAN_FAILED_FEATURE_UNSUPPORTED);
}
if (!isHardwareResourcesAvailableForScan(settings)) {
return postCallbackErrorOrReturn(callback,
- ScanCallback.SCAN_FAILED_OUT_OF_HARDWARE_RESOURCES);
+ ScanCallback.SCAN_FAILED_OUT_OF_HARDWARE_RESOURCES);
}
if (!isSettingsAndFilterComboAllowed(settings, filters)) {
return postCallbackErrorOrReturn(callback,
@@ -285,7 +286,7 @@
* will be delivered through the {@code callback}.
*
* @param callback Callback of the Bluetooth LE Scan, it has to be the same instance as the one
- * used to start scan.
+ * used to start scan.
*/
public void flushPendingScanResults(ScanCallback callback) {
BluetoothLeUtils.checkAdapterStateOn(mBluetoothAdapter);
@@ -486,12 +487,13 @@
// Check null in case the scan has been stopped
synchronized (this) {
- if (mScannerId <= 0)
+ if (mScannerId <= 0) {
return;
+ }
}
Handler handler = new Handler(Looper.getMainLooper());
handler.post(new Runnable() {
- @Override
+ @Override
public void run() {
if (onFound) {
mScanCallback.onScanResult(ScanSettings.CALLBACK_TYPE_FIRST_MATCH,
@@ -510,8 +512,9 @@
Log.d(TAG, "onScanManagerErrorCallback() - errorCode = " + errorCode);
}
synchronized (this) {
- if (mScannerId <= 0)
+ if (mScannerId <= 0) {
return;
+ }
}
postCallbackError(mScanCallback, errorCode);
}
@@ -549,11 +552,11 @@
}
private boolean isSettingsAndFilterComboAllowed(ScanSettings settings,
- List <ScanFilter> filterList) {
+ List<ScanFilter> filterList) {
final int callbackType = settings.getCallbackType();
// If onlost/onfound is requested, a non-empty filter is expected
if ((callbackType & (ScanSettings.CALLBACK_TYPE_FIRST_MATCH
- | ScanSettings.CALLBACK_TYPE_MATCH_LOST)) != 0) {
+ | ScanSettings.CALLBACK_TYPE_MATCH_LOST)) != 0) {
if (filterList == null) {
return false;
}
diff --git a/framework/java/android/bluetooth/le/BluetoothLeUtils.java b/framework/java/android/bluetooth/le/BluetoothLeUtils.java
index c40256b..afec72b 100644
--- a/framework/java/android/bluetooth/le/BluetoothLeUtils.java
+++ b/framework/java/android/bluetooth/le/BluetoothLeUtils.java
@@ -128,11 +128,12 @@
/**
* Ensure Bluetooth is turned on.
*
- * @throws IllegalStateException If {@code adapter} is null or Bluetooth state is not
- * {@link BluetoothAdapter#STATE_ON}.
+ * @throws IllegalStateException If {@code adapter} is null or Bluetooth state is not {@link
+ * BluetoothAdapter#STATE_ON}.
*/
static void checkAdapterStateOn(BluetoothAdapter adapter) {
- if (adapter == null || !adapter.isLeEnabled()) {//adapter.getState() != BluetoothAdapter.STATE_ON) {
+ if (adapter == null
+ || !adapter.isLeEnabled()) {//adapter.getState() != BluetoothAdapter.STATE_ON) {
throw new IllegalStateException("BT Adapter is not turned ON");
}
}
diff --git a/framework/java/android/bluetooth/le/PeriodicAdvertisingCallback.java b/framework/java/android/bluetooth/le/PeriodicAdvertisingCallback.java
index 364b575..14ac911 100644
--- a/framework/java/android/bluetooth/le/PeriodicAdvertisingCallback.java
+++ b/framework/java/android/bluetooth/le/PeriodicAdvertisingCallback.java
@@ -22,8 +22,8 @@
* Bluetooth LE periodic advertising callbacks, used to deliver periodic
* advertising operation status.
*
- * @see PeriodicAdvertisingManager#createSync
* @hide
+ * @see PeriodicAdvertisingManager#createSync
*/
public abstract class PeriodicAdvertisingCallback {
@@ -40,7 +40,7 @@
public static final int SYNC_NO_RESPONSE = 1;
/**
- * Sync failed to be established because controller can't support more syncs.
+ * Sync failed to be established because controller can't support more syncs.
*/
public static final int SYNC_NO_RESOURCES = 2;
@@ -51,28 +51,31 @@
* @param syncHandle handle used to identify this synchronization.
* @param device remote device.
* @param advertisingSid synchronized advertising set id.
- * @param skip The number of periodic advertising packets that can be skipped
- * after a successful receive in force. @see PeriodicAdvertisingManager#createSync
- * @param timeout Synchronization timeout for the periodic advertising in force. One
- * unit is 10ms. @see PeriodicAdvertisingManager#createSync
+ * @param skip The number of periodic advertising packets that can be skipped after a successful
+ * receive in force. @see PeriodicAdvertisingManager#createSync
+ * @param timeout Synchronization timeout for the periodic advertising in force. One unit is
+ * 10ms. @see PeriodicAdvertisingManager#createSync
* @param timeout
* @param status operation status.
*/
public void onSyncEstablished(int syncHandle, BluetoothDevice device,
- int advertisingSid, int skip, int timeout,
- int status) {}
+ int advertisingSid, int skip, int timeout,
+ int status) {
+ }
/**
* Callback when periodic advertising report is received.
*
* @param report periodic advertising report.
*/
- public void onPeriodicAdvertisingReport(PeriodicAdvertisingReport report) {}
+ public void onPeriodicAdvertisingReport(PeriodicAdvertisingReport report) {
+ }
/**
* Callback when periodic advertising synchronization was lost.
*
* @param syncHandle handle used to identify this synchronization.
*/
- public void onSyncLost(int syncHandle) {}
+ public void onSyncLost(int syncHandle) {
+ }
}
diff --git a/framework/java/android/bluetooth/le/PeriodicAdvertisingManager.java b/framework/java/android/bluetooth/le/PeriodicAdvertisingManager.java
index d9c2d88..5e7f4c0 100644
--- a/framework/java/android/bluetooth/le/PeriodicAdvertisingManager.java
+++ b/framework/java/android/bluetooth/le/PeriodicAdvertisingManager.java
@@ -24,6 +24,7 @@
import android.os.Looper;
import android.os.RemoteException;
import android.util.Log;
+
import java.util.IdentityHashMap;
import java.util.Map;
@@ -37,202 +38,207 @@
* <p>
* <b>Note:</b> Most of the methods here require
* {@link android.Manifest.permission#BLUETOOTH_ADMIN} permission.
+ *
* @hide
*/
public final class PeriodicAdvertisingManager {
- private static final String TAG = "PeriodicAdvertisingManager";
+ private static final String TAG = "PeriodicAdvertisingManager";
- private static final int SKIP_MIN = 0;
- private static final int SKIP_MAX = 499;
- private static final int TIMEOUT_MIN = 10;
- private static final int TIMEOUT_MAX = 16384;
+ private static final int SKIP_MIN = 0;
+ private static final int SKIP_MAX = 499;
+ private static final int TIMEOUT_MIN = 10;
+ private static final int TIMEOUT_MAX = 16384;
- private static final int SYNC_STARTING = -1;
+ private static final int SYNC_STARTING = -1;
- private final IBluetoothManager mBluetoothManager;
- private BluetoothAdapter mBluetoothAdapter;
+ private final IBluetoothManager mBluetoothManager;
+ private BluetoothAdapter mBluetoothAdapter;
- /* maps callback, to callback wrapper and sync handle */
- Map<PeriodicAdvertisingCallback,
- IPeriodicAdvertisingCallback /* callbackWrapper */> callbackWrappers;
+ /* maps callback, to callback wrapper and sync handle */
+ Map<PeriodicAdvertisingCallback,
+ IPeriodicAdvertisingCallback /* callbackWrapper */> callbackWrappers;
- /**
- * Use {@link BluetoothAdapter#getBluetoothLeScanner()} instead.
- *
- * @param bluetoothManager BluetoothManager that conducts overall Bluetooth Management.
- * @hide
- */
- public PeriodicAdvertisingManager(IBluetoothManager bluetoothManager) {
- mBluetoothManager = bluetoothManager;
- mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
- callbackWrappers = new IdentityHashMap<>();
- }
-
- /**
- * Synchronize with periodic advertising pointed to by the {@code scanResult}.
- * The {@code scanResult} used must contain a valid advertisingSid. First
- * call to registerSync will use the {@code skip} and {@code timeout} provided.
- * Subsequent calls from other apps, trying to sync with same set will reuse
- * existing sync, thus {@code skip} and {@code timeout} values will not take
- * effect. The values in effect will be returned in
- * {@link PeriodicAdvertisingCallback#onSyncEstablished}.
- *
- * @param scanResult Scan result containing advertisingSid.
- * @param skip The number of periodic advertising packets that can be skipped
- * after a successful receive. Must be between 0 and 499.
- * @param timeout Synchronization timeout for the periodic advertising. One
- * unit is 10ms. Must be between 10 (100ms) and 16384 (163.84s).
- * @param callback Callback used to deliver all operations status.
- * @throws IllegalArgumentException if {@code scanResult} is null or {@code
- * skip} is invalid or {@code timeout} is invalid or {@code callback} is null.
- */
- public void registerSync(ScanResult scanResult, int skip, int timeout,
- PeriodicAdvertisingCallback callback) {
- registerSync(scanResult, skip, timeout, callback, null);
- }
-
- /**
- * Synchronize with periodic advertising pointed to by the {@code scanResult}.
- * The {@code scanResult} used must contain a valid advertisingSid. First
- * call to registerSync will use the {@code skip} and {@code timeout} provided.
- * Subsequent calls from other apps, trying to sync with same set will reuse
- * existing sync, thus {@code skip} and {@code timeout} values will not take
- * effect. The values in effect will be returned in
- * {@link PeriodicAdvertisingCallback#onSyncEstablished}.
- *
- * @param scanResult Scan result containing advertisingSid.
- * @param skip The number of periodic advertising packets that can be skipped
- * after a successful receive. Must be between 0 and 499.
- * @param timeout Synchronization timeout for the periodic advertising. One
- * unit is 10ms. Must be between 10 (100ms) and 16384 (163.84s).
- * @param callback Callback used to deliver all operations status.
- * @param handler thread upon which the callbacks will be invoked.
- * @throws IllegalArgumentException if {@code scanResult} is null or {@code
- * skip} is invalid or {@code timeout} is invalid or {@code callback} is null.
- */
- public void registerSync(ScanResult scanResult, int skip, int timeout,
- PeriodicAdvertisingCallback callback, Handler handler) {
- if (callback == null) {
- throw new IllegalArgumentException("callback can't be null");
+ /**
+ * Use {@link BluetoothAdapter#getBluetoothLeScanner()} instead.
+ *
+ * @param bluetoothManager BluetoothManager that conducts overall Bluetooth Management.
+ * @hide
+ */
+ public PeriodicAdvertisingManager(IBluetoothManager bluetoothManager) {
+ mBluetoothManager = bluetoothManager;
+ mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
+ callbackWrappers = new IdentityHashMap<>();
}
- if (scanResult == null) {
- throw new IllegalArgumentException("scanResult can't be null");
+ /**
+ * Synchronize with periodic advertising pointed to by the {@code scanResult}.
+ * The {@code scanResult} used must contain a valid advertisingSid. First
+ * call to registerSync will use the {@code skip} and {@code timeout} provided.
+ * Subsequent calls from other apps, trying to sync with same set will reuse
+ * existing sync, thus {@code skip} and {@code timeout} values will not take
+ * effect. The values in effect will be returned in
+ * {@link PeriodicAdvertisingCallback#onSyncEstablished}.
+ *
+ * @param scanResult Scan result containing advertisingSid.
+ * @param skip The number of periodic advertising packets that can be skipped after a successful
+ * receive. Must be between 0 and 499.
+ * @param timeout Synchronization timeout for the periodic advertising. One unit is 10ms. Must
+ * be between 10 (100ms) and 16384 (163.84s).
+ * @param callback Callback used to deliver all operations status.
+ * @throws IllegalArgumentException if {@code scanResult} is null or {@code skip} is invalid or
+ * {@code timeout} is invalid or {@code callback} is null.
+ */
+ public void registerSync(ScanResult scanResult, int skip, int timeout,
+ PeriodicAdvertisingCallback callback) {
+ registerSync(scanResult, skip, timeout, callback, null);
}
- if (scanResult.getAdvertisingSid() == ScanResult.SID_NOT_PRESENT) {
- throw new IllegalArgumentException("scanResult must contain a valid sid");
+ /**
+ * Synchronize with periodic advertising pointed to by the {@code scanResult}.
+ * The {@code scanResult} used must contain a valid advertisingSid. First
+ * call to registerSync will use the {@code skip} and {@code timeout} provided.
+ * Subsequent calls from other apps, trying to sync with same set will reuse
+ * existing sync, thus {@code skip} and {@code timeout} values will not take
+ * effect. The values in effect will be returned in
+ * {@link PeriodicAdvertisingCallback#onSyncEstablished}.
+ *
+ * @param scanResult Scan result containing advertisingSid.
+ * @param skip The number of periodic advertising packets that can be skipped after a successful
+ * receive. Must be between 0 and 499.
+ * @param timeout Synchronization timeout for the periodic advertising. One unit is 10ms. Must
+ * be between 10 (100ms) and 16384 (163.84s).
+ * @param callback Callback used to deliver all operations status.
+ * @param handler thread upon which the callbacks will be invoked.
+ * @throws IllegalArgumentException if {@code scanResult} is null or {@code skip} is invalid or
+ * {@code timeout} is invalid or {@code callback} is null.
+ */
+ public void registerSync(ScanResult scanResult, int skip, int timeout,
+ PeriodicAdvertisingCallback callback, Handler handler) {
+ if (callback == null) {
+ throw new IllegalArgumentException("callback can't be null");
+ }
+
+ if (scanResult == null) {
+ throw new IllegalArgumentException("scanResult can't be null");
+ }
+
+ if (scanResult.getAdvertisingSid() == ScanResult.SID_NOT_PRESENT) {
+ throw new IllegalArgumentException("scanResult must contain a valid sid");
+ }
+
+ if (skip < SKIP_MIN || skip > SKIP_MAX) {
+ throw new IllegalArgumentException(
+ "timeout must be between " + TIMEOUT_MIN + " and " + TIMEOUT_MAX);
+ }
+
+ if (timeout < TIMEOUT_MIN || timeout > TIMEOUT_MAX) {
+ throw new IllegalArgumentException(
+ "timeout must be between " + TIMEOUT_MIN + " and " + TIMEOUT_MAX);
+ }
+
+ IBluetoothGatt gatt;
+ try {
+ gatt = mBluetoothManager.getBluetoothGatt();
+ } catch (RemoteException e) {
+ Log.e(TAG, "Failed to get Bluetooth gatt - ", e);
+ callback.onSyncEstablished(0, scanResult.getDevice(), scanResult.getAdvertisingSid(),
+ skip, timeout,
+ PeriodicAdvertisingCallback.SYNC_NO_RESOURCES);
+ return;
+ }
+
+ if (handler == null) {
+ handler = new Handler(Looper.getMainLooper());
+ }
+
+ IPeriodicAdvertisingCallback wrapped = wrap(callback, handler);
+ callbackWrappers.put(callback, wrapped);
+
+ try {
+ gatt.registerSync(scanResult, skip, timeout, wrapped);
+ } catch (RemoteException e) {
+ Log.e(TAG, "Failed to register sync - ", e);
+ return;
+ }
}
- if (skip < SKIP_MIN || skip > SKIP_MAX) {
- throw new IllegalArgumentException(
- "timeout must be between " + TIMEOUT_MIN + " and " + TIMEOUT_MAX);
+ /**
+ * Cancel pending attempt to create sync, or terminate existing sync.
+ *
+ * @param callback Callback used to deliver all operations status.
+ * @throws IllegalArgumentException if {@code callback} is null, or not a properly registered
+ * callback.
+ */
+ public void unregisterSync(PeriodicAdvertisingCallback callback) {
+ if (callback == null) {
+ throw new IllegalArgumentException("callback can't be null");
+ }
+
+ IBluetoothGatt gatt;
+ try {
+ gatt = mBluetoothManager.getBluetoothGatt();
+ } catch (RemoteException e) {
+ Log.e(TAG, "Failed to get Bluetooth gatt - ", e);
+ return;
+ }
+
+ IPeriodicAdvertisingCallback wrapper = callbackWrappers.remove(callback);
+ if (wrapper == null) {
+ throw new IllegalArgumentException("callback was not properly registered");
+ }
+
+ try {
+ gatt.unregisterSync(wrapper);
+ } catch (RemoteException e) {
+ Log.e(TAG, "Failed to cancel sync creation - ", e);
+ return;
+ }
}
- if (timeout < TIMEOUT_MIN || timeout > TIMEOUT_MAX) {
- throw new IllegalArgumentException(
- "timeout must be between " + TIMEOUT_MIN + " and " + TIMEOUT_MAX);
+ private IPeriodicAdvertisingCallback wrap(PeriodicAdvertisingCallback callback,
+ Handler handler) {
+ return new IPeriodicAdvertisingCallback.Stub() {
+ public void onSyncEstablished(int syncHandle, BluetoothDevice device,
+ int advertisingSid, int skip, int timeout, int status) {
+
+ handler.post(new Runnable() {
+ @Override
+ public void run() {
+ callback.onSyncEstablished(syncHandle, device, advertisingSid, skip,
+ timeout,
+ status);
+
+ if (status != PeriodicAdvertisingCallback.SYNC_SUCCESS) {
+ // App can still unregister the sync until notified it failed. Remove
+ // callback
+ // after app was notifed.
+ callbackWrappers.remove(callback);
+ }
+ }
+ });
+ }
+
+ public void onPeriodicAdvertisingReport(PeriodicAdvertisingReport report) {
+ handler.post(new Runnable() {
+ @Override
+ public void run() {
+ callback.onPeriodicAdvertisingReport(report);
+ }
+ });
+ }
+
+ public void onSyncLost(int syncHandle) {
+ handler.post(new Runnable() {
+ @Override
+ public void run() {
+ callback.onSyncLost(syncHandle);
+ // App can still unregister the sync until notified it's lost. Remove callback after
+ // app was notifed.
+ callbackWrappers.remove(callback);
+ }
+ });
+ }
+ };
}
-
- IBluetoothGatt gatt;
- try {
- gatt = mBluetoothManager.getBluetoothGatt();
- } catch (RemoteException e) {
- Log.e(TAG, "Failed to get Bluetooth gatt - ", e);
- callback.onSyncEstablished(0, scanResult.getDevice(), scanResult.getAdvertisingSid(),
- skip, timeout,
- PeriodicAdvertisingCallback.SYNC_NO_RESOURCES);
- return;
- }
-
- if (handler == null)
- handler = new Handler(Looper.getMainLooper());
-
- IPeriodicAdvertisingCallback wrapped = wrap(callback, handler);
- callbackWrappers.put(callback, wrapped);
-
- try {
- gatt.registerSync(scanResult, skip, timeout, wrapped);
- } catch (RemoteException e) {
- Log.e(TAG, "Failed to register sync - ", e);
- return;
- }
- }
-
- /**
- * Cancel pending attempt to create sync, or terminate existing sync.
- *
- * @param callback Callback used to deliver all operations status.
- * @throws IllegalArgumentException if {@code callback} is null, or not a properly
- * registered callback.
- */
- public void unregisterSync(PeriodicAdvertisingCallback callback) {
- if (callback == null) {
- throw new IllegalArgumentException("callback can't be null");
- }
-
- IBluetoothGatt gatt;
- try {
- gatt = mBluetoothManager.getBluetoothGatt();
- } catch (RemoteException e) {
- Log.e(TAG, "Failed to get Bluetooth gatt - ", e);
- return;
- }
-
- IPeriodicAdvertisingCallback wrapper = callbackWrappers.remove(callback);
- if (wrapper == null) {
- throw new IllegalArgumentException("callback was not properly registered");
- }
-
- try {
- gatt.unregisterSync(wrapper);
- } catch (RemoteException e) {
- Log.e(TAG, "Failed to cancel sync creation - ", e);
- return;
- }
- }
-
- private IPeriodicAdvertisingCallback wrap(PeriodicAdvertisingCallback callback, Handler handler) {
- return new IPeriodicAdvertisingCallback.Stub() {
- public void onSyncEstablished(int syncHandle, BluetoothDevice device,
- int advertisingSid, int skip, int timeout, int status) {
-
- handler.post(new Runnable() {
- @Override
- public void run() {
- callback.onSyncEstablished(syncHandle, device, advertisingSid, skip, timeout,
- status);
-
- if (status != PeriodicAdvertisingCallback.SYNC_SUCCESS) {
- // App can still unregister the sync until notified it failed. Remove callback
- // after app was notifed.
- callbackWrappers.remove(callback);
- }
- }
- });
- }
-
- public void onPeriodicAdvertisingReport(PeriodicAdvertisingReport report) {
- handler.post(new Runnable() {
- @Override
- public void run() {
- callback.onPeriodicAdvertisingReport(report);
- }
- });
- }
-
- public void onSyncLost(int syncHandle) {
- handler.post(new Runnable() {
- @Override
- public void run() {
- callback.onSyncLost(syncHandle);
- // App can still unregister the sync until notified it's lost. Remove callback after
- // app was notifed.
- callbackWrappers.remove(callback);
- }
- });
- }
- };
- }
}
diff --git a/framework/java/android/bluetooth/le/PeriodicAdvertisingParameters.java b/framework/java/android/bluetooth/le/PeriodicAdvertisingParameters.java
index cf8f08f..5bd4775 100644
--- a/framework/java/android/bluetooth/le/PeriodicAdvertisingParameters.java
+++ b/framework/java/android/bluetooth/le/PeriodicAdvertisingParameters.java
@@ -45,13 +45,17 @@
/**
* Returns whether the TX Power will be included.
*/
- public boolean getIncludeTxPower() { return includeTxPower; }
+ public boolean getIncludeTxPower() {
+ return includeTxPower;
+ }
/**
* Returns the periodic advertising interval, in 1.25ms unit.
* Valid values are from 80 (100ms) to 65519 (81.89875s).
*/
- public int getInterval() { return interval; }
+ public int getInterval() {
+ return interval;
+ }
@Override
public int describeContents() {
@@ -65,18 +69,18 @@
}
public static final Parcelable
- .Creator<PeriodicAdvertisingParameters> CREATOR =
- new Creator<PeriodicAdvertisingParameters>() {
- @Override
- public PeriodicAdvertisingParameters[] newArray(int size) {
- return new PeriodicAdvertisingParameters[size];
- }
+ .Creator<PeriodicAdvertisingParameters> CREATOR =
+ new Creator<PeriodicAdvertisingParameters>() {
+ @Override
+ public PeriodicAdvertisingParameters[] newArray(int size) {
+ return new PeriodicAdvertisingParameters[size];
+ }
- @Override
- public PeriodicAdvertisingParameters createFromParcel(Parcel in) {
- return new PeriodicAdvertisingParameters(in);
- }
- };
+ @Override
+ public PeriodicAdvertisingParameters createFromParcel(Parcel in) {
+ return new PeriodicAdvertisingParameters(in);
+ }
+ };
public static final class Builder {
private boolean includeTxPower = false;
@@ -95,12 +99,13 @@
* Set advertising interval for periodic advertising, in 1.25ms unit.
* Valid values are from 80 (100ms) to 65519 (81.89875s).
* Value from range [interval, interval+20ms] will be picked as the actual value.
+ *
* @throws IllegalArgumentException If the interval is invalid.
*/
public Builder setInterval(int interval) {
if (interval < INTERVAL_MIN || interval > INTERVAL_MAX) {
throw new IllegalArgumentException("Invalid interval (must be " + INTERVAL_MIN +
- "-" + INTERVAL_MAX + ")");
+ "-" + INTERVAL_MAX + ")");
}
this.interval = interval;
return this;
diff --git a/framework/java/android/bluetooth/le/PeriodicAdvertisingReport.java b/framework/java/android/bluetooth/le/PeriodicAdvertisingReport.java
index 51b93cb..9f1099b 100644
--- a/framework/java/android/bluetooth/le/PeriodicAdvertisingReport.java
+++ b/framework/java/android/bluetooth/le/PeriodicAdvertisingReport.java
@@ -24,6 +24,7 @@
/**
* PeriodicAdvertisingReport for Bluetooth LE synchronized advertising.
+ *
* @hide
*/
public final class PeriodicAdvertisingReport implements Parcelable {
@@ -53,10 +54,9 @@
/**
* Constructor of periodic advertising result.
- *
*/
public PeriodicAdvertisingReport(int syncHandle, int txPower, int rssi,
- int dataStatus, ScanRecord data) {
+ int dataStatus, ScanRecord data) {
this.syncHandle = syncHandle;
this.txPower = txPower;
this.rssi = rssi;
@@ -157,29 +157,30 @@
}
PeriodicAdvertisingReport other = (PeriodicAdvertisingReport) obj;
return (syncHandle == other.syncHandle) &&
- (txPower == other.txPower) &&
- (rssi == other.rssi) &&
- (dataStatus == other.dataStatus) &&
- Objects.equals(data, other.data) &&
- (timestampNanos == other.timestampNanos);
+ (txPower == other.txPower) &&
+ (rssi == other.rssi) &&
+ (dataStatus == other.dataStatus) &&
+ Objects.equals(data, other.data) &&
+ (timestampNanos == other.timestampNanos);
}
@Override
public String toString() {
- return "PeriodicAdvertisingReport{syncHandle=" + syncHandle +
- ", txPower=" + txPower + ", rssi=" + rssi + ", dataStatus=" + dataStatus +
- ", data=" + Objects.toString(data) + ", timestampNanos=" + timestampNanos + '}';
+ return "PeriodicAdvertisingReport{syncHandle=" + syncHandle +
+ ", txPower=" + txPower + ", rssi=" + rssi + ", dataStatus=" + dataStatus +
+ ", data=" + Objects.toString(data) + ", timestampNanos=" + timestampNanos + '}';
}
- public static final Parcelable.Creator<PeriodicAdvertisingReport> CREATOR = new Creator<PeriodicAdvertisingReport>() {
- @Override
- public PeriodicAdvertisingReport createFromParcel(Parcel source) {
- return new PeriodicAdvertisingReport(source);
- }
+ public static final Parcelable.Creator<PeriodicAdvertisingReport> CREATOR =
+ new Creator<PeriodicAdvertisingReport>() {
+ @Override
+ public PeriodicAdvertisingReport createFromParcel(Parcel source) {
+ return new PeriodicAdvertisingReport(source);
+ }
- @Override
- public PeriodicAdvertisingReport[] newArray(int size) {
- return new PeriodicAdvertisingReport[size];
- }
- };
+ @Override
+ public PeriodicAdvertisingReport[] newArray(int size) {
+ return new PeriodicAdvertisingReport[size];
+ }
+ };
}
diff --git a/framework/java/android/bluetooth/le/ResultStorageDescriptor.java b/framework/java/android/bluetooth/le/ResultStorageDescriptor.java
index 748f97d..75139b4 100644
--- a/framework/java/android/bluetooth/le/ResultStorageDescriptor.java
+++ b/framework/java/android/bluetooth/le/ResultStorageDescriptor.java
@@ -80,14 +80,14 @@
public static final Parcelable.Creator<ResultStorageDescriptor>
CREATOR = new Creator<ResultStorageDescriptor>() {
- @Override
- public ResultStorageDescriptor createFromParcel(Parcel source) {
- return new ResultStorageDescriptor(source);
- }
+ @Override
+ public ResultStorageDescriptor createFromParcel(Parcel source) {
+ return new ResultStorageDescriptor(source);
+ }
- @Override
- public ResultStorageDescriptor[] newArray(int size) {
- return new ResultStorageDescriptor[size];
- }
- };
+ @Override
+ public ResultStorageDescriptor[] newArray(int size) {
+ return new ResultStorageDescriptor[size];
+ }
+ };
}
diff --git a/framework/java/android/bluetooth/le/ScanCallback.java b/framework/java/android/bluetooth/le/ScanCallback.java
index aff2e90..fcbc2c7 100644
--- a/framework/java/android/bluetooth/le/ScanCallback.java
+++ b/framework/java/android/bluetooth/le/ScanCallback.java
@@ -46,6 +46,7 @@
/**
* Fails to start scan as it is out of hardware resources.
+ *
* @hide
*/
public static final int SCAN_FAILED_OUT_OF_HARDWARE_RESOURCES = 5;
@@ -55,10 +56,9 @@
/**
* Callback when a BLE advertisement has been found.
*
- * @param callbackType Determines how this callback was triggered. Could be one of
- * {@link ScanSettings#CALLBACK_TYPE_ALL_MATCHES},
- * {@link ScanSettings#CALLBACK_TYPE_FIRST_MATCH} or
- * {@link ScanSettings#CALLBACK_TYPE_MATCH_LOST}
+ * @param callbackType Determines how this callback was triggered. Could be one of {@link
+ * ScanSettings#CALLBACK_TYPE_ALL_MATCHES}, {@link ScanSettings#CALLBACK_TYPE_FIRST_MATCH} or
+ * {@link ScanSettings#CALLBACK_TYPE_MATCH_LOST}
* @param result A Bluetooth LE scan result.
*/
public void onScanResult(int callbackType, ScanResult result) {
diff --git a/framework/java/android/bluetooth/le/ScanFilter.java b/framework/java/android/bluetooth/le/ScanFilter.java
index 457096b..f91cb75 100644
--- a/framework/java/android/bluetooth/le/ScanFilter.java
+++ b/framework/java/android/bluetooth/le/ScanFilter.java
@@ -71,7 +71,7 @@
private final byte[] mManufacturerDataMask;
/** @hide */
- public static final ScanFilter EMPTY = new ScanFilter.Builder().build() ;
+ public static final ScanFilter EMPTY = new ScanFilter.Builder().build();
private ScanFilter(String name, String deviceAddress, ParcelUuid uuid,
@@ -148,67 +148,67 @@
public static final Creator<ScanFilter>
CREATOR = new Creator<ScanFilter>() {
- @Override
- public ScanFilter[] newArray(int size) {
- return new ScanFilter[size];
+ @Override
+ public ScanFilter[] newArray(int size) {
+ return new ScanFilter[size];
+ }
+
+ @Override
+ public ScanFilter createFromParcel(Parcel in) {
+ Builder builder = new Builder();
+ if (in.readInt() == 1) {
+ builder.setDeviceName(in.readString());
+ }
+ if (in.readInt() == 1) {
+ builder.setDeviceAddress(in.readString());
+ }
+ if (in.readInt() == 1) {
+ ParcelUuid uuid = in.readParcelable(ParcelUuid.class.getClassLoader());
+ builder.setServiceUuid(uuid);
+ if (in.readInt() == 1) {
+ ParcelUuid uuidMask = in.readParcelable(
+ ParcelUuid.class.getClassLoader());
+ builder.setServiceUuid(uuid, uuidMask);
}
-
- @Override
- public ScanFilter createFromParcel(Parcel in) {
- Builder builder = new Builder();
- if (in.readInt() == 1) {
- builder.setDeviceName(in.readString());
+ }
+ if (in.readInt() == 1) {
+ ParcelUuid servcieDataUuid =
+ in.readParcelable(ParcelUuid.class.getClassLoader());
+ if (in.readInt() == 1) {
+ int serviceDataLength = in.readInt();
+ byte[] serviceData = new byte[serviceDataLength];
+ in.readByteArray(serviceData);
+ if (in.readInt() == 0) {
+ builder.setServiceData(servcieDataUuid, serviceData);
+ } else {
+ int serviceDataMaskLength = in.readInt();
+ byte[] serviceDataMask = new byte[serviceDataMaskLength];
+ in.readByteArray(serviceDataMask);
+ builder.setServiceData(
+ servcieDataUuid, serviceData, serviceDataMask);
}
- if (in.readInt() == 1) {
- builder.setDeviceAddress(in.readString());
- }
- if (in.readInt() == 1) {
- ParcelUuid uuid = in.readParcelable(ParcelUuid.class.getClassLoader());
- builder.setServiceUuid(uuid);
- if (in.readInt() == 1) {
- ParcelUuid uuidMask = in.readParcelable(
- ParcelUuid.class.getClassLoader());
- builder.setServiceUuid(uuid, uuidMask);
- }
- }
- if (in.readInt() == 1) {
- ParcelUuid servcieDataUuid =
- in.readParcelable(ParcelUuid.class.getClassLoader());
- if (in.readInt() == 1) {
- int serviceDataLength = in.readInt();
- byte[] serviceData = new byte[serviceDataLength];
- in.readByteArray(serviceData);
- if (in.readInt() == 0) {
- builder.setServiceData(servcieDataUuid, serviceData);
- } else {
- int serviceDataMaskLength = in.readInt();
- byte[] serviceDataMask = new byte[serviceDataMaskLength];
- in.readByteArray(serviceDataMask);
- builder.setServiceData(
- servcieDataUuid, serviceData, serviceDataMask);
- }
- }
- }
-
- int manufacturerId = in.readInt();
- if (in.readInt() == 1) {
- int manufacturerDataLength = in.readInt();
- byte[] manufacturerData = new byte[manufacturerDataLength];
- in.readByteArray(manufacturerData);
- if (in.readInt() == 0) {
- builder.setManufacturerData(manufacturerId, manufacturerData);
- } else {
- int manufacturerDataMaskLength = in.readInt();
- byte[] manufacturerDataMask = new byte[manufacturerDataMaskLength];
- in.readByteArray(manufacturerDataMask);
- builder.setManufacturerData(manufacturerId, manufacturerData,
- manufacturerDataMask);
- }
- }
-
- return builder.build();
}
- };
+ }
+
+ int manufacturerId = in.readInt();
+ if (in.readInt() == 1) {
+ int manufacturerDataLength = in.readInt();
+ byte[] manufacturerData = new byte[manufacturerDataLength];
+ in.readByteArray(manufacturerData);
+ if (in.readInt() == 0) {
+ builder.setManufacturerData(manufacturerId, manufacturerData);
+ } else {
+ int manufacturerDataMaskLength = in.readInt();
+ byte[] manufacturerDataMask = new byte[manufacturerDataMaskLength];
+ in.readByteArray(manufacturerDataMask);
+ builder.setManufacturerData(manufacturerId, manufacturerData,
+ manufacturerDataMask);
+ }
+ }
+
+ return builder.build();
+ }
+ };
/**
* Returns the filter set the device name field of Bluetooth advertisement data.
@@ -288,7 +288,7 @@
// Scan record is null but there exist filters on it.
if (scanRecord == null
&& (mDeviceName != null || mServiceUuid != null || mManufacturerData != null
- || mServiceData != null)) {
+ || mServiceData != null)) {
return false;
}
@@ -386,12 +386,12 @@
@Override
public int hashCode() {
return Objects.hash(mDeviceName, mDeviceAddress, mManufacturerId,
- Arrays.hashCode(mManufacturerData),
- Arrays.hashCode(mManufacturerDataMask),
- mServiceDataUuid,
- Arrays.hashCode(mServiceData),
- Arrays.hashCode(mServiceDataMask),
- mServiceUuid, mServiceUuidMask);
+ Arrays.hashCode(mManufacturerData),
+ Arrays.hashCode(mManufacturerDataMask),
+ mServiceDataUuid,
+ Arrays.hashCode(mServiceData),
+ Arrays.hashCode(mServiceDataMask),
+ mServiceUuid, mServiceUuidMask);
}
@Override
@@ -417,6 +417,7 @@
/**
* Checks if the scanfilter is empty
+ *
* @hide
*/
public boolean isAllFieldsEmpty() {
@@ -454,8 +455,8 @@
* Set filter on device address.
*
* @param deviceAddress The device Bluetooth address for the filter. It needs to be in the
- * format of "01:02:03:AB:CD:EF". The device address can be validated using
- * {@link BluetoothAdapter#checkBluetoothAddress}.
+ * format of "01:02:03:AB:CD:EF". The device address can be validated using {@link
+ * BluetoothAdapter#checkBluetoothAddress}.
* @throws IllegalArgumentException If the {@code deviceAddress} is invalid.
*/
public Builder setDeviceAddress(String deviceAddress) {
@@ -480,8 +481,8 @@
* {@code serviceUuid}. Set any bit in the mask to 1 to indicate a match is needed for the
* bit in {@code serviceUuid}, and 0 to ignore that bit.
*
- * @throws IllegalArgumentException If {@code serviceUuid} is {@code null} but
- * {@code uuidMask} is not {@code null}.
+ * @throws IllegalArgumentException If {@code serviceUuid} is {@code null} but {@code
+ * uuidMask} is not {@code null}.
*/
public Builder setServiceUuid(ParcelUuid serviceUuid, ParcelUuid uuidMask) {
if (mUuidMask != null && mServiceUuid == null) {
@@ -513,9 +514,9 @@
* <p>
* The {@code serviceDataMask} must have the same length of the {@code serviceData}.
*
- * @throws IllegalArgumentException If {@code serviceDataUuid} is null or
- * {@code serviceDataMask} is {@code null} while {@code serviceData} is not or
- * {@code serviceDataMask} and {@code serviceData} has different length.
+ * @throws IllegalArgumentException If {@code serviceDataUuid} is null or {@code
+ * serviceDataMask} is {@code null} while {@code serviceData} is not or {@code
+ * serviceDataMask} and {@code serviceData} has different length.
*/
public Builder setServiceData(ParcelUuid serviceDataUuid,
byte[] serviceData, byte[] serviceDataMask) {
@@ -563,10 +564,9 @@
* <p>
* The {@code manufacturerDataMask} must have the same length of {@code manufacturerData}.
*
- * @throws IllegalArgumentException If the {@code manufacturerId} is invalid, or
- * {@code manufacturerData} is null while {@code manufacturerDataMask} is not,
- * or {@code manufacturerData} and {@code manufacturerDataMask} have different
- * length.
+ * @throws IllegalArgumentException If the {@code manufacturerId} is invalid, or {@code
+ * manufacturerData} is null while {@code manufacturerDataMask} is not, or {@code
+ * manufacturerData} and {@code manufacturerDataMask} have different length.
*/
public Builder setManufacturerData(int manufacturerId, byte[] manufacturerData,
byte[] manufacturerDataMask) {
diff --git a/framework/java/android/bluetooth/le/ScanRecord.java b/framework/java/android/bluetooth/le/ScanRecord.java
index 914e8fd..9e5a29a 100644
--- a/framework/java/android/bluetooth/le/ScanRecord.java
+++ b/framework/java/android/bluetooth/le/ScanRecord.java
@@ -231,9 +231,9 @@
case DATA_TYPE_SERVICE_DATA_128_BIT:
int serviceUuidLength = BluetoothUuid.UUID_BYTES_16_BIT;
if (fieldType == DATA_TYPE_SERVICE_DATA_32_BIT) {
- serviceUuidLength = BluetoothUuid.UUID_BYTES_32_BIT;
+ serviceUuidLength = BluetoothUuid.UUID_BYTES_32_BIT;
} else if (fieldType == DATA_TYPE_SERVICE_DATA_128_BIT) {
- serviceUuidLength = BluetoothUuid.UUID_BYTES_128_BIT;
+ serviceUuidLength = BluetoothUuid.UUID_BYTES_128_BIT;
}
byte[] serviceDataUuidBytes = extractBytes(scanRecord, currentPos,
@@ -276,7 +276,8 @@
@Override
public String toString() {
return "ScanRecord [mAdvertiseFlags=" + mAdvertiseFlags + ", mServiceUuids=" + mServiceUuids
- + ", mManufacturerSpecificData=" + BluetoothLeUtils.toString(mManufacturerSpecificData)
+ + ", mManufacturerSpecificData=" + BluetoothLeUtils.toString(
+ mManufacturerSpecificData)
+ ", mServiceData=" + BluetoothLeUtils.toString(mServiceData)
+ ", mTxPowerLevel=" + mTxPowerLevel + ", mDeviceName=" + mDeviceName + "]";
}
diff --git a/framework/java/android/bluetooth/le/ScanResult.java b/framework/java/android/bluetooth/le/ScanResult.java
index e552398..7743822 100644
--- a/framework/java/android/bluetooth/le/ScanResult.java
+++ b/framework/java/android/bluetooth/le/ScanResult.java
@@ -98,7 +98,8 @@
* @param scanRecord Scan record including both advertising data and scan response data.
* @param rssi Received signal strength.
* @param timestampNanos Timestamp at which the scan result was observed.
- * @deprecated use {@link #ScanResult(BluetoothDevice, int, int, int, int, int, int, int, ScanRecord, long)}
+ * @deprecated use {@link #ScanResult(BluetoothDevice, int, int, int, int, int, int, int,
+ * ScanRecord, long)}
*/
public ScanResult(BluetoothDevice device, ScanRecord scanRecord, int rssi,
long timestampNanos) {
@@ -129,8 +130,8 @@
* @param timestampNanos Timestamp at which the scan result was observed.
*/
public ScanResult(BluetoothDevice device, int eventType, int primaryPhy, int secondaryPhy,
- int advertisingSid, int txPower, int rssi, int periodicAdvertisingInterval,
- ScanRecord scanRecord, long timestampNanos) {
+ int advertisingSid, int txPower, int rssi, int periodicAdvertisingInterval,
+ ScanRecord scanRecord, long timestampNanos) {
mDevice = device;
mEventType = eventType;
mPrimaryPhy = primaryPhy;
@@ -254,7 +255,9 @@
* Can be one of {@link BluetoothDevice#PHY_LE_1M} or
* {@link BluetoothDevice#PHY_LE_CODED}.
*/
- public int getPrimaryPhy() { return mPrimaryPhy; }
+ public int getPrimaryPhy() {
+ return mPrimaryPhy;
+ }
/**
* Returns the secondary Physical Layer
@@ -264,21 +267,27 @@
* or {@link ScanResult#PHY_UNUSED} - if the advertisement
* was not received on a secondary physical channel.
*/
- public int getSecondaryPhy() { return mSecondaryPhy; }
+ public int getSecondaryPhy() {
+ return mSecondaryPhy;
+ }
/**
* Returns the advertising set id.
* May return {@link ScanResult#SID_NOT_PRESENT} if
* no set id was is present.
*/
- public int getAdvertisingSid() { return mAdvertisingSid; }
+ public int getAdvertisingSid() {
+ return mAdvertisingSid;
+ }
/**
* Returns the transmit power in dBm.
* Valid range is [-127, 126]. A value of {@link ScanResult#TX_POWER_NOT_PRESENT}
* indicates that the TX power is not present.
*/
- public int getTxPower() { return mTxPower; }
+ public int getTxPower() {
+ return mTxPower;
+ }
/**
* Returns the periodic advertising interval in units of 1.25ms.
@@ -293,9 +302,9 @@
@Override
public int hashCode() {
return Objects.hash(mDevice, mRssi, mScanRecord, mTimestampNanos,
- mEventType, mPrimaryPhy, mSecondaryPhy,
- mAdvertisingSid, mTxPower,
- mPeriodicAdvertisingInterval);
+ mEventType, mPrimaryPhy, mSecondaryPhy,
+ mAdvertisingSid, mTxPower,
+ mPeriodicAdvertisingInterval);
}
@Override
@@ -308,33 +317,33 @@
}
ScanResult other = (ScanResult) obj;
return Objects.equals(mDevice, other.mDevice) && (mRssi == other.mRssi) &&
- Objects.equals(mScanRecord, other.mScanRecord) &&
- (mTimestampNanos == other.mTimestampNanos) &&
- mEventType == other.mEventType &&
- mPrimaryPhy == other.mPrimaryPhy &&
- mSecondaryPhy == other.mSecondaryPhy &&
- mAdvertisingSid == other.mAdvertisingSid &&
- mTxPower == other.mTxPower &&
- mPeriodicAdvertisingInterval == other.mPeriodicAdvertisingInterval;
+ Objects.equals(mScanRecord, other.mScanRecord) &&
+ (mTimestampNanos == other.mTimestampNanos) &&
+ mEventType == other.mEventType &&
+ mPrimaryPhy == other.mPrimaryPhy &&
+ mSecondaryPhy == other.mSecondaryPhy &&
+ mAdvertisingSid == other.mAdvertisingSid &&
+ mTxPower == other.mTxPower &&
+ mPeriodicAdvertisingInterval == other.mPeriodicAdvertisingInterval;
}
@Override
public String toString() {
- return "ScanResult{" + "device=" + mDevice + ", scanRecord=" +
- Objects.toString(mScanRecord) + ", rssi=" + mRssi +
- ", timestampNanos=" + mTimestampNanos + ", eventType=" + mEventType +
- ", primaryPhy=" + mPrimaryPhy + ", secondaryPhy=" + mSecondaryPhy +
- ", advertisingSid=" + mAdvertisingSid + ", txPower=" + mTxPower +
- ", periodicAdvertisingInterval=" + mPeriodicAdvertisingInterval + '}';
+ return "ScanResult{" + "device=" + mDevice + ", scanRecord=" +
+ Objects.toString(mScanRecord) + ", rssi=" + mRssi +
+ ", timestampNanos=" + mTimestampNanos + ", eventType=" + mEventType +
+ ", primaryPhy=" + mPrimaryPhy + ", secondaryPhy=" + mSecondaryPhy +
+ ", advertisingSid=" + mAdvertisingSid + ", txPower=" + mTxPower +
+ ", periodicAdvertisingInterval=" + mPeriodicAdvertisingInterval + '}';
}
public static final Parcelable.Creator<ScanResult> CREATOR = new Creator<ScanResult>() {
- @Override
+ @Override
public ScanResult createFromParcel(Parcel source) {
return new ScanResult(source);
}
- @Override
+ @Override
public ScanResult[] newArray(int size) {
return new ScanResult[size];
}
diff --git a/framework/java/android/bluetooth/le/ScanSettings.java b/framework/java/android/bluetooth/le/ScanSettings.java
index 36e48e9..d2792e0 100644
--- a/framework/java/android/bluetooth/le/ScanSettings.java
+++ b/framework/java/android/bluetooth/le/ScanSettings.java
@@ -202,8 +202,8 @@
}
private ScanSettings(int scanMode, int callbackType, int scanResultType,
- long reportDelayMillis, int matchMode,
- int numOfMatchesPerFilter, boolean legacy, int phy) {
+ long reportDelayMillis, int matchMode,
+ int numOfMatchesPerFilter, boolean legacy, int phy) {
mScanMode = scanMode;
mCallbackType = callbackType;
mScanResultType = scanResultType;
@@ -244,16 +244,16 @@
public static final Parcelable.Creator<ScanSettings>
CREATOR = new Creator<ScanSettings>() {
- @Override
- public ScanSettings[] newArray(int size) {
- return new ScanSettings[size];
- }
+ @Override
+ public ScanSettings[] newArray(int size) {
+ return new ScanSettings[size];
+ }
- @Override
- public ScanSettings createFromParcel(Parcel in) {
- return new ScanSettings(in);
- }
- };
+ @Override
+ public ScanSettings createFromParcel(Parcel in) {
+ return new ScanSettings(in);
+ }
+ };
/**
* Builder for {@link ScanSettings}.
@@ -264,7 +264,7 @@
private int mScanResultType = SCAN_RESULT_TYPE_FULL;
private long mReportDelayMillis = 0;
private int mMatchMode = MATCH_MODE_AGGRESSIVE;
- private int mNumOfMatchesPerFilter = MATCH_NUM_MAX_ADVERTISEMENT;
+ private int mNumOfMatchesPerFilter = MATCH_NUM_MAX_ADVERTISEMENT;
private boolean mLegacy = true;
private int mPhy = PHY_LE_ALL_SUPPORTED;
@@ -272,8 +272,7 @@
* Set scan mode for Bluetooth LE scan.
*
* @param scanMode The scan mode can be one of {@link ScanSettings#SCAN_MODE_LOW_POWER},
- * {@link ScanSettings#SCAN_MODE_BALANCED} or
- * {@link ScanSettings#SCAN_MODE_LOW_LATENCY}.
+ * {@link ScanSettings#SCAN_MODE_BALANCED} or {@link ScanSettings#SCAN_MODE_LOW_LATENCY}.
* @throws IllegalArgumentException If the {@code scanMode} is invalid.
*/
public Builder setScanMode(int scanMode) {
@@ -312,9 +311,8 @@
/**
* Set scan result type for Bluetooth LE scan.
*
- * @param scanResultType Type for scan result, could be either
- * {@link ScanSettings#SCAN_RESULT_TYPE_FULL} or
- * {@link ScanSettings#SCAN_RESULT_TYPE_ABBREVIATED}.
+ * @param scanResultType Type for scan result, could be either {@link
+ * ScanSettings#SCAN_RESULT_TYPE_FULL} or {@link ScanSettings#SCAN_RESULT_TYPE_ABBREVIATED}.
* @throws IllegalArgumentException If the {@code scanResultType} is invalid.
* @hide
*/
@@ -333,8 +331,8 @@
* Set report delay timestamp for Bluetooth LE scan.
*
* @param reportDelayMillis Delay of report in milliseconds. Set to 0 to be notified of
- * results immediately. Values > 0 causes the scan results to be queued up and
- * delivered after the requested delay or when the internal buffers fill up.
+ * results immediately. Values > 0 causes the scan results to be queued up and delivered
+ * after the requested delay or when the internal buffers fill up.
* @throws IllegalArgumentException If {@code reportDelayMillis} < 0.
*/
public Builder setReportDelay(long reportDelayMillis) {
@@ -349,9 +347,9 @@
* Set the number of matches for Bluetooth LE scan filters hardware match
*
* @param numOfMatches The num of matches can be one of
- * {@link ScanSettings#MATCH_NUM_ONE_ADVERTISEMENT} or
- * {@link ScanSettings#MATCH_NUM_FEW_ADVERTISEMENT} or
- * {@link ScanSettings#MATCH_NUM_MAX_ADVERTISEMENT}
+ * {@link ScanSettings#MATCH_NUM_ONE_ADVERTISEMENT}
+ * or {@link ScanSettings#MATCH_NUM_FEW_ADVERTISEMENT} or {@link
+ * ScanSettings#MATCH_NUM_MAX_ADVERTISEMENT}
* @throws IllegalArgumentException If the {@code matchMode} is invalid.
*/
public Builder setNumOfMatches(int numOfMatches) {
@@ -366,9 +364,8 @@
/**
* Set match mode for Bluetooth LE scan filters hardware match
*
- * @param matchMode The match mode can be one of
- * {@link ScanSettings#MATCH_MODE_AGGRESSIVE} or
- * {@link ScanSettings#MATCH_MODE_STICKY}
+ * @param matchMode The match mode can be one of {@link ScanSettings#MATCH_MODE_AGGRESSIVE}
+ * or {@link ScanSettings#MATCH_MODE_STICKY}
* @throws IllegalArgumentException If the {@code matchMode} is invalid.
*/
public Builder setMatchMode(int matchMode) {
@@ -402,10 +399,8 @@
* {@link android.bluetooth.BluetoothAdapter#isLeCodedPhySupported}.
* Selecting an unsupported phy will result in failure to start scan.
*
- * @param phy Can be one of
- * {@link BluetoothDevice#PHY_LE_1M},
- * {@link BluetoothDevice#PHY_LE_CODED} or
- * {@link ScanSettings#PHY_LE_ALL_SUPPORTED}
+ * @param phy Can be one of {@link BluetoothDevice#PHY_LE_1M}, {@link
+ * BluetoothDevice#PHY_LE_CODED} or {@link ScanSettings#PHY_LE_ALL_SUPPORTED}
*/
public Builder setPhy(int phy) {
mPhy = phy;
@@ -417,8 +412,8 @@
*/
public ScanSettings build() {
return new ScanSettings(mScanMode, mCallbackType, mScanResultType,
- mReportDelayMillis, mMatchMode,
- mNumOfMatchesPerFilter, mLegacy, mPhy);
+ mReportDelayMillis, mMatchMode,
+ mNumOfMatchesPerFilter, mLegacy, mPhy);
}
}
}
diff --git a/framework/java/android/bluetooth/le/TruncatedFilter.java b/framework/java/android/bluetooth/le/TruncatedFilter.java
index 685b174..a753aa6 100644
--- a/framework/java/android/bluetooth/le/TruncatedFilter.java
+++ b/framework/java/android/bluetooth/le/TruncatedFilter.java
@@ -17,6 +17,7 @@
package android.bluetooth.le;
import android.annotation.SystemApi;
+
import java.util.List;
/**