Claim Active Source during System Audio Mode init by AVR
when the device also has playback type and can't get Active Source. ag/5141907 Bug:112365691 Test: local tested. Change-Id: I42ca55eb6787e4cbb3eea267fc8f6e387961e98c
This commit is contained in:
@@ -114,7 +114,16 @@ public class SystemAudioInitiationActionFromAvr extends HdmiCecFeatureAction {
|
||||
|
||||
private void handleActiveSourceTimeout() {
|
||||
HdmiLogger.debug("Cannot get active source.");
|
||||
audioSystem().checkSupportAndSetSystemAudioMode(false);
|
||||
// If not able to find Active Source and the current device has playbcak functionality,
|
||||
// claim Active Source and start to query TV system audio mode support.
|
||||
if (audioSystem().mService.isPlaybackDevice()) {
|
||||
audioSystem().mService.setAndBroadcastActiveSourceFromOneDeviceType(
|
||||
Constants.ADDR_BROADCAST, getSourcePath());
|
||||
mState = STATE_WAITING_FOR_TV_SUPPORT;
|
||||
queryTvSystemAudioModeSupport();
|
||||
} else {
|
||||
audioSystem().checkSupportAndSetSystemAudioMode(false);
|
||||
}
|
||||
finish();
|
||||
}
|
||||
|
||||
|
||||
@@ -52,6 +52,8 @@ public class SystemAudioInitiationActionFromAvrTest {
|
||||
private int mMsgSetSystemAudioModeCount;
|
||||
private int mQueryTvSystemAudioModeSupportCount;
|
||||
private boolean mArcEnabled;
|
||||
private boolean mIsPlaybackDevice;
|
||||
private boolean mBroadcastActiveSource;
|
||||
|
||||
@Before
|
||||
public void SetUp() {
|
||||
@@ -137,6 +139,17 @@ public class SystemAudioInitiationActionFromAvrTest {
|
||||
int getPhysicalAddress() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
boolean isPlaybackDevice() {
|
||||
return mIsPlaybackDevice;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAndBroadcastActiveSourceFromOneDeviceType(
|
||||
int sourceAddress, int physicalAddress) {
|
||||
mBroadcastActiveSource = true;
|
||||
}
|
||||
};
|
||||
mHdmiCecLocalDeviceAudioSystem =
|
||||
new HdmiCecLocalDeviceAudioSystem(hdmiControlService) {
|
||||
@@ -257,11 +270,31 @@ public class SystemAudioInitiationActionFromAvrTest {
|
||||
assertTrue(mHdmiCecLocalDeviceAudioSystem.isSystemAudioActivated());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIsPlaybackDevice_cannotReceiveActiveSource() {
|
||||
resetTestVariables();
|
||||
mIsPlaybackDevice = true;
|
||||
assertThat(mHdmiCecLocalDeviceAudioSystem.getActiveSource().physicalAddress)
|
||||
.isEqualTo(Constants.INVALID_PHYSICAL_ADDRESS);
|
||||
|
||||
mHdmiCecLocalDeviceAudioSystem.addAndStartAction(
|
||||
new SystemAudioInitiationActionFromAvr(mHdmiCecLocalDeviceAudioSystem));
|
||||
mTestLooper.dispatchAll();
|
||||
|
||||
assertThat(mMsgRequestActiveSourceCount).isEqualTo(1);
|
||||
assertThat(mMsgSetSystemAudioModeCount).isEqualTo(1);
|
||||
assertThat(mQueryTvSystemAudioModeSupportCount).isEqualTo(1);
|
||||
assertThat(mHdmiCecLocalDeviceAudioSystem.isSystemAudioActivated()).isTrue();
|
||||
assertThat(mBroadcastActiveSource).isTrue();
|
||||
}
|
||||
|
||||
private void resetTestVariables() {
|
||||
mMsgRequestActiveSourceCount = 0;
|
||||
mMsgSetSystemAudioModeCount = 0;
|
||||
mQueryTvSystemAudioModeSupportCount = 0;
|
||||
mTryCountBeforeSucceed = 0;
|
||||
mIsPlaybackDevice = false;
|
||||
mBroadcastActiveSource = false;
|
||||
mHdmiCecLocalDeviceAudioSystem.getActiveSource().physicalAddress =
|
||||
Constants.INVALID_PHYSICAL_ADDRESS;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user