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

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

Merge "AudioService: remove dead BT code" into qt-dev

parents cd43a5f7 58dfb981
Loading
Loading
Loading
Loading
+0 −32
Original line number Diff line number Diff line
@@ -4274,38 +4274,6 @@ public class AudioManager {
        }
    }

     /**
     * Indicate A2DP source or sink active device change and eventually suppress
     * the {@link AudioManager.ACTION_AUDIO_BECOMING_NOISY} intent.
     * This operation is asynchronous but its execution will still be sequentially scheduled
     * relative to calls to {@link #setBluetoothHearingAidDeviceConnectionState(BluetoothDevice,
     * int, boolean, int)} and
     * {@link #handleBluetoothA2dpDeviceConfigChange(BluetoothDevice)}.
     * @param device Bluetooth device connected/disconnected
     * @param state  new connection state (BluetoothProfile.STATE_xxx)
     * @param profile profile for the A2DP device
     * (either {@link android.bluetooth.BluetoothProfile.A2DP} or
     * {@link android.bluetooth.BluetoothProfile.A2DP_SINK})
     * @param a2dpVolume New volume for the connecting device. Does nothing if
     * disconnecting. Pass value -1 in case you want this field to be ignored
     * @param suppressNoisyIntent if true the
     * {@link AudioManager.ACTION_AUDIO_BECOMING_NOISY} intent will not be sent.
     * @return a delay in ms that the caller should wait before broadcasting
     * BluetoothA2dp.ACTION_CONNECTION_STATE_CHANGED intent.
     * {@hide}
     */
    public void handleBluetoothA2dpActiveDeviceChange(
                BluetoothDevice device, int state, int profile,
                boolean suppressNoisyIntent, int a2dpVolume) {
        final IAudioService service = getService();
        try {
            service.handleBluetoothA2dpActiveDeviceChange(device,
                state, profile, suppressNoisyIntent, a2dpVolume);
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
    }

    /** {@hide} */
    public IRingtonePlayer getRingtonePlayer() {
        try {
+0 −3
Original line number Diff line number Diff line
@@ -178,9 +178,6 @@ interface IAudioService {

    void handleBluetoothA2dpDeviceConfigChange(in BluetoothDevice device);

    void handleBluetoothA2dpActiveDeviceChange(in BluetoothDevice device,
            int state, int profile, boolean suppressNoisyIntent, int a2dpVolume);

    @UnsupportedAppUsage
    AudioRoutesInfo startWatchingRoutes(in IAudioRoutesObserver observer);

+1 −29
Original line number Diff line number Diff line
@@ -241,15 +241,6 @@ import com.android.internal.annotations.GuardedBy;
        sendLMsgNoDelay(MSG_L_A2DP_DEVICE_CONNECTION_CHANGE_EXT, SENDMSG_QUEUE, info);
    }

    /*package*/ void postBluetoothA2dpDeviceConfigChangeExt(
            @NonNull BluetoothDevice device,
            @AudioService.BtProfileConnectionState int state, int profile,
            boolean suppressNoisyIntent, int a2dpVolume) {
        final BtDeviceConnectionInfo info = new BtDeviceConnectionInfo(device, state, profile,
                suppressNoisyIntent, a2dpVolume);
        sendLMsgNoDelay(MSG_L_A2DP_ACTIVE_DEVICE_CHANGE_EXT, SENDMSG_QUEUE, info);
    }

    private static final class HearingAidDeviceConnectionInfo {
        final @NonNull BluetoothDevice mDevice;
        final @AudioService.BtProfileConnectionState int mState;
@@ -862,22 +853,6 @@ import com.android.internal.annotations.GuardedBy;
                                info.mDevice, info.mState, info.mSupprNoisy, info.mMusicDevice);
                    }
                } break;
                case MSG_L_A2DP_ACTIVE_DEVICE_CHANGE_EXT: {
                    final BtDeviceConnectionInfo info = (BtDeviceConnectionInfo) msg.obj;
                    AudioService.sDeviceLogger.log((new AudioEventLogger.StringEvent(
                            "handleBluetoothA2dpActiveDeviceChangeExt "
                                    + " state=" + info.mState
                                    // only querying address as this is the only readily available
                                    // field on the device
                                    + " addr=" + info.mDevice.getAddress()
                                    + " prof=" + info.mProfile + " supprNoisy=" + info.mSupprNoisy
                                    + " vol=" + info.mVolume)).printLog(TAG));
                    synchronized (mDeviceStateLock) {
                        mDeviceInventory.handleBluetoothA2dpActiveDeviceChangeExt(
                                info.mDevice, info.mState, info.mProfile,
                                info.mSupprNoisy, info.mVolume);
                    }
                } break;
                default:
                    Log.wtf(TAG, "Invalid message " + msg.what);
            }
@@ -925,10 +900,8 @@ import com.android.internal.annotations.GuardedBy;
    private static final int MSG_L_A2DP_DEVICE_CONNECTION_CHANGE_EXT = 27;
    // process external command to (dis)connect a hearing aid device
    private static final int MSG_L_HEARING_AID_DEVICE_CONNECTION_CHANGE_EXT = 28;
    // process external command to (dis)connect or change active A2DP device
    private static final int MSG_L_A2DP_ACTIVE_DEVICE_CHANGE_EXT = 29;
    // a ScoClient died in BtHelper
    private static final int MSG_L_SCOCLIENT_DIED = 30;
    private static final int MSG_L_SCOCLIENT_DIED = 29;


    private static boolean isMessageHandledUnderWakelock(int msgId) {
@@ -943,7 +916,6 @@ import com.android.internal.annotations.GuardedBy;
            case MSG_L_A2DP_ACTIVE_DEVICE_CHANGE:
            case MSG_L_A2DP_DEVICE_CONNECTION_CHANGE_EXT:
            case MSG_L_HEARING_AID_DEVICE_CONNECTION_CHANGE_EXT:
            case MSG_L_A2DP_ACTIVE_DEVICE_CHANGE_EXT:
                return true;
            default:
                return false;
+0 −43
Original line number Diff line number Diff line
@@ -570,49 +570,6 @@ public final class AudioDeviceInventory {
        }
    }

    /*package*/ void handleBluetoothA2dpActiveDeviceChangeExt(
            @NonNull BluetoothDevice device,
            @AudioService.BtProfileConnectionState int state, int profile,
            boolean suppressNoisyIntent, int a2dpVolume) {
        if (state == BluetoothProfile.STATE_DISCONNECTED) {
            mDeviceBroker.postBluetoothA2dpDeviceConnectionStateSuppressNoisyIntent(
                           device, state, profile, suppressNoisyIntent, a2dpVolume);
            return;
        }
        // state == BluetoothProfile.STATE_CONNECTED
        synchronized (mConnectedDevices) {
            final String address = device.getAddress();
            final int a2dpCodec = mDeviceBroker.getA2dpCodec(device);
            final String deviceKey = DeviceInfo.makeDeviceListKey(
                        AudioSystem.DEVICE_OUT_BLUETOOTH_A2DP, address);
            DeviceInfo deviceInfo = mConnectedDevices.get(deviceKey);
            if (deviceInfo != null) {
                // Device config change for matching A2DP device
                mDeviceBroker.postBluetoothA2dpDeviceConfigChange(device);
                return;
            }
            for (int i = 0; i < mConnectedDevices.size(); i++) {
                deviceInfo = mConnectedDevices.valueAt(i);
                if (deviceInfo.mDeviceType != AudioSystem.DEVICE_OUT_BLUETOOTH_A2DP) {
                    continue;
                }
                // A2DP device exists, handle active device change
                final String existingDevicekey = mConnectedDevices.keyAt(i);
                mConnectedDevices.remove(existingDevicekey);
                mConnectedDevices.put(deviceKey, new DeviceInfo(
                        AudioSystem.DEVICE_OUT_BLUETOOTH_A2DP, BtHelper.getName(device),
                        address, a2dpCodec));
                mDeviceBroker.postA2dpActiveDeviceChange(
                        new BtHelper.BluetoothA2dpDeviceInfo(
                            device, a2dpVolume, a2dpCodec));
                return;
            }
        }
        // New A2DP device connection
        mDeviceBroker.postBluetoothA2dpDeviceConnectionStateSuppressNoisyIntent(
                           device, state, profile, suppressNoisyIntent, a2dpVolume);
    }

    /*package*/ int setWiredDeviceConnectionState(int type, @AudioService.ConnectionState int state,
                                                  String address, String name, String caller) {
        synchronized (mConnectedDevices) {
+0 −21
Original line number Diff line number Diff line
@@ -4382,27 +4382,6 @@ public class AudioService extends IAudioService.Stub
        mDeviceBroker.postBluetoothA2dpDeviceConfigChange(device);
    }

    /**
     * @see AudioManager#handleBluetoothA2dpActiveDeviceChange(BluetoothDevice, int, int,
     *                                                          boolean, int)
     */
    public void handleBluetoothA2dpActiveDeviceChange(
            BluetoothDevice device, int state, int profile, boolean suppressNoisyIntent,
            int a2dpVolume) {
        if (device == null) {
            throw new IllegalArgumentException("Illegal null device");
        }
        if (profile != BluetoothProfile.A2DP && profile != BluetoothProfile.A2DP_SINK) {
            throw new IllegalArgumentException("invalid profile " + profile);
        }
        if (state != BluetoothProfile.STATE_CONNECTED
                && state != BluetoothProfile.STATE_DISCONNECTED) {
            throw new IllegalArgumentException("Invalid state " + state);
        }
        mDeviceBroker.postBluetoothA2dpDeviceConfigChangeExt(device, state, profile,
                suppressNoisyIntent, a2dpVolume);
    }

    private static final int DEVICE_MEDIA_UNMUTED_ON_PLUG =
            AudioSystem.DEVICE_OUT_WIRED_HEADSET | AudioSystem.DEVICE_OUT_WIRED_HEADPHONE |
            AudioSystem.DEVICE_OUT_LINE |