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

Commit bdb465dd authored by Etienne Ruffieux's avatar Etienne Ruffieux
Browse files

Remove unused AVRCP hidden API

AudioManager is informed of absolute volume support
directly by AvrcpTargetService. This API has no known usage
and isn't implemented properly so we can remove it safely.

Having a binder for AVRCP isn't necessary for now as only
the setAvrcpAbsoluteVolume API is used. Other interactions
are made directly between the service and the framework.

Bug: 301242682
Tag: #feature
Test: atest BluetoothA2dpTest
Change-Id: I53edc9b61b17eed91578182381633daeb0e9d3df
parent 0cfacee8
Loading
Loading
Loading
Loading
+0 −16
Original line number Diff line number Diff line
@@ -17,12 +17,10 @@
package com.android.bluetooth.a2dp;

import static android.Manifest.permission.BLUETOOTH_CONNECT;

import static com.android.bluetooth.Utils.checkCallerTargetSdk;
import static com.android.bluetooth.Utils.enforceBluetoothPrivilegedPermission;
import static com.android.bluetooth.Utils.enforceCdmAssociation;
import static com.android.bluetooth.Utils.hasBluetoothPrivilegedPermission;

import static java.util.Objects.requireNonNull;

import android.annotation.NonNull;
@@ -706,15 +704,7 @@ public class A2dpService extends ProfileService {
                .getProfileConnectionPolicy(device, BluetoothProfile.A2DP);
    }

    public boolean isAvrcpAbsoluteVolumeSupported() {
        // TODO (apanicke): Add a hook here for the AvrcpTargetService.
        return false;
    }


    public void setAvrcpAbsoluteVolume(int volume) {
        // TODO (apanicke): Instead of using A2DP as a middleman for volume changes, add a binder
        // service to the new AVRCP Profile and have the audio manager use that instead.
        if (mFactory.getAvrcpTargetService() != null) {
            mFactory.getAvrcpTargetService().sendVolumeChanged(volume);
            return;
@@ -1454,12 +1444,6 @@ public class A2dpService extends ProfileService {
            }
        }

        @Override
        public void isAvrcpAbsoluteVolumeSupported(SynchronousResultReceiver receiver) {
            // TODO (apanicke): Add a hook here for the AvrcpTargetService.
            receiver.send(false);
        }

        @Override
        public void setAvrcpAbsoluteVolume(int volume, AttributionSource source) {
            A2dpService service = getService(source);
+0 −27
Original line number Diff line number Diff line
@@ -21,7 +21,6 @@ import static android.bluetooth.BluetoothUtils.getSyncTimeout;
import android.annotation.IntDef;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.RequiresNoPermission;
import android.annotation.RequiresPermission;
import android.annotation.SdkConstant;
import android.annotation.SdkConstant.SdkConstantType;
@@ -669,32 +668,6 @@ public final class BluetoothA2dp implements BluetoothProfile {
        return defaultValue;
    }

    /**
     * Checks if Avrcp device supports the absolute volume feature.
     *
     * @return true if device supports absolute volume
     * @hide
     */
    @RequiresNoPermission
    public boolean isAvrcpAbsoluteVolumeSupported() {
        if (DBG) Log.d(TAG, "isAvrcpAbsoluteVolumeSupported");
        final IBluetoothA2dp service = getService();
        final boolean defaultValue = false;
        if (service == null) {
            Log.w(TAG, "Proxy not attached to service");
            if (DBG) log(Log.getStackTraceString(new Throwable()));
        } else if (isEnabled()) {
            try {
                final SynchronousResultReceiver<Boolean> recv = SynchronousResultReceiver.get();
                service.isAvrcpAbsoluteVolumeSupported(recv);
                return recv.awaitResultNoInterrupt(getSyncTimeout()).getValue(defaultValue);
            } catch (RemoteException | TimeoutException e) {
                Log.e(TAG, e.toString() + "\n" + Log.getStackTraceString(new Throwable()));
            }
        }
        return defaultValue;
    }

    /**
     * Tells remote device to set an absolute volume. Only if absolute volume is supported
     *
+0 −2
Original line number Diff line number Diff line
@@ -48,8 +48,6 @@ oneway interface IBluetoothA2dp {
    void setConnectionPolicy(in BluetoothDevice device, int connectionPolicy, in AttributionSource attributionSource, in SynchronousResultReceiver receiver);
    @JavaPassthrough(annotation="@android.annotation.RequiresPermission(allOf={android.Manifest.permission.BLUETOOTH_CONNECT,android.Manifest.permission.BLUETOOTH_PRIVILEGED})")
    void getConnectionPolicy(in BluetoothDevice device, in AttributionSource attributionSource, in SynchronousResultReceiver receiver);
    @JavaPassthrough(annotation="@android.annotation.RequiresNoPermission")
    void isAvrcpAbsoluteVolumeSupported(in SynchronousResultReceiver receiver);
    @JavaPassthrough(annotation="@android.annotation.RequiresPermission(allOf={android.Manifest.permission.BLUETOOTH_CONNECT,android.Manifest.permission.BLUETOOTH_PRIVILEGED})")
    oneway void setAvrcpAbsoluteVolume(int volume, in AttributionSource attributionSource);
    @JavaPassthrough(annotation="@android.annotation.RequiresPermission(android.Manifest.permission.BLUETOOTH_CONNECT)")