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

Commit 7bb5e3fd authored by Andre Eisenbach's avatar Andre Eisenbach Committed by Android (Google) Code Review
Browse files

Merge "LE: Add notification sent and congestion callbacks (3/4)"

parents 3ada97b0 dadefdad
Loading
Loading
Loading
Loading
+7 −4
Original line number Diff line number Diff line
@@ -2079,12 +2079,15 @@ public final class BluetoothAdapter {
        public void onMultiAdvertiseCallback(int status) {
            // no op
        }
        /**
         * Callback reporting LE ATT MTU.
         * @hide
         */

        @Override
        public void onConfigureMTU(String address, int mtu, int status) {
            // no op
        }

        @Override
        public void onConnectionCongested(String address, boolean congested) {
            // no op
        }
    }
}
+18 −0
Original line number Diff line number Diff line
@@ -85,6 +85,9 @@ public final class BluetoothGatt implements BluetoothProfile {
    /** A write operation exceeds the maximum length of the attribute */
    public static final int GATT_INVALID_ATTRIBUTE_LENGTH = 0xd;

    /** A remote device connection is congested. */
    public static final int GATT_CONNECTION_CONGESTED = 0x8f;

    /** A GATT operation failed, errors other than the above */
    public static final int GATT_FAILURE = 0x101;

@@ -607,6 +610,21 @@ public final class BluetoothGatt implements BluetoothProfile {
                    Log.w(TAG, "Unhandled exception in callback", ex);
                }
            }

            /**
             * Callback indicating the remote device connection is congested.
             * @hide
             */
            public void onConnectionCongested(String address, boolean congested) {
                if (DBG) Log.d(TAG, "onConnectionCongested() - Device=" + address
                        + " congested=" + congested);
                if (!address.equals(mDevice.getAddress())) return;
                try {
                    mCallback.onConnectionCongested(BluetoothGatt.this, congested);
                } catch (Exception ex) {
                    Log.w(TAG, "Unhandled exception in callback", ex);
                }
            }
        };

    /*package*/ BluetoothGatt(Context context, IBluetoothGatt iGatt, BluetoothDevice device,
+15 −0
Original line number Diff line number Diff line
@@ -153,4 +153,19 @@ public abstract class BluetoothGattCallback {
     */
    public void onConfigureMTU(BluetoothGatt gatt, int mtu, int status) {
    }

    /**
     * Callback indicating that a remote device connection congestestion status has changed.
     *
     * An application should refrain from sending additional data to a remote device when
     * a callback is received with the congested flag set to true. Once the congestion status
     * is cleared up, the application will receive an additional callback with the congested
     * flag set to false.
     *
     * @param gatt The GATT client associated with the remote device
     * @param congested true, if the connection is currently congested
     * @hide
     */
    public void onConnectionCongested(BluetoothGatt gatt, boolean congested) {
    }
}
+36 −0
Original line number Diff line number Diff line
@@ -265,6 +265,42 @@ public final class BluetoothGattServer implements BluetoothProfile {
                    Log.w(TAG, "Unhandled exception in callback", ex);
                }
            }

            /**
             * A notification/indication has been sent.
             * @hide
             */
            public void onNotificationSent(String address, int status) {
                if (DBG) Log.d(TAG, "onNotificationSent() - "
                    + "device=" + address + ", status=" + status);

                BluetoothDevice device = mAdapter.getRemoteDevice(address);
                if (device == null) return;

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

            /**
             * Callback indicating the remote device connection is congested.
             * @hide
             */
            public void onConnectionCongested(String address, boolean congested) {
                if (DBG) Log.d(TAG, "onConnectionCongested() - Device=" + address
                        + " congested=" + congested);

                BluetoothDevice device = mAdapter.getRemoteDevice(address);
                if (device == null) return;

                try {
                    mCallback.onConnectionCongested(device, congested);
                } catch (Exception ex) {
                    Log.w(TAG, "Unhandled exception in callback", ex);
                }
            }
        };

    /**
+30 −0
Original line number Diff line number Diff line
@@ -131,4 +131,34 @@ public abstract class BluetoothGattServerCallback {
     */
    public void onExecuteWrite(BluetoothDevice device, int requestId, boolean execute) {
    }

    /**
     * Callback invoked when a notification or indication has been sent to
     * a remote device.
     *
     * <p>When multiple notifications are to be sent, an application must
     * wait for this callback to be received before sending additional
     * notifications.
     *
     * @param device The remote device the notification has been sent to
     * @param status 0 if the operation was successful
     * @hide
     */
    public void onNotificationSent(BluetoothDevice device, int status) {
    }

    /**
     * Callback indicating that a remote device connection congestestion status has changed.
     *
     * An application should refrain from sending additional data (notifications, indications
     * etc.) to a remote device when a callback is received with the congested flag set
     * to true. Once the congestion status is cleared up, the application will receive an
     * additional callback with the congested flag set to false.
     *
     * @param device The remote device that triggered the congestion state change
     * @param congested true, if the connection is currently congested
     * @hide
     */
    public void onConnectionCongested(BluetoothDevice device, boolean congested) {
    }
}
Loading