diff options
author | Jakub Pawlowski <jpawlowski@google.com> | 2017-04-12 08:51:22 -0700 |
---|---|---|
committer | Jakub Pawlowski <jpawlowski@google.com> | 2017-04-12 10:57:03 -0700 |
commit | 9582b46a4b3b91c36295c9d771a9d5cc07fb10e8 (patch) | |
tree | 079c4b4b1416aeed49d0c90409cf39b76f1c9f6e /framework/java/android/bluetooth/le/AdvertisingSetParameters.java | |
parent | 6acf2c8b4bee0aec004bc3dcf8643f4d9bb09a82 (diff) |
Bluetooth 5 PHY simplification
Having PHY_LE_* constants defined in four different places, with one
value being different than others is misleading. Leave just PHY_LE_*
definitions in BluetoothDevice, and add PHY_LE*_MASK for the mask used
in PHY update API.
This patch also removes need to translate PHY value between PHY update
request and event, as mask is used for request, and the value is
returned in event.
Bug: 30622771
Test: manual
Change-Id: I897effa1204a024465d55501c83c542566c4d37c
Diffstat (limited to 'framework/java/android/bluetooth/le/AdvertisingSetParameters.java')
-rw-r--r-- | framework/java/android/bluetooth/le/AdvertisingSetParameters.java | 38 |
1 files changed, 13 insertions, 25 deletions
diff --git a/framework/java/android/bluetooth/le/AdvertisingSetParameters.java b/framework/java/android/bluetooth/le/AdvertisingSetParameters.java index 4e9fac3ee2..31d8f48209 100644 --- a/framework/java/android/bluetooth/le/AdvertisingSetParameters.java +++ b/framework/java/android/bluetooth/le/AdvertisingSetParameters.java @@ -17,6 +17,7 @@ package android.bluetooth.le; import android.bluetooth.BluetoothAdapter; +import android.bluetooth.BluetoothDevice; import android.os.Parcel; import android.os.Parcelable; @@ -30,21 +31,6 @@ import android.os.Parcelable; public final class AdvertisingSetParameters implements Parcelable { /** - * 1M advertiser PHY. - */ - public static final int PHY_LE_1M = 1; - - /** - * 2M advertiser PHY. - */ - public static final int PHY_LE_2M = 2; - - /** - * LE Coded advertiser PHY. - */ - public static final int PHY_LE_CODED = 3; - - /** * Advertise on low frequency, around every 1000ms. This is the default and * preferred advertising mode as it consumes the least power. */ @@ -246,8 +232,8 @@ public final class AdvertisingSetParameters implements Parcelable { private boolean isLegacy = false; private boolean isAnonymous = false; private boolean includeTxPower = false; - private int primaryPhy = PHY_LE_1M; - private int secondaryPhy = PHY_LE_1M; + private int primaryPhy = BluetoothDevice.PHY_LE_1M; + private int secondaryPhy = BluetoothDevice.PHY_LE_1M; private int interval = INTERVAL_LOW; private int txPowerLevel = TX_POWER_MEDIUM; @@ -321,12 +307,13 @@ public final class AdvertisingSetParameters implements Parcelable { * Use {@link BluetoothAdapter#isLeCodedPhySupported} to determine if LE Coded PHY is * supported on this device. * @param primaryPhy Primary advertising physical channel, can only be - * {@link AdvertisingSetParameters#PHY_LE_1M} or - * {@link AdvertisingSetParameters#PHY_LE_CODED}. + * {@link BluetoothDevice#PHY_LE_1M} or + * {@link BluetoothDevice#PHY_LE_CODED}. * @throws IllegalArgumentException If the primaryPhy is invalid. */ public Builder setPrimaryPhy(int primaryPhy) { - if (primaryPhy != PHY_LE_1M && primaryPhy != PHY_LE_CODED) { + if (primaryPhy != BluetoothDevice.PHY_LE_1M && + primaryPhy != BluetoothDevice.PHY_LE_CODED) { throw new IllegalArgumentException("bad primaryPhy " + primaryPhy); } this.primaryPhy = primaryPhy; @@ -343,14 +330,15 @@ public final class AdvertisingSetParameters implements Parcelable { * supported on this device. * * @param secondaryPhy Secondary advertising physical channel, can only be - * one of {@link AdvertisingSetParameters#PHY_LE_1M}, - * {@link AdvertisingSetParameters#PHY_LE_2M} or - * {@link AdvertisingSetParameters#PHY_LE_CODED}. + * one of {@link BluetoothDevice#PHY_LE_1M}, + * {@link BluetoothDevice#PHY_LE_2M} or + * {@link BluetoothDevice#PHY_LE_CODED}. * @throws IllegalArgumentException If the secondaryPhy is invalid. */ public Builder setSecondaryPhy(int secondaryPhy) { - if (secondaryPhy != PHY_LE_1M && secondaryPhy !=PHY_LE_2M && - secondaryPhy != PHY_LE_CODED) { + if (secondaryPhy != BluetoothDevice.PHY_LE_1M && + secondaryPhy != BluetoothDevice.PHY_LE_2M && + secondaryPhy != BluetoothDevice.PHY_LE_CODED) { throw new IllegalArgumentException("bad secondaryPhy " + secondaryPhy); } this.secondaryPhy = secondaryPhy; |