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

Commit 104eeedb authored by Jakub Pawlowski's avatar Jakub Pawlowski Committed by Gerrit Code Review
Browse files

Merge "Bluetooth 5 PHY selection API"

parents f1d76a71 409cee69
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -128,8 +128,8 @@ LOCAL_SRC_FILES += \
	core/java/android/bluetooth/IBluetoothInputHost.aidl \
	core/java/android/bluetooth/IBluetoothHidDeviceCallback.aidl \
	core/java/android/bluetooth/IBluetoothGatt.aidl \
	core/java/android/bluetooth/IBluetoothGattCallback.aidl \
	core/java/android/bluetooth/IBluetoothGattServerCallback.aidl \
	core/java/android/bluetooth/IBluetoothGattCallbackExt.aidl \
	core/java/android/bluetooth/IBluetoothGattServerCallbackExt.aidl \
	core/java/android/bluetooth/le/IAdvertiserCallback.aidl \
	core/java/android/bluetooth/le/IPeriodicAdvertisingCallback.aidl \
	core/java/android/bluetooth/le/IScannerCallback.aidl \
+28 −2
Original line number Diff line number Diff line
@@ -7076,6 +7076,9 @@ package android.bluetooth {
  public final class BluetoothDevice implements android.os.Parcelable {
    method public android.bluetooth.BluetoothGatt connectGatt(android.content.Context, boolean, android.bluetooth.BluetoothGattCallback);
    method public android.bluetooth.BluetoothGatt connectGatt(android.content.Context, boolean, android.bluetooth.BluetoothGattCallback, int);
    method public android.bluetooth.BluetoothGatt connectGatt(android.content.Context, boolean, android.bluetooth.BluetoothGattCallbackExt);
    method public android.bluetooth.BluetoothGatt connectGatt(android.content.Context, boolean, android.bluetooth.BluetoothGattCallbackExt, int);
    method public android.bluetooth.BluetoothGatt connectGatt(android.content.Context, boolean, android.bluetooth.BluetoothGattCallbackExt, int, int);
    method public boolean createBond();
    method public android.bluetooth.BluetoothSocket createInsecureRfcommSocketToServiceRecord(java.util.UUID) throws java.io.IOException;
    method public android.bluetooth.BluetoothSocket createRfcommSocketToServiceRecord(java.util.UUID) throws java.io.IOException;
@@ -7119,6 +7122,13 @@ package android.bluetooth {
    field public static final java.lang.String EXTRA_UUID = "android.bluetooth.device.extra.UUID";
    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_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_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
    field public static final int TRANSPORT_AUTO = 0; // 0x0
    field public static final int TRANSPORT_BREDR = 1; // 0x1
    field public static final int TRANSPORT_LE = 2; // 0x2
@@ -7141,10 +7151,12 @@ package android.bluetooth {
    method public java.util.List<android.bluetooth.BluetoothGattService> getServices();
    method public boolean readCharacteristic(android.bluetooth.BluetoothGattCharacteristic);
    method public boolean readDescriptor(android.bluetooth.BluetoothGattDescriptor);
    method public void readPhy();
    method public boolean readRemoteRssi();
    method public boolean requestConnectionPriority(int);
    method public boolean requestMtu(int);
    method public boolean setCharacteristicNotification(android.bluetooth.BluetoothGattCharacteristic, boolean);
    method public void setPreferredPhy(int, int, int);
    method public boolean writeCharacteristic(android.bluetooth.BluetoothGattCharacteristic);
    method public boolean writeDescriptor(android.bluetooth.BluetoothGattDescriptor);
    field public static final int CONNECTION_PRIORITY_BALANCED = 0; // 0x0
@@ -7162,8 +7174,12 @@ package android.bluetooth {
    field public static final int GATT_WRITE_NOT_PERMITTED = 3; // 0x3
  }
  public abstract class BluetoothGattCallback {
  public abstract deprecated class BluetoothGattCallback extends android.bluetooth.BluetoothGattCallbackExt {
    ctor public BluetoothGattCallback();
  }
  public abstract class BluetoothGattCallbackExt {
    ctor public BluetoothGattCallbackExt();
    method public void onCharacteristicChanged(android.bluetooth.BluetoothGatt, android.bluetooth.BluetoothGattCharacteristic);
    method public void onCharacteristicRead(android.bluetooth.BluetoothGatt, android.bluetooth.BluetoothGattCharacteristic, int);
    method public void onCharacteristicWrite(android.bluetooth.BluetoothGatt, android.bluetooth.BluetoothGattCharacteristic, int);
@@ -7171,6 +7187,8 @@ package android.bluetooth {
    method public void onDescriptorRead(android.bluetooth.BluetoothGatt, android.bluetooth.BluetoothGattDescriptor, int);
    method public void onDescriptorWrite(android.bluetooth.BluetoothGatt, android.bluetooth.BluetoothGattDescriptor, int);
    method public void onMtuChanged(android.bluetooth.BluetoothGatt, int, int);
    method public void onPhyRead(android.bluetooth.BluetoothGatt, int, int, int);
    method public void onPhyUpdate(android.bluetooth.BluetoothGatt, int, int, int);
    method public void onReadRemoteRssi(android.bluetooth.BluetoothGatt, int, int);
    method public void onReliableWriteCompleted(android.bluetooth.BluetoothGatt, int);
    method public void onServicesDiscovered(android.bluetooth.BluetoothGatt, int);
@@ -7264,12 +7282,18 @@ package android.bluetooth {
    method public android.bluetooth.BluetoothGattService getService(java.util.UUID);
    method public java.util.List<android.bluetooth.BluetoothGattService> getServices();
    method public boolean notifyCharacteristicChanged(android.bluetooth.BluetoothDevice, android.bluetooth.BluetoothGattCharacteristic, boolean);
    method public void readPhy(android.bluetooth.BluetoothDevice);
    method public boolean removeService(android.bluetooth.BluetoothGattService);
    method public boolean sendResponse(android.bluetooth.BluetoothDevice, int, int, int, byte[]);
    method public void setPreferredPhy(android.bluetooth.BluetoothDevice, int, int, int);
  }
  public abstract class BluetoothGattServerCallback {
  public abstract deprecated class BluetoothGattServerCallback extends android.bluetooth.BluetoothGattServerCallbackExt {
    ctor public BluetoothGattServerCallback();
  }
  public abstract class BluetoothGattServerCallbackExt {
    ctor public BluetoothGattServerCallbackExt();
    method public void onCharacteristicReadRequest(android.bluetooth.BluetoothDevice, int, int, android.bluetooth.BluetoothGattCharacteristic);
    method public void onCharacteristicWriteRequest(android.bluetooth.BluetoothDevice, int, android.bluetooth.BluetoothGattCharacteristic, boolean, boolean, int, byte[]);
    method public void onConnectionStateChange(android.bluetooth.BluetoothDevice, int, int);
@@ -7278,6 +7302,8 @@ package android.bluetooth {
    method public void onExecuteWrite(android.bluetooth.BluetoothDevice, int, boolean);
    method public void onMtuChanged(android.bluetooth.BluetoothDevice, int);
    method public void onNotificationSent(android.bluetooth.BluetoothDevice, int);
    method public void onPhyRead(android.bluetooth.BluetoothDevice, int, int, int);
    method public void onPhyUpdate(android.bluetooth.BluetoothDevice, int, int, int);
    method public void onServiceAdded(int, android.bluetooth.BluetoothGattService);
  }
+28 −2
Original line number Diff line number Diff line
@@ -7378,6 +7378,9 @@ package android.bluetooth {
  public final class BluetoothDevice implements android.os.Parcelable {
    method public android.bluetooth.BluetoothGatt connectGatt(android.content.Context, boolean, android.bluetooth.BluetoothGattCallback);
    method public android.bluetooth.BluetoothGatt connectGatt(android.content.Context, boolean, android.bluetooth.BluetoothGattCallback, int);
    method public android.bluetooth.BluetoothGatt connectGatt(android.content.Context, boolean, android.bluetooth.BluetoothGattCallbackExt);
    method public android.bluetooth.BluetoothGatt connectGatt(android.content.Context, boolean, android.bluetooth.BluetoothGattCallbackExt, int);
    method public android.bluetooth.BluetoothGatt connectGatt(android.content.Context, boolean, android.bluetooth.BluetoothGattCallbackExt, int, int);
    method public boolean createBond();
    method public android.bluetooth.BluetoothSocket createInsecureRfcommSocketToServiceRecord(java.util.UUID) throws java.io.IOException;
    method public android.bluetooth.BluetoothSocket createRfcommSocketToServiceRecord(java.util.UUID) throws java.io.IOException;
@@ -7423,6 +7426,13 @@ package android.bluetooth {
    field public static final java.lang.String EXTRA_UUID = "android.bluetooth.device.extra.UUID";
    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_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_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
    field public static final int TRANSPORT_AUTO = 0; // 0x0
    field public static final int TRANSPORT_BREDR = 1; // 0x1
    field public static final int TRANSPORT_LE = 2; // 0x2
@@ -7445,10 +7455,12 @@ package android.bluetooth {
    method public java.util.List<android.bluetooth.BluetoothGattService> getServices();
    method public boolean readCharacteristic(android.bluetooth.BluetoothGattCharacteristic);
    method public boolean readDescriptor(android.bluetooth.BluetoothGattDescriptor);
    method public void readPhy();
    method public boolean readRemoteRssi();
    method public boolean requestConnectionPriority(int);
    method public boolean requestMtu(int);
    method public boolean setCharacteristicNotification(android.bluetooth.BluetoothGattCharacteristic, boolean);
    method public void setPreferredPhy(int, int, int);
    method public boolean writeCharacteristic(android.bluetooth.BluetoothGattCharacteristic);
    method public boolean writeDescriptor(android.bluetooth.BluetoothGattDescriptor);
    field public static final int CONNECTION_PRIORITY_BALANCED = 0; // 0x0
@@ -7466,8 +7478,12 @@ package android.bluetooth {
    field public static final int GATT_WRITE_NOT_PERMITTED = 3; // 0x3
  }
  public abstract class BluetoothGattCallback {
  public abstract deprecated class BluetoothGattCallback extends android.bluetooth.BluetoothGattCallbackExt {
    ctor public BluetoothGattCallback();
  }
  public abstract class BluetoothGattCallbackExt {
    ctor public BluetoothGattCallbackExt();
    method public void onCharacteristicChanged(android.bluetooth.BluetoothGatt, android.bluetooth.BluetoothGattCharacteristic);
    method public void onCharacteristicRead(android.bluetooth.BluetoothGatt, android.bluetooth.BluetoothGattCharacteristic, int);
    method public void onCharacteristicWrite(android.bluetooth.BluetoothGatt, android.bluetooth.BluetoothGattCharacteristic, int);
@@ -7475,6 +7491,8 @@ package android.bluetooth {
    method public void onDescriptorRead(android.bluetooth.BluetoothGatt, android.bluetooth.BluetoothGattDescriptor, int);
    method public void onDescriptorWrite(android.bluetooth.BluetoothGatt, android.bluetooth.BluetoothGattDescriptor, int);
    method public void onMtuChanged(android.bluetooth.BluetoothGatt, int, int);
    method public void onPhyRead(android.bluetooth.BluetoothGatt, int, int, int);
    method public void onPhyUpdate(android.bluetooth.BluetoothGatt, int, int, int);
    method public void onReadRemoteRssi(android.bluetooth.BluetoothGatt, int, int);
    method public void onReliableWriteCompleted(android.bluetooth.BluetoothGatt, int);
    method public void onServicesDiscovered(android.bluetooth.BluetoothGatt, int);
@@ -7568,12 +7586,18 @@ package android.bluetooth {
    method public android.bluetooth.BluetoothGattService getService(java.util.UUID);
    method public java.util.List<android.bluetooth.BluetoothGattService> getServices();
    method public boolean notifyCharacteristicChanged(android.bluetooth.BluetoothDevice, android.bluetooth.BluetoothGattCharacteristic, boolean);
    method public void readPhy(android.bluetooth.BluetoothDevice);
    method public boolean removeService(android.bluetooth.BluetoothGattService);
    method public boolean sendResponse(android.bluetooth.BluetoothDevice, int, int, int, byte[]);
    method public void setPreferredPhy(android.bluetooth.BluetoothDevice, int, int, int);
  }
  public abstract class BluetoothGattServerCallback {
  public abstract deprecated class BluetoothGattServerCallback extends android.bluetooth.BluetoothGattServerCallbackExt {
    ctor public BluetoothGattServerCallback();
  }
  public abstract class BluetoothGattServerCallbackExt {
    ctor public BluetoothGattServerCallbackExt();
    method public void onCharacteristicReadRequest(android.bluetooth.BluetoothDevice, int, int, android.bluetooth.BluetoothGattCharacteristic);
    method public void onCharacteristicWriteRequest(android.bluetooth.BluetoothDevice, int, android.bluetooth.BluetoothGattCharacteristic, boolean, boolean, int, byte[]);
    method public void onConnectionStateChange(android.bluetooth.BluetoothDevice, int, int);
@@ -7582,6 +7606,8 @@ package android.bluetooth {
    method public void onExecuteWrite(android.bluetooth.BluetoothDevice, int, boolean);
    method public void onMtuChanged(android.bluetooth.BluetoothDevice, int);
    method public void onNotificationSent(android.bluetooth.BluetoothDevice, int);
    method public void onPhyRead(android.bluetooth.BluetoothDevice, int, int, int);
    method public void onPhyUpdate(android.bluetooth.BluetoothDevice, int, int, int);
    method public void onServiceAdded(int, android.bluetooth.BluetoothGattService);
  }
+28 −2
Original line number Diff line number Diff line
@@ -7085,6 +7085,9 @@ package android.bluetooth {
  public final class BluetoothDevice implements android.os.Parcelable {
    method public android.bluetooth.BluetoothGatt connectGatt(android.content.Context, boolean, android.bluetooth.BluetoothGattCallback);
    method public android.bluetooth.BluetoothGatt connectGatt(android.content.Context, boolean, android.bluetooth.BluetoothGattCallback, int);
    method public android.bluetooth.BluetoothGatt connectGatt(android.content.Context, boolean, android.bluetooth.BluetoothGattCallbackExt);
    method public android.bluetooth.BluetoothGatt connectGatt(android.content.Context, boolean, android.bluetooth.BluetoothGattCallbackExt, int);
    method public android.bluetooth.BluetoothGatt connectGatt(android.content.Context, boolean, android.bluetooth.BluetoothGattCallbackExt, int, int);
    method public boolean createBond();
    method public android.bluetooth.BluetoothSocket createInsecureRfcommSocketToServiceRecord(java.util.UUID) throws java.io.IOException;
    method public android.bluetooth.BluetoothSocket createRfcommSocketToServiceRecord(java.util.UUID) throws java.io.IOException;
@@ -7128,6 +7131,13 @@ package android.bluetooth {
    field public static final java.lang.String EXTRA_UUID = "android.bluetooth.device.extra.UUID";
    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_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_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
    field public static final int TRANSPORT_AUTO = 0; // 0x0
    field public static final int TRANSPORT_BREDR = 1; // 0x1
    field public static final int TRANSPORT_LE = 2; // 0x2
@@ -7150,10 +7160,12 @@ package android.bluetooth {
    method public java.util.List<android.bluetooth.BluetoothGattService> getServices();
    method public boolean readCharacteristic(android.bluetooth.BluetoothGattCharacteristic);
    method public boolean readDescriptor(android.bluetooth.BluetoothGattDescriptor);
    method public void readPhy();
    method public boolean readRemoteRssi();
    method public boolean requestConnectionPriority(int);
    method public boolean requestMtu(int);
    method public boolean setCharacteristicNotification(android.bluetooth.BluetoothGattCharacteristic, boolean);
    method public void setPreferredPhy(int, int, int);
    method public boolean writeCharacteristic(android.bluetooth.BluetoothGattCharacteristic);
    method public boolean writeDescriptor(android.bluetooth.BluetoothGattDescriptor);
    field public static final int CONNECTION_PRIORITY_BALANCED = 0; // 0x0
@@ -7171,8 +7183,12 @@ package android.bluetooth {
    field public static final int GATT_WRITE_NOT_PERMITTED = 3; // 0x3
  }
  public abstract class BluetoothGattCallback {
  public abstract deprecated class BluetoothGattCallback extends android.bluetooth.BluetoothGattCallbackExt {
    ctor public BluetoothGattCallback();
  }
  public abstract class BluetoothGattCallbackExt {
    ctor public BluetoothGattCallbackExt();
    method public void onCharacteristicChanged(android.bluetooth.BluetoothGatt, android.bluetooth.BluetoothGattCharacteristic);
    method public void onCharacteristicRead(android.bluetooth.BluetoothGatt, android.bluetooth.BluetoothGattCharacteristic, int);
    method public void onCharacteristicWrite(android.bluetooth.BluetoothGatt, android.bluetooth.BluetoothGattCharacteristic, int);
@@ -7180,6 +7196,8 @@ package android.bluetooth {
    method public void onDescriptorRead(android.bluetooth.BluetoothGatt, android.bluetooth.BluetoothGattDescriptor, int);
    method public void onDescriptorWrite(android.bluetooth.BluetoothGatt, android.bluetooth.BluetoothGattDescriptor, int);
    method public void onMtuChanged(android.bluetooth.BluetoothGatt, int, int);
    method public void onPhyRead(android.bluetooth.BluetoothGatt, int, int, int);
    method public void onPhyUpdate(android.bluetooth.BluetoothGatt, int, int, int);
    method public void onReadRemoteRssi(android.bluetooth.BluetoothGatt, int, int);
    method public void onReliableWriteCompleted(android.bluetooth.BluetoothGatt, int);
    method public void onServicesDiscovered(android.bluetooth.BluetoothGatt, int);
@@ -7273,12 +7291,18 @@ package android.bluetooth {
    method public android.bluetooth.BluetoothGattService getService(java.util.UUID);
    method public java.util.List<android.bluetooth.BluetoothGattService> getServices();
    method public boolean notifyCharacteristicChanged(android.bluetooth.BluetoothDevice, android.bluetooth.BluetoothGattCharacteristic, boolean);
    method public void readPhy(android.bluetooth.BluetoothDevice);
    method public boolean removeService(android.bluetooth.BluetoothGattService);
    method public boolean sendResponse(android.bluetooth.BluetoothDevice, int, int, int, byte[]);
    method public void setPreferredPhy(android.bluetooth.BluetoothDevice, int, int, int);
  }
  public abstract class BluetoothGattServerCallback {
  public abstract deprecated class BluetoothGattServerCallback extends android.bluetooth.BluetoothGattServerCallbackExt {
    ctor public BluetoothGattServerCallback();
  }
  public abstract class BluetoothGattServerCallbackExt {
    ctor public BluetoothGattServerCallbackExt();
    method public void onCharacteristicReadRequest(android.bluetooth.BluetoothDevice, int, int, android.bluetooth.BluetoothGattCharacteristic);
    method public void onCharacteristicWriteRequest(android.bluetooth.BluetoothDevice, int, android.bluetooth.BluetoothGattCharacteristic, boolean, boolean, int, byte[]);
    method public void onConnectionStateChange(android.bluetooth.BluetoothDevice, int, int);
@@ -7287,6 +7311,8 @@ package android.bluetooth {
    method public void onExecuteWrite(android.bluetooth.BluetoothDevice, int, boolean);
    method public void onMtuChanged(android.bluetooth.BluetoothDevice, int);
    method public void onNotificationSent(android.bluetooth.BluetoothDevice, int);
    method public void onPhyRead(android.bluetooth.BluetoothDevice, int, int, int);
    method public void onPhyUpdate(android.bluetooth.BluetoothDevice, int, int, int);
    method public void onServiceAdded(int, android.bluetooth.BluetoothGattService);
  }
+98 −1
Original line number Diff line number Diff line
@@ -592,6 +592,42 @@ public final class BluetoothDevice implements Parcelable {
     */
    public static final int TRANSPORT_LE = 2;

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

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

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

    /**
     * Any LE PHY.
     */
    public static final int PHY_LE_ANY = PHY_LE_1M | PHY_LE_2M | PHY_LE_CODED;

    /**
     * No preferred coding when transmitting on the LE Coded PHY.
     */
    public static final int PHY_OPTION_NO_PREFERRED = 0;

    /**
     * Prefer the S=2 coding to be used when transmitting on the LE Coded PHY.
     */
    public static final int PHY_OPTION_S2 = 1;

    /**
     * Prefer the S=8 coding to be used when transmitting on the LE Coded PHY.
     */
    public static final int PHY_OPTION_S8 = 2;


    /** @hide */
    public static final String EXTRA_MAS_INSTANCE =
        "android.bluetooth.device.extra.MAS_INSTANCE";
@@ -1615,6 +1651,67 @@ 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));
    }

    /**
     * Connect to GATT Server hosted by this device. Caller acts as GATT client.
     * The callback is used to deliver results to Caller, such as connection status as well
     * as any further GATT client operations.
     * The method returns a BluetoothGatt instance. You can use BluetoothGatt to conduct
     * GATT client operations.
     * @param callback GATT callback handler that will receive asynchronous callbacks.
     * @param autoConnect Whether to directly connect to the remote device (false)
     *                    or to automatically connect as soon as the remote
     *                    device becomes available (true).
     * @throws IllegalArgumentException if callback is null
     */
    public BluetoothGatt connectGatt(Context context, boolean autoConnect,
                                     BluetoothGattCallbackExt callback) {
        return (connectGatt(context, autoConnect,callback, TRANSPORT_AUTO));
    }

    /**
     * Connect to GATT Server hosted by this device. Caller acts as GATT client.
     * The callback is used to deliver results to Caller, such as connection status as well
     * as any further GATT client operations.
     * The method returns a BluetoothGatt instance. You can use BluetoothGatt to conduct
     * GATT client operations.
     * @param callback GATT callback handler that will receive asynchronous callbacks.
     * @param autoConnect Whether to directly connect to the remote device (false)
     *                    or to automatically connect as soon as the remote
     *                    device becomes available (true).
     * @param transport preferred transport for GATT connections to remote dual-mode devices
     *             {@link BluetoothDevice#TRANSPORT_AUTO} or
     *             {@link BluetoothDevice#TRANSPORT_BREDR} or {@link BluetoothDevice#TRANSPORT_LE}
     * @throws IllegalArgumentException if callback is null
     */
    public BluetoothGatt connectGatt(Context context, boolean autoConnect,
                                     BluetoothGattCallbackExt callback, int transport) {
        return (connectGatt(context, autoConnect,callback, TRANSPORT_AUTO, PHY_LE_1M));
    }

    /**
     * Connect to GATT Server hosted by this device. Caller acts as GATT client.
     * The callback is used to deliver results to Caller, such as connection status as well
     * as any further GATT client operations.
     * The method returns a BluetoothGatt instance. You can use BluetoothGatt to conduct
     * GATT client operations.
     * @param callback GATT callback handler that will receive asynchronous callbacks.
     * @param autoConnect Whether to directly connect to the remote device (false)
     *                    or to automatically connect as soon as the remote
     *                    device becomes available (true).
     * @param transport preferred transport for GATT connections to remote dual-mode devices
     *             {@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
     *             {@code autoConnect} is set to true.
     * @throws IllegalArgumentException if callback is null
     */
    public BluetoothGatt connectGatt(Context context, boolean autoConnect,
                                     BluetoothGattCallbackExt callback, int transport, int phy) {
        // TODO(Bluetooth) check whether platform support BLE
        //     Do the check here or in GattServer?
        BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter();
@@ -1625,7 +1722,7 @@ public final class BluetoothDevice implements Parcelable {
                // BLE is not supported
                return null;
            }
            BluetoothGatt gatt = new BluetoothGatt(iGatt, this, transport);
            BluetoothGatt gatt = new BluetoothGatt(iGatt, this, transport, phy);
            gatt.connect(autoConnect, callback);
            return gatt;
        } catch (RemoteException e) {Log.e(TAG, "", e);}
Loading