1 /* 2 * Copyright (C) 2021 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.google.uwb.support.fira; 18 19 import static java.util.Objects.requireNonNull; 20 21 import android.os.PersistableBundle; 22 import android.uwb.UwbManager; 23 24 import com.google.uwb.support.base.FlagEnum; 25 26 import java.util.ArrayList; 27 import java.util.Collection; 28 import java.util.EnumSet; 29 import java.util.List; 30 31 /** 32 * Defines parameters for FIRA capability. 33 * 34 * <p>This is returned as a bundle from the service API {@link UwbManager#getSpecificationInfo}. 35 */ 36 public class FiraSpecificationParams extends FiraParams { 37 private static final int BUNDLE_VERSION_1 = 1; 38 private static final int BUNDLE_VERSION_CURRENT = BUNDLE_VERSION_1; 39 40 private final FiraProtocolVersion mMinPhyVersionSupported; 41 private final FiraProtocolVersion mMaxPhyVersionSupported; 42 private final FiraProtocolVersion mMinMacVersionSupported; 43 private final FiraProtocolVersion mMaxMacVersionSupported; 44 45 private final List<Integer> mSupportedChannels; 46 47 private final EnumSet<AoaCapabilityFlag> mAoaCapabilities; 48 49 private final EnumSet<DeviceRoleCapabilityFlag> mDeviceRoleCapabilities; 50 51 private final boolean mHasBlockStridingSupport; 52 53 private final boolean mHasNonDeferredModeSupport; 54 55 private final boolean mHasInitiationTimeSupport; 56 57 private final EnumSet<MultiNodeCapabilityFlag> mMultiNodeCapabilities; 58 59 private final EnumSet<PrfCapabilityFlag> mPrfCapabilities; 60 61 private final EnumSet<RangingRoundCapabilityFlag> mRangingRoundCapabilities; 62 63 private final EnumSet<RframeCapabilityFlag> mRframeCapabilities; 64 65 private final EnumSet<StsCapabilityFlag> mStsCapabilities; 66 67 private final EnumSet<PsduDataRateCapabilityFlag> mPsduDataRateCapabilities; 68 69 private final EnumSet<BprfParameterSetCapabilityFlag> mBprfParameterSetCapabilities; 70 71 private final EnumSet<HprfParameterSetCapabilityFlag> mHprfParameterSetCapabilities; 72 73 private static final String KEY_MIN_PHY_VERSION = "min_phy_version"; 74 private static final String KEY_MAX_PHY_VERSION = "max_phy_version"; 75 private static final String KEY_MIN_MAC_VERSION = "min_mac_version"; 76 private static final String KEY_MAX_MAC_VERSION = "max_mac_version"; 77 78 private static final String KEY_SUPPORTED_CHANNELS = "channels"; 79 private static final String KEY_AOA_CAPABILITIES = "aoa_capabilities"; 80 private static final String KEY_DEVICE_ROLE_CAPABILITIES = "device_role_capabilities"; 81 private static final String KEY_BLOCK_STRIDING_SUPPORT = "block_striding"; 82 private static final String KEY_NON_DEFERRED_MODE_SUPPORT = "non_deferred_mode"; 83 private static final String KEY_INITIATION_TIME_SUPPORT = "initiation_time"; 84 private static final String KEY_MULTI_NODE_CAPABILITIES = "multi_node_capabilities"; 85 private static final String KEY_PRF_CAPABILITIES = "prf_capabilities"; 86 private static final String KEY_RANGING_ROUND_CAPABILITIES = "ranging_round_capabilities"; 87 private static final String KEY_RFRAME_CAPABILITIES = "rframe_capabilities"; 88 private static final String KEY_STS_CAPABILITIES = "sts_capabilities"; 89 private static final String KEY_PSDU_DATA_RATE_CAPABILITIES = "psdu_data_rate_capabilities"; 90 private static final String KEY_BPRF_PARAMETER_SET_CAPABILITIES = 91 "bprf_parameter_set_capabilities"; 92 private static final String KEY_HPRF_PARAMETER_SET_CAPABILITIES = 93 "hprf_parameter_set_capabilities"; 94 FiraSpecificationParams( FiraProtocolVersion minPhyVersionSupported, FiraProtocolVersion maxPhyVersionSupported, FiraProtocolVersion minMacVersionSupported, FiraProtocolVersion maxMacVersionSupported, List<Integer> supportedChannels, EnumSet<AoaCapabilityFlag> aoaCapabilities, EnumSet<DeviceRoleCapabilityFlag> deviceRoleCapabilities, boolean hasBlockStridingSupport, boolean hasNonDeferredModeSupport, boolean hasInitiationTimeSupport, EnumSet<MultiNodeCapabilityFlag> multiNodeCapabilities, EnumSet<PrfCapabilityFlag> prfCapabilities, EnumSet<RangingRoundCapabilityFlag> rangingRoundCapabilities, EnumSet<RframeCapabilityFlag> rframeCapabilities, EnumSet<StsCapabilityFlag> stsCapabilities, EnumSet<PsduDataRateCapabilityFlag> psduDataRateCapabilities, EnumSet<BprfParameterSetCapabilityFlag> bprfParameterSetCapabilities, EnumSet<HprfParameterSetCapabilityFlag> hprfParameterSetCapabilities)95 private FiraSpecificationParams( 96 FiraProtocolVersion minPhyVersionSupported, 97 FiraProtocolVersion maxPhyVersionSupported, 98 FiraProtocolVersion minMacVersionSupported, 99 FiraProtocolVersion maxMacVersionSupported, 100 List<Integer> supportedChannels, 101 EnumSet<AoaCapabilityFlag> aoaCapabilities, 102 EnumSet<DeviceRoleCapabilityFlag> deviceRoleCapabilities, 103 boolean hasBlockStridingSupport, 104 boolean hasNonDeferredModeSupport, 105 boolean hasInitiationTimeSupport, 106 EnumSet<MultiNodeCapabilityFlag> multiNodeCapabilities, 107 EnumSet<PrfCapabilityFlag> prfCapabilities, 108 EnumSet<RangingRoundCapabilityFlag> rangingRoundCapabilities, 109 EnumSet<RframeCapabilityFlag> rframeCapabilities, 110 EnumSet<StsCapabilityFlag> stsCapabilities, 111 EnumSet<PsduDataRateCapabilityFlag> psduDataRateCapabilities, 112 EnumSet<BprfParameterSetCapabilityFlag> bprfParameterSetCapabilities, 113 EnumSet<HprfParameterSetCapabilityFlag> hprfParameterSetCapabilities) { 114 mMinPhyVersionSupported = minPhyVersionSupported; 115 mMaxPhyVersionSupported = maxPhyVersionSupported; 116 mMinMacVersionSupported = minMacVersionSupported; 117 mMaxMacVersionSupported = maxMacVersionSupported; 118 mSupportedChannels = supportedChannels; 119 mAoaCapabilities = aoaCapabilities; 120 mDeviceRoleCapabilities = deviceRoleCapabilities; 121 mHasBlockStridingSupport = hasBlockStridingSupport; 122 mHasNonDeferredModeSupport = hasNonDeferredModeSupport; 123 mHasInitiationTimeSupport = hasInitiationTimeSupport; 124 mMultiNodeCapabilities = multiNodeCapabilities; 125 mPrfCapabilities = prfCapabilities; 126 mRangingRoundCapabilities = rangingRoundCapabilities; 127 mRframeCapabilities = rframeCapabilities; 128 mStsCapabilities = stsCapabilities; 129 mPsduDataRateCapabilities = psduDataRateCapabilities; 130 mBprfParameterSetCapabilities = bprfParameterSetCapabilities; 131 mHprfParameterSetCapabilities = hprfParameterSetCapabilities; 132 } 133 134 @Override getBundleVersion()135 protected int getBundleVersion() { 136 return BUNDLE_VERSION_CURRENT; 137 } 138 getMinPhyVersionSupported()139 public FiraProtocolVersion getMinPhyVersionSupported() { 140 return mMinPhyVersionSupported; 141 } 142 getMaxPhyVersionSupported()143 public FiraProtocolVersion getMaxPhyVersionSupported() { 144 return mMaxPhyVersionSupported; 145 } 146 getMinMacVersionSupported()147 public FiraProtocolVersion getMinMacVersionSupported() { 148 return mMinMacVersionSupported; 149 } 150 getMaxMacVersionSupported()151 public FiraProtocolVersion getMaxMacVersionSupported() { 152 return mMaxMacVersionSupported; 153 } 154 getSupportedChannels()155 public List<Integer> getSupportedChannels() { 156 return mSupportedChannels; 157 } 158 getAoaCapabilities()159 public EnumSet<AoaCapabilityFlag> getAoaCapabilities() { 160 return mAoaCapabilities; 161 } 162 getDeviceRoleCapabilities()163 public EnumSet<DeviceRoleCapabilityFlag> getDeviceRoleCapabilities() { 164 return mDeviceRoleCapabilities; 165 } 166 hasBlockStridingSupport()167 public boolean hasBlockStridingSupport() { 168 return mHasBlockStridingSupport; 169 } 170 hasNonDeferredModeSupport()171 public boolean hasNonDeferredModeSupport() { 172 return mHasNonDeferredModeSupport; 173 } 174 hasInitiationTimeSupport()175 public boolean hasInitiationTimeSupport() { 176 return mHasInitiationTimeSupport; 177 } 178 getMultiNodeCapabilities()179 public EnumSet<MultiNodeCapabilityFlag> getMultiNodeCapabilities() { 180 return mMultiNodeCapabilities; 181 } 182 getPrfCapabilities()183 public EnumSet<PrfCapabilityFlag> getPrfCapabilities() { 184 return mPrfCapabilities; 185 } 186 getRangingRoundCapabilities()187 public EnumSet<RangingRoundCapabilityFlag> getRangingRoundCapabilities() { 188 return mRangingRoundCapabilities; 189 } 190 getRframeCapabilities()191 public EnumSet<RframeCapabilityFlag> getRframeCapabilities() { 192 return mRframeCapabilities; 193 } 194 getStsCapabilities()195 public EnumSet<StsCapabilityFlag> getStsCapabilities() { 196 return mStsCapabilities; 197 } 198 getPsduDataRateCapabilities()199 public EnumSet<PsduDataRateCapabilityFlag> getPsduDataRateCapabilities() { 200 return mPsduDataRateCapabilities; 201 } 202 getBprfParameterSetCapabilities()203 public EnumSet<BprfParameterSetCapabilityFlag> getBprfParameterSetCapabilities() { 204 return mBprfParameterSetCapabilities; 205 } 206 getHprfParameterSetCapabilities()207 public EnumSet<HprfParameterSetCapabilityFlag> getHprfParameterSetCapabilities() { 208 return mHprfParameterSetCapabilities; 209 } 210 toIntArray(List<Integer> data)211 private static int[] toIntArray(List<Integer> data) { 212 int[] res = new int[data.size()]; 213 for (int i = 0; i < data.size(); i++) { 214 res[i] = data.get(i); 215 } 216 return res; 217 } 218 219 @Override toBundle()220 public PersistableBundle toBundle() { 221 PersistableBundle bundle = super.toBundle(); 222 bundle.putString(KEY_MIN_PHY_VERSION, mMinPhyVersionSupported.toString()); 223 bundle.putString(KEY_MAX_PHY_VERSION, mMaxPhyVersionSupported.toString()); 224 bundle.putString(KEY_MIN_MAC_VERSION, mMinMacVersionSupported.toString()); 225 bundle.putString(KEY_MAX_MAC_VERSION, mMaxMacVersionSupported.toString()); 226 bundle.putIntArray(KEY_SUPPORTED_CHANNELS, toIntArray(mSupportedChannels)); 227 bundle.putInt(KEY_AOA_CAPABILITIES, FlagEnum.toInt(mAoaCapabilities)); 228 bundle.putInt(KEY_DEVICE_ROLE_CAPABILITIES, FlagEnum.toInt(mDeviceRoleCapabilities)); 229 bundle.putBoolean(KEY_BLOCK_STRIDING_SUPPORT, mHasBlockStridingSupport); 230 bundle.putBoolean(KEY_NON_DEFERRED_MODE_SUPPORT, mHasNonDeferredModeSupport); 231 bundle.putBoolean(KEY_INITIATION_TIME_SUPPORT, mHasInitiationTimeSupport); 232 bundle.putInt(KEY_MULTI_NODE_CAPABILITIES, FlagEnum.toInt(mMultiNodeCapabilities)); 233 bundle.putInt(KEY_PRF_CAPABILITIES, FlagEnum.toInt(mPrfCapabilities)); 234 bundle.putInt(KEY_RANGING_ROUND_CAPABILITIES, FlagEnum.toInt(mRangingRoundCapabilities)); 235 bundle.putInt(KEY_RFRAME_CAPABILITIES, FlagEnum.toInt(mRframeCapabilities)); 236 bundle.putInt(KEY_STS_CAPABILITIES, FlagEnum.toInt(mStsCapabilities)); 237 bundle.putInt(KEY_PSDU_DATA_RATE_CAPABILITIES, FlagEnum.toInt(mPsduDataRateCapabilities)); 238 bundle.putInt(KEY_BPRF_PARAMETER_SET_CAPABILITIES, 239 FlagEnum.toInt(mBprfParameterSetCapabilities)); 240 bundle.putLong(KEY_HPRF_PARAMETER_SET_CAPABILITIES, 241 FlagEnum.toLong(mHprfParameterSetCapabilities)); 242 return bundle; 243 } 244 fromBundle(PersistableBundle bundle)245 public static FiraSpecificationParams fromBundle(PersistableBundle bundle) { 246 if (!isCorrectProtocol(bundle)) { 247 throw new IllegalArgumentException("Invalid protocol"); 248 } 249 250 switch (getBundleVersion(bundle)) { 251 case BUNDLE_VERSION_1: 252 return parseVersion1(bundle); 253 254 default: 255 throw new IllegalArgumentException("Invalid bundle version"); 256 } 257 } 258 toIntList(int[] data)259 private static List<Integer> toIntList(int[] data) { 260 List<Integer> res = new ArrayList<>(); 261 for (int datum : data) { 262 res.add(datum); 263 } 264 return res; 265 } 266 parseVersion1(PersistableBundle bundle)267 private static FiraSpecificationParams parseVersion1(PersistableBundle bundle) { 268 FiraSpecificationParams.Builder builder = new FiraSpecificationParams.Builder(); 269 List<Integer> supportedChannels = 270 toIntList(requireNonNull(bundle.getIntArray(KEY_SUPPORTED_CHANNELS))); 271 return builder.setMinPhyVersionSupported( 272 FiraProtocolVersion.fromString(bundle.getString(KEY_MIN_PHY_VERSION))) 273 .setMaxPhyVersionSupported( 274 FiraProtocolVersion.fromString(bundle.getString(KEY_MAX_PHY_VERSION))) 275 .setMinMacVersionSupported( 276 FiraProtocolVersion.fromString(bundle.getString(KEY_MIN_MAC_VERSION))) 277 .setMaxMacVersionSupported( 278 FiraProtocolVersion.fromString(bundle.getString(KEY_MAX_MAC_VERSION))) 279 .setSupportedChannels(supportedChannels) 280 .setAoaCapabilities( 281 FlagEnum.toEnumSet( 282 bundle.getInt(KEY_AOA_CAPABILITIES), AoaCapabilityFlag.values())) 283 .setDeviceRoleCapabilities( 284 FlagEnum.toEnumSet( 285 bundle.getInt(KEY_DEVICE_ROLE_CAPABILITIES), 286 DeviceRoleCapabilityFlag.values())) 287 .hasBlockStridingSupport(bundle.getBoolean(KEY_BLOCK_STRIDING_SUPPORT)) 288 .hasNonDeferredModeSupport(bundle.getBoolean(KEY_NON_DEFERRED_MODE_SUPPORT)) 289 .hasInitiationTimeSupport(bundle.getBoolean(KEY_INITIATION_TIME_SUPPORT)) 290 .setMultiNodeCapabilities( 291 FlagEnum.toEnumSet( 292 bundle.getInt(KEY_MULTI_NODE_CAPABILITIES), 293 MultiNodeCapabilityFlag.values())) 294 .setPrfCapabilities( 295 FlagEnum.toEnumSet( 296 bundle.getInt(KEY_PRF_CAPABILITIES), PrfCapabilityFlag.values())) 297 .setRangingRoundCapabilities( 298 FlagEnum.toEnumSet( 299 bundle.getInt(KEY_RANGING_ROUND_CAPABILITIES), 300 RangingRoundCapabilityFlag.values())) 301 .setRframeCapabilities( 302 FlagEnum.toEnumSet( 303 bundle.getInt(KEY_RFRAME_CAPABILITIES), 304 RframeCapabilityFlag.values())) 305 .setStsCapabilities( 306 FlagEnum.toEnumSet( 307 bundle.getInt(KEY_STS_CAPABILITIES), StsCapabilityFlag.values())) 308 .setPsduDataRateCapabilities( 309 FlagEnum.toEnumSet( 310 bundle.getInt(KEY_PSDU_DATA_RATE_CAPABILITIES), 311 PsduDataRateCapabilityFlag.values())) 312 .setBprfParameterSetCapabilities( 313 FlagEnum.toEnumSet( 314 bundle.getInt(KEY_BPRF_PARAMETER_SET_CAPABILITIES), 315 BprfParameterSetCapabilityFlag.values())) 316 .setHprfParameterSetCapabilities( 317 FlagEnum.longToEnumSet( 318 bundle.getLong(KEY_HPRF_PARAMETER_SET_CAPABILITIES), 319 HprfParameterSetCapabilityFlag.values())) 320 .build(); 321 } 322 323 /** Builder */ 324 public static class Builder { 325 // Set all default protocol version to FiRa 1.1 326 private FiraProtocolVersion mMinPhyVersionSupported = new FiraProtocolVersion(1, 1); 327 private FiraProtocolVersion mMaxPhyVersionSupported = new FiraProtocolVersion(1, 1); 328 private FiraProtocolVersion mMinMacVersionSupported = new FiraProtocolVersion(1, 1); 329 private FiraProtocolVersion mMaxMacVersionSupported = new FiraProtocolVersion(1, 1); 330 331 private List<Integer> mSupportedChannels; 332 333 private final EnumSet<AoaCapabilityFlag> mAoaCapabilities = 334 EnumSet.noneOf(AoaCapabilityFlag.class); 335 336 // Controller-intiator, Cotrolee-responder are mandatory. 337 private final EnumSet<DeviceRoleCapabilityFlag> mDeviceRoleCapabilities = 338 EnumSet.of( 339 DeviceRoleCapabilityFlag.HAS_CONTROLLER_INITIATOR_SUPPORT, 340 DeviceRoleCapabilityFlag.HAS_CONTROLEE_RESPONDER_SUPPORT); 341 342 private boolean mHasBlockStridingSupport = false; 343 344 private boolean mHasNonDeferredModeSupport = false; 345 346 private boolean mHasInitiationTimeSupport = false; 347 348 // Unicast support is mandatory 349 private final EnumSet<MultiNodeCapabilityFlag> mMultiNodeCapabilities = 350 EnumSet.of(MultiNodeCapabilityFlag.HAS_UNICAST_SUPPORT); 351 352 // BPRF mode is mandatory 353 private final EnumSet<PrfCapabilityFlag> mPrfCapabilities = 354 EnumSet.of(PrfCapabilityFlag.HAS_BPRF_SUPPORT); 355 356 // DS-TWR is mandatory 357 private final EnumSet<RangingRoundCapabilityFlag> mRangingRoundCapabilities = 358 EnumSet.of(RangingRoundCapabilityFlag.HAS_DS_TWR_SUPPORT); 359 360 // SP3 RFrame is mandatory 361 private final EnumSet<RframeCapabilityFlag> mRframeCapabilities = 362 EnumSet.of(RframeCapabilityFlag.HAS_SP3_RFRAME_SUPPORT); 363 364 // STATIC STS is mandatory 365 private final EnumSet<StsCapabilityFlag> mStsCapabilities = 366 EnumSet.of(StsCapabilityFlag.HAS_STATIC_STS_SUPPORT); 367 368 // 6.81Mb/s PSDU data rate is mandatory 369 private final EnumSet<PsduDataRateCapabilityFlag> mPsduDataRateCapabilities = 370 EnumSet.of(PsduDataRateCapabilityFlag.HAS_6M81_SUPPORT); 371 372 private final EnumSet<BprfParameterSetCapabilityFlag> mBprfParameterSetCapabilities = 373 EnumSet.noneOf(BprfParameterSetCapabilityFlag.class); 374 375 private final EnumSet<HprfParameterSetCapabilityFlag> mHprfParameterSetCapabilities = 376 EnumSet.noneOf(HprfParameterSetCapabilityFlag.class); 377 setMinPhyVersionSupported( FiraProtocolVersion version)378 public FiraSpecificationParams.Builder setMinPhyVersionSupported( 379 FiraProtocolVersion version) { 380 mMinPhyVersionSupported = version; 381 return this; 382 } 383 setMaxPhyVersionSupported( FiraProtocolVersion version)384 public FiraSpecificationParams.Builder setMaxPhyVersionSupported( 385 FiraProtocolVersion version) { 386 mMaxPhyVersionSupported = version; 387 return this; 388 } 389 setMinMacVersionSupported( FiraProtocolVersion version)390 public FiraSpecificationParams.Builder setMinMacVersionSupported( 391 FiraProtocolVersion version) { 392 mMinMacVersionSupported = version; 393 return this; 394 } 395 setMaxMacVersionSupported( FiraProtocolVersion version)396 public FiraSpecificationParams.Builder setMaxMacVersionSupported( 397 FiraProtocolVersion version) { 398 mMaxMacVersionSupported = version; 399 return this; 400 } 401 setSupportedChannels( List<Integer> supportedChannels)402 public FiraSpecificationParams.Builder setSupportedChannels( 403 List<Integer> supportedChannels) { 404 mSupportedChannels = List.copyOf(supportedChannels); 405 return this; 406 } 407 setAoaCapabilities( Collection<AoaCapabilityFlag> aoaCapabilities)408 public FiraSpecificationParams.Builder setAoaCapabilities( 409 Collection<AoaCapabilityFlag> aoaCapabilities) { 410 mAoaCapabilities.addAll(aoaCapabilities); 411 return this; 412 } 413 setDeviceRoleCapabilities( Collection<DeviceRoleCapabilityFlag> deviceRoleCapabilities)414 public FiraSpecificationParams.Builder setDeviceRoleCapabilities( 415 Collection<DeviceRoleCapabilityFlag> deviceRoleCapabilities) { 416 mDeviceRoleCapabilities.addAll(deviceRoleCapabilities); 417 return this; 418 } 419 hasBlockStridingSupport(boolean value)420 public FiraSpecificationParams.Builder hasBlockStridingSupport(boolean value) { 421 mHasBlockStridingSupport = value; 422 return this; 423 } 424 hasNonDeferredModeSupport(boolean value)425 public FiraSpecificationParams.Builder hasNonDeferredModeSupport(boolean value) { 426 mHasNonDeferredModeSupport = value; 427 return this; 428 } 429 hasInitiationTimeSupport(boolean value)430 public FiraSpecificationParams.Builder hasInitiationTimeSupport(boolean value) { 431 mHasInitiationTimeSupport = value; 432 return this; 433 } 434 setMultiNodeCapabilities( Collection<MultiNodeCapabilityFlag> multiNodeCapabilities)435 public FiraSpecificationParams.Builder setMultiNodeCapabilities( 436 Collection<MultiNodeCapabilityFlag> multiNodeCapabilities) { 437 mMultiNodeCapabilities.addAll(multiNodeCapabilities); 438 return this; 439 } 440 setPrfCapabilities( Collection<PrfCapabilityFlag> prfCapabilities)441 public FiraSpecificationParams.Builder setPrfCapabilities( 442 Collection<PrfCapabilityFlag> prfCapabilities) { 443 mPrfCapabilities.addAll(prfCapabilities); 444 return this; 445 } 446 setRangingRoundCapabilities( Collection<RangingRoundCapabilityFlag> rangingRoundCapabilities)447 public FiraSpecificationParams.Builder setRangingRoundCapabilities( 448 Collection<RangingRoundCapabilityFlag> rangingRoundCapabilities) { 449 mRangingRoundCapabilities.addAll(rangingRoundCapabilities); 450 return this; 451 } 452 setRframeCapabilities( Collection<RframeCapabilityFlag> rframeCapabilities)453 public FiraSpecificationParams.Builder setRframeCapabilities( 454 Collection<RframeCapabilityFlag> rframeCapabilities) { 455 mRframeCapabilities.addAll(rframeCapabilities); 456 return this; 457 } 458 setStsCapabilities( Collection<StsCapabilityFlag> stsCapabilities)459 public FiraSpecificationParams.Builder setStsCapabilities( 460 Collection<StsCapabilityFlag> stsCapabilities) { 461 mStsCapabilities.addAll(stsCapabilities); 462 return this; 463 } 464 setPsduDataRateCapabilities( Collection<PsduDataRateCapabilityFlag> psduDataRateCapabilities)465 public FiraSpecificationParams.Builder setPsduDataRateCapabilities( 466 Collection<PsduDataRateCapabilityFlag> psduDataRateCapabilities) { 467 mPsduDataRateCapabilities.addAll(psduDataRateCapabilities); 468 return this; 469 } 470 setBprfParameterSetCapabilities( Collection<BprfParameterSetCapabilityFlag> bprfParameterSetCapabilities)471 public FiraSpecificationParams.Builder setBprfParameterSetCapabilities( 472 Collection<BprfParameterSetCapabilityFlag> bprfParameterSetCapabilities) { 473 mBprfParameterSetCapabilities.addAll(bprfParameterSetCapabilities); 474 return this; 475 } 476 setHprfParameterSetCapabilities( Collection<HprfParameterSetCapabilityFlag> hprfParameterSetCapabilities)477 public FiraSpecificationParams.Builder setHprfParameterSetCapabilities( 478 Collection<HprfParameterSetCapabilityFlag> hprfParameterSetCapabilities) { 479 mHprfParameterSetCapabilities.addAll(hprfParameterSetCapabilities); 480 return this; 481 } 482 build()483 public FiraSpecificationParams build() { 484 if (mSupportedChannels == null || mSupportedChannels.size() == 0) { 485 throw new IllegalStateException("Supported channels are not set"); 486 } 487 488 return new FiraSpecificationParams( 489 mMinPhyVersionSupported, 490 mMaxPhyVersionSupported, 491 mMinMacVersionSupported, 492 mMaxMacVersionSupported, 493 mSupportedChannels, 494 mAoaCapabilities, 495 mDeviceRoleCapabilities, 496 mHasBlockStridingSupport, 497 mHasNonDeferredModeSupport, 498 mHasInitiationTimeSupport, 499 mMultiNodeCapabilities, 500 mPrfCapabilities, 501 mRangingRoundCapabilities, 502 mRframeCapabilities, 503 mStsCapabilities, 504 mPsduDataRateCapabilities, 505 mBprfParameterSetCapabilities, 506 mHprfParameterSetCapabilities); 507 } 508 } 509 } 510