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

Commit 936eec00 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Add java document in BluetoothCallback"

parents ccd2c615 31fdd4a9
Loading
Loading
Loading
Loading
+96 −0
Original line number Diff line number Diff line
@@ -22,14 +22,110 @@ package com.android.settingslib.bluetooth;
 * UI to receive events from {@link BluetoothEventManager}.
 */
public interface BluetoothCallback {
    /**
     * It will be called when the state of the local Bluetooth adapter has been changed.
     * It is listening {@link android.bluetooth.BluetoothAdapter#ACTION_STATE_CHANGED}.
     * For example, Bluetooth has been turned on or off.
     *
     * @param bluetoothState the current Bluetooth state, the possible values are:
     * {@link android.bluetooth.BluetoothAdapter#STATE_OFF},
     * {@link android.bluetooth.BluetoothAdapter#STATE_TURNING_ON},
     * {@link android.bluetooth.BluetoothAdapter#STATE_ON},
     * {@link android.bluetooth.BluetoothAdapter#STATE_TURNING_OFF}.
     */
    void onBluetoothStateChanged(int bluetoothState);

    /**
     * It will be called when the local Bluetooth adapter has started
     * or finished the remote device discovery process.
     * It is listening {@link android.bluetooth.BluetoothAdapter#ACTION_DISCOVERY_STARTED} and
     * {@link android.bluetooth.BluetoothAdapter#ACTION_DISCOVERY_FINISHED}.
     *
     * @param started indicate the current process is started or finished.
     */
    void onScanningStateChanged(boolean started);

    /**
     * It will be called in following situations:
     * 1. In scanning mode, when a new device has been found.
     * 2. When a profile service is connected and existing connected devices has been found.
     * This API only invoked once for each device and all devices will be cached in
     * {@link CachedBluetoothDeviceManager}.
     *
     * @param cachedDevice the Bluetooth device.
     */
    void onDeviceAdded(CachedBluetoothDevice cachedDevice);

    /**
     * It will be called when a remote device that was
     * found in the last discovery and is not found in the current discovery.
     * It is listening {@link android.bluetooth.BluetoothDevice#ACTION_DISAPPEARED}
     *
     * @param cachedDevice the Bluetooth device.
     */
    void onDeviceDeleted(CachedBluetoothDevice cachedDevice);

    /**
     * It will be called when bond state of a remote device is changed.
     * It is listening {@link android.bluetooth.BluetoothDevice#ACTION_BOND_STATE_CHANGED}
     *
     * @param cachedDevice the Bluetooth device.
     * @param bondState the Bluetooth device bond state, the possible values are:
     * {@link android.bluetooth.BluetoothDevice#BOND_NONE},
     * {@link android.bluetooth.BluetoothDevice#BOND_BONDING},
     * {@link android.bluetooth.BluetoothDevice#BOND_BONDED}.
     */
    void onDeviceBondStateChanged(CachedBluetoothDevice cachedDevice, int bondState);

    /**
     * It will be called in following situations:
     * 1. When the adapter is not connected to any profiles of any remote devices
     * and it attempts a connection to a profile.
     * 2. When the adapter disconnects from the last profile of the last device.
     * It is listening {@link android.bluetooth.BluetoothAdapter#ACTION_CONNECTION_STATE_CHANGED}
     *
     * @param cachedDevice the Bluetooth device.
     * @param state the Bluetooth device connection state, the possible values are:
     * {@link android.bluetooth.BluetoothAdapter#STATE_DISCONNECTED},
     * {@link android.bluetooth.BluetoothAdapter#STATE_CONNECTING},
     * {@link android.bluetooth.BluetoothAdapter#STATE_CONNECTED},
     * {@link android.bluetooth.BluetoothAdapter#STATE_DISCONNECTING}.
     */
    void onConnectionStateChanged(CachedBluetoothDevice cachedDevice, int state);

    /**
     * It will be called when device been set as active for {@code bluetoothProfile}
     * It is listening in following intent:
     * {@link android.bluetooth.BluetoothA2dp#ACTION_ACTIVE_DEVICE_CHANGED}
     * {@link android.bluetooth.BluetoothHeadset#ACTION_ACTIVE_DEVICE_CHANGED}
     * {@link android.bluetooth.BluetoothHearingAid#ACTION_ACTIVE_DEVICE_CHANGED}
     *
     * @param activeDevice the active Bluetooth device.
     * @param bluetoothProfile the profile of active Bluetooth device.
     */
    void onActiveDeviceChanged(CachedBluetoothDevice activeDevice, int bluetoothProfile);

    /**
     * It will be called in following situations:
     * 1. When the call state on the device is changed.
     * 2. When the audio connection state of the A2DP profile is changed.
     * It is listening in following intent:
     * {@link android.bluetooth.BluetoothHeadset#ACTION_AUDIO_STATE_CHANGED}
     * {@link android.telephony.TelephonyManager#ACTION_PHONE_STATE_CHANGED}
     */
    void onAudioModeChanged();

    /**
     * It will be called when one of the bluetooth device profile connection state is changed.
     *
     * @param cachedDevice the active Bluetooth device.
     * @param state the BluetoothProfile connection state, the possible values are:
     * {@link android.bluetooth.BluetoothProfile#STATE_CONNECTED},
     * {@link android.bluetooth.BluetoothProfile#STATE_CONNECTING},
     * {@link android.bluetooth.BluetoothProfile#STATE_DISCONNECTED},
     * {@link android.bluetooth.BluetoothProfile#STATE_DISCONNECTING}.
     * @param bluetoothProfile the BluetoothProfile id.
     */
    default void onProfileConnectionStateChanged(CachedBluetoothDevice cachedDevice,
            int state, int bluetoothProfile) {
    }