summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Jakub Pawlowski <jpawlowski@google.com> 2017-05-16 10:56:35 -0700
committer Jakub Pawlowski <jpawlowski@google.com> 2017-05-16 13:50:11 -0700
commit09ad0b27bbc7d2ca2acacd9ef3b1e855eaef9ea9 (patch)
tree5803984c418f183f1f94153fa31f6d46d4a4a78b
parente943a3cbe7dd9d7f1ab977e64178730190b37755 (diff)
Discover primary service by UUID for PTS tests (4/4)
Bug: 38123054 Test: manual Change-Id: I89e088e60f4325f1ece59d22efda0c907a3b716a (cherry picked from commit fe2bf16a2b287c3c748cd6fa7c14026becfe83ff)
-rw-r--r--core/java/android/bluetooth/BluetoothGatt.java26
-rw-r--r--core/java/android/bluetooth/IBluetoothGatt.aidl1
2 files changed, 26 insertions, 1 deletions
diff --git a/core/java/android/bluetooth/BluetoothGatt.java b/core/java/android/bluetooth/BluetoothGatt.java
index 5fabbb68df85..a3d6e9f1e499 100644
--- a/core/java/android/bluetooth/BluetoothGatt.java
+++ b/core/java/android/bluetooth/BluetoothGatt.java
@@ -16,7 +16,6 @@
package android.bluetooth;
-import android.content.Context;
import android.os.Handler;
import android.os.ParcelUuid;
import android.os.RemoteException;
@@ -927,6 +926,31 @@ public final class BluetoothGatt implements BluetoothProfile {
}
/**
+ * Discovers a service by UUID. This is exposed only for passing PTS tests.
+ * It should never be used by real applications. The service is not searched
+ * for characteristics and descriptors, or returned in any callback.
+ *
+ * <p>Requires {@link android.Manifest.permission#BLUETOOTH} permission.
+ *
+ * @return true, if the remote service discovery has been started
+ * @hide
+ */
+ public boolean discoverServiceByUuid(UUID uuid) {
+ if (DBG) Log.d(TAG, "discoverServiceByUuid() - device: " + mDevice.getAddress());
+ if (mService == null || mClientIf == 0) return false;
+
+ mServices.clear();
+
+ try {
+ mService.discoverServiceByUuid(mClientIf, mDevice.getAddress(), new ParcelUuid(uuid));
+ } catch (RemoteException e) {
+ Log.e(TAG, "", e);
+ return false;
+ }
+ return true;
+ }
+
+ /**
* Returns a list of GATT services offered by the remote device.
*
* <p>This function requires that service discovery has been completed
diff --git a/core/java/android/bluetooth/IBluetoothGatt.aidl b/core/java/android/bluetooth/IBluetoothGatt.aidl
index dc5c7b6b620c..167f5e9e1080 100644
--- a/core/java/android/bluetooth/IBluetoothGatt.aidl
+++ b/core/java/android/bluetooth/IBluetoothGatt.aidl
@@ -80,6 +80,7 @@ interface IBluetoothGatt {
void clientReadPhy(in int clientIf, in String address);
void refreshDevice(in int clientIf, in String address);
void discoverServices(in int clientIf, in String address);
+ void discoverServiceByUuid(in int clientIf, in String address, in ParcelUuid uuid);
void readCharacteristic(in int clientIf, in String address, in int handle, in int authReq);
void readUsingCharacteristicUuid(in int clientIf, in String address, in ParcelUuid uuid,
in int startHandle, in int endHandle, in int authReq);