From 74c0bcd26e261b26b6e690955c87e520ddc5abb0 Mon Sep 17 00:00:00 2001 From: wanchengzhen Date: Mon, 14 Feb 2022 14:06:33 +0800 Subject: [PATCH 1/7] Fix atomic ability bundle.json change Signed-off-by: wanchengzhen --- bundle.json | 1 - 1 file changed, 1 deletion(-) diff --git a/bundle.json b/bundle.json index 4f20bcf82..8755fad5d 100644 --- a/bundle.json +++ b/bundle.json @@ -20,7 +20,6 @@ "ram": "16M", "deps": { "components": [ - "aafwk_standard", "appexecfwk_standard", "hiviewdfx_hilog_native", "ipc", -- Gitee From 659bba39bd26ab5a317fb8548387edc3a32b1ec0 Mon Sep 17 00:00:00 2001 From: zhushengle Date: Tue, 15 Feb 2022 18:33:29 +0800 Subject: [PATCH 2/7] =?UTF-8?q?feat:=20=20L0=E8=BD=AF=E6=80=BB=E7=BA=BF?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E5=8F=98=E5=8A=A8,=E4=BD=BF=E7=94=A8?= =?UTF-8?q?=E6=96=B0=E9=9A=8F=E6=9C=BA=E6=95=B0=E7=94=9F=E6=88=90=E5=87=BD?= =?UTF-8?q?=E6=95=B0=E5=92=8C=E5=A4=9A=E7=94=A8=E6=88=B7=E9=80=82=E9=85=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Close #I4TRXR Signed-off-by: zhushengle Change-Id: Ib4f62a0687b315048c1293ea7e89bea8b3b7fce3 --- .../src/auth/hichain_connector.cpp | 49 ++++++++++++++++--- .../multipleuser/multiple_user_connector.cpp | 37 ++++++++++++++ .../src/requestauth/request_session.cpp | 5 +- .../src/softbus/softbus_adapter.cpp | 4 +- ext/mini/utils/src/cipher/encrypt_utils.cpp | 4 ++ 5 files changed, 86 insertions(+), 13 deletions(-) create mode 100644 ext/mini/services/devicemanagerservice/src/multipleuser/multiple_user_connector.cpp diff --git a/ext/mini/services/devicemanagerservice/src/auth/hichain_connector.cpp b/ext/mini/services/devicemanagerservice/src/auth/hichain_connector.cpp index 785d04757..5e867efa0 100644 --- a/ext/mini/services/devicemanagerservice/src/auth/hichain_connector.cpp +++ b/ext/mini/services/devicemanagerservice/src/auth/hichain_connector.cpp @@ -37,6 +37,7 @@ #include "softbus_session.h" #include "auth_manager.h" #include "dm_ability_manager.h" +#include "multiple_user_connector.h" namespace OHOS { namespace DistributedHardware { @@ -109,6 +110,7 @@ int64_t HichainConnector::GenRequestId() int32_t HichainConnector::CreateGroup(int64_t requestId, const std::string &groupName) { + int32_t ret; if (deviceGroupManager_ == nullptr) { DMLOG(DM_LOG_ERROR, "HichainConnector::CreateGroup group manager is null, requestId %lld.", requestId); return FAIL; @@ -131,7 +133,13 @@ int32_t HichainConnector::CreateGroup(int64_t requestId, const std::string &grou jsonObj[FIELD_USER_TYPE] = 0; jsonObj[FIELD_GROUP_VISIBILITY] = GROUP_VISIBILITY_PUBLIC; jsonObj[FIELD_EXPIRE_TIME] = FIELD_EXPIRE_TIME_VALUE; - int32_t ret = deviceGroupManager_->createGroup(requestId, DEVICE_MANAGER_APP.c_str(), jsonObj.dump().c_str()); + int32_t userId = MultipleUserConnector::GetCurrentAccountUserID(); + if (userId < 0) { + DMLOG(DM_LOG_ERROR, "get current process account user id failed, userId: %ld", userId); + return FAIL; + } + + ret = deviceGroupManager_->createGroup(userId, requestId, DEVICE_MANAGER_APP.c_str(), jsonObj.dump().c_str()); if (ret != 0) { DMLOG(DM_LOG_ERROR, "Faild to start CreateGroup task, ret: %d, requestId %lld.", ret, requestId); return ret; @@ -157,10 +165,16 @@ int32_t HichainConnector::IsGroupCreated(std::string groupName, GroupInfo &group int32_t HichainConnector::GetGroupInfo(std::string queryParams, std::vector &groupList) { + int32_t ret; char *groupVec = nullptr; uint32_t num = 0; + int32_t userId = MultipleUserConnector::GetCurrentAccountUserID(); + if (userId < 0) { + DMLOG(DM_LOG_ERROR, "get current process account user id failed, userId: %ld", userId); + return false; + } - int32_t ret = deviceGroupManager_->getGroupInfo(DEVICE_MANAGER_APP.c_str(), queryParams.c_str(), &groupVec, &num); + ret = deviceGroupManager_->getGroupInfo(userId, DEVICE_MANAGER_APP.c_str(), queryParams.c_str(), &groupVec, &num); if (ret != 0) { DMLOG(DM_LOG_ERROR, "HichainConnector::GetGroupInfo faild , ret: %d.", ret); return false; @@ -263,9 +277,13 @@ int32_t HichainConnector::AddMemeber(std::string deviceId, std::shared_ptrGetGroupName(); jsonObj[FIELD_CONNECT_PARAMS] = connectInfo.c_str(); std::string tmpStr = jsonObj.dump(); - + int32_t userId = MultipleUserConnector::GetCurrentAccountUserID(); + if (userId < 0) { + DMLOG(DM_LOG_ERROR, "get current process account user id failed, userId: %ld", userId); + return -1; + } DMLOG(DM_LOG_INFO, "HichainConnector::AddMemeber completed"); - return deviceGroupManager_->addMemberToGroup(msgResponseAuth->GetRequestId(), DEVICE_MANAGER_APP.c_str(), + return deviceGroupManager_->addMemberToGroup(userId, msgResponseAuth->GetRequestId(), DEVICE_MANAGER_APP.c_str(), tmpStr.c_str()); } @@ -306,7 +324,13 @@ void HichainConnector::GetRelatedGroups(std::string deviceId, std::vectorgetRelatedGroups(DEVICE_MANAGER_APP.c_str(), deviceId.c_str(), + int32_t userId = MultipleUserConnector::GetCurrentAccountUserID(); + if (userId < 0) { + DMLOG(DM_LOG_ERROR, "get current process account user id failed, userId: %ld", userId); + return; + } + + int32_t ret = deviceGroupManager_->getRelatedGroups(userId, DEVICE_MANAGER_APP.c_str(), deviceId.c_str(), &returnGroups, &groupNum); if (ret != 0) { DMLOG(DM_LOG_ERROR, "HichainConnector::GetRelatedGroups faild , ret: %d.", ret); @@ -389,8 +413,13 @@ int32_t HichainConnector::DelMemberFromGroup(std::string groupId, std::string de jsonObj[FIELD_GROUP_ID] = groupId; jsonObj[FIELD_DELETE_ID] = deviceId; std::string deleteParams = jsonObj.dump(); + int32_t userId = MultipleUserConnector::GetCurrentAccountUserID(); + if (userId < 0) { + DMLOG(DM_LOG_ERROR, "get current process account user id failed, userId: %ld", userId); + return userId; + } - int32_t ret = deviceGroupManager_->deleteMemberFromGroup(requestId, DEVICE_MANAGER_APP.c_str(), + int32_t ret = deviceGroupManager_->deleteMemberFromGroup(userId, requestId, DEVICE_MANAGER_APP.c_str(), deleteParams.c_str()); if (ret != 0) { DMLOG(DM_LOG_ERROR, "HichainConnector::DelMemberFromGroup faild , ret: %d.", ret); @@ -401,12 +430,18 @@ int32_t HichainConnector::DelMemberFromGroup(std::string groupId, std::string de void HichainConnector::DeleteGroup(std::string &groupId) { + int32_t ret; int64_t requestId = GenRequestId(); nlohmann::json jsonObj; jsonObj[FIELD_GROUP_ID] = groupId; std::string disbandParams = jsonObj.dump(); + int32_t userId = MultipleUserConnector::GetCurrentAccountUserID(); + if (userId < 0) { + DMLOG(DM_LOG_ERROR, "get current process account user id failed, userId: %ld", userId); + return; + } - int32_t ret = deviceGroupManager_->deleteGroup(requestId, DEVICE_MANAGER_APP.c_str(), disbandParams.c_str()); + ret = deviceGroupManager_->deleteGroup(userId, requestId, DEVICE_MANAGER_APP.c_str(), disbandParams.c_str()); if (ret != 0) { DMLOG(DM_LOG_ERROR, "HichainConnector::DeleteGroup faild , ret: %d.", ret); } diff --git a/ext/mini/services/devicemanagerservice/src/multipleuser/multiple_user_connector.cpp b/ext/mini/services/devicemanagerservice/src/multipleuser/multiple_user_connector.cpp new file mode 100644 index 000000000..ebb38c73e --- /dev/null +++ b/ext/mini/services/devicemanagerservice/src/multipleuser/multiple_user_connector.cpp @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2021 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 "multiple_user_connector.h" + +namespace OHOS { +namespace DistributedHardware { +int32_t MultipleUserConnector::oldUserId_ = -1; + +int32_t MultipleUserConnector::GetCurrentAccountUserID(void) +{ + return 0; +} + +void MultipleUserConnector::SetSwitchOldUserId(int32_t userId) +{ + oldUserId_ = userId; +} + +int32_t MultipleUserConnector::GetSwitchOldUserId(void) +{ + return oldUserId_; +} +} // namespace DistributedHardware +} // namespace OHOS diff --git a/ext/mini/services/devicemanagerservice/src/requestauth/request_session.cpp b/ext/mini/services/devicemanagerservice/src/requestauth/request_session.cpp index f3e34509b..42628e837 100644 --- a/ext/mini/services/devicemanagerservice/src/requestauth/request_session.cpp +++ b/ext/mini/services/devicemanagerservice/src/requestauth/request_session.cpp @@ -46,10 +46,7 @@ RequestSession::RequestSession(std::string &hostPkgName, std::string &targetPkgN #if (defined(__LINUX__) || defined(__LITEOS_A__)) mPinToken_ = IpcServerAdapter::GenRandInt(MIN_PIN_TOKEN, MAX_PIN_TOKEN); #else - std::random_device randDevice; - std::mt19937 genRand(randDevice()); - std::uniform_int_distribution disRand(MIN_PIN_TOKEN, MAX_PIN_TOKEN); - mPinToken_ = disRand(genRand); + mPinToken_ = MIN_PIN_TOKEN + random() % (MAX_PIN_TOKEN - MIN_PIN_TOKEN); #endif char randStr[TOKEN_LEN] = {0}; bool res = EncryptUtils::MbedtlsGenRandomStr(randStr, sizeof(randStr), false); diff --git a/ext/mini/services/devicemanagerservice/src/softbus/softbus_adapter.cpp b/ext/mini/services/devicemanagerservice/src/softbus/softbus_adapter.cpp index a909b7116..4b1065f6a 100644 --- a/ext/mini/services/devicemanagerservice/src/softbus/softbus_adapter.cpp +++ b/ext/mini/services/devicemanagerservice/src/softbus/softbus_adapter.cpp @@ -124,7 +124,7 @@ void SoftbusAdapter::OnSoftBusDeviceOnline(NodeBasicInfo *info) #endif uint8_t udid[UDID_BUF_LEN] = {0}; int32_t ret = GetNodeKeyInfo(DEVICE_MANAGER_PACKAGE_NAME.c_str(), info->networkId, - NodeDeivceInfoKey::NODE_KEY_UDID, udid, sizeof(udid)); + NodeDeviceInfoKey::NODE_KEY_UDID, udid, sizeof(udid)); if (ret != DEVICEMANAGER_OK) { DMLOG(DM_LOG_ERROR, "GetNodeKeyInfo failed"); return; @@ -428,7 +428,7 @@ bool SoftbusAdapter::IsDeviceOnLine(std::string &deviceId) } uint8_t udid[UDID_BUF_LEN] = {0}; int32_t ret = GetNodeKeyInfo(DEVICE_MANAGER_PACKAGE_NAME.c_str(), networkId.c_str(), - NodeDeivceInfoKey::NODE_KEY_UDID, udid, sizeof(udid)); + NodeDeviceInfoKey::NODE_KEY_UDID, udid, sizeof(udid)); if (ret != DEVICEMANAGER_OK) { DMLOG(DM_LOG_ERROR, "DM_IsDeviceOnLine GetNodeKeyInfo failed"); break; diff --git a/ext/mini/utils/src/cipher/encrypt_utils.cpp b/ext/mini/utils/src/cipher/encrypt_utils.cpp index 67a39b9c4..fe7c065a3 100644 --- a/ext/mini/utils/src/cipher/encrypt_utils.cpp +++ b/ext/mini/utils/src/cipher/encrypt_utils.cpp @@ -45,10 +45,14 @@ int32_t EncryptUtils::MbedtlsBase64Decode(uint8_t *dst, size_t dlen, size_t *ole int32_t EncryptUtils::GenRandInt(int32_t randMin, int32_t randMax) { +#if (defined(__LINUX__) || defined(__LITEOS_A__)) std::random_device randDevice; std::mt19937 genRand(randDevice()); std::uniform_int_distribution disRand(randMin, randMax); return disRand(genRand); +#else + return (randMin + random() % (randMax - randMin)); +#endif } int64_t EncryptUtils::GenRandLongLong(int64_t randMin, int64_t randMax) -- Gitee From 2edd5d0c7a02eddbe0d8b3191e5a38f2ff05ed6d Mon Sep 17 00:00:00 2001 From: lcaidm Date: Wed, 16 Feb 2022 17:25:36 +0800 Subject: [PATCH 3/7] =?UTF-8?q?=E8=83=8C=E6=99=AF/=E6=8C=89=E9=92=AE?= =?UTF-8?q?=E6=A0=B7=E5=BC=8F=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: lcaidm --- common/include/dialog_ui/js/pages/index/index.css | 5 ++++- ext/input_pin_dialog/dialog_ui/js/pages/index/index.css | 5 ++++- ext/show_pin_dialog/dialog_ui/js/pages/index/index.css | 3 ++- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/common/include/dialog_ui/js/pages/index/index.css b/common/include/dialog_ui/js/pages/index/index.css index 024615c38..6a57d7386 100644 --- a/common/include/dialog_ui/js/pages/index/index.css +++ b/common/include/dialog_ui/js/pages/index/index.css @@ -2,7 +2,6 @@ flex-direction: column; justify-content: center; align-items: center; - opacity: 0.8; background-color: azure; } @@ -23,6 +22,8 @@ width: 70%; height: 80px; font-size: 40px; + border: 1px solid #e7e7e7; + border-radius: 50px; } .but2 { @@ -30,6 +31,8 @@ height: 80px; font-size: 40px; margin-left: 10%; + border: 1px solid #e7e7e7; + border-radius: 50px; } diff --git a/ext/input_pin_dialog/dialog_ui/js/pages/index/index.css b/ext/input_pin_dialog/dialog_ui/js/pages/index/index.css index 4ef6358fe..7a13cd6ce 100644 --- a/ext/input_pin_dialog/dialog_ui/js/pages/index/index.css +++ b/ext/input_pin_dialog/dialog_ui/js/pages/index/index.css @@ -2,7 +2,6 @@ flex-direction: column; justify-content: center; align-items: center; - opacity: 0.8; background-color: azure; } @@ -43,6 +42,8 @@ height: 80px; font-size: 40px; margin-left: 10%; + border: 1px solid #e7e7e7; + border-radius: 50px; } .but2 { @@ -50,4 +51,6 @@ height: 80px; font-size: 40px; margin-left: 55%; + border: 1px solid #e7e7e7; + border-radius: 50px; } \ No newline at end of file diff --git a/ext/show_pin_dialog/dialog_ui/js/pages/index/index.css b/ext/show_pin_dialog/dialog_ui/js/pages/index/index.css index 08279e9a3..ad2c2c416 100644 --- a/ext/show_pin_dialog/dialog_ui/js/pages/index/index.css +++ b/ext/show_pin_dialog/dialog_ui/js/pages/index/index.css @@ -2,7 +2,6 @@ flex-direction: column; justify-content: center; align-items: center; - opacity: 0.8; background-color: azure; } @@ -28,4 +27,6 @@ width: 30%; font-size: 40px; height: 80px; + border: 1px solid #e7e7e7; + border-radius: 50px; } \ No newline at end of file -- Gitee From 8a7cccd7801f3bc707a8bd9872a86ae2b656e224 Mon Sep 17 00:00:00 2001 From: handyohos Date: Wed, 16 Feb 2022 22:04:37 +0800 Subject: [PATCH 4/7] bugfix: fix compiling error for qemu-arm-linux-min system. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1)isSystemAppCalling接口导致过多外部依赖,最小系统先隔离该调用;后续需通过access_token的API来访问。 2)devicemanagerservice过多外部依赖,最小系统暂不编译。 3)其它napi模块在最小系统中通过support_jsapi进行隔离。 Signed-off-by: handyohos Change-Id: Ib96a3fb3468104a8873ade4698da140a373c7ced --- bundle.json | 7 +++--- ext/BUILD.gn | 24 +++++++++++++++++++ interfaces/inner_kits/native_cpp/BUILD.gn | 16 ++++++++----- .../native_cpp/src/device_manager_impl.cpp | 9 +++++++ .../src/notify/device_manager_notify.cpp | 1 - interfaces/kits/BUILD.gn | 21 ++++++++++++++++ interfaces/kits/js/BUILD.gn | 4 ---- services/devicemanagerservice/BUILD.gn | 4 ++++ test/BUILD.gn | 5 +++- 9 files changed, 75 insertions(+), 16 deletions(-) create mode 100644 ext/BUILD.gn create mode 100644 interfaces/kits/BUILD.gn diff --git a/bundle.json b/bundle.json index 4f20bcf82..7ba25a8a4 100644 --- a/bundle.json +++ b/bundle.json @@ -45,11 +45,10 @@ "sub_component": [ "//foundation/distributedhardware/devicemanager/utils:devicemanagerutils", "//foundation/distributedhardware/devicemanager/interfaces/inner_kits/native_cpp:devicemanagersdk", - "//foundation/distributedhardware/devicemanager/interfaces/kits/js:devicemanager_native_js", + "//foundation/distributedhardware/devicemanager/interfaces/kits:devicemanager_native_js", "//foundation/distributedhardware/devicemanager/services/devicemanagerservice:devicemanagerservice", "//foundation/distributedhardware/devicemanager/sa_profile:dm_sa_profile", - "//foundation/distributedhardware/devicemanager/ext/pin_auth:devicemanagerext_pin_auth", - "//foundation/distributedhardware/devicemanager/ext/profile:devicemanagerext_profile" + "//foundation/distributedhardware/devicemanager/ext:ext_modules" ], "inner_kits": [ { @@ -71,4 +70,4 @@ ] } } -} \ No newline at end of file +} diff --git a/ext/BUILD.gn b/ext/BUILD.gn new file mode 100644 index 000000000..df1b58535 --- /dev/null +++ b/ext/BUILD.gn @@ -0,0 +1,24 @@ +# Copyright (C) 2021 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. + +import("//build/ohos.gni") + +group("ext_modules") { + deps = [] + if (support_jsapi) { + deps += [ + "./pin_auth:devicemanagerext_pin_auth", + "./profile:devicemanagerext_profile", + ] + } +} diff --git a/interfaces/inner_kits/native_cpp/BUILD.gn b/interfaces/inner_kits/native_cpp/BUILD.gn index 68c8c569c..99011143a 100644 --- a/interfaces/inner_kits/native_cpp/BUILD.gn +++ b/interfaces/inner_kits/native_cpp/BUILD.gn @@ -54,20 +54,24 @@ if (defined(ohos_lite)) { "LOG_DOMAIN=0xD004100", ] - deps = [ - "${utils_path}:devicemanagerutils", - "//foundation/aafwk/standard/interfaces/innerkits/want:want", - ] + deps = [ "${utils_path}:devicemanagerutils" ] external_deps = [ - "bundle_framework:appexecfwk_base", - "bundle_framework:appexecfwk_core", "hiviewdfx_hilog_native:libhilog", "ipc:ipc_core", "samgr_standard:samgr_proxy", "utils_base:utils", ] + if (support_jsapi) { + deps += [ "//foundation/aafwk/standard/interfaces/innerkits/want:want" ] + external_deps += [ + "bundle_framework:appexecfwk_base", + "bundle_framework:appexecfwk_core", + ] + defines += [ "SUPPORT_CALLING_ABILITY" ] + } + subsystem_name = "distributedhardware" part_name = "device_manager_base" diff --git a/interfaces/inner_kits/native_cpp/src/device_manager_impl.cpp b/interfaces/inner_kits/native_cpp/src/device_manager_impl.cpp index 900305b1e..811a6d7f4 100644 --- a/interfaces/inner_kits/native_cpp/src/device_manager_impl.cpp +++ b/interfaces/inner_kits/native_cpp/src/device_manager_impl.cpp @@ -15,10 +15,12 @@ #include "device_manager_impl.h" +#ifdef SUPPORT_CALLING_ABILITY #include "bundle_constants.h" #include "bundle_info.h" #include "bundle_mgr_client.h" #include "bundle_mgr_interface.h" +#endif #include "if_system_ability_manager.h" #include "iservice_registry.h" #include "system_ability_definition.h" @@ -43,13 +45,16 @@ #include "ipc_verify_authenticate_req.h" #include "securec.h" +#ifdef SUPPORT_CALLING_ABILITY using namespace OHOS::AppExecFwk; using namespace OHOS::AppExecFwk::Constants; +#endif namespace OHOS { namespace DistributedHardware { bool DeviceManagerImpl::isSystemAppCalling(void) { +#ifdef SUPPORT_CALLING_ABILITY int32_t uid = IPCSkeleton::GetCallingUid(); if (uid < 0) { LOGI("app caller uid is: %d,", uid); @@ -76,6 +81,10 @@ bool DeviceManagerImpl::isSystemAppCalling(void) } return iBundleMgr->CheckIsSystemAppByUid(uid); +#else + // Minimum system only native services will call + return true; +#endif } DeviceManagerImpl &DeviceManagerImpl::GetInstance() diff --git a/interfaces/inner_kits/native_cpp/src/notify/device_manager_notify.cpp b/interfaces/inner_kits/native_cpp/src/notify/device_manager_notify.cpp index f1c36875e..987ca17c5 100644 --- a/interfaces/inner_kits/native_cpp/src/notify/device_manager_notify.cpp +++ b/interfaces/inner_kits/native_cpp/src/notify/device_manager_notify.cpp @@ -18,7 +18,6 @@ #include "device_manager.h" #include "dm_constants.h" #include "dm_log.h" -#include "nlohmann/json.hpp" namespace OHOS { namespace DistributedHardware { diff --git a/interfaces/kits/BUILD.gn b/interfaces/kits/BUILD.gn new file mode 100644 index 000000000..725c517af --- /dev/null +++ b/interfaces/kits/BUILD.gn @@ -0,0 +1,21 @@ +# Copyright (C) 2021 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. + +import("//build/ohos.gni") + +group("devicemanager_native_js") { + deps = [] + if (support_jsapi) { + deps += [ "./js:devicemanager" ] + } +} diff --git a/interfaces/kits/js/BUILD.gn b/interfaces/kits/js/BUILD.gn index 5704e27a4..c1b70a129 100644 --- a/interfaces/kits/js/BUILD.gn +++ b/interfaces/kits/js/BUILD.gn @@ -61,7 +61,3 @@ ohos_shared_library("devicemanager") { relative_install_dir = "module/distributedhardware" part_name = "device_manager_base" } - -group("devicemanager_native_js") { - deps = [ ":devicemanager" ] -} diff --git a/services/devicemanagerservice/BUILD.gn b/services/devicemanagerservice/BUILD.gn index 5c0c2ae96..c41e20600 100644 --- a/services/devicemanagerservice/BUILD.gn +++ b/services/devicemanagerservice/BUILD.gn @@ -23,6 +23,10 @@ if (defined(ohos_lite)) { executable("devicemanagerservice") { sources = [ "src/ipc/lite/ipc_server_main.cpp" ] } +} else if (!support_jsapi) { + group("devicemanagerservice") { + deps = [] + } } else { config("devicemanagerservice_config") { include_dirs = [ diff --git a/test/BUILD.gn b/test/BUILD.gn index d29faeb19..e9d4fadb9 100644 --- a/test/BUILD.gn +++ b/test/BUILD.gn @@ -14,5 +14,8 @@ group("test") { testonly = true - deps = [ "unittest:unittest" ] + deps = [] + if (support_jsapi) { + deps += [ "unittest:unittest" ] + } } -- Gitee From 311729b86432226128eb4daf5311b063c637ff25 Mon Sep 17 00:00:00 2001 From: caochao Date: Thu, 17 Feb 2022 10:55:59 +0800 Subject: [PATCH 5/7] The sane process cannot ipc communication rectification Signed-off-by: cao_liu_chao --- .../src/ipc/standard/ipc_client_manager.cpp | 1 + .../src/ipc/standard/ipc_client_stub.cpp | 18 ++++++++++++++++-- .../src/ipc/standard/ipc_server_stub.cpp | 17 +++++++++++++++-- 3 files changed, 32 insertions(+), 4 deletions(-) diff --git a/interfaces/inner_kits/native_cpp/src/ipc/standard/ipc_client_manager.cpp b/interfaces/inner_kits/native_cpp/src/ipc/standard/ipc_client_manager.cpp index cc4db5308..06ae13b75 100644 --- a/interfaces/inner_kits/native_cpp/src/ipc/standard/ipc_client_manager.cpp +++ b/interfaces/inner_kits/native_cpp/src/ipc/standard/ipc_client_manager.cpp @@ -18,6 +18,7 @@ #include "device_manager_notify.h" #include "dm_constants.h" #include "dm_log.h" +#include "ipc_client_server_proxy.h" #include "ipc_client_stub.h" #include "ipc_register_listener_req.h" #include "ipc_remote_broker.h" diff --git a/interfaces/inner_kits/native_cpp/src/ipc/standard/ipc_client_stub.cpp b/interfaces/inner_kits/native_cpp/src/ipc/standard/ipc_client_stub.cpp index 748da1c82..798e5f361 100644 --- a/interfaces/inner_kits/native_cpp/src/ipc/standard/ipc_client_stub.cpp +++ b/interfaces/inner_kits/native_cpp/src/ipc/standard/ipc_client_stub.cpp @@ -27,6 +27,7 @@ int32_t IpcClientStub::OnRemoteRequest(uint32_t code, MessageParcel &data, Messa { LOGI("code = %d, flags= %d.", code, option.GetFlags()); if (IpcCmdRegister::GetInstance().OnIpcCmd(code, data, reply) == DM_OK) { + LOGE("on ipc cmd success"); return DM_OK; } LOGW("unsupport code: %d", code); @@ -35,8 +36,21 @@ int32_t IpcClientStub::OnRemoteRequest(uint32_t code, MessageParcel &data, Messa int32_t IpcClientStub::SendCmd(int32_t cmdCode, std::shared_ptr req, std::shared_ptr rsp) { - LOGE("error"); - return DM_OK; + LOGI("SendCmd cmdCode: %d", cmdCode); + MessageParcel data; + MessageParcel reply; + MessageOption option; + if (IpcCmdRegister::GetInstance().SetRequest(cmdCode, req, data) != DM_OK) { + LOGE("set request cmd failed"); + return DM_IPC_FAILED; + } + + LOGI("cmdCode = %d, flags= %d.", cmdCode, option.GetFlags()); + if (IpcCmdRegister::GetInstance().OnIpcCmd(cmdCode, data, reply) == DM_OK) { + LOGE("on ipc cmd success"); + return DM_OK; + } + return IpcCmdRegister::GetInstance().ReadResponse(cmdCode, reply, rsp); } } // namespace DistributedHardware } // namespace OHOS diff --git a/services/devicemanagerservice/src/ipc/standard/ipc_server_stub.cpp b/services/devicemanagerservice/src/ipc/standard/ipc_server_stub.cpp index d1b55df74..dc2d74a92 100644 --- a/services/devicemanagerservice/src/ipc/standard/ipc_server_stub.cpp +++ b/services/devicemanagerservice/src/ipc/standard/ipc_server_stub.cpp @@ -67,7 +67,7 @@ bool IpcServerStub::Init() } registerToService_ = true; } - std::thread {[] { DeviceManagerService::GetInstance().Init(); }}.detach(); + DeviceManagerService::GetInstance().Init(); return true; } @@ -93,7 +93,20 @@ int32_t IpcServerStub::OnRemoteRequest(uint32_t code, MessageParcel &data, Messa int32_t IpcServerStub::SendCmd(int32_t cmdCode, std::shared_ptr req, std::shared_ptr rsp) { LOGI("SendCmd cmdCode: %d", cmdCode); - return DM_OK; + MessageParcel data; + MessageParcel reply; + MessageOption option; + if (IpcCmdRegister::GetInstance().SetRequest(cmdCode, req, data) != DM_OK) { + LOGE("set request cmd failed"); + return DM_IPC_FAILED; + } + + int32_t ret = IpcCmdRegister::GetInstance().OnIpcCmd(cmdCode, data, reply); + if (ret == DM_IPC_NOT_REGISTER_FUNC) { + LOGW("unsupport code: %d", cmdCode); + return IpcCmdRegister::GetInstance().ReadResponse(cmdCode, reply, rsp); + } + return ret; } ServiceRunningState IpcServerStub::QueryServiceState() const -- Gitee From 5e6acd3a9367e0d510c434bbe2f811727dcf1350 Mon Sep 17 00:00:00 2001 From: caochao Date: Mon, 21 Feb 2022 04:47:30 -0800 Subject: [PATCH 6/7] The sane process cannot ipc communication rectification Signed-off-by: cao_liu_chao --- .../devicemanagerservice/src/ipc/standard/ipc_server_stub.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/devicemanagerservice/src/ipc/standard/ipc_server_stub.cpp b/services/devicemanagerservice/src/ipc/standard/ipc_server_stub.cpp index dc2d74a92..a6235f45b 100644 --- a/services/devicemanagerservice/src/ipc/standard/ipc_server_stub.cpp +++ b/services/devicemanagerservice/src/ipc/standard/ipc_server_stub.cpp @@ -104,7 +104,7 @@ int32_t IpcServerStub::SendCmd(int32_t cmdCode, std::shared_ptr req, std int32_t ret = IpcCmdRegister::GetInstance().OnIpcCmd(cmdCode, data, reply); if (ret == DM_IPC_NOT_REGISTER_FUNC) { LOGW("unsupport code: %d", cmdCode); - return IpcCmdRegister::GetInstance().ReadResponse(cmdCode, reply, rsp); + return IPCObjectStub::OnRemoteRequest(cmdCode, data, reply, option); } return ret; } -- Gitee From d028ba12603324c7b00491bb182c35b822e11420 Mon Sep 17 00:00:00 2001 From: caochao <2930650069@qq.com> Date: Mon, 21 Feb 2022 21:38:56 +0800 Subject: [PATCH 7/7] The sane process cannot ipc communication rectification Signed-off-by: cao_liu_chao --- .../src/ipc/standard/ipc_server_stub.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/services/devicemanagerservice/src/ipc/standard/ipc_server_stub.cpp b/services/devicemanagerservice/src/ipc/standard/ipc_server_stub.cpp index a6235f45b..fa475b33c 100644 --- a/services/devicemanagerservice/src/ipc/standard/ipc_server_stub.cpp +++ b/services/devicemanagerservice/src/ipc/standard/ipc_server_stub.cpp @@ -104,9 +104,10 @@ int32_t IpcServerStub::SendCmd(int32_t cmdCode, std::shared_ptr req, std int32_t ret = IpcCmdRegister::GetInstance().OnIpcCmd(cmdCode, data, reply); if (ret == DM_IPC_NOT_REGISTER_FUNC) { LOGW("unsupport code: %d", cmdCode); - return IPCObjectStub::OnRemoteRequest(cmdCode, data, reply, option); + return IPCObjectStub::OnRemoteRequest(cmdCode, data, reply, option); } - return ret; + LOGE("read respons"); + return IpcCmdRegister::GetInstance().ReadResponse(cmdCode, reply, rsp); } ServiceRunningState IpcServerStub::QueryServiceState() const -- Gitee