Loading services/core/java/com/android/server/hdmi/AbsoluteVolumeAudioStatusAction.java +10 −11 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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(); } } Loading @@ -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; Loading services/tests/servicestests/src/com/android/server/hdmi/BaseAbsoluteVolumeBehaviorTest.java +8 −2 Original line number Diff line number Diff line Loading @@ -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); 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); Loading services/tests/servicestests/src/com/android/server/hdmi/BaseTvToAudioSystemAvbTest.java +7 −4 Original line number Diff line number Diff line Loading @@ -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); Loading Loading @@ -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)); Loading Loading
services/core/java/com/android/server/hdmi/AbsoluteVolumeAudioStatusAction.java +10 −11 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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(); } } Loading @@ -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; Loading
services/tests/servicestests/src/com/android/server/hdmi/BaseAbsoluteVolumeBehaviorTest.java +8 −2 Original line number Diff line number Diff line Loading @@ -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); 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); Loading
services/tests/servicestests/src/com/android/server/hdmi/BaseTvToAudioSystemAvbTest.java +7 −4 Original line number Diff line number Diff line Loading @@ -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); Loading Loading @@ -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)); Loading