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

Commit d9ba6780 authored by Jakub Pawlowski's avatar Jakub Pawlowski
Browse files

Use one type for UUID (3/5)

Currently, we have few different representations for UUID in stack:
tBT_UUID, tSDP_UUID, bt_uuid_t, bluetooth:UUID, or uint8_t*.

Additionally, tBT_UUID and bt_uuid_t are used to hold UUID as 128bit
as Little Endian or Big Endian, depending on which part of stack (GATT
or SDP) is using it.

This patch is creating one type, bluetooth::Uuid, that will replace all
other types.

Bug: 66912853
Test: all sl4a tests for GATT and RFCOMM
Merged-In: Ia095898aa381f899327d1b01a71e366ccfdbb995
Change-Id: Ia095898aa381f899327d1b01a71e366ccfdbb995
parent 0cff9baf
Loading
Loading
Loading
Loading
+17 −11
Original line number Original line Diff line number Diff line
@@ -29,6 +29,8 @@
#include <sys/prctl.h>
#include <sys/prctl.h>
#include <sys/stat.h>
#include <sys/stat.h>


using bluetooth::Uuid;

namespace android {
namespace android {
// OOB_LE_BD_ADDR_SIZE is 6 bytes addres + 1 byte address type
// OOB_LE_BD_ADDR_SIZE is 6 bytes addres + 1 byte address type
#define OOB_LE_BD_ADDR_SIZE 7
#define OOB_LE_BD_ADDR_SIZE 7
@@ -1085,20 +1087,23 @@ static int connectSocketNative(JNIEnv* env, jobject object, jbyteArray address,
    return -1;
    return -1;
  }
  }


  jbyte* uuid = NULL;
  Uuid uuid;
  if (uuidObj != NULL) {
  if (uuidObj != NULL) {
    uuid = env->GetByteArrayElements(uuidObj, NULL);
    jbyte* tmp = env->GetByteArrayElements(uuidObj, NULL);
    if (!uuid) {
    if (!tmp) {
      ALOGE("failed to get uuid");
      ALOGE("failed to get uuid");
      env->ReleaseByteArrayElements(address, addr, 0);
      env->ReleaseByteArrayElements(address, addr, 0);
      return -1;
      return -1;
    }
    }

    uuid = Uuid::From128BitBE(reinterpret_cast<uint8_t*>(tmp));
    env->ReleaseByteArrayElements(uuidObj, tmp, 0);
  }
  }


  int socket_fd = -1;
  int socket_fd = -1;
  bt_status_t status = sBluetoothSocketInterface->connect(
  bt_status_t status = sBluetoothSocketInterface->connect(
      (RawAddress*)addr, (btsock_type_t)type, (const uint8_t*)uuid, channel,
      (RawAddress*)addr, (btsock_type_t)type, uuidObj ? &uuid : nullptr,
      &socket_fd, flag, callingUid);
      channel, &socket_fd, flag, callingUid);
  if (status != BT_STATUS_SUCCESS) {
  if (status != BT_STATUS_SUCCESS) {
    ALOGE("Socket connection failed: %d", status);
    ALOGE("Socket connection failed: %d", status);
    socket_fd = -1;
    socket_fd = -1;
@@ -1107,7 +1112,6 @@ static int connectSocketNative(JNIEnv* env, jobject object, jbyteArray address,
  }
  }


  env->ReleaseByteArrayElements(address, addr, 0);
  env->ReleaseByteArrayElements(address, addr, 0);
  env->ReleaseByteArrayElements(uuidObj, uuid, 0);
  return socket_fd;
  return socket_fd;
}
}


@@ -1123,19 +1127,22 @@ static int createSocketChannelNative(JNIEnv* env, jobject object, jint type,
    service_name = env->GetStringUTFChars(name_str, NULL);
    service_name = env->GetStringUTFChars(name_str, NULL);
  }
  }


  jbyte* uuid = NULL;
  Uuid uuid;
  if (uuidObj != NULL) {
  if (uuidObj != NULL) {
    uuid = env->GetByteArrayElements(uuidObj, NULL);
    jbyte* tmp = env->GetByteArrayElements(uuidObj, NULL);
    if (!uuid) {
    if (!tmp) {
      ALOGE("failed to get uuid");
      ALOGE("failed to get uuid");
      if (service_name) env->ReleaseStringUTFChars(name_str, service_name);
      if (service_name) env->ReleaseStringUTFChars(name_str, service_name);
      return -1;
      return -1;
    }
    }

    uuid = Uuid::From128BitBE(reinterpret_cast<uint8_t*>(tmp));
    env->ReleaseByteArrayElements(uuidObj, tmp, 0);
  }
  }


  int socket_fd = -1;
  int socket_fd = -1;
  bt_status_t status = sBluetoothSocketInterface->listen(
  bt_status_t status = sBluetoothSocketInterface->listen(
      (btsock_type_t)type, service_name, (const uint8_t*)uuid, channel,
      (btsock_type_t)type, service_name, uuidObj ? &uuid : nullptr, channel,
      &socket_fd, flag, callingUid);
      &socket_fd, flag, callingUid);
  if (status != BT_STATUS_SUCCESS) {
  if (status != BT_STATUS_SUCCESS) {
    ALOGE("Socket listen failed: %d", status);
    ALOGE("Socket listen failed: %d", status);
@@ -1145,7 +1152,6 @@ static int createSocketChannelNative(JNIEnv* env, jobject object, jint type,
  }
  }


  if (service_name) env->ReleaseStringUTFChars(name_str, service_name);
  if (service_name) env->ReleaseStringUTFChars(name_str, service_name);
  if (uuid) env->ReleaseByteArrayElements(uuidObj, uuid, 0);
  return socket_fd;
  return socket_fd;
}
}


+30 −35
Original line number Original line Diff line number Diff line
@@ -25,6 +25,7 @@


#include <base/bind.h>
#include <base/bind.h>
#include <string.h>
#include <string.h>
#include <array>
#include <memory>
#include <memory>


#include <cutils/log.h>
#include <cutils/log.h>
@@ -38,34 +39,38 @@
#define asrt(s) \
#define asrt(s) \
  if (!(s)) ALOGE("%s(L%d): ASSERT %s failed! ##", __func__, __LINE__, #s)
  if (!(s)) ALOGE("%s(L%d): ASSERT %s failed! ##", __func__, __LINE__, #s)


#define BD_ADDR_LEN 6
using bluetooth::Uuid;


#define UUID_PARAMS(uuid) uuid_lsb(uuid), uuid_msb(uuid)
#define UUID_PARAMS(uuid) uuid_lsb(uuid), uuid_msb(uuid)


static void set_uuid(uint8_t* uuid, jlong uuid_msb, jlong uuid_lsb) {
static Uuid from_java_uuid(jlong uuid_msb, jlong uuid_lsb) {
  for (int i = 0; i != 8; ++i) {
  std::array<uint8_t, Uuid::kNumBytes128> uu;
    uuid[i] = (uuid_lsb >> (8 * i)) & 0xFF;
  for (int i = 0; i < 8; i++) {
    uuid[i + 8] = (uuid_msb >> (8 * i)) & 0xFF;
    uu[7 - i] = (uuid_msb >> (8 * i)) & 0xFF;
    uu[15 - i] = (uuid_lsb >> (8 * i)) & 0xFF;
  }
  }
  return Uuid::From128BitBE(uu);
}
}


static uint64_t uuid_lsb(const bt_uuid_t& uuid) {
static uint64_t uuid_lsb(const Uuid& uuid) {
  uint64_t lsb = 0;
  uint64_t lsb = 0;


  for (int i = 7; i >= 0; i--) {
  auto uu = uuid.To128BitBE();
  for (int i = 8; i <= 15; i++) {
    lsb <<= 8;
    lsb <<= 8;
    lsb |= uuid.uu[i];
    lsb |= uu[i];
  }
  }


  return lsb;
  return lsb;
}
}


static uint64_t uuid_msb(const bt_uuid_t& uuid) {
static uint64_t uuid_msb(const Uuid& uuid) {
  uint64_t msb = 0;
  uint64_t msb = 0;


  for (int i = 15; i >= 8; i--) {
  auto uu = uuid.To128BitBE();
  for (int i = 0; i <= 7; i++) {
    msb <<= 8;
    msb <<= 8;
    msb |= uuid.uu[i];
    msb |= uu[i];
  }
  }


  return msb;
  return msb;
@@ -192,8 +197,7 @@ static jobject mPeriodicScanCallbacksObj = NULL;
 * BTA client callbacks
 * BTA client callbacks
 */
 */


void btgattc_register_app_cb(int status, int clientIf,
void btgattc_register_app_cb(int status, int clientIf, const Uuid& app_uuid) {
                             const bt_uuid_t& app_uuid) {
  CallbackEnv sCallbackEnv(__func__);
  CallbackEnv sCallbackEnv(__func__);
  if (!sCallbackEnv.valid()) return;
  if (!sCallbackEnv.valid()) return;
  sCallbackEnv->CallVoidMethod(mCallbacksObj, method_onClientRegistered, status,
  sCallbackEnv->CallVoidMethod(mCallbacksObj, method_onClientRegistered, status,
@@ -556,7 +560,7 @@ static const btgatt_client_callbacks_t sGattClientCallbacks = {
 * BTA server callbacks
 * BTA server callbacks
 */
 */


void btgatts_register_app_cb(int status, int server_if, const bt_uuid_t& uuid) {
void btgatts_register_app_cb(int status, int server_if, const Uuid& uuid) {
  CallbackEnv sCallbackEnv(__func__);
  CallbackEnv sCallbackEnv(__func__);
  if (!sCallbackEnv.valid()) return;
  if (!sCallbackEnv.valid()) return;
  sCallbackEnv->CallVoidMethod(mCallbacksObj, method_onServerRegistered, status,
  sCallbackEnv->CallVoidMethod(mCallbacksObj, method_onServerRegistered, status,
@@ -939,10 +943,8 @@ static int gattClientGetDeviceTypeNative(JNIEnv* env, jobject object,
static void gattClientRegisterAppNative(JNIEnv* env, jobject object,
static void gattClientRegisterAppNative(JNIEnv* env, jobject object,
                                        jlong app_uuid_lsb,
                                        jlong app_uuid_lsb,
                                        jlong app_uuid_msb) {
                                        jlong app_uuid_msb) {
  bt_uuid_t uuid;

  if (!sGattIf) return;
  if (!sGattIf) return;
  set_uuid(uuid.uu, app_uuid_msb, app_uuid_lsb);
  Uuid uuid = from_java_uuid(app_uuid_msb, app_uuid_lsb);
  sGattIf->client->register_client(uuid);
  sGattIf->client->register_client(uuid);
}
}


@@ -952,7 +954,7 @@ static void gattClientUnregisterAppNative(JNIEnv* env, jobject object,
  sGattIf->client->unregister_client(clientIf);
  sGattIf->client->unregister_client(clientIf);
}
}


void btgattc_register_scanner_cb(bt_uuid_t app_uuid, uint8_t scannerId,
void btgattc_register_scanner_cb(const Uuid& app_uuid, uint8_t scannerId,
                                 uint8_t status) {
                                 uint8_t status) {
  CallbackEnv sCallbackEnv(__func__);
  CallbackEnv sCallbackEnv(__func__);
  if (!sCallbackEnv.valid()) return;
  if (!sCallbackEnv.valid()) return;
@@ -964,8 +966,7 @@ static void registerScannerNative(JNIEnv* env, jobject object,
                                  jlong app_uuid_lsb, jlong app_uuid_msb) {
                                  jlong app_uuid_lsb, jlong app_uuid_msb) {
  if (!sGattIf) return;
  if (!sGattIf) return;


  bt_uuid_t uuid;
  Uuid uuid = from_java_uuid(app_uuid_msb, app_uuid_lsb);
  set_uuid(uuid.uu, app_uuid_msb, app_uuid_lsb);
  sGattIf->scanner->RegisterScanner(
  sGattIf->scanner->RegisterScanner(
      base::Bind(&btgattc_register_scanner_cb, uuid));
      base::Bind(&btgattc_register_scanner_cb, uuid));
}
}
@@ -1041,8 +1042,7 @@ static void gattClientSearchServiceNative(JNIEnv* env, jobject object,
                                          jlong service_uuid_msb) {
                                          jlong service_uuid_msb) {
  if (!sGattIf) return;
  if (!sGattIf) return;


  bt_uuid_t uuid;
  Uuid uuid = from_java_uuid(service_uuid_msb, service_uuid_lsb);
  set_uuid(uuid.uu, service_uuid_msb, service_uuid_lsb);
  sGattIf->client->search_service(conn_id, search_all ? 0 : &uuid);
  sGattIf->client->search_service(conn_id, search_all ? 0 : &uuid);
}
}


@@ -1052,8 +1052,7 @@ static void gattClientDiscoverServiceByUuidNative(JNIEnv* env, jobject object,
                                                  jlong service_uuid_msb) {
                                                  jlong service_uuid_msb) {
  if (!sGattIf) return;
  if (!sGattIf) return;


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


@@ -1077,8 +1076,7 @@ static void gattClientReadUsingCharacteristicUuidNative(
    jint s_handle, jint e_handle, jint authReq) {
    jint s_handle, jint e_handle, jint authReq) {
  if (!sGattIf) return;
  if (!sGattIf) return;


  bt_uuid_t uuid;
  Uuid uuid = from_java_uuid(uuid_msb, uuid_lsb);
  set_uuid(uuid.uu, uuid_msb, uuid_lsb);
  sGattIf->client->read_using_characteristic_uuid(conn_id, uuid, s_handle,
  sGattIf->client->read_using_characteristic_uuid(conn_id, uuid, s_handle,
                                                  e_handle, authReq);
                                                  e_handle, authReq);
}
}
@@ -1299,9 +1297,8 @@ static void gattClientScanFilterAddRemoveNative(
    case 2:  // BTM_BLE_PF_SRVC_UUID
    case 2:  // BTM_BLE_PF_SRVC_UUID
    case 3:  // BTM_BLE_PF_SRVC_SOL_UUID
    case 3:  // BTM_BLE_PF_SRVC_SOL_UUID
    {
    {
      bt_uuid_t uuid, uuid_mask;
      Uuid uuid = from_java_uuid(uuid_msb, uuid_lsb);
      set_uuid(uuid.uu, uuid_msb, uuid_lsb);
      Uuid uuid_mask = from_java_uuid(uuid_mask_msb, uuid_mask_lsb);
      set_uuid(uuid_mask.uu, uuid_mask_msb, uuid_mask_lsb);
      if (uuid_mask_lsb != 0 && uuid_mask_msb != 0)
      if (uuid_mask_lsb != 0 && uuid_mask_msb != 0)
        sGattIf->scanner->ScanFilterAddRemove(
        sGattIf->scanner->ScanFilterAddRemove(
            action, filt_type, filt_index, 0, 0, &uuid, &uuid_mask, NULL, 0, {},
            action, filt_type, filt_index, 0, 0, &uuid, &uuid_mask, NULL, 0, {},
@@ -1469,9 +1466,8 @@ static void gattClientReadScanReportsNative(JNIEnv* env, jobject object,
static void gattServerRegisterAppNative(JNIEnv* env, jobject object,
static void gattServerRegisterAppNative(JNIEnv* env, jobject object,
                                        jlong app_uuid_lsb,
                                        jlong app_uuid_lsb,
                                        jlong app_uuid_msb) {
                                        jlong app_uuid_msb) {
  bt_uuid_t uuid;
  if (!sGattIf) return;
  if (!sGattIf) return;
  set_uuid(uuid.uu, app_uuid_msb, app_uuid_lsb);
  Uuid uuid = from_java_uuid(app_uuid_msb, app_uuid_lsb);
  sGattIf->server->register_server(uuid);
  sGattIf->server->register_server(uuid);
}
}


@@ -1566,7 +1562,7 @@ static void gattServerAddServiceNative(JNIEnv* env, jobject object,
    if (uuid.get() != NULL) {
    if (uuid.get() != NULL) {
      jlong uuid_msb = env->CallLongMethod(uuid.get(), uuidGetMsb);
      jlong uuid_msb = env->CallLongMethod(uuid.get(), uuidGetMsb);
      jlong uuid_lsb = env->CallLongMethod(uuid.get(), uuidGetLsb);
      jlong uuid_lsb = env->CallLongMethod(uuid.get(), uuidGetLsb);
      set_uuid(curr.uuid.uu, uuid_msb, uuid_lsb);
      curr.uuid = from_java_uuid(uuid_msb, uuid_lsb);
    }
    }


    fid = env->GetFieldID(gattDbElementClazz, "type", "I");
    fid = env->GetFieldID(gattDbElementClazz, "type", "I");
@@ -2046,8 +2042,7 @@ static void gattTestNative(JNIEnv* env, jobject object, jint command,


  RawAddress bt_bda1 = str2addr(env, bda1);
  RawAddress bt_bda1 = str2addr(env, bda1);


  bt_uuid_t uuid1;
  Uuid uuid1 = from_java_uuid(uuid1_msb, uuid1_lsb);
  set_uuid(uuid1.uu, uuid1_msb, uuid1_lsb);


  btgatt_test_params_t params;
  btgatt_test_params_t params;
  params.bda1 = &bt_bda1;
  params.bda1 = &bt_bda1;
@@ -2224,4 +2219,4 @@ int register_com_android_bluetooth_gatt(JNIEnv* env) {
         jniRegisterNativeMethods(env, "com/android/bluetooth/gatt/GattService",
         jniRegisterNativeMethods(env, "com/android/bluetooth/gatt/GattService",
                                  sMethods, NELEM(sMethods));
                                  sMethods, NELEM(sMethods));
}
}
}
}  // namespace android
+23 −39
Original line number Original line Diff line number Diff line
@@ -25,29 +25,13 @@


#include <string.h>
#include <string.h>


static const uint8_t UUID_OBEX_OBJECT_PUSH[] = {
using bluetooth::Uuid;
    0x00, 0x00, 0x11, 0x05, 0x00, 0x00, 0x10, 0x00,

    0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
static const Uuid UUID_OBEX_OBJECT_PUSH = Uuid::From16Bit(0x1105);
static const uint8_t UUID_PBAP_PSE[] = {0x00, 0x00, 0x11, 0x2F, 0x00, 0x00,
static const Uuid UUID_PBAP_PSE = Uuid::From16Bit(0x112F);
                                        0x10, 0x00, 0x80, 0x00, 0x00, 0x80,
static const Uuid UUID_MAP_MAS = Uuid::From16Bit(0x1132);
                                        0x5F, 0x9B, 0x34, 0xFB};
static const Uuid UUID_MAP_MNS = Uuid::From16Bit(0x1133);
static const uint8_t UUID_MAP_MAS[] = {0x00, 0x00, 0x11, 0x32, 0x00, 0x00,
static const Uuid UUID_SAP = Uuid::From16Bit(0x112D);
                                       0x10, 0x00, 0x80, 0x00, 0x00, 0x80,
                                       0x5F, 0x9B, 0x34, 0xFB};
static const uint8_t UUID_MAP_MNS[] = {0x00, 0x00, 0x11, 0x33, 0x00, 0x00,
                                       0x10, 0x00, 0x80, 0x00, 0x00, 0x80,
                                       0x5F, 0x9B, 0x34, 0xFB};
static const uint8_t UUID_SAP[] = {0x00, 0x00, 0x11, 0x2D, 0x00, 0x00,
                                   0x10, 0x00, 0x80, 0x00, 0x00, 0x80,
                                   0x5F, 0x9B, 0x34, 0xFB};
// TODO:
// Both the fact that the UUIDs are declared in multiple places, plus the fact
// that there is a mess of UUID comparison and shortening methods will have to
// be fixed.
// The btcore->uuid module should be used for all instances.

#define UUID_MAX_LENGTH 16
#define IS_UUID(u1, u2) !memcmp(u1, u2, UUID_MAX_LENGTH)


namespace android {
namespace android {
static jmethodID method_sdpRecordFoundCallback;
static jmethodID method_sdpRecordFoundCallback;
@@ -59,8 +43,8 @@ static jmethodID method_sdpSapsRecordFoundCallback;


static const btsdp_interface_t* sBluetoothSdpInterface = NULL;
static const btsdp_interface_t* sBluetoothSdpInterface = NULL;


static void sdp_search_callback(bt_status_t status, RawAddress* bd_addr,
static void sdp_search_callback(bt_status_t status, const RawAddress& bd_addr,
                                uint8_t* uuid_in, int record_size,
                                const Uuid& uuid_in, int record_size,
                                bluetooth_sdp_record* record);
                                bluetooth_sdp_record* record);


btsdp_callbacks_t sBluetoothSdpCallbacks = {sizeof(sBluetoothSdpCallbacks),
btsdp_callbacks_t sBluetoothSdpCallbacks = {sizeof(sBluetoothSdpCallbacks),
@@ -135,8 +119,8 @@ static jboolean sdpSearchNative(JNIEnv* env, jobject obj, jbyteArray address,
  }
  }
  ALOGD("%s UUID %.*s", __func__, 16, (uint8_t*)uuid);
  ALOGD("%s UUID %.*s", __func__, 16, (uint8_t*)uuid);


  int ret = sBluetoothSdpInterface->sdp_search((RawAddress*)addr,
  int ret = sBluetoothSdpInterface->sdp_search(
                                               (const uint8_t*)uuid);
      (RawAddress*)addr, Uuid::From128BitBE((uint8_t*)uuid));
  if (ret != BT_STATUS_SUCCESS) {
  if (ret != BT_STATUS_SUCCESS) {
    ALOGE("SDP Search initialization failed: %d", ret);
    ALOGE("SDP Search initialization failed: %d", ret);
  }
  }
@@ -146,8 +130,8 @@ static jboolean sdpSearchNative(JNIEnv* env, jobject obj, jbyteArray address,
  return (ret == BT_STATUS_SUCCESS) ? JNI_TRUE : JNI_FALSE;
  return (ret == BT_STATUS_SUCCESS) ? JNI_TRUE : JNI_FALSE;
}
}


static void sdp_search_callback(bt_status_t status, RawAddress* bd_addr,
static void sdp_search_callback(bt_status_t status, const RawAddress& bd_addr,
                                uint8_t* uuid_in, int count,
                                const Uuid& uuid_in, int count,
                                bluetooth_sdp_record* records) {
                                bluetooth_sdp_record* records) {
  CallbackEnv sCallbackEnv(__func__);
  CallbackEnv sCallbackEnv(__func__);
  if (!sCallbackEnv.valid()) return;
  if (!sCallbackEnv.valid()) return;
@@ -156,14 +140,14 @@ static void sdp_search_callback(bt_status_t status, RawAddress* bd_addr,
      sCallbackEnv.get(), sCallbackEnv->NewByteArray(sizeof(RawAddress)));
      sCallbackEnv.get(), sCallbackEnv->NewByteArray(sizeof(RawAddress)));
  if (!addr.get()) return;
  if (!addr.get()) return;


  ScopedLocalRef<jbyteArray> uuid(
  ScopedLocalRef<jbyteArray> uuid(sCallbackEnv.get(),
      sCallbackEnv.get(), sCallbackEnv->NewByteArray(sizeof(bt_uuid_t)));
                                  sCallbackEnv->NewByteArray(sizeof(Uuid)));
  if (!uuid.get()) return;
  if (!uuid.get()) return;


  sCallbackEnv->SetByteArrayRegion(addr.get(), 0, sizeof(RawAddress),
  sCallbackEnv->SetByteArrayRegion(addr.get(), 0, sizeof(RawAddress),
                                   (jbyte*)bd_addr);
                                   (const jbyte*)&bd_addr);
  sCallbackEnv->SetByteArrayRegion(uuid.get(), 0, sizeof(bt_uuid_t),
  sCallbackEnv->SetByteArrayRegion(uuid.get(), 0, sizeof(Uuid),
                                   (jbyte*)uuid_in);
                                   (const jbyte*)uuid_in.To128BitBE().data());


  ALOGD("%s: Status is: %d, Record count: %d", __func__, status, count);
  ALOGD("%s: Status is: %d, Record count: %d", __func__, status, count);


@@ -179,7 +163,7 @@ static void sdp_search_callback(bt_status_t status, RawAddress* bd_addr,
    }
    }


    /* call the right callback according to the uuid*/
    /* call the right callback according to the uuid*/
    if (IS_UUID(UUID_MAP_MAS, uuid_in)) {
    if (uuid_in == UUID_MAP_MAS) {
      sCallbackEnv->CallVoidMethod(
      sCallbackEnv->CallVoidMethod(
          sCallbacksObj, method_sdpMasRecordFoundCallback, (jint)status,
          sCallbacksObj, method_sdpMasRecordFoundCallback, (jint)status,
          addr.get(), uuid.get(), (jint)record->mas.mas_instance_id,
          addr.get(), uuid.get(), (jint)record->mas.mas_instance_id,
@@ -190,7 +174,7 @@ static void sdp_search_callback(bt_status_t status, RawAddress* bd_addr,
          (jint)record->mas.supported_message_types, service_name.get(),
          (jint)record->mas.supported_message_types, service_name.get(),
          more_results);
          more_results);


    } else if (IS_UUID(UUID_MAP_MNS, uuid_in)) {
    } else if (uuid_in == UUID_MAP_MNS) {
      sCallbackEnv->CallVoidMethod(
      sCallbackEnv->CallVoidMethod(
          sCallbacksObj, method_sdpMnsRecordFoundCallback, (jint)status,
          sCallbacksObj, method_sdpMnsRecordFoundCallback, (jint)status,
          addr.get(), uuid.get(), (jint)record->mns.hdr.l2cap_psm,
          addr.get(), uuid.get(), (jint)record->mns.hdr.l2cap_psm,
@@ -199,7 +183,7 @@ static void sdp_search_callback(bt_status_t status, RawAddress* bd_addr,
          (jint)record->mns.supported_features, service_name.get(),
          (jint)record->mns.supported_features, service_name.get(),
          more_results);
          more_results);


    } else if (IS_UUID(UUID_PBAP_PSE, uuid_in)) {
    } else if (uuid_in == UUID_PBAP_PSE) {
      sCallbackEnv->CallVoidMethod(
      sCallbackEnv->CallVoidMethod(
          sCallbacksObj, method_sdpPseRecordFoundCallback, (jint)status,
          sCallbacksObj, method_sdpPseRecordFoundCallback, (jint)status,
          addr.get(), uuid.get(), (jint)record->pse.hdr.l2cap_psm,
          addr.get(), uuid.get(), (jint)record->pse.hdr.l2cap_psm,
@@ -209,7 +193,7 @@ static void sdp_search_callback(bt_status_t status, RawAddress* bd_addr,
          (jint)record->pse.supported_repositories, service_name.get(),
          (jint)record->pse.supported_repositories, service_name.get(),
          more_results);
          more_results);


    } else if (IS_UUID(UUID_OBEX_OBJECT_PUSH, uuid_in)) {
    } else if (uuid_in == UUID_OBEX_OBJECT_PUSH) {
      jint formats_list_size = record->ops.supported_formats_list_len;
      jint formats_list_size = record->ops.supported_formats_list_len;
      ScopedLocalRef<jbyteArray> formats_list(
      ScopedLocalRef<jbyteArray> formats_list(
          sCallbackEnv.get(), sCallbackEnv->NewByteArray(formats_list_size));
          sCallbackEnv.get(), sCallbackEnv->NewByteArray(formats_list_size));
@@ -225,7 +209,7 @@ static void sdp_search_callback(bt_status_t status, RawAddress* bd_addr,
          (jint)record->ops.hdr.profile_version, service_name.get(),
          (jint)record->ops.hdr.profile_version, service_name.get(),
          formats_list.get(), more_results);
          formats_list.get(), more_results);


    } else if (IS_UUID(UUID_SAP, uuid_in)) {
    } else if (uuid_in == UUID_SAP) {
      sCallbackEnv->CallVoidMethod(
      sCallbackEnv->CallVoidMethod(
          sCallbacksObj, method_sdpSapsRecordFoundCallback, (jint)status,
          sCallbacksObj, method_sdpSapsRecordFoundCallback, (jint)status,
          addr.get(), uuid.get(), (jint)record->mas.hdr.rfcomm_channel_number,
          addr.get(), uuid.get(), (jint)record->mas.hdr.rfcomm_channel_number,