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

Commit 36a44f07 authored by Jakub Pawlowski's avatar Jakub Pawlowski Committed by android-build-merger
Browse files

Merge "Expose connection update callback (4/4)" am: 60865e4a am: 45487910

am: ccff3be9

Change-Id: I621210ff8d2c0b203d86e6ad2a11402466724b97
parents b062e90b ccff3be9
Loading
Loading
Loading
Loading
+32 −0
Original line number Original line Diff line number Diff line
@@ -141,6 +141,7 @@ public final class BluetoothGatt implements BluetoothProfile {
             * Application interface registered - app is ready to go
             * Application interface registered - app is ready to go
             * @hide
             * @hide
             */
             */
            @Override
            public void onClientRegistered(int status, int clientIf) {
            public void onClientRegistered(int status, int clientIf) {
                if (DBG) Log.d(TAG, "onClientRegistered() - status=" + status
                if (DBG) Log.d(TAG, "onClientRegistered() - status=" + status
                    + " clientIf=" + clientIf);
                    + " clientIf=" + clientIf);
@@ -210,6 +211,7 @@ public final class BluetoothGatt implements BluetoothProfile {
             * Client connection state changed
             * Client connection state changed
             * @hide
             * @hide
             */
             */
            @Override
            public void onClientConnectionState(int status, int clientIf,
            public void onClientConnectionState(int status, int clientIf,
                                                boolean connected, String address) {
                                                boolean connected, String address) {
                if (DBG) Log.d(TAG, "onClientConnectionState() - status=" + status
                if (DBG) Log.d(TAG, "onClientConnectionState() - status=" + status
@@ -245,6 +247,7 @@ public final class BluetoothGatt implements BluetoothProfile {
             * we are done at this point.
             * we are done at this point.
             * @hide
             * @hide
             */
             */
            @Override
            public void onSearchComplete(String address, List<BluetoothGattService> services,
            public void onSearchComplete(String address, List<BluetoothGattService> services,
                                         int status) {
                                         int status) {
                if (DBG) Log.d(TAG, "onSearchComplete() = Device=" + address + " Status=" + status);
                if (DBG) Log.d(TAG, "onSearchComplete() = Device=" + address + " Status=" + status);
@@ -288,6 +291,7 @@ public final class BluetoothGatt implements BluetoothProfile {
             * Updates the internal value.
             * Updates the internal value.
             * @hide
             * @hide
             */
             */
            @Override
            public void onCharacteristicRead(String address, int status, int handle, byte[] value) {
            public void onCharacteristicRead(String address, int status, int handle, byte[] value) {
                if (VDBG) Log.d(TAG, "onCharacteristicRead() - Device=" + address
                if (VDBG) Log.d(TAG, "onCharacteristicRead() - Device=" + address
                            + " handle=" + handle + " Status=" + status);
                            + " handle=" + handle + " Status=" + status);
@@ -336,6 +340,7 @@ public final class BluetoothGatt implements BluetoothProfile {
             * Let the app know how we did...
             * Let the app know how we did...
             * @hide
             * @hide
             */
             */
            @Override
            public void onCharacteristicWrite(String address, int status, int handle) {
            public void onCharacteristicWrite(String address, int status, int handle) {
                if (VDBG) Log.d(TAG, "onCharacteristicWrite() - Device=" + address
                if (VDBG) Log.d(TAG, "onCharacteristicWrite() - Device=" + address
                            + " handle=" + handle + " Status=" + status);
                            + " handle=" + handle + " Status=" + status);
@@ -380,6 +385,7 @@ public final class BluetoothGatt implements BluetoothProfile {
             * Updates the internal value.
             * Updates the internal value.
             * @hide
             * @hide
             */
             */
            @Override
            public void onNotify(String address, int handle, byte[] value) {
            public void onNotify(String address, int handle, byte[] value) {
                if (VDBG) Log.d(TAG, "onNotify() - Device=" + address + " handle=" + handle);
                if (VDBG) Log.d(TAG, "onNotify() - Device=" + address + " handle=" + handle);


@@ -403,6 +409,7 @@ public final class BluetoothGatt implements BluetoothProfile {
             * Descriptor has been read.
             * Descriptor has been read.
             * @hide
             * @hide
             */
             */
            @Override
            public void onDescriptorRead(String address, int status, int handle, byte[] value) {
            public void onDescriptorRead(String address, int status, int handle, byte[] value) {
                if (VDBG) Log.d(TAG, "onDescriptorRead() - Device=" + address + " handle=" + handle);
                if (VDBG) Log.d(TAG, "onDescriptorRead() - Device=" + address + " handle=" + handle);


@@ -446,6 +453,7 @@ public final class BluetoothGatt implements BluetoothProfile {
             * Descriptor write operation complete.
             * Descriptor write operation complete.
             * @hide
             * @hide
             */
             */
            @Override
            public void onDescriptorWrite(String address, int status, int handle) {
            public void onDescriptorWrite(String address, int status, int handle) {
                if (VDBG) Log.d(TAG, "onDescriptorWrite() - Device=" + address + " handle=" + handle);
                if (VDBG) Log.d(TAG, "onDescriptorWrite() - Device=" + address + " handle=" + handle);


@@ -488,6 +496,7 @@ public final class BluetoothGatt implements BluetoothProfile {
             * Prepared write transaction completed (or aborted)
             * Prepared write transaction completed (or aborted)
             * @hide
             * @hide
             */
             */
            @Override
            public void onExecuteWrite(String address, int status) {
            public void onExecuteWrite(String address, int status) {
                if (VDBG) Log.d(TAG, "onExecuteWrite() - Device=" + address
                if (VDBG) Log.d(TAG, "onExecuteWrite() - Device=" + address
                    + " status=" + status);
                    + " status=" + status);
@@ -510,6 +519,7 @@ public final class BluetoothGatt implements BluetoothProfile {
             * Remote device RSSI has been read
             * Remote device RSSI has been read
             * @hide
             * @hide
             */
             */
            @Override
            public void onReadRemoteRssi(String address, int rssi, int status) {
            public void onReadRemoteRssi(String address, int rssi, int status) {
                if (VDBG) Log.d(TAG, "onReadRemoteRssi() - Device=" + address +
                if (VDBG) Log.d(TAG, "onReadRemoteRssi() - Device=" + address +
                            " rssi=" + rssi + " status=" + status);
                            " rssi=" + rssi + " status=" + status);
@@ -527,6 +537,7 @@ public final class BluetoothGatt implements BluetoothProfile {
             * Callback invoked when the MTU for a given connection changes
             * Callback invoked when the MTU for a given connection changes
             * @hide
             * @hide
             */
             */
            @Override
            public void onConfigureMTU(String address, int mtu, int status) {
            public void onConfigureMTU(String address, int mtu, int status) {
                if (DBG) Log.d(TAG, "onConfigureMTU() - Device=" + address +
                if (DBG) Log.d(TAG, "onConfigureMTU() - Device=" + address +
                            " mtu=" + mtu + " status=" + status);
                            " mtu=" + mtu + " status=" + status);
@@ -539,6 +550,27 @@ public final class BluetoothGatt implements BluetoothProfile {
                    Log.w(TAG, "Unhandled exception in callback", ex);
                    Log.w(TAG, "Unhandled exception in callback", ex);
                }
                }
            }
            }

            /**
             * Callback invoked when the given connection is updated
             * @hide
             */
            @Override
            public void onConnectionUpdated(String address, int interval, int latency,
                                            int timeout, int status) {
                if (DBG) Log.d(TAG, "onConnectionUpdated() - Device=" + address +
                            " interval=" + interval + " latency=" + latency +
                            " timeout=" + timeout + " status=" + status);
                if (!address.equals(mDevice.getAddress())) {
                    return;
                }
                try {
                    mCallback.onConnectionUpdated(BluetoothGatt.this, interval, latency,
                                                  timeout, status);
                } catch (Exception ex) {
                    Log.w(TAG, "Unhandled exception in callback", ex);
                }
            }
        };
        };


    /*package*/ BluetoothGatt(IBluetoothGatt iGatt, BluetoothDevice device,
    /*package*/ BluetoothGatt(IBluetoothGatt iGatt, BluetoothDevice device,
+18 −0
Original line number Original line Diff line number Diff line
@@ -179,4 +179,22 @@ public abstract class BluetoothGattCallback{
     */
     */
    public void onMtuChanged(BluetoothGatt gatt, int mtu, int status) {
    public void onMtuChanged(BluetoothGatt gatt, int mtu, int status) {
    }
    }

    /**
     * Callback indicating the connection parameters were updated.
     *
     * @param gatt GATT client involved
     * @param interval Connection interval used on this connection, 1.25ms unit. Valid
     *            range is from 6 (7.5ms) to 3200 (4000ms).
     * @param latency Slave latency for the connection in number of connection events. Valid
     *            range is from 0 to 499
     * @param timeout Supervision timeout for this connection, in 10ms unit. Valid range is
     *            from 10 (0.1s) to 3200 (32s)
     * @param status {@link BluetoothGatt#GATT_SUCCESS} if the connection has been updated
     *                successfully
     * @hide
     */
    public void onConnectionUpdated(BluetoothGatt gatt, int interval, int latency, int timeout,
                                    int status) {
    }
}
}
+34 −9
Original line number Original line Diff line number Diff line
@@ -65,6 +65,7 @@ public final class BluetoothGattServer implements BluetoothProfile {
             * Application interface registered - app is ready to go
             * Application interface registered - app is ready to go
             * @hide
             * @hide
             */
             */
            @Override
            public void onServerRegistered(int status, int serverIf) {
            public void onServerRegistered(int status, int serverIf) {
                if (DBG) Log.d(TAG, "onServerRegistered() - status=" + status
                if (DBG) Log.d(TAG, "onServerRegistered() - status=" + status
                    + " serverIf=" + serverIf);
                    + " serverIf=" + serverIf);
@@ -79,19 +80,11 @@ public final class BluetoothGattServer implements BluetoothProfile {
                }
                }
            }
            }


            /**
             * Callback reporting an LE scan result.
             * @hide
             */
            public void onScanResult(String address, int rssi, byte[] advData) {
                if (VDBG) Log.d(TAG, "onScanResult() - Device=" + address + " RSSI=" +rssi);
                // no op
            }

            /**
            /**
             * Server connection state changed
             * Server connection state changed
             * @hide
             * @hide
             */
             */
            @Override
            public void onServerConnectionState(int status, int serverIf,
            public void onServerConnectionState(int status, int serverIf,
                                                boolean connected, String address) {
                                                boolean connected, String address) {
                if (DBG) Log.d(TAG, "onServerConnectionState() - status=" + status
                if (DBG) Log.d(TAG, "onServerConnectionState() - status=" + status
@@ -109,6 +102,7 @@ public final class BluetoothGattServer implements BluetoothProfile {
             * Service has been added
             * Service has been added
             * @hide
             * @hide
             */
             */
            @Override
            public void onServiceAdded(int status, BluetoothGattService service) {
            public void onServiceAdded(int status, BluetoothGattService service) {
                if (DBG) Log.d(TAG, "onServiceAdded() - handle=" + service.getInstanceId()
                if (DBG) Log.d(TAG, "onServiceAdded() - handle=" + service.getInstanceId()
                    + " uuid=" + service.getUuid() + " status=" + status);
                    + " uuid=" + service.getUuid() + " status=" + status);
@@ -149,6 +143,7 @@ public final class BluetoothGattServer implements BluetoothProfile {
             * Remote client characteristic read request.
             * Remote client characteristic read request.
             * @hide
             * @hide
             */
             */
            @Override
            public void onCharacteristicReadRequest(String address, int transId,
            public void onCharacteristicReadRequest(String address, int transId,
                            int offset, boolean isLong, int handle) {
                            int offset, boolean isLong, int handle) {
                if (VDBG) Log.d(TAG, "onCharacteristicReadRequest() - handle=" + handle);
                if (VDBG) Log.d(TAG, "onCharacteristicReadRequest() - handle=" + handle);
@@ -171,6 +166,7 @@ public final class BluetoothGattServer implements BluetoothProfile {
             * Remote client descriptor read request.
             * Remote client descriptor read request.
             * @hide
             * @hide
             */
             */
            @Override
            public void onDescriptorReadRequest(String address, int transId,
            public void onDescriptorReadRequest(String address, int transId,
                            int offset, boolean isLong, int handle) {
                            int offset, boolean isLong, int handle) {
                if (VDBG) Log.d(TAG, "onCharacteristicReadRequest() - handle=" + handle);
                if (VDBG) Log.d(TAG, "onCharacteristicReadRequest() - handle=" + handle);
@@ -193,6 +189,7 @@ public final class BluetoothGattServer implements BluetoothProfile {
             * Remote client characteristic write request.
             * Remote client characteristic write request.
             * @hide
             * @hide
             */
             */
            @Override
            public void onCharacteristicWriteRequest(String address, int transId,
            public void onCharacteristicWriteRequest(String address, int transId,
                            int offset, int length, boolean isPrep, boolean needRsp,
                            int offset, int length, boolean isPrep, boolean needRsp,
                            int handle, byte[] value) {
                            int handle, byte[] value) {
@@ -218,6 +215,7 @@ public final class BluetoothGattServer implements BluetoothProfile {
             * Remote client descriptor write request.
             * Remote client descriptor write request.
             * @hide
             * @hide
             */
             */
            @Override
            public void onDescriptorWriteRequest(String address, int transId, int offset,
            public void onDescriptorWriteRequest(String address, int transId, int offset,
                            int length, boolean isPrep, boolean needRsp, int handle, byte[] value) {
                            int length, boolean isPrep, boolean needRsp, int handle, byte[] value) {
                if (VDBG) Log.d(TAG, "onDescriptorWriteRequest() - handle=" + handle);
                if (VDBG) Log.d(TAG, "onDescriptorWriteRequest() - handle=" + handle);
@@ -241,6 +239,7 @@ public final class BluetoothGattServer implements BluetoothProfile {
             * Execute pending writes.
             * Execute pending writes.
             * @hide
             * @hide
             */
             */
            @Override
            public void onExecuteWrite(String address, int transId,
            public void onExecuteWrite(String address, int transId,
                                       boolean execWrite) {
                                       boolean execWrite) {
                if (DBG) Log.d(TAG, "onExecuteWrite() - "
                if (DBG) Log.d(TAG, "onExecuteWrite() - "
@@ -261,6 +260,7 @@ public final class BluetoothGattServer implements BluetoothProfile {
             * A notification/indication has been sent.
             * A notification/indication has been sent.
             * @hide
             * @hide
             */
             */
            @Override
            public void onNotificationSent(String address, int status) {
            public void onNotificationSent(String address, int status) {
                if (VDBG) Log.d(TAG, "onNotificationSent() - "
                if (VDBG) Log.d(TAG, "onNotificationSent() - "
                    + "device=" + address + ", status=" + status);
                    + "device=" + address + ", status=" + status);
@@ -279,6 +279,7 @@ public final class BluetoothGattServer implements BluetoothProfile {
             * The MTU for a connection has changed
             * The MTU for a connection has changed
             * @hide
             * @hide
             */
             */
            @Override
            public void onMtuChanged(String address, int mtu) {
            public void onMtuChanged(String address, int mtu) {
                if (DBG) Log.d(TAG, "onMtuChanged() - "
                if (DBG) Log.d(TAG, "onMtuChanged() - "
                    + "device=" + address + ", mtu=" + mtu);
                    + "device=" + address + ", mtu=" + mtu);
@@ -297,6 +298,7 @@ public final class BluetoothGattServer implements BluetoothProfile {
             * The PHY for a connection was updated
             * The PHY for a connection was updated
             * @hide
             * @hide
             */
             */
            @Override
            public void onPhyUpdate(String address, int txPhy, int rxPhy, int status) {
            public void onPhyUpdate(String address, int txPhy, int rxPhy, int status) {
                if (DBG) Log.d(TAG, "onPhyUpdate() - " + "device=" + address + ", txPHy=" + txPhy
                if (DBG) Log.d(TAG, "onPhyUpdate() - " + "device=" + address + ", txPHy=" + txPhy
                    + ", rxPHy=" + rxPhy);
                    + ", rxPHy=" + rxPhy);
@@ -315,6 +317,7 @@ public final class BluetoothGattServer implements BluetoothProfile {
             * The PHY for a connection was read
             * The PHY for a connection was read
             * @hide
             * @hide
             */
             */
            @Override
            public void onPhyRead(String address, int txPhy, int rxPhy, int status) {
            public void onPhyRead(String address, int txPhy, int rxPhy, int status) {
                if (DBG) Log.d(TAG, "onPhyUpdate() - " + "device=" + address + ", txPHy=" + txPhy
                if (DBG) Log.d(TAG, "onPhyUpdate() - " + "device=" + address + ", txPHy=" + txPhy
                    + ", rxPHy=" + rxPhy);
                    + ", rxPHy=" + rxPhy);
@@ -328,6 +331,28 @@ public final class BluetoothGattServer implements BluetoothProfile {
                    Log.w(TAG, "Unhandled exception: " + ex);
                    Log.w(TAG, "Unhandled exception: " + ex);
                }
                }
            }
            }

            /**
             * Callback invoked when the given connection is updated
             * @hide
             */
            @Override
            public void onConnectionUpdated(String address, int interval, int latency,
                                            int timeout, int status) {
                if (DBG) Log.d(TAG, "onConnectionUpdated() - Device=" + address +
                            " interval=" + interval + " latency=" + latency +
                            " timeout=" + timeout + " status=" + status);
                BluetoothDevice device = mAdapter.getRemoteDevice(address);
                if (device == null) return;

                try {
                    mCallback.onConnectionUpdated(device, interval, latency,
                                                  timeout, status);
                } catch (Exception ex) {
                    Log.w(TAG, "Unhandled exception: " + ex);
                }
            }

        };
        };


    /**
    /**
+19 −0
Original line number Original line Diff line number Diff line
@@ -184,4 +184,23 @@ public abstract class BluetoothGattServerCallback {
     */
     */
    public void onPhyRead(BluetoothDevice device, int txPhy, int rxPhy, int status) {
    public void onPhyRead(BluetoothDevice device, int txPhy, int rxPhy, int status) {
    }
    }

    /**
     * Callback indicating the connection parameters were updated.
     *
     * @param device The remote device involved
     * @param interval Connection interval used on this connection, 1.25ms unit. Valid
     *            range is from 6 (7.5ms) to 3200 (4000ms).
     * @param latency Slave latency for the connection in number of connection events. Valid
     *            range is from 0 to 499
     * @param timeout Supervision timeout for this connection, in 10ms unit. Valid range is
     *            from 10 (0.1s) to 3200 (32s)
     * @param status {@link BluetoothGatt#GATT_SUCCESS} if the connection has been updated
     *                successfully
     * @hide
     */
    public void onConnectionUpdated(BluetoothDevice gatt, int interval, int latency, int timeout,
                                    int status) {
    }

}
}
+2 −0
Original line number Original line Diff line number Diff line
@@ -37,4 +37,6 @@ oneway interface IBluetoothGattCallbackExt {
    void onNotify(in String address, in int handle, in byte[] value);
    void onNotify(in String address, in int handle, in byte[] value);
    void onReadRemoteRssi(in String address, in int rssi, in int status);
    void onReadRemoteRssi(in String address, in int rssi, in int status);
    void onConfigureMTU(in String address, in int mtu, in int status);
    void onConfigureMTU(in String address, in int mtu, in int status);
    void onConnectionUpdated(in String address, in int interval, in int latency,
                             in int timeout, in int status);
}
}
Loading