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

Commit ac1ece01 authored by William Escande's avatar William Escande Committed by Gerrit Code Review
Browse files

Merge "Make close part of the BluetoothProfile interface"

parents 2992d5bd 3886f1a7
Loading
Loading
Loading
Loading
+5 −2
Original line number Diff line number Diff line
@@ -47,7 +47,6 @@ import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.TimeoutException;


/**
 * This class provides the public APIs to control the Bluetooth A2DP
 * profile.
@@ -290,8 +289,12 @@ public final class BluetoothA2dp implements BluetoothProfile {
        mProfileConnector.connect(context, listener);
    }

    /**
     * @hide
     */
    @UnsupportedAppUsage
    /*package*/ void close() {
    @Override
    public void close() {
        mProfileConnector.disconnect();
    }

+3 −1
Original line number Diff line number Diff line
@@ -105,7 +105,9 @@ public final class BluetoothA2dpSink implements BluetoothProfile {
        mProfileConnector.connect(context, listener);
    }

    /*package*/ void close() {
    /** @hide */
    @Override
    public void close() {
        mProfileConnector.disconnect();
    }

+7 −106
Original line number Diff line number Diff line
@@ -3750,118 +3750,19 @@ public final class BluetoothAdapter {
    /**
     * Close the connection of the profile proxy to the Service.
     *
     * <p> Clients should call this when they are no longer using
     * the proxy obtained from {@link #getProfileProxy}.
     * Profile can be one of  {@link BluetoothProfile#HEADSET} or {@link BluetoothProfile#A2DP}
     * <p>Clients should call this when they are no longer using the proxy obtained from {@link
     * #getProfileProxy}. Profile can be one of {@link BluetoothProfile#HEADSET} or {@link
     * BluetoothProfile#A2DP}
     *
     * @param profile
     * @param unusedProfile
     * @param proxy Profile proxy object
     */
    @SuppressLint({
            "AndroidFrameworkRequiresPermission",
            "AndroidFrameworkBluetoothPermission"
    })
    public void closeProfileProxy(int profile, BluetoothProfile proxy) {
    @SuppressLint({"AndroidFrameworkRequiresPermission", "AndroidFrameworkBluetoothPermission"})
    public void closeProfileProxy(int unusedProfile, BluetoothProfile proxy) {
        if (proxy == null) {
            return;
        }

        switch (profile) {
            case BluetoothProfile.HEADSET:
                BluetoothHeadset headset = (BluetoothHeadset) proxy;
                headset.close();
                break;
            case BluetoothProfile.A2DP:
                BluetoothA2dp a2dp = (BluetoothA2dp) proxy;
                a2dp.close();
                break;
            case BluetoothProfile.A2DP_SINK:
                BluetoothA2dpSink a2dpSink = (BluetoothA2dpSink) proxy;
                a2dpSink.close();
                break;
            case BluetoothProfile.AVRCP_CONTROLLER:
                BluetoothAvrcpController avrcp = (BluetoothAvrcpController) proxy;
                avrcp.close();
                break;
            case BluetoothProfile.HID_HOST:
                BluetoothHidHost iDev = (BluetoothHidHost) proxy;
                iDev.close();
                break;
            case BluetoothProfile.PAN:
                BluetoothPan pan = (BluetoothPan) proxy;
                pan.close();
                break;
            case BluetoothProfile.PBAP:
                BluetoothPbap pbap = (BluetoothPbap) proxy;
                pbap.close();
                break;
            case BluetoothProfile.GATT:
                BluetoothGatt gatt = (BluetoothGatt) proxy;
                gatt.close();
                break;
            case BluetoothProfile.GATT_SERVER:
                BluetoothGattServer gattServer = (BluetoothGattServer) proxy;
                gattServer.close();
                break;
            case BluetoothProfile.MAP:
                BluetoothMap map = (BluetoothMap) proxy;
                map.close();
                break;
            case BluetoothProfile.HEADSET_CLIENT:
                BluetoothHeadsetClient headsetClient = (BluetoothHeadsetClient) proxy;
                headsetClient.close();
                break;
            case BluetoothProfile.SAP:
                BluetoothSap sap = (BluetoothSap) proxy;
                sap.close();
                break;
            case BluetoothProfile.PBAP_CLIENT:
                BluetoothPbapClient pbapClient = (BluetoothPbapClient) proxy;
                pbapClient.close();
                break;
            case BluetoothProfile.MAP_CLIENT:
                BluetoothMapClient mapClient = (BluetoothMapClient) proxy;
                mapClient.close();
                break;
            case BluetoothProfile.HID_DEVICE:
                BluetoothHidDevice hidDevice = (BluetoothHidDevice) proxy;
                hidDevice.close();
                break;
            case BluetoothProfile.HAP_CLIENT:
                BluetoothHapClient HapClient = (BluetoothHapClient) proxy;
                HapClient.close();
                break;
            case BluetoothProfile.HEARING_AID:
                BluetoothHearingAid hearingAid = (BluetoothHearingAid) proxy;
                hearingAid.close();
                break;
            case BluetoothProfile.LE_AUDIO:
                BluetoothLeAudio leAudio = (BluetoothLeAudio) proxy;
                leAudio.close();
                break;
            case BluetoothProfile.LE_AUDIO_BROADCAST:
                BluetoothLeBroadcast leAudioBroadcast = (BluetoothLeBroadcast) proxy;
                leAudioBroadcast.close();
                break;
            case BluetoothProfile.VOLUME_CONTROL:
                BluetoothVolumeControl vcs = (BluetoothVolumeControl) proxy;
                vcs.close();
                break;
            case BluetoothProfile.CSIP_SET_COORDINATOR:
                BluetoothCsipSetCoordinator csipSetCoordinator =
                        (BluetoothCsipSetCoordinator) proxy;
                csipSetCoordinator.close();
                break;
            case BluetoothProfile.LE_CALL_CONTROL:
                BluetoothLeCallControl tbs = (BluetoothLeCallControl) proxy;
                tbs.close();
                break;
            case BluetoothProfile.LE_AUDIO_BROADCAST_ASSISTANT:
                BluetoothLeBroadcastAssistant leAudioBroadcastAssistant =
                        (BluetoothLeBroadcastAssistant) proxy;
                leAudioBroadcastAssistant.close();
                break;
        }
        proxy.close();
    }

    private static final IBluetoothManagerCallback sManagerCallback =
+3 −1
Original line number Diff line number Diff line
@@ -112,7 +112,9 @@ public final class BluetoothAvrcpController implements BluetoothProfile {
        mProfileConnector.connect(context, listener);
    }

    /*package*/ void close() {
    /** @hide */
    @Override
    public void close() {
        mProfileConnector.disconnect();
    }

+2 −3
Original line number Diff line number Diff line
@@ -239,9 +239,8 @@ public final class BluetoothCsipSetCoordinator implements BluetoothProfile, Auto
        close();
    }

    /**
     * @hide
     */
    /** @hide */
    @Override
    public void close() {
        mProfileConnector.disconnect();
    }
Loading