Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 55995e8f authored by Jakub Pawlowski's avatar Jakub Pawlowski
Browse files

Discover primary service by UUID for PTS tests (3/4)

Bug: 38123054
Test: manual
Change-Id: I1547f1dbd46e2d5e9a4e2b953b9973fb3f52a7d7
(cherry picked from commit 84685c0e)
parent 8652cb95
Loading
Loading
Loading
Loading
+13 −0
Original line number Diff line number Diff line
@@ -1069,6 +1069,17 @@ static void gattClientSearchServiceNative(JNIEnv* env, jobject object,
  sGattIf->client->search_service(conn_id, search_all ? 0 : &uuid);
}

static void gattClientDiscoverServiceByUuidNative(JNIEnv* env, jobject object,
                                                  jint conn_id,
                                                  jlong service_uuid_lsb,
                                                  jlong service_uuid_msb) {
  if (!sGattIf) return;

  bt_uuid_t uuid;
  set_uuid(uuid.uu, service_uuid_msb, service_uuid_lsb);
  sGattIf->client->btif_gattc_discover_service_by_uuid(conn_id, &uuid);
}

static void gattClientGetGattDbNative(JNIEnv* env, jobject object,
                                      jint conn_id) {
  if (!sGattIf) return;
@@ -2172,6 +2183,8 @@ static JNINativeMethod sMethods[] = {
     (void*)gattClientRefreshNative},
    {"gattClientSearchServiceNative", "(IZJJ)V",
     (void*)gattClientSearchServiceNative},
    {"gattClientDiscoverServiceByUuidNative", "(IJJ)V",
     (void*)gattClientDiscoverServiceByUuidNative},
    {"gattClientGetGattDbNative", "(I)V", (void*)gattClientGetGattDbNative},
    {"gattClientReadCharacteristicNative", "(III)V",
     (void*)gattClientReadCharacteristicNative},
+20 −0
Original line number Diff line number Diff line
@@ -458,6 +458,12 @@ public class GattService extends ProfileService {
            service.discoverServices(clientIf, address);
        }

        public void discoverServiceByUuid(int clientIf, String address, ParcelUuid uuid) {
            GattService service = getService();
            if (service == null) return;
            service.discoverServiceByUuid(clientIf, address, uuid.getUuid());
        }

        public void readCharacteristic(int clientIf, String address, int handle, int authReq) {
            GattService service = getService();
            if (service == null) return;
@@ -1869,6 +1875,17 @@ public class GattService extends ProfileService {
            Log.e(TAG, "discoverServices() - No connection for " + address + "...");
    }

    void discoverServiceByUuid(int clientIf, String address, UUID uuid) {
        enforceCallingOrSelfPermission(BLUETOOTH_PERM, "Need BLUETOOTH permission");

        Integer connId = mClientMap.connIdByAddress(clientIf, address);
        if (connId != null)
            gattClientDiscoverServiceByUuidNative(
                    connId, uuid.getLeastSignificantBits(), uuid.getMostSignificantBits());
        else
            Log.e(TAG, "discoverServiceByUuid() - No connection for " + address + "...");
    }

    void readCharacteristic(int clientIf, String address, int handle, int authReq) {
        enforceCallingOrSelfPermission(BLUETOOTH_PERM, "Need BLUETOOTH permission");

@@ -2680,6 +2697,9 @@ public class GattService extends ProfileService {
    private native void gattClientSearchServiceNative(int conn_id,
            boolean search_all, long service_uuid_lsb, long service_uuid_msb);

    private native void gattClientDiscoverServiceByUuidNative(
            int conn_id, long service_uuid_lsb, long service_uuid_msb);

    private native void gattClientGetGattDbNative(int conn_id);

    private native void gattClientReadCharacteristicNative(int conn_id, int handle, int authReq);