diff --git a/audio/core/all-versions/default/PrimaryDevice.cpp b/audio/core/all-versions/default/PrimaryDevice.cpp index 679f85dad3..11c1c5a4df 100644 --- a/audio/core/all-versions/default/PrimaryDevice.cpp +++ b/audio/core/all-versions/default/PrimaryDevice.cpp @@ -203,6 +203,9 @@ Return PrimaryDevice::setMode(AudioMode mode) { case AudioMode::RINGTONE: case AudioMode::IN_CALL: case AudioMode::IN_COMMUNICATION: +#if MAJOR_VERSION >= 6 + case AudioMode::CALL_SCREEN: +#endif break; // Valid values default: return Result::INVALID_ARGUMENTS; diff --git a/audio/core/all-versions/vts/functional/4.0/AudioPrimaryHidlHalTest.cpp b/audio/core/all-versions/vts/functional/4.0/AudioPrimaryHidlHalTest.cpp index 709b7cd369..b0eb2e0cfb 100644 --- a/audio/core/all-versions/vts/functional/4.0/AudioPrimaryHidlHalTest.cpp +++ b/audio/core/all-versions/vts/functional/4.0/AudioPrimaryHidlHalTest.cpp @@ -244,7 +244,13 @@ TEST_P(OutputStreamTest, updateSourceMetadata) { TEST_P(AudioPrimaryHidlTest, setMode) { doc::test("Make sure setMode always succeeds if mode is valid and fails otherwise"); // Test Invalid values - for (int mode : {-2, -1, int(AudioMode::IN_COMMUNICATION) + 1}) { +#if MAJOR_VERSION >= 6 + int maxMode = int(AudioMode::CALL_SCREEN); +#else + int maxMode = int(AudioMode::IN_COMMUNICATION); +#endif + + for (int mode : {-2, -1, maxMode + 1}) { ASSERT_RESULT(Result::INVALID_ARGUMENTS, getDevice()->setMode(AudioMode(mode))) << "mode=" << mode; } @@ -253,6 +259,10 @@ TEST_P(AudioPrimaryHidlTest, setMode) { AudioMode::NORMAL /* Make sure to leave the test in normal mode */}) { ASSERT_OK(getDevice()->setMode(mode)) << "mode=" << toString(mode); } + // AudioMode::CALL_SCREEN as support is optional +#if MAJOR_VERSION >= 6 + ASSERT_RESULT(okOrNotSupportedOrInvalidArgs, getDevice()->setMode(AudioMode::CALL_SCREEN)); +#endif } TEST_P(AudioPrimaryHidlTest, setBtHfpSampleRate) {