From b07d24efd30a82fd1754f7255dc87159e21aef16 Mon Sep 17 00:00:00 2001 From: renguang1116 Date: Mon, 7 Mar 2022 14:44:39 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=97=A0=E6=B3=95?= =?UTF-8?q?=E4=B8=8A=E6=8A=A5=E5=A4=9A=E4=B8=AA=E8=AE=BE=E5=A4=87=E9=97=AE?= =?UTF-8?q?=E9=A2=98=20Signed-off-by:=20renguang1116=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../kits/js/include/native_devicemanager_js.h | 33 ++++ .../kits/js/src/native_devicemanager_js.cpp | 153 ++++++++++-------- 2 files changed, 122 insertions(+), 64 deletions(-) diff --git a/interfaces/kits/js/include/native_devicemanager_js.h b/interfaces/kits/js/include/native_devicemanager_js.h index f3a0f1a53..7c8c143a8 100644 --- a/interfaces/kits/js/include/native_devicemanager_js.h +++ b/interfaces/kits/js/include/native_devicemanager_js.h @@ -80,6 +80,39 @@ struct AuthAsyncCallbackInfo { int32_t authType = -1; }; +struct DmNapiStateJsCallback { + std::string bundleName_; + uint16_t subscribeId_; + int32_t reason_; + OHOS::DistributedHardware::DmDeviceInfo deviceInfo_; + + DmNapiStateJsCallback(std::string bundleName, uint16_t subscribeId, int32_t reason, + OHOS::DistributedHardware::DmDeviceInfo deviceInfo) + : bundleName_(bundleName), subscribeId_(subscribeId), reason_(reason), deviceInfo_(deviceInfo) {} +} + +struct DmNapiAuthJsCallback { + std::string bundleName_; + std::string deviceId_; + std::string token_; + int32_t status_; + int32_t reason_; + + DmNapiAuthJsCallback(std::string bundleName, std::string deviceId, std::string token, int32_t status, + int32_t reason) + : bundleName_(bundleName), deviceId_(deviceId), token_(token), status_(status), reason_(reason) {} +} + +struct DmNapiVerifyJsCallback { + std::string bundleName_; + std::string deviceId_; + int32_t resultCode_; + int32_t flag_; + + DmNapiVerifyJsCallback(std::string bundleName, std::string deviceId, int32_t resultCode, int32_t flag) + : bundleName_(bundleName), deviceId_(deviceId), resultCode_(resultCode), flag_(flag) {} +} + enum DmNapiDevStateChangeAction { ONLINE = 0, READY = 1, OFFLINE = 2, CHANGE = 3 }; class DmNapiInitCallback : public OHOS::DistributedHardware::DmInitCallback { diff --git a/interfaces/kits/js/src/native_devicemanager_js.cpp b/interfaces/kits/js/src/native_devicemanager_js.cpp index c56e41381..382b03132 100644 --- a/interfaces/kits/js/src/native_devicemanager_js.cpp +++ b/interfaces/kits/js/src/native_devicemanager_js.cpp @@ -68,16 +68,21 @@ void DmNapiInitCallback::OnRemoteDied() return; } uv_work_t *work = new (std::nothrow) uv_work_t; - if (loop == nullptr) { + if (work == nullptr) { LOGE("DmNapiInitCallback: OnRemoteDied, No memory"); return; } - static std::string staticBundleName = bundleName_; + DmDeviceInfo info; + std::unique_ptr jsCallback = + std::make_unique(bundleName_, 0, 0, info); + work->data = reinterpret_cast(jsCallback.get()); + int ret = uv_queue_work(loop, work, [] (uv_work_t *work) {}, [] (uv_work_t *work, int status) { - DeviceManagerNapi *deviceManagerNapi = DeviceManagerNapi::GetDeviceManagerNapi(staticBundleName); + DmNapiStateJsCallback *callback = reinterpret_cast(work->data); + DeviceManagerNapi *deviceManagerNapi = DeviceManagerNapi::GetDeviceManagerNapi(callback->bundleName_); if (deviceManagerNapi == nullptr) { - LOGE("OnRemoteDied, deviceManagerNapi not find for bunderName %s", staticBundleName.c_str()); + LOGE("OnRemoteDied, deviceManagerNapi not find for bunderName %s", callback->bundleName_.c_str()); return; } deviceManagerNapi->OnEvent("serviceDie", 0, nullptr); @@ -97,20 +102,23 @@ void DmNapiDeviceStateCallback::OnDeviceOnline(const DmDeviceInfo &deviceInfo) return; } uv_work_t *work = new (std::nothrow) uv_work_t; - if (loop == nullptr) { + if (work == nullptr) { LOGE("DmNapiDeviceStateCallback: OnDeviceOnline, No memory"); return; } - static std::string staticBundleName = bundleName_; - static DmDeviceInfo staticDeviceInfo = deviceInfo; + std::unique_ptr jsCallback = + std::make_unique(bundleName_, 0, 0, deviceInfo); + work->data = reinterpret_cast(jsCallback.get()); + int ret = uv_queue_work(loop, work, [] (uv_work_t *work) {}, [] (uv_work_t *work, int status) { - DeviceManagerNapi *deviceManagerNapi = DeviceManagerNapi::GetDeviceManagerNapi(staticBundleName); + DmNapiStateJsCallback *callback = reinterpret_cast(work->data); + DeviceManagerNapi *deviceManagerNapi = DeviceManagerNapi::GetDeviceManagerNapi(callback->bundleName_); if (deviceManagerNapi == nullptr) { - LOGE("OnDeviceOnline, deviceManagerNapi not find for bunderName %s", staticBundleName.c_str()); + LOGE("OnDeviceOnline, deviceManagerNapi not find for bunderName %s", callback->bundleName_.c_str()); return; } - deviceManagerNapi->OnDeviceStateChange(DmNapiDevStateChangeAction::ONLINE, staticDeviceInfo); + deviceManagerNapi->OnDeviceStateChange(DmNapiDevStateChangeAction::ONLINE, callback->deviceInfo_); delete work; }); if (ret != 0) { @@ -127,20 +135,23 @@ void DmNapiDeviceStateCallback::OnDeviceReady(const DmDeviceInfo &deviceInfo) return; } uv_work_t *work = new (std::nothrow) uv_work_t; - if (loop == nullptr) { + if (work == nullptr) { LOGE("DmNapiDeviceStateCallback: OnDeviceReady, No memory"); return; } - static std::string staticBundleName = bundleName_; - static DmDeviceInfo staticDeviceInfo = deviceInfo; + std::unique_ptr jsCallback = + std::make_unique(bundleName_, 0, 0, deviceInfo); + work->data = reinterpret_cast(jsCallback.get()); + int ret = uv_queue_work(loop, work, [] (uv_work_t *work) {}, [] (uv_work_t *work, int status) { - DeviceManagerNapi *deviceManagerNapi = DeviceManagerNapi::GetDeviceManagerNapi(staticBundleName); + DmNapiStateJsCallback *callback = reinterpret_cast(work->data); + DeviceManagerNapi *deviceManagerNapi = DeviceManagerNapi::GetDeviceManagerNapi(callback->bundleName_); if (deviceManagerNapi == nullptr) { - LOGE("OnDeviceReady, deviceManagerNapi not find for bunderName %s", staticBundleName.c_str()); + LOGE("OnDeviceReady, deviceManagerNapi not find for bunderName %s", callback->bundleName_.c_str()); return; } - deviceManagerNapi->OnDeviceStateChange(DmNapiDevStateChangeAction::READY, staticDeviceInfo); + deviceManagerNapi->OnDeviceStateChange(DmNapiDevStateChangeAction::READY, callback->deviceInfo_); delete work; }); if (ret != 0) { @@ -157,20 +168,23 @@ void DmNapiDeviceStateCallback::OnDeviceOffline(const DmDeviceInfo &deviceInfo) return; } uv_work_t *work = new (std::nothrow) uv_work_t; - if (loop == nullptr) { + if (work == nullptr) { LOGE("DmNapiDeviceStateCallback: OnDeviceOffline, No memory"); return; } - static std::string staticBundleName = bundleName_; - static DmDeviceInfo staticDeviceInfo = deviceInfo; + std::unique_ptr jsCallback = + std::make_unique(bundleName_, 0, 0, deviceInfo); + work->data = reinterpret_cast(jsCallback.get()); + int ret = uv_queue_work(loop, work, [] (uv_work_t *work) {}, [] (uv_work_t *work, int status) { - DeviceManagerNapi *deviceManagerNapi = DeviceManagerNapi::GetDeviceManagerNapi(staticBundleName); + DmNapiStateJsCallback *callback = reinterpret_cast(work->data); + DeviceManagerNapi *deviceManagerNapi = DeviceManagerNapi::GetDeviceManagerNapi(callback->bundleName_); if (deviceManagerNapi == nullptr) { - LOGE("OnDeviceOffline, deviceManagerNapi not find for bunderName %s", staticBundleName.c_str()); + LOGE("OnDeviceOffline, deviceManagerNapi not find for bunderName %s", callback->bundleName_.c_str()); return; } - deviceManagerNapi->OnDeviceStateChange(DmNapiDevStateChangeAction::OFFLINE, staticDeviceInfo); + deviceManagerNapi->OnDeviceStateChange(DmNapiDevStateChangeAction::OFFLINE, callback->deviceInfo_); delete work; }); if (ret != 0) { @@ -192,15 +206,18 @@ void DmNapiDeviceStateCallback::OnDeviceChanged(const DmDeviceInfo &deviceInfo) return; } - static std::string staticBundleName = bundleName_; - static DmDeviceInfo staticDeviceInfo = deviceInfo; + std::unique_ptr jsCallback = + std::make_unique(bundleName_, 0, 0, deviceInfo); + work->data = reinterpret_cast(jsCallback.get()); + int ret = uv_queue_work(loop, work, [] (uv_work_t *work) {}, [] (uv_work_t *work, int status) { - DeviceManagerNapi *deviceManagerNapi = DeviceManagerNapi::GetDeviceManagerNapi(staticBundleName); + DmNapiStateJsCallback *callback = reinterpret_cast(work->data); + DeviceManagerNapi *deviceManagerNapi = DeviceManagerNapi::GetDeviceManagerNapi(callback->bundleName_); if (deviceManagerNapi == nullptr) { - LOGE("OnDeviceChanged, deviceManagerNapi not find for bunderName %s", staticBundleName.c_str()); + LOGE("OnDeviceChanged, deviceManagerNapi not find for bunderName %s", callback->bundleName_.c_str()); return; } - deviceManagerNapi->OnDeviceStateChange(DmNapiDevStateChangeAction::CHANGE, staticDeviceInfo); + deviceManagerNapi->OnDeviceStateChange(DmNapiDevStateChangeAction::CHANGE, callback->deviceInfo_); delete work; }); if (ret != 0) { @@ -219,21 +236,23 @@ void DmNapiDiscoveryCallback::OnDeviceFound(uint16_t subscribeId, const DmDevice return; } uv_work_t *work = new (std::nothrow) uv_work_t; - if (loop == nullptr) { + if (work == nullptr) { LOGE("DmNapiDiscoveryCallback: OnDeviceFound, No memory"); return; } - static std::string staticBundleName = bundleName_; - static uint16_t staticSubscribeId = subscribeId; - static DmDeviceInfo staticDeviceInfo = deviceInfo; + std::unique_ptr jsCallback = + std::make_unique(bundleName_, subscribeId, 0, deviceInfo); + work->data = reinterpret_cast(jsCallback.get()); + int ret = uv_queue_work(loop, work, [] (uv_work_t *work) {}, [] (uv_work_t *work, int status) { - DeviceManagerNapi *deviceManagerNapi = DeviceManagerNapi::GetDeviceManagerNapi(staticBundleName); + DmNapiStateJsCallback *callback = reinterpret_cast(work->data); + DeviceManagerNapi *deviceManagerNapi = DeviceManagerNapi::GetDeviceManagerNapi(callback->bundleName_); if (deviceManagerNapi == nullptr) { - LOGE("OnDeviceFound, deviceManagerNapi not find for bunderName %s", staticBundleName.c_str()); + LOGE("OnDeviceFound, deviceManagerNapi not find for bunderName %s", callback->bundleName_.c_str()); return; } - deviceManagerNapi->OnDeviceFound(staticSubscribeId, staticDeviceInfo); + deviceManagerNapi->OnDeviceFound(callback->subscribeId_, callback->deviceInfo_); delete work; }); if (ret != 0) { @@ -252,21 +271,23 @@ void DmNapiDiscoveryCallback::OnDiscoveryFailed(uint16_t subscribeId, int32_t fa return; } uv_work_t *work = new (std::nothrow) uv_work_t; - if (loop == nullptr) { + if (work == nullptr) { LOGE("DmNapiDiscoveryCallback: OnDiscoveryFailed, No memory"); return; } - static std::string staticBundleName = bundleName_; - static uint16_t staticSubscribeId = subscribeId; - static int32_t staticReason = failedReason; + std::unique_ptr jsCallback = + std::make_unique(bundleName_, subscribeId, failedReason, deviceInfo); + work->data = reinterpret_cast(jsCallback.get()); + int ret = uv_queue_work(loop, work, [] (uv_work_t *work) {}, [] (uv_work_t *work, int status) { - DeviceManagerNapi *deviceManagerNapi = DeviceManagerNapi::GetDeviceManagerNapi(staticBundleName); + DmNapiStateJsCallback *callback = reinterpret_cast(work->data); + DeviceManagerNapi *deviceManagerNapi = DeviceManagerNapi::GetDeviceManagerNapi(callback->bundleName_); if (deviceManagerNapi == nullptr) { - LOGE("OnDiscoveryFailed, deviceManagerNapi not find for bunderName %s", staticBundleName.c_str()); + LOGE("OnDiscoveryFailed, deviceManagerNapi not find for bunderName %s", callback->bundleName_.c_str()); return; } - deviceManagerNapi->OnDiscoveryFailed(staticSubscribeId, staticReason); + deviceManagerNapi->OnDiscoveryFailed(callback->subscribeId_, callback->reason_); delete work; }); if (ret != 0) { @@ -309,23 +330,23 @@ void DmNapiAuthenticateCallback::OnAuthResult(const std::string &deviceId, const return; } uv_work_t *work = new (std::nothrow) uv_work_t; - if (loop == nullptr) { + if (work == nullptr) { LOGE("DmNapiAuthenticateCallback: OnAuthResult, No memory"); return; } - static std::string staticBundleName = bundleName_; - static std::string staticDeviceId = deviceId; - static std::string staticToken = token; - static int32_t staticStatus = status; - static int32_t staticReason = reason; + std::unique_ptr jsCallback = + std::make_unique(bundleName_, deviceId, token, status, reason); + work->data = reinterpret_cast(jsCallback.get()); + int ret = uv_queue_work(loop, work, [] (uv_work_t *work) {}, [] (uv_work_t *work, int status) { - DeviceManagerNapi *deviceManagerNapi = DeviceManagerNapi::GetDeviceManagerNapi(staticBundleName); + DmNapiAuthJsCallback *callback = reinterpret_cast(work->data); + DeviceManagerNapi *deviceManagerNapi = DeviceManagerNapi::GetDeviceManagerNapi(callback->bundleName_); if (deviceManagerNapi == nullptr) { - LOGE("OnAuthResult, deviceManagerNapi not find for bunderName %s", staticBundleName.c_str()); + LOGE("OnAuthResult, deviceManagerNapi not find for bunderName %s", callback->bundleName_.c_str()); return; } - deviceManagerNapi->OnAuthResult(staticDeviceId, staticToken, staticStatus, staticReason); + deviceManagerNapi->OnAuthResult(callback->deviceId_, callback->token_, callback->status_, callback->reason_); delete work; }); if (ret != 0) { @@ -342,22 +363,23 @@ void DmNapiVerifyAuthCallback::OnVerifyAuthResult(const std::string &deviceId, i return; } uv_work_t *work = new (std::nothrow) uv_work_t; - if (loop == nullptr) { + if (work == nullptr) { LOGE("DmNapiVerifyAuthCallback: OnVerifyAuthResult, No memory"); return; } - static std::string staticBundleName = bundleName_; - static std::string staticDeviceId = deviceId; - static int32_t staticCode = resultCode; - static int32_t staticFlag = flag; + std::unique_ptr jsCallback = + std::make_unique(bundleName_, deviceId, resultCode, flag); + work->data = reinterpret_cast(jsCallback.get()); + int ret = uv_queue_work(loop, work, [] (uv_work_t *work) {}, [] (uv_work_t *work, int status) { - DeviceManagerNapi *deviceManagerNapi = DeviceManagerNapi::GetDeviceManagerNapi(staticBundleName); + DmNapiVerifyJsCallback *callback = reinterpret_cast(work->data); + DeviceManagerNapi *deviceManagerNapi = DeviceManagerNapi::GetDeviceManagerNapi(callback->bundleName_); if (deviceManagerNapi == nullptr) { - LOGE("OnVerifyAuthResult, deviceManagerNapi not find for bunderName %s", staticBundleName.c_str()); + LOGE("OnVerifyAuthResult, deviceManagerNapi not find for bunderName %s", callback->bundleName_.c_str()); return; } - deviceManagerNapi->OnVerifyResult(staticDeviceId, staticCode, staticFlag); + deviceManagerNapi->OnVerifyResult(callback->deviceId_, callback->resultCode_, callback->flag_); delete work; }); if (ret != 0) { @@ -1013,20 +1035,23 @@ void DmNapiDeviceManagerFaCallback::OnCall(const std::string ¶mJson) return; } uv_work_t *work = new (std::nothrow) uv_work_t; - if (loop == nullptr) { + if (work == nullptr) { LOGE("DmNapiDeviceManagerFaCallback: OnCall, No memory"); return; } - static std::string staticBundleName = bundleName_; - static std::string staticParamJson = paramJson; + std::unique_ptr jsCallback = + std::make_unique(bundleName_, "", paramJson, 0, 0); + work->data = reinterpret_cast(jsCallback.get()); + int ret = uv_queue_work(loop, work, [] (uv_work_t *work) {}, [] (uv_work_t *work, int status) { - DeviceManagerNapi *deviceManagerNapi = DeviceManagerNapi::GetDeviceManagerNapi(staticBundleName); + DmNapiAuthJsCallback *callback = reinterpret_cast(work->data); + DeviceManagerNapi *deviceManagerNapi = DeviceManagerNapi::GetDeviceManagerNapi(callback->bundleName_); if (deviceManagerNapi == nullptr) { - LOGE("OnCall, deviceManagerNapi not find for bunderName %s", staticBundleName.c_str()); + LOGE("OnCall, deviceManagerNapi not find for bunderName %s", callback->bundleName_.c_str()); return; } - deviceManagerNapi->OnDmfaCall(staticParamJson); + deviceManagerNapi->OnDmfaCall(callback->token_); delete work; }); if (ret != 0) { -- Gitee From 3c07fa5e08b48b2fb1ddac8e7ce0f87cee2d09c7 Mon Sep 17 00:00:00 2001 From: renguang1116 Date: Mon, 7 Mar 2022 15:12:32 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=97=A0=E6=B3=95?= =?UTF-8?q?=E4=B8=8A=E6=8A=A5=E5=A4=9A=E4=B8=AA=E8=AE=BE=E5=A4=87=E9=97=AE?= =?UTF-8?q?=E9=A2=98=20Signed-off-by:=20renguang1116=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- interfaces/kits/js/include/native_devicemanager_js.h | 6 +++--- interfaces/kits/js/src/native_devicemanager_js.cpp | 3 ++- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/interfaces/kits/js/include/native_devicemanager_js.h b/interfaces/kits/js/include/native_devicemanager_js.h index 7c8c143a8..96a8871ec 100644 --- a/interfaces/kits/js/include/native_devicemanager_js.h +++ b/interfaces/kits/js/include/native_devicemanager_js.h @@ -89,7 +89,7 @@ struct DmNapiStateJsCallback { DmNapiStateJsCallback(std::string bundleName, uint16_t subscribeId, int32_t reason, OHOS::DistributedHardware::DmDeviceInfo deviceInfo) : bundleName_(bundleName), subscribeId_(subscribeId), reason_(reason), deviceInfo_(deviceInfo) {} -} +}; struct DmNapiAuthJsCallback { std::string bundleName_; @@ -101,7 +101,7 @@ struct DmNapiAuthJsCallback { DmNapiAuthJsCallback(std::string bundleName, std::string deviceId, std::string token, int32_t status, int32_t reason) : bundleName_(bundleName), deviceId_(deviceId), token_(token), status_(status), reason_(reason) {} -} +}; struct DmNapiVerifyJsCallback { std::string bundleName_; @@ -111,7 +111,7 @@ struct DmNapiVerifyJsCallback { DmNapiVerifyJsCallback(std::string bundleName, std::string deviceId, int32_t resultCode, int32_t flag) : bundleName_(bundleName), deviceId_(deviceId), resultCode_(resultCode), flag_(flag) {} -} +}; enum DmNapiDevStateChangeAction { ONLINE = 0, READY = 1, OFFLINE = 2, CHANGE = 3 }; diff --git a/interfaces/kits/js/src/native_devicemanager_js.cpp b/interfaces/kits/js/src/native_devicemanager_js.cpp index 382b03132..7ac949775 100644 --- a/interfaces/kits/js/src/native_devicemanager_js.cpp +++ b/interfaces/kits/js/src/native_devicemanager_js.cpp @@ -276,8 +276,9 @@ void DmNapiDiscoveryCallback::OnDiscoveryFailed(uint16_t subscribeId, int32_t fa return; } + DmDeviceInfo info; std::unique_ptr jsCallback = - std::make_unique(bundleName_, subscribeId, failedReason, deviceInfo); + std::make_unique(bundleName_, subscribeId, failedReason, info); work->data = reinterpret_cast(jsCallback.get()); int ret = uv_queue_work(loop, work, [] (uv_work_t *work) {}, [] (uv_work_t *work, int status) { -- Gitee From 53b79573d4edc081450900a216ff251d41c95be3 Mon Sep 17 00:00:00 2001 From: renguang1116 Date: Mon, 7 Mar 2022 07:13:54 +0000 Subject: [PATCH 3/3] update interfaces/kits/js/include/native_devicemanager_js.h. --- .../kits/js/include/native_devicemanager_js.h | 42 +++++-------------- 1 file changed, 11 insertions(+), 31 deletions(-) diff --git a/interfaces/kits/js/include/native_devicemanager_js.h b/interfaces/kits/js/include/native_devicemanager_js.h index 96a8871ec..3c5342bc2 100644 --- a/interfaces/kits/js/include/native_devicemanager_js.h +++ b/interfaces/kits/js/include/native_devicemanager_js.h @@ -47,20 +47,6 @@ struct DeviceInfoAsyncCallbackInfo { std::string bundleName; size_t bundleNameLen = 0; OHOS::DistributedHardware::DmDeviceInfo deviceInfo; - std::string extra; - // OHOS::DistributedHardware::DmFilterOptions filter; - napi_ref callback = nullptr; - napi_value thisVar = nullptr; - napi_deferred deferred = nullptr; - int32_t status = -1; -}; - -struct DeviceInfoListAsyncCallbackInfo { - napi_env env = nullptr; - napi_async_work asyncWork = nullptr; - - std::string bundleName; - size_t bundleNameLen = 0; std::vector devList; std::string extra; // OHOS::DistributedHardware::DmFilterOptions filter; @@ -68,8 +54,8 @@ struct DeviceInfoListAsyncCallbackInfo { napi_value thisVar = nullptr; napi_deferred deferred = nullptr; int32_t status = -1; + int32_t isList = 0; }; - struct AuthAsyncCallbackInfo { napi_env env = nullptr; @@ -82,13 +68,12 @@ struct AuthAsyncCallbackInfo { struct DmNapiStateJsCallback { std::string bundleName_; - uint16_t subscribeId_; + uint64_t subscribeId_; int32_t reason_; OHOS::DistributedHardware::DmDeviceInfo deviceInfo_; - DmNapiStateJsCallback(std::string bundleName, uint16_t subscribeId, int32_t reason, - OHOS::DistributedHardware::DmDeviceInfo deviceInfo) - : bundleName_(bundleName), subscribeId_(subscribeId), reason_(reason), deviceInfo_(deviceInfo) {} + DmNapiStateJsCallback(std::string bundleName, uint64_t subscribeId, int32_t reason, OHOS::DistributedHardware::DmDeviceInfo deviceInfo) + : bundleName_(bundleName), subscribeId_(subscribeId), reason_(reason), deviceInfo_(deviceInfo) {} }; struct DmNapiAuthJsCallback { @@ -98,9 +83,8 @@ struct DmNapiAuthJsCallback { int32_t status_; int32_t reason_; - DmNapiAuthJsCallback(std::string bundleName, std::string deviceId, std::string token, int32_t status, - int32_t reason) - : bundleName_(bundleName), deviceId_(deviceId), token_(token), status_(status), reason_(reason) {} + DmNapiAuthJsCallback(std::string bundleName, std::string deviceId, std::string token, int32_t status, int32_t reason) + : bundleName_(bundleName), deviceId_(deviceId), token_(token), status_(status), reason_(reason) {} }; struct DmNapiVerifyJsCallback { @@ -110,7 +94,7 @@ struct DmNapiVerifyJsCallback { int32_t flag_; DmNapiVerifyJsCallback(std::string bundleName, std::string deviceId, int32_t resultCode, int32_t flag) - : bundleName_(bundleName), deviceId_(deviceId), resultCode_(resultCode), flag_(flag) {} + : bundleName_(bundleName), deviceId_(deviceId), resultCode_(resultCode), flag_(flag) {} }; enum DmNapiDevStateChangeAction { ONLINE = 0, READY = 1, OFFLINE = 2, CHANGE = 3 }; @@ -148,8 +132,7 @@ private: class DmNapiDiscoveryCallback : public OHOS::DistributedHardware::DiscoveryCallback { public: - explicit DmNapiDiscoveryCallback(napi_env env, std::string &bundleName) - : env_(env), refCount_(0), bundleName_(bundleName) + explicit DmNapiDiscoveryCallback(napi_env env, std::string &bundleName) : env_(env), refCount_(0), bundleName_(bundleName) { } virtual ~DmNapiDiscoveryCallback() {}; @@ -229,7 +212,6 @@ public: static void HandleCreateDmCallBack(const napi_env &env, AsyncCallbackInfo *asCallbackInfo); static DeviceManagerNapi *GetDeviceManagerNapi(std::string &buldleName); static void CreateDmCallback(napi_env env, std::string &bundleName, std::string &eventType); - static void CreateDmCallback(napi_env env, std::string &bundleName, std::string &eventType, std::string &extra); static void ReleaseDmCallback(std::string &bundleName, std::string &eventType); static void DeviceInfoToJsArray(const napi_env &env, const std::vector &vecDevInfo, @@ -276,14 +258,12 @@ private: static napi_value JsOnFrench(napi_env env, int32_t num, napi_value thisVar, napi_value argv[]); static void CallAsyncWorkSync(napi_env env, DeviceInfoAsyncCallbackInfo *deviceInfoAsyncCallbackInfo); static void CallAsyncWork(napi_env env, DeviceInfoAsyncCallbackInfo *deviceInfoAsyncCallbackInfo); - static void CallAsyncWorkSync(napi_env env, DeviceInfoListAsyncCallbackInfo *deviceInfoListAsyncCallbackInfo); - static void CallAsyncWork(napi_env env, DeviceInfoListAsyncCallbackInfo *deviceInfoListAsyncCallbackInfo); static void CallGetTrustedDeviceListStatusSync(napi_env env, napi_status &status, - DeviceInfoListAsyncCallbackInfo *deviceInfoListAsyncCallbackInfo); + DeviceInfoAsyncCallbackInfo *deviceInfoAsyncCallbackInfo); static void CallGetTrustedDeviceListStatus(napi_env env, napi_status &status, - DeviceInfoListAsyncCallbackInfo *deviceInfoListAsyncCallbackInfo); + DeviceInfoAsyncCallbackInfo *deviceInfoAsyncCallbackInfo); static napi_value CallDeviceList(napi_env env, napi_callback_info info, - DeviceInfoListAsyncCallbackInfo *deviceInfoListAsyncCallbackInfo); + DeviceInfoAsyncCallbackInfo *deviceInfoAsyncCallbackInfo); static void CallGetLocalDeviceInfoSync(napi_env env, napi_status &status, DeviceInfoAsyncCallbackInfo *deviceInfoAsyncCallbackInfo); static void CallGetLocalDeviceInfo(napi_env env, napi_status &status, -- Gitee