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

Commit 648a3fd5 authored by Sonny Sasaka's avatar Sonny Sasaka
Browse files

floss: Change vector to pointer in gatt btif

To simplify FFI between Rust and btif, this changes vector to byte array
in GATT Client.

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

Change-Id: I385bc99052056a346ba96c6e31ecfe4b338f18e2
parent 442b6940
Loading
Loading
Loading
Loading
+7 −3
Original line number Diff line number Diff line
@@ -490,9 +490,11 @@ void write_char_cb(uint16_t conn_id, tGATT_STATUS status, uint16_t handle,

static bt_status_t btif_gattc_write_char(int conn_id, uint16_t handle,
                                         int write_type, int auth_req,
                                         vector<uint8_t> value) {
                                         const uint8_t* val, size_t len) {
  CHECK_BTGATT_INIT();

  std::vector<uint8_t> value(val, val + len);

  if (value.size() > BTGATT_MAX_ATTR_LEN) value.resize(BTGATT_MAX_ATTR_LEN);

  return do_in_jni_thread(Bind(&BTA_GATTC_WriteCharValue, conn_id, handle,
@@ -506,10 +508,12 @@ void write_descr_cb(uint16_t conn_id, tGATT_STATUS status, uint16_t handle,
}

static bt_status_t btif_gattc_write_char_descr(int conn_id, uint16_t handle,
                                               int auth_req,
                                               vector<uint8_t> value) {
                                               int auth_req, const uint8_t* val,
                                               size_t len) {
  CHECK_BTGATT_INIT();

  std::vector<uint8_t> value(val, val + len);

  if (value.size() > BTGATT_MAX_ATTR_LEN) value.resize(BTGATT_MAX_ATTR_LEN);

  return do_in_jni_thread(Bind(&BTA_GATTC_WriteCharDescr, conn_id, handle,
+2 −3
Original line number Diff line number Diff line
@@ -18,7 +18,6 @@
#define ANDROID_INCLUDE_BT_GATT_CLIENT_H

#include <stdint.h>
#include <vector>
#include "bt_common_types.h"
#include "bt_gatt_types.h"

@@ -256,14 +255,14 @@ typedef struct {
  /** Write a remote characteristic */
  bt_status_t (*write_characteristic)(int conn_id, uint16_t handle,
                                      int write_type, int auth_req,
                                      std::vector<uint8_t> value);
                                      const uint8_t* value, size_t length);

  /** Read the descriptor for a given characteristic */
  bt_status_t (*read_descriptor)(int conn_id, uint16_t handle, int auth_req);

  /** Write a remote descriptor for a given characteristic */
  bt_status_t (*write_descriptor)(int conn_id, uint16_t handle, int auth_req,
                                  std::vector<uint8_t> value);
                                  const uint8_t* value, size_t length);

  /** Execute a prepared write operation */
  bt_status_t (*execute_write)(int conn_id, int execute);