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

Commit b17a08f3 authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

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

parents fa45c9f1 659b657f
Loading
Loading
Loading
Loading
+9 −3
Original line number Original line Diff line number Diff line
@@ -444,12 +444,18 @@ static jboolean unplugNative(JNIEnv* env, jobject thiz) {
  return result;
  return result;
}
}


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


  jboolean result = JNI_FALSE;
  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);
  ALOGV("%s: connect() returned %d", __FUNCTION__, ret);


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


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


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


  synchronized boolean disconnect(BluetoothDevice 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 sendReportNative(int id, byte[] data);
  private native boolean replyReportNative(byte type, byte id, byte[] data);
  private native boolean replyReportNative(byte type, byte id, byte[] data);
  private native boolean unplugNative();
  private native boolean unplugNative();
  private native boolean connectNative();
  private native boolean connectNative(byte[] btAddress);
  private native boolean disconnectNative();
  private native boolean disconnectNative();
  private native boolean reportErrorNative(byte error);
  private native boolean reportErrorNative(byte error);
}
}