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 += ''; - tableStr += ''; - tableStr += ''; - tableStr += ''; - tableStr += ''; - tableStr += '
123
456
789
.0删除
'; - 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..84e735198536199ec4277f4899c6008773d7ca09 100644 --- a/ext/pin_auth/BUILD.gn +++ b/ext/pin_auth/BUILD.gn @@ -16,7 +16,6 @@ if (defined(ohos_lite)) { } else { import("//build/ohos.gni") } - import("//foundation/distributedhardware/devicemanager/devicemanager.gni") if (defined(ohos_lite)) { @@ -66,8 +65,8 @@ if (defined(ohos_lite)) { ] 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/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/pin_auth.cpp b/ext/pin_auth/src/pin_auth.cpp index 377cb8fdb1691fe835222a9052333acccf339cc9..4c3e3040964568eca1a2df2b93d81a3ec2ce05a8 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(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 +256,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..97f32c139dd64e37f4a10fbc91c04a650615eb29 100644 --- a/interfaces/kits/js/src/native_devicemanager_js.cpp +++ b/interfaces/kits/js/src/native_devicemanager_js.cpp @@ -454,6 +454,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 +472,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); 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 index ba6da08e0826bbce5cc8027b0d06e2cb3f5c42f4..322326b4e41c4f9716ca0ac6d3e2e460de9d5bbb 100755 --- a/services/devicemanagerservice/BUILD.gn +++ b/services/devicemanagerservice/BUILD.gn @@ -93,7 +93,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/src/authentication/dm_auth_manager.cpp b/services/devicemanagerservice/src/authentication/dm_auth_manager.cpp index b45af3e11c017a9a73d6c84043f30f450e869dc4..bb075c5b98ab08045d520c72ccf794811e03fc19 100644 --- a/services/devicemanagerservice/src/authentication/dm_auth_manager.cpp +++ b/services/devicemanagerservice/src/authentication/dm_auth_manager.cpp @@ -249,72 +249,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."); } } 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/softbus/softbus_connector.cpp b/services/devicemanagerservice/src/dependency/softbus/softbus_connector.cpp index a202a09d7773064c192ac7c0bc7bc80494bee014..40f6707ccff6f44e2c9430af44c6c3331166db42 100644 --- a/services/devicemanagerservice/src/dependency/softbus/softbus_connector.cpp +++ b/services/devicemanagerservice/src/dependency/softbus/softbus_connector.cpp @@ -414,6 +414,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 +435,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_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/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_server_main.cpp b/services/devicemanagerservice/src/ipc/lite/ipc_server_main.cpp index e4373c2ad2fcc52596c318129d31308bab2a0bf5..18258ff4faa9aa9d0d183dbf6085d1c041278913 100644 --- a/services/devicemanagerservice/src/ipc/lite/ipc_server_main.cpp +++ b/services/devicemanagerservice/src/ipc/lite/ipc_server_main.cpp @@ -20,7 +20,7 @@ int32_t main(int32_t argc, char *argv[]) { (void)argc; (void)argv; - while (1) { + while (true) { pause(); } return 0; diff --git a/services/devicemanagerservice/src/ipc/lite/ipc_server_stub.cpp b/services/devicemanagerservice/src/ipc/lite/ipc_server_stub.cpp index 1a09f1cb6a15df237dab7c1b785d4cf4ea4e645e..ebdc8241ac1fbffd4abb907e8c525c0feadd6724 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; } 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..97f5c361e461e48393454d1ae35bfcdfed7537d9 100644 --- a/utils/BUILD.gn +++ b/utils/BUILD.gn @@ -31,12 +31,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/utils/include/dm_hash.h b/utils/include/dm_hash.h new file mode 100644 index 0000000000000000000000000000000000000000..851e5bfe99c0cfa160071eee3085719c1f86be4d --- /dev/null +++ b/utils/include/dm_hash.h @@ -0,0 +1,32 @@ +/* + * 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_HASH_H +#define OHOS_DM_HASH_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 { +int32_t GetUdidHash(uint8_t *udid, int32_t udiddataLen, uint8_t outudiddData[32]); +} // namespace DistributedHardware +} // namespace OHOS +#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';