diff --git a/audiohandler/src/daudio_handler.cpp b/audiohandler/src/daudio_handler.cpp index 23220413f78fdb02230481e04f3c6c839a1a536e..bf451890b1f367bfbfa77746dafc1a0ca7b67ce8 100644 --- a/audiohandler/src/daudio_handler.cpp +++ b/audiohandler/src/daudio_handler.cpp @@ -140,7 +140,7 @@ std::vector DAudioHandler::RealQuery(const std::string &dataType) cJSON_AddNumberToObject(infoJson, INTERRUPT_GROUP_ID, dev->interruptGroupId_); cJSON_AddNumberToObject(infoJson, VOLUME_GROUP_ID, dev->volumeGroupId_); cJSON_AddStringToObject(infoJson, KEY_DATATYPE, dataType.c_str()); - dhItem.dhId = AddDhIdPrefix(std::to_string(dhId)); + dhItem.dhId = std::to_string(dhId); char *jsonInfo = cJSON_Print(infoJson); if (jsonInfo == NULL) { DHLOGE("Failed to create JSON data."); @@ -152,7 +152,7 @@ std::vector DAudioHandler::RealQuery(const std::string &dataType) DHLOGD("Query result: dhId: %{public}d, subtype: %{public}s, attrs: %{public}s.", dhId, dhItem.subtype.c_str(), jsonInfo); if (dhId == DEFAULT_RENDER_ID) { - dhItem.dhId = AddDhIdPrefix(std::to_string(LOW_LATENCY_RENDER_ID)); + dhItem.dhId = std::to_string(LOW_LATENCY_RENDER_ID); dhItemVec.push_back(dhItem); DHLOGD("Query result: dhId: %{public}d, attrs: %{public}s.", LOW_LATENCY_RENDER_ID, jsonInfo); } diff --git a/common/include/daudio_util.h b/common/include/daudio_util.h index 07a42e57beccbc4a8b1f85dda749e17337ed9c80..de3ecdaa443263faa4e3669b87085f370f4cc905 100644 --- a/common/include/daudio_util.h +++ b/common/include/daudio_util.h @@ -55,8 +55,6 @@ void SaveFile(std::string fileName, uint8_t *audioData, int32_t size); std::string GetCJsonString(const char *key, const char *value); std::string ParseStringFromArgs(std::string args, const char *key); std::string GetEventNameByType(const int32_t eventType); -std::string AddDhIdPrefix(const std::string &dhId); -std::string ReduceDhIdPrefix(const std::string &dhId); template bool GetSysPara(const char *key, T &value); diff --git a/common/src/daudio_util.cpp b/common/src/daudio_util.cpp index 38b270c023caba3c2e73a35e782efa17d7c6a7d0..adef28dc27643fd58ef120f4fe840074e955a042 100644 --- a/common/src/daudio_util.cpp +++ b/common/src/daudio_util.cpp @@ -490,35 +490,6 @@ std::string ParseStringFromArgs(std::string args, const char *key) return content; } -std::string AddDhIdPrefix(const std::string &dhId) -{ - std::string prefix = "Audio_"; - size_t pos = dhId.find(prefix); - DHLOGD("Append the prefix. The current dhId is %{public}s.", dhId.c_str()); - if (pos != std::string::npos) { - DHLOGD("No need to add prefix."); - return dhId; - } else { - prefix.append(dhId); - DHLOGD("After append the prefix. The current dhId is %{public}s.", prefix.c_str()); - return prefix; - } -} - -std::string ReduceDhIdPrefix(const std::string &dhId) -{ - std::string prefix = "Audio_"; - size_t pos = dhId.find(prefix); - DHLOGD("Delete the prefix. The current dhId is %{public}s.", dhId.c_str()); - if (pos != std::string::npos) { - DHLOGD("After delete the prefix. The current dhId is %{public}s.", dhId.substr(prefix.size()).c_str()); - return dhId.substr(prefix.size()); - } else { - DHLOGD("No need to delete prefix."); - return dhId; - } -} - template bool GetSysPara(const char *key, T &value) { diff --git a/common/test/unittest/src/daudio_utils_test.cpp b/common/test/unittest/src/daudio_utils_test.cpp index d1ac4d3be7d4da6997d44d25ae4fa80ca2a0dd52..37b60bc9964e467b120f1edd78e2492e207f8e68 100644 --- a/common/test/unittest/src/daudio_utils_test.cpp +++ b/common/test/unittest/src/daudio_utils_test.cpp @@ -311,23 +311,9 @@ HWTEST_F(DAudioUtilsTest, DAudioUtilTest_007, TestSize.Level1) EXPECT_EQ(true, CheckDevIdIsLegal(tempDevIdStr)); } -/** - * @tc.name: DAudioLogTest_009 - * @tc.desc: Verify the AddDhIdPrefix and ReduceDhIdPrefix function. - * @tc.type: FUNC - * @tc.require: AR000H0E5U - */ -HWTEST_F(DAudioUtilsTest, DAudioUtilTest_009, TestSize.Level1) -{ - EXPECT_EQ(AddDhIdPrefix("1394302"), "Audio_1394302"); - EXPECT_EQ(AddDhIdPrefix("Audio_1394302"), "Audio_1394302"); - EXPECT_EQ(ReduceDhIdPrefix("Audio_1394302"), "1394302"); - EXPECT_EQ(ReduceDhIdPrefix("1394302"), "1394302"); -} - /** * @tc.name: DAudioLogTest_010 - * @tc.desc: Verify the AddDhIdPrefix and ReduceDhIdPrefix function. + * @tc.desc: Verify the cjson function. * @tc.type: FUNC * @tc.require: AR000H0E5U */ @@ -351,7 +337,7 @@ HWTEST_F(DAudioUtilsTest, DAudioUtilTest_010, TestSize.Level1) /** * @tc.name: DAudioLogTest_011 - * @tc.desc: Verify the AddDhIdPrefix and ReduceDhIdPrefix function. + * @tc.desc: Verify the cjson function. * @tc.type: FUNC * @tc.require: AR000H0E5U */ @@ -375,7 +361,7 @@ HWTEST_F(DAudioUtilsTest, DAudioUtilTest_011, TestSize.Level1) /** * @tc.name: DAudioLogTest_012 - * @tc.desc: Verify the AddDhIdPrefix and ReduceDhIdPrefix function. + * @tc.desc: Verify the IsAudioParam function. * @tc.type: FUNC * @tc.require: AR000H0E5U */ @@ -396,7 +382,7 @@ HWTEST_F(DAudioUtilsTest, DAudioUtilTest_012, TestSize.Level1) /** * @tc.name: DAudioLogTest_013 - * @tc.desc: Verify the AddDhIdPrefix and ReduceDhIdPrefix function. + * @tc.desc: Verify the IsParamEnabled function. * @tc.type: FUNC * @tc.require: AR000H0E5U */ @@ -409,7 +395,7 @@ HWTEST_F(DAudioUtilsTest, DAudioUtilTest_013, TestSize.Level1) /** * @tc.name: DAudioLogTest_014 - * @tc.desc: Verify the AddDhIdPrefix and ReduceDhIdPrefix function. + * @tc.desc: Verify the GetSysPara function. * @tc.type: FUNC * @tc.require: AR000H0E5U */ @@ -424,7 +410,7 @@ HWTEST_F(DAudioUtilsTest, DAudioUtilTest_014, TestSize.Level1) /** * @tc.name: DAudioLogTest_015 - * @tc.desc: Verify the AddDhIdPrefix and ReduceDhIdPrefix function. + * @tc.desc: Verify the AbsoluteSleep function. * @tc.type: FUNC * @tc.require: AR000H0E5U */ diff --git a/interfaces/inner_kits/native_cpp/audio_sink/src/daudio_sink_handler.cpp b/interfaces/inner_kits/native_cpp/audio_sink/src/daudio_sink_handler.cpp index 59ec8812e6a5dc2c723905b34f38ffcb038f648c..bd6ee6f2579e71d6db1d54adb93ea5a38b78f8fe 100644 --- a/interfaces/inner_kits/native_cpp/audio_sink/src/daudio_sink_handler.cpp +++ b/interfaces/inner_kits/native_cpp/audio_sink/src/daudio_sink_handler.cpp @@ -101,7 +101,7 @@ int32_t DAudioSinkHandler::SubscribeLocalHardware(const std::string &dhId, const if (dhId.length() > DAUDIO_MAX_DEVICE_ID_LEN) { return ERR_DH_AUDIO_SA_DEVID_ILLEGAL; } - std::string reduceDhId = ReduceDhIdPrefix(dhId); + std::string reduceDhId = dhId; int32_t ret = dAudioSinkProxy_->SubscribeLocalHardware(reduceDhId, param); return ret; } @@ -114,7 +114,7 @@ int32_t DAudioSinkHandler::UnsubscribeLocalHardware(const std::string &dhId) if (dhId.length() > DAUDIO_MAX_DEVICE_ID_LEN) { return ERR_DH_AUDIO_SA_DEVID_ILLEGAL; } - std::string reduceDhId = ReduceDhIdPrefix(dhId); + std::string reduceDhId = dhId; int32_t ret = dAudioSinkProxy_->UnsubscribeLocalHardware(reduceDhId); return ret; } diff --git a/interfaces/inner_kits/native_cpp/audio_source/src/daudio_ipc_callback.cpp b/interfaces/inner_kits/native_cpp/audio_source/src/daudio_ipc_callback.cpp index 5b50e516312e989a01df5a816b3c007eae08a6b2..ce68d631402b4e2a78bdce0dd0004129535c2444 100644 --- a/interfaces/inner_kits/native_cpp/audio_source/src/daudio_ipc_callback.cpp +++ b/interfaces/inner_kits/native_cpp/audio_source/src/daudio_ipc_callback.cpp @@ -39,7 +39,7 @@ int32_t DAudioIpcCallback::OnNotifyRegResult(const std::string &devId, const std std::lock_guard registerLck(registerMapMtx_); auto iter = registerCallbackMap_.find(reqId); if (iter != registerCallbackMap_.end()) { - std::string reduceDhId = AddDhIdPrefix(dhId); + std::string reduceDhId = dhId; if (iter->second != nullptr) { iter->second->OnRegisterResult(devId, reduceDhId, status, resultData); } @@ -64,7 +64,7 @@ int32_t DAudioIpcCallback::OnNotifyUnregResult(const std::string &devId, const s std::lock_guard registerLck(unregisterMapMtx_); auto iter = unregisterCallbackMap_.find(reqId); if (iter != unregisterCallbackMap_.end()) { - std::string reduceDhId = AddDhIdPrefix(dhId); + std::string reduceDhId = dhId; if (iter->second != nullptr) { iter->second->OnUnregisterResult(devId, reduceDhId, status, resultData); } diff --git a/interfaces/inner_kits/native_cpp/audio_source/src/daudio_source_handler.cpp b/interfaces/inner_kits/native_cpp/audio_source/src/daudio_source_handler.cpp index d7a5c3343bcb0acd1ea270c5eeb0fb49d65ae7e9..9563ab41c484625d71b4fdf5985771448d636eac 100644 --- a/interfaces/inner_kits/native_cpp/audio_source/src/daudio_source_handler.cpp +++ b/interfaces/inner_kits/native_cpp/audio_source/src/daudio_source_handler.cpp @@ -108,7 +108,7 @@ int32_t DAudioSourceHandler::RegisterDistributedHardware(const std::string &devI std::string reqId = GetRandomID(); dAudioIpcCallback_->PushRegisterCallback(reqId, callback); - std::string reduceDhId = ReduceDhIdPrefix(dhId); + std::string reduceDhId = dhId; return dAudioSourceProxy_->RegisterDistributedHardware(devId, reduceDhId, param, reqId); } @@ -126,7 +126,7 @@ int32_t DAudioSourceHandler::UnregisterDistributedHardware(const std::string &de std::string reqId = GetRandomID(); dAudioIpcCallback_->PushUnregisterCallback(reqId, callback); - std::string reduceDhId = ReduceDhIdPrefix(dhId); + std::string reduceDhId = dhId; return dAudioSourceProxy_->UnregisterDistributedHardware(devId, reduceDhId, reqId); } @@ -140,7 +140,7 @@ int32_t DAudioSourceHandler::ConfigDistributedHardware(const std::string &devId, if (devId.length() > DAUDIO_MAX_DEVICE_ID_LEN || dhId.length() > DAUDIO_MAX_DEVICE_ID_LEN) { return ERR_DH_AUDIO_SA_DEVID_ILLEGAL; } - std::string reduceDhId = ReduceDhIdPrefix(dhId); + std::string reduceDhId = dhId; return dAudioSourceProxy_->ConfigDistributedHardware(devId, reduceDhId, key, value); } diff --git a/services/audiomanager/managersource/src/daudio_source_dev.cpp b/services/audiomanager/managersource/src/daudio_source_dev.cpp index 300c50c92d274c975cb85d1bb62e43367028cd5f..f153a4f5739857cf4e9549734835b387d957ab95 100644 --- a/services/audiomanager/managersource/src/daudio_source_dev.cpp +++ b/services/audiomanager/managersource/src/daudio_source_dev.cpp @@ -867,7 +867,7 @@ int32_t DAudioSourceDev::TaskOpenDSpeaker(const std::string &args) DHLOGE("Task Open DSpeaker Execute failed, error code %{public}d.", ret); return ret; } - NotifyFwkRunning(devId_, AddDhIdPrefix(std::to_string(dhId))); + NotifyFwkRunning(devId_, std::to_string(dhId)); cJSON_Delete(jAudioParam); return DH_SUCCESS; } @@ -973,7 +973,7 @@ int32_t DAudioSourceDev::TaskCloseDSpeaker(const std::string &args) return ret; } NotifyHDF(NOTIFY_CLOSE_SPEAKER_RESULT, HDF_EVENT_RESULT_SUCCESS, dhId); - NotifyFwkIdle(devId_, AddDhIdPrefix(std::to_string(dhId))); + NotifyFwkIdle(devId_, std::to_string(dhId)); return DH_SUCCESS; } @@ -1043,7 +1043,7 @@ int32_t DAudioSourceDev::TaskOpenDMic(const std::string &args) return ret; } NotifyHDF(NOTIFY_OPEN_MIC_RESULT, HDF_EVENT_RESULT_SUCCESS, dhId); - NotifyFwkRunning(devId_, AddDhIdPrefix(std::to_string(dhId))); + NotifyFwkRunning(devId_, std::to_string(dhId)); cJSON_Delete(jAudioParam); return DH_SUCCESS; } @@ -1090,7 +1090,7 @@ int32_t DAudioSourceDev::TaskCloseDMic(const std::string &args) return ret; } NotifyHDF(NOTIFY_CLOSE_MIC_RESULT, HDF_EVENT_RESULT_SUCCESS, dhId); - NotifyFwkIdle(devId_, AddDhIdPrefix(std::to_string(dhId))); + NotifyFwkIdle(devId_, std::to_string(dhId)); return DH_SUCCESS; }