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

Commit 54a9d882 authored by android-build-team Robot's avatar android-build-team Robot
Browse files

Merge cherrypicks of [7077329, 7077440, 7077330, 7077468, 7076852, 7077469,...

Merge cherrypicks of [7077329, 7077440, 7077330, 7077468, 7076852, 7077469, 7077580, 7077581, 7077582, 7074025, 7077706, 7077707, 7077708, 7077388, 7077583, 7077584, 7077585, 7077726, 7077727, 7077331, 7077332, 7077459, 7077709, 7077710, 7077711, 7077712, 7077460, 7077461, 7077333, 7077334, 7077696] into pi-qpr3-release

Change-Id: I2136d4f180dc2e9efb6030ea13539c51fb1adc61
parents ef1e0371 6c0477bf
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -127,6 +127,7 @@ cc_test {
        "libprotobuf-cpp-lite",
        "libcutils",
        "libutils",
        "libstatslog",
    ],
    static_libs: [
        "libbt-bta",
+42 −0
Original line number Diff line number Diff line
@@ -35,6 +35,7 @@
#include <alloca.h>
#include <base/logging.h>
#include <ctype.h>
#include <log/log.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
@@ -794,6 +795,45 @@ bt_status_t btif_storage_remove_bonded_device(
  return ret ? BT_STATUS_SUCCESS : BT_STATUS_FAIL;
}

/* Some devices hardcode sample LTK value from spec, instead of generating one.
 * Treat such devices as insecure, and remove such bonds when bluetooth
 * restarts. Removing them after disconnection is handled separately.
 *
 * We still allow such devices to bond in order to give the user a chance to
 * update firmware.
 */
static void remove_devices_with_sample_ltk() {
  std::vector<RawAddress> bad_ltk;
  for (const section_t& section : btif_config_sections()) {
    const std::string& name = section.name;
    if (!RawAddress::IsValidAddress(name)) {
      continue;
    }

    RawAddress bd_addr;
    RawAddress::FromString(name, bd_addr);

    tBTA_LE_KEY_VALUE key;
    memset(&key, 0, sizeof(key));

    if (btif_storage_get_ble_bonding_key(
            &bd_addr, BTIF_DM_LE_KEY_PENC, (uint8_t*)&key,
            sizeof(tBTM_LE_PENC_KEYS)) == BT_STATUS_SUCCESS) {
      if (is_sample_ltk(key.penc_key.ltk)) {
        bad_ltk.push_back(bd_addr);
      }
    }
  }

  for (RawAddress address : bad_ltk) {
    android_errorWriteLog(0x534e4554, "128437297");
    LOG(ERROR) << __func__
               << ": removing bond to device using test TLK: " << address;

    btif_storage_remove_bonded_device(&address);
  }
}

/*******************************************************************************
 *
 * Function         btif_storage_load_bonded_devices
@@ -821,6 +861,8 @@ bt_status_t btif_storage_load_bonded_devices(void) {
  Uuid remote_uuids[BT_MAX_NUM_UUIDS];
  bt_status_t status;

  remove_devices_with_sample_ltk();

  btif_in_fetch_bonded_devices(&bonded_devices, 1);

  /* Now send the adapter_properties_cb with all adapter_properties */
+4 −0
Original line number Diff line number Diff line
@@ -264,6 +264,10 @@ static future_t* start_up(void) {
        response, &number_of_local_supported_codecs, local_supported_codecs);
  }

  if (!HCI_READ_ENCR_KEY_SIZE_SUPPORTED(supported_commands)) {
    LOG(FATAL) << " Controller must support Read Encryption Key Size command";
  }

  readable = true;
  return future_new_immediate(FUTURE_SUCCESS);
}
+1 −0
Original line number Diff line number Diff line
@@ -51,6 +51,7 @@ cc_library_shared {
        "libutils",
        "libtinyxml2",
        "libz",
        "libstatslog",
    ],
    static_libs: [
        "libbt-sbc-decoder",
+1 −0
Original line number Diff line number Diff line
@@ -178,6 +178,7 @@ cc_library_static {
    shared_libs: [
        "libcutils",
        "liblog",
        "libstatslog",
    ],
    required: [
        "libldacBT_enc",
Loading