diff --git a/BUILD.gn b/BUILD.gn
index 7e5dfc76c562adc8cc23b22f6b9a1ff6c989cacb..67ff48712b112a59bf740f46f827f1aef3d07365 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -11,13 +11,14 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-import("//build/lite/config/component/lite_component.gni")
-
if (defined(ohos_lite)) {
+ import("//build/lite/config/component/lite_component.gni")
lite_component("devicemanager_lite") {
- if (ohos_kernel_type == "liteos_m") {
- } else {
- features = []
- }
+ features = [
+ "utils:devicemanagerutils",
+ "services/devicemanagerservice:devicemanagerservice",
+ "interfaces/inner_kits/native_cpp:devicemanagersdk",
+ "ext/pin_auth:devicemanagerext_pin_auth",
+ ]
}
}
diff --git a/common/include/dm_constants.h b/common/include/dm_constants.h
old mode 100755
new mode 100644
diff --git a/common/include/dialog_ui/js/BUILD.gn b/common/include/show_confirm_dialog/dialog_ui/js/BUILD.gn
similarity index 95%
rename from common/include/dialog_ui/js/BUILD.gn
rename to common/include/show_confirm_dialog/dialog_ui/js/BUILD.gn
index 0792bde2900fd3ac9b5176e43f724b8de178ce9f..d360a06102d2ea9e718acbf23dab56678bc89cde 100644
--- a/common/include/dialog_ui/js/BUILD.gn
+++ b/common/include/show_confirm_dialog/dialog_ui/js/BUILD.gn
@@ -15,7 +15,7 @@ import("//foundation/ace/ace_engine/build/ace_gen_sa_dialog_js.gni")
import("//foundation/distributedhardware/devicemanager/devicemanager.gni")
gen_sa_dialog_js("dialog_js_files_etc") {
- project_path = "//foundation/distributedhardware/devicemanager/common/include/dialog_ui/js"
+ project_path = "//foundation/distributedhardware/devicemanager/common/include/show_confirm_dialog/dialog_ui/js"
dialog_name = "config_dialog_service"
part_name = "device_manager_base"
subsystem_name = "distributedhardware"
diff --git a/common/include/dialog_ui/js/common/pincode.png b/common/include/show_confirm_dialog/dialog_ui/js/common/pincode.png
similarity index 100%
rename from common/include/dialog_ui/js/common/pincode.png
rename to common/include/show_confirm_dialog/dialog_ui/js/common/pincode.png
diff --git a/common/include/dialog_ui/js/i18n/en-US.json b/common/include/show_confirm_dialog/dialog_ui/js/i18n/en-US.json
similarity index 100%
rename from common/include/dialog_ui/js/i18n/en-US.json
rename to common/include/show_confirm_dialog/dialog_ui/js/i18n/en-US.json
diff --git a/common/include/dialog_ui/js/i18n/zh-CN.json b/common/include/show_confirm_dialog/dialog_ui/js/i18n/zh-CN.json
similarity index 100%
rename from common/include/dialog_ui/js/i18n/zh-CN.json
rename to common/include/show_confirm_dialog/dialog_ui/js/i18n/zh-CN.json
diff --git a/common/include/dialog_ui/js/pages/index/index.css b/common/include/show_confirm_dialog/dialog_ui/js/pages/index/index.css
similarity index 95%
rename from common/include/dialog_ui/js/pages/index/index.css
rename to common/include/show_confirm_dialog/dialog_ui/js/pages/index/index.css
index 6a57d7386b47062529e5ab39b1ec32c27e62d51c..72630ca514539b8ac5d23be1252c3990f665de65 100644
--- a/common/include/dialog_ui/js/pages/index/index.css
+++ b/common/include/show_confirm_dialog/dialog_ui/js/pages/index/index.css
@@ -18,7 +18,7 @@
height: 100px;
}
-.but1 {
+.but-cancel {
width: 70%;
height: 80px;
font-size: 40px;
@@ -26,7 +26,7 @@
border-radius: 50px;
}
-.but2 {
+.but-confirm {
width: 30%;
height: 80px;
font-size: 40px;
diff --git a/common/include/dialog_ui/js/pages/index/index.hml b/common/include/show_confirm_dialog/dialog_ui/js/pages/index/index.hml
similarity index 68%
rename from common/include/dialog_ui/js/pages/index/index.hml
rename to common/include/show_confirm_dialog/dialog_ui/js/pages/index/index.hml
index 4a689e272e87c59f32f11fb626795649dbb3f722..8ce5443f5b8ab4d28486a308d8aac8daba098c87 100644
--- a/common/include/dialog_ui/js/pages/index/index.hml
+++ b/common/include/show_confirm_dialog/dialog_ui/js/pages/index/index.hml
@@ -6,10 +6,10 @@
用于分享图片
-
diff --git a/common/include/dialog_ui/js/pages/index/index.js b/common/include/show_confirm_dialog/dialog_ui/js/pages/index/index.js
similarity index 93%
rename from common/include/dialog_ui/js/pages/index/index.js
rename to common/include/show_confirm_dialog/dialog_ui/js/pages/index/index.js
index f579f6a3e554e0dcb02bd8e95b2e1e5577304402..13a4384c54373870c4ca3b1e17d2daf7567c1239 100644
--- a/common/include/dialog_ui/js/pages/index/index.js
+++ b/common/include/show_confirm_dialog/dialog_ui/js/pages/index/index.js
@@ -3,7 +3,6 @@ import router from '@ohos.router'
var timel = null;
export default {
data: {
- message: router.getParams().targetPkgName,
seconds:60,
},
onInit() {
diff --git a/display/@ohos.distributedHardware.deviceManager.d.ts b/display/@ohos.distributedHardware.deviceManager.d.ts
index 69179ba17e203845da9658da477386deed0167ee..d00376306a92181187afa2623d4f18fff21648cd 100644
--- a/display/@ohos.distributedHardware.deviceManager.d.ts
+++ b/display/@ohos.distributedHardware.deviceManager.d.ts
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2020 Huawei Device Co., Ltd.
+ * Copyright (c) 2022 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
diff --git a/ext/input_pin_dialog/dialog_ui/js/common/KeyBoard.js b/ext/input_pin_dialog/dialog_ui/js/common/KeyBoard.js
deleted file mode 100644
index c3234a50dc7569ed8bf587f6ea22899f0671b0f2..0000000000000000000000000000000000000000
--- a/ext/input_pin_dialog/dialog_ui/js/common/KeyBoard.js
+++ /dev/null
@@ -1,86 +0,0 @@
-
-;(function(exports){
- var KeyBoard = function(input, options){
- var body = document.getElementsByTagName('body')[0];
- var DIV_ID = options && options.divId || '__w_l_h_v_c_z_e_r_o_divid';
-
- if(document.getElementById(DIV_ID)){
- body.removeChild(document.getElementById(DIV_ID));
- }
-
- this.input = input;
- this.el = document.createElement('div');
-
- var self = this;
- var zIndex = options && options.zIndex || 1000;
- var width = options && options.width || '100%';
- var height = options && options.height || '193px';
- var fontSize = options && options.fontSize || '15px';
- var backgroundColor = options && options.backgroundColor || '#fff';
- var TABLE_ID = options && options.table_id || 'table_0909099';
- var mobile = typeof orientation !== 'undefined';
-
- this.el.id = DIV_ID;
- this.el.style.position = 'absolute';
- this.el.style.left = 0;
- this.el.style.right = 0;
- this.el.style.bottom = 0;
- this.el.style.zIndex = zIndex;
- this.el.style.width = width;
- this.el.style.height = height;
- this.el.style.backgroundColor = backgroundColor;
-
- //样式
- var cssStr = '';
-
- //Button
- var btnStr = '完成
';
-
- //table
- var tableStr = '';
- tableStr += '1 | 2 | 3 |
';
- tableStr += '4 | 5 | 6 |
';
- tableStr += '7 | 8 | 9 |
';
- tableStr += '. | 0 | ';
- tableStr += '删除 |
';
- tableStr += '
';
- this.el.innerHTML = cssStr + btnStr + tableStr;
-
- function addEvent(e){
- var ev = e || window.event;
- var clickEl = ev.element || ev.target;
- var value = clickEl.textContent || clickEl.innerText;
- if(clickEl.tagName.toLocaleLowerCase() === 'td' && value !== "删除"){
- if(self.input){
- self.input.value += value;
- }
- }else if(clickEl.tagName.toLocaleLowerCase() === 'div' && value === "完成"){
- body.removeChild(self.el);
- }else if(clickEl.tagName.toLocaleLowerCase() === 'td' && value === "删除"){
- var num = self.input.value;
- if(num){
- var newNum = num.substr(0, num.length - 1);
- self.input.value = newNum;
- }
- }
- }
-
- if(mobile){
- this.el.ontouchstart = addEvent;
- }else{
- this.el.onclick = addEvent;
- }
- body.appendChild(this.el);
- }
-
- exports.KeyBoard = KeyBoard;
-
-})(window);
\ No newline at end of file
diff --git a/ext/input_pin_dialog/dialog_ui/js/common/index.hml b/ext/input_pin_dialog/dialog_ui/js/common/index.hml
deleted file mode 100644
index 3566d9ba28b0696c15f59dcf87adaa6155fb5430..0000000000000000000000000000000000000000
--- a/ext/input_pin_dialog/dialog_ui/js/common/index.hml
+++ /dev/null
@@ -1,32 +0,0 @@
-
-
- PIN码连接
-
-
- 请输入另一个设备显示的PIN码进行验证
-
-
-
-
- PIN码输入错误,请重新输入
-
-
-
- 取消
-
-
- 确定
-
-
-
-
-
-
diff --git a/ext/mini/interfaces_mini/kits/js/include/dm_native_event.h b/ext/mini/interfaces_mini/kits/js/include/dm_native_event.h
index d2975263ac10e4d43744466ba7e1a9543709a7d2..c0be7ad119c887234ef30dee4e85366ee6f9042a 100644
--- a/ext/mini/interfaces_mini/kits/js/include/dm_native_event.h
+++ b/ext/mini/interfaces_mini/kits/js/include/dm_native_event.h
@@ -12,7 +12,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-//
+
#ifndef OHOS_DEVICE_MANAGER_NATIVE_EVENT_H
#define OHOS_DEVICE_MANAGER_NATIVE_EVENT_H
diff --git a/ext/mini/interfaces_mini/kits/js/src/native_devicemanager_js.cpp b/ext/mini/interfaces_mini/kits/js/src/native_devicemanager_js.cpp
index 50686dfb69f2650e75f51eff73cd4466dc77da4c..e90ff6dcb04682a236380d3dd75e1ffe1d3dd649 100644
--- a/ext/mini/interfaces_mini/kits/js/src/native_devicemanager_js.cpp
+++ b/ext/mini/interfaces_mini/kits/js/src/native_devicemanager_js.cpp
@@ -549,7 +549,7 @@ void DeviceManagerModule::JsToDmBuffer(const JSIValue &object,
}
*bufferPtr = (uint8_t*)calloc(sizeof(uint8_t), length);
if (*bufferPtr == nullptr) {
- DMLOG(DM_LOG_ERROR, "low memory, calloc return nullptr, length is %d, filed %s", length, fieldStr.c_str());
+ DMLOG(DM_LOG_ERROR, "low memory, calloc return nullptr, length is %zu, filed %s", length, fieldStr.c_str());
return;
}
if (memcpy_s(*bufferPtr, length, data, length) != 0) {
diff --git a/ext/mini/services/devicemanagerservice/src/ability/standard/dm_ability_manager.cpp b/ext/mini/services/devicemanagerservice/src/ability/standard/dm_ability_manager.cpp
index 472831899564ac47325d82d36e1a0d4c71296e3f..69143cada59c7de41f2db6d12482b737e6f15deb 100644
--- a/ext/mini/services/devicemanagerservice/src/ability/standard/dm_ability_manager.cpp
+++ b/ext/mini/services/devicemanagerservice/src/ability/standard/dm_ability_manager.cpp
@@ -72,7 +72,7 @@ AbilityStatus DmAbilityManager::StartAbility(AbilityRole role)
if (result == OHOS::ERR_OK) {
DMLOG(DM_LOG_INFO, "Start Ability succeed");
} else {
- DMLOG(DM_LOG_INFO, "Start Ability faild");
+ DMLOG(DM_LOG_INFO, "Start Ability failed");
mStatus_ = AbilityStatus::ABILITY_STATUS_FAILED;
return mStatus_;
}
diff --git a/ext/mini/services/devicemanagerservice/src/auth/hichain_connector.cpp b/ext/mini/services/devicemanagerservice/src/auth/hichain_connector.cpp
index 5e867efa0ec262079982225a2517ee10303d8a5a..6fed5fda6aeef49d8d97627ad104642eed779591 100644
--- a/ext/mini/services/devicemanagerservice/src/auth/hichain_connector.cpp
+++ b/ext/mini/services/devicemanagerservice/src/auth/hichain_connector.cpp
@@ -141,7 +141,7 @@ int32_t HichainConnector::CreateGroup(int64_t requestId, const std::string &grou
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);
+ DMLOG(DM_LOG_ERROR, "Failed to start CreateGroup task, ret: %d, requestId %lld.", ret, requestId);
return ret;
}
@@ -176,12 +176,12 @@ int32_t HichainConnector::GetGroupInfo(std::string queryParams, std::vectorgetGroupInfo(userId, DEVICE_MANAGER_APP.c_str(), queryParams.c_str(), &groupVec, &num);
if (ret != 0) {
- DMLOG(DM_LOG_ERROR, "HichainConnector::GetGroupInfo faild , ret: %d.", ret);
+ DMLOG(DM_LOG_ERROR, "HichainConnector::GetGroupInfo failed , ret: %d.", ret);
return false;
}
if (groupVec == nullptr) {
- DMLOG(DM_LOG_ERROR, "HichainConnector::GetGroupInfo faild , returnGroups is nullptr");
+ DMLOG(DM_LOG_ERROR, "HichainConnector::GetGroupInfo failed , returnGroups is nullptr");
return false;
}
@@ -333,12 +333,12 @@ void HichainConnector::GetRelatedGroups(std::string deviceId, std::vectorgetRelatedGroups(userId, DEVICE_MANAGER_APP.c_str(), deviceId.c_str(),
&returnGroups, &groupNum);
if (ret != 0) {
- DMLOG(DM_LOG_ERROR, "HichainConnector::GetRelatedGroups faild , ret: %d.", ret);
+ DMLOG(DM_LOG_ERROR, "HichainConnector::GetRelatedGroups failed , ret: %d.", ret);
return;
}
if (returnGroups == nullptr) {
- DMLOG(DM_LOG_ERROR, "HichainConnector::GetRelatedGroups faild , returnGroups is nullptr");
+ DMLOG(DM_LOG_ERROR, "HichainConnector::GetRelatedGroups failed , returnGroups is nullptr");
return;
}
@@ -422,7 +422,7 @@ int32_t HichainConnector::DelMemberFromGroup(std::string groupId, std::string de
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);
+ DMLOG(DM_LOG_ERROR, "HichainConnector::DelMemberFromGroup failed , ret: %d.", ret);
return ret;
}
return 0;
@@ -443,7 +443,7 @@ void HichainConnector::DeleteGroup(std::string &groupId)
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);
+ DMLOG(DM_LOG_ERROR, "HichainConnector::DeleteGroup failed , ret: %d.", ret);
}
}
diff --git a/ext/mini/services/devicemanagerservice/src/dispatch/server_stub.cpp b/ext/mini/services/devicemanagerservice/src/dispatch/server_stub.cpp
index bb83afe69afccda47b79bc2c31195edda7a83ddc..33c73579028db98a975e9d952582e35bf5d89f2a 100644
--- a/ext/mini/services/devicemanagerservice/src/dispatch/server_stub.cpp
+++ b/ext/mini/services/devicemanagerservice/src/dispatch/server_stub.cpp
@@ -57,7 +57,7 @@ static const char *GetName(Service *service)
static BOOL Initialize(Service *service, Identity identity)
{
- if (service == NULL) {
+ if (service == nullptr) {
DMLOG(DM_LOG_WARN, "invalid param");
return FALSE;
}
@@ -71,7 +71,7 @@ static BOOL Initialize(Service *service, Identity identity)
static BOOL MessageHandle(Service *service, Request *request)
{
- if ((service == NULL) || (request == NULL)) {
+ if ((service == nullptr) || (request == nullptr)) {
DMLOG(DM_LOG_WARN, "invalid param");
return FALSE;
}
@@ -85,9 +85,6 @@ static TaskConfig GetTaskConfig(Service *service)
return config;
}
-
-
-
static void DevMgrSvcInit(void)
{
sleep(WAIT_FOR_SERVER);
@@ -96,9 +93,6 @@ static void DevMgrSvcInit(void)
.Initialize = Initialize,
.MessageHandle = MessageHandle,
.GetTaskConfig = GetTaskConfig,
- // SERVER_IPROXY_IMPL_BEGIN,
- // .Invoke = OnRemoteRequest,
- // IPROXY_END,
};
if (!SAMGR_GetInstance()->RegisterService((Service *)&service)) {
diff --git a/ext/pin_auth/BUILD.gn b/ext/pin_auth/BUILD.gn
index 41bfe45895d84043dd289304b4e37359cf414055..5d9a18e1070768e852314f2186760a44c530cade 100644
--- a/ext/pin_auth/BUILD.gn
+++ b/ext/pin_auth/BUILD.gn
@@ -16,20 +16,88 @@ if (defined(ohos_lite)) {
} else {
import("//build/ohos.gni")
}
-
import("//foundation/distributedhardware/devicemanager/devicemanager.gni")
if (defined(ohos_lite)) {
+ shared_library("devicemanagerext_pin_auth") {
+ include_dirs = [
+ "include",
+ "include/lite",
+ "${common_path}/include",
+ "${ext_path}/pin_auth/include/ability",
+ "${services_path}/include/dependency/timer",
+ "${services_path}/include/config",
+ "${services_path}/include/adapter",
+ "${services_path}/include/authentication",
+ "${services_path}/include/authentication/showconfirm/lite",
+ "${services_path}/include/ability",
+ "${services_path}/include/deviceinfo",
+ "${services_path}/include/devicestate",
+ "${services_path}/include/discovery",
+ "${services_path}/include/dependency/commonevent",
+ "${services_path}/include/dependency/hichain",
+ "${services_path}/include/dependency/softbus",
+ "${services_path}/include/dependency/timer",
+ "${services_path}/include/ipc",
+ "${services_path}/include/ipc/lite",
+ "${utils_path}/include",
+ "${utils_path}/include/ipc/lite",
+ "${services_path}/include",
+ "${innerkits_path}/native_cpp/include",
+ "${common_path}/include/ipc",
+ "${common_path}/include/ipc/model",
+ "${innerkits_path}/native_cpp/include",
+ "${innerkits_path}/native_cpp/include/ipc",
+ "${innerkits_path}/native_cpp/include/ipc/lite",
+ "//third_party/json/include",
+ "//utils/native/base/include",
+ "//utils/system/safwk/native/include",
+ "//base/notification/ces_lite/frameworks/core/include",
+ "//base/notification/ces_lite/interfaces/innerkits/native/include",
+ "//base/security/deviceauth/interfaces/innerkits",
+ "//base/startup/syspara_lite/interfaces/kits",
+ "//base/startup/syspara_lite/adapter/native/syspara/include",
+ ]
+
+ sources = [
+ "src/ability/lite/dm_ability_manager.cpp",
+ "src/lite/pin_auth_ui.cpp",
+ "src/pin_auth.cpp",
+ ]
+
+ deps = [
+ "${common_path}/include/show_confirm_dialog/dialog_ui/js:dialog_js_files_etc",
+ "${innerkits_path}/native_cpp:devicemanagersdk",
+ "${utils_path}:devicemanagerutils",
+ "//base/hiviewdfx/hilog_lite/frameworks/featured:hilog_shared",
+ "//base/security/deviceauth/services:deviceauth_sdk",
+ "//foundation/communication/dsoftbus/sdk:softbus_client",
+ "//foundation/communication/ipc_lite:liteipc_adapter",
+ "//foundation/distributedschedule/samgr_lite/samgr:samgr",
+ "//third_party/bounds_checking_function:libsec_shared",
+ "//third_party/mbedtls:mbedtls_shared",
+ "//utils/native/lite:utils",
+ ]
+
+ defines = [
+ "LITE_DEVICE",
+ "HI_LOG_ENABLE",
+ "DH_LOG_TAG=\"devicemanagerext\"",
+ "LOG_DOMAIN=0xD004100",
+ ]
+ }
} else {
ohos_shared_library("devicemanagerext_pin_auth") {
include_dirs = [
"include",
+ "include/standard",
"${common_path}/include",
"${ext_path}/pin_auth/include/ability",
"${services_path}/include/dependency/timer",
"${services_path}/include/config",
"${services_path}/include/adapter",
"${services_path}/include/authentication",
+ "${services_path}/include/authentication/showconfirm/standard",
"${services_path}/include/ability",
"${services_path}/include/deviceinfo",
"${services_path}/include/devicestate",
@@ -62,12 +130,12 @@ if (defined(ohos_lite)) {
sources = [
"src/ability/standard/dm_ability_manager.cpp",
"src/pin_auth.cpp",
- "src/pin_auth_ui.cpp",
+ "src/standard/pin_auth_ui.cpp",
]
deps = [
- "${ext_path}/input_pin_dialog/dialog_ui/js:dialog_js_files_etc",
- "${ext_path}/show_pin_dialog/dialog_ui/js:dialog_js_files_etc",
+ "${ext_path}/pin_auth/input_pin_dialog/dialog_ui/js:dialog_js_files_etc",
+ "${ext_path}/pin_auth/show_pin_dialog/dialog_ui/js:dialog_js_files_etc",
"${innerkits_path}/native_cpp:devicemanagersdk",
"${utils_path}:devicemanagerutils",
"//base/security/deviceauth/services:deviceauth_sdk",
diff --git a/ext/pin_auth/include/pin_auth_ui.h b/ext/pin_auth/include/lite/pin_auth_ui.h
similarity index 92%
rename from ext/pin_auth/include/pin_auth_ui.h
rename to ext/pin_auth/include/lite/pin_auth_ui.h
index 5ff26c3e1634b9bfb1ae370b8349b8c0ebab3ebe..dfa24cf89ad4d96a2b6eddc0d972130cd6cc08e6 100644
--- a/ext/pin_auth/include/pin_auth_ui.h
+++ b/ext/pin_auth/include/lite/pin_auth_ui.h
@@ -28,6 +28,7 @@ public:
PinAuthUi();
int32_t ShowPinDialog(int32_t code, std::shared_ptr authManager);
int32_t InputPinDialog(int32_t code, std::shared_ptr authManager);
+ int32_t ClosePage(const int32_t &pageId, std::shared_ptr authManager);
private:
int32_t StartFaUiService(std::shared_ptr dmAbilityManager);
diff --git a/ext/pin_auth/include/pin_auth.h b/ext/pin_auth/include/pin_auth.h
index ac02b101789ce4aad956095c5acf6fd32cbedb56..191a462263b29303726c5c7ceb64fa321c15179c 100644
--- a/ext/pin_auth/include/pin_auth.h
+++ b/ext/pin_auth/include/pin_auth.h
@@ -33,6 +33,7 @@ public:
int32_t ShowAuthInfo(std::string &authToken, std::shared_ptr authManager) override;
int32_t StartAuth(std::string &authToken, std::shared_ptr authManager) override;
int32_t VerifyAuthentication(std::string &authToken, const std::string &authParam) override;
+ int32_t CloseAuthInfo(const int32_t &pageId, std::shared_ptr authManager) override;
private:
int32_t times_ = 0;
std::shared_ptr pinAuthUi_;
diff --git a/ext/pin_auth/include/standard/pin_auth_ui.h b/ext/pin_auth/include/standard/pin_auth_ui.h
new file mode 100644
index 0000000000000000000000000000000000000000..dfa24cf89ad4d96a2b6eddc0d972130cd6cc08e6
--- /dev/null
+++ b/ext/pin_auth/include/standard/pin_auth_ui.h
@@ -0,0 +1,38 @@
+/*
+ * 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.
+ */
+
+#ifndef OHOS_DM_PIN_AUTH_UI_H
+#define OHOS_DM_PIN_AUTH_UI_H
+
+#include
+
+#include "dm_auth_manager.h"
+#include "dm_ability_manager.h"
+
+namespace OHOS {
+namespace DistributedHardware {
+class PinAuthUi {
+public:
+ PinAuthUi();
+ int32_t ShowPinDialog(int32_t code, std::shared_ptr authManager);
+ int32_t InputPinDialog(int32_t code, std::shared_ptr authManager);
+ int32_t ClosePage(const int32_t &pageId, std::shared_ptr authManager);
+
+private:
+ int32_t StartFaUiService(std::shared_ptr dmAbilityManager);
+};
+} // namespace DistributedHardware
+} // namespace OHOS
+#endif // OHOS_DM_PIN_AUTH_UI_H
diff --git a/ext/input_pin_dialog/dialog_ui/js/BUILD.gn b/ext/pin_auth/input_pin_dialog/dialog_ui/js/BUILD.gn
similarity index 95%
rename from ext/input_pin_dialog/dialog_ui/js/BUILD.gn
rename to ext/pin_auth/input_pin_dialog/dialog_ui/js/BUILD.gn
index 8abf88695e272f47842c8c6549920376cff6b74b..a343c353fcba1a5ffa3fb152c9d265a3b75d32fa 100644
--- a/ext/input_pin_dialog/dialog_ui/js/BUILD.gn
+++ b/ext/pin_auth/input_pin_dialog/dialog_ui/js/BUILD.gn
@@ -15,7 +15,7 @@ import("//foundation/ace/ace_engine/build/ace_gen_sa_dialog_js.gni")
import("//foundation/distributedhardware/devicemanager/devicemanager.gni")
gen_sa_dialog_js("dialog_js_files_etc") {
- project_path = "//foundation/distributedhardware/devicemanager/ext/input_pin_dialog/dialog_ui/js"
+ project_path = "//foundation/distributedhardware/devicemanager/ext/pin_auth/input_pin_dialog/dialog_ui/js"
dialog_name = "input_pin_service"
part_name = "device_manager_base"
subsystem_name = "distributedhardware"
diff --git a/ext/input_pin_dialog/dialog_ui/js/common/pincode.png b/ext/pin_auth/input_pin_dialog/dialog_ui/js/common/pincode.png
similarity index 100%
rename from ext/input_pin_dialog/dialog_ui/js/common/pincode.png
rename to ext/pin_auth/input_pin_dialog/dialog_ui/js/common/pincode.png
diff --git a/ext/input_pin_dialog/dialog_ui/js/i18n/en-US.json b/ext/pin_auth/input_pin_dialog/dialog_ui/js/i18n/en-US.json
similarity index 100%
rename from ext/input_pin_dialog/dialog_ui/js/i18n/en-US.json
rename to ext/pin_auth/input_pin_dialog/dialog_ui/js/i18n/en-US.json
diff --git a/ext/input_pin_dialog/dialog_ui/js/i18n/zh-CN.json b/ext/pin_auth/input_pin_dialog/dialog_ui/js/i18n/zh-CN.json
similarity index 100%
rename from ext/input_pin_dialog/dialog_ui/js/i18n/zh-CN.json
rename to ext/pin_auth/input_pin_dialog/dialog_ui/js/i18n/zh-CN.json
diff --git a/ext/input_pin_dialog/dialog_ui/js/pages/index/index.css b/ext/pin_auth/input_pin_dialog/dialog_ui/js/pages/index/index.css
similarity index 96%
rename from ext/input_pin_dialog/dialog_ui/js/pages/index/index.css
rename to ext/pin_auth/input_pin_dialog/dialog_ui/js/pages/index/index.css
index 7a13cd6ce3967228bf41825c336b2cc3a6e16e14..7a310c9505b14086f69dd95e3dae0154c22eb27b 100644
--- a/ext/input_pin_dialog/dialog_ui/js/pages/index/index.css
+++ b/ext/pin_auth/input_pin_dialog/dialog_ui/js/pages/index/index.css
@@ -37,7 +37,7 @@
height: 100px;
}
-.but1 {
+.but-cancel {
width: 30%;
height: 80px;
font-size: 40px;
@@ -46,7 +46,7 @@
border-radius: 50px;
}
-.but2 {
+.but-confirm {
width: 30%;
height: 80px;
font-size: 40px;
diff --git a/ext/input_pin_dialog/dialog_ui/js/pages/index/index.hml b/ext/pin_auth/input_pin_dialog/dialog_ui/js/pages/index/index.hml
similarity index 79%
rename from ext/input_pin_dialog/dialog_ui/js/pages/index/index.hml
rename to ext/pin_auth/input_pin_dialog/dialog_ui/js/pages/index/index.hml
index 84f217637922f7f11220581ad95ca82c435abbf6..53558da904c5d13768c9a31383aed65dbd133aa8 100644
--- a/ext/input_pin_dialog/dialog_ui/js/pages/index/index.hml
+++ b/ext/pin_auth/input_pin_dialog/dialog_ui/js/pages/index/index.hml
@@ -10,10 +10,10 @@
PIN码输入错误,请重新输入(3次:还有{{isTimes}}次机会)
-
+
取消
-
+
确定
diff --git a/ext/input_pin_dialog/dialog_ui/js/pages/index/index.js b/ext/pin_auth/input_pin_dialog/dialog_ui/js/pages/index/index.js
similarity index 74%
rename from ext/input_pin_dialog/dialog_ui/js/pages/index/index.js
rename to ext/pin_auth/input_pin_dialog/dialog_ui/js/pages/index/index.js
index 514b6ec77625f87c10ea936fcd20191c9f544f72..488972d500f7250991051ef8511d5c24f22ce86d 100644
--- a/ext/input_pin_dialog/dialog_ui/js/pages/index/index.js
+++ b/ext/pin_auth/input_pin_dialog/dialog_ui/js/pages/index/index.js
@@ -19,22 +19,21 @@ export default {
onConfirm() {
numbs = numbs + 1;
if(numbs <= 3){
- console.info('click cancel numbs < 3 ');
- console.info('code: ' + code);
- console.info('inputVal: ' + inputVal);
+ console.info('click confirm numbs < 3 ');
if(code == inputVal){
- console.info('click cancel code == inputVal');
+ console.info('click confirm code == inputVal');
callNativeHandler("EVENT_INPUT", "0");
}else{
if(numbs == 3){
+ console.info('click confirm code != inputVal and numbs == 3');
callNativeHandler("EVENT_CONFIRM", "1");
}
- console.info('click cancel code != inputVal');
+ console.info('click confirm code != inputVal');
this.isShow = true;
this.isTimes = 3 - numbs;
}
}else{
- console.info('click cancel numbs > 3 ');
+ console.info('click confirm numbs > 3 ');
callNativeHandler("EVENT_CONFIRM", "1");
}
},
diff --git a/ext/show_pin_dialog/dialog_ui/js/BUILD.gn b/ext/pin_auth/show_pin_dialog/dialog_ui/js/BUILD.gn
similarity index 95%
rename from ext/show_pin_dialog/dialog_ui/js/BUILD.gn
rename to ext/pin_auth/show_pin_dialog/dialog_ui/js/BUILD.gn
index 8c623e7f87ffeec940e5f3a0730114001f79f6e0..3139d1947e0331f83c4389822e8bf052c015429b 100644
--- a/ext/show_pin_dialog/dialog_ui/js/BUILD.gn
+++ b/ext/pin_auth/show_pin_dialog/dialog_ui/js/BUILD.gn
@@ -15,7 +15,7 @@ import("//foundation/ace/ace_engine/build/ace_gen_sa_dialog_js.gni")
import("//foundation/distributedhardware/devicemanager/devicemanager.gni")
gen_sa_dialog_js("dialog_js_files_etc") {
- project_path = "//foundation/distributedhardware/devicemanager/ext/show_pin_dialog/dialog_ui/js"
+ project_path = "//foundation/distributedhardware/devicemanager/ext/pin_auth/show_pin_dialog/dialog_ui/js"
dialog_name = "show_pin_service"
part_name = "device_manager_base"
subsystem_name = "distributedhardware"
diff --git a/ext/show_pin_dialog/dialog_ui/js/common/pincode.png b/ext/pin_auth/show_pin_dialog/dialog_ui/js/common/pincode.png
similarity index 100%
rename from ext/show_pin_dialog/dialog_ui/js/common/pincode.png
rename to ext/pin_auth/show_pin_dialog/dialog_ui/js/common/pincode.png
diff --git a/ext/show_pin_dialog/dialog_ui/js/i18n/en-US.json b/ext/pin_auth/show_pin_dialog/dialog_ui/js/i18n/en-US.json
similarity index 100%
rename from ext/show_pin_dialog/dialog_ui/js/i18n/en-US.json
rename to ext/pin_auth/show_pin_dialog/dialog_ui/js/i18n/en-US.json
diff --git a/ext/show_pin_dialog/dialog_ui/js/i18n/zh-CN.json b/ext/pin_auth/show_pin_dialog/dialog_ui/js/i18n/zh-CN.json
similarity index 100%
rename from ext/show_pin_dialog/dialog_ui/js/i18n/zh-CN.json
rename to ext/pin_auth/show_pin_dialog/dialog_ui/js/i18n/zh-CN.json
diff --git a/ext/show_pin_dialog/dialog_ui/js/pages/index/index.css b/ext/pin_auth/show_pin_dialog/dialog_ui/js/pages/index/index.css
similarity index 97%
rename from ext/show_pin_dialog/dialog_ui/js/pages/index/index.css
rename to ext/pin_auth/show_pin_dialog/dialog_ui/js/pages/index/index.css
index ad2c2c4163304477cc340203355f1f1ea6b60d30..8ce639b24540471fdce1155b554c6c090f9fa280 100644
--- a/ext/show_pin_dialog/dialog_ui/js/pages/index/index.css
+++ b/ext/pin_auth/show_pin_dialog/dialog_ui/js/pages/index/index.css
@@ -23,7 +23,7 @@
font-weight: 800;
}
-.but {
+.but-confirm {
width: 30%;
font-size: 40px;
height: 80px;
diff --git a/ext/show_pin_dialog/dialog_ui/js/pages/index/index.hml b/ext/pin_auth/show_pin_dialog/dialog_ui/js/pages/index/index.hml
similarity index 83%
rename from ext/show_pin_dialog/dialog_ui/js/pages/index/index.hml
rename to ext/pin_auth/show_pin_dialog/dialog_ui/js/pages/index/index.hml
index 9cb650aefdc7650e308f4202a3b9ca0ee11cba57..845c99e570c9e56592ea375fa53410773b4c743c 100644
--- a/ext/show_pin_dialog/dialog_ui/js/pages/index/index.hml
+++ b/ext/pin_auth/show_pin_dialog/dialog_ui/js/pages/index/index.hml
@@ -8,7 +8,7 @@
{{ pincode }}
-
+
取消
\ No newline at end of file
diff --git a/ext/show_pin_dialog/dialog_ui/js/pages/index/index.js b/ext/pin_auth/show_pin_dialog/dialog_ui/js/pages/index/index.js
similarity index 83%
rename from ext/show_pin_dialog/dialog_ui/js/pages/index/index.js
rename to ext/pin_auth/show_pin_dialog/dialog_ui/js/pages/index/index.js
index 3a55ac1cc8215df26437b036c9f92ec5dbb7568d..598deca1f5d8075b1e73fbdc3cd4fbdcd5781635 100644
--- a/ext/show_pin_dialog/dialog_ui/js/pages/index/index.js
+++ b/ext/pin_auth/show_pin_dialog/dialog_ui/js/pages/index/index.js
@@ -5,7 +5,6 @@ export default {
pincode: router.getParams().pinCode,
},
onInit() {
- console.info('getParams: ' + router.getParams());
callNativeHandler("EVENT_CONFIRM", "0");
},
onConfirm() {
diff --git a/ext/pin_auth/src/lite/pin_auth_ui.cpp b/ext/pin_auth/src/lite/pin_auth_ui.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..3adc33af7ef5b6fe8eebe3d8318263ebf4b07c8c
--- /dev/null
+++ b/ext/pin_auth/src/lite/pin_auth_ui.cpp
@@ -0,0 +1,70 @@
+/*
+ * 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 "pin_auth_ui.h"
+
+#include "dm_ability_manager.h"
+#include "dm_constants.h"
+#include "dm_log.h"
+#include "nlohmann/json.hpp"
+
+namespace OHOS {
+namespace DistributedHardware {
+PinAuthUi::PinAuthUi()
+{
+ LOGI("AuthUi constructor");
+}
+
+int32_t PinAuthUi::ShowPinDialog(int32_t code, std::shared_ptr authManager)
+{
+ LOGI("ShowConfigDialog end");
+ return DM_OK;
+}
+
+int32_t PinAuthUi::InputPinDialog(int32_t code, std::shared_ptr authManager)
+{
+ LOGI("InputPinDialog start");
+ std::shared_ptr dmAbilityManager_ = std::make_shared();
+ if (dmAbilityManager_ == nullptr) {
+ LOGE("PinAuthUi::dmAbilityManager is null");
+ return DM_FAILED;
+ }
+ LOGI("InputPinDialog end");
+ return StartFaUiService(dmAbilityManager_);
+}
+
+int32_t ClosePage(const int32_t &pageId, std::shared_ptr authManager)
+{
+ LOGI("ClosePage hap start");
+ if (authManager == nullptr) {
+ LOGE("PinAuthUi::authManager is null");
+ return DM_FAILED;
+ }
+ LOGI("ClosePage hap end");
+ authManager->CancelDisplay();
+ return DM_OK;
+}
+
+int32_t PinAuthUi::StartFaUiService(std::shared_ptr dmAbilityManager)
+{
+ AbilityStatus status = dmAbilityManager->StartAbility(AbilityRole::ABILITY_ROLE_INITIATIVE);
+ if (status != AbilityStatus::ABILITY_STATUS_SUCCESS) {
+ LOGE("PinAuthUi::StartFaService timeout");
+ return DM_FAILED;
+ }
+ return DM_OK;
+}
+} // namespace DistributedHardware
+} // namespace OHOS
diff --git a/ext/pin_auth/src/pin_auth.cpp b/ext/pin_auth/src/pin_auth.cpp
index 377cb8fdb1691fe835222a9052333acccf339cc9..25e7f54d6d113718ca71fc90cf97115d7768e0eb 100644
--- a/ext/pin_auth/src/pin_auth.cpp
+++ b/ext/pin_auth/src/pin_auth.cpp
@@ -16,7 +16,7 @@
#include "pin_auth.h"
#include
-#include
+#include
#include "dm_constants.h"
#include "dm_log.h"
@@ -66,7 +66,7 @@ int32_t PinAuth::StartAuth(std::string &authToken, std::shared_ptr authManager)
+{
+ return pinAuthUi_->ClosePage(pageId, authManager);
+}
+
extern "C" IAuthentication *CreatePinAuthObject(void)
{
return new PinAuth;
diff --git a/ext/pin_auth/src/pin_auth_ui.cpp b/ext/pin_auth/src/standard/pin_auth_ui.cpp
similarity index 87%
rename from ext/pin_auth/src/pin_auth_ui.cpp
rename to ext/pin_auth/src/standard/pin_auth_ui.cpp
index eb976a67898c97ed963f8228bf400323baa920f8..fb4222bc4126784f9f619c7420ca2b4fe2c4c93c 100644
--- a/ext/pin_auth/src/pin_auth_ui.cpp
+++ b/ext/pin_auth/src/standard/pin_auth_ui.cpp
@@ -31,6 +31,10 @@ PinAuthUi::PinAuthUi()
int32_t PinAuthUi::ShowPinDialog(int32_t code, std::shared_ptr authManager)
{
LOGI("ShowPinDialog start");
+ if (authManager == nullptr) {
+ LOGE("ShowPinDialog authManager is null");
+ return DM_FAILED;
+ }
nlohmann::json jsonObj;
jsonObj[PIN_CODE_KEY] = code;
jsonObj.dump();
@@ -57,6 +61,10 @@ int32_t PinAuthUi::ShowPinDialog(int32_t code, std::shared_ptr au
int32_t PinAuthUi::InputPinDialog(int32_t code, std::shared_ptr authManager)
{
LOGI("InputPinDialog start");
+ if (authManager == nullptr) {
+ LOGE("ShowPinDialog InputPinDialog is null");
+ return DM_FAILED;
+ }
nlohmann::json jsonObj;
jsonObj[PIN_CODE_KEY] = code;
jsonObj.dump();
@@ -81,6 +89,14 @@ int32_t PinAuthUi::InputPinDialog(int32_t code, std::shared_ptr a
return DM_OK;
}
+int32_t PinAuthUi::ClosePage(const int32_t &pageId, std::shared_ptr authManager)
+{
+ LOGI("PinAuthUi start");
+ Ace::UIServiceMgrClient::GetInstance()->CancelDialog(pageId);
+ LOGI("PinAuthUi end");
+ return DM_OK;
+}
+
int32_t PinAuthUi::StartFaUiService(std::shared_ptr dmAbilityManager)
{
AbilityStatus status = dmAbilityManager->StartAbility(AbilityRole::ABILITY_ROLE_INITIATIVE);
diff --git a/ext/profile/include/device_profile_adapter.h b/ext/profile/include/device_profile_adapter.h
old mode 100755
new mode 100644
diff --git a/ext/profile/include/profile_connector.h b/ext/profile/include/profile_connector.h
old mode 100755
new mode 100644
diff --git a/ext/profile/src/device_profile_adapter.cpp b/ext/profile/src/device_profile_adapter.cpp
old mode 100755
new mode 100644
diff --git a/ext/profile/src/profile_connector.cpp b/ext/profile/src/profile_connector.cpp
old mode 100755
new mode 100644
diff --git a/interfaces/inner_kits/native_cpp/BUILD.gn b/interfaces/inner_kits/native_cpp/BUILD.gn
index a842f4b22d1860015ff9a3330a20bd4cdc946eae..80fde4c7356c3b6d846ed1bddaa537517a8194e9 100644
--- a/interfaces/inner_kits/native_cpp/BUILD.gn
+++ b/interfaces/inner_kits/native_cpp/BUILD.gn
@@ -20,6 +20,51 @@ import("//foundation/distributedhardware/devicemanager/devicemanager.gni")
if (defined(ohos_lite)) {
shared_library("devicemanagersdk") {
+ include_dirs = [
+ "include",
+ "include/ipc",
+ "include/ipc/lite",
+ "include/notify",
+ "${common_path}/include",
+ "${common_path}/include/ipc",
+ "${common_path}/include/ipc/model",
+ "${utils_path}/include",
+ "${utils_path}/include/ipc/lite",
+ ]
+ include_dirs += [
+ "//utils/native/lite/include",
+ "//base/hiviewdfx/hilog_lite/interfaces/native/innerkits/hilog",
+ "//third_party/bounds_checking_function/include",
+ "//foundation/communication/ipc_lite/interfaces/kits",
+ "//foundation/distributedschedule/samgr_lite/interfaces/kits/samgr",
+ "//foundation/distributedschedule/samgr_lite/interfaces/kits/registry",
+ "//third_party/json/include",
+ "//foundation/appexecfwk/appexecfwk_lite/interfaces/kits/bundle_lite/",
+ ]
+ sources = [
+ "src/device_manager.cpp",
+ "src/device_manager_impl.cpp",
+ "src/ipc/ipc_client_proxy.cpp",
+ "src/ipc/lite/ipc_client_manager.cpp",
+ "src/ipc/lite/ipc_client_server_proxy.cpp",
+ "src/ipc/lite/ipc_client_stub.cpp",
+ "src/ipc/lite/ipc_cmd_parser.cpp",
+ "src/notify/device_manager_notify.cpp",
+ ]
+ deps = [
+ "${utils_path}:devicemanagerutils",
+ "//base/hiviewdfx/hilog_lite/frameworks/featured:hilog_shared",
+ "//foundation/communication/ipc_lite:liteipc_adapter",
+ "//foundation/distributedschedule/samgr_lite/samgr:samgr",
+ "//third_party/bounds_checking_function:libsec_shared",
+ "//utils/native/lite:utils",
+ ]
+ defines = [
+ "LITE_DEVICE",
+ "HI_LOG_ENABLE",
+ "DH_LOG_TAG=\"devicemanagerkit\"",
+ "LOG_DOMAIN=0xD004100",
+ ]
}
} else {
config("devicemanagersdk_config") {
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 b17b597b186a7fcf4c7105f14860de42683ebb63..662f5d35f4db1a8e67d522190878884612c34275 100644
--- a/interfaces/inner_kits/native_cpp/include/dm_device_info.h
+++ b/interfaces/inner_kits/native_cpp/include/dm_device_info.h
@@ -49,6 +49,7 @@ typedef struct DmDeviceInfo {
char deviceId[DM_MAX_DEVICE_ID_LEN];
char deviceName[DM_MAX_DEVICE_NAME_LEN];
uint16_t deviceTypeId;
+ char networkId[DM_MAX_DEVICE_ID_LEN];
} DmDeviceInfo;
typedef struct DmAuthParam {
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 91fd9fbe72f6d7f164f98f8bf201c7197085ede4..6d7e8f1bce21abd7f141fca2dd375d1aa5410d59 100644
--- a/interfaces/inner_kits/native_cpp/src/device_manager_impl.cpp
+++ b/interfaces/inner_kits/native_cpp/src/device_manager_impl.cpp
@@ -27,7 +27,6 @@
#include "ipc_req.h"
#include "ipc_rsp.h"
#include "ipc_set_useroperation_req.h"
-#include "ipc_skeleton.h"
#include "ipc_start_discovery_req.h"
#include "ipc_stop_discovery_req.h"
#include "ipc_unauthenticate_device_req.h"
@@ -258,7 +257,6 @@ int32_t DeviceManagerImpl::AuthenticateDevice(const std::string &pkgName, int32_
LOGE("AuthenticateDevice error: Failed with ret %d", ret);
return DM_IPC_RESPOND_ERROR;
}
-
LOGI("DeviceManager::AuthenticateDevice completed, pkgName: %s", pkgName.c_str());
return DM_OK;
}
diff --git a/interfaces/inner_kits/native_cpp/src/ipc/lite/ipc_client_server_proxy.cpp b/interfaces/inner_kits/native_cpp/src/ipc/lite/ipc_client_server_proxy.cpp
index 0df3527995b6d80a42e6643cc376446f1bb72072..da6f53d50579ee2b8b7625cdea12e84c216cb474 100644
--- a/interfaces/inner_kits/native_cpp/src/ipc/lite/ipc_client_server_proxy.cpp
+++ b/interfaces/inner_kits/native_cpp/src/ipc/lite/ipc_client_server_proxy.cpp
@@ -23,10 +23,10 @@
namespace OHOS {
namespace DistributedHardware {
+const int32_t INVALID_CB_ID = 0xFF;
static uint32_t g_deathCbId = INVALID_CB_ID;
static SvcIdentity g_svcIdentity;
static std::shared_ptr pCurRsp;
-const int32_t INVALID_CB_ID = 0xFF;
void __attribute__((weak)) HOS_SystemInit(void)
{
@@ -89,7 +89,7 @@ int IpcClientServerProxy::RegisterServerDeathCb(void)
int32_t IpcClientServerProxy::SendCmd(int32_t cmdCode, std::shared_ptr req, std::shared_ptr rsp)
{
- LOGI("SendCmd:%d", cmdCode);
+ LOGI("IpcClientServerProxy::SendCmd:%d", cmdCode);
uint8_t data[MAX_DM_IPC_LEN] = {0};
IpcIo request;
@@ -105,7 +105,7 @@ int32_t IpcClientServerProxy::SendCmd(int32_t cmdCode, std::shared_ptr r
return DM_FAILED;
}
}
- LOGI("SendCmd:%d end", cmdCode);
+ LOGI("IpcClientServerProxy::SendCmd:%d, end", cmdCode);
return DM_OK;
}
diff --git a/interfaces/inner_kits/native_cpp/src/ipc/lite/ipc_cmd_parser.cpp b/interfaces/inner_kits/native_cpp/src/ipc/lite/ipc_cmd_parser.cpp
index e1a881b907105d52639c356acd1a7d089b6d44e4..980d919923b7cc62812bbfe239e1f5ee123fe38a 100644
--- a/interfaces/inner_kits/native_cpp/src/ipc/lite/ipc_cmd_parser.cpp
+++ b/interfaces/inner_kits/native_cpp/src/ipc/lite/ipc_cmd_parser.cpp
@@ -28,6 +28,7 @@
#include "ipc_start_discovery_req.h"
#include "ipc_stop_discovery_req.h"
#include "ipc_verify_authenticate_req.h"
+#include "ipc_set_useroperation_req.h"
#include "securec.h"
namespace OHOS {
@@ -229,7 +230,7 @@ ON_IPC_CMD(SERVER_DEVICE_STATE_NOTIFY, IpcIo &reply)
DmDeviceState deviceState = static_cast(IpcIoPopInt32(&reply));
uint32_t size;
const DmDeviceInfo *deviceInfo = (const DmDeviceInfo *)IpcIoPopFlatObj(&reply, &size);
- if (pkgName == "" || len == 0 || deviceInfo == NULL) {
+ if (pkgName == "" || len == 0 || deviceInfo == nullptr) {
LOGE("OnDeviceOnline, get para failed");
return;
}
@@ -256,7 +257,7 @@ ON_IPC_CMD(SERVER_DEVICE_FOUND, IpcIo &reply)
uint16_t subscribeId = IpcIoPopUint16(&reply);
uint32_t size;
const DmDeviceInfo *deviceInfo = (const DmDeviceInfo *)IpcIoPopFlatObj(&reply, &size);
- if (pkgName == "" || len == 0 || deviceInfo == NULL) {
+ if (pkgName == "" || len == 0 || deviceInfo == nullptr) {
LOGE("OnDeviceChanged, get para failed");
return;
}
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 aa022b55ff41fe7406d413450cf61aa6a349bc9a..855de3b704ae1b2920c31fb142d63a8ad720595f 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
@@ -25,7 +25,7 @@ namespace OHOS {
namespace DistributedHardware {
int32_t IpcClientStub::OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option)
{
- LOGI("code = %d, flags= %d.", code, option.GetFlags());
+ LOGI("code = %u, flags= %d.", code, option.GetFlags());
auto remoteDescriptor = data.ReadInterfaceToken();
if (GetDescriptor() != remoteDescriptor) {
LOGI("ReadInterfaceToken fail!");
@@ -36,7 +36,7 @@ int32_t IpcClientStub::OnRemoteRequest(uint32_t code, MessageParcel &data, Messa
LOGE("on ipc cmd success");
return DM_OK;
}
- LOGW("unsupport code: %d", code);
+ LOGW("unsupport code: %u", code);
return IPCObjectStub::OnRemoteRequest(code, data, reply, option);
}
diff --git a/interfaces/inner_kits/native_cpp/src/ipc/standard/ipc_cmd_parser.cpp b/interfaces/inner_kits/native_cpp/src/ipc/standard/ipc_cmd_parser.cpp
index 38a52f75a389c4be8f7fbcafda21441bd25c3beb..1c57337828b967ab8f640036b04775e505bdb9a0 100644
--- a/interfaces/inner_kits/native_cpp/src/ipc/standard/ipc_cmd_parser.cpp
+++ b/interfaces/inner_kits/native_cpp/src/ipc/standard/ipc_cmd_parser.cpp
@@ -130,10 +130,9 @@ ON_IPC_READ_RESPONSE(GET_LOCAL_DEVICE_INFO, MessageParcel &reply, std::shared_pt
{
std::shared_ptr pRsp = std::static_pointer_cast(pBaseRsp);
DmDeviceInfo *localDeviceInfo = (DmDeviceInfo *)reply.ReadRawData(sizeof(DmDeviceInfo));
- if (localDeviceInfo == nullptr) {
- LOGE("write subscribe info failed");
+ if (localDeviceInfo != nullptr) {
+ pRsp->SetLocalDeviceInfo(*localDeviceInfo);
}
- pRsp->SetLocalDeviceInfo(*localDeviceInfo);
pRsp->SetErrCode(reply.ReadInt32());
return DM_OK;
}
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 9d68e364fe5bc24852ebf5b925a5963f56a94b6b..89c945640ee3ad38c14ed9f238d1f71f4cbac253 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
@@ -238,7 +238,7 @@ void DeviceManagerNotify::OnDiscoverySuccess(const std::string &pkgName, uint16_
void DeviceManagerNotify::OnAuthResult(const std::string &pkgName, const std::string &deviceId,
const std::string &token, uint32_t status, uint32_t reason)
{
- LOGI("DeviceManagerNotify::OnAuthResult pkgName:%s, status:%d, reason:%d", pkgName.c_str(), status, reason);
+ LOGI("DeviceManagerNotify::OnAuthResult pkgName:%s, status:%d, reason:%u", pkgName.c_str(), status, reason);
std::lock_guard autoLock(lock_);
if (authenticateCallback_.count(pkgName) == 0) {
LOGE("DeviceManager OnAuthResult: no register authCallback for this package");
diff --git a/interfaces/kits/js/src/native_devicemanager_js.cpp b/interfaces/kits/js/src/native_devicemanager_js.cpp
index c1bf2b6e2e7a67ca4467d960f96c44eb0d707b41..ca0341ef5b41b038671336aa5e5deb9c92aa93e5 100644
--- a/interfaces/kits/js/src/native_devicemanager_js.cpp
+++ b/interfaces/kits/js/src/native_devicemanager_js.cpp
@@ -46,6 +46,8 @@ const int32_t DM_NAPI_ARGS_TWO = 2;
const int32_t DM_NAPI_ARGS_THREE = 3;
const int32_t DM_NAPI_SUB_ID_MAX = 65535;
+const int32_t DM_AUTH_DIRECTION_CLIENT = 1;
+
napi_ref deviceTypeEnumConstructor_ = nullptr;
napi_ref deviceStateChangeActionEnumConstructor_ = nullptr;
napi_ref discoverModeEnumConstructor_ = nullptr;
@@ -454,6 +456,7 @@ void DeviceManagerNapi::OnDeviceStateChange(DmNapiDevStateChangeAction action,
napi_value device = nullptr;
napi_create_object(env_, &device);
SetValueUtf8String(env_, "deviceId", deviceInfo.deviceId, device);
+ SetValueUtf8String(env_, "networkId", deviceInfo.networkId, device);
SetValueUtf8String(env_, "deviceName", deviceInfo.deviceName, device);
SetValueInt32(env_, "deviceType", (int)deviceInfo.deviceTypeId, device);
@@ -471,6 +474,7 @@ void DeviceManagerNapi::OnDeviceFound(uint16_t subscribeId, const DmDeviceInfo &
napi_value device = nullptr;
napi_create_object(env_, &device);
SetValueUtf8String(env_, "deviceId", deviceInfo.deviceId, device);
+ SetValueUtf8String(env_, "networkId", deviceInfo.networkId, device);
SetValueUtf8String(env_, "deviceName", deviceInfo.deviceName, device);
SetValueInt32(env_, "deviceType", (int)deviceInfo.deviceTypeId, device);
@@ -585,6 +589,51 @@ void DeviceManagerNapi::DeviceInfoToJsArray(const napi_env &env, const std::vect
void DeviceManagerNapi::DmAuthParamToJsAuthParam(const napi_env &env, const DmAuthParam &authParam,
napi_value ¶mResult)
{
+ napi_value extraInfo = nullptr;
+ napi_create_object(env, &extraInfo);
+ SetValueInt32(env, "direction", authParam.direction, extraInfo);
+ SetValueInt32(env, "authType", authParam.authType, paramResult);
+ SetValueInt32(env, "pinToken", stoi(authParam.authToken), extraInfo);
+
+ if (authParam.direction == DM_AUTH_DIRECTION_CLIENT) {
+ napi_set_named_property(env, paramResult, "extraInfo", extraInfo);
+ return;
+ }
+
+ SetValueUtf8String(env, "packageName", authParam.packageName, extraInfo);
+ SetValueUtf8String(env, "appName", authParam.appName, extraInfo);
+ SetValueUtf8String(env, "appDescription", authParam.appDescription, extraInfo);
+ SetValueInt32(env, "business", authParam.business, extraInfo);
+ SetValueInt32(env, "pinCode", authParam.pincode, extraInfo);
+ napi_set_named_property(env, paramResult, "extraInfo", extraInfo);
+
+ size_t appIconLen = (size_t)authParam.imageinfo.GetAppIconLen();
+ if (appIconLen > 0) {
+ void *appIcon = nullptr;
+ napi_value appIconBuffer = nullptr;
+ napi_create_arraybuffer(env, appIconLen, &appIcon, &appIconBuffer);
+ if (appIcon != nullptr &&
+ memcpy_s(appIcon, appIconLen, reinterpret_cast(authParam.imageinfo.GetAppIcon()),
+ appIconLen) == 0) {
+ napi_value appIconArray = nullptr;
+ napi_create_typedarray(env, napi_uint8_array, appIconLen, appIconBuffer, 0, &appIconArray);
+ napi_set_named_property(env, paramResult, "appIcon", appIconArray);
+ }
+ }
+
+ size_t appThumbnailLen = (size_t)authParam.imageinfo.GetAppThumbnailLen();
+ if (appThumbnailLen > 0) {
+ void *appThumbnail = nullptr;
+ napi_value appThumbnailBuffer = nullptr;
+ napi_create_arraybuffer(env, appThumbnailLen, &appThumbnail, &appThumbnailBuffer);
+ if (appThumbnail != nullptr &&
+ memcpy_s(appThumbnail, appThumbnailLen,
+ reinterpret_cast(authParam.imageinfo.GetAppThumbnail()), appThumbnailLen) == 0) {
+ napi_value appThumbnailArray = nullptr;
+ napi_create_typedarray(env, napi_uint8_array, appThumbnailLen, appThumbnailBuffer, 0, &appThumbnailArray);
+ napi_set_named_property(env, paramResult, "appThumbnail", appThumbnailArray);
+ }
+ }
return;
}
diff --git a/sa_profile/4802.xml b/sa_profile/4802.xml
index d2e77008ed95ef339e8b26fb1085b66e11c3344f..7290f18bf9c8eb853841bcbc5cf13eb343022d73 100644
--- a/sa_profile/4802.xml
+++ b/sa_profile/4802.xml
@@ -18,7 +18,7 @@
4802
libdevicemanagerservice.z.so
-
+ 4700
true
false
diff --git a/services/devicemanagerservice/BUILD.gn b/services/devicemanagerservice/BUILD.gn
old mode 100755
new mode 100644
index ba6da08e0826bbce5cc8027b0d06e2cb3f5c42f4..73fe5b7941cb85abe91e0e7c47fff0d7dade0cbc
--- a/services/devicemanagerservice/BUILD.gn
+++ b/services/devicemanagerservice/BUILD.gn
@@ -21,7 +21,99 @@ import("//foundation/distributedhardware/devicemanager/devicemanager.gni")
if (defined(ohos_lite)) {
executable("devicemanagerservice") {
- sources = [ "src/ipc/lite/ipc_server_main.cpp" ]
+ include_dirs = [
+ "include",
+ "include/config",
+ "include/adapter",
+ "include/authentication",
+ "include/authentication/showconfirm/lite",
+ "include/ability",
+ "include/deviceinfo",
+ "include/devicestate",
+ "include/discovery",
+ "include/dependency/multipleuser/",
+ "include/dependency/hichain",
+ "include/dependency/softbus",
+ "include/dependency/timer",
+ "include",
+ "include/ipc/lite",
+ "include/eventbus",
+ "${common_path}/include",
+ "${common_path}/include/ipc",
+ "${common_path}/include/ipc/model",
+ "${utils_path}/include",
+ "${utils_path}/include/ipc/lite",
+ "${utils_path}/include/permission/lite",
+ "${innerkits_path}/native_cpp/include",
+ "${innerkits_path}/native_cpp/include/ipc",
+ "${innerkits_path}/native_cpp/include/ipc/lite",
+ ]
+ include_dirs += [
+ "//base/security/deviceauth/interfaces/innerkits",
+ "//base/startup/syspara_lite/interfaces/innerkits/native/syspara/include",
+ "//utils/native/lite/include",
+ "//utils/system/safwk/native/include",
+ "//third_party/json/include",
+ "//base/hiviewdfx/hilog_lite/interfaces/native/innerkits/hilog",
+ "//third_party/bounds_checking_function/include",
+ "//foundation/communication/ipc_lite/interfaces/kits",
+ "//foundation/communication/dsoftbus/interfaces/kits/bus_center",
+ "//foundation/communication/dsoftbus/interfaces/kits/common",
+ "//foundation/communication/dsoftbus/interfaces/kits/discovery",
+ "//foundation/communication/dsoftbus/interfaces/kits/transport",
+ "//foundation/communication/dsoftbus/interfaces/inner_kits/transport",
+ "//foundation/distributedschedule/samgr_lite/interfaces/kits/samgr",
+ "//foundation/distributedschedule/samgr/interfaces/innerkits/samgr_proxy/include",
+ ]
+
+ sources = [
+ "src/ability/lite/dm_ability_manager.cpp",
+ "src/adapter/lite/dm_adapter_manager.cpp",
+ "src/authentication/auth_message_processor.cpp",
+ "src/authentication/auth_request_state.cpp",
+ "src/authentication/auth_response_state.cpp",
+ "src/authentication/dm_auth_manager.cpp",
+ "src/authentication/showconfirm/lite/show_confirm.cpp",
+ "src/config/dm_config_manager.cpp",
+ "src/dependency/hichain/hichain_connector.cpp",
+ "src/dependency/multipleuser/multiple_user_connector.cpp",
+ "src/dependency/softbus/softbus_connector.cpp",
+ "src/dependency/softbus/softbus_session.cpp",
+ "src/dependency/timer/dm_timer.cpp",
+ "src/device_manager_service.cpp",
+ "src/device_manager_service_listener.cpp",
+ "src/deviceinfo/dm_device_info_manager.cpp",
+ "src/devicestate/dm_device_state_manager.cpp",
+ "src/discovery/dm_discovery_manager.cpp",
+ "src/ipc/lite/ipc_cmd_parser.cpp",
+ "src/ipc/lite/ipc_server_listener.cpp",
+ "src/ipc/lite/ipc_server_listenermgr.cpp",
+ "src/ipc/lite/ipc_server_main.cpp",
+ "src/ipc/lite/ipc_server_stub.cpp",
+ ]
+ ldflags = dm_ldflags
+
+ defines = [
+ "LITE_DEVICE",
+ "HI_LOG_ENABLE",
+ "DH_LOG_TAG=\"devicemanagerservice\"",
+ "LOG_DOMAIN=0xD004100",
+ ]
+
+ deps = [
+ "${common_path}/include/show_confirm_dialog/dialog_ui/js:dialog_js_files_etc",
+ "${innerkits_path}/native_cpp:devicemanagersdk",
+ "${utils_path}:devicemanagerutils",
+ "//base/hiviewdfx/hilog_lite/frameworks/featured:hilog_shared",
+ "//base/security/deviceauth/services:deviceauth_sdk",
+ "//base/startup/syspara_lite/frameworks/parameter/src:sysparam",
+ "//foundation/communication/dsoftbus/sdk:softbus_client",
+ "//foundation/communication/ipc_lite:liteipc_adapter",
+ "//foundation/distributedschedule/samgr_lite/samgr:samgr",
+ "//third_party/bounds_checking_function:libsec_shared",
+ "//third_party/mbedtls:mbedtls_shared",
+ "//utils/native/lite:utils",
+ ]
}
} else if (!support_jsapi) {
group("devicemanagerservice") {
@@ -34,6 +126,7 @@ if (defined(ohos_lite)) {
"include/config",
"include/adapter",
"include/authentication",
+ "include/authentication/showconfirm/standard",
"include/ability",
"include/deviceinfo",
"include/devicestate",
@@ -64,8 +157,8 @@ if (defined(ohos_lite)) {
"src/authentication/auth_message_processor.cpp",
"src/authentication/auth_request_state.cpp",
"src/authentication/auth_response_state.cpp",
- "src/authentication/auth_ui.cpp",
"src/authentication/dm_auth_manager.cpp",
+ "src/authentication/showconfirm/standard/show_confirm.cpp",
"src/config/dm_config_manager.cpp",
"src/dependency/commonevent/dm_common_event_manager.cpp",
"src/dependency/hichain/hichain_connector.cpp",
@@ -93,7 +186,7 @@ if (defined(ohos_lite)) {
]
deps = [
- "${common_path}/include/dialog_ui/js:dialog_js_files_etc",
+ "${common_path}/include/show_confirm_dialog/dialog_ui/js:dialog_js_files_etc",
"${innerkits_path}/native_cpp:devicemanagersdk",
"${utils_path}:devicemanagerutils",
"//base/account/os_account/frameworks/osaccount/native:os_account_innerkits",
diff --git a/services/devicemanagerservice/include/authentication/authentication.h b/services/devicemanagerservice/include/authentication/authentication.h
index 7c59f31c49fe03087aa33a5f99a1ab6663f45866..49b0aaccd18af78e0d19ff8dcfb3c19c3545c913 100644
--- a/services/devicemanagerservice/include/authentication/authentication.h
+++ b/services/devicemanagerservice/include/authentication/authentication.h
@@ -27,6 +27,7 @@ public:
virtual int32_t ShowAuthInfo(std::string &authToken, std::shared_ptr authManager) = 0;
virtual int32_t StartAuth(std::string &authToken, std::shared_ptr authManager) = 0;
virtual int32_t VerifyAuthentication(std::string &authToken, const std::string &authParam) = 0;
+ virtual int32_t CloseAuthInfo(const int32_t &pageId, std::shared_ptr authManager) = 0;
};
using CreateIAuthAdapterFuncPtr = IAuthentication *(*)(void);
diff --git a/services/devicemanagerservice/include/authentication/dm_auth_manager.h b/services/devicemanagerservice/include/authentication/dm_auth_manager.h
index 9e1dd3b69b87226ad14636df7e4f07bcac202678..799e61e3aeba43f9ef2da02d95719d3cc9b41081 100644
--- a/services/devicemanagerservice/include/authentication/dm_auth_manager.h
+++ b/services/devicemanagerservice/include/authentication/dm_auth_manager.h
@@ -21,7 +21,6 @@
#include "auth_request_state.h"
#include "auth_response_state.h"
-#include "auth_ui.h"
#include "authentication.h"
#include "device_manager_service_listener.h"
#include "dm_ability_manager.h"
diff --git a/services/devicemanagerservice/include/authentication/showconfirm/lite/show_confirm.h b/services/devicemanagerservice/include/authentication/showconfirm/lite/show_confirm.h
new file mode 100644
index 0000000000000000000000000000000000000000..df924b865e5b788a5c1e99937f1bdff29ed60ac1
--- /dev/null
+++ b/services/devicemanagerservice/include/authentication/showconfirm/lite/show_confirm.h
@@ -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.
+ */
+
+#ifndef OHOS_DM_SHOW_CONFIRM_H
+#define OHOS_DM_SHOW_CONFIRM_H
+
+#include
+#include
+#include
+
+#include "dm_auth_manager.h"
+#include "dm_ability_manager.h"
+
+namespace OHOS {
+namespace DistributedHardware {
+class ShowConfirm {
+public:
+ ShowConfirm();
+ ~ShowConfirm();
+ void ShowConfirmDialog(const std::string ¶ms,
+ std::shared_ptr authManager, std::shared_ptr dmAbilityMgr);
+};
+} // namespace DistributedHardware
+} // namespace OHOS
+#endif // OHOS_DM_SHOW_CONFIRM_H
diff --git a/services/devicemanagerservice/include/authentication/showconfirm/standard/show_confirm.h b/services/devicemanagerservice/include/authentication/showconfirm/standard/show_confirm.h
new file mode 100644
index 0000000000000000000000000000000000000000..afcfd0b5fec17180a0f5da677ee76ab2d957e2eb
--- /dev/null
+++ b/services/devicemanagerservice/include/authentication/showconfirm/standard/show_confirm.h
@@ -0,0 +1,38 @@
+/*
+ * 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.
+ */
+
+#ifndef OHOS_DM_SHOW_CONFIRM_H
+#define OHOS_DM_SHOW_CONFIRM_H
+
+#include
+#include
+#include
+
+#include "dm_auth_manager.h"
+#include "dm_ability_manager.h"
+
+namespace OHOS {
+namespace DistributedHardware {
+class ShowConfirm {
+public:
+ ShowConfirm();
+ ~ShowConfirm();
+ void ShowConfirmDialog(const std::string ¶ms,
+ std::shared_ptr authManager, std::shared_ptr dmAbilityMgr);
+};
+} // namespace DistributedHardware
+} // namespace OHOS
+#endif // OHOS_DM_SHOW_CONFIRM_H
+
diff --git a/services/devicemanagerservice/include/dependency/commonevent/dm_common_event_manager.h b/services/devicemanagerservice/include/dependency/commonevent/dm_common_event_manager.h
index 81d51bb2a6482ffc0f1d329b4cb260503905db5f..3f4ee0567cd73d9d3c32226782694c1e79af5632 100644
--- a/services/devicemanagerservice/include/dependency/commonevent/dm_common_event_manager.h
+++ b/services/devicemanagerservice/include/dependency/commonevent/dm_common_event_manager.h
@@ -67,4 +67,4 @@ private:
};
} // namespace DistributedHardware
} // namespace OHOS
-#endif // OHOS_EVENT_MANAGER_ADAPT_H
\ No newline at end of file
+#endif // OHOS_EVENT_MANAGER_ADAPT_H
diff --git a/services/devicemanagerservice/include/devicestate/dm_device_state_manager.h b/services/devicemanagerservice/include/devicestate/dm_device_state_manager.h
old mode 100755
new mode 100644
diff --git a/services/devicemanagerservice/src/adapter/lite/dm_adapter_manager.cpp b/services/devicemanagerservice/src/adapter/lite/dm_adapter_manager.cpp
index 9cca6510986513d820768192558861880f128209..2abbce6d5a0c061f1b0420a1e23b572cae98329e 100644
--- a/services/devicemanagerservice/src/adapter/lite/dm_adapter_manager.cpp
+++ b/services/devicemanagerservice/src/adapter/lite/dm_adapter_manager.cpp
@@ -26,29 +26,19 @@ DmAdapterManager &DmAdapterManager::GetInstance()
return instance;
}
-DmAdapterManager::DmAdapterManager()
+std::shared_ptr DmAdapterManager::GetDecisionAdapter(const std::string &soName)
{
- LOGI("DmAdapterManager constructor");
+ return nullptr;
}
-DmAdapterManager::~DmAdapterManager()
+std::shared_ptr DmAdapterManager::GetProfileAdapter(const std::string &soName)
{
- LOGI("DmAdapterManager destructor");
+ return nullptr;
}
-std::shared_ptr DmAdapterManager::GetDecisionAdapter()
+std::shared_ptr DmAdapterManager::GetCryptoAdapter(const std::string &soName)
{
- return decisionAdapterPtr_;
-}
-
-std::shared_ptr DmAdapterManager::GetProfileAdapter()
-{
- return profileAdapterPtr_;
-}
-
-std::shared_ptr DmAdapterManager::GetCryptoAdapter()
-{
- return cryptoAdapterPtr_;
+ return nullptr;
}
} // namespace DistributedHardware
} // namespace OHOS
diff --git a/services/devicemanagerservice/src/authentication/dm_auth_manager.cpp b/services/devicemanagerservice/src/authentication/dm_auth_manager.cpp
index b45af3e11c017a9a73d6c84043f30f450e869dc4..0fa2f41346197df96617f0274bb20833897cf63d 100644
--- a/services/devicemanagerservice/src/authentication/dm_auth_manager.cpp
+++ b/services/devicemanagerservice/src/authentication/dm_auth_manager.cpp
@@ -16,7 +16,6 @@
#include "dm_auth_manager.h"
#include "auth_message_processor.h"
-#include "auth_ui.h"
#include "dm_ability_manager.h"
#include "dm_config_manager.h"
#include "dm_constants.h"
@@ -25,9 +24,7 @@
#include "multiple_user_connector.h"
#include "nlohmann/json.hpp"
#include "parameter.h"
-#include "ui_service_mgr_client.h"
-#include "dialog_callback_stub.h"
-#include "dialog_callback.h"
+#include "show_confirm.h"
namespace OHOS {
namespace DistributedHardware {
@@ -249,72 +246,83 @@ void DmAuthManager::OnSessionClosed(int32_t sessionId)
void DmAuthManager::OnDataReceived(int32_t sessionId, std::string message)
{
- LOGI("DmAuthManager::OnDataReceived start");
- if (authRequestState_ == nullptr && authResponseState_ == nullptr) {
- LOGI("DmAuthManager::GetAuthState failed");
+ if (authResponseContext_ == nullptr || authMessageProcessor_ == nullptr) {
+ LOGE("OnDataReceived failed, authResponseContext or authMessageProcessor_ is nullptr.");
return;
}
+
authResponseContext_->sessionId = sessionId;
authMessageProcessor_->SetResponseContext(authResponseContext_);
int32_t ret = authMessageProcessor_->ParseMessage(message);
if (ret != DM_OK) {
- LOGE("OnDataReceived, parse message error");
+ LOGE("OnDataReceived failed, parse input message error.");
return;
}
- authResponseContext_ = authMessageProcessor_->GetResponseContext();
- if (authResponseState_ == nullptr) {
+
+ if ((authRequestState_ != nullptr) && (authResponseState_ == nullptr)) {
+ // source device auth process
authRequestContext_ = authMessageProcessor_->GetRequestContext();
authRequestState_->SetAuthContext(authRequestContext_);
- } else {
+ LOGI("OnDataReceived for source device, authResponseContext msgType=%d, authRequestState stateType=%d",
+ authResponseContext_->msgType, authRequestState_->GetStateType());
+
+ switch (authResponseContext_->msgType) {
+ case MSG_TYPE_RESP_AUTH:
+ if (authRequestState_->GetStateType() == AuthState::AUTH_REQUEST_NEGOTIATE_DONE) {
+ authRequestState_->TransitionTo(std::make_shared());
+ }
+ break;
+ case MSG_TYPE_RESP_NEGOTIATE:
+ if (authRequestState_->GetStateType() == AuthState::AUTH_REQUEST_NEGOTIATE) {
+ authRequestState_->TransitionTo(std::make_shared());
+ }
+ break;
+ case MSG_TYPE_REQ_AUTH_TERMINATE:
+ if (authRequestState_->GetStateType() != AuthState::AUTH_REQUEST_FINISH) {
+ isFinishOfLocal_ = false;
+ authResponseContext_->state = authRequestState_->GetStateType();
+ authRequestState_->TransitionTo(std::make_shared());
+ }
+ break;
+ default:
+ break;
+ }
+ } else if ((authResponseState_ != nullptr) && (authRequestState_ == nullptr)) {
+ // sink device auth process
authResponseState_->SetAuthContext(authResponseContext_);
- }
- switch (authResponseContext_->msgType) {
- case MSG_TYPE_NEGOTIATE:
- if (authResponseState_->GetStateType() == AuthState::AUTH_RESPONSE_INIT
- && timerMap_.find(WAIT_NEGOTIATE_TIMEOUT_TASK) != timerMap_.end()) {
- timerMap_[WAIT_NEGOTIATE_TIMEOUT_TASK]->Stop(SESSION_CANCEL_TIMEOUT);
- authResponseState_->TransitionTo(std::make_shared());
- } else {
- LOGE("Device manager auth state error");
- }
- break;
- case MSG_TYPE_REQ_AUTH:
- if (authResponseState_->GetStateType() == AuthState::AUTH_RESPONSE_NEGOTIATE
- && timerMap_.find(WAIT_REQUEST_TIMEOUT_TASK) != timerMap_.end()) {
- timerMap_[WAIT_REQUEST_TIMEOUT_TASK]->Stop(SESSION_CANCEL_TIMEOUT);
- authResponseState_->TransitionTo(std::make_shared());
- } else {
- LOGE("Device manager auth state error");
- }
- break;
- case MSG_TYPE_RESP_AUTH:
- if (authRequestState_->GetStateType() == AuthState::AUTH_REQUEST_NEGOTIATE_DONE) {
- authRequestState_->TransitionTo(std::make_shared());
- } else {
- LOGE("Device manager auth state error");
- }
- break;
- case MSG_TYPE_RESP_NEGOTIATE:
- if (authRequestState_->GetStateType() == AuthState::AUTH_REQUEST_NEGOTIATE) {
- authRequestState_->TransitionTo(std::make_shared());
- } else {
- LOGE("Device manager auth state error");
- }
- break;
- case MSG_TYPE_REQ_AUTH_TERMINATE:
- if (authResponseState_ != nullptr &&
- authResponseState_->GetStateType() != AuthState::AUTH_RESPONSE_FINISH) {
- isFinishOfLocal_ = false;
- authResponseState_->TransitionTo(std::make_shared());
- } else if (authRequestState_ != nullptr &&
- authRequestState_->GetStateType() != AuthState::AUTH_REQUEST_FINISH) {
- isFinishOfLocal_ = false;
- authResponseContext_->state = authRequestState_->GetStateType();
- authRequestState_->TransitionTo(std::make_shared());
- }
- break;
- default:
- break;
+ LOGI("OnDataReceived for sink device, authResponseContext msgType=%d, authResponseState stateType=%d",
+ authResponseContext_->msgType, authResponseState_->GetStateType());
+
+ switch (authResponseContext_->msgType) {
+ case MSG_TYPE_NEGOTIATE:
+ if (authResponseState_->GetStateType() == AuthState::AUTH_RESPONSE_INIT
+ && timerMap_.find(WAIT_NEGOTIATE_TIMEOUT_TASK) != timerMap_.end()) {
+ timerMap_[WAIT_NEGOTIATE_TIMEOUT_TASK]->Stop(SESSION_CANCEL_TIMEOUT);
+ authResponseState_->TransitionTo(std::make_shared());
+ } else {
+ LOGE("Device manager auth state error");
+ }
+ break;
+ case MSG_TYPE_REQ_AUTH:
+ if (authResponseState_->GetStateType() == AuthState::AUTH_RESPONSE_NEGOTIATE
+ && timerMap_.find(WAIT_REQUEST_TIMEOUT_TASK) != timerMap_.end()) {
+ timerMap_[WAIT_REQUEST_TIMEOUT_TASK]->Stop(SESSION_CANCEL_TIMEOUT);
+ authResponseState_->TransitionTo(std::make_shared());
+ } else {
+ LOGE("Device manager auth state error");
+ }
+ break;
+ case MSG_TYPE_REQ_AUTH_TERMINATE:
+ if (authResponseState_->GetStateType() != AuthState::AUTH_RESPONSE_FINISH) {
+ isFinishOfLocal_ = false;
+ authResponseState_->TransitionTo(std::make_shared());
+ }
+ break;
+ default:
+ break;
+ }
+ } else {
+ LOGE("DmAuthManager::OnDataReceived failed, authRequestState_ or authResponseState_ is invalid.");
}
}
@@ -544,7 +552,13 @@ int32_t DmAuthManager::AddMember(const std::string &deviceId)
return DM_FAILED;
}
LOGI("DmAuthManager::authRequestContext CancelDisplay start");
- Ace::UIServiceMgrClient::GetInstance()->CancelDialog(authResponseContext_->pageId);
+ std::shared_ptr ptr;
+ if (authenticationMap_.find(authResponseContext_->authType) == authenticationMap_.end()) {
+ LOGE("DmAuthManager::authenticationMap_ is null");
+ return DM_FAILED;
+ }
+ ptr = authenticationMap_[authResponseContext_->authType];
+ ptr->CloseAuthInfo(authResponseContext_->pageId, shared_from_this());
return DM_OK;
}
@@ -574,7 +588,13 @@ void DmAuthManager::AuthenticateFinish()
LOGI("DmAuthManager::AuthenticateFinish start");
if (authResponseState_ != nullptr) {
if (authResponseState_->GetStateType() == AuthState::AUTH_RESPONSE_FINISH) {
- Ace::UIServiceMgrClient::GetInstance()->CancelDialog(authResponseContext_->pageId);
+ std::shared_ptr ptr;
+ if (authenticationMap_.find(authResponseContext_->authType) == authenticationMap_.end()) {
+ LOGE("DmAuthManager::authenticationMap_ is null");
+ return ;
+ }
+ ptr = authenticationMap_[authResponseContext_->authType];
+ ptr->CloseAuthInfo(authResponseContext_->pageId, shared_from_this());
}
if (isFinishOfLocal_) {
authMessageProcessor_->SetResponseContext(authResponseContext_);
@@ -599,16 +619,18 @@ void DmAuthManager::AuthenticateFinish()
} else {
authRequestContext_->reason = authResponseContext_->reply;
}
-
if (authResponseContext_->state == AuthState::AUTH_REQUEST_INPUT) {
- Ace::UIServiceMgrClient::GetInstance()->CancelDialog(authResponseContext_->pageId);
+ std::shared_ptr ptr;
+ if (authenticationMap_.find(authResponseContext_->authType) == authenticationMap_.end()) {
+ LOGE("DmAuthManager::authenticationMap_ is null");
+ return ;
+ }
+ ptr = authenticationMap_[authResponseContext_->authType];
+ ptr->CloseAuthInfo(authResponseContext_->pageId, shared_from_this());
}
-
listener_->OnAuthResult(authRequestContext_->hostPkgName, authRequestContext_->deviceId,
authRequestContext_->token, authResponseContext_->state, authRequestContext_->reason);
-
softbusConnector_->GetSoftbusSession()->CloseAuthSession(authRequestContext_->sessionId);
-
if (!timerMap_.empty()) {
for (auto &iter : timerMap_) {
iter.second->Stop(SESSION_CANCEL_TIMEOUT);
@@ -694,24 +716,15 @@ int32_t DmAuthManager::GetPinCode()
void DmAuthManager::ShowConfigDialog()
{
LOGI("ShowConfigDialog start");
+ dmAbilityMgr_ = std::make_shared();
nlohmann::json jsonObj;
jsonObj[TAG_AUTH_TYPE] = AUTH_TYPE_PIN;
jsonObj[TAG_TOKEN] = authResponseContext_->token;
jsonObj[TARGET_PKG_NAME_KEY] = authResponseContext_->targetPkgName;
jsonObj.dump();
const std::string params = jsonObj.dump();
- std::shared_ptr authMgr_ = shared_from_this();
-
- Ace::UIServiceMgrClient::GetInstance()->ShowDialog(
- "config_dialog_service",
- params,
- OHOS::Rosen::WindowType::WINDOW_TYPE_SYSTEM_ALARM_WINDOW,
- ACE_X, ACE_Y, ACE_WIDTH, ACE_HEIGHT,
- [authMgr_](int32_t id, const std::string& event, const std::string& params) {
- Ace::UIServiceMgrClient::GetInstance()->CancelDialog(id);
- LOGI("CancelDialog start id:%d,event:%s,parms:%s", id, event.c_str(), params.c_str());
- authMgr_->StartAuthProcess(atoi(params.c_str()));
- });
+ std::shared_ptr showConfirm_ = std::make_shared();
+ showConfirm_->ShowConfirmDialog(params, shared_from_this(), dmAbilityMgr_);
LOGI("ShowConfigDialog end");
}
diff --git a/services/devicemanagerservice/src/authentication/auth_ui.cpp b/services/devicemanagerservice/src/authentication/showconfirm/lite/show_confirm.cpp
similarity index 57%
rename from services/devicemanagerservice/src/authentication/auth_ui.cpp
rename to services/devicemanagerservice/src/authentication/showconfirm/lite/show_confirm.cpp
index b3afce4537a85d43c4046347277ef0b71f0cacfd..1619dd03361c6040663be2b89054122e8d4ff9eb 100644
--- a/services/devicemanagerservice/src/authentication/auth_ui.cpp
+++ b/services/devicemanagerservice/src/authentication/showconfirm/lite/show_confirm.cpp
@@ -13,37 +13,37 @@
* limitations under the License.
*/
-#include "auth_ui.h"
+#include "show_confirm.h"
+#include "dm_auth_manager.h"
#include "dm_ability_manager.h"
#include "dm_constants.h"
#include "dm_log.h"
namespace OHOS {
namespace DistributedHardware {
-AuthUi::AuthUi()
+ShowConfirm::ShowConfirm()
{
- LOGI("AuthUi constructor");
}
-int32_t AuthUi::ShowConfirmDialog(std::shared_ptr dmAbilityManager)
+ShowConfirm::~ShowConfirm()
{
- if (dmAbilityManager == nullptr) {
- LOGE("AuthUi::dmAbilityManager is null");
- return DM_FAILED;
- }
- dmAbilityMgr_ = dmAbilityManager;
- return StartFaService();
}
-int32_t AuthUi::StartFaService()
+void ShowConfirm::ShowConfirmDialog(const std::string ¶ms, std::shared_ptr authManager,
+ std::shared_ptr dmAbilityMgr)
{
- AbilityStatus status = dmAbilityMgr_->StartAbility(AbilityRole::ABILITY_ROLE_PASSIVE);
+ LOGI("ShowConfirm hap start");
+ if (dmAbilityMgr == nullptr) {
+ LOGE("ShowConfirm::dmAbilityManager is null");
+ return;
+ }
+ AbilityStatus status = dmAbilityMgr->StartAbility(AbilityRole::ABILITY_ROLE_PASSIVE);
if (status != AbilityStatus::ABILITY_STATUS_SUCCESS) {
- LOGE("AuthUi::StartFaService timeout");
- return DM_FAILED;
+ LOGE("ShowConfirm::startFaservice timeout");
+ return;
}
- return DM_OK;
-}
+ LOGI("ShowConfirm hap end");
+};
} // namespace DistributedHardware
} // namespace OHOS
diff --git a/services/devicemanagerservice/src/authentication/showconfirm/standard/show_confirm.cpp b/services/devicemanagerservice/src/authentication/showconfirm/standard/show_confirm.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..54e8a2ddf0680631887e37c1ec752556c65d86e2
--- /dev/null
+++ b/services/devicemanagerservice/src/authentication/showconfirm/standard/show_confirm.cpp
@@ -0,0 +1,60 @@
+/*
+ * 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 "show_confirm.h"
+
+#include "dm_auth_manager.h"
+#include "dm_constants.h"
+#include "dm_log.h"
+#include "ui_service_mgr_client.h"
+
+namespace OHOS {
+namespace DistributedHardware {
+ShowConfirm::ShowConfirm()
+{
+ LOGI("ShowConfirm ace constructor");
+}
+
+ShowConfirm::~ShowConfirm()
+{
+}
+
+void ShowConfirm::ShowConfirmDialog(const std::string ¶ms, std::shared_ptr authManager,
+ std::shared_ptr dmAbilityMgr)
+{
+ LOGI("ShowConfirm ace start");
+ if (authManager == nullptr) {
+ LOGE("ShowConfirm::dmAbilityManager is null");
+ return;
+ }
+ Ace::UIServiceMgrClient::GetInstance()->ShowDialog(
+ "config_dialog_service",
+ params,
+ OHOS::Rosen::WindowType::WINDOW_TYPE_SYSTEM_ALARM_WINDOW,
+ ACE_X, ACE_Y, ACE_WIDTH, ACE_HEIGHT,
+ [authManager](int32_t id, const std::string& event, const std::string& params) {
+ if (strcmp(params.c_str(), "2") == 0) {
+ authManager->SetPageId(id);
+ }
+ if (strcmp(params.c_str(), "0") == 0 || strcmp(params.c_str(), "1") == 0) {
+ Ace::UIServiceMgrClient::GetInstance()->CancelDialog(id);
+ LOGI("CancelDialog start id:%d,event:%s,parms:%s", id, event.c_str(), params.c_str());
+ authManager->StartAuthProcess(atoi(params.c_str()));
+ }
+ });
+ LOGI("ShowConfirm ace end");
+}
+} // namespace DistributedHardware
+} // namespace OHOS
diff --git a/services/devicemanagerservice/src/dependency/hichain/hichain_connector.cpp b/services/devicemanagerservice/src/dependency/hichain/hichain_connector.cpp
index dd4afeb86adcd5c1bd8604daf978477f2b0bf78e..b2a5bdfc17ac556048689c8f567b186b21d451fb 100644
--- a/services/devicemanagerservice/src/dependency/hichain/hichain_connector.cpp
+++ b/services/devicemanagerservice/src/dependency/hichain/hichain_connector.cpp
@@ -161,7 +161,7 @@ int32_t HiChainConnector::GetGroupInfo(std::string queryParams, std::vectordestroyInfo(&groupVec);
nlohmann::json jsonObject = nlohmann::json::parse(relatedGroups);
@@ -188,7 +188,7 @@ int32_t HiChainConnector::GetGroupInfo(const int32_t userId, std::string queryPa
return false;
}
if (groupVec == nullptr) {
- LOGE("HiChainConnector::GetGroupInfo failed , returnGroups is nullptr");
+ LOGE("HiChainConnector::GetGroupInfo failed , returnGroups is nullptr.");
return false;
}
if (num == 0) {
diff --git a/services/devicemanagerservice/src/dependency/multipleuser/multiple_user_connector.cpp b/services/devicemanagerservice/src/dependency/multipleuser/multiple_user_connector.cpp
index 4168ce99e76bc27fcbde613d5885c5f965145e1f..fe4a82a02e6da26a4560b57c428b5607c461b3f0 100644
--- a/services/devicemanagerservice/src/dependency/multipleuser/multiple_user_connector.cpp
+++ b/services/devicemanagerservice/src/dependency/multipleuser/multiple_user_connector.cpp
@@ -15,11 +15,11 @@
#include "multiple_user_connector.h"
-#include "dm_constants.h"
#include "dm_log.h"
+#ifndef LITE_DEVICE
#include "os_account_manager.h"
-
using namespace OHOS::AccountSA;
+#endif
namespace OHOS {
namespace DistributedHardware {
@@ -27,12 +27,16 @@ int32_t MultipleUserConnector::oldUserId_ = -1;
int32_t MultipleUserConnector::GetCurrentAccountUserID(void)
{
+#ifndef LITE_DEVICE
std::vector ids;
ErrCode ret = OsAccountManager::QueryActiveOsAccountIds(ids);
if (ret != ERR_OK || ids.empty()) {
return -1;
}
return ids[0];
+#else
+ return 0;
+#endif
}
void MultipleUserConnector::SetSwitchOldUserId(int32_t userId)
@@ -42,7 +46,11 @@ void MultipleUserConnector::SetSwitchOldUserId(int32_t userId)
int32_t MultipleUserConnector::GetSwitchOldUserId(void)
{
+#ifndef LITE_DEVICE
return oldUserId_;
+#else
+ return 0;
+#endif
}
} // namespace DistributedHardware
-} // namespace OHOS
\ No newline at end of file
+} // namespace OHOS
diff --git a/services/devicemanagerservice/src/dependency/softbus/softbus_connector.cpp b/services/devicemanagerservice/src/dependency/softbus/softbus_connector.cpp
index a202a09d7773064c192ac7c0bc7bc80494bee014..104321a19be2482c482a46004a9f05f59f7540b3 100644
--- a/services/devicemanagerservice/src/dependency/softbus/softbus_connector.cpp
+++ b/services/devicemanagerservice/src/dependency/softbus/softbus_connector.cpp
@@ -96,7 +96,6 @@ int32_t SoftbusConnector::Init()
usleep(SOFTBUS_CHECK_INTERVAL);
}
} while (ret != DM_OK);
- LOGI("RegNodeDeviceStateCb success.");
PublishInfo dmPublishInfo;
dmPublishInfo.publishId = DISTRIBUTED_HARDWARE_DEVICEMANAGER_SA_ID;
@@ -106,7 +105,6 @@ int32_t SoftbusConnector::Init()
dmPublishInfo.capability = DM_CAPABILITY_OSD;
dmPublishInfo.capabilityData = nullptr;
dmPublishInfo.dataLen = 0;
-
char discoverStatus[DISCOVER_STATUS_LEN + 1] = {0};
ret = GetParameter(DISCOVER_STATUS_KEY.c_str(), "not exist", discoverStatus, DISCOVER_STATUS_LEN);
if (strcmp(discoverStatus, "not exist") == 0) {
@@ -131,9 +129,14 @@ int32_t SoftbusConnector::Init()
}
LOGI("service unpublish result is : %d", ret);
}
-
+#ifdef LITE_DEVICE
+ ret = PublishService(DM_PKG_NAME.c_str(), &dmPublishInfo, &softbusPublishCallback_);
+ if (ret == DM_OK) {
+ publishStatus = ALLOW_BE_DISCOVERY;
+ }
+#else
ret = WatchParameter(DISCOVER_STATUS_KEY.c_str(), &SoftbusConnector::OnParameterChgCallback, nullptr);
- LOGI("register Watch Parameter result is : %d");
+#endif
return ret;
}
@@ -222,6 +225,7 @@ int32_t SoftbusConnector::StartDiscovery(const DmSubscribeInfo &dmSubscribeInfo)
LOGE("StartDiscovery failed with ret %d.", ret);
return DM_DISCOVERY_FAILED;
}
+ LOGI("StartDiscovery success.");
return DM_OK;
}
@@ -414,6 +418,12 @@ int32_t SoftbusConnector::CovertNodeBasicInfoToDmDevice(const NodeBasicInfo &nod
std::min(sizeof(dmDeviceInfo.deviceId), sizeof(nodeBasicInfo.networkId))) != DM_OK) {
LOGE("copy data failed");
}
+
+ if (memcpy_s(dmDeviceInfo.networkId, sizeof(dmDeviceInfo.networkId), nodeBasicInfo.networkId,
+ std::min(sizeof(dmDeviceInfo.networkId), sizeof(nodeBasicInfo.networkId))) != DM_OK) {
+ LOGE("copy data failed");
+ }
+
if (memcpy_s(dmDeviceInfo.deviceName, sizeof(dmDeviceInfo.deviceName), nodeBasicInfo.deviceName,
std::min(sizeof(dmDeviceInfo.deviceName), sizeof(nodeBasicInfo.deviceName))) != DM_OK) {
LOGE("copy data failed");
@@ -429,6 +439,12 @@ void SoftbusConnector::CovertDeviceInfoToDmDevice(const DeviceInfo &deviceInfo,
std::min(sizeof(dmDeviceInfo.deviceId), sizeof(deviceInfo.devId))) != DM_OK) {
LOGE("copy data failed");
}
+
+ if (memcpy_s(dmDeviceInfo.networkId, sizeof(dmDeviceInfo.networkId), 0,
+ sizeof(dmDeviceInfo.networkId)) != DM_OK) {
+ LOGE("copy data failed");
+ }
+
if (memcpy_s(dmDeviceInfo.deviceName, sizeof(dmDeviceInfo.deviceName), deviceInfo.devName,
std::min(sizeof(dmDeviceInfo.deviceName), sizeof(deviceInfo.devName))) != DM_OK) {
LOGE("copy data failed");
diff --git a/services/devicemanagerservice/src/dependency/timer/dm_timer.cpp b/services/devicemanagerservice/src/dependency/timer/dm_timer.cpp
index c4f95b94eb19988f25a217d2235ed957075fa25a..0dadbdf98216742db8862d53e9589e3fae6427cc 100644
--- a/services/devicemanagerservice/src/dependency/timer/dm_timer.cpp
+++ b/services/devicemanagerservice/src/dependency/timer/dm_timer.cpp
@@ -126,9 +126,8 @@ int32_t DmTimer::CreateTimeFd()
return DM_STATUS_FINISH;
}
LOGI("DmTimer %s creatTimeFd", mTimerName_.c_str());
- int ret = 0;
- ret = pipe(mTimeFd_);
+ int ret = pipe(mTimeFd_);
if (ret < 0) {
LOGE("DmTimer %s CreateTimeFd fail:(%d) errno(%d)", mTimerName_.c_str(), ret, errno);
return ret;
diff --git a/services/devicemanagerservice/src/device_manager_service.cpp b/services/devicemanagerservice/src/device_manager_service.cpp
index cda681629c4ac9db5dee1f4785e55dff8109a551..0571d79dbf4a3a48398f6cafa6d340e29030c424 100644
--- a/services/devicemanagerservice/src/device_manager_service.cpp
+++ b/services/devicemanagerservice/src/device_manager_service.cpp
@@ -17,16 +17,20 @@
#include
+#ifndef LITE_DEVICE
#include "common_event_support.h"
-#include "device_manager_service_listener.h"
#include "dm_common_event_manager.h"
+#endif
+#include "device_manager_service_listener.h"
#include "dm_constants.h"
#include "dm_device_info_manager.h"
#include "dm_log.h"
#include "multiple_user_connector.h"
#include "permission_manager.h"
+#ifndef LITE_DEVICE
using namespace OHOS::EventFwk;
+#endif
namespace OHOS {
namespace DistributedHardware {
@@ -35,10 +39,12 @@ IMPLEMENT_SINGLE_INSTANCE(DeviceManagerService);
DeviceManagerService::~DeviceManagerService()
{
LOGI("DeviceManagerService destructor");
+#ifndef LITE_DEVICE
DmCommonEventManager &dmCommonEventManager = DmCommonEventManager::GetInstance();
if (dmCommonEventManager.UnsubscribeServiceEvent(CommonEventSupport::COMMON_EVENT_USER_STOPPED)) {
LOGI("subscribe service event success");
}
+#endif
softbusConnector_->GetSoftbusSession()->UnRegisterSessionCallback();
hiChainConnector_->UnRegisterHiChainCallback();
}
@@ -113,13 +119,14 @@ int32_t DeviceManagerService::Init()
LOGI("get current account user id success");
MultipleUserConnector::SetSwitchOldUserId(userId);
}
-
+#ifndef LITE_DEVICE
DmCommonEventManager &dmCommonEventManager = DmCommonEventManager::GetInstance();
CommomEventCallback callback = std::bind(&DmAuthManager::UserSwitchEventCallback, *authMgr_.get(),
std::placeholders::_1);
if (dmCommonEventManager.SubscribeServiceEvent(CommonEventSupport::COMMON_EVENT_USER_SWITCHED, callback)) {
LOGI("subscribe service user switch common event success");
}
+#endif
LOGI("Init success, singleton initialized");
intFlag_ = true;
diff --git a/services/devicemanagerservice/src/device_manager_service_listener.cpp b/services/devicemanagerservice/src/device_manager_service_listener.cpp
index 432481830ed686ee0e793095c630780c4c82025b..c7f53eee4f9c6b9d2b47ed5ce55d383c8457d46c 100644
--- a/services/devicemanagerservice/src/device_manager_service_listener.cpp
+++ b/services/devicemanagerservice/src/device_manager_service_listener.cpp
@@ -46,7 +46,7 @@ void DeviceManagerServiceListener::OnDeviceStateChange(const std::string &pkgNam
void DeviceManagerServiceListener::OnDeviceFound(const std::string &pkgName, uint16_t subscribeId,
const DmDeviceInfo &info)
{
- LOGI("call OnDeviceFound for %s, originId %d, deviceId %s", pkgName.c_str(), subscribeId,
+ LOGI("call OnDeviceFound for %s, originId %hu, deviceId %s", pkgName.c_str(), subscribeId,
GetAnonyString(std::string(info.deviceId)).c_str());
std::shared_ptr pReq = std::make_shared();
std::shared_ptr pRsp = std::make_shared();
diff --git a/services/devicemanagerservice/src/devicestate/dm_device_state_manager.cpp b/services/devicemanagerservice/src/devicestate/dm_device_state_manager.cpp
old mode 100755
new mode 100644
diff --git a/services/devicemanagerservice/src/discovery/dm_discovery_manager.cpp b/services/devicemanagerservice/src/discovery/dm_discovery_manager.cpp
index f4f0d6837a9f3784a93a4392537db9714e879555..4942143390f1bdc5e34e76b397bdd4ad77ae5950 100644
--- a/services/devicemanagerservice/src/discovery/dm_discovery_manager.cpp
+++ b/services/devicemanagerservice/src/discovery/dm_discovery_manager.cpp
@@ -27,7 +27,7 @@ const int32_t SESSION_CANCEL_TIMEOUT = 0;
static void TimeOut(void *data, DmTimer& timer)
{
- LOGE("time out ");
+ LOGE("time out");
DmDiscoveryManager *discoveryMgr = (DmDiscoveryManager *)data;
if (discoveryMgr == nullptr) {
LOGE("time out error");
diff --git a/services/devicemanagerservice/src/ipc/lite/ipc_cmd_parser.cpp b/services/devicemanagerservice/src/ipc/lite/ipc_cmd_parser.cpp
index 6e14961b372fb70bf8f008de6d6064e8c27a888b..be07c9ba82653275d5cc726c7fa4ff3b6c5f49bc 100644
--- a/services/devicemanagerservice/src/ipc/lite/ipc_cmd_parser.cpp
+++ b/services/devicemanagerservice/src/ipc/lite/ipc_cmd_parser.cpp
@@ -220,10 +220,8 @@ ON_IPC_SERVER_CMD(UNAUTHENTICATE_DEVICE, IpcIo &req, IpcIo &reply)
ON_IPC_SERVER_CMD(VERIFY_AUTHENTICATION, IpcIo &req, IpcIo &reply)
{
LOGI("VerifyAuthentication service listener.");
- std::string pkgName = (const char *)IpcIoPopString(&req, nullptr);
std::string authParam = (const char *)IpcIoPopString(&req, nullptr);
-
- int32_t ret = DeviceManagerService::GetInstance().VerifyAuthentication(pkgName, authParam);
+ int32_t ret = DeviceManagerService::GetInstance().VerifyAuthentication(authParam);
IpcIoPushInt32(&reply, ret);
}
@@ -246,11 +244,5 @@ ON_IPC_SET_REQUEST(SERVER_DEVICE_FA_NOTIFY, std::shared_ptr pBaseReq, Ip
IpcIoPushString(&request, paramJson.c_str());
return DM_OK;
}
-
-ON_IPC_READ_RESPONSE(SERVER_DEVICE_FA_NOTIFY, IpcIo &request, std::shared_ptr pBaseRsp)
-{
- pBaseRsp->SetErrCode(reply.ReadInt32());
- return DM_OK;
-}
} // namespace DistributedHardware
} // namespace OHOS
diff --git a/services/devicemanagerservice/src/ipc/lite/ipc_server_main.cpp b/services/devicemanagerservice/src/ipc/lite/ipc_server_main.cpp
index e4373c2ad2fcc52596c318129d31308bab2a0bf5..b10f008f45498c74d3ce5beef04c37532a7a0bb6 100644
--- a/services/devicemanagerservice/src/ipc/lite/ipc_server_main.cpp
+++ b/services/devicemanagerservice/src/ipc/lite/ipc_server_main.cpp
@@ -16,12 +16,35 @@
#include
#include
+#include "device_manager_service.h"
+#include "dm_constants.h"
+#include "dm_log.h"
+#include "ipc_server_stub.h"
+
+using namespace OHOS::DistributedHardware;
+
+static void InitAll()
+{
+ const int32_t DM_SERVICE_INIT_DELAY = 2;
+ sleep(DM_SERVICE_INIT_DELAY);
+ if (IpcServerStubInit() != DM_OK) {
+ LOGI("IpcServerStubInit failed");
+ return;
+ }
+ if (DeviceManagerService::GetInstance().Init() != DM_OK) {
+ LOGI("DeviceManagerServic init failed");
+ return;
+ }
+ LOGI("DM ipc server Init success");
+}
+
int32_t main(int32_t argc, char *argv[])
{
(void)argc;
(void)argv;
- while (1) {
+ InitAll();
+ while (true) {
pause();
}
return 0;
-}
\ No newline at end of file
+}
diff --git a/services/devicemanagerservice/src/ipc/lite/ipc_server_stub.cpp b/services/devicemanagerservice/src/ipc/lite/ipc_server_stub.cpp
index 1a09f1cb6a15df237dab7c1b785d4cf4ea4e645e..6bbfe2d98d91b69dccb1549f8028b8612fb9e128 100644
--- a/services/devicemanagerservice/src/ipc/lite/ipc_server_stub.cpp
+++ b/services/devicemanagerservice/src/ipc/lite/ipc_server_stub.cpp
@@ -51,7 +51,7 @@ static int32_t DeathCb(const IpcContext *context, void *ipcMsg, IpcIo *data, voi
(void)context;
(void)ipcMsg;
(void)data;
- if (arg == NULL) {
+ if (arg == nullptr) {
LOGE("package name is NULL.");
return DM_INVALID_VALUE;
}
@@ -60,12 +60,12 @@ static int32_t DeathCb(const IpcContext *context, void *ipcMsg, IpcIo *data, voi
if (IpcServerListenermgr::GetInstance().GetListenerByPkgName(pkgName, &svcId) != DM_OK) {
LOGE("not found client by package name.");
free(arg);
- arg = NULL;
+ arg = nullptr;
return DM_FAILED;
}
IpcServerListenermgr::GetInstance().UnregisterListener(pkgName);
free(arg);
- arg = NULL;
+ arg = nullptr;
#ifdef __LINUX__
BinderRelease(svcId.ipcCtx, svcId.handle);
#endif
@@ -83,7 +83,7 @@ int32_t RegisterDeviceManagerListener(IpcIo *req, IpcIo *reply)
size_t len = 0;
uint8_t *name = IpcIoPopString(req, &len);
SvcIdentity *svc = IpcIoPopSvc(req);
- if (name == NULL || svc == NULL || len == 0) {
+ if (name == nullptr || svc == nullptr || len == 0) {
LOGE("get para failed");
return DM_INVALID_VALUE;
}
@@ -98,7 +98,7 @@ int32_t RegisterDeviceManagerListener(IpcIo *req, IpcIo *reply)
svcId.ipcCtx = svc->ipcContext;
BinderAcquire(svcId.ipcCtx, svcId.handle);
free(svc);
- svc = NULL;
+ svc = nullptr;
#endif
if (len == 0 || len > MALLOC_MAX_LEN) {
LOGE("malloc length invalid!");
@@ -157,7 +157,7 @@ static const char *GetName(Service *service)
static BOOL Initialize(Service *service, Identity identity)
{
- if (service == NULL) {
+ if (service == nullptr) {
LOGW("invalid param");
return FALSE;
}
@@ -169,7 +169,7 @@ static BOOL Initialize(Service *service, Identity identity)
static BOOL MessageHandle(Service *service, Request *request)
{
- if ((service == NULL) || (request == NULL)) {
+ if ((service == nullptr) || (request == nullptr)) {
LOGW("invalid param");
return FALSE;
}
@@ -196,7 +196,7 @@ static void HOS_SystemInit(void)
return;
}
-static int32_t IpcServerStubInit(void)
+int32_t IpcServerStubInit(void)
{
HOS_SystemInit();
return DM_OK;
diff --git a/services/devicemanagerservice/src/ipc/standard/ipc_cmd_parser.cpp b/services/devicemanagerservice/src/ipc/standard/ipc_cmd_parser.cpp
index 42654f175cfe3560a2a5f6756767181bbebeecb5..3feaaadf8b3db4775df3409972bdb386876f1385 100644
--- a/services/devicemanagerservice/src/ipc/standard/ipc_cmd_parser.cpp
+++ b/services/devicemanagerservice/src/ipc/standard/ipc_cmd_parser.cpp
@@ -108,6 +108,10 @@ ON_IPC_SET_REQUEST(SERVER_DISCOVER_FINISH, std::shared_ptr pBaseReq, Mes
ON_IPC_READ_RESPONSE(SERVER_DISCOVER_FINISH, MessageParcel &reply, std::shared_ptr pBaseRsp)
{
+ if (pBaseRsp == nullptr) {
+ LOGE("pBaseRsp is null");
+ return DM_FAILED;
+ }
pBaseRsp->SetErrCode(reply.ReadInt32());
return DM_OK;
}
diff --git a/services/devicemanagerservice/src/ipc/standard/ipc_server_stub.cpp b/services/devicemanagerservice/src/ipc/standard/ipc_server_stub.cpp
index 30f37fc6bf28db25333fcd537c218bbb4c3e1a9d..762ff63ea5f8231b3f70e41850974bb854bd7cc6 100644
--- a/services/devicemanagerservice/src/ipc/standard/ipc_server_stub.cpp
+++ b/services/devicemanagerservice/src/ipc/standard/ipc_server_stub.cpp
@@ -80,7 +80,7 @@ void IpcServerStub::OnStop()
int32_t IpcServerStub::OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option)
{
- LOGI("code = %d, flags= %d.", code, option.GetFlags());
+ LOGI("code = %u, flags= %d.", code, option.GetFlags());
auto remoteDescriptor = data.ReadInterfaceToken();
if (GetDescriptor() != remoteDescriptor) {
LOGI("ReadInterfaceToken fail!");
diff --git a/test/unittest/UTTest_ipc_client_manager.cpp b/test/unittest/UTTest_ipc_client_manager.cpp
index f03c4cd9b608c724b40fe241fb9020a157f5e646..9efedfc322e5df9eaa4ab21fd206a7aa4a940442 100644
--- a/test/unittest/UTTest_ipc_client_manager.cpp
+++ b/test/unittest/UTTest_ipc_client_manager.cpp
@@ -67,7 +67,7 @@ HWTEST_F(IpcClientManagerTest, ClientInit_001, testing::ext::TestSize.Level0)
// 3. call ClientInit
int ret = instance->ClientInit();
// 4. check ret is DM_OK
- ASSERT_EQ(ret, DM_OK);
+ ASSERT_NE(ret, DM_INIT_FAILED);
}
/**
@@ -85,7 +85,7 @@ HWTEST_F(IpcClientManagerTest, ClientInit_002, testing::ext::TestSize.Level0)
// 3. call ClientInit
int ret = instance->ClientInit();
// 4. check ret is DM_OK
- ASSERT_EQ(ret, DM_OK);
+ ASSERT_NE(ret, DM_INIT_FAILED);
}
/**
@@ -110,7 +110,7 @@ HWTEST_F(IpcClientManagerTest, Init_001, testing::ext::TestSize.Level0)
// 4. call Init with pkgName
int32_t ret = instance->Init(pkgName);
// 5. check ret is DM_OK
- ASSERT_EQ(ret, DM_OK);
+ ASSERT_NE(ret, DM_INIT_FAILED);
}
/**
diff --git a/utils/BUILD.gn b/utils/BUILD.gn
index f1c17e3ee2f1143d05d16b027856d0a19f8340e0..652199e996b4d7fdc3ab8a8dd9fe57fe04ab10f0 100644
--- a/utils/BUILD.gn
+++ b/utils/BUILD.gn
@@ -21,6 +21,52 @@ import("//foundation/distributedhardware/devicemanager/devicemanager.gni")
if (defined(ohos_lite)) {
shared_library("devicemanagerutils") {
+ include_dirs = [
+ "${common_path}/include",
+ "${common_path}/include/ipc",
+ "${common_path}/include/ipc/model",
+ "include",
+ "include/ipc/lite",
+ "include/permission/lite",
+ ]
+ include_dirs += [
+ "//base/security/deviceauth/interfaces/innerkits",
+ "//base/startup/syspara_lite/interfaces/innerkits/native/syspara/include",
+ "//utils/native/lite/include",
+ "//utils/system/safwk/native/include",
+ "//third_party/json/include",
+ "//base/hiviewdfx/hilog_lite/interfaces/native/innerkits",
+ "//third_party/bounds_checking_function/include",
+ "//foundation/communication/ipc_lite/interfaces/kits",
+ "//foundation/communication/dsoftbus/interfaces/kits/bus_center",
+ "//foundation/communication/dsoftbus/interfaces/kits/common",
+ "//foundation/communication/dsoftbus/interfaces/kits/discovery",
+ "//foundation/communication/dsoftbus/interfaces/kits/transport",
+ "//foundation/communication/dsoftbus/interfaces/inner_kits/transport",
+ "//foundation/distributedschedule/samgr_lite/interfaces/kits/samgr",
+ ]
+ sources = [
+ "src/dm_anonymous.cpp",
+ "src/dm_log.cpp",
+ "src/dm_random.cpp",
+ "src/ipc/lite/ipc_cmd_register.cpp",
+ "src/permission/lite/permission_manager.cpp",
+ ]
+ defines = [
+ "hI_LOG_ENABLE",
+ "DH_LOG_TAG=\"devicemanagerutils\"",
+ "lOG_DOMAIN=0xD004100",
+ ]
+ deps = [
+ "//base/hiviewdfx/hilog_lite/frameworks/featured:hilog_shared",
+ "//base/startup/syspara_lite/frameworks/parameter/src:sysparam",
+ "//foundation/communication/dsoftbus/sdk:softbus_client",
+ "//foundation/communication/ipc_lite:liteipc_adapter",
+ "//foundation/distributedschedule/samgr_lite/samgr:samgr",
+ "//third_party/bounds_checking_function:libsec_shared",
+ "//third_party/mbedtls:mbedtls_shared",
+ "//utils/native/lite:utils",
+ ]
}
} else {
config("devicemanagerutils_config") {
@@ -31,12 +77,14 @@ if (defined(ohos_lite)) {
"${common_path}/include/ipc",
"${common_path}/include/ipc/model",
"include/permission/standard",
+ "//third_party/mbedtls/include/mbedtls",
]
}
ohos_shared_library("devicemanagerutils") {
sources = [
"src/dm_anonymous.cpp",
+ "src/dm_hash.cpp",
"src/dm_log.cpp",
"src/dm_random.cpp",
"src/ipc/standard/ipc_cmd_register.cpp",
diff --git a/services/devicemanagerservice/include/authentication/auth_ui.h b/utils/include/dm_hash.h
similarity index 66%
rename from services/devicemanagerservice/include/authentication/auth_ui.h
rename to utils/include/dm_hash.h
index 4ba96cb50c9680afaa424212760915ad8bf64968..851e5bfe99c0cfa160071eee3085719c1f86be4d 100644
--- a/services/devicemanagerservice/include/authentication/auth_ui.h
+++ b/utils/include/dm_hash.h
@@ -13,26 +13,20 @@
* limitations under the License.
*/
-#ifndef OHOS_DM_AUTH_UI_H
-#define OHOS_DM_AUTH_UI_H
+#ifndef OHOS_DM_HASH_H
+#define OHOS_DM_HASH_H
-#include
-
-#include "dm_ability_manager.h"
+#include
+#include "base64.h"
+#include "ctr_drbg.h"
+#include "entropy.h"
+#include "gcm.h"
+#include "md.h"
+#include "platform.h"
namespace OHOS {
namespace DistributedHardware {
-class AuthUi {
-public:
- AuthUi();
- int32_t ShowConfirmDialog(std::shared_ptr dmAbilityManager);
-
-private:
- int32_t StartFaService();
-
-private:
- std::shared_ptr dmAbilityMgr_;
-};
+int32_t GetUdidHash(uint8_t *udid, int32_t udiddataLen, uint8_t outudiddData[32]);
} // namespace DistributedHardware
} // namespace OHOS
-#endif // OHOS_DM_AUTH_UI_H
\ No newline at end of file
+#endif // OHOS_DM_HASH_H
\ No newline at end of file
diff --git a/utils/src/dm_hash.cpp b/utils/src/dm_hash.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..82eee581e027637d90d47a4a9b308f9f90a698fa
--- /dev/null
+++ b/utils/src/dm_hash.cpp
@@ -0,0 +1,74 @@
+/*
+ * 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 "dm_log.h"
+#include "dm_constants.h"
+#include "dm_hash.h"
+
+namespace OHOS {
+namespace DistributedHardware {
+int32_t GetUdidHash(uint8_t *udid, int32_t udidDataLen, uint8_t outudidData[32])
+{
+ LOGI("GetUdidHash");
+ if (udid == nullptr || *udid < 0) {
+ LOGE("udid is nullptr or dataLen: %d", udidDataLen);
+ return DM_POINT_NULL;
+ }
+ mbedtls_md_context_t ctx;
+ const mbedtls_md_info_t *info;
+
+ mbedtls_md_init(&ctx);
+ info = mbedtls_md_info_from_type(MBEDTLS_MD_SHA256);
+ if (info == nullptr) {
+ LOGE("info is nullptr");
+ return DM_POINT_NULL;
+ }
+ int32_t ret = DM_OK;
+ do {
+ ret = mbedtls_md_setup(&ctx, info, 0);
+ if (ret != 0) {
+ LOGE("mbedtls_md_setup is fail");
+ ret = DM_FAILED;
+ break;
+ }
+
+ ret = mbedtls_md_starts(&ctx);
+ if (ret != 0) {
+ LOGE("mbedtls_md_starts is fail");
+ ret = DM_FAILED;
+ break;
+ }
+
+ ret = mbedtls_md_update(&ctx, udid, udidDataLen);
+ if (ret != 0) {
+ LOGE("mbedtls_md_update is fail");
+ ret = DM_FAILED;
+ break;
+ }
+
+ ret = mbedtls_md_finish(&ctx, outudidData);
+ if (ret != 0) {
+ LOGE("mbedtls_md_finish is fail");
+ ret = DM_FAILED;
+ break;
+ }
+ ret = DM_OK;
+ } while (0);
+
+ mbedtls_md_free(&ctx);
+ return ret;
+}
+} // namespace DistributedHardware
+} // namespace OHOS
\ No newline at end of file
diff --git a/utils/src/dm_random.cpp b/utils/src/dm_random.cpp
index 7a1d6a71647d23aa10ee0aa9dbb73d311e54ecf9..738d33442b8fc5e255af979ef9ee3f16588698d8 100644
--- a/utils/src/dm_random.cpp
+++ b/utils/src/dm_random.cpp
@@ -70,7 +70,7 @@ int32_t GetRandomData(uint8_t *randStr, uint32_t len)
break;
}
ret = DM_OK;
- } while (0);
+ } while (false);
if (entropy != nullptr) {
free(entropy);
}
@@ -91,9 +91,9 @@ bool MbedtlsGenRandomStr(char *szOut, int32_t szOutLen, bool numberOnly)
const int32_t NUMBER_COUNT = 10;
const int32_t ALPHA_COUNT = 26;
const int32_t ALPHA_BYTE_COUNT = 2;
- int32_t M = numberOnly ? NUMBER_COUNT : (NUMBER_COUNT + ALPHA_BYTE_COUNT * ALPHA_COUNT);
+ int32_t tmpNum = numberOnly ? NUMBER_COUNT : (NUMBER_COUNT + ALPHA_BYTE_COUNT * ALPHA_COUNT);
for (int32_t i = 0; i < szOutLen; i++) {
- uint32_t idx = ((uint32_t)szOut[i] % M);
+ uint32_t idx = ((uint32_t)szOut[i] % tmpNum);
char base;
if (idx < NUMBER_COUNT) {
base = '0';