From 926f4eb808475828dc3903ea02d505e96eb16996 Mon Sep 17 00:00:00 2001 From: liuzhongming Date: Sat, 22 Feb 2025 15:14:49 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BB=91=E5=AE=9A=E6=94=AF=E6=8C=81=E6=96=B0?= =?UTF-8?q?=E9=80=9A=E9=81=93=20Signed-off-by:=20liuzhongming=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- common/include/dm_constants.h | 8 + common/src/dm_anonymous.cpp | 2 +- common/src/ipc/standard/ipc_model_codec.cpp | 1 + .../native_cpp/include/dm_device_info.h | 5 + .../kits/js4.0/include/dm_native_util.h | 3 +- .../js4.0/include/native_devicemanager_js.h | 4 +- interfaces/kits/js4.0/src/dm_native_util.cpp | 15 +- .../js4.0/src/native_devicemanager_js.cpp | 14 +- sa_profile/device_manager.cfg | 4 + services/implementation/BUILD.gn | 2 + .../include/authentication/dm_auth_manager.h | 10 +- .../dependency/softbus/softbus_connector.h | 7 + .../dependency/softbus/softbus_session.h | 7 + .../include/i18n/dm_language_manager.h | 40 +++++ .../src/authentication/dm_auth_manager.cpp | 122 ++++++++++++--- .../dependency/softbus/softbus_connector.cpp | 12 ++ .../dependency/softbus/softbus_session.cpp | 27 ++++ .../src/i18n/dm_language_manager.cpp | 148 ++++++++++++++++++ .../service/include/device_manager_service.h | 1 + .../include/softbus/softbus_listener.h | 5 + .../src/advertise/advertise_manager.cpp | 3 + .../service/src/device_manager_service.cpp | 58 +++++-- .../src/device_manager_service_listener.cpp | 34 ++++ .../src/discovery/discovery_manager.cpp | 16 +- .../src/ipc/standard/ipc_cmd_parser.cpp | 1 + .../service/src/softbus/softbus_listener.cpp | 80 +++++++++- .../UTTest_dm_auth_manager_first.cpp | 12 +- .../UTTest_dm_auth_manager_second.cpp | 2 +- .../onsoftbusdevicefound_fuzzer/BUILD.gn | 1 + .../BUILD.gn | 1 + .../onsoftbusdeviceoffline_fuzzer/BUILD.gn | 1 + .../onsoftbusdeviceonline_fuzzer/BUILD.gn | 1 + .../BUILD.gn | 1 + .../publishsoftbuslnn_fuzzer/BUILD.gn | 1 + .../refreshsoftbuslnn_fuzzer/BUILD.gn | 1 + .../BUILD.gn | 1 + .../stoprefreshsoftbuslnn_fuzzer/BUILD.gn | 1 + test/unittest/BUILD.gn | 2 + 38 files changed, 601 insertions(+), 53 deletions(-) create mode 100644 services/implementation/include/i18n/dm_language_manager.h create mode 100644 services/implementation/src/i18n/dm_language_manager.cpp diff --git a/common/include/dm_constants.h b/common/include/dm_constants.h index d145695d0..da6ea708c 100755 --- a/common/include/dm_constants.h +++ b/common/include/dm_constants.h @@ -152,6 +152,7 @@ constexpr const char* DM_CAPABILITY_CASTPLUS = "castPlus"; constexpr const char* DM_CAPABILITY_VIRTUAL_LINK = "virtualLink"; constexpr const char* DM_CAPABILITY_SHARE = "share"; constexpr const char* DM_CAPABILITY_WEAR = "wear"; +constexpr const char* DM_CAPABILITY_OOP = "oop"; constexpr const char* DM_CREDENTIAL_TYPE = "CREDENTIAL_TYPE"; constexpr const char* DM_CREDENTIAL_REQJSONSTR = "CREDENTIAL_REQJSONSTR"; constexpr const char* DM_CREDENTIAL_RETURNJSONSTR = "CREDENTIAL_RETURNJSONSTR"; @@ -262,6 +263,11 @@ constexpr const char* PROCESS_NAME = "PROCESS_NAME"; constexpr const char* PARAM_CLOSE_SESSION_DELAY_SECONDS = "DM_CLOSE_SESSION_DELAY_SECONDS"; constexpr const char* DM_AUTHENTICATION_TYPE = "DM_AUTHENTICATION_TYPE"; +constexpr const char* PARAM_KEY_CONN_SESSIONTYPE = "connSessionType"; +constexpr const char* PARAM_KEY_HML_RELEASETIME = "hmlReleaseTime"; +constexpr const char* PARAM_KEY_HML_ENABLE_160M = "hmlEnable160M"; +constexpr const char* PARAM_KEY_HML_ACTIONID = "hmlActionId"; +const std::string CONN_SESSION_TYPE_HML = "HML"; // screen state constexpr int32_t DM_SCREEN_UNKNOWN = -1; constexpr int32_t DM_SCREEN_ON = 0; @@ -291,6 +297,8 @@ constexpr int32_t MAX_ICON_SIZE = 4 * 1024 * 1024; constexpr int32_t MAX_CONTAINER_SIZE = 500; // One year 365 * 24 * 60 * 60 constexpr int32_t MAX_ALWAYS_ALLOW_SECONDS = 31536000; + +const std::string PICKER_PROXY_SPLIT = "_pickerProxy_"; } // namespace DistributedHardware } // namespace OHOS #endif // OHOS_DM_CONSTANTS_H \ No newline at end of file diff --git a/common/src/dm_anonymous.cpp b/common/src/dm_anonymous.cpp index 1ae4cd2b3..8241a39bf 100644 --- a/common/src/dm_anonymous.cpp +++ b/common/src/dm_anonymous.cpp @@ -384,7 +384,7 @@ std::string GetSubStr(const std::string &rawStr, const std::string &separator, i while (end != std::string::npos) { strVec.push_back(rawStr.substr(start, end - start)); - start = end + 1; + start = end + separator.size(); end = rawStr.find(separator, start); } strVec.push_back(rawStr.substr(start)); diff --git a/common/src/ipc/standard/ipc_model_codec.cpp b/common/src/ipc/standard/ipc_model_codec.cpp index 0deff2a12..212b69c69 100644 --- a/common/src/ipc/standard/ipc_model_codec.cpp +++ b/common/src/ipc/standard/ipc_model_codec.cpp @@ -42,6 +42,7 @@ void IpcModelCodec::DecodeDmDeviceBasicInfo(MessageParcel &parcel, DmDeviceBasic LOGE("strcpy_s networkId failed!"); return; } + devInfo.extraData = parcel.ReadString(); } bool IpcModelCodec::EncodePeerTargetId(const PeerTargetId &targetId, MessageParcel &parcel) diff --git a/interfaces/inner_kits/native_cpp/include/dm_device_info.h b/interfaces/inner_kits/native_cpp/include/dm_device_info.h index e6d3c26ae..610fa1558 100644 --- a/interfaces/inner_kits/native_cpp/include/dm_device_info.h +++ b/interfaces/inner_kits/native_cpp/include/dm_device_info.h @@ -208,6 +208,11 @@ DmDeviceBasicInfo { * NetworkId of the device. */ char networkId[DM_MAX_DEVICE_ID_LEN] = {0}; + /** + * Extra data of the device. + * include json keys: "CUSTOM_DATA" + */ + std::string extraData; } DmDeviceBasicInfo; /** diff --git a/interfaces/kits/js4.0/include/dm_native_util.h b/interfaces/kits/js4.0/include/dm_native_util.h index 68d0edb9a..38a4158e3 100644 --- a/interfaces/kits/js4.0/include/dm_native_util.h +++ b/interfaces/kits/js4.0/include/dm_native_util.h @@ -87,7 +87,8 @@ void DmDeviceIconInfoToJs(const napi_env &env, const DmDeviceIconInfo &deviceIco void DmDeviceProfileInfoToJsArray(const napi_env &env, const std::vector &devInfos, napi_value &arrayResult); bool JsToDmDeviceProfileInfos(const napi_env &env, const napi_value &jsObj, std::vector &devInfos); - +void JsToDiscoveryParam(const napi_env &env, const napi_value &object, + std::map &discParam); } // namespace DistributedHardware } // namespace OHOS #endif // OHOS_DM_NATIVE_UTIL_H diff --git a/interfaces/kits/js4.0/include/native_devicemanager_js.h b/interfaces/kits/js4.0/include/native_devicemanager_js.h index 0bd52b05d..02c473977 100644 --- a/interfaces/kits/js4.0/include/native_devicemanager_js.h +++ b/interfaces/kits/js4.0/include/native_devicemanager_js.h @@ -334,8 +334,8 @@ public: private: static void ReleasePublishCallback(std::string &bundleName); static void ReleaseDiscoveryCallback(std::string &bundleName); - static void LockDiscoveryCallbackMutex(napi_env env, std::string &bundleName, std::string &extra, - uint32_t subscribeId); + static void LockDiscoveryCallbackMutex(napi_env env, std::string &bundleName, + std::map discParam, std::string &extra, uint32_t subscribeId); static void ClearBundleCallbacks(std::string &bundleName); static napi_value JsOffFrench(napi_env env, int32_t num, napi_value thisVar, napi_value argv[]); static napi_value JsOnFrench(napi_env env, int32_t num, napi_value thisVar, napi_value argv[]); diff --git a/interfaces/kits/js4.0/src/dm_native_util.cpp b/interfaces/kits/js4.0/src/dm_native_util.cpp index 8b08c668a..c2633595e 100644 --- a/interfaces/kits/js4.0/src/dm_native_util.cpp +++ b/interfaces/kits/js4.0/src/dm_native_util.cpp @@ -47,7 +47,8 @@ const int32_t MAX_OBJECT_LEN = 4096; void JsObjectToString(const napi_env &env, const napi_value &object, const std::string &fieldStr, char *dest, const int32_t destLen) { - if (dest == nullptr || destLen < 0 || destLen > MAX_OBJECT_LEN) { + if (dest == nullptr || destLen < 0 || (destLen > MAX_OBJECT_LEN && fieldStr != CUSTOM_DESCRIPTION) || + destLen > DM_NAPI_DESCRIPTION_BUF_LENGTH) { return; } bool hasProperty = false; @@ -292,6 +293,7 @@ void DmDeviceBasicToJsObject(napi_env env, const DmDeviceBasicInfo &devInfo, nap SetValueUtf8String(env, "deviceName", devInfo.deviceName, result); std::string deviceType = GetDeviceTypeById(static_cast(devInfo.deviceTypeId)); SetValueUtf8String(env, "deviceType", deviceType.c_str(), result); + SetValueUtf8String(env, "extraData", devInfo.extraData.c_str(), result); } void JsToDmPublishInfo(const napi_env &env, const napi_value &object, DmPublishInfo &info) @@ -434,6 +436,17 @@ void JsToDmDiscoveryExtra(const napi_env &env, const napi_value &object, std::st LOGI("JsToDmDiscoveryExtra, extra :%{public}s", extra.c_str()); } +void JsToDiscoveryParam(const napi_env &env, const napi_value &object, + std::map &discParam) +{ + char customData[DM_NAPI_BUF_LENGTH] = ""; + JsObjectToString(env, object, "CUSTOM_DATA", customData, sizeof(customData)); + discParam.insert(std::pair(PARAM_KEY_CUSTOM_DATA, customData)); + char capability[DM_NAPI_BUF_LENGTH] = ""; + JsObjectToString(env, object, "DISC_CAPABILITY", capability, sizeof(capability)); + discParam.insert(std::pair(PARAM_KEY_DISC_CAPABILITY, capability)); +} + void InsertMapParames(nlohmann::json &bindParamObj, std::map &bindParamMap) { LOGI("Insert map parames start"); diff --git a/interfaces/kits/js4.0/src/native_devicemanager_js.cpp b/interfaces/kits/js4.0/src/native_devicemanager_js.cpp index ed6317237..48fe2775b 100644 --- a/interfaces/kits/js4.0/src/native_devicemanager_js.cpp +++ b/interfaces/kits/js4.0/src/native_devicemanager_js.cpp @@ -1482,8 +1482,8 @@ napi_value DeviceManagerNapi::GetDeviceType(napi_env env, napi_callback_info inf return result; } -void DeviceManagerNapi::LockDiscoveryCallbackMutex(napi_env env, std::string &bundleName, std::string &extra, - uint32_t subscribeId) +void DeviceManagerNapi::LockDiscoveryCallbackMutex(napi_env env, std::string &bundleName, + std::map discParam, std::string &extra, uint32_t subscribeId) { std::shared_ptr discoveryCallback = nullptr; { @@ -1497,7 +1497,10 @@ void DeviceManagerNapi::LockDiscoveryCallbackMutex(napi_env env, std::string &bu } } uint64_t tokenId = OHOS::IPCSkeleton::GetSelfTokenID(); - int32_t ret = DeviceManager::GetInstance().StartDeviceDiscovery(bundleName, tokenId, extra, discoveryCallback); + discParam.insert(std::pair(PARAM_KEY_SUBSCRIBE_ID, std::to_string(tokenId))); + std::map filterOps; + filterOps.insert(std::pair(PARAM_KEY_FILTER_OPTIONS, extra)); + int32_t ret = DeviceManager::GetInstance().StartDiscovering(bundleName, discParam, filterOps, discoveryCallback); if (ret != 0) { LOGE("Discovery failed, bundleName %{public}s, ret %{public}d", bundleName.c_str(), ret); CreateBusinessError(env, ret); @@ -1510,6 +1513,7 @@ napi_value DeviceManagerNapi::StartDeviceDiscover(napi_env env, napi_callback_in { LOGI("StartDeviceDiscover in"); std::string extra = ""; + std::map discParam; napi_value result = nullptr; napi_value thisVar = nullptr; size_t argcNum = 0; @@ -1526,11 +1530,13 @@ napi_value DeviceManagerNapi::StartDeviceDiscover(napi_env env, napi_callback_in if (!JsToDiscoverTargetType(env, argv[DM_NAPI_ARGS_ZERO], discoverTargetType) || discoverTargetType != 1) { return nullptr; } + JsToDiscoveryParam(env, argv[DM_NAPI_ARGS_ZERO], discParam); } else if (argcNum == DM_NAPI_ARGS_TWO) { GET_PARAMS(env, info, DM_NAPI_ARGS_TWO); if (!JsToDiscoverTargetType(env, argv[DM_NAPI_ARGS_ZERO], discoverTargetType) || discoverTargetType != 1) { return nullptr; } + JsToDiscoveryParam(env, argv[DM_NAPI_ARGS_ZERO], discParam); napi_valuetype objectType = napi_undefined; napi_typeof(env, argv[DM_NAPI_ARGS_ONE], &objectType); if (!(CheckArgsType(env, objectType == napi_object, "filterOptions", "object or undefined"))) { @@ -1538,7 +1544,7 @@ napi_value DeviceManagerNapi::StartDeviceDiscover(napi_env env, napi_callback_in } JsToDmDiscoveryExtra(env, argv[DM_NAPI_ARGS_ONE], extra); } - LockDiscoveryCallbackMutex(env, deviceManagerWrapper->bundleName_, extra, subscribeId); + LockDiscoveryCallbackMutex(env, deviceManagerWrapper->bundleName_, discParam, extra, subscribeId); napi_get_undefined(env, &result); return result; } diff --git a/sa_profile/device_manager.cfg b/sa_profile/device_manager.cfg index 4a495502f..f99cf2b50 100644 --- a/sa_profile/device_manager.cfg +++ b/sa_profile/device_manager.cfg @@ -30,6 +30,7 @@ "ohos.permission.ACCESS_BLUETOOTH", "ohos.permission.MANAGE_BLUETOOTH", "ohos.permission.MANAGE_SETTINGS", + "ohos.permission.MANAGE_SOFTBUS_NETWORK", "ohos.permission.START_SYSTEM_DIALOG", "ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS", "ohos.permission.GET_BUNDLE_RESOURCES", @@ -40,6 +41,9 @@ "ohos.permission.ACCESS_SERVICE_DP", "ohos.permission.ACCESS_SENSING_WITH_ULTRASOUND" ], + "permission_acls" : [ + "ohos.permission.MANAGE_SOFTBUS_NETWORK" + ], "jobs" : { "on-start" : "service:device_manager" }, diff --git a/services/implementation/BUILD.gn b/services/implementation/BUILD.gn index e841ebcdc..10ad1737b 100644 --- a/services/implementation/BUILD.gn +++ b/services/implementation/BUILD.gn @@ -124,6 +124,7 @@ if (defined(ohos_lite)) { "include/dependency/multipleuser", "include/dependency/hichain", "include/dependency/softbus", + "include/i18n", "${common_path}/include", "${common_path}/include/dfx", "${common_path}/include/dfx/standard", @@ -190,6 +191,7 @@ if (defined(ohos_lite)) { "src/dependency/softbus/softbus_session.cpp", "src/device_manager_service_impl.cpp", "src/devicestate/dm_device_state_manager.cpp", + "src/i18n/dm_language_manager.cpp", ] public_configs = [ ":devicemanagerserviceimpl_config" ] diff --git a/services/implementation/include/authentication/dm_auth_manager.h b/services/implementation/include/authentication/dm_auth_manager.h index 760000cb4..f18d72342 100644 --- a/services/implementation/include/authentication/dm_auth_manager.h +++ b/services/implementation/include/authentication/dm_auth_manager.h @@ -134,6 +134,10 @@ typedef struct DmAuthRequestContext { std::string addr; std::string hostPkgLabel; int32_t closeSessionDelaySeconds = 0; + std::string connSessionType; + int32_t hmlActionId = 0; + int32_t hmlReleaseTime = 0; + bool hmlEnable160M = false; } DmAuthRequestContext; typedef struct DmAuthResponseContext { @@ -474,9 +478,11 @@ public: int32_t RegisterAuthenticationType(int32_t authenticationType); private: + bool IsHmlSessionType(); + void JoinLnn(const std::string &deviceId); int32_t CheckAuthParamVaild(const std::string &pkgName, int32_t authType, const std::string &deviceId, const std::string &extra); - int32_t CheckAuthParamVaildExtra(const std::string &extra); + int32_t CheckAuthParamVaildExtra(const std::string &extra, const std::string &deviceId); bool CheckProcessNameInWhiteList(const std::string &processName); void ProcessSourceMsg(); void ProcessSinkMsg(); @@ -527,6 +533,7 @@ private: void GetAuthParam(const std::string &pkgName, int32_t authType, const std::string &deviceId, const std::string &extra); void ParseJsonObject(nlohmann::json jsonObject); + void ParseHmlInfoInJsonObject(nlohmann::json &jsonObject); int32_t DeleteAcl(const std::string &pkgName, const std::string &localUdid, const std::string &remoteUdid, int32_t bindLevel, const std::string &extra); void ProcessAuthRequestExt(const int32_t &sessionId); @@ -558,6 +565,7 @@ private: bool IsSinkMsgValid(); bool IsSourceMsgValid(); void ProcessReqPublicKey(); + int32_t GetTokenIdByBundleName(int32_t userId, std::string &bundleName, int64_t &tokenId); private: std::shared_ptr softbusConnector_; diff --git a/services/implementation/include/dependency/softbus/softbus_connector.h b/services/implementation/include/dependency/softbus/softbus_connector.h index 2536eeacc..30d44b6b1 100644 --- a/services/implementation/include/dependency/softbus/softbus_connector.h +++ b/services/implementation/include/dependency/softbus/softbus_connector.h @@ -77,6 +77,13 @@ public: * @tc.type: FUNC */ static void JoinLnn(const std::string &deviceId); + + /** + * @tc.name: SoftbusConnector::JoinLnnByHml + * @tc.desc: join lnn by session id + * @tc.type: FUNC + */ + static void JoinLnnByHml(const int32_t sessionId); public: SoftbusConnector(); ~SoftbusConnector(); diff --git a/services/implementation/include/dependency/softbus/softbus_session.h b/services/implementation/include/dependency/softbus/softbus_session.h index 99387bb76..289a9cd60 100644 --- a/services/implementation/include/dependency/softbus/softbus_session.h +++ b/services/implementation/include/dependency/softbus/softbus_session.h @@ -60,6 +60,13 @@ public: */ int32_t OpenAuthSession(const std::string &deviceId); + /** + * @tc.name: SoftbusSession::OpenAuthSessionWithPara + * @tc.desc: Open HML AuthSession of the Softbus Session + * @tc.type: FUNC + */ + int32_t OpenAuthSessionWithPara(const std::string &deviceId, int32_t actionId, bool isEnable160m); + /** * @tc.name: SoftbusSession::CloseAuthSession * @tc.desc: Close AuthSession of the Softbus Session diff --git a/services/implementation/include/i18n/dm_language_manager.h b/services/implementation/include/i18n/dm_language_manager.h new file mode 100644 index 000000000..9cbc36243 --- /dev/null +++ b/services/implementation/include/i18n/dm_language_manager.h @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2025 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef OHOS_DM_LANGUAGE_MANAGER_H +#define OHOS_DM_LANGUAGE_MANAGER_H + +#include +#include + +#include "cJSON.h" +#include "dm_single_instance.h" +namespace OHOS { +namespace DistributedHardware { + +class DmLanguageManager { + DM_DECLARE_SINGLE_INSTANCE_BASE(DmLanguageManager); + +public: + DmLanguageManager() {} + ~DmLanguageManager() {} + std::string GetSystemParam(const std::string &key); + void GetLocaleByLanguage(const std::string &language, std::set &localeSet); + std::string GetTextBySystemLocale(const cJSON *const textObj, const std::set &localeSet); + std::string GetTextBySystemLanguage(const std::string &text); +}; +} // namespace DistributedHardware +} // namespace OHOS +#endif // OHOS_DM_LANGUAGE_MANAGER_H diff --git a/services/implementation/src/authentication/dm_auth_manager.cpp b/services/implementation/src/authentication/dm_auth_manager.cpp index 0c53794ff..19779a3f9 100644 --- a/services/implementation/src/authentication/dm_auth_manager.cpp +++ b/services/implementation/src/authentication/dm_auth_manager.cpp @@ -37,6 +37,7 @@ #include "dm_constants.h" #include "dm_crypto.h" #include "dm_dialog_manager.h" +#include "dm_language_manager.h" #include "dm_log.h" #include "dm_radar_helper.h" #include "dm_random.h" @@ -63,6 +64,7 @@ const int32_t CLONE_NEGOTIATE_TIMEOUT = 10; const int32_t CLONE_ADD_TIMEOUT = 10; const int32_t CLONE_WAIT_NEGOTIATE_TIMEOUT = 10; const int32_t CLONE_WAIT_REQUEST_TIMEOUT = 10; +const int32_t HML_SESSION_TIMEOUT = 10; const int32_t CLONE_SESSION_HEARTBEAT_TIMEOUT = 20; const int32_t CANCEL_PIN_CODE_DISPLAY = 1; const int32_t DEVICE_ID_HALF = 2; @@ -128,6 +130,12 @@ DmAuthManager::~DmAuthManager() LOGI("DmAuthManager destructor"); } +bool DmAuthManager::IsHmlSessionType() +{ + CHECK_NULL_RETURN(authRequestContext_, false); + return authRequestContext_->connSessionType == CONN_SESSION_TYPE_HML; +} + int32_t DmAuthManager::CheckAuthParamVaild(const std::string &pkgName, int32_t authType, const std::string &deviceId, const std::string &extra) { @@ -159,14 +167,6 @@ int32_t DmAuthManager::CheckAuthParamVaild(const std::string &pkgName, int32_t a return ERR_DM_AUTH_BUSINESS_BUSY; } - if (!softbusConnector_->HaveDeviceInMap(deviceId)) { - LOGE("CheckAuthParamVaild failed, the discoveryDeviceInfoMap_ not have this device."); - listener_->OnAuthResult(processInfo_, peerTargetId_.deviceId, "", STATUS_DM_AUTH_DEFAULT, - ERR_DM_INPUT_PARA_INVALID); - listener_->OnBindResult(processInfo_, peerTargetId_, ERR_DM_INPUT_PARA_INVALID, STATUS_DM_AUTH_DEFAULT, ""); - return ERR_DM_INPUT_PARA_INVALID; - } - if ((authType == AUTH_TYPE_IMPORT_AUTH_CODE) && (!IsAuthCodeReady(pkgName))) { LOGE("Auth code not exist."); listener_->OnAuthResult(processInfo_, peerTargetId_.deviceId, "", STATUS_DM_AUTH_DEFAULT, @@ -177,9 +177,18 @@ int32_t DmAuthManager::CheckAuthParamVaild(const std::string &pkgName, int32_t a return DM_OK; } -int32_t DmAuthManager::CheckAuthParamVaildExtra(const std::string &extra) +int32_t DmAuthManager::CheckAuthParamVaildExtra(const std::string &extra, const std::string &deviceId) { nlohmann::json jsonObject = nlohmann::json::parse(extra, nullptr, false); + if ((jsonObject.is_discarded() || !IsString(jsonObject, PARAM_KEY_CONN_SESSIONTYPE) || + jsonObject[PARAM_KEY_CONN_SESSIONTYPE].get() != CONN_SESSION_TYPE_HML) && + !softbusConnector_->HaveDeviceInMap(deviceId)) { + LOGE("CheckAuthParamVaild failed, the discoveryDeviceInfoMap_ not have this device."); + listener_->OnAuthResult(processInfo_, peerTargetId_.deviceId, "", STATUS_DM_AUTH_DEFAULT, + ERR_DM_INPUT_PARA_INVALID); + listener_->OnBindResult(processInfo_, peerTargetId_, ERR_DM_INPUT_PARA_INVALID, STATUS_DM_AUTH_DEFAULT, ""); + return ERR_DM_INPUT_PARA_INVALID; + } if (jsonObject.is_discarded() || jsonObject.find(TAG_BIND_LEVEL) == jsonObject.end() || !IsInt32(jsonObject, TAG_BIND_LEVEL)) { return DM_OK; @@ -223,8 +232,10 @@ void DmAuthManager::GetAuthParam(const std::string &pkgName, int32_t authType, char localDeviceId[DEVICE_UUID_LENGTH] = {0}; GetDevUdid(localDeviceId, DEVICE_UUID_LENGTH); std::string localUdid = static_cast(localDeviceId); - authRequestContext_->hostPkgName = pkgName; - authRequestContext_->hostPkgLabel = GetBundleLable(pkgName); + std::string realPkgName = GetSubStr(pkgName, PICKER_PROXY_SPLIT, 1); + realPkgName = realPkgName.empty() ? pkgName : realPkgName; + authRequestContext_->hostPkgName = realPkgName; + authRequestContext_->hostPkgLabel = GetBundleLable(realPkgName); authRequestContext_->authType = authType; authRequestContext_->localDeviceName = softbusConnector_->GetLocalDeviceName(); authRequestContext_->localDeviceTypeId = softbusConnector_->GetLocalDeviceTypeId(); @@ -232,9 +243,12 @@ void DmAuthManager::GetAuthParam(const std::string &pkgName, int32_t authType, authRequestContext_->deviceId = deviceId; authRequestContext_->addr = deviceId; authRequestContext_->dmVersion = DM_VERSION_5_0_3; - uint32_t tokenId = 0 ; + uint32_t tokenId = 0; MultipleUserConnector::GetTokenIdAndForegroundUserId(tokenId, authRequestContext_->localUserId); authRequestContext_->tokenId = static_cast(tokenId); + if (realPkgName != pkgName) { + GetTokenIdByBundleName(authRequestContext_->localUserId, realPkgName, authRequestContext_->tokenId); + } authRequestContext_->localAccountId = MultipleUserConnector::GetOhosAccountIdByUserId(authRequestContext_->localUserId); authRequestContext_->isOnline = false; @@ -260,7 +274,8 @@ void DmAuthManager::ParseJsonObject(nlohmann::json jsonObject) authRequestContext_->appOperation = jsonObject[APP_OPERATION_KEY].get(); } if (IsString(jsonObject, CUSTOM_DESCRIPTION_KEY)) { - authRequestContext_->customDesc = jsonObject[CUSTOM_DESCRIPTION_KEY].get(); + authRequestContext_->customDesc = DmLanguageManager::GetInstance(). + GetTextBySystemLanguage(jsonObject[CUSTOM_DESCRIPTION_KEY].get()); } if (IsString(jsonObject, APP_THUMBNAIL)) { authRequestContext_->appThumbnail = jsonObject[APP_THUMBNAIL].get(); @@ -282,10 +297,46 @@ void DmAuthManager::ParseJsonObject(nlohmann::json jsonObject) } else { authRequestContext_->peerBundleName = authRequestContext_->hostPkgName; } + ParseHmlInfoInJsonObject(jsonObject); } authRequestContext_->bundleName = GetBundleName(jsonObject); } +void DmAuthManager::ParseHmlInfoInJsonObject(nlohmann::json &jsonObject) +{ + if (IsString(jsonObject, PARAM_KEY_CONN_SESSIONTYPE)) { + authRequestContext_->connSessionType = jsonObject[PARAM_KEY_CONN_SESSIONTYPE].get(); + LOGI("[nopincode] input connSessionType %{public}s", authRequestContext_->connSessionType.c_str()); + } + if (!IsHmlSessionType()) { + LOGI("[nopincode] not HML session type"); + return; + } + if (IsInt32(jsonObject, PARAM_KEY_HML_RELEASETIME)) { + authRequestContext_->hmlReleaseTime = jsonObject[PARAM_KEY_HML_RELEASETIME].get(); + if (authRequestContext_->hmlReleaseTime <= 0) { + authRequestContext_->hmlReleaseTime = 0; + } + LOGI("[nopincode] input hmlReleaseTime %{public}d", authRequestContext_->hmlReleaseTime); + } + if (IsBool(jsonObject, PARAM_KEY_HML_ENABLE_160M)) { + authRequestContext_->hmlEnable160M = jsonObject[PARAM_KEY_HML_ENABLE_160M].get(); + LOGI("[nopincode] input hmlEnable160M %{public}d", authRequestContext_->hmlEnable160M); + } + if (IsInt32(jsonObject, PARAM_KEY_HML_ACTIONID)) { + authRequestContext_->hmlActionId = jsonObject[PARAM_KEY_HML_ACTIONID].get(); + if (authRequestContext_->hmlActionId <= 0) { + authRequestContext_->hmlActionId = 0; + } + LOGI("[nopincode] input hmlActionId %{public}d", authRequestContext_->hmlActionId); + } + if (authRequestContext_->hmlReleaseTime > 0) { + authRequestContext_->closeSessionDelaySeconds = authRequestContext_->hmlReleaseTime; + } else { + authRequestContext_->closeSessionDelaySeconds = HML_SESSION_TIMEOUT; + } +} + int32_t DmAuthManager::GetCloseSessionDelaySeconds(std::string &delaySecondsStr) { if (!IsNumberString(delaySecondsStr)) { @@ -345,7 +396,7 @@ int32_t DmAuthManager::AuthenticateDevice(const std::string &pkgName, int32_t au LOGE("DmAuthManager::AuthenticateDevice failed, param is invaild."); return ret; } - ret = CheckAuthParamVaildExtra(extra); + ret = CheckAuthParamVaildExtra(extra, deviceId); if (ret != DM_OK) { LOGE("CheckAuthParamVaildExtra failed, param is invaild."); return ret; @@ -801,7 +852,14 @@ void DmAuthManager::HandleAuthenticateTimeout(std::string name) int32_t DmAuthManager::EstablishAuthChannel(const std::string &deviceId) { - int32_t sessionId = softbusConnector_->GetSoftbusSession()->OpenAuthSession(deviceId); + int32_t sessionId = 0; + if (IsHmlSessionType()) { + CHECK_NULL_RETURN(authRequestContext_, ERR_DM_FAILED); + sessionId = softbusConnector_->GetSoftbusSession()->OpenAuthSessionWithPara(deviceId, + authRequestContext_->hmlActionId, authRequestContext_->hmlEnable160M); + } else { + sessionId = softbusConnector_->GetSoftbusSession()->OpenAuthSession(deviceId); + } struct RadarInfo info = { .funcName = "EstablishAuthChannel", .stageRes = (sessionId > 0) ? @@ -1092,7 +1150,7 @@ bool DmAuthManager::IsAuthFinish() if ((authResponseContext_->isIdenticalAccount && !authResponseContext_->authed) || (authResponseContext_->authed && !authResponseContext_->isOnline)) { - softbusConnector_->JoinLnn(authRequestContext_->addr); + JoinLnn(authRequestContext_->addr); authRequestContext_->reason = DM_OK; authResponseContext_->state = AuthState::AUTH_REQUEST_FINISH; authResponseContext_->reply = DM_OK; @@ -2025,7 +2083,7 @@ void DmAuthManager::RequestCredentialDone() if (timer_ != nullptr) { timer_->DeleteTimer(std::string(AUTHENTICATE_TIMEOUT_TASK)); } - softbusConnector_->JoinLnn(authRequestContext_->addr); + JoinLnn(authRequestContext_->addr); authResponseContext_->state = AuthState::AUTH_REQUEST_FINISH; authRequestContext_->reason = DM_OK; authResponseContext_->reply = DM_OK; @@ -2119,7 +2177,7 @@ void DmAuthManager::SrcAuthDeviceFinish() return; } if (!authResponseContext_->isOnline && authResponseContext_->haveCredential) { - softbusConnector_->JoinLnn(authRequestContext_->addr); + JoinLnn(authRequestContext_->addr); timer_->DeleteTimer(std::string(AUTHENTICATE_TIMEOUT_TASK)); ConverToFinish(); return; @@ -2555,7 +2613,7 @@ int32_t DmAuthManager::CheckTrustState() } if (authResponseContext_->isIdenticalAccount) { if (IsIdenticalAccount()) { - softbusConnector_->JoinLnn(authResponseContext_->deviceId); + JoinLnn(authResponseContext_->deviceId); authResponseContext_->state = AuthState::AUTH_REQUEST_FINISH; authRequestContext_->reason = DM_OK; authResponseContext_->reply = DM_OK; @@ -2568,7 +2626,7 @@ int32_t DmAuthManager::CheckTrustState() authResponseContext_->localDeviceId)) { CompatiblePutAcl(); } - softbusConnector_->JoinLnn(authResponseContext_->deviceId); + JoinLnn(authResponseContext_->deviceId); authResponseContext_->state = AuthState::AUTH_REQUEST_FINISH; authRequestState_->TransitionTo(std::make_shared()); return ALREADY_BIND; @@ -2936,5 +2994,29 @@ void DmAuthManager::ProcessReqPublicKey() isNeedProcCachedSrcReqMsg_ = true; } } + +void DmAuthManager::JoinLnn(const std::string &deviceId) +{ + CHECK_NULL_VOID(authRequestContext_); + CHECK_NULL_VOID(softbusConnector_); + if (IsHmlSessionType()) { + softbusConnector_->JoinLnnByHml(authRequestContext_->sessionId); + return; + } + softbusConnector_->JoinLnn(authRequestContext_->addr); +} + +int32_t DmAuthManager::GetTokenIdByBundleName(int32_t userId, std::string &bundleName, int64_t &tokenId) +{ + int32_t ret = AppManager::GetInstance().GetNativeTokenIdByName(bundleName, tokenId); + if (ret == DM_OK) { + return DM_OK; + } + ret = AppManager::GetInstance().GetHapTokenIdByName(userId, bundleName, 0, tokenId); + if (ret != DM_OK) { + LOGE("get tokenId by bundleName failed %{public}s", GetAnonyString(bundleName).c_str()); + } + return ret; +} } // namespace DistributedHardware } // namespace OHOS diff --git a/services/implementation/src/dependency/softbus/softbus_connector.cpp b/services/implementation/src/dependency/softbus/softbus_connector.cpp index d6debe90f..ed559777d 100644 --- a/services/implementation/src/dependency/softbus/softbus_connector.cpp +++ b/services/implementation/src/dependency/softbus/softbus_connector.cpp @@ -96,6 +96,18 @@ void SoftbusConnector::JoinLnn(const std::string &deviceId) return; } +void SoftbusConnector::JoinLnnByHml(const int32_t sessionId) +{ + LOGI("start, JoinLnnByHml sessionId: %{public}d.", sessionId); + ConnectionAddr addrInfo; + addrInfo.type = CONNECTION_ADDR_SESSION; + addrInfo.info.session.sessionId = sessionId; + int32_t ret = ::JoinLNN(DM_PKG_NAME, &addrInfo, OnSoftbusJoinLNNResult); + if (ret != DM_OK) { + LOGE("[SOFTBUS]JoinLNN failed, ret: %{public}d.", ret); + } +} + int32_t SoftbusConnector::GetUdidByNetworkId(const char *networkId, std::string &udid) { LOGI("start, networkId: %{public}s.", GetAnonyString(std::string(networkId)).c_str()); diff --git a/services/implementation/src/dependency/softbus/softbus_session.cpp b/services/implementation/src/dependency/softbus/softbus_session.cpp index 9e579ba80..76d008140 100644 --- a/services/implementation/src/dependency/softbus/softbus_session.cpp +++ b/services/implementation/src/dependency/softbus/softbus_session.cpp @@ -22,6 +22,10 @@ #include "dm_log.h" #include "nlohmann/json.hpp" #include "softbus_connector.h" +#include "softbus_error_code.h" +#ifndef DEVICE_MANAGER_COMMON_FLAG +#include "session_ex.h" +#endif namespace OHOS { namespace DistributedHardware { @@ -110,6 +114,29 @@ int32_t SoftbusSession::OpenAuthSession(const std::string &deviceId) return sessionId; } +int32_t SoftbusSession::OpenAuthSessionWithPara(const std::string &deviceId, int32_t actionId, bool isEnable160m) +{ +#ifdef DEVICE_MANAGER_COMMON_FLAG + LOGE("[SOFTBUS] OpenAuthSessionWithPara no implement"); + return SOFTBUS_NOT_IMPLEMENT; +#else + DmTraceStart(std::string(DM_HITRACE_AUTH_TO_OPPEN_SESSION)); + LinkPara para; + para.type = PARA_ACTION; + para.action.actionId = actionId; + para.enable160M = isEnable160m; + para.accountInfo = false; + int32_t sessionId = ::OpenAuthSessionWithPara(DM_SESSION_NAME, ¶); + if (sessionId < 0) { + LOGE("[SOFTBUS]open session error, sessionId: %{public}d.", sessionId); + return sessionId; + } + DmTraceEnd(); + LOGI("OpenAuthSessionWithPara success. sessionId: %{public}d.", sessionId); + return sessionId; +#endif +} + int32_t SoftbusSession::CloseAuthSession(int32_t sessionId) { LOGI("CloseAuthSession."); diff --git a/services/implementation/src/i18n/dm_language_manager.cpp b/services/implementation/src/i18n/dm_language_manager.cpp new file mode 100644 index 000000000..77f080ee5 --- /dev/null +++ b/services/implementation/src/i18n/dm_language_manager.cpp @@ -0,0 +1,148 @@ +/* + * Copyright (c) 2025 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "dm_language_manager.h" + +#include "cJSON.h" +#include + +#include "dm_constants.h" +#include "dm_log.h" +#include "parameter.h" + +namespace OHOS { +namespace DistributedHardware { +DM_IMPLEMENT_SINGLE_INSTANCE(DmLanguageManager); +const int32_t MAX_LEN = 128; +const std::string SYSTEM_LANGUAGE_KEY = "persist.global.language"; +const std::string SYSTEM_LANGUAGE_LOCALE_KEY = "persist.global.locale"; +const std::string DEFAULT_LANGUAGE = "zh-Hans"; +const std::string LANGUAGE_EN = "en-Latn_US"; +const std::string LANGUAGE_AND_LOCALE_STR = + R"({ + "zh-Hant": [ + { + "persist.global.locale": "zh-Hant-HK" + }, + { + "persist.global.locale": "zh-Hant-TW" + } + ] +})"; + +std::string DmLanguageManager::GetSystemParam(const std::string &key) +{ + char value[MAX_LEN] = {0}; + int32_t ret = GetParameter(key.c_str(), "", value, MAX_LEN); + if (ret <= 0) { + LOGE("GetSystemParam %{public}s failed", key.c_str()); + return ""; + } + return std::string(value); +} + +void DmLanguageManager::GetLocaleByLanguage(const std::string &language, std::set &localeSet) +{ + cJSON *languageAndLocaleObj = cJSON_Parse(LANGUAGE_AND_LOCALE_STR.c_str()); + if (languageAndLocaleObj == NULL) { + LOGE("parse languageAndLocaleObj failed"); + return; + } + cJSON *languageObj = cJSON_GetObjectItem(languageAndLocaleObj, language.c_str()); + if (languageObj == NULL || !cJSON_IsArray(languageObj)) { + cJSON_Delete(languageAndLocaleObj); + return; + } + cJSON *item = NULL; + cJSON_ArrayForEach(item, languageObj) { + if (!cJSON_IsObject(item)) { + LOGE("item is not object!"); + continue; + } + cJSON* localeObj = cJSON_GetObjectItemCaseSensitive(item, SYSTEM_LANGUAGE_LOCALE_KEY.c_str()); + if (!cJSON_IsString(localeObj) || localeObj->valuestring == NULL) { + LOGE("Get localeObj fail!"); + continue; + } + localeSet.insert(localeObj->valuestring); + } + cJSON_Delete(languageAndLocaleObj); +} + +std::string DmLanguageManager::GetTextBySystemLanguage(const std::string &text) +{ + if (text.empty()) { + return ""; + } + cJSON *textObj = cJSON_Parse(text.c_str()); + if (textObj == NULL) { + LOGE("parse text failed"); + return text; + } + std::string resultText = text; + std::string language = GetSystemParam(SYSTEM_LANGUAGE_KEY); + language = language.empty() ? DEFAULT_LANGUAGE : language; + std::set localeSet; + GetLocaleByLanguage(language, localeSet); + if (localeSet.size() > 0) { + resultText = GetTextBySystemLocale(textObj, localeSet); + if (!resultText.empty()) { + cJSON_Delete(textObj); + return resultText; + } + } + cJSON *languageJson = cJSON_GetObjectItem(textObj, language.c_str()); + if (languageJson != NULL && cJSON_IsString(languageJson)) { + resultText = std::string(languageJson->valuestring); + cJSON_Delete(textObj); + return resultText; + } + cJSON *defaultJson = cJSON_GetObjectItem(textObj, DEFAULT_LANGUAGE.c_str()); + if (defaultJson != NULL && cJSON_IsString(defaultJson)) { + resultText = std::string(defaultJson->valuestring); + cJSON_Delete(textObj); + return resultText; + } + cJSON *enJson = cJSON_GetObjectItem(textObj, LANGUAGE_EN.c_str()); + if (enJson != NULL && cJSON_IsString(enJson)) { + resultText = std::string(enJson->valuestring); + cJSON_Delete(textObj); + return resultText; + } + cJSON_Delete(textObj); + return ""; +} + +std::string DmLanguageManager::GetTextBySystemLocale(const cJSON *const textObj, + const std::set &localeSet) +{ + std::string resultText = ""; + std::string languageLocale = GetSystemParam(SYSTEM_LANGUAGE_LOCALE_KEY); + cJSON *languageLocaleson = cJSON_GetObjectItem(textObj, languageLocale.c_str()); + if (languageLocaleson != NULL && cJSON_IsString(languageLocaleson)) { + resultText = std::string(languageLocaleson->valuestring); + return resultText; + } + for (std::string locale : localeSet) { + cJSON *localesonObj = cJSON_GetObjectItem(textObj, locale.c_str()); + if (localesonObj != NULL && cJSON_IsString(localesonObj)) { + resultText = std::string(localesonObj->valuestring); + return resultText; + } + } + return ""; +} +} // namespace DistributedHardware +} // namespace OHOS \ No newline at end of file diff --git a/services/service/include/device_manager_service.h b/services/service/include/device_manager_service.h index f57a29acb..2c2fd5dc1 100644 --- a/services/service/include/device_manager_service.h +++ b/services/service/include/device_manager_service.h @@ -266,6 +266,7 @@ private: std::vector backgroundUserIds); void ProcessCheckSumByBT(std::string networkId, std::vector foregroundUserIds, std::vector backgroundUserIds); + void AddHmlInfoToBindParam(int32_t actionId, std::string &bindParam); #if !(defined(__LITEOS_M__) || defined(LITE_DEVICE)) void SubscribeAccountCommonEvent(); diff --git a/services/service/include/softbus/softbus_listener.h b/services/service/include/softbus/softbus_listener.h index b0d13359f..45866ef95 100644 --- a/services/service/include/softbus/softbus_listener.h +++ b/services/service/include/softbus/softbus_listener.h @@ -25,6 +25,7 @@ #include #include +#include "cJSON.h" #include "softbus_bus_center.h" #include "dm_device_info.h" #include "dm_publish_info.h" @@ -113,6 +114,7 @@ public: int32_t GetAllTrustedDeviceList(const std::string &pkgName, const std::string &extra, std::vector &deviceList); int32_t GetUdidFromDp(const std::string &udidHash, std::string &udid); + static void GetActionId(const std::string &deviceId, int32_t &actionId); private: static int32_t FillDeviceInfo(const DeviceInfo &device, DmDeviceInfo &dmDevice); static void ParseConnAddrInfo(const ConnectionAddr *addrInfo, nlohmann::json &jsonObj); @@ -120,6 +122,9 @@ private: #if !(defined(__LITEOS_M__) || defined(LITE_DEVICE)) void ConvertAclToDeviceInfo(DistributedDeviceProfile::AccessControlProfile &profile, DmDeviceInfo &dmDevice); #endif + static int32_t GetAttrFromCustomData(const cJSON *const customDataJson, DmDeviceInfo &dmDevInfo, + int32_t &actionId); + static int32_t GetAttrFromExtraData(DmDeviceInfo &dmDevInfo, int32_t &actionId); private: static std::string hostName_; static bool isRadarSoLoad_; diff --git a/services/service/src/advertise/advertise_manager.cpp b/services/service/src/advertise/advertise_manager.cpp index 263203e85..9f94c5293 100644 --- a/services/service/src/advertise/advertise_manager.cpp +++ b/services/service/src/advertise/advertise_manager.cpp @@ -51,6 +51,9 @@ int32_t AdvertiseManager::StartAdvertising(const std::string &pkgName, if (capability == DM_CAPABILITY_APPROACH || capability == DM_CAPABILITY_TOUCH) { dmPubInfo.mode = DmDiscoverMode::DM_DISCOVER_MODE_ACTIVE; } + if (capability == DM_CAPABILITY_OOP) { + dmPubInfo.ranging = false; + } std::string customData = ""; if (advertiseParam.find(PARAM_KEY_CUSTOM_DATA) != advertiseParam.end()) { customData = advertiseParam.find(PARAM_KEY_CUSTOM_DATA)->second; diff --git a/services/service/src/device_manager_service.cpp b/services/service/src/device_manager_service.cpp index 9b78f1d5f..4f1b74f13 100755 --- a/services/service/src/device_manager_service.cpp +++ b/services/service/src/device_manager_service.cpp @@ -15,6 +15,7 @@ #include "device_manager_service.h" +#include "cJSON.h" #include #include @@ -299,11 +300,13 @@ int32_t DeviceManagerService::GetTrustedDeviceList(const std::string &pkgName, c return DM_OK; } if (!onlineDeviceList.empty() && IsDMServiceImplReady()) { + std::string queryPkgName = GetSubStr(pkgName, PICKER_PROXY_SPLIT, 1); + queryPkgName = queryPkgName.empty() ? pkgName : queryPkgName; std::unordered_map udidMap; - if (PermissionManager::GetInstance().CheckWhiteListSystemSA(pkgName)) { + if (PermissionManager::GetInstance().CheckWhiteListSystemSA(queryPkgName)) { udidMap = dmServiceImpl_->GetAppTrustDeviceIdList(std::string(ALL_PKGNAME)); } else { - udidMap = dmServiceImpl_->GetAppTrustDeviceIdList(pkgName); + udidMap = dmServiceImpl_->GetAppTrustDeviceIdList(queryPkgName); } for (auto item : onlineDeviceList) { #if !(defined(__LITEOS_M__) || defined(LITE_DEVICE)) @@ -644,16 +647,24 @@ int32_t DeviceManagerService::BindDevice(const std::string &pkgName, int32_t aut } #endif PeerTargetId targetId; - ConnectionAddrType addrType; - int32_t ret = SoftbusListener::GetTargetInfoFromCache(queryDeviceId, targetId, addrType); - if (ret != DM_OK) { - LOGE("BindDevice failed, cannot get target info from cached discovered device map."); - return ERR_DM_BIND_INPUT_PARA_INVALID; - } std::map bindParamMap; + std::string bindParamStr = bindParam; + int32_t actionId = 0; + SoftbusListener::GetActionId(queryDeviceId, actionId); + if (actionId > 0) { + targetId.deviceId = queryDeviceId; + AddHmlInfoToBindParam(actionId, bindParamStr); + } else { + ConnectionAddrType addrType; + int32_t ret = SoftbusListener::GetTargetInfoFromCache(queryDeviceId, targetId, addrType); + if (ret != DM_OK) { + LOGE("BindDevice failed, cannot get target info from cached discovered device map."); + return ERR_DM_BIND_INPUT_PARA_INVALID; + } + bindParamMap.insert(std::pair(PARAM_KEY_CONN_ADDR_TYPE, std::to_string(addrType))); + } bindParamMap.insert(std::pair(PARAM_KEY_AUTH_TYPE, std::to_string(authType))); - bindParamMap.insert(std::pair(PARAM_KEY_BIND_EXTRA_DATA, bindParam)); - bindParamMap.insert(std::pair(PARAM_KEY_CONN_ADDR_TYPE, std::to_string(addrType))); + bindParamMap.insert(std::pair(PARAM_KEY_BIND_EXTRA_DATA, bindParamStr)); return dmServiceImpl_->BindTarget(pkgName, targetId, bindParamMap); } @@ -688,13 +699,15 @@ int32_t DeviceManagerService::UnBindDevice(const std::string &pkgName, const std char localUdid[DEVICE_UUID_LENGTH] = {0}; GetDevUdid(localUdid, DEVICE_UUID_LENGTH); uint64_t tokenId = 0; - int32_t bindLevel = dmServiceImpl_->GetBindLevel(pkgName, std::string(localUdid), udid, tokenId); + std::string unbindPkgName = GetSubStr(pkgName, PICKER_PROXY_SPLIT, 1); + unbindPkgName = unbindPkgName.empty() ? pkgName : unbindPkgName; + int32_t bindLevel = dmServiceImpl_->GetBindLevel(unbindPkgName, std::string(localUdid), udid, tokenId); LOGI("UnAuthenticateDevice get bindlevel %{public}d.", bindLevel); if (bindLevel == INVALIED_BIND_LEVEL) { LOGE("UnAuthenticateDevice failed, Acl not contain the bindLevel %{public}d.", bindLevel); return ERR_DM_FAILED; } - if (dmServiceImpl_->UnBindDevice(pkgName, udid, bindLevel) != DM_OK) { + if (dmServiceImpl_->UnBindDevice(unbindPkgName, udid, bindLevel) != DM_OK) { LOGE("dmServiceImpl_ UnBindDevice failed."); return ERR_DM_FAILED; } @@ -2695,5 +2708,26 @@ std::vector DeviceManagerService::GetDeviceNamePrefixs() } return dmServiceImplExtResident_->GetDeviceNamePrefixs(); } + +void DeviceManagerService::AddHmlInfoToBindParam(int32_t actionId, std::string &bindParam) +{ + cJSON *bindParamObj = cJSON_Parse(bindParam.c_str()); + if (bindParamObj == NULL) { + bindParamObj = cJSON_CreateObject(); + if (bindParamObj == NULL) { + LOGE("Create bindParamObj object failed."); + return; + } + } + cJSON_AddStringToObject(bindParamObj, PARAM_KEY_CONN_SESSIONTYPE, CONN_SESSION_TYPE_HML.c_str()); + cJSON_AddNumberToObject(bindParamObj, PARAM_KEY_HML_ACTIONID, actionId); + char *str = cJSON_PrintUnformatted(bindParamObj); + if (str == nullptr) { + cJSON_Delete(bindParamObj); + return; + } + bindParam = std::string(str); + cJSON_Delete(bindParamObj); +} } // namespace DistributedHardware } // namespace OHOS \ No newline at end of file diff --git a/services/service/src/device_manager_service_listener.cpp b/services/service/src/device_manager_service_listener.cpp index 6b48b0d93..f8b25f8de 100644 --- a/services/service/src/device_manager_service_listener.cpp +++ b/services/service/src/device_manager_service_listener.cpp @@ -14,6 +14,7 @@ */ #include +#include "cJSON.h" #include "device_manager_service_listener.h" @@ -83,6 +84,33 @@ void DeviceManagerServiceListener::ConvertDeviceInfoToDeviceBasicInfo(const std: } deviceBasicInfo.deviceTypeId = info.deviceTypeId; + cJSON *extraDataJsonObj = cJSON_Parse(info.extraData.c_str()); + if (extraDataJsonObj == NULL) { + return; + } + cJSON *customDataJson = cJSON_GetObjectItem(extraDataJsonObj, PARAM_KEY_CUSTOM_DATA); + if (customDataJson == NULL || !cJSON_IsString(customDataJson)) { + cJSON_Delete(extraDataJsonObj); + return; + } + char *customData = cJSON_PrintUnformatted(customDataJson); + if (customData == nullptr) { + cJSON_Delete(extraDataJsonObj); + return; + } + cJSON_Delete(extraDataJsonObj); + cJSON *basicExtraDataJsonObj = cJSON_CreateObject(); + if (basicExtraDataJsonObj == NULL) { + return; + } + cJSON_AddStringToObject(basicExtraDataJsonObj, PARAM_KEY_CUSTOM_DATA, customData); + char *basicExtraData = cJSON_PrintUnformatted(basicExtraDataJsonObj); + if (basicExtraData == nullptr) { + cJSON_Delete(basicExtraDataJsonObj); + return; + } + deviceBasicInfo.extraData = std::string(basicExtraData); + cJSON_Delete(basicExtraDataJsonObj); } void DeviceManagerServiceListener::SetDeviceInfo(std::shared_ptr pReq, @@ -194,6 +222,12 @@ void DeviceManagerServiceListener::ProcessAppStateChange(const ProcessInfo &proc std::vector processInfoVec = GetWhiteListSAProcessInfo(DmCommonNotifyEvent::REG_DEVICE_STATE); ProcessInfo bindProcessInfo = DealBindProcessInfo(processInfo); processInfoVec.push_back(bindProcessInfo); + std::vector allProcessInfos = ipcServerListener_.GetAllProcessInfo(); + for (auto item : allProcessInfos) { + if (item.pkgName.find(PICKER_PROXY_SPLIT + processInfo.pkgName) != std::string::npos) { + processInfoVec.push_back(item); + } + } switch (static_cast(state)) { case static_cast(DmDeviceState::DEVICE_STATE_ONLINE): ProcessAppOnline(processInfoVec, processInfo, state, info, deviceBasicInfo); diff --git a/services/service/src/discovery/discovery_manager.cpp b/services/service/src/discovery/discovery_manager.cpp index a68fe4667..a70e688e0 100644 --- a/services/service/src/discovery/discovery_manager.cpp +++ b/services/service/src/discovery/discovery_manager.cpp @@ -235,8 +235,14 @@ int32_t DiscoveryManager::StartDiscovering4MineLibary(const std::string &pkgName int32_t DiscoveryManager::StartDiscoveringNoMetaType(const std::string &pkgName, DmSubscribeInfo &dmSubInfo, const std::map ¶m) { - (void)param; - if (strcpy_s(dmSubInfo.capability, DM_MAX_DEVICE_CAPABILITY_LEN, DM_CAPABILITY_OSD) != EOK) { + if (param.find(PARAM_KEY_DISC_CAPABILITY) != param.end() && + !param.find(PARAM_KEY_DISC_CAPABILITY)->second.empty()) { + if (strcpy_s(dmSubInfo.capability, DM_MAX_DEVICE_CAPABILITY_LEN, + param.find(PARAM_KEY_DISC_CAPABILITY)->second.c_str()) != EOK) { + LOGE("capability copy err."); + return ERR_DM_START_DISCOVERING_FAILED; + } + } else if (strcpy_s(dmSubInfo.capability, DM_MAX_DEVICE_CAPABILITY_LEN, DM_CAPABILITY_OSD) != EOK) { LOGE("capability copy err."); return ERR_DM_START_DISCOVERING_FAILED; } @@ -247,7 +253,11 @@ int32_t DiscoveryManager::StartDiscoveringNoMetaType(const std::string &pkgName, std::lock_guard capLock(capabilityMapLocks_); capabilityMap_[pkgName] = std::string(dmSubInfo.capability); } - int32_t ret = softbusListener_->RefreshSoftbusLNN(DM_PKG_NAME, dmSubInfo, LNN_DISC_CAPABILITY); + std::string customData = LNN_DISC_CAPABILITY; + if (param.find(PARAM_KEY_CUSTOM_DATA) != param.end() && !param.find(PARAM_KEY_CUSTOM_DATA)->second.empty()) { + customData = param.find(PARAM_KEY_CUSTOM_DATA)->second; + } + int32_t ret = softbusListener_->RefreshSoftbusLNN(DM_PKG_NAME, dmSubInfo, customData); if (ret != DM_OK) { LOGE("StartDiscoveringNoMetaType failed, softbus refresh lnn ret: %{public}d.", ret); } diff --git a/services/service/src/ipc/standard/ipc_cmd_parser.cpp b/services/service/src/ipc/standard/ipc_cmd_parser.cpp index 7e1060799..9843714cc 100644 --- a/services/service/src/ipc/standard/ipc_cmd_parser.cpp +++ b/services/service/src/ipc/standard/ipc_cmd_parser.cpp @@ -84,6 +84,7 @@ bool EncodeDmDeviceBasicInfo(const DmDeviceBasicInfo &devInfo, MessageParcel &pa bRet = (bRet && parcel.WriteUint16(devInfo.deviceTypeId)); std::string networkIdStr(devInfo.networkId); bRet = (bRet && parcel.WriteString(networkIdStr)); + bRet = (bRet && parcel.WriteString(devInfo.extraData)); return bRet; } diff --git a/services/service/src/softbus/softbus_listener.cpp b/services/service/src/softbus/softbus_listener.cpp index 295edf45b..0ace7b175 100644 --- a/services/service/src/softbus/softbus_listener.cpp +++ b/services/service/src/softbus/softbus_listener.cpp @@ -58,6 +58,10 @@ constexpr static uint16_t ARRAY_DOUBLE_SIZE = 2; constexpr static uint16_t BIN_HIGH_FOUR_NUM = 4; constexpr uint32_t SOFTBUS_MAX_RETRY_TIME = 10; +constexpr const char* CUSTOM_DATA_ACTIONID = "actionId"; +constexpr const char* CUSTOM_DATA_NETWORKID = "networkId"; +constexpr const char* CUSTOM_DATA_DISPLAY_NAME = "displayName"; + static std::mutex g_deviceMapMutex; static std::mutex g_lnnCbkMapMutex; static std::mutex g_radarLoadLock; @@ -73,6 +77,7 @@ static std::mutex g_credentialAuthStatus; static std::map>>> discoveredDeviceMap; static std::map> lnnOpsCbkMap; +static std::map discoveredDeviceActionIdMap; static std::set deviceIdSet; bool SoftbusListener::isRadarSoLoad_ = false; IDmRadarHelper* SoftbusListener::dmRadarHelper_ = nullptr; @@ -446,8 +451,14 @@ void SoftbusListener::OnSoftbusDeviceFound(const DeviceInfo *device) "isOnline=%{public}d, capability=%{public}u", GetAnonyString(dmDevInfo.deviceId).c_str(), GetAnonyString(dmDevInfo.deviceName).c_str(), dmDevInfo.deviceTypeId, dmDevInfo.range, device->isOnline, device->capabilityBitmap[0]); - + int32_t actionId = 0; + int32_t ret = GetAttrFromExtraData(dmDevInfo, actionId); + if (ret != DM_OK) { + LOGE("GetAttrFromExtraData failed"); + return; + } std::lock_guard lock(g_lnnCbkMapMutex); + discoveredDeviceActionIdMap[dmDevInfo.deviceId] = actionId; CacheDiscoveredDevice(device); for (auto &iter : lnnOpsCbkMap) { iter.second->OnDeviceFound(iter.first, dmDevInfo, device->isOnline); @@ -1287,5 +1298,72 @@ int32_t SoftbusListener::GetUdidFromDp(const std::string &udidHash, std::string #endif return ERR_DM_FAILED; } + +int32_t SoftbusListener::GetAttrFromExtraData(DmDeviceInfo &dmDevInfo, int32_t &actionId) +{ + cJSON *extraDataJsonObj = cJSON_Parse(dmDevInfo.extraData.c_str()); + if (extraDataJsonObj == NULL) { + return DM_OK; + } + cJSON *customData = cJSON_GetObjectItem(extraDataJsonObj, PARAM_KEY_CUSTOM_DATA); + if (customData == NULL) { + cJSON_Delete(extraDataJsonObj); + return DM_OK; + } + cJSON *customDataJson = cJSON_Parse(customData->valuestring); + if (customDataJson == NULL) { + cJSON_Delete(extraDataJsonObj); + return DM_OK; + } + int32_t ret = GetAttrFromCustomData(customDataJson, dmDevInfo, actionId); + cJSON_Delete(customDataJson); + cJSON_Delete(extraDataJsonObj); + return ret; +} + +int32_t SoftbusListener::GetAttrFromCustomData(const cJSON *const customDataJson, DmDeviceInfo &dmDevInfo, + int32_t &actionId) +{ + cJSON *actionIdJson = cJSON_GetObjectItem(customDataJson, CUSTOM_DATA_ACTIONID); + if (actionIdJson == NULL || !cJSON_IsNumber(actionIdJson)) { + return DM_OK; + } + actionId = actionIdJson->valueint; + cJSON *networkIdJson = cJSON_GetObjectItem(customDataJson, CUSTOM_DATA_NETWORKID); + if (networkIdJson == NULL || !cJSON_IsString(networkIdJson)) { + return DM_OK; + } + std::string networkId = networkIdJson->valuestring; + if (memcpy_s(dmDevInfo.deviceId, sizeof(dmDevInfo.deviceId), networkId.c_str(), + std::min(sizeof(dmDevInfo.deviceId), sizeof(networkId))) != DM_OK) { + LOGE("copy deviceId failed."); + return ERR_DM_FAILED; + } + if (memcpy_s(dmDevInfo.networkId, sizeof(dmDevInfo.networkId), networkId.c_str(), + std::min(sizeof(dmDevInfo.networkId), sizeof(networkId))) != DM_OK) { + LOGE("copy networkId failed."); + return ERR_DM_FAILED; + } + cJSON *displayNameJson = cJSON_GetObjectItem(customDataJson, CUSTOM_DATA_DISPLAY_NAME); + if (displayNameJson == NULL || !cJSON_IsString(displayNameJson)) { + return DM_OK; + } + std::string displayName = displayNameJson->valuestring; + if (memcpy_s(dmDevInfo.deviceName, sizeof(dmDevInfo.deviceName), displayName.c_str(), + std::min(sizeof(dmDevInfo.deviceName), sizeof(displayName))) != DM_OK) { + LOGE("copy deviceName failed."); + return ERR_DM_FAILED; + } + return DM_OK; +} + +void SoftbusListener::GetActionId(const std::string &deviceId, int32_t &actionId) +{ + std::lock_guard lock(g_lnnCbkMapMutex); + if (discoveredDeviceActionIdMap.find(deviceId) == discoveredDeviceActionIdMap.end()) { + return; + } + actionId = discoveredDeviceActionIdMap.find(deviceId)->second; +} } // namespace DistributedHardware } // namespace OHOS \ No newline at end of file diff --git a/test/commonunittest/UTTest_dm_auth_manager_first.cpp b/test/commonunittest/UTTest_dm_auth_manager_first.cpp index 7c563bde9..637235394 100644 --- a/test/commonunittest/UTTest_dm_auth_manager_first.cpp +++ b/test/commonunittest/UTTest_dm_auth_manager_first.cpp @@ -1382,21 +1382,21 @@ HWTEST_F(DmAuthManagerTest, CheckAuthParamVaildExtra_001, testing::ext::TestSize std::string extra = R"({"extra": {"bindLevel": "123"}})"; nlohmann::json jsonObject; jsonObject["bindLevel"] = 1; - int32_t ret = authManager_->CheckAuthParamVaildExtra(extra); - EXPECT_EQ(ret, DM_OK); + int32_t ret = authManager_->CheckAuthParamVaildExtra(extra, ""); + EXPECT_EQ(ret, ERR_DM_INPUT_PARA_INVALID); extra = SafetyDump(jsonObject); EXPECT_CALL(*appManagerMock_, IsSystemSA()).WillOnce(Return(false)); - ret = authManager_->CheckAuthParamVaildExtra(extra); + ret = authManager_->CheckAuthParamVaildExtra(extra, ""); EXPECT_EQ(ret, ERR_DM_INPUT_PARA_INVALID); EXPECT_CALL(*appManagerMock_, IsSystemSA()).WillOnce(Return(true)); - ret = authManager_->CheckAuthParamVaildExtra(extra); - EXPECT_EQ(ret, DM_OK); + ret = authManager_->CheckAuthParamVaildExtra(extra, ""); + EXPECT_EQ(ret, ERR_DM_INPUT_PARA_INVALID); jsonObject["bindLevel"] = 15; extra = SafetyDump(jsonObject); - ret = authManager_->CheckAuthParamVaildExtra(extra); + ret = authManager_->CheckAuthParamVaildExtra(extra, ""); EXPECT_EQ(ret, ERR_DM_INPUT_PARA_INVALID); } diff --git a/test/commonunittest/UTTest_dm_auth_manager_second.cpp b/test/commonunittest/UTTest_dm_auth_manager_second.cpp index 2416020c8..5e8f303f3 100644 --- a/test/commonunittest/UTTest_dm_auth_manager_second.cpp +++ b/test/commonunittest/UTTest_dm_auth_manager_second.cpp @@ -1263,7 +1263,7 @@ HWTEST_F(DmAuthManagerTest, CheckAuthParamVaild_0013, testing::ext::TestSize.Lev authManager_->authResponseState_ = nullptr; authManager_->softbusConnector_->discoveryDeviceInfoMap_.clear(); int32_t ret = authManager_->CheckAuthParamVaild(pkgName, authType, deviceId, extra); - ASSERT_EQ(ret, ERR_DM_INPUT_PARA_INVALID); + ASSERT_EQ(ret, DM_OK); } HWTEST_F(DmAuthManagerTest, CheckAuthParamVaild_0014, testing::ext::TestSize.Level0) diff --git a/test/softbusfuzztest/onsoftbusdevicefound_fuzzer/BUILD.gn b/test/softbusfuzztest/onsoftbusdevicefound_fuzzer/BUILD.gn index d2195a85e..f960bcba3 100644 --- a/test/softbusfuzztest/onsoftbusdevicefound_fuzzer/BUILD.gn +++ b/test/softbusfuzztest/onsoftbusdevicefound_fuzzer/BUILD.gn @@ -50,6 +50,7 @@ ohos_fuzztest("OnSoftbusDeviceFoundFuzzTest") { ] external_deps = [ + "cJSON:cjson", "c_utils:utils", "dsoftbus:softbus_client", "safwk:system_ability_fwk", diff --git a/test/softbusfuzztest/onsoftbusdeviceinfochanged_fuzzer/BUILD.gn b/test/softbusfuzztest/onsoftbusdeviceinfochanged_fuzzer/BUILD.gn index 0cb1e7b21..420e8426c 100644 --- a/test/softbusfuzztest/onsoftbusdeviceinfochanged_fuzzer/BUILD.gn +++ b/test/softbusfuzztest/onsoftbusdeviceinfochanged_fuzzer/BUILD.gn @@ -45,6 +45,7 @@ ohos_fuzztest("OnSoftbusDeviceInfoChangedFuzzTest") { ] external_deps = [ + "cJSON:cjson", "c_utils:utils", "device_auth:deviceauth_sdk", "device_info_manager:distributed_device_profile_common", diff --git a/test/softbusfuzztest/onsoftbusdeviceoffline_fuzzer/BUILD.gn b/test/softbusfuzztest/onsoftbusdeviceoffline_fuzzer/BUILD.gn index ecf137944..877101702 100644 --- a/test/softbusfuzztest/onsoftbusdeviceoffline_fuzzer/BUILD.gn +++ b/test/softbusfuzztest/onsoftbusdeviceoffline_fuzzer/BUILD.gn @@ -46,6 +46,7 @@ ohos_fuzztest("OnSoftbusDeviceOfflineFuzzTest") { ] external_deps = [ + "cJSON:cjson", "c_utils:utils", "device_auth:deviceauth_sdk", "device_info_manager:distributed_device_profile_common", diff --git a/test/softbusfuzztest/onsoftbusdeviceonline_fuzzer/BUILD.gn b/test/softbusfuzztest/onsoftbusdeviceonline_fuzzer/BUILD.gn index 049ffdb53..72332df3e 100644 --- a/test/softbusfuzztest/onsoftbusdeviceonline_fuzzer/BUILD.gn +++ b/test/softbusfuzztest/onsoftbusdeviceonline_fuzzer/BUILD.gn @@ -46,6 +46,7 @@ ohos_fuzztest("OnSoftbusDeviceOnlineFuzzTest") { ] external_deps = [ + "cJSON:cjson", "c_utils:utils", "device_auth:deviceauth_sdk", "device_info_manager:distributed_device_profile_common", diff --git a/test/softbusfuzztest/onsoftbuslistenerdevicefound_fuzzer/BUILD.gn b/test/softbusfuzztest/onsoftbuslistenerdevicefound_fuzzer/BUILD.gn index 6bc275719..5682d0b4b 100644 --- a/test/softbusfuzztest/onsoftbuslistenerdevicefound_fuzzer/BUILD.gn +++ b/test/softbusfuzztest/onsoftbuslistenerdevicefound_fuzzer/BUILD.gn @@ -45,6 +45,7 @@ ohos_fuzztest("OnSoftbusListenerDeviceFoundFuzzTest") { ] external_deps = [ + "cJSON:cjson", "c_utils:utils", "device_auth:deviceauth_sdk", "device_info_manager:distributed_device_profile_common", diff --git a/test/softbusfuzztest/publishsoftbuslnn_fuzzer/BUILD.gn b/test/softbusfuzztest/publishsoftbuslnn_fuzzer/BUILD.gn index 8a1a5e385..31e0254e8 100644 --- a/test/softbusfuzztest/publishsoftbuslnn_fuzzer/BUILD.gn +++ b/test/softbusfuzztest/publishsoftbuslnn_fuzzer/BUILD.gn @@ -46,6 +46,7 @@ ohos_fuzztest("PublishSoftbusLnnFuzzTest") { ] external_deps = [ + "cJSON:cjson", "c_utils:utils", "device_auth:deviceauth_sdk", "device_info_manager:distributed_device_profile_common", diff --git a/test/softbusfuzztest/refreshsoftbuslnn_fuzzer/BUILD.gn b/test/softbusfuzztest/refreshsoftbuslnn_fuzzer/BUILD.gn index 731f97cc5..2c12dd74e 100644 --- a/test/softbusfuzztest/refreshsoftbuslnn_fuzzer/BUILD.gn +++ b/test/softbusfuzztest/refreshsoftbuslnn_fuzzer/BUILD.gn @@ -46,6 +46,7 @@ ohos_fuzztest("RefreshSoftbusLnnFuzzTest") { ] external_deps = [ + "cJSON:cjson", "c_utils:utils", "device_auth:deviceauth_sdk", "device_info_manager:distributed_device_profile_common", diff --git a/test/softbusfuzztest/softbuslistenergetlocaldeviceinfo_fuzzer/BUILD.gn b/test/softbusfuzztest/softbuslistenergetlocaldeviceinfo_fuzzer/BUILD.gn index caea4d6ff..208f4dd31 100644 --- a/test/softbusfuzztest/softbuslistenergetlocaldeviceinfo_fuzzer/BUILD.gn +++ b/test/softbusfuzztest/softbuslistenergetlocaldeviceinfo_fuzzer/BUILD.gn @@ -49,6 +49,7 @@ ohos_fuzztest("SoftbusListenerGetLocalDeviceInfoFuzzTest") { external_deps = [ "access_token:libaccesstoken_sdk", "access_token:libtokenid_sdk", + "cJSON:cjson", "c_utils:utils", "device_auth:deviceauth_sdk", "device_info_manager:distributed_device_profile_common", diff --git a/test/softbusfuzztest/stoprefreshsoftbuslnn_fuzzer/BUILD.gn b/test/softbusfuzztest/stoprefreshsoftbuslnn_fuzzer/BUILD.gn index b69e49882..23dbd11b3 100644 --- a/test/softbusfuzztest/stoprefreshsoftbuslnn_fuzzer/BUILD.gn +++ b/test/softbusfuzztest/stoprefreshsoftbuslnn_fuzzer/BUILD.gn @@ -46,6 +46,7 @@ ohos_fuzztest("StopRefreshSoftbusLnnFuzzTest") { ] external_deps = [ + "cJSON:cjson", "c_utils:utils", "device_auth:deviceauth_sdk", "device_info_manager:distributed_device_profile_common", diff --git a/test/unittest/BUILD.gn b/test/unittest/BUILD.gn index 258dc2528..b42408371 100644 --- a/test/unittest/BUILD.gn +++ b/test/unittest/BUILD.gn @@ -535,6 +535,7 @@ ohos_unittest("UTTest_mine_softbus_listener") { external_deps = [ "ability_base:want", "ability_runtime:ability_manager", + "cJSON:cjson", "device_auth:deviceauth_sdk", "device_info_manager:distributed_device_profile_common", "device_info_manager:distributed_device_profile_sdk", @@ -1430,6 +1431,7 @@ ohos_unittest("UTTest_discovery_manager") { deps = [ ":device_manager_test_common" ] external_deps = [ + "cJSON:cjson", "device_auth:deviceauth_sdk", "device_info_manager:distributed_device_profile_common", "device_info_manager:distributed_device_profile_sdk", -- Gitee