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

Commit 8ccf2cb1 authored by William Escande's avatar William Escande Committed by Automerger Merge Worker
Browse files

Merge "Make close part of the BluetoothProfile interface" am: ac1ece01 am: e7147f9a

parents 25de519a e7147f9a
Loading
Loading
Loading
Loading
+5 −2
Original line number Original line Diff line number Diff line
@@ -47,7 +47,6 @@ import java.util.ArrayList;
import java.util.List;
import java.util.List;
import java.util.concurrent.TimeoutException;
import java.util.concurrent.TimeoutException;



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


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


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


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


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


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


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


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