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

Commit 416bec05 authored by Treehugger Robot's avatar Treehugger Robot Committed by Automerger Merge Worker
Browse files

Merge "gd HCI: Add check for static address" am: db614cbd

Change-Id: Ibee8672d33d7252b0ac69b2bd8f3e2c65e1beacb
parents 2281de40 db614cbd
Loading
Loading
Loading
Loading
+2 −3
Original line number Original line Diff line number Diff line
@@ -37,7 +37,7 @@ class LeAclManagerTest(GdBaseTestClass):
        private_policy = le_initiator_address_facade.PrivacyPolicy(
        private_policy = le_initiator_address_facade.PrivacyPolicy(
            address_policy=le_initiator_address_facade.AddressPolicy.USE_STATIC_ADDRESS,
            address_policy=le_initiator_address_facade.AddressPolicy.USE_STATIC_ADDRESS,
            address_with_type=common.BluetoothAddressWithType(
            address_with_type=common.BluetoothAddressWithType(
                address=common.BluetoothAddress(address=bytes(b'0D:05:04:03:02:01')),
                address=common.BluetoothAddress(address=bytes(b'D0:05:04:03:02:01')),
                type=common.RANDOM_DEVICE_ADDRESS),
                type=common.RANDOM_DEVICE_ADDRESS),
            rotation_irk=b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00',
            rotation_irk=b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00',
            minimum_rotation_time=(7 * 60 * 1000),
            minimum_rotation_time=(7 * 60 * 1000),
@@ -176,7 +176,6 @@ class LeAclManagerTest(GdBaseTestClass):
            gap_data = le_advertising_facade.GapDataMsg(data=bytes(gap_name.Serialize()))
            gap_data = le_advertising_facade.GapDataMsg(data=bytes(gap_name.Serialize()))
            config = le_advertising_facade.AdvertisingConfig(
            config = le_advertising_facade.AdvertisingConfig(
                advertisement=[gap_data],
                advertisement=[gap_data],
                random_address=common.BluetoothAddress(address=bytes(b'0D:05:04:03:02:01')),
                interval_min=512,
                interval_min=512,
                interval_max=768,
                interval_max=768,
                event_type=le_advertising_facade.AdvertisingEventType.ADV_IND,
                event_type=le_advertising_facade.AdvertisingEventType.ADV_IND,
@@ -204,7 +203,7 @@ class LeAclManagerTest(GdBaseTestClass):
                hci_packets.LeExtendedCreateConnectionBuilder(hci_packets.InitiatorFilterPolicy.USE_PEER_ADDRESS,
                hci_packets.LeExtendedCreateConnectionBuilder(hci_packets.InitiatorFilterPolicy.USE_PEER_ADDRESS,
                                                              hci_packets.OwnAddressType.RANDOM_DEVICE_ADDRESS,
                                                              hci_packets.OwnAddressType.RANDOM_DEVICE_ADDRESS,
                                                              hci_packets.AddressType.RANDOM_DEVICE_ADDRESS,
                                                              hci_packets.AddressType.RANDOM_DEVICE_ADDRESS,
                                                              '0D:05:04:03:02:01', 1, [phy_scan_params]), False)
                                                              'D0:05:04:03:02:01', 1, [phy_scan_params]), False)


            # Cert gets ConnectionComplete with a handle and sends ACL data
            # Cert gets ConnectionComplete with a handle and sends ACL data
            handle = 0xfff
            handle = 0xfff
+14 −3
Original line number Original line Diff line number Diff line
@@ -32,10 +32,21 @@ void LeAddressRotator::SetPrivacyPolicyForInitiatorAddress(AddressPolicy address
    case AddressPolicy::USE_PUBLIC_ADDRESS:
    case AddressPolicy::USE_PUBLIC_ADDRESS:
      le_address_ = fixed_address;
      le_address_ = fixed_address;
      break;
      break;
    case AddressPolicy::USE_STATIC_ADDRESS:
    case AddressPolicy::USE_STATIC_ADDRESS: {
      auto addr = fixed_address.GetAddress();
      auto address = addr.address;
      // The two most significant bits of the static address shall be equal to 1
      ASSERT_LOG((address[5] & BLE_ADDR_MASK) == BLE_ADDR_MASK, "The two most significant bits shall be equal to 1");
      // Bits of the random part of the address shall not be all 1 or all 0
      if ((address[0] == 0x00 && address[1] == 0x00 && address[2] == 0x00 && address[3] == 0x00 && address[4] == 0x00 &&
           address[5] == BLE_ADDR_MASK) ||
          (address[0] == 0xFF && address[1] == 0xFF && address[2] == 0xFF && address[3] == 0xFF && address[4] == 0xFF &&
           address[5] == 0xFF)) {
        LOG_ALWAYS_FATAL("Bits of the random part of the address shall not be all 1 or all 0");
      }
      le_address_ = fixed_address;
      le_address_ = fixed_address;
      handler_->Post(common::Bind(set_random_address_, le_address_.GetAddress()));
      handler_->Post(common::Bind(set_random_address_, le_address_.GetAddress()));
      break;
    } break;
    case AddressPolicy::USE_NON_RESOLVABLE_ADDRESS:
    case AddressPolicy::USE_NON_RESOLVABLE_ADDRESS:
    case AddressPolicy::USE_RESOLVABLE_ADDRESS:
    case AddressPolicy::USE_RESOLVABLE_ADDRESS:
      rotation_irk_ = rotation_irk;
      rotation_irk_ = rotation_irk;
@@ -43,7 +54,7 @@ void LeAddressRotator::SetPrivacyPolicyForInitiatorAddress(AddressPolicy address
      maximum_rotation_time_ = maximum_rotation_time;
      maximum_rotation_time_ = maximum_rotation_time;
      address_rotation_alarm_ = std::make_unique<os::Alarm>(handler_);
      address_rotation_alarm_ = std::make_unique<os::Alarm>(handler_);
      break;
      break;
    default:
    case AddressPolicy::POLICY_NOT_SET:
      LOG_ALWAYS_FATAL("invalid parameters");
      LOG_ALWAYS_FATAL("invalid parameters");
  }
  }
}
}
+2 −2
Original line number Original line Diff line number Diff line
@@ -50,9 +50,9 @@ class DualL2capTest(GdBaseTestClass):
        self.dut_le_l2cap = PyLeL2cap(self.dut)
        self.dut_le_l2cap = PyLeL2cap(self.dut)
        self.cert_le_l2cap = CertLeL2cap(self.cert)
        self.cert_le_l2cap = CertLeL2cap(self.cert)
        self.dut_le_address = common.BluetoothAddressWithType(
        self.dut_le_address = common.BluetoothAddressWithType(
            address=common.BluetoothAddress(address=bytes(b'0D:05:04:03:02:01')), type=common.RANDOM_DEVICE_ADDRESS)
            address=common.BluetoothAddress(address=bytes(b'D0:05:04:03:02:01')), type=common.RANDOM_DEVICE_ADDRESS)
        self.cert_address = common.BluetoothAddressWithType(
        self.cert_address = common.BluetoothAddressWithType(
            address=common.BluetoothAddress(address=bytes(b'55:11:FF:AA:33:22')), type=common.RANDOM_DEVICE_ADDRESS)
            address=common.BluetoothAddress(address=bytes(b'C0:11:FF:AA:33:22')), type=common.RANDOM_DEVICE_ADDRESS)
        dut_privacy_policy = le_initiator_address_facade.PrivacyPolicy(
        dut_privacy_policy = le_initiator_address_facade.PrivacyPolicy(
            address_policy=le_initiator_address_facade.AddressPolicy.USE_STATIC_ADDRESS,
            address_policy=le_initiator_address_facade.AddressPolicy.USE_STATIC_ADDRESS,
            address_with_type=self.dut_le_address,
            address_with_type=self.dut_le_address,
+2 −2
Original line number Original line Diff line number Diff line
@@ -44,9 +44,9 @@ class LeL2capTest(GdBaseTestClass):
        self.dut_l2cap = PyLeL2cap(self.dut)
        self.dut_l2cap = PyLeL2cap(self.dut)
        self.cert_l2cap = CertLeL2cap(self.cert)
        self.cert_l2cap = CertLeL2cap(self.cert)
        self.dut_address = common.BluetoothAddressWithType(
        self.dut_address = common.BluetoothAddressWithType(
            address=common.BluetoothAddress(address=bytes(b'0D:05:04:03:02:01')), type=common.RANDOM_DEVICE_ADDRESS)
            address=common.BluetoothAddress(address=bytes(b'D0:05:04:03:02:01')), type=common.RANDOM_DEVICE_ADDRESS)
        self.cert_address = common.BluetoothAddressWithType(
        self.cert_address = common.BluetoothAddressWithType(
            address=common.BluetoothAddress(address=bytes(b'55:11:FF:AA:33:22')), type=common.RANDOM_DEVICE_ADDRESS)
            address=common.BluetoothAddress(address=bytes(b'C0:11:FF:AA:33:22')), type=common.RANDOM_DEVICE_ADDRESS)
        dut_privacy_policy = le_initiator_address_facade.PrivacyPolicy(
        dut_privacy_policy = le_initiator_address_facade.PrivacyPolicy(
            address_policy=le_initiator_address_facade.AddressPolicy.USE_STATIC_ADDRESS,
            address_policy=le_initiator_address_facade.AddressPolicy.USE_STATIC_ADDRESS,
            address_with_type=self.dut_address,
            address_with_type=self.dut_address,