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

Commit 86fa06b1 authored by Gopi Sakshihally Bhuthaiah's avatar Gopi Sakshihally Bhuthaiah
Browse files

Added transport in HID host JNI

Bug: 324120239
Test: mma packages/modules/Bluetooth
Flag: EXEMPT no logical change
Change-Id: I5f6c54f420f44c7ce8bcc3fba70fb1c70ca5ba4b
parent 23fe2b3f
Loading
Loading
Loading
Loading
+88 −47
Original line number Diff line number Diff line
@@ -50,6 +50,8 @@ static jbyteArray marshall_bda(RawAddress* bd_addr) {
}

static void connection_state_callback(RawAddress* bd_addr,
                                      tBLE_ADDR_TYPE addr_type,
                                      tBT_TRANSPORT transport,
                                      bthh_connection_state_t state) {
  std::shared_lock<std::shared_timed_mutex> lock(mCallbacks_mutex);
  CallbackEnv sCallbackEnv(__func__);
@@ -65,10 +67,13 @@ static void connection_state_callback(RawAddress* bd_addr,
  }

  sCallbackEnv->CallVoidMethod(mCallbacksObj, method_onConnectStateChanged,
                               addr.get(), (jint)state);
                               addr.get(), (jint)addr_type, (jint)transport,
                               (jint)state);
}

static void get_protocol_mode_callback(RawAddress* bd_addr,
                                       tBLE_ADDR_TYPE addr_type,
                                       tBT_TRANSPORT transport,
                                       bthh_status_t hh_status,
                                       bthh_protocol_mode_t mode) {
  std::shared_lock<std::shared_timed_mutex> lock(mCallbacks_mutex);
@@ -90,11 +95,14 @@ static void get_protocol_mode_callback(RawAddress* bd_addr,
  }

  sCallbackEnv->CallVoidMethod(mCallbacksObj, method_onGetProtocolMode,
                               addr.get(), (jint)mode);
                               addr.get(), (jint)addr_type, (jint)transport,
                               (jint)mode);
}

static void get_report_callback(RawAddress* bd_addr, bthh_status_t hh_status,
                                uint8_t* rpt_data, int rpt_size) {
static void get_report_callback(RawAddress* bd_addr, tBLE_ADDR_TYPE addr_type,
                                tBT_TRANSPORT transport,
                                bthh_status_t hh_status, uint8_t* rpt_data,
                                int rpt_size) {
  std::shared_lock<std::shared_timed_mutex> lock(mCallbacks_mutex);
  CallbackEnv sCallbackEnv(__func__);
  if (!sCallbackEnv.valid()) return;
@@ -121,10 +129,13 @@ static void get_report_callback(RawAddress* bd_addr, bthh_status_t hh_status,

  sCallbackEnv->SetByteArrayRegion(data.get(), 0, rpt_size, (jbyte*)rpt_data);
  sCallbackEnv->CallVoidMethod(mCallbacksObj, method_onGetReport, addr.get(),
                               data.get(), (jint)rpt_size);
                               (jint)addr_type, (jint)transport, data.get(),
                               (jint)rpt_size);
}

static void virtual_unplug_callback(RawAddress* bd_addr,
                                    tBLE_ADDR_TYPE addr_type,
                                    tBT_TRANSPORT transport,
                                    bthh_status_t hh_status) {
  log::verbose("call to virtual_unplug_callback");
  std::shared_lock<std::shared_timed_mutex> lock(mCallbacks_mutex);
@@ -140,10 +151,13 @@ static void virtual_unplug_callback(RawAddress* bd_addr,
    return;
  }
  sCallbackEnv->CallVoidMethod(mCallbacksObj, method_onVirtualUnplug,
                               addr.get(), (jint)hh_status);
                               addr.get(), (jint)addr_type, (jint)transport,
                               (jint)hh_status);
}

static void handshake_callback(RawAddress* bd_addr, bthh_status_t hh_status) {
static void handshake_callback(RawAddress* bd_addr, tBLE_ADDR_TYPE addr_type,
                               tBT_TRANSPORT transport,
                               bthh_status_t hh_status) {
  std::shared_lock<std::shared_timed_mutex> lock(mCallbacks_mutex);
  CallbackEnv sCallbackEnv(__func__);
  if (!sCallbackEnv.valid()) return;
@@ -158,10 +172,13 @@ static void handshake_callback(RawAddress* bd_addr, bthh_status_t hh_status) {
    return;
  }
  sCallbackEnv->CallVoidMethod(mCallbacksObj, method_onHandshake, addr.get(),
                               (jint)addr_type, (jint)transport,
                               (jint)hh_status);
}

static void get_idle_time_callback(RawAddress* bd_addr,
                                   tBLE_ADDR_TYPE addr_type,
                                   tBT_TRANSPORT transport,
                                   bthh_status_t /* hh_status */,
                                   int idle_time) {
  std::shared_lock<std::shared_timed_mutex> lock(mCallbacks_mutex);
@@ -174,6 +191,7 @@ static void get_idle_time_callback(RawAddress* bd_addr,
    return;
  }
  sCallbackEnv->CallVoidMethod(mCallbacksObj, method_onGetIdleTime, addr.get(),
                               (jint)addr_type, (jint)transport,
                               (jint)idle_time);
}

@@ -249,7 +267,8 @@ static void cleanupNative(JNIEnv* env, jobject /* object */) {
}

static jboolean connectHidNative(JNIEnv* env, jobject /* object */,
                                 jbyteArray address) {
                                 jbyteArray address, jint address_type,
                                 jint transport) {
  if (!sBluetoothHidInterface) return JNI_FALSE;

  jbyte* addr = env->GetByteArrayElements(address, NULL);
@@ -259,7 +278,9 @@ static jboolean connectHidNative(JNIEnv* env, jobject /* object */,
  }

  jboolean ret = JNI_TRUE;
  bt_status_t status = sBluetoothHidInterface->connect((RawAddress*)addr);
  bt_status_t status = sBluetoothHidInterface->connect(
      (RawAddress*)addr, (tBLE_ADDR_TYPE)address_type,
      (tBT_TRANSPORT)transport);
  if (status != BT_STATUS_SUCCESS && status != BT_STATUS_BUSY) {
    log::error("Failed HID channel connection, status: {}",
               bt_status_text(status));
@@ -271,7 +292,8 @@ static jboolean connectHidNative(JNIEnv* env, jobject /* object */,
}

static jboolean disconnectHidNative(JNIEnv* env, jobject /* object */,
                                    jbyteArray address) {
                                    jbyteArray address, jint address_type,
                                    jint transport) {
  jbyte* addr;
  jboolean ret = JNI_TRUE;
  if (!sBluetoothHidInterface) return JNI_FALSE;
@@ -282,7 +304,9 @@ static jboolean disconnectHidNative(JNIEnv* env, jobject /* object */,
    return JNI_FALSE;
  }

  bt_status_t status = sBluetoothHidInterface->disconnect((RawAddress*)addr);
  bt_status_t status = sBluetoothHidInterface->disconnect(
      (RawAddress*)addr, (tBLE_ADDR_TYPE)address_type,
      (tBT_TRANSPORT)transport);
  if (status != BT_STATUS_SUCCESS) {
    log::error("Failed disconnect hid channel, status: {}",
               bt_status_text(status));
@@ -294,7 +318,8 @@ static jboolean disconnectHidNative(JNIEnv* env, jobject /* object */,
}

static jboolean getProtocolModeNative(JNIEnv* env, jobject /* object */,
                                      jbyteArray address) {
                                      jbyteArray address, jint address_type,
                                      jint transport) {
  if (!sBluetoothHidInterface) return JNI_FALSE;

  jbyte* addr = env->GetByteArrayElements(address, NULL);
@@ -307,7 +332,8 @@ static jboolean getProtocolModeNative(JNIEnv* env, jobject /* object */,
  // TODO: protocolMode is unused by the backend: see b/28908173
  bthh_protocol_mode_t protocolMode = BTHH_UNSUPPORTED_MODE;
  bt_status_t status = sBluetoothHidInterface->get_protocol(
      (RawAddress*)addr, (bthh_protocol_mode_t)protocolMode);
      (RawAddress*)addr, (tBLE_ADDR_TYPE)address_type, (tBT_TRANSPORT)transport,
      (bthh_protocol_mode_t)protocolMode);
  if (status != BT_STATUS_SUCCESS) {
    log::error("Failed get protocol mode, status: {}", bt_status_text(status));
    ret = JNI_FALSE;
@@ -318,7 +344,8 @@ static jboolean getProtocolModeNative(JNIEnv* env, jobject /* object */,
}

static jboolean virtualUnPlugNative(JNIEnv* env, jobject /* object */,
                                    jbyteArray address) {
                                    jbyteArray address, jint address_type,
                                    jint transport) {
  if (!sBluetoothHidInterface) return JNI_FALSE;

  jbyte* addr = env->GetByteArrayElements(address, NULL);
@@ -328,8 +355,9 @@ static jboolean virtualUnPlugNative(JNIEnv* env, jobject /* object */,
  }

  jboolean ret = JNI_TRUE;
  bt_status_t status =
      sBluetoothHidInterface->virtual_unplug((RawAddress*)addr);
  bt_status_t status = sBluetoothHidInterface->virtual_unplug(
      (RawAddress*)addr, (tBLE_ADDR_TYPE)address_type,
      (tBT_TRANSPORT)transport);
  if (status != BT_STATUS_SUCCESS) {
    log::error("Failed virual unplug, status: {}", bt_status_text(status));
    ret = JNI_FALSE;
@@ -339,7 +367,8 @@ static jboolean virtualUnPlugNative(JNIEnv* env, jobject /* object */,
}

static jboolean setProtocolModeNative(JNIEnv* env, jobject /* object */,
                                      jbyteArray address, jint protocolMode) {
                                      jbyteArray address, jint address_type,
                                      jint transport, jint protocolMode) {
  if (!sBluetoothHidInterface) return JNI_FALSE;

  log::debug("protocolMode = {}", protocolMode);
@@ -364,8 +393,9 @@ static jboolean setProtocolModeNative(JNIEnv* env, jobject /* object */,
  }

  jboolean ret = JNI_TRUE;
  bt_status_t status =
      sBluetoothHidInterface->set_protocol((RawAddress*)addr, mode);
  bt_status_t status = sBluetoothHidInterface->set_protocol(
      (RawAddress*)addr, (tBLE_ADDR_TYPE)address_type, (tBT_TRANSPORT)transport,
      mode);
  if (status != BT_STATUS_SUCCESS) {
    log::error("Failed set protocol mode, status: {}", bt_status_text(status));
    ret = JNI_FALSE;
@@ -376,7 +406,8 @@ static jboolean setProtocolModeNative(JNIEnv* env, jobject /* object */,
}

static jboolean getReportNative(JNIEnv* env, jobject /* object */,
                                jbyteArray address, jbyte reportType,
                                jbyteArray address, jint address_type,
                                jint transport, jbyte reportType,
                                jbyte reportId, jint bufferSize) {
  log::verbose("reportType = {}, reportId = {}, bufferSize = {}", reportType,
               reportId, bufferSize);
@@ -392,7 +423,8 @@ static jboolean getReportNative(JNIEnv* env, jobject /* object */,
  jint rId = reportId;

  bt_status_t status = sBluetoothHidInterface->get_report(
      (RawAddress*)addr, (bthh_report_type_t)rType, (uint8_t)rId, bufferSize);
      (RawAddress*)addr, (tBLE_ADDR_TYPE)address_type, (tBT_TRANSPORT)transport,
      (bthh_report_type_t)rType, (uint8_t)rId, bufferSize);
  jboolean ret = JNI_TRUE;
  if (status != BT_STATUS_SUCCESS) {
    log::error("Failed get report, status: {}", bt_status_text(status));
@@ -404,7 +436,8 @@ static jboolean getReportNative(JNIEnv* env, jobject /* object */,
}

static jboolean setReportNative(JNIEnv* env, jobject /* object */,
                                jbyteArray address, jbyte reportType,
                                jbyteArray address, jint address_type,
                                jint transport, jbyte reportType,
                                jstring report) {
  log::verbose("reportType = {}", reportType);
  if (!sBluetoothHidInterface) return JNI_FALSE;
@@ -419,7 +452,8 @@ static jboolean setReportNative(JNIEnv* env, jobject /* object */,

  jboolean ret = JNI_TRUE;
  bt_status_t status = sBluetoothHidInterface->set_report(
      (RawAddress*)addr, (bthh_report_type_t)rType, (char*)c_report);
      (RawAddress*)addr, (tBLE_ADDR_TYPE)address_type, (tBT_TRANSPORT)transport,
      (bthh_report_type_t)rType, (char*)c_report);
  if (status != BT_STATUS_SUCCESS) {
    log::error("Failed set report, status: {}", bt_status_text(status));
    ret = JNI_FALSE;
@@ -431,7 +465,8 @@ static jboolean setReportNative(JNIEnv* env, jobject /* object */,
}

static jboolean sendDataNative(JNIEnv* env, jobject /* object */,
                               jbyteArray address, jstring report) {
                               jbyteArray address, jint address_type,
                               jint transport, jstring report) {
  log::verbose("");
  jboolean ret = JNI_TRUE;
  if (!sBluetoothHidInterface) return JNI_FALSE;
@@ -444,8 +479,9 @@ static jboolean sendDataNative(JNIEnv* env, jobject /* object */,

  const char* c_report = env->GetStringUTFChars(report, NULL);

  bt_status_t status =
      sBluetoothHidInterface->send_data((RawAddress*)addr, (char*)c_report);
  bt_status_t status = sBluetoothHidInterface->send_data(
      (RawAddress*)addr, (tBLE_ADDR_TYPE)address_type, (tBT_TRANSPORT)transport,
      (char*)c_report);
  if (status != BT_STATUS_SUCCESS) {
    log::error("Failed set data, status: {}", bt_status_text(status));
    ret = JNI_FALSE;
@@ -457,7 +493,8 @@ static jboolean sendDataNative(JNIEnv* env, jobject /* object */,
}

static jboolean getIdleTimeNative(JNIEnv* env, jobject /* object */,
                                  jbyteArray address) {
                                  jbyteArray address, jint address_type,
                                  jint transport) {
  if (!sBluetoothHidInterface) return JNI_FALSE;

  jbyte* addr = env->GetByteArrayElements(address, NULL);
@@ -466,7 +503,9 @@ static jboolean getIdleTimeNative(JNIEnv* env, jobject /* object */,
    return JNI_FALSE;
  }

  bt_status_t status = sBluetoothHidInterface->get_idle_time((RawAddress*)addr);
  bt_status_t status = sBluetoothHidInterface->get_idle_time(
      (RawAddress*)addr, (tBLE_ADDR_TYPE)address_type,
      (tBT_TRANSPORT)transport);
  if (status != BT_STATUS_SUCCESS) {
    log::error("Failed get idle time, status: {}", bt_status_text(status));
  }
@@ -476,7 +515,8 @@ static jboolean getIdleTimeNative(JNIEnv* env, jobject /* object */,
}

static jboolean setIdleTimeNative(JNIEnv* env, jobject /* object */,
                                  jbyteArray address, jbyte idle_time) {
                                  jbyteArray address, jint address_type,
                                  jint transport, jbyte idle_time) {
  if (!sBluetoothHidInterface) return JNI_FALSE;

  jbyte* addr = env->GetByteArrayElements(address, NULL);
@@ -485,8 +525,9 @@ static jboolean setIdleTimeNative(JNIEnv* env, jobject /* object */,
    return JNI_FALSE;
  }

  bt_status_t status =
      sBluetoothHidInterface->set_idle_time((RawAddress*)addr, idle_time);
  bt_status_t status = sBluetoothHidInterface->set_idle_time(
      (RawAddress*)addr, (tBLE_ADDR_TYPE)address_type, (tBT_TRANSPORT)transport,
      idle_time);
  if (status != BT_STATUS_SUCCESS) {
    log::error("Failed set idle time, status: {}", bt_status_text(status));
  }
@@ -499,16 +540,16 @@ int register_com_android_bluetooth_hid_host(JNIEnv* env) {
  const JNINativeMethod methods[] = {
      {"initializeNative", "()V", (void*)initializeNative},
      {"cleanupNative", "()V", (void*)cleanupNative},
      {"connectHidNative", "([B)Z", (void*)connectHidNative},
      {"disconnectHidNative", "([B)Z", (void*)disconnectHidNative},
      {"getProtocolModeNative", "([B)Z", (void*)getProtocolModeNative},
      {"virtualUnPlugNative", "([B)Z", (void*)virtualUnPlugNative},
      {"setProtocolModeNative", "([BB)Z", (void*)setProtocolModeNative},
      {"getReportNative", "([BBBI)Z", (void*)getReportNative},
      {"setReportNative", "([BBLjava/lang/String;)Z", (void*)setReportNative},
      {"sendDataNative", "([BLjava/lang/String;)Z", (void*)sendDataNative},
      {"getIdleTimeNative", "([B)Z", (void*)getIdleTimeNative},
      {"setIdleTimeNative", "([BB)Z", (void*)setIdleTimeNative},
      {"connectHidNative", "([BII)Z", (void*)connectHidNative},
      {"disconnectHidNative", "([BII)Z", (void*)disconnectHidNative},
      {"getProtocolModeNative", "([BII)Z", (void*)getProtocolModeNative},
      {"virtualUnPlugNative", "([BII)Z", (void*)virtualUnPlugNative},
      {"setProtocolModeNative", "([BIIB)Z", (void*)setProtocolModeNative},
      {"getReportNative", "([BIIBBI)Z", (void*)getReportNative},
      {"setReportNative", "([BIIBLjava/lang/String;)Z", (void*)setReportNative},
      {"sendDataNative", "([BIILjava/lang/String;)Z", (void*)sendDataNative},
      {"getIdleTimeNative", "([BII)Z", (void*)getIdleTimeNative},
      {"setIdleTimeNative", "([BIIB)Z", (void*)setIdleTimeNative},
  };
  const int result = REGISTER_NATIVE_METHODS(
      env, "com/android/bluetooth/hid/HidHostNativeInterface", methods);
@@ -517,12 +558,12 @@ int register_com_android_bluetooth_hid_host(JNIEnv* env) {
  }

  const JNIJavaMethod javaMethods[] = {
      {"onConnectStateChanged", "([BI)V", &method_onConnectStateChanged},
      {"onGetProtocolMode", "([BI)V", &method_onGetProtocolMode},
      {"onGetReport", "([B[BI)V", &method_onGetReport},
      {"onHandshake", "([BI)V", &method_onHandshake},
      {"onVirtualUnplug", "([BI)V", &method_onVirtualUnplug},
      {"onGetIdleTime", "([BI)V", &method_onGetIdleTime},
      {"onConnectStateChanged", "([BIII)V", &method_onConnectStateChanged},
      {"onGetProtocolMode", "([BIII)V", &method_onGetProtocolMode},
      {"onGetReport", "([BII[BI)V", &method_onGetReport},
      {"onHandshake", "([BIII)V", &method_onHandshake},
      {"onVirtualUnplug", "([BIII)V", &method_onVirtualUnplug},
      {"onGetIdleTime", "([BIII)V", &method_onGetIdleTime},
  };
  GET_JAVA_METHODS(env, "com/android/bluetooth/hid/HidHostNativeInterface",
                   javaMethods);
+60 −42
Original line number Diff line number Diff line
@@ -60,44 +60,51 @@ public class HidHostNativeInterface {
        cleanupNative();
    }

    boolean connectHid(byte[] address) {
        return connectHidNative(address);
    boolean connectHid(byte[] address, int addressType, int transport) {
        return connectHidNative(address, addressType, transport);
    }

    boolean disconnectHid(byte[] address) {
        return disconnectHidNative(address);
    boolean disconnectHid(byte[] address, int addressType, int transport) {
        return disconnectHidNative(address, addressType, transport);
    }

    boolean getProtocolMode(byte[] address) {
        return getProtocolModeNative(address);
    boolean getProtocolMode(byte[] address, int addressType, int transport) {
        return getProtocolModeNative(address, addressType, transport);
    }

    boolean virtualUnPlug(byte[] address) {
        return virtualUnPlugNative(address);
    boolean virtualUnPlug(byte[] address, int addressType, int transport) {
        return virtualUnPlugNative(address, addressType, transport);
    }

    boolean setProtocolMode(byte[] address, byte protocolMode) {
        return setProtocolModeNative(address, protocolMode);
    boolean setProtocolMode(byte[] address, int addressType, int transport, byte protocolMode) {
        return setProtocolModeNative(address, addressType, transport, protocolMode);
    }

    boolean getReport(byte[] address, byte reportType, byte reportId, int bufferSize) {
        return getReportNative(address, reportType, reportId, bufferSize);
    boolean getReport(
            byte[] address,
            int addressType,
            int transport,
            byte reportType,
            byte reportId,
            int bufferSize) {
        return getReportNative(address, addressType, transport, reportType, reportId, bufferSize);
    }

    boolean setReport(byte[] address, byte reportType, String report) {
        return setReportNative(address, reportType, report);
    boolean setReport(
            byte[] address, int addressType, int transport, byte reportType, String report) {
        return setReportNative(address, addressType, transport, reportType, report);
    }

    boolean sendData(byte[] address, String report) {
        return sendDataNative(address, report);
    boolean sendData(byte[] address, int addressType, int transport, String report) {
        return sendDataNative(address, addressType, transport, report);
    }

    boolean setIdleTime(byte[] address, byte idleTime) {
        return setIdleTimeNative(address, idleTime);
    boolean setIdleTime(byte[] address, int addressType, int transport, byte idleTime) {
        return setIdleTimeNative(address, addressType, transport, idleTime);
    }

    boolean getIdleTime(byte[] address) {
        return getIdleTimeNative(address);
    boolean getIdleTime(byte[] address, int addressType, int transport) {
        return getIdleTimeNative(address, addressType, transport);
    }

    private static int convertHalState(int halState) {
@@ -120,34 +127,36 @@ public class HidHostNativeInterface {
    /*********************************** callbacks from native ************************************/
    /**********************************************************************************************/

    private void onConnectStateChanged(byte[] address, int state) {
    private void onConnectStateChanged(byte[] address, int addressType, int transport, int state) {
        if (DBG) Log.d(TAG, "onConnectStateChanged: state=" + state);
        mHidHostService.onConnectStateChanged(address, convertHalState(state));
        mHidHostService.onConnectStateChanged(
                address, addressType, transport, convertHalState(state));
    }

    private void onGetProtocolMode(byte[] address, int mode) {
    private void onGetProtocolMode(byte[] address, int addressType, int transport, int mode) {
        if (DBG) Log.d(TAG, "onGetProtocolMode()");
        mHidHostService.onGetProtocolMode(address, mode);
        mHidHostService.onGetProtocolMode(address, addressType, transport, mode);
    }

    private void onGetReport(byte[] address, byte[] report, int rptSize) {
    private void onGetReport(
            byte[] address, int addressType, int transport, byte[] report, int rptSize) {
        if (DBG) Log.d(TAG, "onGetReport()");
        mHidHostService.onGetReport(address, report, rptSize);
        mHidHostService.onGetReport(address, addressType, transport, report, rptSize);
    }

    private void onHandshake(byte[] address, int status) {
    private void onHandshake(byte[] address, int addressType, int transport, int status) {
        if (DBG) Log.d(TAG, "onHandshake: status=" + status);
        mHidHostService.onHandshake(address, status);
        mHidHostService.onHandshake(address, addressType, transport, status);
    }

    private void onVirtualUnplug(byte[] address, int status) {
    private void onVirtualUnplug(byte[] address, int addressType, int transport, int status) {
        if (DBG) Log.d(TAG, "onVirtualUnplug: status=" + status);
        mHidHostService.onVirtualUnplug(address, status);
        mHidHostService.onVirtualUnplug(address, addressType, transport, status);
    }

    private void onGetIdleTime(byte[] address, int idleTime) {
    private void onGetIdleTime(byte[] address, int addressType, int transport, int idleTime) {
        if (DBG) Log.d(TAG, "onGetIdleTime()");
        mHidHostService.onGetIdleTime(address, idleTime);
        mHidHostService.onGetIdleTime(address, addressType, transport, idleTime);
    }

    /**********************************************************************************************/
@@ -166,24 +175,33 @@ public class HidHostNativeInterface {

    private native void cleanupNative();

    private native boolean connectHidNative(byte[] btAddress);
    private native boolean connectHidNative(byte[] btAddress, int addressType, int transport);

    private native boolean disconnectHidNative(byte[] btAddress);
    private native boolean disconnectHidNative(byte[] btAddress, int addressType, int transport);

    private native boolean getProtocolModeNative(byte[] btAddress);
    private native boolean getProtocolModeNative(byte[] btAddress, int addressType, int transport);

    private native boolean virtualUnPlugNative(byte[] btAddress);
    private native boolean virtualUnPlugNative(byte[] btAddress, int addressType, int transport);

    private native boolean setProtocolModeNative(byte[] btAddress, byte protocolMode);
    private native boolean setProtocolModeNative(
            byte[] btAddress, int addressType, int transport, byte protocolMode);

    private native boolean getReportNative(
            byte[] btAddress, byte reportType, byte reportId, int bufferSize);
            byte[] btAddress,
            int addressType,
            int transport,
            byte reportType,
            byte reportId,
            int bufferSize);

    private native boolean setReportNative(byte[] btAddress, byte reportType, String report);
    private native boolean setReportNative(
            byte[] btAddress, int addressType, int transport, byte reportType, String report);

    private native boolean sendDataNative(byte[] btAddress, String report);
    private native boolean sendDataNative(
            byte[] btAddress, int addressType, int transport, String report);

    private native boolean setIdleTimeNative(byte[] btAddress, byte idleTime);
    private native boolean setIdleTimeNative(
            byte[] btAddress, int addressType, int transport, byte idleTime);

    private native boolean getIdleTimeNative(byte[] btAddress);
    private native boolean getIdleTimeNative(byte[] btAddress, int addressType, int transport);
}
+197 −139

File changed.

Preview size limit exceeded, changes collapsed.

+10 −6
Original line number Diff line number Diff line
@@ -502,7 +502,7 @@ void bta_hh_connect(tBTA_HH_DEV_CB* p_cb, const tBTA_HH_DATA* p_data) {
  bt_property_t remote_properties = {BT_PROPERTY_UUIDS, sizeof(remote_uuids),
                                     &remote_uuids};
  const RawAddress& bd_addr = p_data->api_conn.link_spec.addrt.bda;

  p_cb->link_spec = p_data->api_conn.link_spec;
  // Find the device type
  tBT_DEVICE_TYPE dev_type;
  tBLE_ADDR_TYPE addr_type;
@@ -554,6 +554,11 @@ void bta_hh_connect(tBTA_HH_DEV_CB* p_cb, const tBTA_HH_DATA* p_data) {
      ADDRESS_TO_LOGGABLE_CSTR(bd_addr), bredr, hid_available, le_acl,
      hogp_available, dev_type, p_cb->is_le_device);

  // TODO: Use requested address type and transport
  p_cb->link_spec.addrt.type = addr_type;
  p_cb->link_spec.transport =
      p_cb->is_le_device ? BT_TRANSPORT_LE : BT_TRANSPORT_BR_EDR;

  p_cb->mode = p_data->api_conn.mode;
  bta_hh_cb.p_cur = p_cb;

@@ -641,8 +646,7 @@ void bta_hh_open_cmpl_act(tBTA_HH_DEV_CB* p_cb, const tBTA_HH_DATA* p_data) {
                     "%s initiator:%s", (p_cb->is_le_device) ? "le" : "classic",
                     (p_cb->incoming_conn) ? "remote" : "local"));

  if (!p_cb->is_le_device)
  {
  if (!p_cb->is_le_device) {
    /* inform role manager */
    bta_sys_conn_open(BTA_ID_HH, p_cb->app_id, p_cb->link_spec.addrt.bda);

@@ -1005,7 +1009,8 @@ void bta_hh_maint_dev_act(tBTA_HH_DEV_CB* p_cb, const tBTA_HH_DATA* p_data) {
      dev_info.link_spec = p_dev_info->link_spec;
      /* initialize callback data */
      if (p_cb->hid_handle == BTA_HH_INVALID_HANDLE) {
        if (BTM_UseLeLink(p_data->api_conn.link_spec.addrt.bda)) {
        if (BTM_UseLeLink(p_data->api_maintdev.link_spec.addrt.bda)) {
          p_cb->link_spec.transport = BT_TRANSPORT_LE;
          p_cb->is_le_device = true;
          dev_info.handle = bta_hh_le_add_device(p_cb, p_dev_info);
          if (dev_info.handle != BTA_HH_INVALID_HANDLE)
@@ -1049,8 +1054,7 @@ void bta_hh_maint_dev_act(tBTA_HH_DEV_CB* p_cb, const tBTA_HH_DATA* p_data) {
        bta_hh_le_remove_dev_bg_conn(p_cb);
        bta_hh_sm_execute(p_cb, BTA_HH_API_CLOSE_EVT, NULL);
        bta_hh_clean_up_kdev(p_cb);
      } else
      {
      } else {
        if (HID_HostRemoveDev(dev_info.handle) == HID_SUCCESS) {
          dev_info.status = BTA_HH_OK;

+4 −3
Original line number Diff line number Diff line
@@ -290,9 +290,10 @@ static tBTA_HH_DEV_CB* bta_hh_le_find_dev_cb_by_conn_id(uint16_t conn_id) {

/*******************************************************************************
 *
 * Function         bta_hh_le_find_dev_cb_by_bda
 * Function         bta_hh_le_find_dev_cb_by_addr_transport
 *
 * Description      Utility function find a device control block by BD address.
 * Description      Utility function find a device control block by ACL link
 *                  specification.
 *
 ******************************************************************************/
static tBTA_HH_DEV_CB* bta_hh_le_find_dev_cb_by_bda(
@@ -962,7 +963,7 @@ static void bta_hh_le_pri_service_discovery(tBTA_HH_DEV_CB* p_cb) {
 *
 ******************************************************************************/
static void bta_hh_le_encrypt_cback(const RawAddress* bd_addr,
                                    UNUSED_ATTR tBT_TRANSPORT transport,
                                    tBT_TRANSPORT transport,
                                    UNUSED_ATTR void* p_ref_data,
                                    tBTM_STATUS result) {
  tAclLinkSpec link_spec;
Loading