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

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

Merge "Revert "Make close part of the BluetoothProfile interface""

parents 74e4b438 fbbbc47b
Loading
Loading
Loading
Loading
+2 −5
Original line number Diff line number Diff line
@@ -47,6 +47,7 @@ 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.
@@ -289,12 +290,8 @@ public final class BluetoothA2dp implements BluetoothProfile {
        mProfileConnector.connect(context, listener);
    }

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

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

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

+106 −7
Original line number Diff line number Diff line
@@ -3750,19 +3750,118 @@ 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 unusedProfile
     * @param profile
     * @param proxy Profile proxy object
     */
    @SuppressLint({"AndroidFrameworkRequiresPermission", "AndroidFrameworkBluetoothPermission"})
    public void closeProfileProxy(int unusedProfile, BluetoothProfile proxy) {
    @SuppressLint({
            "AndroidFrameworkRequiresPermission",
            "AndroidFrameworkBluetoothPermission"
    })
    public void closeProfileProxy(int profile, BluetoothProfile proxy) {
        if (proxy == null) {
            return;
        }
        proxy.close();

        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;
        }
    }

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

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

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

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