diff --git a/bundle.json b/bundle.json index 4f20bcf82df4b96da008cfc6e746c712f4714c14..8755fad5d8ceae5662ddfb3608641b31f0f4609e 100644 --- a/bundle.json +++ b/bundle.json @@ -20,7 +20,6 @@ "ram": "16M", "deps": { "components": [ - "aafwk_standard", "appexecfwk_standard", "hiviewdfx_hilog_native", "ipc", diff --git a/common/include/dialog_ui/js/pages/index/index.css b/common/include/dialog_ui/js/pages/index/index.css index 024615c3806a6534e933fafd9fa5b8585e2064fb..02f3350cd83e7af04219e73e73c060d5da5264ad 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; } 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..79a2c413743e0a03fbf89f18892e11c56f53ccc8 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; } 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..d5cc1dd15cca3aa3bf07821544db1a88aeb9e7c8 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; }