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

Commit 510c18d8 authored by Ivan Podogov's avatar Ivan Podogov Committed by android-build-merger
Browse files

Merge "Allow HID Device to connect to a specific device"

am: b17a08f3

Change-Id: Ic431301bdc4424613f6bb9aaa0e8f95fe7cb4e49
parents 7f05f328 b17a08f3
Loading
Loading
Loading
Loading
+9 −3
Original line number Diff line number Diff line
@@ -444,12 +444,18 @@ static jboolean unplugNative(JNIEnv* env, jobject thiz) {
  return result;
}

static jboolean connectNative(JNIEnv* env, jobject thiz) {
static jboolean connectNative(JNIEnv* env, jobject thiz, jbyteArray address) {
  ALOGV("%s enter", __FUNCTION__);

  jboolean result = JNI_FALSE;

  bt_status_t ret = sHiddIf->connect();
  jbyte* addr = env->GetByteArrayElements(address, NULL);
  if (!addr) {
    ALOGE("Bluetooth device address null");
    return JNI_FALSE;
  }

  bt_status_t ret = sHiddIf->connect((bt_bdaddr_t*)addr);

  ALOGV("%s: connect() returned %d", __FUNCTION__, ret);

@@ -492,7 +498,7 @@ static JNINativeMethod sMethods[] = {
    {"replyReportNative", "(BB[B)Z", (void*)replyReportNative},
    {"reportErrorNative", "(B)Z", (void*)reportErrorNative},
    {"unplugNative", "()Z", (void*)unplugNative},
    {"connectNative", "()Z", (void*)connectNative},
    {"connectNative", "([B)Z", (void*)connectNative},
    {"disconnectNative", "()Z", (void*)disconnectNative},
};

+2 −2
Original line number Diff line number Diff line
@@ -478,7 +478,7 @@ public class HidDevService extends ProfileService {
  synchronized boolean connect(BluetoothDevice device) {
      if (DBG) Log.v(TAG, "connect(): device=" + device);

      return connectNative();
      return connectNative(Utils.getByteAddress(device));
  }

  synchronized boolean disconnect(BluetoothDevice device) {
@@ -696,7 +696,7 @@ public class HidDevService extends ProfileService {
  private native boolean sendReportNative(int id, byte[] data);
  private native boolean replyReportNative(byte type, byte id, byte[] data);
  private native boolean unplugNative();
  private native boolean connectNative();
  private native boolean connectNative(byte[] btAddress);
  private native boolean disconnectNative();
  private native boolean reportErrorNative(byte error);
}