Loading services/audiopolicy/tests/AudioPolicyTestManager.h +1 −0 Original line number Diff line number Diff line Loading @@ -37,6 +37,7 @@ class AudioPolicyTestManager : public AudioPolicyManager { using AudioPolicyManager::getDirectProfilesForAttributes; using AudioPolicyManager::setDeviceConnectionState; using AudioPolicyManager::deviceToAudioPort; using AudioPolicyManager::handleDeviceConfigChange; uint32_t getAudioPortGeneration() const { return mAudioPortGeneration; } }; Loading services/audiopolicy/tests/audiopolicymanager_tests.cpp +24 −0 Original line number Diff line number Diff line Loading @@ -919,6 +919,30 @@ TEST_F(AudioPolicyManagerTestWithConfigurationFile, ListAudioPortsHasFlags) { EXPECT_TRUE(foundVoipTx); } TEST_F(AudioPolicyManagerTestWithConfigurationFile, HandleDeviceConfigChange) { { const auto prevCounter = mClient->getRoutingUpdatedCounter(); EXPECT_EQ(NO_ERROR, mManager->setDeviceConnectionState(AUDIO_DEVICE_OUT_BLUETOOTH_A2DP, AUDIO_POLICY_DEVICE_STATE_AVAILABLE, "", "", AUDIO_FORMAT_LDAC)); const auto currCounter = mClient->getRoutingUpdatedCounter(); EXPECT_GT(currCounter, prevCounter); } { const auto prevCounter = mClient->getRoutingUpdatedCounter(); // Update device configuration EXPECT_EQ(NO_ERROR, mManager->handleDeviceConfigChange(AUDIO_DEVICE_OUT_BLUETOOTH_A2DP, "" /*address*/, "" /*name*/, AUDIO_FORMAT_AAC)); // As mClient marks isReconfigA2dpSupported to false, device state needs to be toggled for // config changes to take effect const auto currCounter = mClient->getRoutingUpdatedCounter(); EXPECT_GT(currCounter, prevCounter); } } using PolicyMixTuple = std::tuple<audio_usage_t, audio_source_t, uint32_t>; class AudioPolicyManagerTestDynamicPolicy : public AudioPolicyManagerTestWithConfigurationFile { Loading services/audiopolicy/tests/resources/test_audio_policy_configuration.xml +5 −0 Original line number Diff line number Diff line Loading @@ -71,6 +71,9 @@ <devicePort tagName="BT SCO Headset Mic" type="AUDIO_DEVICE_IN_BLUETOOTH_SCO_HEADSET" role="source" address="hfp_client_in"> </devicePort> <devicePort tagName="BT A2DP Out" type="AUDIO_DEVICE_OUT_BLUETOOTH_A2DP" role="sink" encodedFormats="AUDIO_FORMAT_LDAC AUDIO_FORMAT_APTX AUDIO_FORMAT_APTX_HD AUDIO_FORMAT_AAC AUDIO_FORMAT_SBC"> </devicePort> </devicePorts> <routes> <route type="mix" sink="Speaker" Loading @@ -85,6 +88,8 @@ sources="mixport_bt_hfp_output,voip_rx"/> <route type="mix" sink="mixport_bt_hfp_input" sources="BT SCO Headset Mic"/> <route type="mix" sink="BT A2DP Out" sources="primary output"/> </routes> </module> Loading Loading
services/audiopolicy/tests/AudioPolicyTestManager.h +1 −0 Original line number Diff line number Diff line Loading @@ -37,6 +37,7 @@ class AudioPolicyTestManager : public AudioPolicyManager { using AudioPolicyManager::getDirectProfilesForAttributes; using AudioPolicyManager::setDeviceConnectionState; using AudioPolicyManager::deviceToAudioPort; using AudioPolicyManager::handleDeviceConfigChange; uint32_t getAudioPortGeneration() const { return mAudioPortGeneration; } }; Loading
services/audiopolicy/tests/audiopolicymanager_tests.cpp +24 −0 Original line number Diff line number Diff line Loading @@ -919,6 +919,30 @@ TEST_F(AudioPolicyManagerTestWithConfigurationFile, ListAudioPortsHasFlags) { EXPECT_TRUE(foundVoipTx); } TEST_F(AudioPolicyManagerTestWithConfigurationFile, HandleDeviceConfigChange) { { const auto prevCounter = mClient->getRoutingUpdatedCounter(); EXPECT_EQ(NO_ERROR, mManager->setDeviceConnectionState(AUDIO_DEVICE_OUT_BLUETOOTH_A2DP, AUDIO_POLICY_DEVICE_STATE_AVAILABLE, "", "", AUDIO_FORMAT_LDAC)); const auto currCounter = mClient->getRoutingUpdatedCounter(); EXPECT_GT(currCounter, prevCounter); } { const auto prevCounter = mClient->getRoutingUpdatedCounter(); // Update device configuration EXPECT_EQ(NO_ERROR, mManager->handleDeviceConfigChange(AUDIO_DEVICE_OUT_BLUETOOTH_A2DP, "" /*address*/, "" /*name*/, AUDIO_FORMAT_AAC)); // As mClient marks isReconfigA2dpSupported to false, device state needs to be toggled for // config changes to take effect const auto currCounter = mClient->getRoutingUpdatedCounter(); EXPECT_GT(currCounter, prevCounter); } } using PolicyMixTuple = std::tuple<audio_usage_t, audio_source_t, uint32_t>; class AudioPolicyManagerTestDynamicPolicy : public AudioPolicyManagerTestWithConfigurationFile { Loading
services/audiopolicy/tests/resources/test_audio_policy_configuration.xml +5 −0 Original line number Diff line number Diff line Loading @@ -71,6 +71,9 @@ <devicePort tagName="BT SCO Headset Mic" type="AUDIO_DEVICE_IN_BLUETOOTH_SCO_HEADSET" role="source" address="hfp_client_in"> </devicePort> <devicePort tagName="BT A2DP Out" type="AUDIO_DEVICE_OUT_BLUETOOTH_A2DP" role="sink" encodedFormats="AUDIO_FORMAT_LDAC AUDIO_FORMAT_APTX AUDIO_FORMAT_APTX_HD AUDIO_FORMAT_AAC AUDIO_FORMAT_SBC"> </devicePort> </devicePorts> <routes> <route type="mix" sink="Speaker" Loading @@ -85,6 +88,8 @@ sources="mixport_bt_hfp_output,voip_rx"/> <route type="mix" sink="mixport_bt_hfp_input" sources="BT SCO Headset Mic"/> <route type="mix" sink="BT A2DP Out" sources="primary output"/> </routes> </module> Loading