diff --git a/bundle.json b/bundle.json index 4f20bcf82df4b96da008cfc6e746c712f4714c14..06952ef47384abcef9ebebef2d5cf7b62fefc703 100644 --- a/bundle.json +++ b/bundle.json @@ -20,7 +20,6 @@ "ram": "16M", "deps": { "components": [ - "aafwk_standard", "appexecfwk_standard", "hiviewdfx_hilog_native", "ipc", @@ -45,11 +44,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 +69,4 @@ ] } } -} \ No newline at end of file +} diff --git a/common/include/dialog_ui/js/pages/index/index.css b/common/include/dialog_ui/js/pages/index/index.css index 024615c3806a6534e933fafd9fa5b8585e2064fb..6a57d7386b47062529e5ab39b1ec32c27e62d51c 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/BUILD.gn b/ext/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..df1b58535c2d55fa019bf3c12c6dafefad964edb --- /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/ext/input_pin_dialog/dialog_ui/js/pages/index/index.css b/ext/input_pin_dialog/dialog_ui/js/pages/index/index.css index 4ef6358fe1480d9328b653b36d2efc590d5e3e93..7a13cd6ce3967228bf41825c336b2cc3a6e16e14 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/mini/services/devicemanagerservice/src/auth/hichain_connector.cpp b/ext/mini/services/devicemanagerservice/src/auth/hichain_connector.cpp index 785d04757a41518a2f23ed330629cb77a19c134a..5e867efa0ec262079982225a2517ee10303d8a5a 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 0000000000000000000000000000000000000000..ebb38c73e584a752976951c67a6766d4b9c95a5c --- /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 f3e34509b04cb811bad1d063b2f368946f0cdfc9..42628e837d6d62fdc8a4b7b3301ab0106cb2b0b1 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 a909b71169ff5cd731b150963b8884bc59b070a6..4b1065f6a40e8ce802a6594a809223f4f9a4b51f 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 67a39b9c44b1c26513c7f0d3a79b102c8688c784..fe7c065a3d755421a943e27dc1f92ff5d34141c1 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) 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 08279e9a3fdc796a6018f761a1fa9777b439bab2..ad2c2c4163304477cc340203355f1f1ea6b60d30 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 diff --git a/interfaces/inner_kits/native_cpp/BUILD.gn b/interfaces/inner_kits/native_cpp/BUILD.gn index 68c8c569cadbd69c2abb355fcb8707fd8ec4939b..99011143aa34c6f8bd509c458f50138fd8ed6ce1 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 900305b1eb2b6841f7acfa23458b585b1cc007ab..811a6d7f49c9bacdfd17d18f177127b3dcd7b8a6 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/ipc/standard/ipc_client_manager.cpp b/interfaces/inner_kits/native_cpp/src/ipc/standard/ipc_client_manager.cpp index cc4db5308d5447e97857f4202ac064cb09ac5c17..06ae13b7536292ed57d5b153f0d25f17203086ba 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 748da1c824852c5731e764bbe74e1cdd5d5993a9..798e5f36128e5eadba41f32a1b884a6881e1f450 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/interfaces/inner_kits/native_cpp/src/notify/device_manager_notify.cpp b/interfaces/inner_kits/native_cpp/src/notify/device_manager_notify.cpp index f1c36875eb76b23974e04affb9ebbe31f1e40b21..987ca17c59d945707a9b04cebe7f114c6cb8f810 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 0000000000000000000000000000000000000000..725c517af55510212a3da6358dd97d27450ae9fa --- /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 5704e27a42dac3bf80b429e59bd8733ff82daaa3..c1b70a129bef76416dad027b23f80ef52e5aed36 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 4e798afa5d234e01b2d92a5039832fc5f8e136ab..cde4b3193c839c7d977c0188478d1d6adbfb58ef 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/services/devicemanagerservice/src/ipc/standard/ipc_server_stub.cpp b/services/devicemanagerservice/src/ipc/standard/ipc_server_stub.cpp index d1b55df74d7923ce86f2fc4f292da7ab7dfd1e2a..fa475b33cf8100190dabe3f14c489ad4e5b26d77 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,21 @@ 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 IPCObjectStub::OnRemoteRequest(cmdCode, data, reply, option); + } + LOGE("read respons"); + return IpcCmdRegister::GetInstance().ReadResponse(cmdCode, reply, rsp); } ServiceRunningState IpcServerStub::QueryServiceState() const diff --git a/test/BUILD.gn b/test/BUILD.gn index d29faeb194418a02c8220d91acb1068c98a57961..e9d4fadb93b89ba74871ec5a6ffc5e69e99a7930 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" ] + } }