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

Commit d0a8d6f0 authored by jiabin's avatar jiabin
Browse files

Do not use disabled devices when getting output device.

When disabled devies are set for a particular strategy, they are not
supposed to be used for that particular strategy. In that case, when
querying output devices, remove the disabled devices from available
devices list.

Bug: 247045771
Test: manually
Change-Id: I73d1c911b29a25e27914cddb3c15c04f03f485b2
parent 0f9c1a8a
Loading
Loading
Loading
Loading
+18 −1
Original line number Diff line number Diff line
@@ -463,7 +463,7 @@ DeviceVector Engine::getDevicesForStrategyInt(legacy_strategy strategy,
    }

    if (devices.isEmpty()) {
        ALOGV("%s no device found for strategy %d", __func__, strategy);
        ALOGI("%s no device found for strategy %d", __func__, strategy);
        sp<DeviceDescriptor> defaultOutputDevice = getApmObserver()->getDefaultOutputDevice();
        if (defaultOutputDevice != nullptr) {
            devices.add(defaultOutputDevice);
@@ -699,6 +699,18 @@ DeviceVector Engine::getPreferredAvailableDevicesForProductStrategy(
    return preferredAvailableDevVec;
}

DeviceVector Engine::getDisabledDevicesForProductStrategy(
        const DeviceVector &availableOutputDevices, product_strategy_t strategy) const {
    DeviceVector disabledDevices = {};
    AudioDeviceTypeAddrVector disabledDevicesTypeAddr;
    const status_t status = getDevicesForRoleAndStrategy(
            strategy, DEVICE_ROLE_DISABLED, disabledDevicesTypeAddr);
    if (status == NO_ERROR) {
        disabledDevices =
                availableOutputDevices.getDevicesFromDeviceTypeAddrVec(disabledDevicesTypeAddr);
    }
    return disabledDevices;
}

DeviceVector Engine::getDevicesForProductStrategy(product_strategy_t strategy) const {
    const SwAudioOutputCollection& outputs = getApmObserver()->getOutputs();
@@ -722,6 +734,11 @@ DeviceVector Engine::getDevicesForProductStrategy(product_strategy_t strategy) c
        return preferredAvailableDevVec;
    }

    // Remove all disabled devices from the available device list.
    DeviceVector disabledDevVec =
            getDisabledDevicesForProductStrategy(availableOutputDevices, strategy);
    availableOutputDevices.remove(disabledDevVec);

    return getDevicesForStrategyInt(legacyStrategy,
                                    availableOutputDevices,
                                    outputs);
+2 −0
Original line number Diff line number Diff line
@@ -96,6 +96,8 @@ private:
        const DeviceVector& availableOutputDevices, legacy_strategy legacyStrategy) const;
    DeviceVector getPreferredAvailableDevicesForProductStrategy(
        const DeviceVector& availableOutputDevices, product_strategy_t strategy) const;
    DeviceVector getDisabledDevicesForProductStrategy(
        const DeviceVector& availableOutputDevices, product_strategy_t strategy) const;

    DeviceStrategyMap mDevicesForStrategies;