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

Commit 9e377194 authored by Jakub Pawlowski's avatar Jakub Pawlowski
Browse files

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
parent 70fea2df
Loading
Loading
Loading
Loading
+4 −10
Original line number Diff line number Diff line
@@ -7121,9 +7121,11 @@ package android.bluetooth {
    field public static final int PAIRING_VARIANT_PASSKEY_CONFIRMATION = 2; // 0x2
    field public static final int PAIRING_VARIANT_PIN = 0; // 0x0
    field public static final int PHY_LE_1M = 1; // 0x1
    field public static final int PHY_LE_1M_MASK = 1; // 0x1
    field public static final int PHY_LE_2M = 2; // 0x2
    field public static final int PHY_LE_ANY = 7; // 0x7
    field public static final int PHY_LE_CODED = 4; // 0x4
    field public static final int PHY_LE_2M_MASK = 2; // 0x2
    field public static final int PHY_LE_CODED = 3; // 0x3
    field public static final int PHY_LE_CODED_MASK = 4; // 0x4
    field public static final int PHY_OPTION_NO_PREFERRED = 0; // 0x0
    field public static final int PHY_OPTION_S2 = 1; // 0x1
    field public static final int PHY_OPTION_S8 = 2; // 0x2
@@ -7541,9 +7543,6 @@ package android.bluetooth.le {
    field public static final int INTERVAL_MAX = 16777215; // 0xffffff
    field public static final int INTERVAL_MEDIUM = 400; // 0x190
    field public static final int INTERVAL_MIN = 160; // 0xa0
    field public static final int PHY_LE_1M = 1; // 0x1
    field public static final int PHY_LE_2M = 2; // 0x2
    field public static final int PHY_LE_CODED = 3; // 0x3
    field public static final int TX_POWER_HIGH = 1; // 0x1
    field public static final int TX_POWER_LOW = -15; // 0xfffffff1
    field public static final int TX_POWER_MAX = 1; // 0x1
@@ -7672,9 +7671,6 @@ package android.bluetooth.le {
    field public static final android.os.Parcelable.Creator<android.bluetooth.le.ScanResult> CREATOR;
    field public static final int DATA_COMPLETE = 0; // 0x0
    field public static final int DATA_TRUNCATED = 2; // 0x2
    field public static final int PHY_LE_1M = 1; // 0x1
    field public static final int PHY_LE_2M = 2; // 0x2
    field public static final int PHY_LE_CODED = 3; // 0x3
    field public static final int PHY_UNUSED = 0; // 0x0
    field public static final int SID_NOT_PRESENT = 255; // 0xff
  }
@@ -7697,9 +7693,7 @@ package android.bluetooth.le {
    field public static final int MATCH_NUM_FEW_ADVERTISEMENT = 2; // 0x2
    field public static final int MATCH_NUM_MAX_ADVERTISEMENT = 3; // 0x3
    field public static final int MATCH_NUM_ONE_ADVERTISEMENT = 1; // 0x1
    field public static final int PHY_LE_1M = 1; // 0x1
    field public static final int PHY_LE_ALL_SUPPORTED = 255; // 0xff
    field public static final int PHY_LE_CODED = 3; // 0x3
    field public static final int SCAN_MODE_BALANCED = 1; // 0x1
    field public static final int SCAN_MODE_LOW_LATENCY = 2; // 0x2
    field public static final int SCAN_MODE_LOW_POWER = 0; // 0x0
+4 −10
Original line number Diff line number Diff line
@@ -7426,9 +7426,11 @@ package android.bluetooth {
    field public static final int PAIRING_VARIANT_PASSKEY_CONFIRMATION = 2; // 0x2
    field public static final int PAIRING_VARIANT_PIN = 0; // 0x0
    field public static final int PHY_LE_1M = 1; // 0x1
    field public static final int PHY_LE_1M_MASK = 1; // 0x1
    field public static final int PHY_LE_2M = 2; // 0x2
    field public static final int PHY_LE_ANY = 7; // 0x7
    field public static final int PHY_LE_CODED = 4; // 0x4
    field public static final int PHY_LE_2M_MASK = 2; // 0x2
    field public static final int PHY_LE_CODED = 3; // 0x3
    field public static final int PHY_LE_CODED_MASK = 4; // 0x4
    field public static final int PHY_OPTION_NO_PREFERRED = 0; // 0x0
    field public static final int PHY_OPTION_S2 = 1; // 0x1
    field public static final int PHY_OPTION_S8 = 2; // 0x2
@@ -7846,9 +7848,6 @@ package android.bluetooth.le {
    field public static final int INTERVAL_MAX = 16777215; // 0xffffff
    field public static final int INTERVAL_MEDIUM = 400; // 0x190
    field public static final int INTERVAL_MIN = 160; // 0xa0
    field public static final int PHY_LE_1M = 1; // 0x1
    field public static final int PHY_LE_2M = 2; // 0x2
    field public static final int PHY_LE_CODED = 3; // 0x3
    field public static final int TX_POWER_HIGH = 1; // 0x1
    field public static final int TX_POWER_LOW = -15; // 0xfffffff1
    field public static final int TX_POWER_MAX = 1; // 0x1
@@ -7990,9 +7989,6 @@ package android.bluetooth.le {
    field public static final android.os.Parcelable.Creator<android.bluetooth.le.ScanResult> CREATOR;
    field public static final int DATA_COMPLETE = 0; // 0x0
    field public static final int DATA_TRUNCATED = 2; // 0x2
    field public static final int PHY_LE_1M = 1; // 0x1
    field public static final int PHY_LE_2M = 2; // 0x2
    field public static final int PHY_LE_CODED = 3; // 0x3
    field public static final int PHY_UNUSED = 0; // 0x0
    field public static final int SID_NOT_PRESENT = 255; // 0xff
  }
@@ -8015,9 +8011,7 @@ package android.bluetooth.le {
    field public static final int MATCH_NUM_FEW_ADVERTISEMENT = 2; // 0x2
    field public static final int MATCH_NUM_MAX_ADVERTISEMENT = 3; // 0x3
    field public static final int MATCH_NUM_ONE_ADVERTISEMENT = 1; // 0x1
    field public static final int PHY_LE_1M = 1; // 0x1
    field public static final int PHY_LE_ALL_SUPPORTED = 255; // 0xff
    field public static final int PHY_LE_CODED = 3; // 0x3
    field public static final int SCAN_MODE_BALANCED = 1; // 0x1
    field public static final int SCAN_MODE_LOW_LATENCY = 2; // 0x2
    field public static final int SCAN_MODE_LOW_POWER = 0; // 0x0
+4 −10
Original line number Diff line number Diff line
@@ -7130,9 +7130,11 @@ package android.bluetooth {
    field public static final int PAIRING_VARIANT_PASSKEY_CONFIRMATION = 2; // 0x2
    field public static final int PAIRING_VARIANT_PIN = 0; // 0x0
    field public static final int PHY_LE_1M = 1; // 0x1
    field public static final int PHY_LE_1M_MASK = 1; // 0x1
    field public static final int PHY_LE_2M = 2; // 0x2
    field public static final int PHY_LE_ANY = 7; // 0x7
    field public static final int PHY_LE_CODED = 4; // 0x4
    field public static final int PHY_LE_2M_MASK = 2; // 0x2
    field public static final int PHY_LE_CODED = 3; // 0x3
    field public static final int PHY_LE_CODED_MASK = 4; // 0x4
    field public static final int PHY_OPTION_NO_PREFERRED = 0; // 0x0
    field public static final int PHY_OPTION_S2 = 1; // 0x1
    field public static final int PHY_OPTION_S8 = 2; // 0x2
@@ -7550,9 +7552,6 @@ package android.bluetooth.le {
    field public static final int INTERVAL_MAX = 16777215; // 0xffffff
    field public static final int INTERVAL_MEDIUM = 400; // 0x190
    field public static final int INTERVAL_MIN = 160; // 0xa0
    field public static final int PHY_LE_1M = 1; // 0x1
    field public static final int PHY_LE_2M = 2; // 0x2
    field public static final int PHY_LE_CODED = 3; // 0x3
    field public static final int TX_POWER_HIGH = 1; // 0x1
    field public static final int TX_POWER_LOW = -15; // 0xfffffff1
    field public static final int TX_POWER_MAX = 1; // 0x1
@@ -7681,9 +7680,6 @@ package android.bluetooth.le {
    field public static final android.os.Parcelable.Creator<android.bluetooth.le.ScanResult> CREATOR;
    field public static final int DATA_COMPLETE = 0; // 0x0
    field public static final int DATA_TRUNCATED = 2; // 0x2
    field public static final int PHY_LE_1M = 1; // 0x1
    field public static final int PHY_LE_2M = 2; // 0x2
    field public static final int PHY_LE_CODED = 3; // 0x3
    field public static final int PHY_UNUSED = 0; // 0x0
    field public static final int SID_NOT_PRESENT = 255; // 0xff
  }
@@ -7706,9 +7702,7 @@ package android.bluetooth.le {
    field public static final int MATCH_NUM_FEW_ADVERTISEMENT = 2; // 0x2
    field public static final int MATCH_NUM_MAX_ADVERTISEMENT = 3; // 0x3
    field public static final int MATCH_NUM_ONE_ADVERTISEMENT = 1; // 0x1
    field public static final int PHY_LE_1M = 1; // 0x1
    field public static final int PHY_LE_ALL_SUPPORTED = 255; // 0xff
    field public static final int PHY_LE_CODED = 3; // 0x3
    field public static final int SCAN_MODE_BALANCED = 1; // 0x1
    field public static final int SCAN_MODE_LOW_LATENCY = 2; // 0x2
    field public static final int SCAN_MODE_LOW_POWER = 0; // 0x0
+19 −9
Original line number Diff line number Diff line
@@ -593,24 +593,34 @@ public final class BluetoothDevice implements Parcelable {
    public static final int TRANSPORT_LE = 2;

    /**
     * 1M initiating PHY.
     * Bluetooth LE 1M PHY.
     */
    public static final int PHY_LE_1M = 1;

    /**
     * 2M initiating PHY.
     * Bluetooth LE 2M PHY.
     */
    public static final int PHY_LE_2M = 2;

    /**
     * LE Coded initiating PHY.
     * Bluetooth LE Coded PHY.
     */
    public static final int PHY_LE_CODED = 4;
    public static final int PHY_LE_CODED = 3;

    /**
     * Any LE PHY.
     * Bluetooth LE 1M PHY mask.
     */
    public static final int PHY_LE_ANY = PHY_LE_1M | PHY_LE_2M | PHY_LE_CODED;
    public static final int PHY_LE_1M_MASK = 1;

    /**
     * Bluetooth LE 2M PHY mask.
     */
    public static final int PHY_LE_2M_MASK = 2;

    /**
     * Bluetooth LE Coded PHY mask.
     */
    public static final int PHY_LE_CODED_MASK = 4;

    /**
     * No preferred coding when transmitting on the LE Coded PHY.
@@ -1651,7 +1661,7 @@ public final class BluetoothDevice implements Parcelable {
     */
    public BluetoothGatt connectGatt(Context context, boolean autoConnect,
                                     BluetoothGattCallback callback, int transport) {
        return (connectGatt(context, autoConnect,callback, TRANSPORT_AUTO, PHY_LE_1M));
        return (connectGatt(context, autoConnect,callback, TRANSPORT_AUTO, PHY_LE_1M_MASK));
    }

    /**
@@ -1668,8 +1678,8 @@ public final class BluetoothDevice implements Parcelable {
     *             {@link BluetoothDevice#TRANSPORT_AUTO} or
     *             {@link BluetoothDevice#TRANSPORT_BREDR} or {@link BluetoothDevice#TRANSPORT_LE}
     * @param phy preferred PHY for connections to remote LE device. Bitwise OR of any of
     *             {@link BluetoothDevice#PHY_LE_1M}, {@link BluetoothDevice#PHY_LE_2M},
     *             and {@link BluetoothDevice#PHY_LE_CODED}. This option does not take effect if
     *             {@link BluetoothDevice#PHY_LE_1M_MASK}, {@link BluetoothDevice#PHY_LE_2M_MASK},
     *             and {@link BluetoothDevice#PHY_LE_CODED_MASK}. This option does not take effect if
     *             {@code autoConnect} is set to true.
     * @throws IllegalArgumentException if callback is null
     */
+4 −4
Original line number Diff line number Diff line
@@ -785,11 +785,11 @@ public final class BluetoothGatt implements BluetoothProfile {
     * if no PHY change happens. It is also triggered when remote device updates the PHY.
     *
     * @param txPhy preferred transmitter PHY. Bitwise OR of any of
     *             {@link BluetoothDevice#PHY_LE_1M}, {@link BluetoothDevice#PHY_LE_2M}, and
     *             {@link BluetoothDevice#PHY_LE_CODED}.
     *             {@link BluetoothDevice#PHY_LE_1M_MASK}, {@link BluetoothDevice#PHY_LE_2M_MASK},
     *             and {@link BluetoothDevice#PHY_LE_CODED_MASK}.
     * @param rxPhy preferred receiver PHY. Bitwise OR of any of
     *             {@link BluetoothDevice#PHY_LE_1M}, {@link BluetoothDevice#PHY_LE_2M}, and
     *             {@link BluetoothDevice#PHY_LE_CODED}.
     *             {@link BluetoothDevice#PHY_LE_1M_MASK}, {@link BluetoothDevice#PHY_LE_2M_MASK},
     *             and {@link BluetoothDevice#PHY_LE_CODED_MASK}.
     * @param phyOptions preferred coding to use when transmitting on the LE Coded PHY. Can be one
     *             of {@link BluetoothDevice#PHY_OPTION_NO_PREFERRED},
     *             {@link BluetoothDevice#PHY_OPTION_S2} or {@link BluetoothDevice#PHY_OPTION_S8}
Loading