From 34040bbd5d9cc2ded5193095d5d4b618c84c2713 Mon Sep 17 00:00:00 2001 From: chen0088 Date: Mon, 20 May 2024 14:52:21 +0800 Subject: [PATCH] Add inspection switch Signed-off-by: chen0088 --- .../managersink/include/daudio_sink_manager.h | 3 ++- .../managersink/src/daudio_sink_manager.cpp | 22 ++++++++++--------- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/services/audiomanager/managersink/include/daudio_sink_manager.h b/services/audiomanager/managersink/include/daudio_sink_manager.h index 7902e1d2..a78776c2 100644 --- a/services/audiomanager/managersink/include/daudio_sink_manager.h +++ b/services/audiomanager/managersink/include/daudio_sink_manager.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022-2023 Huawei Device Co., Ltd. + * Copyright (c) 2022-2024 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -92,6 +92,7 @@ private: void *pRHandler_ = nullptr; bool isSensitive_ = false; bool isSameAccount_ = false; + bool isCheckSecLevel_ = false; sptr ipcSinkCallback_ = nullptr; std::shared_ptr initCallback_; }; diff --git a/services/audiomanager/managersink/src/daudio_sink_manager.cpp b/services/audiomanager/managersink/src/daudio_sink_manager.cpp index 2a614f0e..cafc375e 100644 --- a/services/audiomanager/managersink/src/daudio_sink_manager.cpp +++ b/services/audiomanager/managersink/src/daudio_sink_manager.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022-2023 Huawei Device Co., Ltd. + * Copyright (c) 2022-2024 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -515,15 +515,17 @@ int32_t DAudioSinkManager::VerifySecurityLevel(const std::string &devId) return ERR_DH_AUDIO_FAILED; } - std::string sinkDevId = ""; - ret = GetLocalDeviceNetworkId(sinkDevId); - if (ret != DH_SUCCESS) { - DHLOGE("GetLocalDeviceNetworkId failed, ret: %{public}d", ret); - return ret; - } - if (isSensitive_ && !CheckDeviceSecurityLevel(devId, sinkDevId)) { - DHLOGE("Check device security level failed!"); - return ERR_DH_AUDIO_FAILED; + if (isCheckSecLevel_) { + std::string sinkDevId = ""; + ret = GetLocalDeviceNetworkId(sinkDevId); + if (ret != DH_SUCCESS) { + DHLOGE("GetLocalDeviceNetworkId failed, ret: %{public}d", ret); + return ret; + } + if (isSensitive_ && !CheckDeviceSecurityLevel(devId, sinkDevId)) { + DHLOGE("Check device security level failed!"); + return ERR_DH_AUDIO_FAILED; + } } return DH_SUCCESS; } -- Gitee