diff --git a/README.md b/README.md old mode 100755 new mode 100644 diff --git a/README_zh.md b/README_zh.md old mode 100755 new mode 100644 diff --git a/figures/zh-cn_image_0000001123704367.png b/figures/zh-cn_image_0000001123704367.png old mode 100755 new mode 100644 diff --git a/figures/zh-cn_image_account_struct.png b/figures/zh-cn_image_account_struct.png old mode 100755 new mode 100644 diff --git a/frameworks/appaccount/native/BUILD.gn b/frameworks/appaccount/native/BUILD.gn index 50dd7e0b7..3bdcb7479 100644 --- a/frameworks/appaccount/native/BUILD.gn +++ b/frameworks/appaccount/native/BUILD.gn @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Huawei Device Co., Ltd. +# Copyright (c) 2021-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/frameworks/appaccount/native/test/unittest/app_account_manager_test.cpp b/frameworks/appaccount/native/test/unittest/app_account_manager_test.cpp index 742806527..ccdcdda2d 100644 --- a/frameworks/appaccount/native/test/unittest/app_account_manager_test.cpp +++ b/frameworks/appaccount/native/test/unittest/app_account_manager_test.cpp @@ -857,7 +857,6 @@ HWTEST_F(AppAccountManagerTest, AppAccountManager_SetOAuthToken_0200, TestSize.L HWTEST_F(AppAccountManagerTest, AppAccountManager_DeleteOAuthToken_0100, TestSize.Level1) { ACCOUNT_LOGI("AppAccountManager_DeleteOAuthToken_0100"); - std::string token; ErrCode result = AppAccountManager::DeleteOAuthToken(STRING_EMPTY, STRING_OWNER, STRING_AUTH_TYPE, STRING_TOKEN); EXPECT_EQ(result, ERR_APPACCOUNT_KIT_INVALID_PARAMETER); diff --git a/frameworks/common/BUILD.gn b/frameworks/common/BUILD.gn old mode 100755 new mode 100644 diff --git a/frameworks/common/account_error/include/account_error_no.h b/frameworks/common/account_error/include/account_error_no.h old mode 100755 new mode 100644 index 0c2536dfc..6ef70985c --- a/frameworks/common/account_error/include/account_error_no.h +++ b/frameworks/common/account_error/include/account_error_no.h @@ -13,8 +13,8 @@ * limitations under the License. */ -#ifndef BASE_ACCOUNT_INCLUDE_ACCOUNT_ERROR_NO_H -#define BASE_ACCOUNT_INCLUDE_ACCOUNT_ERROR_NO_H +#ifndef OS_ACCOUNT_FRAMEWORKS_COMMON_ACCOUNT_ERROR_INCLUDE_ACCOUNT_ERROR_NO_H +#define OS_ACCOUNT_FRAMEWORKS_COMMON_ACCOUNT_ERROR_INCLUDE_ACCOUNT_ERROR_NO_H #include "errors.h" @@ -420,4 +420,4 @@ enum { }; } // namespace OHOS -#endif /* BASE_ACCOUNT_INCLUDE_ACCOUNT_ERROR_NO_H */ +#endif // OS_ACCOUNT_FRAMEWORKS_COMMON_ACCOUNT_ERROR_INCLUDE_ACCOUNT_ERROR_NO_H diff --git a/frameworks/common/database/include/iaccount_info.h b/frameworks/common/database/include/iaccount_info.h index 46b00226f..5d5c7dfc6 100644 --- a/frameworks/common/database/include/iaccount_info.h +++ b/frameworks/common/database/include/iaccount_info.h @@ -12,13 +12,13 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#ifndef OS_ACCOUNT_FRAMEWORKS_COMMON_DATABASE_IACCOUNT_INFO_H -#define OS_ACCOUNT_FRAMEWORKS_COMMON_DATABASE_IACCOUNT_INFO_H + +#ifndef OS_ACCOUNT_FRAMEWORKS_COMMON_DATABASE_INCLUDE_IACCOUNT_INFO_H +#define OS_ACCOUNT_FRAMEWORKS_COMMON_DATABASE_INCLUDE_IACCOUNT_INFO_H #include #include "nlohmann/json.hpp" - namespace OHOS { namespace AccountSA { using Json = nlohmann::json; @@ -86,4 +86,4 @@ void GetDataByType(const Json &jsonObject, const nlohmann::detail::iter_impl #include "hilog/log.h" - namespace OHOS { namespace AccountSA { enum class AccountLogLevel { DEBUG = 0, INFO, WARN, ERROR, FATAL }; @@ -63,4 +62,4 @@ private: } // namespace AccountSA } // namespace OHOS -#endif // BASE_ACCOUNT_COMMON_LOG_INCLUDE_ACCOUNT_LOG_WRAPPER_H +#endif // OS_ACCOUNT_FRAMEWORKS_COMMON_LOG_INCLUDE_ACCOUNT_LOG_WRAPPER_H diff --git a/frameworks/common/log/src/account_log_wrapper.cpp b/frameworks/common/log/src/account_log_wrapper.cpp old mode 100755 new mode 100644 diff --git a/frameworks/common/perf_stat/include/perf_stat.h b/frameworks/common/perf_stat/include/perf_stat.h old mode 100755 new mode 100644 index a1d2cb3e8..7f87b4ce9 --- a/frameworks/common/perf_stat/include/perf_stat.h +++ b/frameworks/common/perf_stat/include/perf_stat.h @@ -13,8 +13,8 @@ * limitations under the License. */ -#ifndef BASE_ACCOUNT_SERVICES_COMMON_INCLUDE_PERF_STAT_H -#define BASE_ACCOUNT_SERVICES_COMMON_INCLUDE_PERF_STAT_H +#ifndef OS_ACCOUNT_FRAMEWORKS_COMMON_PERF_STAT_INCLUDE_PERF_STAT_H +#define OS_ACCOUNT_FRAMEWORKS_COMMON_PERF_STAT_INCLUDE_PERF_STAT_H #include #include @@ -84,7 +84,7 @@ private: bool enableStat_ = true; }; -} // namespace AccountSA -} // namespace OHOS +} // namespace AccountSA +} // namespace OHOS -#endif // BASE_ACCOUNT_SERVICES_COMMON_INCLUDE_PERF_STAT_H +#endif // OS_ACCOUNT_FRAMEWORKS_COMMON_PERF_STAT_INCLUDE_PERF_STAT_H diff --git a/frameworks/common/perf_stat/src/perf_stat.cpp b/frameworks/common/perf_stat/src/perf_stat.cpp old mode 100755 new mode 100644 diff --git a/frameworks/common/test/BUILD.gn b/frameworks/common/test/BUILD.gn old mode 100755 new mode 100644 diff --git a/frameworks/common/test/unittest/common_account_log_test/BUILD.gn b/frameworks/common/test/unittest/common_account_log_test/BUILD.gn old mode 100755 new mode 100644 diff --git a/frameworks/common/test/unittest/common_account_log_test/account_log_test.cpp b/frameworks/common/test/unittest/common_account_log_test/account_log_test.cpp old mode 100755 new mode 100644 diff --git a/frameworks/common/test/unittest/common_account_perf_test/BUILD.gn b/frameworks/common/test/unittest/common_account_perf_test/BUILD.gn old mode 100755 new mode 100644 diff --git a/frameworks/common/test/unittest/common_account_perf_test/account_perf_stat_test.cpp b/frameworks/common/test/unittest/common_account_perf_test/account_perf_stat_test.cpp old mode 100755 new mode 100644 diff --git a/frameworks/ohosaccount/account_kits_headers.gni b/frameworks/ohosaccount/account_kits_headers.gni old mode 100755 new mode 100644 index feb74e9ff..d5fa69d07 --- a/frameworks/ohosaccount/account_kits_headers.gni +++ b/frameworks/ohosaccount/account_kits_headers.gni @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Huawei Device Co., Ltd. +# Copyright (c) 2021-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/frameworks/ohosaccount/native/BUILD.gn b/frameworks/ohosaccount/native/BUILD.gn old mode 100755 new mode 100644 index 3f7737272..9342e45e0 --- a/frameworks/ohosaccount/native/BUILD.gn +++ b/frameworks/ohosaccount/native/BUILD.gn @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Huawei Device Co., Ltd. +# Copyright (c) 2021-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/frameworks/ohosaccount/native/src/account_proxy.cpp b/frameworks/ohosaccount/native/src/account_proxy.cpp old mode 100755 new mode 100644 diff --git a/frameworks/ohosaccount/native/src/ohos_account_kits.cpp b/frameworks/ohosaccount/native/src/ohos_account_kits.cpp old mode 100755 new mode 100644 index 1174064fd..29bed0138 --- a/frameworks/ohosaccount/native/src/ohos_account_kits.cpp +++ b/frameworks/ohosaccount/native/src/ohos_account_kits.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) 2021-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 @@ -13,14 +13,14 @@ * limitations under the License. */ -#include "ohos_account_kits.h" -#include "ohos_account_kits_impl.h" - -namespace OHOS { -namespace AccountSA { +#include "ohos_account_kits.h" +#include "ohos_account_kits_impl.h" + +namespace OHOS { +namespace AccountSA { OhosAccountKits& OhosAccountKits::GetInstance() -{ - return DelayedRefSingleton::GetInstance(); -} -} // namespace AccountSA -} // namespace OHOS +{ + return DelayedRefSingleton::GetInstance(); +} +} // namespace AccountSA +} // namespace OHOS diff --git a/frameworks/ohosaccount/native/src/ohos_account_kits_impl.cpp b/frameworks/ohosaccount/native/src/ohos_account_kits_impl.cpp old mode 100755 new mode 100644 diff --git a/frameworks/ohosaccount/test/BUILD.gn b/frameworks/ohosaccount/test/BUILD.gn old mode 100755 new mode 100644 index cf2518e66..0ad290d7f --- a/frameworks/ohosaccount/test/BUILD.gn +++ b/frameworks/ohosaccount/test/BUILD.gn @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Huawei Device Co., Ltd. +# Copyright (c) 2021-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/frameworks/ohosaccount/test/moduletests/account_mgr_test/BUILD.gn b/frameworks/ohosaccount/test/moduletests/account_mgr_test/BUILD.gn old mode 100755 new mode 100644 index 9593e13bb..1e546a840 --- a/frameworks/ohosaccount/test/moduletests/account_mgr_test/BUILD.gn +++ b/frameworks/ohosaccount/test/moduletests/account_mgr_test/BUILD.gn @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Huawei Device Co., Ltd. +# Copyright (c) 2021-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/frameworks/ohosaccount/test/moduletests/account_mgr_test/account_mgr_inner_sdk_func_test.cpp b/frameworks/ohosaccount/test/moduletests/account_mgr_test/account_mgr_inner_sdk_func_test.cpp old mode 100755 new mode 100644 index 2ef555e19..eb03f0c7a --- a/frameworks/ohosaccount/test/moduletests/account_mgr_test/account_mgr_inner_sdk_func_test.cpp +++ b/frameworks/ohosaccount/test/moduletests/account_mgr_test/account_mgr_inner_sdk_func_test.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) 2021-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/frameworks/osaccount/core/BUILD.gn b/frameworks/osaccount/core/BUILD.gn index 780976882..705f3cb43 100644 --- a/frameworks/osaccount/core/BUILD.gn +++ b/frameworks/osaccount/core/BUILD.gn @@ -41,8 +41,6 @@ config("os_account_core_config") { } config("os_account_core_public_config") { - # visibility = [ ":*" ] - include_dirs = [ "${os_account_core_path}/include", "${os_account_interfaces_native_path}/include", diff --git a/frameworks/osaccount/core/include/ios_account.h b/frameworks/osaccount/core/include/ios_account.h index 30d49abe1..d21b6fd52 100644 --- a/frameworks/osaccount/core/include/ios_account.h +++ b/frameworks/osaccount/core/include/ios_account.h @@ -12,8 +12,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#ifndef OS_ACCOUNT_FRAMEWORK_OSACCOUNT_CORE_INCLUDE_IOS_ACCOUNT_H -#define OS_ACCOUNT_FRAMEWORK_OSACCOUNT_CORE_INCLUDE_IOS_ACCOUNT_H + +#ifndef OS_ACCOUNT_FRAMEWORKS_OSACCOUNT_CORE_INCLUDE_IOS_ACCOUNT_H +#define OS_ACCOUNT_FRAMEWORKS_OSACCOUNT_CORE_INCLUDE_IOS_ACCOUNT_H + #include #include "iremote_broker.h" #include "iremote_object.h" @@ -21,6 +23,7 @@ #include "account_error_no.h" #include "os_account_constants.h" #include "os_account_event_listener.h" + namespace OHOS { namespace AccountSA { class IOsAccount : public IRemoteBroker { @@ -123,4 +126,5 @@ public: }; } // namespace AccountSA } // namespace OHOS + #endif // OS_ACCOUNT_FRAMEWORK_OSACCOUNT_CORE_INCLUDE_IOS_ACCOUNT_H diff --git a/frameworks/osaccount/core/include/os_account.h b/frameworks/osaccount/core/include/os_account.h index e38454dcf..4423e0cde 100644 --- a/frameworks/osaccount/core/include/os_account.h +++ b/frameworks/osaccount/core/include/os_account.h @@ -12,10 +12,13 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#ifndef OS_ACCOUNT_FRAMEWORK_OSACCOUNT_CORE_INCLUDE_OS_ACCOUNT_H -#define OS_ACCOUNT_FRAMEWORK_OSACCOUNT_CORE_INCLUDE_OS_ACCOUNT_H + +#ifndef OS_ACCOUNT_FRAMEWORKS_OSACCOUNT_CORE_INCLUDE_OS_ACCOUNT_H +#define OS_ACCOUNT_FRAMEWORKS_OSACCOUNT_CORE_INCLUDE_OS_ACCOUNT_H + #include "ios_account.h" #include "os_account_event_listener.h" + namespace OHOS { namespace AccountSA { class OsAccount { @@ -82,4 +85,5 @@ private: }; } // namespace AccountSA } // namespace OHOS -#endif /* OS_ACCOUNT_FRAMEWORK_OSACCOUNT_CORE_INCLUDE_OS_ACCOUNT_H */ + +#endif // OS_ACCOUNT_FRAMEWORKS_OSACCOUNT_CORE_INCLUDE_OS_ACCOUNT_H diff --git a/frameworks/osaccount/core/include/os_account_event_listener.h b/frameworks/osaccount/core/include/os_account_event_listener.h index 80fdc748f..5e6ffb10e 100644 --- a/frameworks/osaccount/core/include/os_account_event_listener.h +++ b/frameworks/osaccount/core/include/os_account_event_listener.h @@ -24,9 +24,9 @@ namespace AccountSA { class OsAccountEventListener : public OsAccountEventStub { public: explicit OsAccountEventListener(const std::shared_ptr &subscriber); - virtual ~OsAccountEventListener() override; + ~OsAccountEventListener() override; - virtual void OnAccountsChanged(const int &id) override; + void OnAccountsChanged(const int &id) override; void Stop(); diff --git a/frameworks/osaccount/core/include/os_account_event_proxy.h b/frameworks/osaccount/core/include/os_account_event_proxy.h index 241a2d1df..0eeffe419 100644 --- a/frameworks/osaccount/core/include/os_account_event_proxy.h +++ b/frameworks/osaccount/core/include/os_account_event_proxy.h @@ -24,9 +24,9 @@ namespace AccountSA { class OsAccountEventProxy : public IRemoteProxy { public: explicit OsAccountEventProxy(const sptr &object); - virtual ~OsAccountEventProxy() override; + ~OsAccountEventProxy() override; - virtual void OnAccountsChanged(const int &id) override; + void OnAccountsChanged(const int &id) override; private: template diff --git a/frameworks/osaccount/core/include/os_account_event_stub.h b/frameworks/osaccount/core/include/os_account_event_stub.h index c2ea6cf94..0170c15fa 100644 --- a/frameworks/osaccount/core/include/os_account_event_stub.h +++ b/frameworks/osaccount/core/include/os_account_event_stub.h @@ -24,9 +24,9 @@ namespace AccountSA { class OsAccountEventStub : public IRemoteStub { public: OsAccountEventStub(); - virtual ~OsAccountEventStub() override; + ~OsAccountEventStub() override; - virtual int OnRemoteRequest( + int OnRemoteRequest( uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) override; private: diff --git a/frameworks/osaccount/core/include/os_account_proxy.h b/frameworks/osaccount/core/include/os_account_proxy.h index a30fe0b4b..e24b6edfd 100644 --- a/frameworks/osaccount/core/include/os_account_proxy.h +++ b/frameworks/osaccount/core/include/os_account_proxy.h @@ -12,67 +12,70 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#ifndef OS_ACCOUNT_FRAMEWORK_OSACCOUNT_CORE_INCLUDE_OS_ACCOUNT_PROXY_H -#define OS_ACCOUNT_FRAMEWORK_OSACCOUNT_CORE_INCLUDE_OS_ACCOUNT_PROXY_H + +#ifndef OS_ACCOUNT_FRAMEWORKS_OSACCOUNT_CORE_INCLUDE_OS_ACCOUNT_PROXY_H +#define OS_ACCOUNT_FRAMEWORKS_OSACCOUNT_CORE_INCLUDE_OS_ACCOUNT_PROXY_H + #include "ios_account.h" #include "iremote_proxy.h" + namespace OHOS { namespace AccountSA { class OsAccountProxy : public IRemoteProxy { public: explicit OsAccountProxy(const sptr &object); - virtual ~OsAccountProxy() override; + ~OsAccountProxy() override; - virtual ErrCode CreateOsAccount( + ErrCode CreateOsAccount( const std::string &name, const OsAccountType &type, OsAccountInfo &osAccountInfo) override; - virtual ErrCode CreateOsAccountForDomain( + ErrCode CreateOsAccountForDomain( const OsAccountType &type, const DomainAccountInfo &domainInfo, OsAccountInfo &osAccountInfo) override; - virtual ErrCode RemoveOsAccount(const int id) override; - virtual ErrCode IsOsAccountExists(const int id, bool &isOsAccountExists) override; - virtual ErrCode IsOsAccountActived(const int id, bool &isOsAccountActived) override; - virtual ErrCode IsOsAccountConstraintEnable( + ErrCode RemoveOsAccount(const int id) override; + ErrCode IsOsAccountExists(const int id, bool &isOsAccountExists) override; + ErrCode IsOsAccountActived(const int id, bool &isOsAccountActived) override; + ErrCode IsOsAccountConstraintEnable( const int id, const std::string &constraint, bool &isConstraintEnable) override; - virtual ErrCode IsOsAccountVerified(const int id, bool &isVerified) override; - virtual ErrCode GetCreatedOsAccountsCount(unsigned int &osAccountsCount) override; - virtual ErrCode GetOsAccountLocalIdFromProcess(int &id) override; - virtual ErrCode GetOsAccountLocalIdFromDomain(const DomainAccountInfo &domainInfo, int &id) override; - virtual ErrCode QueryMaxOsAccountNumber(int &maxOsAccountNumber) override; - virtual ErrCode GetOsAccountAllConstraints(const int id, std::vector &constraints) override; - virtual ErrCode QueryAllCreatedOsAccounts(std::vector &osAccountInfos) override; - virtual ErrCode QueryCurrentOsAccount(OsAccountInfo &osAccountInfo) override; - virtual ErrCode QueryOsAccountById(const int id, OsAccountInfo &osAccountInfo) override; - virtual ErrCode GetOsAccountTypeFromProcess(OsAccountType &type) override; - virtual ErrCode GetOsAccountProfilePhoto(const int id, std::string &photo) override; - virtual ErrCode IsMultiOsAccountEnable(bool &isMultiOsAccountEnable) override; - virtual ErrCode SetOsAccountName(const int id, const std::string &localName) override; - virtual ErrCode SetOsAccountConstraints( + ErrCode IsOsAccountVerified(const int id, bool &isVerified) override; + ErrCode GetCreatedOsAccountsCount(unsigned int &osAccountsCount) override; + ErrCode GetOsAccountLocalIdFromProcess(int &id) override; + ErrCode GetOsAccountLocalIdFromDomain(const DomainAccountInfo &domainInfo, int &id) override; + ErrCode QueryMaxOsAccountNumber(int &maxOsAccountNumber) override; + ErrCode GetOsAccountAllConstraints(const int id, std::vector &constraints) override; + ErrCode QueryAllCreatedOsAccounts(std::vector &osAccountInfos) override; + ErrCode QueryCurrentOsAccount(OsAccountInfo &osAccountInfo) override; + ErrCode QueryOsAccountById(const int id, OsAccountInfo &osAccountInfo) override; + ErrCode GetOsAccountTypeFromProcess(OsAccountType &type) override; + ErrCode GetOsAccountProfilePhoto(const int id, std::string &photo) override; + ErrCode IsMultiOsAccountEnable(bool &isMultiOsAccountEnable) override; + ErrCode SetOsAccountName(const int id, const std::string &localName) override; + ErrCode SetOsAccountConstraints( const int id, const std::vector &constraints, const bool enable) override; - virtual ErrCode SetOsAccountProfilePhoto(const int id, const std::string &photo) override; - virtual ErrCode ActivateOsAccount(const int id) override; - virtual ErrCode StartOsAccount(const int id) override; - virtual ErrCode StopOsAccount(const int id) override; - virtual ErrCode GetOsAccountLocalIdBySerialNumber(const int64_t serialNumber, int &id) override; - virtual ErrCode GetSerialNumberByOsAccountLocalId(const int &id, int64_t &serialNumber) override; - virtual ErrCode SubscribeOsAccount( + ErrCode SetOsAccountProfilePhoto(const int id, const std::string &photo) override; + ErrCode ActivateOsAccount(const int id) override; + ErrCode StartOsAccount(const int id) override; + ErrCode StopOsAccount(const int id) override; + ErrCode GetOsAccountLocalIdBySerialNumber(const int64_t serialNumber, int &id) override; + ErrCode GetSerialNumberByOsAccountLocalId(const int &id, int64_t &serialNumber) override; + ErrCode SubscribeOsAccount( const OsAccountSubscribeInfo &subscribeInfo, const sptr &eventListener) override; - virtual ErrCode UnsubscribeOsAccount(const sptr &eventListener) override; - virtual OS_ACCOUNT_SWITCH_MOD GetOsAccountSwitchMod() override; - virtual ErrCode IsCurrentOsAccountVerified(bool &isVerified) override; - virtual ErrCode IsOsAccountCompleted(const int id, bool &isOsAccountCompleted) override; - virtual ErrCode SetCurrentOsAccountIsVerified(const bool isVerified) override; - virtual ErrCode SetOsAccountIsVerified(const int id, const bool isVerified) override; - virtual ErrCode DumpState(const int &id, std::vector &state) override; + ErrCode UnsubscribeOsAccount(const sptr &eventListener) override; + OS_ACCOUNT_SWITCH_MOD GetOsAccountSwitchMod() override; + ErrCode IsCurrentOsAccountVerified(bool &isVerified) override; + ErrCode IsOsAccountCompleted(const int id, bool &isOsAccountCompleted) override; + ErrCode SetCurrentOsAccountIsVerified(const bool isVerified) override; + ErrCode SetOsAccountIsVerified(const int id, const bool isVerified) override; + ErrCode DumpState(const int &id, std::vector &state) override; - virtual void CreateBasicAccounts() override; - virtual ErrCode GetCreatedOsAccountNumFromDatabase(const std::string& storeID, + void CreateBasicAccounts() override; + ErrCode GetCreatedOsAccountNumFromDatabase(const std::string& storeID, int &createdOsAccountNum) override; - virtual ErrCode GetSerialNumberFromDatabase(const std::string& storeID, int64_t &serialNumber) override; - virtual ErrCode GetMaxAllowCreateIdFromDatabase(const std::string& storeID, int &id) override; - virtual ErrCode GetOsAccountFromDatabase(const std::string& storeID, const int id, + ErrCode GetSerialNumberFromDatabase(const std::string& storeID, int64_t &serialNumber) override; + ErrCode GetMaxAllowCreateIdFromDatabase(const std::string& storeID, int &id) override; + ErrCode GetOsAccountFromDatabase(const std::string& storeID, const int id, OsAccountInfo &osAccountInfo) override; - virtual ErrCode GetOsAccountListFromDatabase(const std::string& storeID, + ErrCode GetOsAccountListFromDatabase(const std::string& storeID, std::vector &osAccountList) override; - virtual ErrCode QueryActiveOsAccountIds(std::vector& ids) override; + ErrCode QueryActiveOsAccountIds(std::vector& ids) override; private: template @@ -86,4 +89,5 @@ private: }; } // namespace AccountSA } // namespace OHOS -#endif /* OS_ACCOUNT_FRAMEWORK_OSACCOUNT_CORE_INCLUDE_OS_ACCOUNT_PROXY_H */ + +#endif // OS_ACCOUNT_FRAMEWORKS_OSACCOUNT_CORE_INCLUDE_OS_ACCOUNT_PROXY_H diff --git a/frameworks/osaccount/core/include/os_account_stub.h b/frameworks/osaccount/core/include/os_account_stub.h index 010963b10..79ad21c58 100644 --- a/frameworks/osaccount/core/include/os_account_stub.h +++ b/frameworks/osaccount/core/include/os_account_stub.h @@ -12,18 +12,21 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#ifndef OS_ACCOUNT_FRAMEWORK_OSACCOUNT_CORE_INCLUDE_OS_ACCOUNT_STUB_H -#define OS_ACCOUNT_FRAMEWORK_OSACCOUNT_CORE_INCLUDE_OS_ACCOUNT_STUB_H + +#ifndef OS_ACCOUNT_FRAMEWORKS_OSACCOUNT_CORE_INCLUDE_OS_ACCOUNT_STUB_H +#define OS_ACCOUNT_FRAMEWORKS_OSACCOUNT_CORE_INCLUDE_OS_ACCOUNT_STUB_H + #include "ios_account.h" #include "iremote_stub.h" + namespace OHOS { namespace AccountSA { class OsAccountStub : public IRemoteStub { public: using MessageProcFunction = ErrCode (OsAccountStub::*)(MessageParcel &data, MessageParcel &reply); OsAccountStub(); - virtual ~OsAccountStub() override; - virtual int OnRemoteRequest( + ~OsAccountStub() override; + int OnRemoteRequest( uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) override; private: @@ -80,4 +83,5 @@ private: }; } // namespace AccountSA } // namespace OHOS -#endif /* OS_ACCOUNT_FRAMEWORK_OSACCOUNT_CORE_INCLUDE_OS_ACCOUNT_STUB_H */ + +#endif // OS_ACCOUNT_FRAMEWORKS_OSACCOUNT_CORE_INCLUDE_OS_ACCOUNT_STUB_H diff --git a/frameworks/osaccount/core/src/os_account_proxy.cpp b/frameworks/osaccount/core/src/os_account_proxy.cpp index f38174822..9da24d2d9 100644 --- a/frameworks/osaccount/core/src/os_account_proxy.cpp +++ b/frameworks/osaccount/core/src/os_account_proxy.cpp @@ -1267,7 +1267,7 @@ bool OsAccountProxy::ReadParcelableVector(std::vector &parcelableInfos, Messa ACCOUNT_LOGI("Account read Parcelable size is %{public}d", infoSize); parcelableInfos.clear(); for (uint32_t index = 0; index < infoSize; index++) { - T *info = data.ReadParcelable(); + std::shared_ptr info(data.ReadParcelable()); if (info == nullptr) { ACCOUNT_LOGE("Account read Parcelable infos failed."); return false; diff --git a/frameworks/osaccount/core/src/os_account_stub.cpp b/frameworks/osaccount/core/src/os_account_stub.cpp index 5c6c60565..ef086e882 100644 --- a/frameworks/osaccount/core/src/os_account_stub.cpp +++ b/frameworks/osaccount/core/src/os_account_stub.cpp @@ -233,7 +233,7 @@ bool OsAccountStub::ReadParcelableVector(std::vector &parcelableInfos, Messag parcelableInfos.clear(); for (uint32_t index = 0; index < infoSize; index++) { - T *info = data.ReadParcelable(); + std::shared_ptr info(data.ReadParcelable()); if (info == nullptr) { ACCOUNT_LOGE("read Parcelable infos failed."); return false; diff --git a/frameworks/osaccount/native/test/moduletest/os_account_manager_module_test.cpp b/frameworks/osaccount/native/test/moduletest/os_account_manager_module_test.cpp index 126c53232..a41373313 100644 --- a/frameworks/osaccount/native/test/moduletest/os_account_manager_module_test.cpp +++ b/frameworks/osaccount/native/test/moduletest/os_account_manager_module_test.cpp @@ -1037,7 +1037,7 @@ HWTEST_F(OsAccountManagerModuleTest, OsAccountManagerModuleTest053, TestSize.Lev std::string osAccountName = domainInfo.domain_ + "/" + domainInfo.accountName_; checkValid = (osAccountInfo.GetLocalName() == osAccountName); EXPECT_EQ(checkValid, true); - + EXPECT_EQ(OsAccountManager::RemoveOsAccount(osAccountInfo.GetLocalId()), ERR_OK); } @@ -1363,7 +1363,7 @@ HWTEST_F(OsAccountManagerModuleTest, OsAccountManagerModuleTest065, TestSize.Lev OsAccountInfo osAccountInfo; ret = OsAccountManager::GetOsAccountFromDatabase(storeID, osAccountInfoOne.GetLocalId(), osAccountInfo); EXPECT_NE(ret, ERR_OK); - + // remove the new os account ret = OsAccountManager::RemoveOsAccount(osAccountInfoOne.GetLocalId()); EXPECT_NE(ret, ERR_OK); diff --git a/hisysevent.yaml b/hisysevent.yaml index dabaf491c..69a9636de 100644 --- a/hisysevent.yaml +++ b/hisysevent.yaml @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Huawei Device Co., Ltd. +# Copyright (c) 2021-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/interfaces/innerkits/ohosaccount/native/include/account_info.h b/interfaces/innerkits/ohosaccount/native/include/account_info.h old mode 100755 new mode 100644 index cd329dedc..baa8c8cd8 --- a/interfaces/innerkits/ohosaccount/native/include/account_info.h +++ b/interfaces/innerkits/ohosaccount/native/include/account_info.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) 2021-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 @@ -73,7 +73,7 @@ public: OhosAccountInfo() { status_ = ACCOUNT_STATE_UNBOUND; - }; + } ~OhosAccountInfo() {}; }; @@ -115,7 +115,7 @@ public: bindTime_ = 0; } - ~AccountInfo() {}; + ~AccountInfo() {} }; } // namespace AccountSA } // namespace OHOS diff --git a/interfaces/innerkits/ohosaccount/native/include/device_account_info.h b/interfaces/innerkits/ohosaccount/native/include/device_account_info.h old mode 100755 new mode 100644 index e56baa158..258e94991 --- a/interfaces/innerkits/ohosaccount/native/include/device_account_info.h +++ b/interfaces/innerkits/ohosaccount/native/include/device_account_info.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) 2021-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/interfaces/innerkits/ohosaccount/native/include/iaccount.h b/interfaces/innerkits/ohosaccount/native/include/iaccount.h old mode 100755 new mode 100644 diff --git a/interfaces/innerkits/ohosaccount/native/include/ohos_account_kits.h b/interfaces/innerkits/ohosaccount/native/include/ohos_account_kits.h old mode 100755 new mode 100644 index b94c76470..324ecad24 --- a/interfaces/innerkits/ohosaccount/native/include/ohos_account_kits.h +++ b/interfaces/innerkits/ohosaccount/native/include/ohos_account_kits.h @@ -1,18 +1,18 @@ -/* - * 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. - */ - +/* + * Copyright (c) 2021-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 + * + * 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 BASE_ACCOUNT_OHOS_ACCOUNT_KITS_H #define BASE_ACCOUNT_OHOS_ACCOUNT_KITS_H @@ -34,7 +34,7 @@ public: * * @return Instance of ohos account manager. */ - static OhosAccountKits& GetInstance(); + static OhosAccountKits& GetInstance(); /** * Query OHOS Account Info. @@ -45,18 +45,18 @@ public: virtual std::pair QueryOhosAccountInfo() = 0; /** - * Update OHOS Account Info. - * - * @param accountName Indicates the name of the OS account used for a distributed system. - * @param uid Uniquely identifies the OS account used for a distributed system. - * @param eventStr Indicates the event of the OS account used for a distributed system. - * @return Returns {@code true} if the distributed information of the account is updated; - * returns {@code false} otherwise. - */ - virtual bool UpdateOhosAccountInfo(const std::string& accountName, const std::string& uid, - const std::string& eventStr) = 0; - - /** + * Update OHOS Account Info. + * + * @param accountName Indicates the name of the OS account used for a distributed system. + * @param uid Uniquely identifies the OS account used for a distributed system. + * @param eventStr Indicates the event of the OS account used for a distributed system. + * @return Returns {@code true} if the distributed information of the account is updated; + * returns {@code false} otherwise. + */ + virtual bool UpdateOhosAccountInfo(const std::string& accountName, const std::string& uid, + const std::string& eventStr) = 0; + + /** * Query Device Account Id. * * @param device account id. diff --git a/interfaces/innerkits/ohosaccount/native/include/ohos_account_kits_impl.h b/interfaces/innerkits/ohosaccount/native/include/ohos_account_kits_impl.h old mode 100755 new mode 100644 index 1f67662b4..3f0b1a3a7 --- a/interfaces/innerkits/ohosaccount/native/include/ohos_account_kits_impl.h +++ b/interfaces/innerkits/ohosaccount/native/include/ohos_account_kits_impl.h @@ -1,25 +1,25 @@ -/* - * 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. - */ - +/* + * Copyright (c) 2021-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 + * + * 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 BASE_ACCOUNT_OHOS_ACCOUNT_KITS_IMPL_H #define BASE_ACCOUNT_OHOS_ACCOUNT_KITS_IMPL_H #include #include "ipc_skeleton.h" -#include "ohos_account_kits.h" -#include "singleton.h" +#include "ohos_account_kits.h" +#include "singleton.h" namespace OHOS { namespace AccountSA { @@ -28,8 +28,8 @@ class OhosAccountKitsImpl final : public OhosAccountKits, public DelayedRefSingl public: DISALLOW_COPY_AND_MOVE(OhosAccountKitsImpl); - bool UpdateOhosAccountInfo(const std::string& accountName, const std::string& uid, - const std::string& eventStr) final; + bool UpdateOhosAccountInfo(const std::string& accountName, const std::string& uid, + const std::string& eventStr) final; std::pair QueryOhosAccountInfo() final; ErrCode QueryDeviceAccountId(std::int32_t& accountId) final; std::int32_t GetDeviceAccountIdByUID(std::int32_t& uid) final; diff --git a/interfaces/innerkits/osaccount/native/include/os_account_info.h b/interfaces/innerkits/osaccount/native/include/os_account_info.h index 7733552b4..a5e2d5b4f 100644 --- a/interfaces/innerkits/osaccount/native/include/os_account_info.h +++ b/interfaces/innerkits/osaccount/native/include/os_account_info.h @@ -88,17 +88,17 @@ public: void SetLastLoginTime(const int64_t lastLoginTime); - virtual Json ToJson() const override; + Json ToJson() const override; - virtual void FromJson(const Json &jsonObject) override; + void FromJson(const Json &jsonObject) override; - virtual bool Marshalling(Parcel &parcel) const override; + bool Marshalling(Parcel &parcel) const override; bool ReadFromParcel(Parcel &parcel); - virtual std::string ToString() const override; + std::string ToString() const override; - virtual std::string GetPrimeKey() const override; + std::string GetPrimeKey() const override; static OsAccountInfo *Unmarshalling(Parcel &parcel); diff --git a/interfaces/innerkits/osaccount/native/include/os_account_subscribe_info.h b/interfaces/innerkits/osaccount/native/include/os_account_subscribe_info.h index 079c6dffa..a689297c7 100644 --- a/interfaces/innerkits/osaccount/native/include/os_account_subscribe_info.h +++ b/interfaces/innerkits/osaccount/native/include/os_account_subscribe_info.h @@ -36,7 +36,7 @@ public: ErrCode GetName(std::string &name) const; ErrCode SetName(const std::string &name); - virtual bool Marshalling(Parcel &parcel) const override; + bool Marshalling(Parcel &parcel) const override; static OsAccountSubscribeInfo *Unmarshalling(Parcel &parcel); private: diff --git a/interfaces/kits/napi/appaccount/include/napi_app_account.h b/interfaces/kits/napi/appaccount/include/napi_app_account.h index 86722746a..6dcac4f90 100644 --- a/interfaces/kits/napi/appaccount/include/napi_app_account.h +++ b/interfaces/kits/napi/appaccount/include/napi_app_account.h @@ -13,8 +13,8 @@ * limitations under the License. */ -#ifndef NAPI_APPACCOUNT_ACCOUNT_H -#define NAPI_APPACCOUNT_ACCOUNT_H +#ifndef OS_ACCOUNT_INTERFACES_KITS_NAPI_APPACCOUNT_INCLUDE_NAPI_APP_ACCOUNT_H +#define OS_ACCOUNT_INTERFACES_KITS_NAPI_APPACCOUNT_INCLUDE_NAPI_APP_ACCOUNT_H #include "napi/native_api.h" @@ -59,4 +59,4 @@ private: } // namespace AccountJsKit } // namespace OHOS -#endif // NAPI_APPACCOUNT_ACCOUNT_H \ No newline at end of file +#endif // OS_ACCOUNT_INTERFACES_KITS_NAPI_APPACCOUNT_INCLUDE_NAPI_APP_ACCOUNT_H diff --git a/interfaces/kits/napi/appaccount/include/napi_app_account_authenticator.h b/interfaces/kits/napi/appaccount/include/napi_app_account_authenticator.h index f7e76bbe4..795d3cb0f 100644 --- a/interfaces/kits/napi/appaccount/include/napi_app_account_authenticator.h +++ b/interfaces/kits/napi/appaccount/include/napi_app_account_authenticator.h @@ -13,8 +13,8 @@ * limitations under the License. */ -#ifndef NAPI_APP_ACCOUNT_ACCOUNT_AUTHENTICATOR_STUB_H -#define NAPI_APP_ACCOUNT_ACCOUNT_AUTHENTICATOR_STUB_H +#ifndef OS_ACCOUNT_INTERFACES_KITS_NAPI_APPACCOUNT_INCLUDE_NAPI_APP_ACCOUNT_AUTHENTICATOR_H +#define OS_ACCOUNT_INTERFACES_KITS_NAPI_APPACCOUNT_INCLUDE_NAPI_APP_ACCOUNT_AUTHENTICATOR_H #include @@ -47,13 +47,13 @@ class NapiAppAccountAuthenticator : public AccountSA::AppAccountAuthenticatorStu public: NapiAppAccountAuthenticator(const napi_env &env, const napi_ref &addAccountImplicitlyRef, const napi_ref &authenticateRef); - virtual ~NapiAppAccountAuthenticator() override; + ~NapiAppAccountAuthenticator() override; bool CheckObjectLegality() const override; int GetObjectType() const override; static napi_value Init(napi_env env, napi_value exports); - virtual ErrCode AddAccountImplicitly(const std::string &authType, const std::string &callerBundleName, + ErrCode AddAccountImplicitly(const std::string &authType, const std::string &callerBundleName, const AAFwk::WantParams &options, const sptr &callback) override; - virtual ErrCode Authenticate( + ErrCode Authenticate( const std::string &name, const std::string &authType, const std::string &callerBundleName, const AAFwk::WantParams &options, const sptr &callback) override; @@ -68,4 +68,4 @@ private: } // namespace AccountJsKit } // namespace OHOS -#endif // NAPI_APP_ACCOUNT_ACCOUNT_AUTHENTICATOR_H \ No newline at end of file +#endif // OS_ACCOUNT_INTERFACES_KITS_NAPI_APPACCOUNT_INCLUDE_NAPI_APP_ACCOUNT_AUTHENTICATOR_H diff --git a/interfaces/kits/napi/appaccount/include/napi_app_account_authenticator_callback.h b/interfaces/kits/napi/appaccount/include/napi_app_account_authenticator_callback.h index ccb5c5724..483293b95 100644 --- a/interfaces/kits/napi/appaccount/include/napi_app_account_authenticator_callback.h +++ b/interfaces/kits/napi/appaccount/include/napi_app_account_authenticator_callback.h @@ -13,8 +13,8 @@ * limitations under the License. */ -#ifndef NAPI_APP_ACCOUNT_AUTHENTICATOR_CALLBACK_PROXY_H -#define NAPI_APP_ACCOUNT_AUTHENTICATOR_CALLBACK_PROXY_H +#ifndef OS_ACCOUNT_INTERFACES_KITS_NAPI_APPACCOUNT_INCLUDE_NAPI_APP_ACCOUNT_AUTHENTICATOR_CALLBACK_H +#define OS_ACCOUNT_INTERFACES_KITS_NAPI_APPACCOUNT_INCLUDE_NAPI_APP_ACCOUNT_AUTHENTICATOR_CALLBACK_H #include "iapp_account_authenticator_callback.h" #include "iremote_proxy.h" @@ -47,6 +47,7 @@ struct CallbackParam { napi_ref callbackRef; NapiAppAccountAuthenticatorCallback *callback; }; -} // namespace AccountSA +} // namespace AccountJsKit } // namespace OHOS -#endif // NAPI_APP_ACCOUNT_AUTHENTICATOR_CALLBACK_PROXY_H + +#endif // OS_ACCOUNT_INTERFACES_KITS_NAPI_APPACCOUNT_INCLUDE_NAPI_APP_ACCOUNT_AUTHENTICATOR_CALLBACK_H diff --git a/interfaces/kits/napi/appaccount/include/napi_app_account_common.h b/interfaces/kits/napi/appaccount/include/napi_app_account_common.h index 3d6933f34..0869ce886 100644 --- a/interfaces/kits/napi/appaccount/include/napi_app_account_common.h +++ b/interfaces/kits/napi/appaccount/include/napi_app_account_common.h @@ -13,8 +13,8 @@ * limitations under the License. */ -#ifndef NAPI_APP_ACCOUNT_COMMON -#define NAPI_APP_ACCOUNT_COMMON +#ifndef OS_ACCOUNT_INTERFACES_KITS_NAPI_APPACCOUNT_INCLUDE_NAPI_APP_ACCOUNT_COMMON_H +#define OS_ACCOUNT_INTERFACES_KITS_NAPI_APPACCOUNT_INCLUDE_NAPI_APP_ACCOUNT_COMMON_H #include #include #include "app_account_authenticator_callback_stub.h" @@ -55,10 +55,10 @@ extern std::map> g_ class SubscriberPtr : public AppAccountSubscriber { public: - SubscriberPtr(const AppAccountSubscribeInfo &subscribeInfo); + explicit SubscriberPtr(const AppAccountSubscribeInfo &subscribeInfo); ~SubscriberPtr(); - virtual void OnAccountsChanged(const std::vector &accounts) override; + void OnAccountsChanged(const std::vector &accounts) override; void SetEnv(const napi_env &env); void SetCallbackRef(const napi_ref &ref); @@ -164,8 +164,8 @@ public: AppAccountManagerCallback(); ~AppAccountManagerCallback(); - virtual void OnResult(int32_t resultCode, const AAFwk::Want &result) override; - virtual void OnRequestRedirected(AAFwk::Want &request) override; + void OnResult(int32_t resultCode, const AAFwk::Want &result) override; + void OnRequestRedirected(AAFwk::Want &request) override; void SetEnv(const napi_env &env); void SetResultRef(const napi_ref &ref); @@ -261,4 +261,4 @@ void UnsubscribeCallbackCompletedCB(napi_env env, napi_status status, void *data } // namespace AccountJsKit } // namespace OHOS -#endif /* NAPI_APP_ACCOUNT_COMMON */ +#endif // OS_ACCOUNT_INTERFACES_KITS_NAPI_APPACCOUNT_INCLUDE_NAPI_APP_ACCOUNT_COMMON_H diff --git a/interfaces/kits/napi/appaccount/include/napi_app_account_constant.h b/interfaces/kits/napi/appaccount/include/napi_app_account_constant.h index ad63a6404..f446e2b8c 100644 --- a/interfaces/kits/napi/appaccount/include/napi_app_account_constant.h +++ b/interfaces/kits/napi/appaccount/include/napi_app_account_constant.h @@ -13,8 +13,8 @@ * limitations under the License. */ -#ifndef NAPI_APP_ACCOUNT_CONSTANTS -#define NAPI_APP_ACCOUNT_CONSTANTS +#ifndef OS_ACCOUNT_INTERFACES_KITS_NAPI_APPACCOUNT_INCLUDE_NAPI_APP_ACCOUNT_CONSTANT_H +#define OS_ACCOUNT_INTERFACES_KITS_NAPI_APPACCOUNT_INCLUDE_NAPI_APP_ACCOUNT_CONSTANT_H #include "napi/native_api.h" @@ -26,4 +26,5 @@ public: }; } // namespace AccountJsKit } // namespace OHOS -#endif // NAPI_APP_ACCOUNT_CONSTANTS \ No newline at end of file + +#endif // OS_ACCOUNT_INTERFACES_KITS_NAPI_APPACCOUNT_INCLUDE_NAPI_APP_ACCOUNT_CONSTANT_H diff --git a/interfaces/kits/napi/appaccount/src/napi_app_account.cpp b/interfaces/kits/napi/appaccount/src/napi_app_account.cpp index 31ae9e4a3..eeeca942c 100644 --- a/interfaces/kits/napi/appaccount/src/napi_app_account.cpp +++ b/interfaces/kits/napi/appaccount/src/napi_app_account.cpp @@ -146,14 +146,14 @@ napi_value NapiAppAccount::AddAccount(napi_env env, napi_callback_info cbInfo) resource, [](napi_env env, void *data) { ACCOUNT_LOGI("AddAccount, napi_create_async_work running."); - AppAccountAsyncContext *asyncContext = (AppAccountAsyncContext *)data; + AppAccountAsyncContext *asyncContext = reinterpret_cast(data); asyncContext->errCode = AppAccountManager::AddAccount(asyncContext->name, asyncContext->extraInfo); ACCOUNT_LOGI("Addcount errcode parameter is %{public}d", asyncContext->errCode); asyncContext->status = asyncContext->errCode == 0 ? napi_ok : napi_generic_failure; }, [](napi_env env, napi_status status, void *data) { ACCOUNT_LOGI("AddAccount, napi_create_async_work complete."); - AppAccountAsyncContext *asyncContext = (AppAccountAsyncContext *)data; + AppAccountAsyncContext *asyncContext = reinterpret_cast(data); napi_value addResult[RESULT_COUNT] = {0}; addResult[PARAMZERO] = GetErrorCodeValue(env, asyncContext->errCode); napi_get_undefined(env, &addResult[PARAMONE]); @@ -162,7 +162,7 @@ napi_value NapiAppAccount::AddAccount(napi_env env, napi_callback_info cbInfo) delete asyncContext; asyncContext = nullptr; }, - (void *)asyncContext, + reinterpret_cast(asyncContext), &asyncContext->work); napi_queue_async_work(env, asyncContext->work); return result; @@ -195,7 +195,7 @@ napi_value NapiAppAccount::AddAccountImplicitly(napi_env env, napi_callback_info resourceName, [](napi_env env, void *data) { ACCOUNT_LOGI("AddAccountImplicitly, napi_create_async_work running."); - OAuthAsyncContext *asyncContext = (OAuthAsyncContext *)data; + OAuthAsyncContext *asyncContext = reinterpret_cast(data); ErrCode errCode = AppAccountManager::AddAccountImplicitly(asyncContext->owner, asyncContext->authType, asyncContext->options, asyncContext->appAccountMgrCb); asyncContext->errCode = ConvertToJSErrCode(errCode); @@ -203,7 +203,7 @@ napi_value NapiAppAccount::AddAccountImplicitly(napi_env env, napi_callback_info }, [](napi_env env, napi_status status, void *data) { ACCOUNT_LOGI("AddAccountImplicitly, napi_create_async_work complete."); - OAuthAsyncContext *asyncContext = (OAuthAsyncContext *)data; + OAuthAsyncContext *asyncContext = reinterpret_cast(data); AAFwk::Want errResult; if ((asyncContext->errCode != 0) && (asyncContext->appAccountMgrCb != nullptr)) { asyncContext->appAccountMgrCb->OnResult(asyncContext->errCode, errResult); @@ -212,7 +212,7 @@ napi_value NapiAppAccount::AddAccountImplicitly(napi_env env, napi_callback_info delete asyncContext; asyncContext = nullptr; }, - (void *)asyncContext, + reinterpret_cast(asyncContext), &asyncContext->work)); NAPI_CALL(env, napi_queue_async_work(env, asyncContext->work)); return NapiGetNull(env); @@ -248,14 +248,14 @@ napi_value NapiAppAccount::DeleteAccount(napi_env env, napi_callback_info cbInfo resource, [](napi_env env, void *data) { ACCOUNT_LOGI("DeleteAccount, napi_create_async_work running."); - AppAccountAsyncContext *asyncContext = (AppAccountAsyncContext *)data; + AppAccountAsyncContext *asyncContext = reinterpret_cast(data); asyncContext->errCode = AppAccountManager::DeleteAccount(asyncContext->name); ACCOUNT_LOGI("Deleteaccount errcode parameter is %{public}d", asyncContext->errCode); asyncContext->status = asyncContext->errCode == 0 ? napi_ok : napi_generic_failure; }, [](napi_env env, napi_status status, void *data) { ACCOUNT_LOGI("DeleteAccount, napi_create_async_work complete."); - AppAccountAsyncContext *asyncContext = (AppAccountAsyncContext *)data; + AppAccountAsyncContext *asyncContext = reinterpret_cast(data); napi_value delResult[RESULT_COUNT] = {0}; delResult[PARAMZERO] = GetErrorCodeValue(env, asyncContext->errCode); napi_get_undefined(env, &delResult[PARAMONE]); @@ -264,7 +264,7 @@ napi_value NapiAppAccount::DeleteAccount(napi_env env, napi_callback_info cbInfo delete asyncContext; asyncContext = nullptr; }, - (void *)asyncContext, + reinterpret_cast(asyncContext), &asyncContext->work); napi_queue_async_work(env, asyncContext->work); return result; @@ -302,14 +302,14 @@ napi_value NapiAppAccount::DisableAppAccess(napi_env env, napi_callback_info cbI resource, [](napi_env env, void *data) { ACCOUNT_LOGI("DisableAppAccess, napi_create_async_work running."); - AppAccountAsyncContext *asyncContext = (AppAccountAsyncContext *)data; + AppAccountAsyncContext *asyncContext = reinterpret_cast(data); asyncContext->errCode = AppAccountManager::DisableAppAccess(asyncContext->name, asyncContext->bundleName); ACCOUNT_LOGI("DisableAppAccess errcode parameter is %{public}d", asyncContext->errCode); asyncContext->status = asyncContext->errCode == 0 ? napi_ok : napi_generic_failure; }, [](napi_env env, napi_status status, void *data) { ACCOUNT_LOGI("DisableAppAccess, napi_create_async_work complete."); - AppAccountAsyncContext *asyncContext = (AppAccountAsyncContext *)data; + AppAccountAsyncContext *asyncContext = reinterpret_cast(data); napi_value disResult[RESULT_COUNT] = {0}; disResult[PARAMZERO] = GetErrorCodeValue(env, asyncContext->errCode); napi_get_undefined(env, &disResult[PARAMONE]); @@ -318,7 +318,7 @@ napi_value NapiAppAccount::DisableAppAccess(napi_env env, napi_callback_info cbI delete asyncContext; asyncContext = nullptr; }, - (void *)asyncContext, + reinterpret_cast(asyncContext), &asyncContext->work); napi_queue_async_work(env, asyncContext->work); return result; @@ -356,14 +356,14 @@ napi_value NapiAppAccount::EnableAppAccess(napi_env env, napi_callback_info cbIn resource, [](napi_env env, void *data) { ACCOUNT_LOGI("EnableAppAccess, napi_create_async_work running."); - AppAccountAsyncContext *asyncContext = (AppAccountAsyncContext *)data; + AppAccountAsyncContext *asyncContext = reinterpret_cast(data); asyncContext->errCode = AppAccountManager::EnableAppAccess(asyncContext->name, asyncContext->bundleName); ACCOUNT_LOGI("EnableAppAccess errcode parameter is %{public}d", asyncContext->errCode); asyncContext->status = asyncContext->errCode == 0 ? napi_ok : napi_generic_failure; }, [](napi_env env, napi_status status, void *data) { ACCOUNT_LOGI("EnableAppAccess, napi_create_async_work complete."); - AppAccountAsyncContext *asyncContext = (AppAccountAsyncContext *)data; + AppAccountAsyncContext *asyncContext = reinterpret_cast(data); napi_value enResult[RESULT_COUNT] = {0}; enResult[PARAMZERO] = GetErrorCodeValue(env, asyncContext->errCode); napi_get_undefined(env, &enResult[PARAMONE]); @@ -372,7 +372,7 @@ napi_value NapiAppAccount::EnableAppAccess(napi_env env, napi_callback_info cbIn delete asyncContext; asyncContext = nullptr; }, - (void *)asyncContext, + reinterpret_cast(asyncContext), &asyncContext->work); napi_queue_async_work(env, asyncContext->work); return result; @@ -408,7 +408,7 @@ napi_value NapiAppAccount::CheckAppAccountSyncEnable(napi_env env, napi_callback resource, [](napi_env env, void *data) { ACCOUNT_LOGI("CheckAppAccountSyncEnable, napi_create_async_work running."); - AppAccountAsyncContext *asyncContext = (AppAccountAsyncContext *)data; + AppAccountAsyncContext *asyncContext = reinterpret_cast(data); asyncContext->errCode = AppAccountManager::CheckAppAccountSyncEnable(asyncContext->name, asyncContext->result); ACCOUNT_LOGI("CheckAppAccountSyncEnable errcode parameter is %{public}d", asyncContext->errCode); @@ -416,7 +416,7 @@ napi_value NapiAppAccount::CheckAppAccountSyncEnable(napi_env env, napi_callback }, [](napi_env env, napi_status status, void *data) { ACCOUNT_LOGI("CheckAppAccountSyncEnable, napi_create_async_work complete."); - AppAccountAsyncContext *asyncContext = (AppAccountAsyncContext *)data; + AppAccountAsyncContext *asyncContext = reinterpret_cast(data); napi_value checkResult[RESULT_COUNT] = {0}; checkResult[PARAMZERO] = GetErrorCodeValue(env, asyncContext->errCode); napi_get_boolean(env, asyncContext->result, &checkResult[PARAMONE]); @@ -425,7 +425,7 @@ napi_value NapiAppAccount::CheckAppAccountSyncEnable(napi_env env, napi_callback delete asyncContext; asyncContext = nullptr; }, - (void *)asyncContext, + reinterpret_cast(asyncContext), &asyncContext->work); napi_queue_async_work(env, asyncContext->work); return result; @@ -463,7 +463,7 @@ napi_value NapiAppAccount::SetAccountCredential(napi_env env, napi_callback_info resource, [](napi_env env, void *data) { ACCOUNT_LOGI("SetAccountCredential, napi_create_async_work running."); - AppAccountAsyncContext *asyncContext = (AppAccountAsyncContext *)data; + AppAccountAsyncContext *asyncContext = reinterpret_cast(data); asyncContext->errCode = AppAccountManager::SetAccountCredential( asyncContext->name, asyncContext->credentialType, asyncContext->credential); ACCOUNT_LOGI("SetAccountCredential errcode parameter is %{public}d", asyncContext->errCode); @@ -471,7 +471,7 @@ napi_value NapiAppAccount::SetAccountCredential(napi_env env, napi_callback_info }, [](napi_env env, napi_status status, void *data) { ACCOUNT_LOGI("SetAccountCredential, napi_create_async_work complete."); - AppAccountAsyncContext *asyncContext = (AppAccountAsyncContext *)data; + AppAccountAsyncContext *asyncContext = reinterpret_cast(data); napi_value setResult[RESULT_COUNT] = {0}; setResult[PARAMZERO] = GetErrorCodeValue(env, asyncContext->errCode); napi_get_undefined(env, &setResult[PARAMONE]); @@ -480,7 +480,7 @@ napi_value NapiAppAccount::SetAccountCredential(napi_env env, napi_callback_info delete asyncContext; asyncContext = nullptr; }, - (void *)asyncContext, + reinterpret_cast(asyncContext), &asyncContext->work); napi_queue_async_work(env, asyncContext->work); return result; @@ -518,7 +518,7 @@ napi_value NapiAppAccount::SetAccountExtraInfo(napi_env env, napi_callback_info resource, [](napi_env env, void *data) { ACCOUNT_LOGI("SetAccountExtraInfo, napi_create_async_work running."); - AppAccountAsyncContext *asyncContext = (AppAccountAsyncContext *)data; + AppAccountAsyncContext *asyncContext = reinterpret_cast(data); asyncContext->errCode = AppAccountManager::SetAccountExtraInfo( asyncContext->name, asyncContext->extraInfo); ACCOUNT_LOGI("SetAccountExtraInfo errcode parameter is %{public}d", asyncContext->errCode); @@ -526,7 +526,7 @@ napi_value NapiAppAccount::SetAccountExtraInfo(napi_env env, napi_callback_info }, [](napi_env env, napi_status status, void *data) { ACCOUNT_LOGI("SetAccountExtraInfo, napi_create_async_work complete."); - AppAccountAsyncContext *asyncContext = (AppAccountAsyncContext *)data; + AppAccountAsyncContext *asyncContext = reinterpret_cast(data); napi_value setResult[RESULT_COUNT] = {0}; setResult[PARAMZERO] = GetErrorCodeValue(env, asyncContext->errCode); napi_get_undefined(env, &setResult[PARAMONE]); @@ -535,7 +535,7 @@ napi_value NapiAppAccount::SetAccountExtraInfo(napi_env env, napi_callback_info delete asyncContext; asyncContext = nullptr; }, - (void *)asyncContext, + reinterpret_cast(asyncContext), &asyncContext->work); napi_queue_async_work(env, asyncContext->work); return result; @@ -571,7 +571,7 @@ napi_value NapiAppAccount::SetAppAccountSyncEnable(napi_env env, napi_callback_i resource, [](napi_env env, void *data) { ACCOUNT_LOGI("SetAppAccountSyncEnable, napi_create_async_work running."); - AppAccountAsyncContext *asyncContext = (AppAccountAsyncContext *)data; + AppAccountAsyncContext *asyncContext = reinterpret_cast(data); asyncContext->errCode = AppAccountManager::SetAppAccountSyncEnable(asyncContext->name, asyncContext->isEnable); ACCOUNT_LOGI("SetAppAccountSyncEnable errcode parameter is %{public}d", asyncContext->errCode); @@ -579,7 +579,7 @@ napi_value NapiAppAccount::SetAppAccountSyncEnable(napi_env env, napi_callback_i }, [](napi_env env, napi_status status, void *data) { ACCOUNT_LOGI("SetAppAccountSyncEnable, napi_create_async_work complete."); - AppAccountAsyncContext *asyncContext = (AppAccountAsyncContext *)data; + AppAccountAsyncContext *asyncContext = reinterpret_cast(data); napi_value setResult[RESULT_COUNT] = {0}; setResult[PARAMZERO] = GetErrorCodeValue(env, asyncContext->errCode); napi_get_undefined(env, &setResult[PARAMONE]); @@ -588,7 +588,7 @@ napi_value NapiAppAccount::SetAppAccountSyncEnable(napi_env env, napi_callback_i delete asyncContext; asyncContext = nullptr; }, - (void *)asyncContext, + reinterpret_cast(asyncContext), &asyncContext->work); napi_queue_async_work(env, asyncContext->work); return result; @@ -624,7 +624,7 @@ napi_value NapiAppAccount::SetAssociatedData(napi_env env, napi_callback_info cb resource, [](napi_env env, void *data) { ACCOUNT_LOGI("SetAssociatedData, napi_create_async_work running."); - AppAccountAsyncContext *asyncContext = (AppAccountAsyncContext *)data; + AppAccountAsyncContext *asyncContext = reinterpret_cast(data); asyncContext->errCode = AppAccountManager::SetAssociatedData(asyncContext->name, asyncContext->key, asyncContext->value); ACCOUNT_LOGI("SetAssociatedData errcode parameter is %{public}d", asyncContext->errCode); @@ -632,7 +632,7 @@ napi_value NapiAppAccount::SetAssociatedData(napi_env env, napi_callback_info cb }, [](napi_env env, napi_status status, void *data) { ACCOUNT_LOGI("SetAssociatedData, napi_create_async_work complete."); - AppAccountAsyncContext *asyncContext = (AppAccountAsyncContext *)data; + AppAccountAsyncContext *asyncContext = reinterpret_cast(data); napi_value setResult[RESULT_COUNT] = {0}; setResult[PARAMZERO] = GetErrorCodeValue(env, asyncContext->errCode); napi_get_undefined(env, &setResult[PARAMONE]); @@ -641,7 +641,7 @@ napi_value NapiAppAccount::SetAssociatedData(napi_env env, napi_callback_info cb delete asyncContext; asyncContext = nullptr; }, - (void *)asyncContext, + reinterpret_cast(asyncContext), &asyncContext->work); napi_queue_async_work(env, asyncContext->work); return result; @@ -676,14 +676,14 @@ napi_value NapiAppAccount::GetAllAccessibleAccounts(napi_env env, napi_callback_ resource, [](napi_env env, void *data) { ACCOUNT_LOGI("GetAllAccessibleAccounts, napi_create_async_work running."); - GetAccountsAsyncContext *asyncContext = (GetAccountsAsyncContext *)data; + GetAccountsAsyncContext *asyncContext = reinterpret_cast(data); asyncContext->errCode = AppAccountManager::GetAllAccessibleAccounts(asyncContext->appAccounts); ACCOUNT_LOGI("GetAllAccessibleAccounts errcode parameter is %{public}d", asyncContext->errCode); asyncContext->status = asyncContext->errCode == 0 ? napi_ok : napi_generic_failure; }, [](napi_env env, napi_status status, void *data) { ACCOUNT_LOGI("GetAllAccessibleAccounts, napi_create_async_work complete."); - GetAccountsAsyncContext *asyncContext = (GetAccountsAsyncContext *)data; + GetAccountsAsyncContext *asyncContext = reinterpret_cast(data); napi_value getResult[RESULT_COUNT] = {0}; getResult[PARAMZERO] = GetErrorCodeValue(env, asyncContext->errCode); napi_create_array(env, &getResult[PARAMONE]); @@ -693,7 +693,7 @@ napi_value NapiAppAccount::GetAllAccessibleAccounts(napi_env env, napi_callback_ delete asyncContext; asyncContext = nullptr; }, - (void *)asyncContext, + reinterpret_cast(asyncContext), &asyncContext->work); napi_queue_async_work(env, asyncContext->work); return result; @@ -728,14 +728,14 @@ napi_value NapiAppAccount::GetAllAccounts(napi_env env, napi_callback_info cbInf resource, [](napi_env env, void *data) { ACCOUNT_LOGI("GetAllAccounts, napi_create_async_work running."); - GetAccountsAsyncContext *asyncContext = (GetAccountsAsyncContext *)data; + GetAccountsAsyncContext *asyncContext = reinterpret_cast(data); asyncContext->errCode = AppAccountManager::GetAllAccounts(asyncContext->owner, asyncContext->appAccounts); ACCOUNT_LOGI("GetAllAccounts errcode parameter is %{public}d", asyncContext->errCode); asyncContext->status = asyncContext->errCode == 0 ? napi_ok : napi_generic_failure; }, [](napi_env env, napi_status status, void *data) { ACCOUNT_LOGI("GetAllAccounts, napi_create_async_work complete."); - GetAccountsAsyncContext *asyncContext = (GetAccountsAsyncContext *)data; + GetAccountsAsyncContext *asyncContext = reinterpret_cast(data); napi_value getResult[RESULT_COUNT] = {0}; getResult[PARAMZERO] = GetErrorCodeValue(env, asyncContext->errCode); napi_create_array(env, &getResult[PARAMONE]); @@ -745,7 +745,7 @@ napi_value NapiAppAccount::GetAllAccounts(napi_env env, napi_callback_info cbInf delete asyncContext; asyncContext = nullptr; }, - (void *)asyncContext, + reinterpret_cast(asyncContext), &asyncContext->work); napi_queue_async_work(env, asyncContext->work); return result; @@ -783,7 +783,7 @@ napi_value NapiAppAccount::GetAccountCredential(napi_env env, napi_callback_info resource, [](napi_env env, void *data) { ACCOUNT_LOGI("GetAccountCredential, napi_create_async_work running."); - AppAccountAsyncContext *asyncContext = (AppAccountAsyncContext *)data; + AppAccountAsyncContext *asyncContext = reinterpret_cast(data); asyncContext->errCode = AppAccountManager::GetAccountCredential( asyncContext->name, asyncContext->credentialType, asyncContext->credential); ACCOUNT_LOGI("GetAccountCredential errcode parameter is %{public}d", asyncContext->errCode); @@ -791,7 +791,7 @@ napi_value NapiAppAccount::GetAccountCredential(napi_env env, napi_callback_info }, [](napi_env env, napi_status status, void *data) { ACCOUNT_LOGI("GetAccountCredential, napi_create_async_work complete."); - AppAccountAsyncContext *asyncContext = (AppAccountAsyncContext *)data; + AppAccountAsyncContext *asyncContext = reinterpret_cast(data); napi_value getResult[RESULT_COUNT] = {0}; getResult[PARAMZERO] = GetErrorCodeValue(env, asyncContext->errCode); napi_create_string_utf8(env, asyncContext->credential.c_str(), NAPI_AUTO_LENGTH, &getResult[PARAMONE]); @@ -800,7 +800,7 @@ napi_value NapiAppAccount::GetAccountCredential(napi_env env, napi_callback_info delete asyncContext; asyncContext = nullptr; }, - (void *)asyncContext, + reinterpret_cast(asyncContext), &asyncContext->work); napi_queue_async_work(env, asyncContext->work); return result; @@ -836,14 +836,14 @@ napi_value NapiAppAccount::GetAccountExtraInfo(napi_env env, napi_callback_info resource, [](napi_env env, void *data) { ACCOUNT_LOGI("GetAccountExtraInfo, napi_create_async_work running."); - AppAccountAsyncContext *asyncContext = (AppAccountAsyncContext *)data; + AppAccountAsyncContext *asyncContext = reinterpret_cast(data); asyncContext->errCode = AppAccountManager::GetAccountExtraInfo(asyncContext->name, asyncContext->extraInfo); ACCOUNT_LOGI("GetAccountExtraInfo errcode parameter is %{public}d", asyncContext->errCode); asyncContext->status = asyncContext->errCode == 0 ? napi_ok : napi_generic_failure; }, [](napi_env env, napi_status status, void *data) { ACCOUNT_LOGI("GetAccountExtraInfo, napi_create_async_work complete."); - AppAccountAsyncContext *asyncContext = (AppAccountAsyncContext *)data; + AppAccountAsyncContext *asyncContext = reinterpret_cast(data); napi_value getResult[RESULT_COUNT] = {0}; getResult[PARAMZERO] = GetErrorCodeValue(env, asyncContext->errCode); napi_create_string_utf8(env, asyncContext->extraInfo.c_str(), NAPI_AUTO_LENGTH, &getResult[PARAMONE]); @@ -852,7 +852,7 @@ napi_value NapiAppAccount::GetAccountExtraInfo(napi_env env, napi_callback_info delete asyncContext; asyncContext = nullptr; }, - (void *)asyncContext, + reinterpret_cast(asyncContext), &asyncContext->work); napi_queue_async_work(env, asyncContext->work); return result; @@ -888,7 +888,7 @@ napi_value NapiAppAccount::GetAssociatedData(napi_env env, napi_callback_info cb resource, [](napi_env env, void *data) { ACCOUNT_LOGI("GetAssociatedData, napi_create_async_work running."); - AppAccountAsyncContext *asyncContext = (AppAccountAsyncContext *)data; + AppAccountAsyncContext *asyncContext = reinterpret_cast(data); asyncContext->errCode = AppAccountManager::GetAssociatedData(asyncContext->name, asyncContext->key, asyncContext->value); ACCOUNT_LOGI("GetAssociatedData errcode parameter is %{public}d", asyncContext->errCode); @@ -896,7 +896,7 @@ napi_value NapiAppAccount::GetAssociatedData(napi_env env, napi_callback_info cb }, [](napi_env env, napi_status status, void *data) { ACCOUNT_LOGI("GetAssociatedData, napi_create_async_work complete."); - AppAccountAsyncContext *asyncContext = (AppAccountAsyncContext *)data; + AppAccountAsyncContext *asyncContext = reinterpret_cast(data); napi_value getResult[RESULT_COUNT] = {0}; getResult[PARAMZERO] = GetErrorCodeValue(env, asyncContext->errCode); napi_create_string_utf8(env, asyncContext->value.c_str(), NAPI_AUTO_LENGTH, &getResult[PARAMONE]); @@ -905,7 +905,7 @@ napi_value NapiAppAccount::GetAssociatedData(napi_env env, napi_callback_info cb delete asyncContext; asyncContext = nullptr; }, - (void *)asyncContext, + reinterpret_cast(asyncContext), &asyncContext->work); napi_queue_async_work(env, asyncContext->work); return result; @@ -937,7 +937,7 @@ napi_value NapiAppAccount::Authenticate(napi_env env, napi_callback_info cbInfo) resourceName, [](napi_env env, void *data) { ACCOUNT_LOGI("Authenticate, napi_create_async_work running."); - OAuthAsyncContext *asyncContext = (OAuthAsyncContext *)data; + OAuthAsyncContext *asyncContext = reinterpret_cast(data); ErrCode errCode = AppAccountManager::Authenticate(asyncContext->name, asyncContext->owner, asyncContext->authType, asyncContext->options, asyncContext->appAccountMgrCb); asyncContext->errCode = ConvertToJSErrCode(errCode); @@ -945,7 +945,7 @@ napi_value NapiAppAccount::Authenticate(napi_env env, napi_callback_info cbInfo) }, [](napi_env env, napi_status status, void *data) { ACCOUNT_LOGI("Authenticate, napi_create_async_work complete."); - OAuthAsyncContext *asyncContext = (OAuthAsyncContext *)data; + OAuthAsyncContext *asyncContext = reinterpret_cast(data); AAFwk::Want errResult; if ((asyncContext->errCode != 0) && (asyncContext->appAccountMgrCb != nullptr)) { asyncContext->appAccountMgrCb->OnResult(asyncContext->errCode, errResult); @@ -954,7 +954,7 @@ napi_value NapiAppAccount::Authenticate(napi_env env, napi_callback_info cbInfo) delete asyncContext; asyncContext = nullptr; }, - (void *)asyncContext, + reinterpret_cast(asyncContext), &asyncContext->work)); NAPI_CALL(env, napi_queue_async_work(env, asyncContext->work)); return NapiGetNull(env); @@ -987,7 +987,7 @@ napi_value NapiAppAccount::GetOAuthToken(napi_env env, napi_callback_info cbInfo resource, [](napi_env env, void *data) { ACCOUNT_LOGI("GetOAuthToken, napi_create_async_work running."); - OAuthAsyncContext *asyncContext = (OAuthAsyncContext *)data; + OAuthAsyncContext *asyncContext = reinterpret_cast(data); ErrCode errCode = AppAccountManager::GetOAuthToken( asyncContext->name, asyncContext->owner, asyncContext->authType, asyncContext->token); asyncContext->errCode = ConvertToJSErrCode(errCode); @@ -996,7 +996,7 @@ napi_value NapiAppAccount::GetOAuthToken(napi_env env, napi_callback_info cbInfo }, [](napi_env env, napi_status status, void *data) { ACCOUNT_LOGI("GetOAuthToken, napi_create_async_work complete."); - OAuthAsyncContext *asyncContext = (OAuthAsyncContext *)data; + OAuthAsyncContext *asyncContext = reinterpret_cast(data); napi_value getResult[RESULT_COUNT] = {0}; getResult[PARAMZERO] = GetErrorCodeValue(env, asyncContext->errCode); napi_create_string_utf8(env, asyncContext->token.c_str(), NAPI_AUTO_LENGTH, &getResult[PARAMONE]); @@ -1005,7 +1005,7 @@ napi_value NapiAppAccount::GetOAuthToken(napi_env env, napi_callback_info cbInfo delete asyncContext; asyncContext = nullptr; }, - (void *)asyncContext, + reinterpret_cast(asyncContext), &asyncContext->work); napi_queue_async_work(env, asyncContext->work); return result; @@ -1037,7 +1037,7 @@ napi_value NapiAppAccount::SetOAuthToken(napi_env env, napi_callback_info cbInfo resource, [](napi_env env, void *data) { ACCOUNT_LOGI("SetOAuthToken, napi_create_async_work running."); - OAuthAsyncContext *asyncContext = (OAuthAsyncContext *)data; + OAuthAsyncContext *asyncContext = reinterpret_cast(data); ErrCode errCode = AppAccountManager::SetOAuthToken( asyncContext->name, asyncContext->authType, asyncContext->token); asyncContext->errCode = ConvertToJSErrCode(errCode); @@ -1046,7 +1046,7 @@ napi_value NapiAppAccount::SetOAuthToken(napi_env env, napi_callback_info cbInfo }, [](napi_env env, napi_status status, void *data) { ACCOUNT_LOGI("SetOAuthToken, napi_create_async_work complete."); - OAuthAsyncContext *asyncContext = (OAuthAsyncContext *)data; + OAuthAsyncContext *asyncContext = reinterpret_cast(data); napi_value setResult[RESULT_COUNT] = {0}; setResult[PARAMZERO] = GetErrorCodeValue(env, asyncContext->errCode); napi_get_undefined(env, &setResult[PARAMONE]); @@ -1055,7 +1055,7 @@ napi_value NapiAppAccount::SetOAuthToken(napi_env env, napi_callback_info cbInfo delete asyncContext; asyncContext = nullptr; }, - (void *)asyncContext, + reinterpret_cast(asyncContext), &asyncContext->work); napi_queue_async_work(env, asyncContext->work); return result; @@ -1088,7 +1088,7 @@ napi_value NapiAppAccount::DeleteOAuthToken(napi_env env, napi_callback_info cbI resource, [](napi_env env, void *data) { ACCOUNT_LOGI("DeleteOAuthToken, napi_create_async_work running."); - OAuthAsyncContext *asyncContext = (OAuthAsyncContext *)data; + OAuthAsyncContext *asyncContext = reinterpret_cast(data); ErrCode errCode = AppAccountManager::DeleteOAuthToken( asyncContext->name, asyncContext->owner, asyncContext->authType, asyncContext->token); asyncContext->errCode = ConvertToJSErrCode(errCode); @@ -1097,7 +1097,7 @@ napi_value NapiAppAccount::DeleteOAuthToken(napi_env env, napi_callback_info cbI }, [](napi_env env, napi_status status, void *data) { ACCOUNT_LOGI("DeleteOAuthToken, napi_create_async_work complete."); - OAuthAsyncContext *asyncContext = (OAuthAsyncContext *)data; + OAuthAsyncContext *asyncContext = reinterpret_cast(data); napi_value delResult[RESULT_COUNT] = {0}; delResult[PARAMZERO] = GetErrorCodeValue(env, asyncContext->errCode); napi_get_undefined(env, &delResult[PARAMONE]); @@ -1106,7 +1106,7 @@ napi_value NapiAppAccount::DeleteOAuthToken(napi_env env, napi_callback_info cbI delete asyncContext; asyncContext = nullptr; }, - (void *)asyncContext, + reinterpret_cast(asyncContext), &asyncContext->work)); NAPI_CALL(env, napi_queue_async_work(env, asyncContext->work)); return result; @@ -1139,7 +1139,7 @@ napi_value NapiAppAccount::SetOAuthTokenVisibility(napi_env env, napi_callback_i resource, [](napi_env env, void *data) { ACCOUNT_LOGI("DisableOAuthTokenAccess, napi_create_async_work running."); - OAuthAsyncContext *asyncContext = (OAuthAsyncContext *)data; + OAuthAsyncContext *asyncContext = reinterpret_cast(data); ErrCode errCode = AppAccountManager::SetOAuthTokenVisibility( asyncContext->name, asyncContext->authType, asyncContext->bundleName, asyncContext->isVisible); asyncContext->errCode = ConvertToJSErrCode(errCode); @@ -1148,7 +1148,7 @@ napi_value NapiAppAccount::SetOAuthTokenVisibility(napi_env env, napi_callback_i }, [](napi_env env, napi_status status, void *data) { ACCOUNT_LOGI("DisableOAuthTokenAccess, napi_create_async_work complete."); - OAuthAsyncContext *asyncContext = (OAuthAsyncContext *)data; + OAuthAsyncContext *asyncContext = reinterpret_cast(data); napi_value setResult[RESULT_COUNT] = {0}; setResult[PARAMZERO] = GetErrorCodeValue(env, asyncContext->errCode); napi_get_boolean(env, asyncContext->isVisible, &setResult[PARAMONE]); @@ -1157,7 +1157,7 @@ napi_value NapiAppAccount::SetOAuthTokenVisibility(napi_env env, napi_callback_i delete asyncContext; asyncContext = nullptr; }, - (void *)asyncContext, + reinterpret_cast(asyncContext), &asyncContext->work)); NAPI_CALL(env, napi_queue_async_work(env, asyncContext->work)); return result; @@ -1190,7 +1190,7 @@ napi_value NapiAppAccount::CheckOAuthTokenVisibility(napi_env env, napi_callback resource, [](napi_env env, void *data) { ACCOUNT_LOGI("CheckOAuthTokenVisibility, napi_create_async_work running."); - OAuthAsyncContext *asyncContext = (OAuthAsyncContext *)data; + OAuthAsyncContext *asyncContext = reinterpret_cast(data); ErrCode errCode = AppAccountManager::CheckOAuthTokenVisibility( asyncContext->name, asyncContext->authType, asyncContext->bundleName, asyncContext->isVisible); asyncContext->errCode = ConvertToJSErrCode(errCode); @@ -1199,7 +1199,7 @@ napi_value NapiAppAccount::CheckOAuthTokenVisibility(napi_env env, napi_callback }, [](napi_env env, napi_status status, void *data) { ACCOUNT_LOGI("CheckOAuthTokenVisibility, napi_create_async_work complete."); - OAuthAsyncContext *asyncContext = (OAuthAsyncContext *)data; + OAuthAsyncContext *asyncContext = reinterpret_cast(data); napi_value checkResult[RESULT_COUNT] = {0}; checkResult[PARAMZERO] = GetErrorCodeValue(env, asyncContext->errCode); napi_get_boolean(env, asyncContext->isVisible, &checkResult[PARAMONE]); @@ -1208,7 +1208,7 @@ napi_value NapiAppAccount::CheckOAuthTokenVisibility(napi_env env, napi_callback delete asyncContext; asyncContext = nullptr; }, - (void *)asyncContext, + reinterpret_cast(asyncContext), &asyncContext->work)); NAPI_CALL(env, napi_queue_async_work(env, asyncContext->work)); return result; @@ -1241,7 +1241,7 @@ napi_value NapiAppAccount::GetAuthenticatorInfo(napi_env env, napi_callback_info resource, [](napi_env env, void *data) { ACCOUNT_LOGI("GetAuthenticatorInfo, napi_create_async_work running."); - OAuthAsyncContext *asyncContext = (OAuthAsyncContext *)data; + OAuthAsyncContext *asyncContext = reinterpret_cast(data); ErrCode errCode = AppAccountManager::GetAuthenticatorInfo( asyncContext->owner, asyncContext->authenticatorInfo); asyncContext->errCode = ConvertToJSErrCode(errCode); @@ -1250,7 +1250,7 @@ napi_value NapiAppAccount::GetAuthenticatorInfo(napi_env env, napi_callback_info }, [](napi_env env, napi_status status, void *data) { ACCOUNT_LOGI("GetAuthenticatorInfo, napi_create_async_work complete."); - OAuthAsyncContext *asyncContext = (OAuthAsyncContext *)data; + OAuthAsyncContext *asyncContext = reinterpret_cast(data); napi_value getResult[RESULT_COUNT] = {0}; getResult[PARAMZERO] = GetErrorCodeValue(env, asyncContext->errCode); napi_create_object(env, &getResult[PARAMONE]); @@ -1260,7 +1260,7 @@ napi_value NapiAppAccount::GetAuthenticatorInfo(napi_env env, napi_callback_info delete asyncContext; asyncContext = nullptr; }, - (void *)asyncContext, + reinterpret_cast(asyncContext), &asyncContext->work)); NAPI_CALL(env, napi_queue_async_work(env, asyncContext->work)); return result; @@ -1293,7 +1293,7 @@ napi_value NapiAppAccount::GetAllOAuthTokens(napi_env env, napi_callback_info cb resource, [](napi_env env, void *data) { ACCOUNT_LOGI("GetAllOAuthTokens, napi_create_async_work running."); - OAuthAsyncContext *asyncContext = (OAuthAsyncContext *)data; + OAuthAsyncContext *asyncContext = reinterpret_cast(data); ErrCode errCode = AppAccountManager::GetAllOAuthTokens( asyncContext->name, asyncContext->owner, asyncContext->oauthTokenInfos); asyncContext->errCode = ConvertToJSErrCode(errCode); @@ -1302,7 +1302,7 @@ napi_value NapiAppAccount::GetAllOAuthTokens(napi_env env, napi_callback_info cb }, [](napi_env env, napi_status status, void *data) { ACCOUNT_LOGI("GetAllOAuthTokens, napi_create_async_work complete."); - OAuthAsyncContext *asyncContext = (OAuthAsyncContext *)data; + OAuthAsyncContext *asyncContext = reinterpret_cast(data); napi_value getResult[RESULT_COUNT] = {0}; getResult[PARAMZERO] = GetErrorCodeValue(env, asyncContext->errCode); napi_create_array(env, &getResult[PARAMONE]); @@ -1312,7 +1312,7 @@ napi_value NapiAppAccount::GetAllOAuthTokens(napi_env env, napi_callback_info cb delete asyncContext; asyncContext = nullptr; }, - (void *)asyncContext, + reinterpret_cast(asyncContext), &asyncContext->work)); NAPI_CALL(env, napi_queue_async_work(env, asyncContext->work)); return result; @@ -1345,7 +1345,7 @@ napi_value NapiAppAccount::GetOAuthList(napi_env env, napi_callback_info cbInfo) resource, [](napi_env env, void *data) { ACCOUNT_LOGI("GetOAuthList, napi_create_async_work running."); - OAuthAsyncContext *asyncContext = (OAuthAsyncContext *)data; + OAuthAsyncContext *asyncContext = reinterpret_cast(data); ErrCode errCode = AppAccountManager::GetOAuthList( asyncContext->name, asyncContext->authType, asyncContext->authList); asyncContext->errCode = ConvertToJSErrCode(errCode); @@ -1354,7 +1354,7 @@ napi_value NapiAppAccount::GetOAuthList(napi_env env, napi_callback_info cbInfo) }, [](napi_env env, napi_status status, void *data) { ACCOUNT_LOGI("GetOAuthList, napi_create_async_work complete."); - OAuthAsyncContext *asyncContext = (OAuthAsyncContext *)data; + OAuthAsyncContext *asyncContext = reinterpret_cast(data); napi_value getResult[RESULT_COUNT] = {0}; getResult[PARAMZERO] = GetErrorCodeValue(env, asyncContext->errCode); napi_create_array(env, &getResult[PARAMONE]); @@ -1364,7 +1364,7 @@ napi_value NapiAppAccount::GetOAuthList(napi_env env, napi_callback_info cbInfo) delete asyncContext; asyncContext = nullptr; }, - (void *)asyncContext, + reinterpret_cast(asyncContext), &asyncContext->work)); NAPI_CALL(env, napi_queue_async_work(env, asyncContext->work)); return result; @@ -1396,7 +1396,7 @@ napi_value NapiAppAccount::GetAuthenticatorCallback(napi_env env, napi_callback_ nullptr, resource, [](napi_env env, void *data) { - OAuthAsyncContext *asyncContext = (OAuthAsyncContext *)data; + OAuthAsyncContext *asyncContext = reinterpret_cast(data); ErrCode errCode = AppAccountManager::GetAuthenticatorCallback( asyncContext->sessionId, asyncContext->authenticatorCb); asyncContext->errCode = ConvertToJSErrCode(errCode); @@ -1405,7 +1405,7 @@ napi_value NapiAppAccount::GetAuthenticatorCallback(napi_env env, napi_callback_ }, [](napi_env env, napi_status status, void *data) { ACCOUNT_LOGI("GetAuthenticatorCallback, napi_create_async_work complete."); - OAuthAsyncContext *asyncContext = (OAuthAsyncContext *)data; + OAuthAsyncContext *asyncContext = reinterpret_cast(data); napi_value getResult[RESULT_COUNT] = {0}; getResult[PARAMZERO] = GetErrorCodeValue(env, asyncContext->errCode); GetAuthenticatorCallbackForResult(env, asyncContext->authenticatorCb, &getResult[PARAMONE]); @@ -1414,7 +1414,7 @@ napi_value NapiAppAccount::GetAuthenticatorCallback(napi_env env, napi_callback_ delete asyncContext; asyncContext = nullptr; }, - (void *)asyncContext, + reinterpret_cast(asyncContext), &asyncContext->work)); NAPI_CALL(env, napi_queue_async_work(env, asyncContext->work)); return result; @@ -1455,7 +1455,7 @@ napi_value NapiAppAccount::Subscribe(napi_env env, napi_callback_info cbInfo) } asyncContextForOn->callbackRef = callback; AppAccountManager *objectInfo = nullptr; - napi_unwrap(env, thisVar, (void **)&objectInfo); + napi_unwrap(env, thisVar, reinterpret_cast(&objectInfo)); asyncContextForOn->appAccountManager = objectInfo; { @@ -1472,10 +1472,10 @@ napi_value NapiAppAccount::Subscribe(napi_env env, napi_callback_info cbInfo) SubscribeExecuteCB, [](napi_env env, napi_status status, void *data) { ACCOUNT_LOGI("Subscribe, napi_create_async_work complete."); - AsyncContextForSubscribe *asyncContextForOn = (AsyncContextForSubscribe *)data; + AsyncContextForSubscribe *asyncContextForOn = reinterpret_cast(data); napi_delete_async_work(env, asyncContextForOn->work); }, - (void *)asyncContextForOn, + reinterpret_cast(asyncContextForOn), &asyncContextForOn->work); napi_queue_async_work(env, asyncContextForOn->work); return NapiGetNull(env); @@ -1505,7 +1505,7 @@ napi_value NapiAppAccount::Unsubscribe(napi_env env, napi_callback_info cbInfo) asyncContextForOff->callbackRef = nullptr; AppAccountManager *objectInfo = nullptr; - napi_unwrap(env, thisVar, (void **)&objectInfo); + napi_unwrap(env, thisVar, reinterpret_cast(&objectInfo)); asyncContextForOff->appAccountManager = objectInfo; asyncContextForOff->callbackRef = callback; @@ -1526,7 +1526,7 @@ napi_value NapiAppAccount::Unsubscribe(napi_env env, napi_callback_info cbInfo) resourceName, UnsubscribeExecuteCB, UnsubscribeCallbackCompletedCB, - (void *)asyncContextForOff, + reinterpret_cast(asyncContextForOff), &asyncContextForOff->work); napi_queue_async_work(env, asyncContextForOff->work); return NapiGetNull(env); diff --git a/interfaces/kits/napi/appaccount/src/napi_app_account_authenticator.cpp b/interfaces/kits/napi/appaccount/src/napi_app_account_authenticator.cpp index 4aec44918..9ea611d43 100644 --- a/interfaces/kits/napi/appaccount/src/napi_app_account_authenticator.cpp +++ b/interfaces/kits/napi/appaccount/src/napi_app_account_authenticator.cpp @@ -186,7 +186,7 @@ void UvQueueWorkCallJsFunction(uv_work_t *work, int status) if (param->funcName == Constants::OAUTH_ACTION_ADD_ACCOUNT_IMPLICITLY) { napi_get_reference_value(param->env, param->addAccountImplicitlyRef, &jsFunction); ret = napi_call_function(param->env, undefined, jsFunction, ARGS_SIZE_FOUR, &argv2[1], &returnVal); - } else if (param->funcName == Constants::OAUTH_ACTION_AUTHENTICATE) { + } else { napi_get_reference_value(param->env, param->authenticateRef, &jsFunction); ret = napi_call_function(param->env, undefined, jsFunction, ARGS_SIZE_FIVE, argv2, &returnVal); } @@ -200,8 +200,8 @@ void UvQueueWorkCallJsFunction(uv_work_t *work, int status) ErrCode NapiAppAccountAuthenticator::CallJsFunction(AuthParam *param) { ACCOUNT_LOGI("Enter"); - if (param == nullptr) { - ACCOUNT_LOGE("param is nullptr!"); + if ((param == nullptr) || (param->lockInfo == nullptr)) { + ACCOUNT_LOGE("param or lockInfo is nullptr!"); return ERR_ACCOUNT_COMMON_INSUFFICIENT_MEMORY_ERROR; } uv_loop_s *loop = nullptr; diff --git a/interfaces/kits/napi/appaccount/src/napi_app_account_authenticator_callback.cpp b/interfaces/kits/napi/appaccount/src/napi_app_account_authenticator_callback.cpp index b57395a1b..ec4b2e26e 100644 --- a/interfaces/kits/napi/appaccount/src/napi_app_account_authenticator_callback.cpp +++ b/interfaces/kits/napi/appaccount/src/napi_app_account_authenticator_callback.cpp @@ -71,7 +71,7 @@ static void ParseContextForOnResult(napi_env env, napi_callback_info cbInfo, Cal napi_value argv[ARGS_SIZE_FOUR] = {0}; napi_value thisVar = nullptr; napi_get_cb_info(env, cbInfo, &argc, argv, &thisVar, nullptr); - napi_unwrap(env, thisVar, (void **)&(param->callback)); + napi_unwrap(env, thisVar, reinterpret_cast(&(param->callback))); for (size_t i = 0; i < argc; ++i) { napi_valuetype valueType = napi_undefined; napi_typeof(env, argv[i], &valueType); @@ -95,7 +95,7 @@ static void ParseContextForRequestRedirected(napi_env env, napi_callback_info cb napi_value argv[ARGS_SIZE_ONE] = {0}; napi_value thisVar = nullptr; napi_get_cb_info(env, cbInfo, &argc, argv, &thisVar, nullptr); - napi_unwrap(env, thisVar, (void **)&(param->callback)); + napi_unwrap(env, thisVar, reinterpret_cast(&(param->callback))); napi_valuetype valueType = napi_undefined; napi_typeof(env, argv[0], &valueType); if (valueType == napi_object) { @@ -127,7 +127,11 @@ napi_value NapiAppAccountAuthenticatorCallback::JsOnResult(napi_env env, napi_ca resourceName, [](napi_env env, void *data) { ACCOUNT_LOGI("JsOnResult, napi_create_async_work running."); - CallbackParam *param = (CallbackParam *)data; + CallbackParam *param = reinterpret_cast(data); + if ((param == nullptr) || (param->callback == nullptr)) { + ACCOUNT_LOGE("invalid parameters"); + return; + } auto callbackProxy = iface_cast(param->callback->GetRemoteObject()); if ((callbackProxy != nullptr) && (callbackProxy->AsObject() != nullptr)) { AAFwk::Want result; @@ -137,12 +141,12 @@ napi_value NapiAppAccountAuthenticatorCallback::JsOnResult(napi_env env, napi_ca }, [](napi_env env, napi_status status, void *data) { ACCOUNT_LOGI("JsOnResult, napi_create_async_work complete."); - CallbackParam *param = (CallbackParam *)data; + CallbackParam *param = reinterpret_cast(data); napi_delete_async_work(env, param->work); delete param; param = nullptr; }, - (void *)param, + reinterpret_cast(param), ¶m->work)); NAPI_CALL(env, napi_queue_async_work(env, param->work)); return NapiGetNull(env); @@ -168,7 +172,11 @@ napi_value NapiAppAccountAuthenticatorCallback::JsOnRequestRedirected(napi_env e resourceName, [](napi_env env, void *data) { ACCOUNT_LOGI("JsOnRequestRedirected, napi_create_async_work running."); - CallbackParam *param = (CallbackParam *)data; + CallbackParam *param = reinterpret_cast(data); + if ((param == nullptr) || (param->callback == nullptr)) { + ACCOUNT_LOGE("invalid parameters"); + return; + } auto callbackProxy = iface_cast(param->callback->GetRemoteObject()); if ((callbackProxy != nullptr) && (callbackProxy->AsObject() != nullptr)) { callbackProxy->OnRequestRedirected(param->request); @@ -176,12 +184,12 @@ napi_value NapiAppAccountAuthenticatorCallback::JsOnRequestRedirected(napi_env e }, [](napi_env env, napi_status status, void *data) { ACCOUNT_LOGI("JsOnRequestRedirected, napi_create_async_work complete."); - CallbackParam *param = (CallbackParam *)data; + CallbackParam *param = reinterpret_cast(data); napi_delete_async_work(env, param->work); delete param; param = nullptr; }, - (void *)param, + reinterpret_cast(param), ¶m->work)); NAPI_CALL(env, napi_queue_async_work(env, param->work)); return NapiGetNull(env); @@ -217,5 +225,5 @@ napi_value NapiAppAccountAuthenticatorCallback::JsConstructor(napi_env env, napi NAPI_ASSERT(env, status == napi_ok, "wrap js AuthenticatorStub and native callback failed"); return thisVar; } -} // namespace AccountSA +} // namespace AccountJsKit } // namespace OHOS diff --git a/interfaces/kits/napi/appaccount/src/napi_app_account_common.cpp b/interfaces/kits/napi/appaccount/src/napi_app_account_common.cpp index df66dceaa..80ea568fd 100644 --- a/interfaces/kits/napi/appaccount/src/napi_app_account_common.cpp +++ b/interfaces/kits/napi/appaccount/src/napi_app_account_common.cpp @@ -39,7 +39,7 @@ void UvQueueWorkOnAppAccountsChanged(uv_work_t *work, int status) if (work == nullptr || work->data == nullptr) { return; } - SubscriberAccountsWorker *subscriberAccountsWorkerData = (SubscriberAccountsWorker *)work->data; + SubscriberAccountsWorker *subscriberAccountsWorkerData = reinterpret_cast(work->data); uint32_t index = 0; napi_value results[ARGS_SIZE_ONE] = {nullptr}; napi_create_array(subscriberAccountsWorkerData->env, &results[0]); @@ -84,9 +84,6 @@ void SubscriberPtr::OnAccountsChanged(const std::vector &account { ACCOUNT_LOGI("enter"); - ErrCode result; - std::string owner; - std::string name; uv_loop_s *loop = nullptr; napi_get_uv_event_loop(env_, &loop); if (loop == nullptr) { @@ -106,21 +103,13 @@ void SubscriberPtr::OnAccountsChanged(const std::vector &account return; } - for (auto account : accounts_) { - result = account.GetOwner(owner); - ACCOUNT_LOGI("owner = %{public}s", owner.c_str()); - - result = account.GetName(name); - ACCOUNT_LOGI("name = %{public}s", name.c_str()); - } - subscriberAccountsWorker->accounts = accounts_; subscriberAccountsWorker->env = env_; subscriberAccountsWorker->ref = ref_; ACCOUNT_LOGI("subscriberAccountsWorker->ref == %{public}p", subscriberAccountsWorker->ref); - work->data = (void *)subscriberAccountsWorker; + work->data = reinterpret_cast(subscriberAccountsWorker); uv_queue_work(loop, work, [](uv_work_t *work) {}, UvQueueWorkOnAppAccountsChanged); @@ -153,7 +142,7 @@ void UvQueueWorkOnResult(uv_work_t *work, int status) ACCOUNT_LOGE("work or data is nullptr"); return; } - AuthenticatorCallbackParam *data = (AuthenticatorCallbackParam *)work->data; + AuthenticatorCallbackParam *data = reinterpret_cast(work->data); napi_value results[ARGS_SIZE_TWO] = {nullptr}; results[0] = GetErrorCodeValue(data->env, data->resultCode); results[ARGS_SIZE_ONE] = AppExecFwk::WrapWantParams(data->env, data->result); @@ -180,7 +169,7 @@ void UvQueueWorkOnRequestRedirected(uv_work_t *work, int status) ACCOUNT_LOGE("work or data is nullptr"); return; } - AuthenticatorCallbackParam *data = (AuthenticatorCallbackParam *)work->data; + AuthenticatorCallbackParam *data = reinterpret_cast(work->data); napi_value results[ARGS_SIZE_ONE] = {nullptr}; results[0] = AppExecFwk::WrapWant(data->env, data->request); napi_value undefined = nullptr; @@ -215,7 +204,7 @@ void AppAccountManagerCallback::OnResult(int32_t resultCode, const AAFwk::Want & .resultRef = resultRef_, .requestRedirectedRef = requestRedirectedRef_, }; - work->data = (void *)param; + work->data = reinterpret_cast(param); uv_queue_work(loop, work, [](uv_work_t *work) {}, UvQueueWorkOnResult); } @@ -239,7 +228,7 @@ void AppAccountManagerCallback::OnRequestRedirected(AAFwk::Want &request) .resultRef = resultRef_, .requestRedirectedRef = requestRedirectedRef_, }; - work->data = (void *)param; + work->data = reinterpret_cast(param); uv_queue_work(loop, work, [](uv_work_t *work) {}, UvQueueWorkOnRequestRedirected); } @@ -383,7 +372,7 @@ void GetAuthenticatorCallbackForResult(napi_env env, sptr callbac return; } napi_value remote; - napi_create_int64(env, reinterpret_cast((IRemoteObject *) callback), &remote); + napi_create_int64(env, reinterpret_cast((IRemoteObject *)callback), &remote); napi_value global = nullptr; napi_get_global(env, &global); if (global == nullptr) { @@ -450,7 +439,7 @@ void ParseContextForSetExInfo(napi_env env, napi_callback_info cbInfo, AppAccoun } } -void ParseArguments(napi_env env, napi_value *argv, const napi_valuetype *valueTypes, size_t &argc) +void ParseArguments(napi_env env, napi_value *argv, const napi_valuetype *valueTypes, size_t argc) { napi_valuetype valuetype = napi_undefined; for (size_t i = 0; i < argc; ++i) { @@ -489,7 +478,7 @@ void ParseContextForAuthenticate(napi_env env, napi_callback_info cbInfo, OAuthA napi_get_named_property(env, global, "ability", &abilityObj); if (abilityObj != nullptr) { AppExecFwk::Ability *ability = nullptr; - napi_get_value_external(env, abilityObj, (void **)&ability); + napi_get_value_external(env, abilityObj, reinterpret_cast(&ability)); auto abilityInfo = ability->GetAbilityInfo(); asyncContext->options.SetParam(Constants::KEY_CALLER_ABILITY_NAME, abilityInfo->name); } @@ -1000,7 +989,7 @@ napi_value ParseParametersByUnsubscribe( void SubscribeExecuteCB(napi_env env, void *data) { ACCOUNT_LOGI("Subscribe, napi_create_async_work running."); - AsyncContextForSubscribe *asyncContextForOn = (AsyncContextForSubscribe *)data; + AsyncContextForSubscribe *asyncContextForOn = reinterpret_cast(data); asyncContextForOn->subscriber->SetEnv(env); asyncContextForOn->subscriber->SetCallbackRef(asyncContextForOn->callbackRef); int errCode = AppAccountManager::SubscribeAppAccount(asyncContextForOn->subscriber); @@ -1010,7 +999,7 @@ void SubscribeExecuteCB(napi_env env, void *data) void UnsubscribeExecuteCB(napi_env env, void *data) { ACCOUNT_LOGI("Unsubscribe napi_create_async_work start."); - AsyncContextForUnsubscribe *asyncContextForOff = (AsyncContextForUnsubscribe *)data; + AsyncContextForUnsubscribe *asyncContextForOff = reinterpret_cast(data); for (auto offSubscriber : asyncContextForOff->subscribers) { int errCode = AppAccountManager::UnsubscribeAppAccount(offSubscriber); ACCOUNT_LOGI("Unsubscribe errcode parameter is %{public}d", errCode); @@ -1020,7 +1009,7 @@ void UnsubscribeExecuteCB(napi_env env, void *data) void UnsubscribeCallbackCompletedCB(napi_env env, napi_status status, void *data) { ACCOUNT_LOGI("Unsubscribe napi_create_async_work end."); - AsyncContextForUnsubscribe *asyncContextForOff = (AsyncContextForUnsubscribe *)data; + AsyncContextForUnsubscribe *asyncContextForOff = reinterpret_cast(data); if (asyncContextForOff == nullptr) { return; } diff --git a/interfaces/kits/napi/distributedaccount/BUILD.gn b/interfaces/kits/napi/distributedaccount/BUILD.gn old mode 100755 new mode 100644 index d82ebf3d0..621fd03b7 --- a/interfaces/kits/napi/distributedaccount/BUILD.gn +++ b/interfaces/kits/napi/distributedaccount/BUILD.gn @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Huawei Device Co., Ltd. +# Copyright (c) 2021-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/interfaces/kits/napi/distributedaccount/include/napi_distributed_account.h b/interfaces/kits/napi/distributedaccount/include/napi_distributed_account.h old mode 100755 new mode 100644 index caa22c063..ee4a1e191 --- a/interfaces/kits/napi/distributedaccount/include/napi_distributed_account.h +++ b/interfaces/kits/napi/distributedaccount/include/napi_distributed_account.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) 2021-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 @@ -13,8 +13,8 @@ * limitations under the License. */ -#ifndef NAPI_DISTRIBUTED_ACCOUNT_H -#define NAPI_DISTRIBUTED_ACCOUNT_H +#ifndef OS_ACCOUNT_INTERFACES_KITS_NAPI_DISTRIBUTEDACCOUNT_INCLUDE_NAPI_DISTRIBUTED_ACCOUNT_H +#define OS_ACCOUNT_INTERFACES_KITS_NAPI_DISTRIBUTEDACCOUNT_INCLUDE_NAPI_DISTRIBUTED_ACCOUNT_H #include "napi/native_api.h" @@ -34,4 +34,4 @@ private: } // namespace AccountJsKit } // namespace OHOS -#endif // NAPI_DISTRIBUTED_ACCOUNT_H +#endif // OS_ACCOUNT_INTERFACES_KITS_NAPI_DISTRIBUTEDACCOUNT_INCLUDE_NAPI_DISTRIBUTED_ACCOUNT_H diff --git a/interfaces/kits/napi/distributedaccount/src/napi_distributed_account.cpp b/interfaces/kits/napi/distributedaccount/src/napi_distributed_account.cpp index 45bbca3ab..b54fb6b83 100644 --- a/interfaces/kits/napi/distributedaccount/src/napi_distributed_account.cpp +++ b/interfaces/kits/napi/distributedaccount/src/napi_distributed_account.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) 2021-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 @@ -120,9 +120,9 @@ void ProcessSetNamedProperty(napi_env env, const DistributedAccountAsyncContext napi_set_named_property(env, result[1], PROPERTY_KEY_EVENT.c_str(), value); napi_value scalable = nullptr; napi_create_object(env, &scalable); - for (const auto &[key, value]:asyncContext->scalableData) { + for (const auto &[key, val]:asyncContext->scalableData) { napi_value jsValue = nullptr; - napi_create_string_utf8(env, value.c_str(), value.size(), &jsValue); + napi_create_string_utf8(env, val.c_str(), val.size(), &jsValue); napi_set_named_property(env, scalable, key.c_str(), jsValue); } napi_set_named_property(env, result[1], PROPERTY_KEY_SCALABLE.c_str(), scalable); @@ -205,7 +205,7 @@ napi_value NapiDistributedAccount::QueryOhosAccountInfo(napi_env env, napi_callb napi_create_async_work( env, nullptr, resource, [](napi_env env, void *data) { - DistributedAccountAsyncContext *asyncContext = (DistributedAccountAsyncContext*)data; + DistributedAccountAsyncContext *asyncContext = reinterpret_cast(data); std::pair accountInfo = OhosAccountKits::GetInstance().QueryOhosAccountInfo(); if (accountInfo.first) { asyncContext->name = accountInfo.second.name_; @@ -218,12 +218,12 @@ napi_value NapiDistributedAccount::QueryOhosAccountInfo(napi_env env, napi_callb } }, [](napi_env env, napi_status status, void *data) { - DistributedAccountAsyncContext *asyncContext = (DistributedAccountAsyncContext*)data; + DistributedAccountAsyncContext *asyncContext = reinterpret_cast(data); ProcessSetNamedProperty(env, asyncContext); napi_delete_async_work(env, asyncContext->work); delete asyncContext; }, - (void*)asyncContext, &asyncContext->work); + reinterpret_cast(asyncContext), &asyncContext->work); napi_queue_async_work(env, asyncContext->work); return result; @@ -254,12 +254,12 @@ napi_value NapiDistributedAccount::UpdateOsAccountDistributedInfo(napi_env env, napi_create_async_work( env, nullptr, resource, [](napi_env env, void *data) { - DistributedAccountAsyncContext *asyncContext = (DistributedAccountAsyncContext*)data; + DistributedAccountAsyncContext *asyncContext = reinterpret_cast(data); asyncContext->status = OhosAccountKits::GetInstance().UpdateOhosAccountInfo(asyncContext->name, asyncContext->id, asyncContext->event) ? napi_ok : napi_generic_failure; }, [](napi_env env, napi_status status, void *data) { - DistributedAccountAsyncContext *asyncContext = (DistributedAccountAsyncContext*)data; + DistributedAccountAsyncContext *asyncContext = reinterpret_cast(data); napi_value result[RESULT_COUNT] = {0}; if (asyncContext->status == napi_ok) { napi_get_undefined(env, &result[0]); @@ -274,7 +274,7 @@ napi_value NapiDistributedAccount::UpdateOsAccountDistributedInfo(napi_env env, napi_delete_async_work(env, asyncContext->work); delete asyncContext; }, - (void*)asyncContext, &asyncContext->work); + reinterpret_cast(asyncContext), &asyncContext->work); napi_queue_async_work(env, asyncContext->work); return result; diff --git a/interfaces/kits/napi/osaccount/include/napi_os_account.h b/interfaces/kits/napi/osaccount/include/napi_os_account.h index 52681801f..01e5e971d 100644 --- a/interfaces/kits/napi/osaccount/include/napi_os_account.h +++ b/interfaces/kits/napi/osaccount/include/napi_os_account.h @@ -13,8 +13,8 @@ * limitations under the License. */ -#ifndef NAPI_OS_ACCOUNT_H -#define NAPI_OS_ACCOUNT_H +#ifndef OS_ACCOUNT_INTERFACES_KITS_NAPI_OSACCOUNT_INCLUDE_NAPI_OS_ACCOUNT_H +#define OS_ACCOUNT_INTERFACES_KITS_NAPI_OSACCOUNT_INCLUDE_NAPI_OS_ACCOUNT_H #include #include @@ -36,10 +36,10 @@ static thread_local napi_ref osAccountRef_ = nullptr; class SubscriberPtr : public OsAccountSubscriber { public: - SubscriberPtr(const OsAccountSubscribeInfo &subscribeInfo); + explicit SubscriberPtr(const OsAccountSubscribeInfo &subscribeInfo); ~SubscriberPtr(); - virtual void OnAccountsChanged(const int &id) override; + void OnAccountsChanged(const int &id) override; void SetEnv(const napi_env &env); void SetCallbackRef(const napi_ref &ref); @@ -498,4 +498,5 @@ void UnsubscribeCallbackCompletedCB(napi_env env, napi_status status, void *data void SetEnumProperty(napi_env env, napi_value dstObj, const int objValue, const char *propName); } // namespace AccountJsKit } // namespace OHOS -#endif // NAPI_OS_ACCOUNT_H + +#endif // OS_ACCOUNT_INTERFACES_KITS_NAPI_OSACCOUNT_INCLUDE_NAPI_OS_ACCOUNT_H diff --git a/interfaces/kits/napi/osaccount/include/napi_os_account_common.h b/interfaces/kits/napi/osaccount/include/napi_os_account_common.h index 88338aa4f..04858f650 100644 --- a/interfaces/kits/napi/osaccount/include/napi_os_account_common.h +++ b/interfaces/kits/napi/osaccount/include/napi_os_account_common.h @@ -13,8 +13,8 @@ * limitations under the License. */ -#ifndef NAPI_OS_ACCOUNT_COMMON_H -#define NAPI_OS_ACCOUNT_COMMON_H +#ifndef OS_ACCOUNT_INTERFACES_KITS_NAPI_OSACCOUNT_INCLUDE_NAPI_OS_ACCOUNT_COMMON_H +#define OS_ACCOUNT_INTERFACES_KITS_NAPI_OSACCOUNT_INCLUDE_NAPI_OS_ACCOUNT_COMMON_H #include "account_info.h" #include "napi_os_account.h" @@ -23,8 +23,6 @@ namespace OHOS { namespace AccountJsKit { -#define PARAM0 0 -#define PARAM1 1 constexpr std::int32_t MAX_VALUE_LEN = 4096; constexpr std::int32_t MAX_SUBSCRIBER_NAME_LEN = 1024; constexpr const std::int32_t STR_MAX_SIZE = 256; @@ -284,4 +282,5 @@ napi_value ParseParaToUnsubscriber(const napi_env &env, const size_t &argc, cons napi_ref &callback, OS_ACCOUNT_SUBSCRIBE_TYPE &offType, std::string &offName); } // namespace AccountJsKit } // namespace OHOS -#endif // NAPI_OS_ACCOUNT_COMMON_H \ No newline at end of file + +#endif // OS_ACCOUNT_INTERFACES_KITS_NAPI_OSACCOUNT_INCLUDE_NAPI_OS_ACCOUNT_COMMON_H diff --git a/interfaces/kits/napi/osaccount/src/napi_os_account.cpp b/interfaces/kits/napi/osaccount/src/napi_os_account.cpp index 58a8e5bc9..e618e570f 100644 --- a/interfaces/kits/napi/osaccount/src/napi_os_account.cpp +++ b/interfaces/kits/napi/osaccount/src/napi_os_account.cpp @@ -169,7 +169,7 @@ napi_value QueryOsAccountById(napi_env env, napi_callback_info cbInfo) resource, QueryOAByIdExecuteCB, QueryOAByIdCallbackCompletedCB, - (void *)queryOAByIdCB, + reinterpret_cast(queryOAByIdCB), &queryOAByIdCB->work); napi_queue_async_work(env, queryOAByIdCB->work); @@ -205,8 +205,8 @@ napi_value RemoveOsAccount(napi_env env, napi_callback_info cbInfo) napi_value resource = nullptr; napi_create_string_utf8(env, "RemoveOsAccount", NAPI_AUTO_LENGTH, &resource); - napi_create_async_work( - env, nullptr, resource, RemoveOAExecuteCB, RemoveOACallbackCompletedCB, (void *)removeOACB, &removeOACB->work); + napi_create_async_work(env, nullptr, resource, RemoveOAExecuteCB, RemoveOACallbackCompletedCB, + reinterpret_cast(removeOACB), &removeOACB->work); napi_queue_async_work(env, removeOACB->work); return result; @@ -246,7 +246,7 @@ napi_value SetOsAccountName(napi_env env, napi_callback_info cbInfo) resource, SetOANameExecuteCB, SetOANameCallbackCompletedCB, - (void *)setOANameCB, + reinterpret_cast(setOANameCB), &setOANameCB->work); napi_queue_async_work(env, setOANameCB->work); @@ -287,7 +287,7 @@ napi_value SetOsAccountConstraints(napi_env env, napi_callback_info cbInfo) resource, SetOAConsExecuteCB, SetOAConsCallbackCompletedCB, - (void *)setOAConsCB, + reinterpret_cast(setOAConsCB), &setOAConsCB->work); napi_queue_async_work(env, setOAConsCB->work); @@ -328,7 +328,7 @@ napi_value ActivateOsAccount(napi_env env, napi_callback_info cbInfo) resource, ActivateOAExecuteCB, ActivateOACallbackCompletedCB, - (void *)activeOACB, + reinterpret_cast(activeOACB), &activeOACB->work); napi_queue_async_work(env, activeOACB->work); @@ -364,8 +364,8 @@ napi_value CreateOsAccount(napi_env env, napi_callback_info cbInfo) napi_value resource = nullptr; napi_create_string_utf8(env, "CreateOsAccount", NAPI_AUTO_LENGTH, &resource); - napi_create_async_work( - env, nullptr, resource, CreateOAExecuteCB, CreateOACallbackCompletedCB, (void *)createOACB, &createOACB->work); + napi_create_async_work(env, nullptr, resource, CreateOAExecuteCB, CreateOACallbackCompletedCB, + reinterpret_cast(createOACB), &createOACB->work); napi_queue_async_work(env, createOACB->work); return result; @@ -399,8 +399,8 @@ napi_value CreateOsAccountForDomain(napi_env env, napi_callback_info cbInfo) napi_value resource = nullptr; napi_create_string_utf8(env, "CreateOsAccountForDomain", NAPI_AUTO_LENGTH, &resource); - napi_create_async_work(env, nullptr, resource, CreateOAForDomainExecuteCB, - CreateOAForDomainCallbackCompletedCB, (void *)createOAForDomainCB, &createOAForDomainCB->work); + napi_create_async_work(env, nullptr, resource, CreateOAForDomainExecuteCB, CreateOAForDomainCallbackCompletedCB, + reinterpret_cast(createOAForDomainCB), &createOAForDomainCB->work); napi_queue_async_work(env, createOAForDomainCB->work); return result; @@ -436,7 +436,7 @@ napi_value GetCreatedOsAccountsCount(napi_env env, napi_callback_info cbInfo) resource, GetOACountExecuteCB, GetOACountCallbackCompletedCB, - (void *)getOACount, + reinterpret_cast(getOACount), &getOACount->work); napi_queue_async_work(env, getOACount->work); @@ -473,7 +473,7 @@ napi_value GetDistributedVirtualDeviceId(napi_env env, napi_callback_info cbInfo resource, DbDeviceIdExecuteCB, DbDeviceIdCallbackCompletedCB, - (void *)dbDeviceId, + reinterpret_cast(dbDeviceId), &dbDeviceId->work); napi_queue_async_work(env, dbDeviceId->work); @@ -513,7 +513,7 @@ napi_value GetOsAccountAllConstraints(napi_env env, napi_callback_info cbInfo) resource, GetAllConsExecuteCB, GetAllConsCallbackCompletedCB, - (void *)getAllConsCB, + reinterpret_cast(getAllConsCB), &getAllConsCB->work); napi_queue_async_work(env, getAllConsCB->work); @@ -550,7 +550,7 @@ napi_value GetOsAccountLocalIdFromProcess(napi_env env, napi_callback_info cbInf resource, GetProcessIdExecuteCB, GetProcessIdCallbackCompletedCB, - (void *)getIdCB, + reinterpret_cast(getIdCB), &getIdCB->work); napi_queue_async_work(env, getIdCB->work); @@ -587,7 +587,7 @@ napi_value QueryAllCreatedOsAccounts(napi_env env, napi_callback_info cbInfo) resource, QueryCreateOAExecuteCB, QueryCreateOACallbackCompletedCB, - (void *)queryAllOA, + reinterpret_cast(queryAllOA), &queryAllOA->work); napi_queue_async_work(env, queryAllOA->work); @@ -624,7 +624,7 @@ napi_value QueryActivatedOsAccountIds(napi_env env, napi_callback_info cbInfo) resource, QueryActiveIdsExecuteCB, QueryActiveIdsCallbackCompletedCB, - (void *)queryActiveIds, + reinterpret_cast(queryActiveIds), &queryActiveIds->work); napi_queue_async_work(env, queryActiveIds->work); @@ -660,8 +660,8 @@ napi_value GetOsAccountProfilePhoto(napi_env env, napi_callback_info cbInfo) napi_value resource = nullptr; napi_create_string_utf8(env, "GetOsAccountProfilePhoto", NAPI_AUTO_LENGTH, &resource); - napi_create_async_work( - env, nullptr, resource, GetOAPhoteExecuteCB, GetOAPhoteCallbackCompletedCB, (void *)getPhoto, &getPhoto->work); + napi_create_async_work(env, nullptr, resource, GetOAPhoteExecuteCB, GetOAPhoteCallbackCompletedCB, + reinterpret_cast(getPhoto), &getPhoto->work); napi_queue_async_work(env, getPhoto->work); return result; @@ -697,7 +697,7 @@ napi_value QueryCurrentOsAccount(napi_env env, napi_callback_info cbInfo) resource, QueryCurrentOAExecuteCB, QueryCurrentOACallbackCompletedCB, - (void *)currentOA, + reinterpret_cast(currentOA), ¤tOA->work); napi_queue_async_work(env, currentOA->work); @@ -732,8 +732,8 @@ napi_value GetOsAccountLocalIdFromUid(napi_env env, napi_callback_info cbInfo) napi_value resource = nullptr; napi_create_string_utf8(env, "GetOsAccountLocalIdFromUid", NAPI_AUTO_LENGTH, &resource); - napi_create_async_work( - env, nullptr, resource, GetIdByUidExecuteCB, GetIdByUidCallbackCompletedCB, (void *)idByUid, &idByUid->work); + napi_create_async_work(env, nullptr, resource, GetIdByUidExecuteCB, GetIdByUidCallbackCompletedCB, + reinterpret_cast(idByUid), &idByUid->work); napi_queue_async_work(env, idByUid->work); return result; @@ -767,8 +767,8 @@ napi_value GetOsAccountLocalIdFromDomain(napi_env env, napi_callback_info cbInfo napi_value resource = nullptr; napi_create_string_utf8(env, "GetOsAccountLocalIdFromDomain", NAPI_AUTO_LENGTH, &resource); - napi_create_async_work(env, nullptr, resource, GetIdByDomainExecuteCB, - GetIdByDomainCallbackCompletedCB, (void *)idByDomain, &idByDomain->work); + napi_create_async_work(env, nullptr, resource, GetIdByDomainExecuteCB, GetIdByDomainCallbackCompletedCB, + reinterpret_cast(idByDomain), &idByDomain->work); napi_queue_async_work(env, idByDomain->work); return result; @@ -802,8 +802,8 @@ napi_value SetOsAccountProfilePhoto(napi_env env, napi_callback_info cbInfo) napi_value resource = nullptr; napi_create_string_utf8(env, "SetOsAccountProfilePhoto", NAPI_AUTO_LENGTH, &resource); - napi_create_async_work( - env, nullptr, resource, SetPhotoExecuteCB, SetPhotoCompletedCB, (void *)setPhoto, &setPhoto->work); + napi_create_async_work(env, nullptr, resource, SetPhotoExecuteCB, SetPhotoCompletedCB, + reinterpret_cast(setPhoto), &setPhoto->work); napi_queue_async_work(env, setPhoto->work); return result; @@ -834,8 +834,8 @@ napi_value QueryMaxOsAccountNumber(napi_env env, napi_callback_info cbInfo) napi_value resource = nullptr; napi_create_string_utf8(env, "QueryMaxOsAccountNumber", NAPI_AUTO_LENGTH, &resource); - napi_create_async_work( - env, nullptr, resource, QueryMaxNumExecuteCB, QueryMaxNumCompletedCB, (void *)maxNum, &maxNum->work); + napi_create_async_work(env, nullptr, resource, QueryMaxNumExecuteCB, QueryMaxNumCompletedCB, + reinterpret_cast(maxNum), &maxNum->work); napi_queue_async_work(env, maxNum->work); return result; @@ -869,8 +869,8 @@ napi_value IsOsAccountActived(napi_env env, napi_callback_info cbInfo) napi_value resource = nullptr; napi_create_string_utf8(env, "IsOsAccountActived", NAPI_AUTO_LENGTH, &resource); - napi_create_async_work( - env, nullptr, resource, IsActivedExecuteCB, IsActivedCompletedCB, (void *)isActived, &isActived->work); + napi_create_async_work(env, nullptr, resource, IsActivedExecuteCB, IsActivedCompletedCB, + reinterpret_cast(isActived), &isActived->work); napi_queue_async_work(env, isActived->work); return result; @@ -904,8 +904,8 @@ napi_value IsOsAccountConstraintEnable(napi_env env, napi_callback_info cbInfo) napi_value resource = nullptr; napi_create_string_utf8(env, "IsOsAccountConstraintEnable", NAPI_AUTO_LENGTH, &resource); - napi_create_async_work( - env, nullptr, resource, IsEnableExecuteCB, IsEnableCompletedCB, (void *)isEnable, &isEnable->work); + napi_create_async_work(env, nullptr, resource, IsEnableExecuteCB, IsEnableCompletedCB, + reinterpret_cast(isEnable), &isEnable->work); napi_queue_async_work(env, isEnable->work); return result; @@ -936,8 +936,8 @@ napi_value GetOsAccountTypeFromProcess(napi_env env, napi_callback_info cbInfo) napi_value resource = nullptr; napi_create_string_utf8(env, "GetOsAccountTypeFromProcess", NAPI_AUTO_LENGTH, &resource); - napi_create_async_work( - env, nullptr, resource, GetTypeExecuteCB, GetTypeCompletedCB, (void *)getType, &getType->work); + napi_create_async_work(env, nullptr, resource, GetTypeExecuteCB, GetTypeCompletedCB, + reinterpret_cast(getType), &getType->work); napi_queue_async_work(env, getType->work); return result; @@ -968,8 +968,8 @@ napi_value IsMultiOsAccountEnable(napi_env env, napi_callback_info cbInfo) napi_value resource = nullptr; napi_create_string_utf8(env, "IsMultiOsAccountEnable", NAPI_AUTO_LENGTH, &resource); - napi_create_async_work( - env, nullptr, resource, IsMultiEnExecuteCB, IsMultiEnCompletedCB, (void *)multiEn, &multiEn->work); + napi_create_async_work(env, nullptr, resource, IsMultiEnExecuteCB, IsMultiEnCompletedCB, + reinterpret_cast(multiEn), &multiEn->work); napi_queue_async_work(env, multiEn->work); return result; @@ -1003,8 +1003,8 @@ napi_value IsOsAccountVerified(napi_env env, napi_callback_info cbInfo) napi_value resource = nullptr; napi_create_string_utf8(env, "IsOsAccountVerified", NAPI_AUTO_LENGTH, &resource); - napi_create_async_work( - env, nullptr, resource, IsVerifiedExecuteCB, IsVerifiedCompletedCB, (void *)isVerified, &isVerified->work); + napi_create_async_work(env, nullptr, resource, IsVerifiedExecuteCB, IsVerifiedCompletedCB, + reinterpret_cast(isVerified), &isVerified->work); napi_queue_async_work(env, isVerified->work); return result; @@ -1038,8 +1038,8 @@ napi_value GetOsAccountLocalIdBySerialNumber(napi_env env, napi_callback_info cb napi_value resource = nullptr; napi_create_string_utf8(env, "GetOsAccountLocalIdBySerialNumber", NAPI_AUTO_LENGTH, &resource); - napi_create_async_work( - env, nullptr, resource, SerialNumIdExecuteCB, SerialNumIdCompletedCB, (void *)serialNumId, &serialNumId->work); + napi_create_async_work(env, nullptr, resource, SerialNumIdExecuteCB, SerialNumIdCompletedCB, + reinterpret_cast(serialNumId), &serialNumId->work); napi_queue_async_work(env, serialNumId->work); return result; @@ -1078,7 +1078,7 @@ napi_value GetSerialNumberByOsAccountLocalId(napi_env env, napi_callback_info cb resource, GetSerialNumExecuteCB, GetSerialNumCompletedCB, - (void *)getSerialNum, + reinterpret_cast(getSerialNum), &getSerialNum->work); napi_queue_async_work(env, getSerialNum->work); @@ -1116,18 +1116,18 @@ napi_value IsTestOsAccount(napi_env env, napi_callback_info cbInfo) [](napi_env env, void *data) {}, [](napi_env env, napi_status status, void *data) { ACCOUNT_LOGI("napi_create_async_work complete"); - IsTestOAInfo *isTest = (IsTestOAInfo *)data; + IsTestOAInfo *isTest = reinterpret_cast(data); isTest->errCode = 0; isTest->isTestOsAccount = false; napi_value result[RESULT_COUNT] = {0}; - result[PARAM0] = GetErrorCodeValue(env, isTest->errCode); - napi_get_boolean(env, isTest->isTestOsAccount, &result[PARAM1]); - CBOrPromiseIsTestOA(env, isTest, result[PARAM0], result[PARAM1]); + result[PARAMZERO] = GetErrorCodeValue(env, isTest->errCode); + napi_get_boolean(env, isTest->isTestOsAccount, &result[PARAMONE]); + CBOrPromiseIsTestOA(env, isTest, result[PARAMZERO], result[PARAMONE]); napi_delete_async_work(env, isTest->work); delete isTest; isTest = nullptr; }, - (void *)isTest, + reinterpret_cast(isTest), &isTest->work); napi_queue_async_work(env, isTest->work); @@ -1171,7 +1171,7 @@ napi_value Subscribe(napi_env env, napi_callback_info cbInfo) subscribeCBInfo->subscriber = std::make_shared(subscribeInfo); OsAccountManager *objectInfo = nullptr; - napi_unwrap(env, thisVar, (void **)&objectInfo); + napi_unwrap(env, thisVar, reinterpret_cast(&objectInfo)); subscribeCBInfo->osManager = objectInfo; ACCOUNT_LOGI("OsAccountManager objectInfo = %{public}p", objectInfo); @@ -1189,7 +1189,7 @@ napi_value Subscribe(napi_env env, napi_callback_info cbInfo) resourceName, SubscribeExecuteCB, SubscribeCompletedCB, - (void *)subscribeCBInfo, + reinterpret_cast(subscribeCBInfo), &subscribeCBInfo->work); napi_queue_async_work(env, subscribeCBInfo->work); return WrapVoidToJS(env); @@ -1228,7 +1228,7 @@ void SubscriberPtr::OnAccountsChanged(const int &id_) subscriberOAWorker->env = env_; subscriberOAWorker->ref = ref_; subscriberOAWorker->subscriber = this; - work->data = (void *)subscriberOAWorker; + work->data = reinterpret_cast(subscriberOAWorker); uv_queue_work(loop, work, [](uv_work_t *work) {}, UvQueueWorkOnAccountsChanged); ACCOUNT_LOGI("end"); @@ -1240,10 +1240,10 @@ void UvQueueWorkOnAccountsChanged(uv_work_t *work, int status) if (work == nullptr || work->data == nullptr) { return; } - SubscriberOAWorker *subscriberOAWorkerData = (SubscriberOAWorker *)work->data; + SubscriberOAWorker *subscriberOAWorkerData = reinterpret_cast(work->data); napi_value result[ARGS_SIZE_ONE] = {nullptr}; - napi_create_int32(subscriberOAWorkerData->env, subscriberOAWorkerData->id, &result[PARAM0]); + napi_create_int32(subscriberOAWorkerData->env, subscriberOAWorkerData->id, &result[PARAMZERO]); napi_value undefined = nullptr; napi_get_undefined(subscriberOAWorkerData->env, &undefined); @@ -1319,7 +1319,7 @@ napi_value Unsubscribe(napi_env env, napi_callback_info cbInfo) } OsAccountManager *objectInfo = nullptr; - napi_unwrap(env, thisVar, (void **)&objectInfo); + napi_unwrap(env, thisVar, reinterpret_cast(&objectInfo)); unsubscribeCBInfo->osManager = objectInfo; unsubscribeCBInfo->callbackRef = callback; unsubscribeCBInfo->osSubscribeType = offType; @@ -1344,7 +1344,7 @@ napi_value Unsubscribe(napi_env env, napi_callback_info cbInfo) resourceName, UnsubscribeExecuteCB, UnsubscribeCallbackCompletedCB, - (void *)unsubscribeCBInfo, + reinterpret_cast(unsubscribeCBInfo), &unsubscribeCBInfo->work); napi_queue_async_work(env, unsubscribeCBInfo->work); return WrapVoidToJS(env); @@ -1383,7 +1383,7 @@ void FindSubscriberInMap( void UnsubscribeExecuteCB(napi_env env, void *data) { ACCOUNT_LOGI("napi_create_async_work running"); - UnsubscribeCBInfo *unsubscribeCBInfo = (UnsubscribeCBInfo *)data; + UnsubscribeCBInfo *unsubscribeCBInfo = reinterpret_cast(data); ACCOUNT_LOGI("UnsubscribeExecuteCB Off size = %{public}zu", unsubscribeCBInfo->subscribers.size()); for (auto offSubscriber : unsubscribeCBInfo->subscribers) { int errCode = OsAccountManager::UnsubscribeOsAccount(offSubscriber); @@ -1394,7 +1394,7 @@ void UnsubscribeExecuteCB(napi_env env, void *data) void UnsubscribeCallbackCompletedCB(napi_env env, napi_status status, void *data) { ACCOUNT_LOGI("napi_create_async_work complete."); - UnsubscribeCBInfo *unsubscribeCBInfo = (UnsubscribeCBInfo *)data; + UnsubscribeCBInfo *unsubscribeCBInfo = reinterpret_cast(data); if (unsubscribeCBInfo == nullptr) { return; } @@ -1411,7 +1411,7 @@ void UnsubscribeCallbackCompletedCB(napi_env env, napi_status status, void *data napi_get_reference_value(env, unsubscribeCBInfo->callbackRef, &callback); napi_value results[ARGS_SIZE_ONE] = {nullptr}; - results[PARAM0] = result; + results[PARAMZERO] = result; NAPI_CALL_RETURN_VOID( env, napi_call_function(env, undefined, callback, ARGS_SIZE_ONE, &results[0], &resultout)); diff --git a/interfaces/kits/napi/osaccount/src/napi_os_account_common.cpp b/interfaces/kits/napi/osaccount/src/napi_os_account_common.cpp index 840bd62bc..1fea1bc11 100644 --- a/interfaces/kits/napi/osaccount/src/napi_os_account_common.cpp +++ b/interfaces/kits/napi/osaccount/src/napi_os_account_common.cpp @@ -13,9 +13,10 @@ * limitations under the License. */ -#include "napi_os_account.h" #include "napi_os_account_common.h" +#include "napi_os_account.h" + namespace OHOS { namespace AccountJsKit { napi_value WrapVoidToJS(napi_env env) @@ -94,7 +95,7 @@ napi_value ParseParaQueryOAByIdCB(napi_env env, napi_callback_info cbInfo, Query void QueryOAByIdExecuteCB(napi_env env, void *data) { ACCOUNT_LOGI("napi_create_async_work running"); - QueryOAByIdAsyncContext *queryOAByIdCB = (QueryOAByIdAsyncContext *)data; + QueryOAByIdAsyncContext *queryOAByIdCB = reinterpret_cast(data); queryOAByIdCB->errCode = OsAccountManager::QueryOsAccountById(queryOAByIdCB->id, queryOAByIdCB->osAccountInfos); ACCOUNT_LOGI("errcode is %{public}d", queryOAByIdCB->errCode); queryOAByIdCB->status = (queryOAByIdCB->errCode == 0) ? napi_ok : napi_generic_failure; @@ -103,12 +104,12 @@ void QueryOAByIdExecuteCB(napi_env env, void *data) void QueryOAByIdCallbackCompletedCB(napi_env env, napi_status status, void *data) { ACCOUNT_LOGI("napi_create_async_work complete"); - QueryOAByIdAsyncContext *queryOAByIdCB = (QueryOAByIdAsyncContext *)data; + QueryOAByIdAsyncContext *queryOAByIdCB = reinterpret_cast(data); napi_value queryResult[RESULT_COUNT] = {0}; - queryResult[PARAM0] = GetErrorCodeValue(env, queryOAByIdCB->errCode); - napi_create_object(env, &queryResult[PARAM1]); - GetOACBInfoToJs(env, queryOAByIdCB->osAccountInfos, queryResult[PARAM1]); - CBOrPromiseToQueryOAById(env, queryOAByIdCB, queryResult[PARAM0], queryResult[PARAM1]); + queryResult[PARAMZERO] = GetErrorCodeValue(env, queryOAByIdCB->errCode); + napi_create_object(env, &queryResult[PARAMONE]); + GetOACBInfoToJs(env, queryOAByIdCB->osAccountInfos, queryResult[PARAMONE]); + CBOrPromiseToQueryOAById(env, queryOAByIdCB, queryResult[PARAMZERO], queryResult[PARAMONE]); napi_delete_async_work(env, queryOAByIdCB->work); delete queryOAByIdCB; queryOAByIdCB = nullptr; @@ -220,14 +221,8 @@ void GetOACBInfoToJs(napi_env env, OsAccountInfo &info, napi_value objOAInfo) napi_set_named_property(env, dbInfoToJs, "event", value); // scalableData - std::map scalableData = {}; napi_value scalable = nullptr; napi_create_object(env, &scalable); - for (const auto &[key, item] : scalableData) { - napi_value jsValue = nullptr; - napi_create_string_utf8(env, item.c_str(), item.size(), &jsValue); - napi_set_named_property(env, scalable, key.c_str(), jsValue); - } napi_set_named_property(env, dbInfoToJs, "scalableData", scalable); } else { napi_get_undefined(env, &dbInfoToJs); @@ -316,7 +311,7 @@ napi_value ParseParaRemoveOACB(napi_env env, napi_callback_info cbInfo, RemoveOA void RemoveOAExecuteCB(napi_env env, void *data) { ACCOUNT_LOGI("napi_create_async_work running"); - RemoveOAAsyncContext *removeOACB = (RemoveOAAsyncContext *)data; + RemoveOAAsyncContext *removeOACB = reinterpret_cast(data); removeOACB->errCode = OsAccountManager::RemoveOsAccount(removeOACB->id); ACCOUNT_LOGI("errcode is %{public}d", removeOACB->errCode); removeOACB->status = (removeOACB->errCode == 0) ? napi_ok : napi_generic_failure; @@ -325,11 +320,11 @@ void RemoveOAExecuteCB(napi_env env, void *data) void RemoveOACallbackCompletedCB(napi_env env, napi_status status, void *data) { ACCOUNT_LOGI("napi_create_async_work complete"); - RemoveOAAsyncContext *removeOACB = (RemoveOAAsyncContext *)data; + RemoveOAAsyncContext *removeOACB = reinterpret_cast(data); napi_value rmResult[RESULT_COUNT] = {0}; - rmResult[PARAM0] = GetErrorCodeValue(env, removeOACB->errCode); - napi_get_undefined(env, &rmResult[PARAM1]); - CBOrPromiseToRemoveOA(env, removeOACB, rmResult[PARAM0], rmResult[PARAM1]); + rmResult[PARAMZERO] = GetErrorCodeValue(env, removeOACB->errCode); + napi_get_undefined(env, &rmResult[PARAMONE]); + CBOrPromiseToRemoveOA(env, removeOACB, rmResult[PARAMZERO], rmResult[PARAMONE]); napi_delete_async_work(env, removeOACB->work); delete removeOACB; removeOACB = nullptr; @@ -386,7 +381,7 @@ napi_value ParseParaSetOAName(napi_env env, napi_callback_info cbInfo, SetOAName void SetOANameExecuteCB(napi_env env, void *data) { ACCOUNT_LOGI("napi_create_async_work running"); - SetOANameAsyncContext *setOANameCB = (SetOANameAsyncContext *)data; + SetOANameAsyncContext *setOANameCB = reinterpret_cast(data); setOANameCB->errCode = OsAccountManager::SetOsAccountName(setOANameCB->id, setOANameCB->name); ACCOUNT_LOGI("errcode is %{public}d", setOANameCB->errCode); setOANameCB->status = (setOANameCB->errCode == 0) ? napi_ok : napi_generic_failure; @@ -395,11 +390,11 @@ void SetOANameExecuteCB(napi_env env, void *data) void SetOANameCallbackCompletedCB(napi_env env, napi_status status, void *data) { ACCOUNT_LOGI("napi_create_async_work complete"); - SetOANameAsyncContext *setOANameCB = (SetOANameAsyncContext *)data; + SetOANameAsyncContext *setOANameCB = reinterpret_cast(data); napi_value setNameResult[RESULT_COUNT] = {0}; - setNameResult[PARAM0] = GetErrorCodeValue(env, setOANameCB->errCode); - napi_get_undefined(env, &setNameResult[PARAM1]); - CBOrPromiseToSetOAName(env, setOANameCB, setNameResult[PARAM0], setNameResult[PARAM1]); + setNameResult[PARAMZERO] = GetErrorCodeValue(env, setOANameCB->errCode); + napi_get_undefined(env, &setNameResult[PARAMONE]); + CBOrPromiseToSetOAName(env, setOANameCB, setNameResult[PARAMZERO], setNameResult[PARAMONE]); napi_delete_async_work(env, setOANameCB->work); delete setOANameCB; setOANameCB = nullptr; @@ -489,7 +484,7 @@ napi_value ParseParaSetOAConstraints(napi_env env, napi_callback_info cbInfo, Se void SetOAConsExecuteCB(napi_env env, void *data) { ACCOUNT_LOGI("napi_create_async_work running"); - SetOAConsAsyncContext *setOAConsCB = (SetOAConsAsyncContext *)data; + SetOAConsAsyncContext *setOAConsCB = reinterpret_cast(data); setOAConsCB->errCode = OsAccountManager::SetOsAccountConstraints(setOAConsCB->id, setOAConsCB->constraints, setOAConsCB->enable); ACCOUNT_LOGI("errcode is %{public}d", setOAConsCB->errCode); @@ -499,11 +494,11 @@ void SetOAConsExecuteCB(napi_env env, void *data) void SetOAConsCallbackCompletedCB(napi_env env, napi_status status, void *data) { ACCOUNT_LOGI("napi_create_async_work complete"); - SetOAConsAsyncContext *setOAConsCB = (SetOAConsAsyncContext *)data; + SetOAConsAsyncContext *setOAConsCB = reinterpret_cast(data); napi_value setConsResult[RESULT_COUNT] = {0}; - setConsResult[PARAM0] = GetErrorCodeValue(env, setOAConsCB->errCode); - napi_get_undefined(env, &setConsResult[PARAM1]); - CBOrPromiseToSetOACons(env, setOAConsCB, setConsResult[PARAM0], setConsResult[PARAM1]); + setConsResult[PARAMZERO] = GetErrorCodeValue(env, setOAConsCB->errCode); + napi_get_undefined(env, &setConsResult[PARAMONE]); + CBOrPromiseToSetOACons(env, setOAConsCB, setConsResult[PARAMZERO], setConsResult[PARAMONE]); napi_delete_async_work(env, setOAConsCB->work); delete setOAConsCB; setOAConsCB = nullptr; @@ -558,7 +553,7 @@ napi_value ParseParaActiveOA(napi_env env, napi_callback_info cbInfo, ActivateOA void ActivateOAExecuteCB(napi_env env, void *data) { ACCOUNT_LOGI("napi_create_async_work running"); - ActivateOAAsyncContext *activateOACB = (ActivateOAAsyncContext *)data; + ActivateOAAsyncContext *activateOACB = reinterpret_cast(data); activateOACB->errCode = OsAccountManager::ActivateOsAccount(activateOACB->id); ACCOUNT_LOGI("errcode is %{public}d", activateOACB->errCode); activateOACB->status = (activateOACB->errCode == 0) ? napi_ok : napi_generic_failure; @@ -567,11 +562,11 @@ void ActivateOAExecuteCB(napi_env env, void *data) void ActivateOACallbackCompletedCB(napi_env env, napi_status status, void *data) { ACCOUNT_LOGI("napi_create_async_work complete"); - ActivateOAAsyncContext *activateOA = (ActivateOAAsyncContext *)data; + ActivateOAAsyncContext *activateOA = reinterpret_cast(data); napi_value activateResult[RESULT_COUNT] = {0}; - activateResult[PARAM0] = GetErrorCodeValue(env, activateOA->errCode); - napi_get_undefined(env, &activateResult[PARAM1]); - CBOrPromiseToActivateOA(env, activateOA, activateResult[PARAM0], activateResult[PARAM1]); + activateResult[PARAMZERO] = GetErrorCodeValue(env, activateOA->errCode); + napi_get_undefined(env, &activateResult[PARAMONE]); + CBOrPromiseToActivateOA(env, activateOA, activateResult[PARAMZERO], activateResult[PARAMONE]); napi_delete_async_work(env, activateOA->work); delete activateOA; activateOA = nullptr; @@ -660,7 +655,7 @@ napi_value ParseParaCreateOAForDomain(napi_env env, napi_callback_info cbInfo, void CreateOAExecuteCB(napi_env env, void *data) { ACCOUNT_LOGI("napi_create_async_work running"); - CreateOAAsyncContext *createOACB = (CreateOAAsyncContext *)data; + CreateOAAsyncContext *createOACB = reinterpret_cast(data); createOACB->errCode = OsAccountManager::CreateOsAccount(createOACB->name, createOACB->type, createOACB->osAccountInfos); ACCOUNT_LOGI("errocde is %{public}d", createOACB->errCode); @@ -670,7 +665,7 @@ void CreateOAExecuteCB(napi_env env, void *data) void CreateOAForDomainExecuteCB(napi_env env, void *data) { ACCOUNT_LOGI("napi_create_async_work running"); - CreateOAForDomainAsyncContext *createOAForDomainCB = (CreateOAForDomainAsyncContext *)data; + CreateOAForDomainAsyncContext *createOAForDomainCB = reinterpret_cast(data); createOAForDomainCB->errCode = OsAccountManager::CreateOsAccountForDomain(createOAForDomainCB->type, createOAForDomainCB->domainInfo, createOAForDomainCB->osAccountInfos); ACCOUNT_LOGI("errocde is %{public}d", createOAForDomainCB->errCode); @@ -680,12 +675,12 @@ void CreateOAForDomainExecuteCB(napi_env env, void *data) void CreateOACallbackCompletedCB(napi_env env, napi_status status, void *data) { ACCOUNT_LOGI("napi_create_async_work complete"); - CreateOAAsyncContext *createOACB = (CreateOAAsyncContext *)data; + CreateOAAsyncContext *createOACB = reinterpret_cast(data); napi_value createResult[RESULT_COUNT] = {0}; - createResult[PARAM0] = GetErrorCodeValue(env, createOACB->errCode); - napi_create_object(env, &createResult[PARAM1]); - GetOACBInfoToJs(env, createOACB->osAccountInfos, createResult[PARAM1]); - CBOrPromiseToCreateOA(env, createOACB, createResult[PARAM0], createResult[PARAM1]); + createResult[PARAMZERO] = GetErrorCodeValue(env, createOACB->errCode); + napi_create_object(env, &createResult[PARAMONE]); + GetOACBInfoToJs(env, createOACB->osAccountInfos, createResult[PARAMONE]); + CBOrPromiseToCreateOA(env, createOACB, createResult[PARAMZERO], createResult[PARAMONE]); napi_delete_async_work(env, createOACB->work); delete createOACB; createOACB = nullptr; @@ -694,12 +689,12 @@ void CreateOACallbackCompletedCB(napi_env env, napi_status status, void *data) void CreateOAForDomainCallbackCompletedCB(napi_env env, napi_status status, void *data) { ACCOUNT_LOGI("napi_create_async_work complete"); - CreateOAForDomainAsyncContext *createOAForDomainCB = (CreateOAForDomainAsyncContext *)data; + CreateOAForDomainAsyncContext *createOAForDomainCB = reinterpret_cast(data); napi_value createResult[RESULT_COUNT] = {0}; - createResult[PARAM0] = GetErrorCodeValue(env, createOAForDomainCB->errCode); - napi_create_object(env, &createResult[PARAM1]); - GetOACBInfoToJs(env, createOAForDomainCB->osAccountInfos, createResult[PARAM1]); - CBOrPromiseToCreateOAForDomain(env, createOAForDomainCB, createResult[PARAM0], createResult[PARAM1]); + createResult[PARAMZERO] = GetErrorCodeValue(env, createOAForDomainCB->errCode); + napi_create_object(env, &createResult[PARAMONE]); + GetOACBInfoToJs(env, createOAForDomainCB->osAccountInfos, createResult[PARAMONE]); + CBOrPromiseToCreateOAForDomain(env, createOAForDomainCB, createResult[PARAMZERO], createResult[PARAMONE]); napi_delete_async_work(env, createOAForDomainCB->work); delete createOAForDomainCB; createOAForDomainCB = nullptr; @@ -771,7 +766,7 @@ void ParseParaGetOACount(napi_env env, napi_callback_info cbInfo, GetOACountAsyn void GetOACountExecuteCB(napi_env env, void *data) { ACCOUNT_LOGI("napi_create_async_work running"); - GetOACountAsyncContext *getOACount = (GetOACountAsyncContext *)data; + GetOACountAsyncContext *getOACount = reinterpret_cast(data); getOACount->errCode = OsAccountManager::GetCreatedOsAccountsCount(getOACount->osAccountsCount); ACCOUNT_LOGI("errocde is %{public}d", getOACount->errCode); getOACount->status = (getOACount->errCode == 0) ? napi_ok : napi_generic_failure; @@ -780,11 +775,11 @@ void GetOACountExecuteCB(napi_env env, void *data) void GetOACountCallbackCompletedCB(napi_env env, napi_status status, void *data) { ACCOUNT_LOGI("napi_create_async_work complete"); - GetOACountAsyncContext *getOACount = (GetOACountAsyncContext *)data; + GetOACountAsyncContext *getOACount = reinterpret_cast(data); napi_value getResult[RESULT_COUNT] = {0}; - getResult[PARAM0] = GetErrorCodeValue(env, getOACount->errCode); - napi_create_uint32(env, getOACount->osAccountsCount, &getResult[PARAM1]); - CBOrPromiseToGetOACount(env, getOACount, getResult[PARAM0], getResult[PARAM1]); + getResult[PARAMZERO] = GetErrorCodeValue(env, getOACount->errCode); + napi_create_uint32(env, getOACount->osAccountsCount, &getResult[PARAMONE]); + CBOrPromiseToGetOACount(env, getOACount, getResult[PARAMZERO], getResult[PARAMONE]); napi_delete_async_work(env, getOACount->work); delete getOACount; getOACount = nullptr; @@ -832,7 +827,7 @@ void ParseParaDbDeviceId(napi_env env, napi_callback_info cbInfo, DbDeviceIdAsyn void DbDeviceIdExecuteCB(napi_env env, void *data) { ACCOUNT_LOGI("napi_create_async_work running"); - DbDeviceIdAsyncContext *dbDeviceId = (DbDeviceIdAsyncContext *)data; + DbDeviceIdAsyncContext *dbDeviceId = reinterpret_cast(data); dbDeviceId->errCode = OsAccountManager::GetDistributedVirtualDeviceId(dbDeviceId->deviceId); ACCOUNT_LOGI("errocde is %{public}d", dbDeviceId->errCode); dbDeviceId->status = (dbDeviceId->errCode == 0) ? napi_ok : napi_generic_failure; @@ -841,11 +836,11 @@ void DbDeviceIdExecuteCB(napi_env env, void *data) void DbDeviceIdCallbackCompletedCB(napi_env env, napi_status status, void *data) { ACCOUNT_LOGI("napi_create_async_work complete"); - DbDeviceIdAsyncContext *dbDeviceId = (DbDeviceIdAsyncContext *)data; + DbDeviceIdAsyncContext *dbDeviceId = reinterpret_cast(data); napi_value dbIdResult[RESULT_COUNT] = {0}; - dbIdResult[PARAM0] = GetErrorCodeValue(env, dbDeviceId->errCode); - napi_create_string_utf8(env, dbDeviceId->deviceId.c_str(), NAPI_AUTO_LENGTH, &dbIdResult[PARAM1]); - CBOrPromiseToDbDeviceId(env, dbDeviceId, dbIdResult[PARAM0], dbIdResult[PARAM1]); + dbIdResult[PARAMZERO] = GetErrorCodeValue(env, dbDeviceId->errCode); + napi_create_string_utf8(env, dbDeviceId->deviceId.c_str(), NAPI_AUTO_LENGTH, &dbIdResult[PARAMONE]); + CBOrPromiseToDbDeviceId(env, dbDeviceId, dbIdResult[PARAMZERO], dbIdResult[PARAMONE]); napi_delete_async_work(env, dbDeviceId->work); delete dbDeviceId; dbDeviceId = nullptr; @@ -900,7 +895,7 @@ napi_value ParseParaGetAllCons(napi_env env, napi_callback_info cbInfo, GetAllCo void GetAllConsExecuteCB(napi_env env, void *data) { ACCOUNT_LOGI("napi_create_async_work running"); - GetAllConsAsyncContext *getAllConsCB = (GetAllConsAsyncContext *)data; + GetAllConsAsyncContext *getAllConsCB = reinterpret_cast(data); getAllConsCB->errCode = OsAccountManager::GetOsAccountAllConstraints(getAllConsCB->id, getAllConsCB->constraints); ACCOUNT_LOGI("errocde is %{public}d", getAllConsCB->errCode); getAllConsCB->status = (getAllConsCB->errCode == 0) ? napi_ok : napi_generic_failure; @@ -909,12 +904,12 @@ void GetAllConsExecuteCB(napi_env env, void *data) void GetAllConsCallbackCompletedCB(napi_env env, napi_status status, void *data) { ACCOUNT_LOGI("napi_create_async_work complete"); - GetAllConsAsyncContext *getAllConsCB = (GetAllConsAsyncContext *)data; + GetAllConsAsyncContext *getAllConsCB = reinterpret_cast(data); napi_value getResult[RESULT_COUNT] = {0}; - getResult[PARAM0] = GetErrorCodeValue(env, getAllConsCB->errCode); - napi_create_array(env, &getResult[PARAM1]); - GetAllAccountCons(env, getAllConsCB->constraints, getResult[PARAM1]); - CBOrPromiseToGetAllCons(env, getAllConsCB, getResult[PARAM0], getResult[PARAM1]); + getResult[PARAMZERO] = GetErrorCodeValue(env, getAllConsCB->errCode); + napi_create_array(env, &getResult[PARAMONE]); + GetAllAccountCons(env, getAllConsCB->constraints, getResult[PARAMONE]); + CBOrPromiseToGetAllCons(env, getAllConsCB, getResult[PARAMZERO], getResult[PARAMONE]); napi_delete_async_work(env, getAllConsCB->work); delete getAllConsCB; getAllConsCB = nullptr; @@ -990,7 +985,7 @@ void ParseParaProcessId(napi_env env, napi_callback_info cbInfo, GetIdAsyncConte void GetProcessIdExecuteCB(napi_env env, void *data) { ACCOUNT_LOGI("napi_create_async_work running"); - GetIdAsyncContext *getIdCB = (GetIdAsyncContext *)data; + GetIdAsyncContext *getIdCB = reinterpret_cast(data); getIdCB->errCode = OsAccountManager::GetOsAccountLocalIdFromProcess(getIdCB->id); ACCOUNT_LOGI("errocde is %{public}d", getIdCB->errCode); getIdCB->status = (getIdCB->errCode == 0) ? napi_ok : napi_generic_failure; @@ -999,11 +994,11 @@ void GetProcessIdExecuteCB(napi_env env, void *data) void GetProcessIdCallbackCompletedCB(napi_env env, napi_status status, void *data) { ACCOUNT_LOGI("napi_create_async_work complete"); - GetIdAsyncContext *getIdCB = (GetIdAsyncContext *)data; + GetIdAsyncContext *getIdCB = reinterpret_cast(data); napi_value getResult[RESULT_COUNT] = {0}; - getResult[PARAM0] = GetErrorCodeValue(env, getIdCB->errCode); - napi_create_int32(env, getIdCB->id, &getResult[PARAM1]); - CBOrPromiseToGetProcessId(env, getIdCB, getResult[PARAM0], getResult[PARAM1]); + getResult[PARAMZERO] = GetErrorCodeValue(env, getIdCB->errCode); + napi_create_int32(env, getIdCB->id, &getResult[PARAMONE]); + CBOrPromiseToGetProcessId(env, getIdCB, getResult[PARAMZERO], getResult[PARAMONE]); napi_delete_async_work(env, getIdCB->work); delete getIdCB; getIdCB = nullptr; @@ -1065,7 +1060,7 @@ void ParseQueryActiveIds(napi_env env, napi_callback_info cbInfo, QueryActiveIds void QueryCreateOAExecuteCB(napi_env env, void *data) { ACCOUNT_LOGI("napi_create_async_work running"); - QueryCreateOAAsyncContext *queryAllOA = (QueryCreateOAAsyncContext *)data; + QueryCreateOAAsyncContext *queryAllOA = reinterpret_cast(data); queryAllOA->errCode = OsAccountManager::QueryAllCreatedOsAccounts(queryAllOA->osAccountInfos); ACCOUNT_LOGI("errocde is %{public}d", queryAllOA->errCode); queryAllOA->status = (queryAllOA->errCode == 0) ? napi_ok : napi_generic_failure; @@ -1074,7 +1069,7 @@ void QueryCreateOAExecuteCB(napi_env env, void *data) void QueryActiveIdsExecuteCB(napi_env env, void *data) { ACCOUNT_LOGI("napi_create_async_work running"); - QueryActiveIdsAsyncContext *queryActiveIds = (QueryActiveIdsAsyncContext *)data; + QueryActiveIdsAsyncContext *queryActiveIds = reinterpret_cast(data); queryActiveIds->errCode = OsAccountManager::QueryActiveOsAccountIds(queryActiveIds->osAccountIds); ACCOUNT_LOGI("errocde is %{public}d", queryActiveIds->errCode); queryActiveIds->status = (queryActiveIds->errCode == 0) ? napi_ok : napi_generic_failure; @@ -1083,12 +1078,12 @@ void QueryActiveIdsExecuteCB(napi_env env, void *data) void QueryCreateOACallbackCompletedCB(napi_env env, napi_status status, void *data) { ACCOUNT_LOGI("napi_create_async_work complete"); - QueryCreateOAAsyncContext *queryAllOA = (QueryCreateOAAsyncContext *)data; + QueryCreateOAAsyncContext *queryAllOA = reinterpret_cast(data); napi_value queryResult[RESULT_COUNT] = {0}; - queryResult[PARAM0] = GetErrorCodeValue(env, queryAllOA->errCode); - napi_create_array(env, &queryResult[PARAM1]); - QueryOAInfoForResult(env, queryAllOA->osAccountInfos, queryResult[PARAM1]); - CBOrPromiseToQueryOA(env, queryAllOA, queryResult[PARAM0], queryResult[PARAM1]); + queryResult[PARAMZERO] = GetErrorCodeValue(env, queryAllOA->errCode); + napi_create_array(env, &queryResult[PARAMONE]); + QueryOAInfoForResult(env, queryAllOA->osAccountInfos, queryResult[PARAMONE]); + CBOrPromiseToQueryOA(env, queryAllOA, queryResult[PARAMZERO], queryResult[PARAMONE]); napi_delete_async_work(env, queryAllOA->work); delete queryAllOA; queryAllOA = nullptr; @@ -1097,12 +1092,12 @@ void QueryCreateOACallbackCompletedCB(napi_env env, napi_status status, void *da void QueryActiveIdsCallbackCompletedCB(napi_env env, napi_status status, void *data) { ACCOUNT_LOGI("napi_create_async_work complete"); - QueryActiveIdsAsyncContext *queryActiveIds = (QueryActiveIdsAsyncContext *)data; + QueryActiveIdsAsyncContext *queryActiveIds = reinterpret_cast(data); napi_value queryResult[RESULT_COUNT] = {0}; - queryResult[PARAM0] = GetErrorCodeValue(env, queryActiveIds->errCode); - napi_create_array(env, &queryResult[PARAM1]); - GetActiveIds(env, queryActiveIds->osAccountIds, queryResult[PARAM1]); - CBOrPromiseToQueryActiveIds(env, queryActiveIds, queryResult[PARAM0], queryResult[PARAM1]); + queryResult[PARAMZERO] = GetErrorCodeValue(env, queryActiveIds->errCode); + napi_create_array(env, &queryResult[PARAMONE]); + GetActiveIds(env, queryActiveIds->osAccountIds, queryResult[PARAMONE]); + CBOrPromiseToQueryActiveIds(env, queryActiveIds, queryResult[PARAMZERO], queryResult[PARAMONE]); napi_delete_async_work(env, queryActiveIds->work); delete queryActiveIds; queryActiveIds = nullptr; @@ -1196,7 +1191,7 @@ napi_value ParseParaGetPhote(napi_env env, napi_callback_info cbInfo, GetOAPhoto void GetOAPhoteExecuteCB(napi_env env, void *data) { ACCOUNT_LOGI("napi_create_async_work running"); - GetOAPhotoAsyncContext *getPhoto = (GetOAPhotoAsyncContext *)data; + GetOAPhotoAsyncContext *getPhoto = reinterpret_cast(data); getPhoto->errCode = OsAccountManager::GetOsAccountProfilePhoto(getPhoto->id, getPhoto->photo); ACCOUNT_LOGI("errocde is %{public}d", getPhoto->errCode); getPhoto->status = (getPhoto->errCode == 0) ? napi_ok : napi_generic_failure; @@ -1205,11 +1200,11 @@ void GetOAPhoteExecuteCB(napi_env env, void *data) void GetOAPhoteCallbackCompletedCB(napi_env env, napi_status status, void *data) { ACCOUNT_LOGI("napi_create_async_work complete"); - GetOAPhotoAsyncContext *getPhoto = (GetOAPhotoAsyncContext *)data; + GetOAPhotoAsyncContext *getPhoto = reinterpret_cast(data); napi_value getResult[RESULT_COUNT] = {0}; - getResult[PARAM0] = GetErrorCodeValue(env, getPhoto->errCode); - napi_create_string_utf8(env, getPhoto->photo.c_str(), NAPI_AUTO_LENGTH, &getResult[PARAM1]); - CBOrPromiseToGetPhoto(env, getPhoto, getResult[PARAM0], getResult[PARAM1]); + getResult[PARAMZERO] = GetErrorCodeValue(env, getPhoto->errCode); + napi_create_string_utf8(env, getPhoto->photo.c_str(), NAPI_AUTO_LENGTH, &getResult[PARAMONE]); + CBOrPromiseToGetPhoto(env, getPhoto, getResult[PARAMZERO], getResult[PARAMONE]); napi_delete_async_work(env, getPhoto->work); delete getPhoto; getPhoto = nullptr; @@ -1257,7 +1252,7 @@ void ParseParaCurrentOA(napi_env env, napi_callback_info cbInfo, CurrentOAAsyncC void QueryCurrentOAExecuteCB(napi_env env, void *data) { ACCOUNT_LOGI("napi_create_async_work running"); - CurrentOAAsyncContext *currentOA = (CurrentOAAsyncContext *)data; + CurrentOAAsyncContext *currentOA = reinterpret_cast(data); currentOA->errCode = OsAccountManager::QueryCurrentOsAccount(currentOA->osAccountInfos); ACCOUNT_LOGI("errocde is %{public}d", currentOA->errCode); currentOA->status = (currentOA->errCode == 0) ? napi_ok : napi_generic_failure; @@ -1266,12 +1261,12 @@ void QueryCurrentOAExecuteCB(napi_env env, void *data) void QueryCurrentOACallbackCompletedCB(napi_env env, napi_status status, void *data) { ACCOUNT_LOGI("napi_create_async_work complete"); - CurrentOAAsyncContext *currentOA = (CurrentOAAsyncContext *)data; + CurrentOAAsyncContext *currentOA = reinterpret_cast(data); napi_value queryResult[RESULT_COUNT] = {0}; - queryResult[PARAM0] = GetErrorCodeValue(env, currentOA->errCode); - napi_create_object(env, &queryResult[PARAM1]); - GetOACBInfoToJs(env, currentOA->osAccountInfos, queryResult[PARAM1]); - CBOrPromiseQueryCurrentOA(env, currentOA, queryResult[PARAM0], queryResult[PARAM1]); + queryResult[PARAMZERO] = GetErrorCodeValue(env, currentOA->errCode); + napi_create_object(env, &queryResult[PARAMONE]); + GetOACBInfoToJs(env, currentOA->osAccountInfos, queryResult[PARAMONE]); + CBOrPromiseQueryCurrentOA(env, currentOA, queryResult[PARAMZERO], queryResult[PARAMONE]); napi_delete_async_work(env, currentOA->work); delete currentOA; currentOA = nullptr; @@ -1355,7 +1350,7 @@ napi_value ParseParaGetIdByDomain(napi_env env, napi_callback_info cbInfo, GetId void GetIdByUidExecuteCB(napi_env env, void *data) { ACCOUNT_LOGI("napi_create_async_work running"); - GetIdByUidAsyncContext *idByUid = (GetIdByUidAsyncContext *)data; + GetIdByUidAsyncContext *idByUid = reinterpret_cast(data); idByUid->errCode = OsAccountManager::GetOsAccountLocalIdFromUid(idByUid->uid, idByUid->id); ACCOUNT_LOGI("errocde is %{public}d", idByUid->errCode); idByUid->status = (idByUid->errCode == 0) ? napi_ok : napi_generic_failure; @@ -1364,7 +1359,7 @@ void GetIdByUidExecuteCB(napi_env env, void *data) void GetIdByDomainExecuteCB(napi_env env, void *data) { ACCOUNT_LOGI("napi_create_async_work running"); - GetIdByDomainAsyncContext *idByDomain = (GetIdByDomainAsyncContext *)data; + GetIdByDomainAsyncContext *idByDomain = reinterpret_cast(data); idByDomain->errCode = OsAccountManager::GetOsAccountLocalIdFromDomain( idByDomain->domainInfo, idByDomain->id); ACCOUNT_LOGI("errocde is %{public}d", idByDomain->errCode); @@ -1374,11 +1369,11 @@ void GetIdByDomainExecuteCB(napi_env env, void *data) void GetIdByUidCallbackCompletedCB(napi_env env, napi_status status, void *data) { ACCOUNT_LOGI("napi_create_async_work complete"); - GetIdByUidAsyncContext *idByUid = (GetIdByUidAsyncContext *)data; + GetIdByUidAsyncContext *idByUid = reinterpret_cast(data); napi_value uidResult[RESULT_COUNT] = {0}; - uidResult[PARAM0] = GetErrorCodeValue(env, idByUid->errCode); - napi_create_int32(env, idByUid->id, &uidResult[PARAM1]); - CBOrPromiseGetIdByUid(env, idByUid, uidResult[PARAM0], uidResult[PARAM1]); + uidResult[PARAMZERO] = GetErrorCodeValue(env, idByUid->errCode); + napi_create_int32(env, idByUid->id, &uidResult[PARAMONE]); + CBOrPromiseGetIdByUid(env, idByUid, uidResult[PARAMZERO], uidResult[PARAMONE]); napi_delete_async_work(env, idByUid->work); delete idByUid; idByUid = nullptr; @@ -1387,11 +1382,11 @@ void GetIdByUidCallbackCompletedCB(napi_env env, napi_status status, void *data) void GetIdByDomainCallbackCompletedCB(napi_env env, napi_status status, void *data) { ACCOUNT_LOGI("napi_create_async_work complete"); - GetIdByDomainAsyncContext *idByDomain = (GetIdByDomainAsyncContext *)data; + GetIdByDomainAsyncContext *idByDomain = reinterpret_cast(data); napi_value uidResult[RESULT_COUNT] = {0}; - uidResult[PARAM0] = GetErrorCodeValue(env, idByDomain->errCode); - napi_create_int32(env, idByDomain->id, &uidResult[PARAM1]); - CBOrPromiseGetIdByDomain(env, idByDomain, uidResult[PARAM0], uidResult[PARAM1]); + uidResult[PARAMZERO] = GetErrorCodeValue(env, idByDomain->errCode); + napi_create_int32(env, idByDomain->id, &uidResult[PARAMONE]); + CBOrPromiseGetIdByDomain(env, idByDomain, uidResult[PARAMZERO], uidResult[PARAMONE]); napi_delete_async_work(env, idByDomain->work); delete idByDomain; idByDomain = nullptr; @@ -1472,7 +1467,7 @@ napi_value ParseParaSetPhoto(napi_env env, napi_callback_info cbInfo, SetOAPhoto void SetPhotoExecuteCB(napi_env env, void *data) { ACCOUNT_LOGI("napi_create_async_work running"); - SetOAPhotoAsyncContext *setPhoto = (SetOAPhotoAsyncContext *)data; + SetOAPhotoAsyncContext *setPhoto = reinterpret_cast(data); setPhoto->errCode = OsAccountManager::SetOsAccountProfilePhoto(setPhoto->id, setPhoto->photo); ACCOUNT_LOGI("errocde is %{public}d", setPhoto->errCode); setPhoto->status = (setPhoto->errCode == 0) ? napi_ok : napi_generic_failure; @@ -1481,11 +1476,11 @@ void SetPhotoExecuteCB(napi_env env, void *data) void SetPhotoCompletedCB(napi_env env, napi_status status, void *data) { ACCOUNT_LOGI("napi_create_async_work complete"); - SetOAPhotoAsyncContext *setPhoto = (SetOAPhotoAsyncContext *)data; + SetOAPhotoAsyncContext *setPhoto = reinterpret_cast(data); napi_value setResult[RESULT_COUNT] = {0}; - setResult[PARAM0] = GetErrorCodeValue(env, setPhoto->errCode); - napi_get_undefined(env, &setResult[PARAM1]); - CBOrPromiseSetPhoto(env, setPhoto, setResult[PARAM0], setResult[PARAM1]); + setResult[PARAMZERO] = GetErrorCodeValue(env, setPhoto->errCode); + napi_get_undefined(env, &setResult[PARAMONE]); + CBOrPromiseSetPhoto(env, setPhoto, setResult[PARAMZERO], setResult[PARAMONE]); napi_delete_async_work(env, setPhoto->work); delete setPhoto; setPhoto = nullptr; @@ -1533,7 +1528,7 @@ void ParseParaQueryMaxNum(napi_env env, napi_callback_info cbInfo, QueryMaxNumAs void QueryMaxNumExecuteCB(napi_env env, void *data) { ACCOUNT_LOGI("napi_create_async_work running"); - QueryMaxNumAsyncContext *maxNum = (QueryMaxNumAsyncContext *)data; + QueryMaxNumAsyncContext *maxNum = reinterpret_cast(data); maxNum->errCode = OsAccountManager::QueryMaxOsAccountNumber(maxNum->maxOsAccountNumber); ACCOUNT_LOGI("errocde is %{public}d", maxNum->errCode); maxNum->status = (maxNum->errCode == 0) ? napi_ok : napi_generic_failure; @@ -1542,11 +1537,11 @@ void QueryMaxNumExecuteCB(napi_env env, void *data) void QueryMaxNumCompletedCB(napi_env env, napi_status status, void *data) { ACCOUNT_LOGI("napi_create_async_work complete"); - QueryMaxNumAsyncContext *maxNum = (QueryMaxNumAsyncContext *)data; + QueryMaxNumAsyncContext *maxNum = reinterpret_cast(data); napi_value queryResult[RESULT_COUNT] = {0}; - queryResult[PARAM0] = GetErrorCodeValue(env, maxNum->errCode); - napi_create_int32(env, maxNum->maxOsAccountNumber, &queryResult[PARAM1]); - CBOrPromiseMaxNum(env, maxNum, queryResult[PARAM0], queryResult[PARAM1]); + queryResult[PARAMZERO] = GetErrorCodeValue(env, maxNum->errCode); + napi_create_int32(env, maxNum->maxOsAccountNumber, &queryResult[PARAMONE]); + CBOrPromiseMaxNum(env, maxNum, queryResult[PARAMZERO], queryResult[PARAMONE]); napi_delete_async_work(env, maxNum->work); delete maxNum; maxNum = nullptr; @@ -1601,7 +1596,7 @@ napi_value ParseParaIsActived(napi_env env, napi_callback_info cbInfo, IsActived void IsActivedExecuteCB(napi_env env, void *data) { ACCOUNT_LOGI("napi_create_async_work running"); - IsActivedAsyncContext *isActived = (IsActivedAsyncContext *)data; + IsActivedAsyncContext *isActived = reinterpret_cast(data); isActived->errCode = OsAccountManager::IsOsAccountActived(isActived->id, isActived->isOsAccountActived); ACCOUNT_LOGI("errocde is %{public}d", isActived->errCode); isActived->status = (isActived->errCode == 0) ? napi_ok : napi_generic_failure; @@ -1610,11 +1605,11 @@ void IsActivedExecuteCB(napi_env env, void *data) void IsActivedCompletedCB(napi_env env, napi_status status, void *data) { ACCOUNT_LOGI("napi_create_async_work complete"); - IsActivedAsyncContext *isActived = (IsActivedAsyncContext *)data; + IsActivedAsyncContext *isActived = reinterpret_cast(data); napi_value result[RESULT_COUNT] = {0}; - result[PARAM0] = GetErrorCodeValue(env, isActived->errCode); - napi_get_boolean(env, isActived->isOsAccountActived, &result[PARAM1]); - CBOrPromiseIsActived(env, isActived, result[PARAM0], result[PARAM1]); + result[PARAMZERO] = GetErrorCodeValue(env, isActived->errCode); + napi_get_boolean(env, isActived->isOsAccountActived, &result[PARAMONE]); + CBOrPromiseIsActived(env, isActived, result[PARAMZERO], result[PARAMONE]); napi_delete_async_work(env, isActived->work); delete isActived; isActived = nullptr; @@ -1671,7 +1666,7 @@ napi_value ParseParaIsEnable(napi_env env, napi_callback_info cbInfo, IsConEnabl void IsEnableExecuteCB(napi_env env, void *data) { ACCOUNT_LOGI("napi_create_async_work running"); - IsConEnableAsyncContext *isEnable = (IsConEnableAsyncContext *)data; + IsConEnableAsyncContext *isEnable = reinterpret_cast(data); isEnable->errCode = OsAccountManager::IsOsAccountConstraintEnable(isEnable->id, isEnable->constraint, isEnable->isConsEnable); ACCOUNT_LOGI("errocde is %{public}d", isEnable->errCode); @@ -1681,11 +1676,11 @@ void IsEnableExecuteCB(napi_env env, void *data) void IsEnableCompletedCB(napi_env env, napi_status status, void *data) { ACCOUNT_LOGI("napi_create_async_work complete"); - IsConEnableAsyncContext *isEnable = (IsConEnableAsyncContext *)data; + IsConEnableAsyncContext *isEnable = reinterpret_cast(data); napi_value result[RESULT_COUNT] = {0}; - result[PARAM0] = GetErrorCodeValue(env, isEnable->errCode); - napi_get_boolean(env, isEnable->isConsEnable, &result[PARAM1]); - CBOrPromiseIsEnable(env, isEnable, result[PARAM0], result[PARAM1]); + result[PARAMZERO] = GetErrorCodeValue(env, isEnable->errCode); + napi_get_boolean(env, isEnable->isConsEnable, &result[PARAMONE]); + CBOrPromiseIsEnable(env, isEnable, result[PARAMZERO], result[PARAMONE]); napi_delete_async_work(env, isEnable->work); delete isEnable; isEnable = nullptr; @@ -1733,7 +1728,7 @@ void ParseParaGetType(napi_env env, napi_callback_info cbInfo, GetTypeAsyncConte void GetTypeExecuteCB(napi_env env, void *data) { ACCOUNT_LOGI("napi_create_async_work running"); - GetTypeAsyncContext *getType = (GetTypeAsyncContext *)data; + GetTypeAsyncContext *getType = reinterpret_cast(data); getType->errCode = OsAccountManager::GetOsAccountTypeFromProcess(getType->type); ACCOUNT_LOGI("errocde is %{public}d", getType->errCode); getType->status = (getType->errCode == 0) ? napi_ok : napi_generic_failure; @@ -1742,29 +1737,29 @@ void GetTypeExecuteCB(napi_env env, void *data) void GetTypeCompletedCB(napi_env env, napi_status status, void *data) { ACCOUNT_LOGI("napi_create_async_work complete"); - GetTypeAsyncContext *getType = (GetTypeAsyncContext *)data; + GetTypeAsyncContext *getType = reinterpret_cast(data); napi_value result[RESULT_COUNT] = {0}; napi_value jsType = nullptr; int cType = static_cast(getType->type); - result[PARAM0] = GetErrorCodeValue(env, getType->errCode); - napi_create_object(env, &result[PARAM1]); + result[PARAMZERO] = GetErrorCodeValue(env, getType->errCode); + napi_create_object(env, &result[PARAMONE]); napi_create_int32(env, cType, &jsType); switch (cType) { case PARAMZERO: - napi_set_named_property(env, result[PARAM1], "ADMIN", jsType); + napi_set_named_property(env, result[PARAMONE], "ADMIN", jsType); break; case PARAMONE: - napi_set_named_property(env, result[PARAM1], "NORMAL", jsType); + napi_set_named_property(env, result[PARAMONE], "NORMAL", jsType); break; case PARAMTWO: - napi_set_named_property(env, result[PARAM1], "GUEST", jsType); + napi_set_named_property(env, result[PARAMONE], "GUEST", jsType); break; default: ACCOUNT_LOGI("cType %{public}d is an invalid value", cType); break; } - CBOrPromiseGetType(env, getType, result[PARAM0], result[PARAM1]); + CBOrPromiseGetType(env, getType, result[PARAMZERO], result[PARAMONE]); napi_delete_async_work(env, getType->work); delete getType; getType = nullptr; @@ -1812,7 +1807,7 @@ void ParseParaIsMultiEn(napi_env env, napi_callback_info cbInfo, IsMultiEnAsyncC void IsMultiEnExecuteCB(napi_env env, void *data) { ACCOUNT_LOGI("napi_create_async_work running"); - IsMultiEnAsyncContext *multiEn = (IsMultiEnAsyncContext *)data; + IsMultiEnAsyncContext *multiEn = reinterpret_cast(data); multiEn->errCode = OsAccountManager::IsMultiOsAccountEnable(multiEn->isMultiOAEnable); ACCOUNT_LOGI("errocde is %{public}d", multiEn->errCode); multiEn->status = (multiEn->errCode == 0) ? napi_ok : napi_generic_failure; @@ -1821,11 +1816,11 @@ void IsMultiEnExecuteCB(napi_env env, void *data) void IsMultiEnCompletedCB(napi_env env, napi_status status, void *data) { ACCOUNT_LOGI("napi_create_async_work complete"); - IsMultiEnAsyncContext *multiEn = (IsMultiEnAsyncContext *)data; + IsMultiEnAsyncContext *multiEn = reinterpret_cast(data); napi_value result[RESULT_COUNT] = {0}; - result[PARAM0] = GetErrorCodeValue(env, multiEn->errCode); - napi_get_boolean(env, multiEn->isMultiOAEnable, &result[PARAM1]); - CBOrPromiseIsMultiEn(env, multiEn, result[PARAM0], result[PARAM1]); + result[PARAMZERO] = GetErrorCodeValue(env, multiEn->errCode); + napi_get_boolean(env, multiEn->isMultiOAEnable, &result[PARAMONE]); + CBOrPromiseIsMultiEn(env, multiEn, result[PARAMZERO], result[PARAMONE]); napi_delete_async_work(env, multiEn->work); delete multiEn; multiEn = nullptr; @@ -1883,7 +1878,7 @@ napi_value ParseParaIsVerified(napi_env env, napi_callback_info cbInfo, IsVerifi void IsVerifiedExecuteCB(napi_env env, void *data) { ACCOUNT_LOGI("napi_create_async_work running"); - IsVerifiedAsyncContext *isVerified = (IsVerifiedAsyncContext *)data; + IsVerifiedAsyncContext *isVerified = reinterpret_cast(data); isVerified->errCode = OsAccountManager::IsOsAccountVerified(isVerified->id, isVerified->isTestOA); ACCOUNT_LOGI("errocde is %{public}d", isVerified->errCode); isVerified->status = (isVerified->errCode == 0) ? napi_ok : napi_generic_failure; @@ -1892,11 +1887,11 @@ void IsVerifiedExecuteCB(napi_env env, void *data) void IsVerifiedCompletedCB(napi_env env, napi_status status, void *data) { ACCOUNT_LOGI("napi_create_async_work complete"); - IsVerifiedAsyncContext *isVerified = (IsVerifiedAsyncContext *)data; + IsVerifiedAsyncContext *isVerified = reinterpret_cast(data); napi_value result[RESULT_COUNT] = {0}; - result[PARAM0] = GetErrorCodeValue(env, isVerified->errCode); - napi_get_boolean(env, isVerified->isTestOA, &result[PARAM1]); - CBOrPromiseIsVerified(env, isVerified, result[PARAM0], result[PARAM1]); + result[PARAMZERO] = GetErrorCodeValue(env, isVerified->errCode); + napi_get_boolean(env, isVerified->isTestOA, &result[PARAMONE]); + CBOrPromiseIsVerified(env, isVerified, result[PARAMZERO], result[PARAMONE]); napi_delete_async_work(env, isVerified->work); delete isVerified; isVerified = nullptr; @@ -1951,7 +1946,7 @@ napi_value ParseParaSerialNumId(napi_env env, napi_callback_info cbInfo, GetSeri void SerialNumIdExecuteCB(napi_env env, void *data) { ACCOUNT_LOGI("napi_create_async_work running"); - GetSerialNumIdCBInfo *serialNumId = (GetSerialNumIdCBInfo *)data; + GetSerialNumIdCBInfo *serialNumId = reinterpret_cast(data); serialNumId->errCode = OsAccountManager::GetOsAccountLocalIdBySerialNumber(serialNumId->serialNumber, serialNumId->id); ACCOUNT_LOGI("errocde is %{public}d", serialNumId->errCode); @@ -1961,11 +1956,11 @@ void SerialNumIdExecuteCB(napi_env env, void *data) void SerialNumIdCompletedCB(napi_env env, napi_status status, void *data) { ACCOUNT_LOGI("napi_create_async_work complete"); - GetSerialNumIdCBInfo *serialNumId = (GetSerialNumIdCBInfo *)data; + GetSerialNumIdCBInfo *serialNumId = reinterpret_cast(data); napi_value result[RESULT_COUNT] = {0}; - result[PARAM0] = GetErrorCodeValue(env, serialNumId->errCode); - napi_create_int32(env, serialNumId->id, &result[PARAM1]); - CBOrPromiseSerialNum(env, serialNumId, result[PARAM0], result[PARAM1]); + result[PARAMZERO] = GetErrorCodeValue(env, serialNumId->errCode); + napi_create_int32(env, serialNumId->id, &result[PARAMONE]); + CBOrPromiseSerialNum(env, serialNumId, result[PARAMZERO], result[PARAMONE]); napi_delete_async_work(env, serialNumId->work); delete serialNumId; serialNumId = nullptr; @@ -2020,7 +2015,7 @@ napi_value ParseParaGetSerialNum(napi_env env, napi_callback_info cbInfo, GetSer void GetSerialNumExecuteCB(napi_env env, void *data) { ACCOUNT_LOGI("napi_create_async_work running"); - GetSerialNumForOAInfo *getSerialNum = (GetSerialNumForOAInfo *)data; + GetSerialNumForOAInfo *getSerialNum = reinterpret_cast(data); getSerialNum->errCode = OsAccountManager::GetSerialNumberByOsAccountLocalId(getSerialNum->id, getSerialNum->serialNum); ACCOUNT_LOGI("errocde is %{public}d", getSerialNum->errCode); @@ -2030,11 +2025,11 @@ void GetSerialNumExecuteCB(napi_env env, void *data) void GetSerialNumCompletedCB(napi_env env, napi_status status, void *data) { ACCOUNT_LOGI("napi_create_async_work complete"); - GetSerialNumForOAInfo *getSerialNum = (GetSerialNumForOAInfo *)data; + GetSerialNumForOAInfo *getSerialNum = reinterpret_cast(data); napi_value result[RESULT_COUNT] = {0}; - result[PARAM0] = GetErrorCodeValue(env, getSerialNum->errCode); - napi_create_int64(env, getSerialNum->serialNum, &result[PARAM1]); - CBOrPromiseGetSerialNum(env, getSerialNum, result[PARAM0], result[PARAM1]); + result[PARAMZERO] = GetErrorCodeValue(env, getSerialNum->errCode); + napi_create_int64(env, getSerialNum->serialNum, &result[PARAMONE]); + CBOrPromiseGetSerialNum(env, getSerialNum, result[PARAMZERO], result[PARAMONE]); napi_delete_async_work(env, getSerialNum->work); delete getSerialNum; getSerialNum = nullptr; @@ -2153,7 +2148,7 @@ napi_value ParseParaToSubscriber(const napi_env &env, const napi_value (&argv)[A void SubscribeExecuteCB(napi_env env, void *data) { ACCOUNT_LOGI("napi_create_async_work running"); - SubscribeCBInfo *subscribeCBInfo = (SubscribeCBInfo *)data; + SubscribeCBInfo *subscribeCBInfo = reinterpret_cast(data); subscribeCBInfo->subscriber->SetEnv(env); subscribeCBInfo->subscriber->SetCallbackRef(subscribeCBInfo->callbackRef); int errCode = OsAccountManager::SubscribeOsAccount(subscribeCBInfo->subscriber); @@ -2163,7 +2158,7 @@ void SubscribeExecuteCB(napi_env env, void *data) void SubscribeCompletedCB(napi_env env, napi_status status, void *data) { ACCOUNT_LOGI("napi_create_async_work complete."); - SubscribeCBInfo *subscribeCBInfo = (SubscribeCBInfo *)data; + SubscribeCBInfo *subscribeCBInfo = reinterpret_cast(data); napi_delete_async_work(env, subscribeCBInfo->work); } diff --git a/os_account.gni b/os_account.gni old mode 100755 new mode 100644 index 4ca6c08f3..2e632ddb6 --- a/os_account.gni +++ b/os_account.gni @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Huawei Device Co., Ltd. +# Copyright (c) 2021-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/sa_profile/200.xml b/sa_profile/200.xml old mode 100755 new mode 100644 index b803a4cec..fa6f42553 --- a/sa_profile/200.xml +++ b/sa_profile/200.xml @@ -1,5 +1,5 @@ -