summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Marie Janssen <jamuraa@google.com> 2017-01-24 14:09:59 -0800
committer Marie Janssen <jamuraa@google.com> 2017-01-27 18:48:11 -0800
commit23a48331571cdee029539aa9025ccff2053d8cf0 (patch)
treeb0ae4bfe5c1431c220bedc62cb1ef086aa1d329f
parentd0638435496675fef59f9a4a2427e79e503ae77a (diff)
Bluetooth: add getDiscoveryEndMillis() call
Method to tell when the adapter finished (or will finish) being in discovery mode. Test: compiles and still can scan Bug: 34395439 Change-Id: I41b48c2b934c0a1d5e1727cec08f3f762e3cb309
-rw-r--r--core/java/android/bluetooth/BluetoothAdapter.java19
-rw-r--r--core/java/android/bluetooth/IBluetooth.aidl1
-rwxr-xr-xpackages/SettingsLib/src/com/android/settingslib/bluetooth/LocalBluetoothAdapter.java4
3 files changed, 24 insertions, 0 deletions
diff --git a/core/java/android/bluetooth/BluetoothAdapter.java b/core/java/android/bluetooth/BluetoothAdapter.java
index f9be3a1d7f0b..9302cbc480e1 100644
--- a/core/java/android/bluetooth/BluetoothAdapter.java
+++ b/core/java/android/bluetooth/BluetoothAdapter.java
@@ -1184,6 +1184,25 @@ public final class BluetoothAdapter {
}
/**
+ * 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.
+ * @hide
+ */
+ public long getDiscoveryEndMillis() {
+ try {
+ mServiceLock.readLock().lock();
+ if (mService != null) return mService.getDiscoveryEndMillis();
+ } catch (RemoteException e) {
+ Log.e(TAG, "", e);
+ } finally {
+ mServiceLock.readLock().unlock();
+ }
+ return -1;
+ }
+
+ /**
* Start the remote device discovery process.
* <p>The discovery process usually involves an inquiry scan of about 12
* seconds, followed by a page scan of each new device to retrieve its
diff --git a/core/java/android/bluetooth/IBluetooth.aidl b/core/java/android/bluetooth/IBluetooth.aidl
index 7c5458b7704b..53fef2add344 100644
--- a/core/java/android/bluetooth/IBluetooth.aidl
+++ b/core/java/android/bluetooth/IBluetooth.aidl
@@ -52,6 +52,7 @@ interface IBluetooth
boolean startDiscovery();
boolean cancelDiscovery();
boolean isDiscovering();
+ long getDiscoveryEndMillis();
int getAdapterConnectionState();
int getProfileConnectionState(int profile);
diff --git a/packages/SettingsLib/src/com/android/settingslib/bluetooth/LocalBluetoothAdapter.java b/packages/SettingsLib/src/com/android/settingslib/bluetooth/LocalBluetoothAdapter.java
index 26836099c9de..c4437c220c5c 100755
--- a/packages/SettingsLib/src/com/android/settingslib/bluetooth/LocalBluetoothAdapter.java
+++ b/packages/SettingsLib/src/com/android/settingslib/bluetooth/LocalBluetoothAdapter.java
@@ -135,6 +135,10 @@ public final class LocalBluetoothAdapter {
mAdapter.setDiscoverableTimeout(timeout);
}
+ public long getDiscoveryEndMillis() {
+ return mAdapter.getDiscoveryEndMillis();
+ }
+
public void setName(String name) {
mAdapter.setName(name);
}