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

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

Merge changes I73f0fb18,Ia5640c02,I51550c1b,I51da3a2c,I9139c5e6

* changes:
  Use correct address type based on address policy
  Rename LeAddressManager#GetCurrentAddress()
  Add support for NRPAs in advertisement sets
  Add RotatingAddress() method to le_address_manager
  Use dedicated enum for Advertiser Address Type
parents 53150399 877a2276
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -972,6 +972,7 @@ package android.bluetooth.le {
    field public static final int ADDRESS_TYPE_DEFAULT = -1; // 0xffffffff
    field public static final int ADDRESS_TYPE_PUBLIC = 0; // 0x0
    field public static final int ADDRESS_TYPE_RANDOM = 1; // 0x1
    field public static final int ADDRESS_TYPE_RANDOM_NON_RESOLVABLE = 2; // 0x2
  }

  public static final class AdvertisingSetParameters.Builder {
+2 −1
Original line number Diff line number Diff line
@@ -285,7 +285,8 @@ public final class AdvertiseSettings implements Parcelable {
        @SystemApi
        public @NonNull Builder setOwnAddressType(@AddressTypeStatus int ownAddressType) {
            if (ownAddressType < AdvertisingSetParameters.ADDRESS_TYPE_DEFAULT
                    ||  ownAddressType > AdvertisingSetParameters.ADDRESS_TYPE_RANDOM) {
                    || ownAddressType
                            > AdvertisingSetParameters.ADDRESS_TYPE_RANDOM_NON_RESOLVABLE) {
                throw new IllegalArgumentException("unknown address type " + ownAddressType);
            }
            mOwnAddressType = ownAddressType;
+12 −2
Original line number Diff line number Diff line
@@ -107,7 +107,8 @@ public final class AdvertisingSetParameters implements Parcelable {
    @IntDef(prefix = "ADDRESS_TYPE_", value = {
        ADDRESS_TYPE_DEFAULT,
        ADDRESS_TYPE_PUBLIC,
        ADDRESS_TYPE_RANDOM
        ADDRESS_TYPE_RANDOM,
        ADDRESS_TYPE_RANDOM_NON_RESOLVABLE,
    })
    @Retention(RetentionPolicy.SOURCE)
    public @interface AddressTypeStatus {}
@@ -136,6 +137,14 @@ public final class AdvertisingSetParameters implements Parcelable {
    @SystemApi
    public static final int ADDRESS_TYPE_RANDOM = 1;

    /**
     * Generate and advertise on non-resolvable private address.
     *
     * @hide
     */
    @SystemApi
    public static final int ADDRESS_TYPE_RANDOM_NON_RESOLVABLE = 2;

    private final boolean mIsLegacy;
    private final boolean mIsAnonymous;
    private final boolean mIncludeTxPower;
@@ -500,7 +509,8 @@ public final class AdvertisingSetParameters implements Parcelable {
        @SystemApi
        public @NonNull Builder setOwnAddressType(@AddressTypeStatus int ownAddressType) {
            if (ownAddressType < AdvertisingSetParameters.ADDRESS_TYPE_DEFAULT
                    ||  ownAddressType > AdvertisingSetParameters.ADDRESS_TYPE_RANDOM) {
                    || ownAddressType
                            > AdvertisingSetParameters.ADDRESS_TYPE_RANDOM_NON_RESOLVABLE) {
                throw new IllegalArgumentException("unknown address type " + ownAddressType);
            }
            mOwnAddressType = ownAddressType;
+1 −1
Original line number Diff line number Diff line
@@ -8,7 +8,7 @@ import "blueberry/facade/common.proto";
service LeInitiatorAddressFacade {
  rpc SetPrivacyPolicyForInitiatorAddress(PrivacyPolicy) returns (google.protobuf.Empty) {}
  rpc GetCurrentInitiatorAddress(google.protobuf.Empty) returns (blueberry.facade.BluetoothAddressWithType) {}
  rpc GetAnotherAddress(google.protobuf.Empty) returns (blueberry.facade.BluetoothAddressWithType) {}
  rpc NewResolvableAddress(google.protobuf.Empty) returns (blueberry.facade.BluetoothAddressWithType) {}
}

enum AddressPolicy {
+4 −4
Original line number Diff line number Diff line
@@ -338,7 +338,7 @@ struct le_impl : public bluetooth::hci::LeAddressManagerCallback {
    auto peer_address_type = connection_complete.GetPeerAddressType();
    auto role = connection_complete.GetRole();
    AddressWithType remote_address(address, peer_address_type);
    AddressWithType local_address = le_address_manager_->GetCurrentAddress();
    AddressWithType local_address = le_address_manager_->GetInitiatorAddress();
    const bool in_filter_accept_list = is_device_in_connect_list(remote_address);

    if (role == hci::Role::CENTRAL) {
@@ -612,7 +612,7 @@ struct le_impl : public bluetooth::hci::LeAddressManagerCallback {

  RoleSpecificData initialize_role_specific_data(Role role) {
    if (role == hci::Role::CENTRAL) {
      return DataAsCentral{le_address_manager_->GetCurrentAddress()};
      return DataAsCentral{le_address_manager_->GetInitiatorAddress()};
    } else if (
        controller_->SupportsBleExtendedAdvertising() ||
        controller_->IsSupported(hci::OpCode::LE_MULTI_ADVT)) {
@@ -624,7 +624,7 @@ struct le_impl : public bluetooth::hci::LeAddressManagerCallback {
      // the exception is if we only support legacy advertising - here, our current address is also
      // our advertised address
      return DataAsPeripheral{
          le_address_manager_->GetCurrentAddress(),
          le_address_manager_->GetInitiatorAddress(),
          {},
          true /* For now, ignore non-discoverable legacy advertising TODO(b/254314964) */};
    }
@@ -889,7 +889,7 @@ struct le_impl : public bluetooth::hci::LeAddressManagerCallback {
    }
    InitiatorFilterPolicy initiator_filter_policy = InitiatorFilterPolicy::USE_FILTER_ACCEPT_LIST;
    OwnAddressType own_address_type =
        static_cast<OwnAddressType>(le_address_manager_->GetCurrentAddress().GetAddressType());
        static_cast<OwnAddressType>(le_address_manager_->GetInitiatorAddress().GetAddressType());
    uint16_t conn_interval_min = os::GetSystemPropertyUint32(kPropertyMinConnInterval, kConnIntervalMin);
    uint16_t conn_interval_max = os::GetSystemPropertyUint32(kPropertyMaxConnInterval, kConnIntervalMax);
    uint16_t conn_latency = os::GetSystemPropertyUint32(kPropertyConnLatency, kConnLatency);
Loading