summaryrefslogtreecommitdiffstats
path: root/core/java
diff options
context:
space:
mode:
authorJay Civelli <jcivelli@google.com>2014-05-08 09:24:08 -0700
committerJay Civelli <jcivelli@google.com>2014-06-04 12:15:35 -0700
commit174928c0aaf020de4514a5c02799299c6e56e4c0 (patch)
tree13db2b956471bfbf80192b1721918f1d69d30377 /core/java
parent2808907362922f077fa48b97ece28bf9e18482a6 (diff)
downloadframeworks_base-174928c0aaf020de4514a5c02799299c6e56e4c0.zip
frameworks_base-174928c0aaf020de4514a5c02799299c6e56e4c0.tar.gz
frameworks_base-174928c0aaf020de4514a5c02799299c6e56e4c0.tar.bz2
Adding a method to know if there is a connection to a BluetoothDevice.
Adding a new method to BluetoothDevice that lets callers know whether a remote device is connected. Change-Id: I6f7cb99147f3cdad1d676a93183856dbb4083a06
Diffstat (limited to 'core/java')
-rw-r--r--core/java/android/bluetooth/BluetoothDevice.java20
-rw-r--r--core/java/android/bluetooth/IBluetooth.aidl1
2 files changed, 21 insertions, 0 deletions
diff --git a/core/java/android/bluetooth/BluetoothDevice.java b/core/java/android/bluetooth/BluetoothDevice.java
index 7f8d0ab..64d80a0 100644
--- a/core/java/android/bluetooth/BluetoothDevice.java
+++ b/core/java/android/bluetooth/BluetoothDevice.java
@@ -874,6 +874,26 @@ public final class BluetoothDevice implements Parcelable {
}
/**
+ * Returns whether there is an open connection to this device.
+ * <p>Requires {@link android.Manifest.permission#BLUETOOTH}.
+ *
+ * @return True if there is at least one open connection to this device.
+ * @hide
+ */
+ public boolean isConnected() {
+ if (sService == null) {
+ // BT is not enabled, we cannot be connected.
+ return false;
+ }
+ try {
+ return sService.isConnected(this);
+ } catch (RemoteException e) {
+ Log.e(TAG, "", e);
+ return false;
+ }
+ }
+
+ /**
* Get the Bluetooth class of the remote device.
* <p>Requires {@link android.Manifest.permission#BLUETOOTH}.
*
diff --git a/core/java/android/bluetooth/IBluetooth.aidl b/core/java/android/bluetooth/IBluetooth.aidl
index 07db8cc..a45c6b8 100644
--- a/core/java/android/bluetooth/IBluetooth.aidl
+++ b/core/java/android/bluetooth/IBluetooth.aidl
@@ -58,6 +58,7 @@ interface IBluetooth
boolean cancelBondProcess(in BluetoothDevice device);
boolean removeBond(in BluetoothDevice device);
int getBondState(in BluetoothDevice device);
+ boolean isConnected(in BluetoothDevice device);
String getRemoteName(in BluetoothDevice device);
int getRemoteType(in BluetoothDevice device);