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

Commit 556aa155 authored by Yan Han's avatar Yan Han
Browse files

Implement soundbar volume UI for TV panels.

This is done by adopting adjust-only absolute volume behavior when the
connected amplifier is able to send <Report Audio Status>. Adjust-only
absolute volume behavior supports volume tracking and automatically
displays volume UI when the volume level is updated in AudioService.

In HdmiControlService, adoption of this behavior is implemented as a
special case in the logic for adopting absolute volume behavior:
- Absolute volume behavior is currently adopted when a TV panel or
  playback device is able to track AND set the percentage volume level
  of the System Audio device.
- Adjust-only absolute volume behavior will be adopted when a TV panel
  can track, but not set, the volume level of the System Audio device.

The only behavioral difference in HdmiControlService when using
adjust-only AVB, compared to regular AVB, is that it does not send <Set
Audio Volume Level> to the System Audio device.

Bug: 240663266
Test: atest TvToAudioSystemAvbTest PlaybackDeviceToTvAvbTest PlaybackDeviceToAudioSystemAvbTest
Change-Id: I05465cd0eab2f3c3464bf41c1194cdc3be7af4bf
parent 71afeaa6
Loading
Loading
Loading
Loading
+6 −3
Original line number Original line Diff line number Diff line
@@ -17,10 +17,13 @@
package com.android.server.hdmi;
package com.android.server.hdmi;


/**
/**
 * Action to query and track the audio status of the System Audio device when enabling or using
 * Action to query and track the audio status of the System Audio device when using
 * absolute volume behavior. Must be removed when AVB is disabled. Performs two main functions:
 * absolute volume behavior, or adjust-only absolute volume behavior. Must be removed when
 * neither behavior is used.
 *
 * Performs two main functions:
 * 1. When enabling AVB: queries the starting audio status of the System Audio device and
 * 1. When enabling AVB: queries the starting audio status of the System Audio device and
 *    enables the feature upon receiving a response.
 *    adopts the appropriate volume behavior upon receiving a response.
 * 2. While AVB is enabled: monitors <Report Audio Status> messages from the System Audio device and
 * 2. While AVB is enabled: monitors <Report Audio Status> messages from the System Audio device and
 *    notifies AudioService if the audio status changes.
 *    notifies AudioService if the audio status changes.
 */
 */
+11 −0
Original line number Original line Diff line number Diff line
@@ -61,4 +61,15 @@ public interface AudioDeviceVolumeManagerWrapper {
            @NonNull @CallbackExecutor Executor executor,
            @NonNull @CallbackExecutor Executor executor,
            @NonNull AudioDeviceVolumeManager.OnAudioDeviceVolumeChangedListener vclistener,
            @NonNull AudioDeviceVolumeManager.OnAudioDeviceVolumeChangedListener vclistener,
            boolean handlesVolumeAdjustment);
            boolean handlesVolumeAdjustment);

    /**
     * Wrapper for {@link AudioDeviceVolumeManager#setDeviceAbsoluteVolumeAdjustOnlyBehavior(
     * AudioDeviceAttributes, VolumeInfo, Executor, OnAudioDeviceVolumeChangedListener, boolean)}
     */
    void setDeviceAbsoluteVolumeAdjustOnlyBehavior(
            @NonNull AudioDeviceAttributes device,
            @NonNull VolumeInfo volume,
            @NonNull @CallbackExecutor Executor executor,
            @NonNull AudioDeviceVolumeManager.OnAudioDeviceVolumeChangedListener vclistener,
            boolean handlesVolumeAdjustment);
}
}
+11 −0
Original line number Original line Diff line number Diff line
@@ -67,4 +67,15 @@ public class DefaultAudioDeviceVolumeManagerWrapper
        mAudioDeviceVolumeManager.setDeviceAbsoluteVolumeBehavior(device, volume, executor,
        mAudioDeviceVolumeManager.setDeviceAbsoluteVolumeBehavior(device, volume, executor,
                vclistener, handlesVolumeAdjustment);
                vclistener, handlesVolumeAdjustment);
    }
    }

    @Override
    public void setDeviceAbsoluteVolumeAdjustOnlyBehavior(
            @NonNull AudioDeviceAttributes device,
            @NonNull VolumeInfo volume,
            @NonNull @CallbackExecutor Executor executor,
            @NonNull AudioDeviceVolumeManager.OnAudioDeviceVolumeChangedListener vclistener,
            boolean handlesVolumeAdjustment) {
        mAudioDeviceVolumeManager.setDeviceAbsoluteVolumeAdjustOnlyBehavior(device, volume,
                executor, vclistener, handlesVolumeAdjustment);
    }
}
}
+6 −0
Original line number Original line Diff line number Diff line
@@ -1012,17 +1012,23 @@ abstract class HdmiCecLocalDevice extends HdmiLocalDevice {
        action.start();
        action.start();
    }
    }


    @ServiceThreadOnly
    void addAvbAudioStatusAction(int targetAddress) {
    void addAvbAudioStatusAction(int targetAddress) {
        assertRunOnServiceThread();
        if (!hasAction(AbsoluteVolumeAudioStatusAction.class)) {
        if (!hasAction(AbsoluteVolumeAudioStatusAction.class)) {
            addAndStartAction(new AbsoluteVolumeAudioStatusAction(this, targetAddress));
            addAndStartAction(new AbsoluteVolumeAudioStatusAction(this, targetAddress));
        }
        }
    }
    }


    @ServiceThreadOnly
    void removeAvbAudioStatusAction() {
    void removeAvbAudioStatusAction() {
        assertRunOnServiceThread();
        removeAction(AbsoluteVolumeAudioStatusAction.class);
        removeAction(AbsoluteVolumeAudioStatusAction.class);
    }
    }


    @ServiceThreadOnly
    void updateAvbVolume(int volumeIndex) {
    void updateAvbVolume(int volumeIndex) {
        assertRunOnServiceThread();
        for (AbsoluteVolumeAudioStatusAction action :
        for (AbsoluteVolumeAudioStatusAction action :
                getActions(AbsoluteVolumeAudioStatusAction.class)) {
                getActions(AbsoluteVolumeAudioStatusAction.class)) {
            action.updateVolume(volumeIndex);
            action.updateVolume(volumeIndex);
+1 −1
Original line number Original line Diff line number Diff line
@@ -66,7 +66,7 @@ import java.util.stream.Collectors;
/**
/**
 * Represent a logical device of type TV residing in Android system.
 * Represent a logical device of type TV residing in Android system.
 */
 */
final class HdmiCecLocalDeviceTv extends HdmiCecLocalDevice {
public final class HdmiCecLocalDeviceTv extends HdmiCecLocalDevice {
    private static final String TAG = "HdmiCecLocalDeviceTv";
    private static final String TAG = "HdmiCecLocalDeviceTv";


    // Whether ARC is available or not. "true" means that ARC is established between TV and
    // Whether ARC is available or not. "true" means that ARC is established between TV and
Loading