diff --git a/services/audio_policy/server/domain/volume/src/audio_adapter_manager.cpp b/services/audio_policy/server/domain/volume/src/audio_adapter_manager.cpp index 0a51874cfbda71c10d9b21fa473be786ecc61017..8601c72324f903e93c5fd2f41d2e09b8709f91d1 100644 --- a/services/audio_policy/server/domain/volume/src/audio_adapter_manager.cpp +++ b/services/audio_policy/server/domain/volume/src/audio_adapter_manager.cpp @@ -2168,6 +2168,7 @@ DeviceVolumeType AudioAdapterManager::GetDeviceCategory(DeviceType deviceType) case DEVICE_TYPE_BLUETOOTH_A2DP: case DEVICE_TYPE_USB_HEADSET: case DEVICE_TYPE_USB_ARM_HEADSET: + case DEVICE_TYPE_NEARLINK: return HEADSET_VOLUME_TYPE; default: return SPEAKER_VOLUME_TYPE; diff --git a/services/audio_policy/test/unittest/audio_pipe_manager_unit_test/src/audio_pipe_manager_unit_test.cpp b/services/audio_policy/test/unittest/audio_pipe_manager_unit_test/src/audio_pipe_manager_unit_test.cpp index c3f640dde4f4d9db185652192eea02a62730f182..1451d7bce0b6f46bb56c2714e55ffd96630ea4e4 100644 --- a/services/audio_policy/test/unittest/audio_pipe_manager_unit_test/src/audio_pipe_manager_unit_test.cpp +++ b/services/audio_policy/test/unittest/audio_pipe_manager_unit_test/src/audio_pipe_manager_unit_test.cpp @@ -1278,5 +1278,33 @@ HWTEST_F(AudioPipeManagerUnitTest, GetAllCapturerStreamDescs_002, TestSize.Level auto result = audioPipeManager->GetAllCapturerStreamDescs(); EXPECT_EQ(result.size(), 0); } + +/** + * @tc.name: IsStreamUsageActive_001 + * @tc.desc: Test IsStreamUsageActive. + * @tc.type: FUNC + */ +HWTEST_F(AudioPipeManagerUnitTest, IsStreamUsageActive_001, TestSize.Level1) +{ + auto audioPipeManager = AudioPipeManager::GetPipeManager(); + audioPipeManager->curPipeList_.clear(); + + std::shared_ptr pipeInfo = std::make_shared(); + pipeInfo->pipeRole_ = PIPE_ROLE_OUTPUT; + std::shared_ptr desc = std::make_shared(); + desc->rendererInfo_.streamUsage = STREAM_USAGE_ALARM; + desc->streamStatus_ = STREAM_STATUS_STARTED; + pipeInfo->streamDescriptors_.push_back(desc); + + audioPipeManager->AddAudioPipeInfo(pipeInfo); + EXPECT_TRUE(audioPipeManager->IsStreamUsageActive(STREAM_USAGE_ALARM)); + EXPECT_FALSE(audioPipeManager->IsStreamUsageActive(STREAM_USAGE_VOICE_RINGTONE)); + + desc->streamStatus_ = STREAM_STATUS_STOPPED; + pipeInfo->streamDescriptors_.push_back(desc); + + audioPipeManager->AddAudioPipeInfo(pipeInfo); + EXPECT_FALSE(audioPipeManager->IsStreamUsageActive(STREAM_USAGE_ALARM)); +} } // namespace AudioStandard } // namespace OHOS \ No newline at end of file