summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--services/core/java/com/android/server/hdmi/AbsoluteVolumeAudioStatusAction.java21
-rw-r--r--services/tests/servicestests/src/com/android/server/hdmi/BaseAbsoluteVolumeBehaviorTest.java10
-rw-r--r--services/tests/servicestests/src/com/android/server/hdmi/BaseTvToAudioSystemAvbTest.java11
3 files changed, 25 insertions, 17 deletions
diff --git a/services/core/java/com/android/server/hdmi/AbsoluteVolumeAudioStatusAction.java b/services/core/java/com/android/server/hdmi/AbsoluteVolumeAudioStatusAction.java
index 9172dc02a4ac..82786001ab68 100644
--- a/services/core/java/com/android/server/hdmi/AbsoluteVolumeAudioStatusAction.java
+++ b/services/core/java/com/android/server/hdmi/AbsoluteVolumeAudioStatusAction.java
@@ -32,10 +32,6 @@ final class AbsoluteVolumeAudioStatusAction extends HdmiCecFeatureAction {
private int mInitialAudioStatusRetriesLeft = 2;
- // Flag to notify AudioService of the next audio status reported,
- // regardless of whether the audio status changed.
- private boolean mForceNextAudioStatusUpdate = false;
-
private static final int STATE_WAIT_FOR_INITIAL_AUDIO_STATUS = 1;
private static final int STATE_MONITOR_AUDIO_STATUS = 2;
@@ -74,13 +70,11 @@ final class AbsoluteVolumeAudioStatusAction extends HdmiCecFeatureAction {
return false;
}
-
/**
* If AVB has been enabled, send <Give Audio Status> and notify AudioService of the response.
*/
void requestAndUpdateAudioStatus() {
if (mState == STATE_MONITOR_AUDIO_STATUS) {
- mForceNextAudioStatusUpdate = true;
sendGiveAudioStatus();
}
}
@@ -104,15 +98,20 @@ final class AbsoluteVolumeAudioStatusAction extends HdmiCecFeatureAction {
localDevice().getService().enableAbsoluteVolumeBehavior(audioStatus);
mState = STATE_MONITOR_AUDIO_STATUS;
} else if (mState == STATE_MONITOR_AUDIO_STATUS) {
- if (mForceNextAudioStatusUpdate
- || audioStatus.getVolume() != mLastAudioStatus.getVolume()) {
+ // On TV panels, we notify AudioService even if neither volume nor mute state changed.
+ // This ensures that the user sees volume UI if they tried to adjust the AVR's volume,
+ // even if the new volume level is the same as the previous one.
+ boolean notifyAvbVolumeToShowUi = localDevice().getService().isTvDevice()
+ && audioStatus.equals(mLastAudioStatus);
+
+ if (audioStatus.getVolume() != mLastAudioStatus.getVolume()
+ || notifyAvbVolumeToShowUi) {
localDevice().getService().notifyAvbVolumeChange(audioStatus.getVolume());
}
- if (mForceNextAudioStatusUpdate
- || audioStatus.getMute() != mLastAudioStatus.getMute()) {
+
+ if (audioStatus.getMute() != mLastAudioStatus.getMute()) {
localDevice().getService().notifyAvbMuteChange(audioStatus.getMute());
}
- mForceNextAudioStatusUpdate = false;
}
mLastAudioStatus = audioStatus;
diff --git a/services/tests/servicestests/src/com/android/server/hdmi/BaseAbsoluteVolumeBehaviorTest.java b/services/tests/servicestests/src/com/android/server/hdmi/BaseAbsoluteVolumeBehaviorTest.java
index e7c3cab7f872..a63d01b6225a 100644
--- a/services/tests/servicestests/src/com/android/server/hdmi/BaseAbsoluteVolumeBehaviorTest.java
+++ b/services/tests/servicestests/src/com/android/server/hdmi/BaseAbsoluteVolumeBehaviorTest.java
@@ -528,9 +528,15 @@ public abstract class BaseAbsoluteVolumeBehaviorTest {
clearInvocations(mAudioManager);
// Repeat of earlier message: sets neither volume nor mute
+ // Exception: On TV, volume is set to ensure that UI is shown
receiveReportAudioStatus(32, false);
- verify(mAudioManager, never()).setStreamVolume(eq(AudioManager.STREAM_MUSIC), eq(8),
- anyInt());
+ if (getDeviceType() == HdmiDeviceInfo.DEVICE_TV) {
+ verify(mAudioManager).setStreamVolume(eq(AudioManager.STREAM_MUSIC), eq(8),
+ anyInt());
+ } else {
+ verify(mAudioManager, never()).setStreamVolume(eq(AudioManager.STREAM_MUSIC), eq(8),
+ anyInt());
+ }
verify(mAudioManager, never()).adjustStreamVolume(eq(AudioManager.STREAM_MUSIC),
eq(AudioManager.ADJUST_UNMUTE), anyInt());
clearInvocations(mAudioManager);
diff --git a/services/tests/servicestests/src/com/android/server/hdmi/BaseTvToAudioSystemAvbTest.java b/services/tests/servicestests/src/com/android/server/hdmi/BaseTvToAudioSystemAvbTest.java
index cb530c0c711c..a410702e202d 100644
--- a/services/tests/servicestests/src/com/android/server/hdmi/BaseTvToAudioSystemAvbTest.java
+++ b/services/tests/servicestests/src/com/android/server/hdmi/BaseTvToAudioSystemAvbTest.java
@@ -190,12 +190,13 @@ public abstract class BaseTvToAudioSystemAvbTest extends BaseAbsoluteVolumeBehav
eq(AudioManager.ADJUST_UNMUTE), anyInt());
clearInvocations(mAudioManager);
- // Repeat of earlier message: sets neither volume nor mute
+ // Repeat of earlier message: sets volume only (to ensure volume UI is shown)
receiveReportAudioStatus(32, false);
- verify(mAudioManager, never()).setStreamVolume(eq(AudioManager.STREAM_MUSIC), eq(8),
+ verify(mAudioManager).setStreamVolume(eq(AudioManager.STREAM_MUSIC), eq(8),
anyInt());
verify(mAudioManager, never()).adjustStreamVolume(eq(AudioManager.STREAM_MUSIC),
eq(AudioManager.ADJUST_UNMUTE), anyInt());
+ clearInvocations(mAudioManager);
// Volume not within range [0, 100]: sets neither volume nor mute
receiveReportAudioStatus(127, true);
@@ -391,14 +392,16 @@ public abstract class BaseTvToAudioSystemAvbTest extends BaseAbsoluteVolumeBehav
INITIAL_SYSTEM_AUDIO_DEVICE_STATUS.getMute()));
mTestLooper.dispatchAll();
- // HdmiControlService calls setStreamVolume and adjustStreamVolume to trigger volume UI
+ // HdmiControlService calls setStreamVolume to trigger volume UI
verify(mAudioManager).setStreamVolume(
eq(AudioManager.STREAM_MUSIC),
// Volume level is rescaled to the max volume of STREAM_MUSIC
eq(INITIAL_SYSTEM_AUDIO_DEVICE_STATUS.getVolume()
* STREAM_MUSIC_MAX_VOLUME / AudioStatus.MAX_VOLUME),
eq(AudioManager.FLAG_ABSOLUTE_VOLUME | AudioManager.FLAG_SHOW_UI));
- verify(mAudioManager).adjustStreamVolume(
+ // adjustStreamVolume is not called because mute status didn't change,
+ // and setStreamVolume is sufficient to show volume UI
+ verify(mAudioManager, never()).adjustStreamVolume(
eq(AudioManager.STREAM_MUSIC),
eq(AudioManager.ADJUST_UNMUTE),
eq(AudioManager.FLAG_ABSOLUTE_VOLUME | AudioManager.FLAG_SHOW_UI));