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

Commit fb2bb021 authored by Sonny Sasaka's avatar Sonny Sasaka
Browse files

floss: JNI: Change vector to byte array in gatt client

To make FFI between btif and Rust simpler, this changes vector to byte
array.

Bug: 193916778
Tag: #floss
Test: atest --host bluetooth_test_common

Change-Id: Ic56a273cd7613cc91a1ebe80064940d9da4bf381
parent a4b936a2
Loading
Loading
Loading
Loading
+7 −8
Original line number Original line Diff line number Diff line
@@ -1313,11 +1313,11 @@ static void gattClientWriteCharacteristicNative(JNIEnv* env, jobject object,
  jbyte* p_value = env->GetByteArrayElements(value, NULL);
  jbyte* p_value = env->GetByteArrayElements(value, NULL);
  if (p_value == NULL) return;
  if (p_value == NULL) return;


  std::vector<uint8_t> vect_val(p_value, p_value + len);
  env->ReleaseByteArrayElements(value, p_value, 0);

  sGattIf->client->write_characteristic(conn_id, handle, write_type, auth_req,
  sGattIf->client->write_characteristic(conn_id, handle, write_type, auth_req,
                                        std::move(vect_val));
                                        reinterpret_cast<uint8_t*>(p_value),
                                        len);

  env->ReleaseByteArrayElements(value, p_value, 0);
}
}


static void gattClientExecuteWriteNative(JNIEnv* env, jobject object,
static void gattClientExecuteWriteNative(JNIEnv* env, jobject object,
@@ -1340,11 +1340,10 @@ static void gattClientWriteDescriptorNative(JNIEnv* env, jobject object,
  jbyte* p_value = env->GetByteArrayElements(value, NULL);
  jbyte* p_value = env->GetByteArrayElements(value, NULL);
  if (p_value == NULL) return;
  if (p_value == NULL) return;


  std::vector<uint8_t> vect_val(p_value, p_value + len);
  env->ReleaseByteArrayElements(value, p_value, 0);

  sGattIf->client->write_descriptor(conn_id, handle, auth_req,
  sGattIf->client->write_descriptor(conn_id, handle, auth_req,
                                    std::move(vect_val));
                                    reinterpret_cast<uint8_t*>(p_value), len);

  env->ReleaseByteArrayElements(value, p_value, 0);
}
}


static void gattClientRegisterForNotificationsNative(
static void gattClientRegisterForNotificationsNative(