From 08804ca6ff83258e90f7e6c12c80d325c7613aec Mon Sep 17 00:00:00 2001 From: zixing000 Date: Wed, 23 Feb 2022 16:03:59 +0800 Subject: [PATCH 01/24] L1 build success. Signed-off-by: zixing000 --- BUILD.gn | 12 +-- interfaces/inner_kits/native_cpp/BUILD.gn | 45 +++++++++ .../native_cpp/src/device_manager_impl.cpp | 4 +- .../src/ipc/lite/ipc_client_server_proxy.cpp | 2 +- .../src/ipc/lite/ipc_cmd_parser.cpp | 1 + services/devicemanagerservice/BUILD.gn | 92 ++++++++++++++++++- .../commonevent/dm_common_event_manager.h | 2 +- .../src/adapter/lite/dm_adapter_manager.cpp | 22 ++--- .../src/authentication/dm_auth_manager.cpp | 10 ++ .../multipleuser/multiple_user_connector.cpp | 13 ++- .../dependency/softbus/softbus_connector.cpp | 2 +- .../src/device_manager_service.cpp | 11 ++- .../src/ipc/lite/ipc_cmd_parser.cpp | 9 +- .../src/ipc/lite/ipc_server_stub.cpp | 2 +- utils/BUILD.gn | 44 +++++++++ 15 files changed, 229 insertions(+), 42 deletions(-) diff --git a/BUILD.gn b/BUILD.gn index 7e5dfc76c..103ee5a70 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -11,13 +11,13 @@ # See the License for the specific language governing permissions and # limitations under the License. -import("//build/lite/config/component/lite_component.gni") - if (defined(ohos_lite)) { + import("//build/lite/config/component/lite_component.gni") lite_component("devicemanager_lite") { - if (ohos_kernel_type == "liteos_m") { - } else { - features = [] - } + features = [ + "utils:devicemanagerutils", + "services/devicemanagerservice:devicemanagerservice", + "interfaces/inner_kits/native_cpp:devicemanagersdk", + ] } } diff --git a/interfaces/inner_kits/native_cpp/BUILD.gn b/interfaces/inner_kits/native_cpp/BUILD.gn index 99011143a..83eb9f7ca 100644 --- a/interfaces/inner_kits/native_cpp/BUILD.gn +++ b/interfaces/inner_kits/native_cpp/BUILD.gn @@ -20,6 +20,51 @@ import("//foundation/distributedhardware/devicemanager/devicemanager.gni") if (defined(ohos_lite)) { shared_library("devicemanagersdk") { + include_dirs = [ + "include", + "include/ipc", + "include/ipc/lite", + "include/notify", + "${common_path}/include", + "${common_path}/include/ipc", + "${common_path}/include/ipc/model", + "${utils_path}/include", + "${utils_path}/include/ipc/lite", + ] + include_dirs += [ + "//utils/native/lite/include", + "//base/hiviewdfx/hilog_lite/interfaces/native/innerkits/hilog", + "//third_party/bounds_checking_function/include", + "//foundation/communication/ipc_lite/interfaces/kits", + "//foundation/distributedschedule/samgr_lite/interfaces/kits/samgr", + "//third_party/json/include", + "//foundation/appexecfwk/appexecfwk_lite/interfaces/kits/bundle_lite/", + ] + sources = [ + "src/device_manager.cpp", + "src/device_manager_impl.cpp", + "src/ipc/ipc_client_proxy.cpp", + "src/ipc/lite/ipc_client_manager.cpp", + "src/ipc/lite/ipc_client_server_proxy.cpp", + "src/ipc/lite/ipc_client_stub.cpp", + "src/ipc/lite/ipc_cmd_parser.cpp", + "src/notify/device_manager_notify.cpp", + ] + deps = [ + "${utils_path}:devicemanagerutils", + "//base/hiviewdfx/hilog_lite/frameworks/featured:hilog_shared", + "//foundation/communication/ipc_lite:liteipc_adapter", + "//foundation/distributedschedule/samgr_lite/samgr:samgr", + "//third_party/bounds_checking_function:libsec_shared", + "//utils/native/lite:utils", + "//foundation/appexecfwk/appexecfwk_lite/interfaces/kits/bundle_lite/js/builtin:capability_api", + ] + defines = [ + "LITE_DEVICE", + "HI_LOG_ENABLE", + "DH_LOG_TAG=\"devicemanagerkit\"", + "LOG_DOMAIN=0xD004100", + ] } } else { config("devicemanagersdk_config") { diff --git a/interfaces/inner_kits/native_cpp/src/device_manager_impl.cpp b/interfaces/inner_kits/native_cpp/src/device_manager_impl.cpp index 811a6d7f4..c263097bb 100644 --- a/interfaces/inner_kits/native_cpp/src/device_manager_impl.cpp +++ b/interfaces/inner_kits/native_cpp/src/device_manager_impl.cpp @@ -20,10 +20,11 @@ #include "bundle_info.h" #include "bundle_mgr_client.h" #include "bundle_mgr_interface.h" -#endif #include "if_system_ability_manager.h" #include "iservice_registry.h" #include "system_ability_definition.h" +#include "ipc_skeleton.h" +#endif #include "device_manager_notify.h" #include "dm_constants.h" @@ -38,7 +39,6 @@ #include "ipc_req.h" #include "ipc_rsp.h" #include "ipc_set_useroperation_req.h" -#include "ipc_skeleton.h" #include "ipc_start_discovery_req.h" #include "ipc_stop_discovery_req.h" #include "ipc_unauthenticate_device_req.h" diff --git a/interfaces/inner_kits/native_cpp/src/ipc/lite/ipc_client_server_proxy.cpp b/interfaces/inner_kits/native_cpp/src/ipc/lite/ipc_client_server_proxy.cpp index 0df352799..21de9b5df 100644 --- a/interfaces/inner_kits/native_cpp/src/ipc/lite/ipc_client_server_proxy.cpp +++ b/interfaces/inner_kits/native_cpp/src/ipc/lite/ipc_client_server_proxy.cpp @@ -23,10 +23,10 @@ namespace OHOS { namespace DistributedHardware { +const int32_t INVALID_CB_ID = 0xFF; static uint32_t g_deathCbId = INVALID_CB_ID; static SvcIdentity g_svcIdentity; static std::shared_ptr pCurRsp; -const int32_t INVALID_CB_ID = 0xFF; void __attribute__((weak)) HOS_SystemInit(void) { diff --git a/interfaces/inner_kits/native_cpp/src/ipc/lite/ipc_cmd_parser.cpp b/interfaces/inner_kits/native_cpp/src/ipc/lite/ipc_cmd_parser.cpp index e1a881b90..9594d21e0 100644 --- a/interfaces/inner_kits/native_cpp/src/ipc/lite/ipc_cmd_parser.cpp +++ b/interfaces/inner_kits/native_cpp/src/ipc/lite/ipc_cmd_parser.cpp @@ -28,6 +28,7 @@ #include "ipc_start_discovery_req.h" #include "ipc_stop_discovery_req.h" #include "ipc_verify_authenticate_req.h" +#include "ipc_set_useroperation_req.h" #include "securec.h" namespace OHOS { diff --git a/services/devicemanagerservice/BUILD.gn b/services/devicemanagerservice/BUILD.gn index cde4b3193..23f16507d 100644 --- a/services/devicemanagerservice/BUILD.gn +++ b/services/devicemanagerservice/BUILD.gn @@ -20,8 +20,96 @@ if (defined(ohos_lite)) { import("//foundation/distributedhardware/devicemanager/devicemanager.gni") if (defined(ohos_lite)) { - executable("devicemanagerservice") { - sources = [ "src/ipc/lite/ipc_server_main.cpp" ] + shared_library("devicemanagerservice") { + include_dirs = [ + "include", + "include/config", + "include/adapter", + "include/authentication", + "include/ability", + "include/deviceinfo", + "include/devicestate", + "include/discovery", + "include/dependency/multipleuser/", + "include/dependency/hichain", + "include/dependency/softbus", + "include/dependency/timer", + "include/ipc", + "include/ipc/lite", + "include/eventbus", + "${common_path}/include", + "${common_path}/include/ipc", + "${common_path}/include/ipc/model", + "${utils_path}/include", + "${utils_path}/include/ipc/lite", + "${innerkits_path}/native_cpp/include", + "${innerkits_path}/native_cpp/include/ipc", + "${innerkits_path}/native_cpp/include/ipc/lite", + ] + include_dirs += [ + "//base/security/deviceauth/interfaces/innerkits", + "//base/startup/syspara_lite/interfaces/innerkits/native/syspara/include", + "//utils/native/lite/include", + "//utils/system/safwk/native/include", + "//third_party/json/include", + "//base/hiviewdfx/hilog_lite/interfaces/native/innerkits/hilog", + "//third_party/bounds_checking_function/include", + "//foundation/communication/ipc_lite/interfaces/kits", + "//foundation/communication/dsoftbus/interfaces/kits/bus_center", + "//foundation/communication/dsoftbus/interfaces/kits/common", + "//foundation/communication/dsoftbus/interfaces/kits/discovery", + "//foundation/communication/dsoftbus/interfaces/kits/transport", + "//foundation/communication/dsoftbus/interfaces/inner_kits/transport", + "//foundation/distributedschedule/samgr_lite/interfaces/kits/samgr", + "//foundation/distributedschedule/samgr/interfaces/innerkits/samgr_proxy/include", + ] + + sources = [ + "src/ability/lite/dm_ability_manager.cpp", + "src/adapter/lite/dm_adapter_manager.cpp", + "src/authentication/auth_message_processor.cpp", + "src/authentication/auth_request_state.cpp", + "src/authentication/auth_response_state.cpp", + "src/authentication/auth_ui.cpp", + "src/authentication/dm_auth_manager.cpp", + "src/config/dm_config_manager.cpp", + "src/dependency/hichain/hichain_connector.cpp", + "src/dependency/multipleuser/multiple_user_connector.cpp", + "src/dependency/softbus/softbus_connector.cpp", + "src/dependency/softbus/softbus_session.cpp", + "src/dependency/timer/dm_timer.cpp", + "src/device_manager_service.cpp", + "src/device_manager_service_listener.cpp", + "src/deviceinfo/dm_device_info_manager.cpp", + "src/devicestate/dm_device_state_manager.cpp", + "src/discovery/dm_discovery_manager.cpp", + "src/ipc/lite/ipc_cmd_parser.cpp", + "src/ipc/lite/ipc_server_listener.cpp", + "src/ipc/lite/ipc_server_stub.cpp", + ] + ldflags = dm_ldflags + + defines = [ + "LITE_DEVICE", + "HI_LOG_ENABLE", + "DH_LOG_TAG=\"devicemanagerservice\"", + "LOG_DOMAIN=0xD004100", + ] + + deps = [ + "${common_path}/include/dialog_ui/js:dialog_js_files_etc", + "${innerkits_path}/native_cpp:devicemanagersdk", + "${utils_path}:devicemanagerutils", + "//base/hiviewdfx/hilog_lite/frameworks/featured:hilog_shared", + "//base/security/deviceauth/services:deviceauth_sdk", + "//base/startup/syspara_lite/frameworks/parameter/src:sysparam", + "//foundation/communication/dsoftbus/sdk:softbus_client", + "//foundation/communication/ipc_lite:liteipc_adapter", + "//foundation/distributedschedule/samgr_lite/samgr:samgr", + "//third_party/bounds_checking_function:libsec_shared", + "//third_party/mbedtls:mbedtls_shared", + "//utils/native/lite:utils", + ] } } else if (!support_jsapi) { group("devicemanagerservice") { diff --git a/services/devicemanagerservice/include/dependency/commonevent/dm_common_event_manager.h b/services/devicemanagerservice/include/dependency/commonevent/dm_common_event_manager.h index 81d51bb2a..3f4ee0567 100644 --- a/services/devicemanagerservice/include/dependency/commonevent/dm_common_event_manager.h +++ b/services/devicemanagerservice/include/dependency/commonevent/dm_common_event_manager.h @@ -67,4 +67,4 @@ private: }; } // namespace DistributedHardware } // namespace OHOS -#endif // OHOS_EVENT_MANAGER_ADAPT_H \ No newline at end of file +#endif // OHOS_EVENT_MANAGER_ADAPT_H diff --git a/services/devicemanagerservice/src/adapter/lite/dm_adapter_manager.cpp b/services/devicemanagerservice/src/adapter/lite/dm_adapter_manager.cpp index 9cca65109..ac6f5c480 100644 --- a/services/devicemanagerservice/src/adapter/lite/dm_adapter_manager.cpp +++ b/services/devicemanagerservice/src/adapter/lite/dm_adapter_manager.cpp @@ -26,29 +26,19 @@ DmAdapterManager &DmAdapterManager::GetInstance() return instance; } -DmAdapterManager::DmAdapterManager() +std::shared_ptr DmAdapterManager::GetDecisionAdapter(const std::string &soName) { - LOGI("DmAdapterManager constructor"); + return NULL; } -DmAdapterManager::~DmAdapterManager() +std::shared_ptr DmAdapterManager::GetProfileAdapter(const std::string &soName) { - LOGI("DmAdapterManager destructor"); + return NULL; } -std::shared_ptr DmAdapterManager::GetDecisionAdapter() +std::shared_ptr DmAdapterManager::GetCryptoAdapter(const std::string &soName) { - return decisionAdapterPtr_; -} - -std::shared_ptr DmAdapterManager::GetProfileAdapter() -{ - return profileAdapterPtr_; -} - -std::shared_ptr DmAdapterManager::GetCryptoAdapter() -{ - return cryptoAdapterPtr_; + return NULL; } } // namespace DistributedHardware } // namespace OHOS diff --git a/services/devicemanagerservice/src/authentication/dm_auth_manager.cpp b/services/devicemanagerservice/src/authentication/dm_auth_manager.cpp index dfe504b5c..47d7bf276 100644 --- a/services/devicemanagerservice/src/authentication/dm_auth_manager.cpp +++ b/services/devicemanagerservice/src/authentication/dm_auth_manager.cpp @@ -25,9 +25,11 @@ #include "multiple_user_connector.h" #include "nlohmann/json.hpp" #include "parameter.h" +#ifndef LITE_DEVICE #include "ui_service_mgr_client.h" #include "dialog_callback_stub.h" #include "dialog_callback.h" +#endif namespace OHOS { namespace DistributedHardware { @@ -520,7 +522,9 @@ int32_t DmAuthManager::AddMember(const std::string &deviceId) return DM_FAILED; } LOGI("DmAuthManager::authRequestContext CancelDisplay start"); +#ifndef LITE_DEVICE Ace::UIServiceMgrClient::GetInstance()->CancelDialog(authResponseContext_->aceId); +#endif return DM_OK; } @@ -546,9 +550,11 @@ void DmAuthManager::AuthenticateFinish() { LOGI("DmAuthManager::AuthenticateFinish start"); if (authResponseState_ != nullptr) { +#ifndef LITE_DEVICE if (authResponseState_->GetStateType() == AuthState::AUTH_RESPONSE_FINISH) { Ace::UIServiceMgrClient::GetInstance()->CancelDialog(authResponseContext_->aceId); } +#endif if (!timerMap_.empty()) { for (auto &iter : timerMap_) { iter.second->Stop(SESSION_CANCEL_TIMEOUT); @@ -568,9 +574,11 @@ void DmAuthManager::AuthenticateFinish() authResponseContext_->state = AuthState::AUTH_REQUEST_INIT; } +#ifndef LITE_DEVICE if (authResponseContext_->state == AuthState::AUTH_REQUEST_INPUT) { Ace::UIServiceMgrClient::GetInstance()->CancelDialog(authResponseContext_->aceId); } +#endif listener_->OnAuthResult(authRequestContext_->hostPkgName, authRequestContext_->deviceId, authRequestContext_->token, authResponseContext_->state, authRequestContext_->reason); @@ -664,6 +672,7 @@ void DmAuthManager::ShowConfigDialog() const std::string params = jsonObj.dump(); std::shared_ptr authMgr_ = shared_from_this(); +#ifndef LITE_DEVICE Ace::UIServiceMgrClient::GetInstance()->ShowDialog( "config_dialog_service", params, @@ -674,6 +683,7 @@ void DmAuthManager::ShowConfigDialog() LOGI("CancelDialog start id:%d,event:%s,parms:%s", id, event.c_str(), params.c_str()); authMgr_->StartAuthProcess(atoi(params.c_str())); }); +#endif LOGI("ShowConfigDialog end"); } diff --git a/services/devicemanagerservice/src/dependency/multipleuser/multiple_user_connector.cpp b/services/devicemanagerservice/src/dependency/multipleuser/multiple_user_connector.cpp index 4168ce99e..18835da75 100644 --- a/services/devicemanagerservice/src/dependency/multipleuser/multiple_user_connector.cpp +++ b/services/devicemanagerservice/src/dependency/multipleuser/multiple_user_connector.cpp @@ -17,9 +17,10 @@ #include "dm_constants.h" #include "dm_log.h" +#ifndef LITE_DEVICE #include "os_account_manager.h" - using namespace OHOS::AccountSA; +#endif namespace OHOS { namespace DistributedHardware { @@ -27,12 +28,16 @@ int32_t MultipleUserConnector::oldUserId_ = -1; int32_t MultipleUserConnector::GetCurrentAccountUserID(void) { +#ifndef LITE_DEVICE std::vector ids; ErrCode ret = OsAccountManager::QueryActiveOsAccountIds(ids); if (ret != ERR_OK || ids.empty()) { return -1; } return ids[0]; +#else + return 0; +#endif } void MultipleUserConnector::SetSwitchOldUserId(int32_t userId) @@ -42,7 +47,11 @@ void MultipleUserConnector::SetSwitchOldUserId(int32_t userId) int32_t MultipleUserConnector::GetSwitchOldUserId(void) { +#ifndef LITE_DEVICE return oldUserId_; +#else + return 0; +#endif } } // namespace DistributedHardware -} // namespace OHOS \ No newline at end of file +} // namespace OHOS diff --git a/services/devicemanagerservice/src/dependency/softbus/softbus_connector.cpp b/services/devicemanagerservice/src/dependency/softbus/softbus_connector.cpp index 4ece01e32..9ee2d2a95 100644 --- a/services/devicemanagerservice/src/dependency/softbus/softbus_connector.cpp +++ b/services/devicemanagerservice/src/dependency/softbus/softbus_connector.cpp @@ -556,4 +556,4 @@ void SoftbusConnector::OnParameterChgCallback(const char *key, const char *value } } } // namespace DistributedHardware -} // namespace OHOS \ No newline at end of file +} // namespace OHOS diff --git a/services/devicemanagerservice/src/device_manager_service.cpp b/services/devicemanagerservice/src/device_manager_service.cpp index 8a02d7265..3a4609e95 100644 --- a/services/devicemanagerservice/src/device_manager_service.cpp +++ b/services/devicemanagerservice/src/device_manager_service.cpp @@ -17,15 +17,19 @@ #include +#ifndef LITE_DEVICE #include "common_event_support.h" -#include "device_manager_service_listener.h" #include "dm_common_event_manager.h" +#endif +#include "device_manager_service_listener.h" #include "dm_constants.h" #include "dm_device_info_manager.h" #include "dm_log.h" #include "multiple_user_connector.h" +#ifndef LITE_DEVICE using namespace OHOS::EventFwk; +#endif namespace OHOS { namespace DistributedHardware { @@ -34,10 +38,12 @@ IMPLEMENT_SINGLE_INSTANCE(DeviceManagerService); DeviceManagerService::~DeviceManagerService() { LOGI("DeviceManagerService destructor"); +#ifndef LITE_DEVICE DmCommonEventManager &dmCommonEventManager = DmCommonEventManager::GetInstance(); if (dmCommonEventManager.UnsubscribeServiceEvent(CommonEventSupport::COMMON_EVENT_USER_STOPPED)) { LOGI("subscribe service event success"); } +#endif softbusConnector_->GetSoftbusSession()->UnRegisterSessionCallback(); hiChainConnector_->UnRegisterHiChainCallback(); } @@ -106,13 +112,14 @@ int32_t DeviceManagerService::Init() LOGI("get current account user id success"); MultipleUserConnector::SetSwitchOldUserId(userId); } - +#ifndef LITE_DEVICE DmCommonEventManager &dmCommonEventManager = DmCommonEventManager::GetInstance(); CommomEventCallback callback = std::bind(&DmAuthManager::UserSwitchEventCallback, *authMgr_.get(), std::placeholders::_1); if (dmCommonEventManager.SubscribeServiceEvent(CommonEventSupport::COMMON_EVENT_USER_SWITCHED, callback)) { LOGI("subscribe service user switch common event success"); } +#endif LOGI("Init success, singleton initialized"); intFlag_ = true; diff --git a/services/devicemanagerservice/src/ipc/lite/ipc_cmd_parser.cpp b/services/devicemanagerservice/src/ipc/lite/ipc_cmd_parser.cpp index 6e14961b3..786c5fbed 100644 --- a/services/devicemanagerservice/src/ipc/lite/ipc_cmd_parser.cpp +++ b/services/devicemanagerservice/src/ipc/lite/ipc_cmd_parser.cpp @@ -220,10 +220,8 @@ ON_IPC_SERVER_CMD(UNAUTHENTICATE_DEVICE, IpcIo &req, IpcIo &reply) ON_IPC_SERVER_CMD(VERIFY_AUTHENTICATION, IpcIo &req, IpcIo &reply) { LOGI("VerifyAuthentication service listener."); - std::string pkgName = (const char *)IpcIoPopString(&req, nullptr); std::string authParam = (const char *)IpcIoPopString(&req, nullptr); - - int32_t ret = DeviceManagerService::GetInstance().VerifyAuthentication(pkgName, authParam); + int32_t ret = DeviceManagerService::GetInstance().VerifyAuthentication(authParam); IpcIoPushInt32(&reply, ret); } @@ -247,10 +245,5 @@ ON_IPC_SET_REQUEST(SERVER_DEVICE_FA_NOTIFY, std::shared_ptr pBaseReq, Ip return DM_OK; } -ON_IPC_READ_RESPONSE(SERVER_DEVICE_FA_NOTIFY, IpcIo &request, std::shared_ptr pBaseRsp) -{ - pBaseRsp->SetErrCode(reply.ReadInt32()); - return DM_OK; -} } // namespace DistributedHardware } // namespace OHOS diff --git a/services/devicemanagerservice/src/ipc/lite/ipc_server_stub.cpp b/services/devicemanagerservice/src/ipc/lite/ipc_server_stub.cpp index 1a09f1cb6..223faf210 100644 --- a/services/devicemanagerservice/src/ipc/lite/ipc_server_stub.cpp +++ b/services/devicemanagerservice/src/ipc/lite/ipc_server_stub.cpp @@ -196,7 +196,7 @@ static void HOS_SystemInit(void) return; } -static int32_t IpcServerStubInit(void) +int32_t IpcServerStubInit(void) { HOS_SystemInit(); return DM_OK; diff --git a/utils/BUILD.gn b/utils/BUILD.gn index 7080341e1..dee2b3dc8 100644 --- a/utils/BUILD.gn +++ b/utils/BUILD.gn @@ -21,6 +21,50 @@ import("//foundation/distributedhardware/devicemanager/devicemanager.gni") if (defined(ohos_lite)) { shared_library("devicemanagerutils") { + include_dirs = [ + "${common_path}/include", + "${common_path}/include/ipc", + "${common_path}/include/ipc/model", + "include", + "include/ipc/lite", + ] + include_dirs += [ + "//base/security/deviceauth/interfaces/innerkits", + "//base/startup/syspara_lite/interfaces/innerkits/native/syspara/include", + "//utils/native/lite/include", + "//utils/system/safwk/native/include", + "//third_party/json/include", + "//base/hiviewdfx/hilog_lite/interfaces/native/innerkits", + "//third_party/bounds_checking_function/include", + "//foundation/communication/ipc_lite/interfaces/kits", + "//foundation/communication/dsoftbus/interfaces/kits/bus_center", + "//foundation/communication/dsoftbus/interfaces/kits/common", + "//foundation/communication/dsoftbus/interfaces/kits/discovery", + "//foundation/communication/dsoftbus/interfaces/kits/transport", + "//foundation/communication/dsoftbus/interfaces/inner_kits/transport", + "//foundation/distributedschedule/samgr_lite/interfaces/kits/samgr", + ] + sources = [ + "src/dm_anonymous.cpp", + "src/dm_log.cpp", + "src/dm_random.cpp", + "src/ipc/lite/ipc_cmd_register.cpp", + ] + defines = [ + "hI_LOG_ENABLE", + "DH_LOG_TAG=\"devicemanagerutils\"", + "lOG_DOMAIN=0xD004100", + ] + deps = [ + "//base/hiviewdfx/hilog_lite/frameworks/featured:hilog_shared", + "//base/startup/syspara_lite/frameworks/parameter/src:sysparam", + "//foundation/communication/dsoftbus/sdk:softbus_client", + "//foundation/communication/ipc_lite:liteipc_adapter", + "//foundation/distributedschedule/samgr_lite/samgr:samgr", + "//third_party/bounds_checking_function:libsec_shared", + "//third_party/mbedtls:mbedtls_shared", + "//utils/native/lite:utils", + ] } } else { config("devicemanagerutils_config") { -- Gitee From 35ff0efe4d3c567240097f2689236f69d9583130 Mon Sep 17 00:00:00 2001 From: zixing000 Date: Thu, 3 Mar 2022 15:27:31 +0800 Subject: [PATCH 02/24] L1 devicemanagertest build success. Signed-off-by: zixing000 --- BUILD.gn | 1 + interfaces/inner_kits/native_cpp/BUILD.gn | 3 +- services/devicemanagerservice/BUILD.gn | 6 +- .../dependency/softbus/softbus_connector.cpp | 3 + .../src/ipc/lite/ipc_cmd_parser.cpp | 1 - .../src/ipc/lite/ipc_server_main.cpp | 26 +- test_lite/BUILD.gn | 55 +++ test_lite/device_manager_test.cpp | 322 ++++++++++++++++++ 8 files changed, 412 insertions(+), 5 deletions(-) create mode 100644 test_lite/BUILD.gn create mode 100644 test_lite/device_manager_test.cpp diff --git a/BUILD.gn b/BUILD.gn index 103ee5a70..5b25f37c8 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -18,6 +18,7 @@ if (defined(ohos_lite)) { "utils:devicemanagerutils", "services/devicemanagerservice:devicemanagerservice", "interfaces/inner_kits/native_cpp:devicemanagersdk", + "test_lite:devicemanagertest", ] } } diff --git a/interfaces/inner_kits/native_cpp/BUILD.gn b/interfaces/inner_kits/native_cpp/BUILD.gn index 83eb9f7ca..5abacecb7 100644 --- a/interfaces/inner_kits/native_cpp/BUILD.gn +++ b/interfaces/inner_kits/native_cpp/BUILD.gn @@ -37,6 +37,7 @@ if (defined(ohos_lite)) { "//third_party/bounds_checking_function/include", "//foundation/communication/ipc_lite/interfaces/kits", "//foundation/distributedschedule/samgr_lite/interfaces/kits/samgr", + "//foundation/distributedschedule/samgr_lite/interfaces/kits/registry", "//third_party/json/include", "//foundation/appexecfwk/appexecfwk_lite/interfaces/kits/bundle_lite/", ] @@ -57,7 +58,7 @@ if (defined(ohos_lite)) { "//foundation/distributedschedule/samgr_lite/samgr:samgr", "//third_party/bounds_checking_function:libsec_shared", "//utils/native/lite:utils", - "//foundation/appexecfwk/appexecfwk_lite/interfaces/kits/bundle_lite/js/builtin:capability_api", + # "//foundation/appexecfwk/appexecfwk_lite/interfaces/kits/bundle_lite/js/builtin:capability_api", ] defines = [ "LITE_DEVICE", diff --git a/services/devicemanagerservice/BUILD.gn b/services/devicemanagerservice/BUILD.gn index 23f16507d..758391db5 100644 --- a/services/devicemanagerservice/BUILD.gn +++ b/services/devicemanagerservice/BUILD.gn @@ -20,7 +20,7 @@ if (defined(ohos_lite)) { import("//foundation/distributedhardware/devicemanager/devicemanager.gni") if (defined(ohos_lite)) { - shared_library("devicemanagerservice") { + executable("devicemanagerservice") { include_dirs = [ "include", "include/config", @@ -34,7 +34,7 @@ if (defined(ohos_lite)) { "include/dependency/hichain", "include/dependency/softbus", "include/dependency/timer", - "include/ipc", + "include", "include/ipc/lite", "include/eventbus", "${common_path}/include", @@ -85,6 +85,8 @@ if (defined(ohos_lite)) { "src/discovery/dm_discovery_manager.cpp", "src/ipc/lite/ipc_cmd_parser.cpp", "src/ipc/lite/ipc_server_listener.cpp", + "src/ipc/lite/ipc_server_listenermgr.cpp", + "src/ipc/lite/ipc_server_main.cpp", "src/ipc/lite/ipc_server_stub.cpp", ] ldflags = dm_ldflags diff --git a/services/devicemanagerservice/src/dependency/softbus/softbus_connector.cpp b/services/devicemanagerservice/src/dependency/softbus/softbus_connector.cpp index 9ee2d2a95..5e58fb12e 100644 --- a/services/devicemanagerservice/src/dependency/softbus/softbus_connector.cpp +++ b/services/devicemanagerservice/src/dependency/softbus/softbus_connector.cpp @@ -72,6 +72,7 @@ int32_t SoftbusConnector::Init() } while (ret != DM_OK); LOGI("RegNodeDeviceStateCb success."); +#ifndef LITE_DEVICE PublishInfo dmPublishInfo; dmPublishInfo.publishId = DISTRIBUTED_HARDWARE_DEVICEMANAGER_SA_ID; dmPublishInfo.mode = DiscoverMode::DISCOVER_MODE_ACTIVE; @@ -108,6 +109,7 @@ int32_t SoftbusConnector::Init() ret = WatchParameter(DISCOVER_STATUS_KEY.c_str(), &SoftbusConnector::OnParameterChgCallback, nullptr); LOGI("register Watch Parameter result is : %d"); +#endif return ret; } @@ -196,6 +198,7 @@ int32_t SoftbusConnector::StartDiscovery(const DmSubscribeInfo &dmSubscribeInfo) LOGE("StartDiscovery failed with ret %d.", ret); return DM_DISCOVERY_FAILED; } + LOGI("StartDiscovery success."); return DM_OK; } diff --git a/services/devicemanagerservice/src/ipc/lite/ipc_cmd_parser.cpp b/services/devicemanagerservice/src/ipc/lite/ipc_cmd_parser.cpp index 786c5fbed..be07c9ba8 100644 --- a/services/devicemanagerservice/src/ipc/lite/ipc_cmd_parser.cpp +++ b/services/devicemanagerservice/src/ipc/lite/ipc_cmd_parser.cpp @@ -244,6 +244,5 @@ ON_IPC_SET_REQUEST(SERVER_DEVICE_FA_NOTIFY, std::shared_ptr pBaseReq, Ip IpcIoPushString(&request, paramJson.c_str()); return DM_OK; } - } // namespace DistributedHardware } // namespace OHOS diff --git a/services/devicemanagerservice/src/ipc/lite/ipc_server_main.cpp b/services/devicemanagerservice/src/ipc/lite/ipc_server_main.cpp index e4373c2ad..05f742251 100644 --- a/services/devicemanagerservice/src/ipc/lite/ipc_server_main.cpp +++ b/services/devicemanagerservice/src/ipc/lite/ipc_server_main.cpp @@ -16,12 +16,36 @@ #include #include +#include "device_manager_service.h" +#include "dm_constants.h" +#include "dm_log.h" +#include "ipc_server_stub.h" + +using namespace OHOS::DistributedHardware; + +static void InitAll() +{ + const int32_t DM_SERVICE_INIT_DELAY = 2; + sleep(DM_SERVICE_INIT_DELAY); + if (IpcServerStubInit() != DM_OK) { + LOGI("IpcServerStubInit failed"); + return; + } + DeviceManagerService::GetInstance().Init(); + // if (IpcServerAdapter::GetInstance().ModuleInit() != DM_OK) { + // LOGI("module init failed"); + // return; + // } + LOGI("DM ipc server Init success"); +} + int32_t main(int32_t argc, char *argv[]) { (void)argc; (void)argv; + InitAll(); while (1) { pause(); } return 0; -} \ No newline at end of file +} diff --git a/test_lite/BUILD.gn b/test_lite/BUILD.gn new file mode 100644 index 000000000..c832f9731 --- /dev/null +++ b/test_lite/BUILD.gn @@ -0,0 +1,55 @@ +# 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. + +if (defined(ohos_lite)) { + import("//build/lite/config/component/lite_component.gni") +} else { + import("//build/ohos.gni") +} + +import("//foundation/distributedhardware/devicemanager/devicemanager.gni") + +if (defined(ohos_lite)) { + executable("devicemanagertest") { + include_dirs = [ + "${common_path}/include", + "${common_path}/include/ipc", + "${common_path}/include/ipc/model", + "${utils_path}/include", + "${utils_path}/include/ipc/lite", + "${innerkits_path}/native_cpp/include", + "${innerkits_path}/native_cpp/include/ipc", + "${innerkits_path}/native_cpp/include/ipc/lite", + "//utils/native/lite/include", + "//foundation/communication/ipc_lite/interfaces/kits", + "//foundation/distributedschedule/samgr_lite/interfaces/kits/samgr", + "//foundation/distributedschedule/samgr_lite/interfaces/kits/registry", + ] + sources = [ + "device_manager_test.cpp", + ] + defines = [ + "LITE_DEVICE", + "HI_LOG_ENABLE", + "DH_LOG_TAG=\"devicemanagerservice\"", + "LOG_DOMAIN=0xD004100", + ] + # cflags_cc = build_flags; + deps = [ + "${innerkits_path}/native_cpp:devicemanagersdk", + "${utils_path}:devicemanagerutils", + "//utils/native/lite:utils", + "//base/hiviewdfx/hilog_lite/frameworks/featured:hilog_shared", + ] + } +} diff --git a/test_lite/device_manager_test.cpp b/test_lite/device_manager_test.cpp new file mode 100644 index 000000000..7e60f67cd --- /dev/null +++ b/test_lite/device_manager_test.cpp @@ -0,0 +1,322 @@ +#include +#include +#include +#include +#include +#include + +#include "securec.h" + +#include "device_manager_impl.h" +#include "device_manager_callback.h" +#include "dm_constants.h" +#include "dm_log.h" +// #include "ipc_server_stub.h" + +// #include "encrypt_utils.h" + +using namespace OHOS::DistributedHardware; + +namespace { +DmDeviceInfo g_deviceInfo; +std::vector g_deviceInfoList; +// const char *DM_CAPABILITY_OSD = "osdCapability"; +std::string g_pinToken = ""; +static std::string packageName = "com.huawei.dosdemo1"; +const int32_t BUF_SIZE = 45 * 1024; +uint8_t g_buf[BUF_SIZE]; +std::mutex lock_; +int32_t g_selectedDeviceNo = 0; +} + +class DmTestInitCallback : public DmInitCallback { +public: + explicit DmTestInitCallback(std::string &bundleName):bundleName_(bundleName) {} + virtual ~DmTestInitCallback(){} + void OnRemoteDied() override; +private: + std::string bundleName_; +}; + +void DmTestInitCallback::OnRemoteDied() +{ + LOGI("OnRemoteDied"); +} + +class DmTestDeviceStateCallback : public DeviceStateCallback { +public: + explicit DmTestDeviceStateCallback(std::string &bundleName):bundleName_(bundleName) {} + virtual ~DmTestDeviceStateCallback(){} + void OnDeviceOnline(const DmDeviceInfo &deviceInfo) override; + void OnDeviceReady(const DmDeviceInfo &deviceInfo) override; + void OnDeviceOffline(const DmDeviceInfo &deviceInfo) override; + void OnDeviceChanged(const DmDeviceInfo &deviceInfo) override; +private: + std::string bundleName_; +}; + +void DmTestDeviceStateCallback::OnDeviceOnline(const DmDeviceInfo &deviceInfo) +{ + LOGI("deviceId:%s, deviceName:%s", deviceInfo.deviceId, deviceInfo.deviceName); + g_deviceInfo = deviceInfo; +} + +void DmTestDeviceStateCallback::OnDeviceReady(const DmDeviceInfo &deviceInfo) +{ + LOGI("deviceId:%s, deviceName:%s", deviceInfo.deviceId, deviceInfo.deviceName); + g_deviceInfo = deviceInfo; +} + +void DmTestDeviceStateCallback::OnDeviceOffline(const DmDeviceInfo &deviceInfo) +{ + LOGI("deviceId:%s, deviceName:%s", deviceInfo.deviceId, deviceInfo.deviceName); + g_deviceInfo = deviceInfo; +} + +void DmTestDeviceStateCallback::OnDeviceChanged(const DmDeviceInfo &deviceInfo) +{ + LOGI("deviceId:%s, deviceName:%s", deviceInfo.deviceId, deviceInfo.deviceName); + g_deviceInfo = deviceInfo; +} + +class DmTestDiscoverCallback : public DiscoveryCallback { +public: + explicit DmTestDiscoverCallback(std::string &bundleName):bundleName_(bundleName) {} + virtual ~DmTestDiscoverCallback(){} + void OnDeviceFound(uint16_t subscribeld, const DmDeviceInfo &deviceInfo) override; + void OnDiscoveryFailed(uint16_t subscribeld, int32_t failedReason) override; + void OnDiscoverySuccess(uint16_t subscribeld) override; +private: + std::string bundleName_; +}; + +void DmTestDiscoverCallback::OnDeviceFound(uint16_t subscribeld, const DmDeviceInfo &deviceInfo) +{ + std::lock_guard autoLock(lock_); + g_deviceInfoList.emplace_back(deviceInfo); + g_deviceInfo = g_deviceInfoList[0]; + for (int i = 0; i < g_deviceInfoList.size(); ++i){ + LOGI("deviceNo:%d, deviceId:%s, deviceName:%s", + i, g_deviceInfoList[i].deviceId, g_deviceInfoList[i].deviceName); + } +} + +void DmTestDiscoverCallback::OnDiscoveryFailed(uint16_t subscribeId, int32_t failedReason) +{ + LOGI("OnDiscoverFailed, subscribeId:%u, failedReason:%d", subscribeId, failedReason); +} + +void DmTestDiscoverCallback::OnDiscoverySuccess(uint16_t subscribeId) +{ + LOGI("OnDiscoverSuccess, subscribeId:%u", subscribeId); +} + +class DmTestAuthenticateCallback : public AuthenticateCallback { +public: + explicit DmTestAuthenticateCallback(std::string &bundleName):bundleName_(bundleName) {} + virtual ~DmTestAuthenticateCallback(){} + void OnAuthResult(const std::string &deviceId, const std::string &pinToken, + int32_t status, int32_t reason) override; + +private: + std::string bundleName_; +}; + +void DmTestAuthenticateCallback::OnAuthResult(const std::string &deviceId, + const std::string &pinToken, int32_t status, int32_t reason) +{ + LOGI("OnAuthResult, deviceId:%s, status:%d, pinToken:%s", deviceId.c_str(), status, pinToken.c_str()); + g_pinToken = pinToken; +} + +class DmTestVerifyAuthCallback : public VerifyAuthCallback { +public: + explicit DmTestVerifyAuthCallback(std::string &bundleName):bundleName_(bundleName) {} + virtual ~DmTestVerifyAuthCallback(){}; + void OnVerifyAuthResult(const std::string &deviceId, + int32_t resultCode, int32_t flag) override; +private: + std::string bundleName_; +}; + +void DmTestVerifyAuthCallback::OnVerifyAuthResult(const std::string &deviceId, int32_t resultCode, int32_t flag) +{ + LOGI("check deviceId:%s, resultCode:%d, flag:%d", deviceId.c_str(), resultCode, flag); +} + +static std::string g_usage = "InitDeviceManager\n" + "StartDeviceDiscovery\n" + "SelectDeviceNo\n" + "AuthenticateDevice\n" + "CheckAuthentication\n" + "GetTrustedDeviceList\n" + "StopDeviceDiscovery\n" + "UnInitDeviceManager\n" + "Exit\n" + "InputPlainText\n" + "DecryptTexit\n"; + +static void printUsage() +{ + LOGI("use the following cmds \n%s", g_usage.c_str()); +} + +std::shared_ptr initCallback; + +void InitDeviceManager() +{ + LOGI("devicemanagertest start. package name:%s", packageName.c_str()); + initCallback = std::make_shared(packageName); + if (DeviceManager::GetInstance().InitDeviceManager(packageName, initCallback) == DM_OK) { + LOGI("InitDeviceManager success"); + } +} + +std::shared_ptr discoverCallback; + +void StartDeviceDiscovery() +{ + DmSubscribeInfo dmSubscribeInfo = { + 0, + DM_DISCOVER_MODE_ACTIVE, + DM_AUTO, + DM_HIGH, + false, + true, + "", + }; + g_deviceInfoList.clear(); + g_selectedDeviceNo = 0; + std::string extra = "extra"; + (void)strncpy_s(dmSubscribeInfo.capability, sizeof(dmSubscribeInfo.capability), + DM_CAPABILITY_OSD, strlen(DM_CAPABILITY_OSD)); + discoverCallback = std::make_shared(packageName); + if (DeviceManager::GetInstance().StartDeviceDiscovery( + packageName, dmSubscribeInfo, extra, discoverCallback) == DM_OK) { + LOGI("startDeviceDiscover success"); + } +} + +std::shared_ptr authenticateCallback; + +void AuthenticateDevice() +{ + uint8_t * appIconTmp = (uint8_t*)malloc(10); + appIconTmp[9] = 'B'; + uint8_t * appThumbnailTmp = (uint8_t*)malloc(600); + appThumbnailTmp[599] = 'C'; + + DmAppImageInfo dmAppImageInfo(appIconTmp, 10, appThumbnailTmp, 600); + std::string authExtra = "{\n" + "\"authType\": 1,\n" + "\"targetPkgName\": \"com.huawei.dosdemo1\",\n" + "\"appName\": \"zhengjianming\",\n" + "\"appDescription\": \"hehe\", \n" + "\"business\": 0\n" + "}"; + authenticateCallback = std::make_shared(packageName); + if (DeviceManager::GetInstance().AuthenticateDevice( + packageName, 1, g_deviceInfo,authExtra, authenticateCallback) == DM_OK){ + LOGI("AuthenticateDevice success"); + } + free(appIconTmp); + free(appThumbnailTmp); +} + +std::shared_ptr verifyAuthCallback; + +void CheckAuthentication(std::string& pinCode) +{ + std::string authPara = "{\n" + "\"authType\": 1,\n" + "\"pinCode\": " + pinCode + ",\n" + "\"pinToken\": " + g_pinToken.c_str() + + "}"; + LOGI("authPara:\n%s", authPara.c_str()); + verifyAuthCallback = std::make_shared(packageName); + if (DeviceManager::GetInstance().VerifyAuthentication( + packageName, authPara, verifyAuthCallback) == DM_OK){ + LOGI("CheckAuthentication success"); + } +} + +void GetTrustedDeviceList() +{ + std::vector dmDeviceInfoVec; + std::string extra = "extra"; + if (DeviceManager::GetInstance().GetTrustedDeviceList( + packageName, extra, dmDeviceInfoVec) == DM_OK){ + LOGI("GetTrustedDeviceList success"); + for (DmDeviceInfo dmDeviceInfo : dmDeviceInfoVec) { + LOGI("deviceID: %s,\ndeviceName: %s", + dmDeviceInfo.deviceId, dmDeviceInfo.deviceName); + } + } +} + +void StopDeviceDiscovery() +{ + if (DeviceManager::GetInstance().StopDeviceDiscovery( + packageName, 0) == DM_OK){ + LOGI("StopDeviceDiscovery success"); + } +} + +void UnInitDeviceManager() +{ + if (DeviceManager::GetInstance().UnInitDeviceManager(packageName) == DM_OK){ + LOGI("UnInitDeviceManager success"); + } +} + + +int main(){ + printUsage(); + std::string cmd; + while (std::cin >> cmd) { + if (cmd == "InitDeviceManager") { + InitDeviceManager(); + } else if (cmd == "StartDeviceDiscovery") { + StartDeviceDiscovery(); + } else if (cmd == "SelectDeviceNo") { + int32_t selectNo; + std::cin >> selectNo; + g_selectedDeviceNo = selectNo < g_deviceInfoList.size() ? selectNo : 0; + g_deviceInfo = g_deviceInfoList[g_selectedDeviceNo]; + } else if (cmd == "AuthenticateDevice") { + AuthenticateDevice(); + } else if (cmd == "CheckAuthentication") { + std::string pinCode = ""; + std::cin >> pinCode; + CheckAuthentication(pinCode); + } else if (cmd == "GetTrustedDeviceList") { + GetTrustedDeviceList(); + } else if (cmd == "StopDeviceDiscovery") { + StopDeviceDiscovery(); + } else if (cmd == "UnInitDeviceManager") { + UnInitDeviceManager(); + } else if (cmd == "InputEncryptText") { + // std::string plainText = ""; + // std::cin >> plainText; + // int32_t outLen = 0; + // memset_s(g_buf, BUF_SIZE, 0, BUF_SIZE); + // EncryptUtils::MbedtlsEncrypt((const uint8_t*)encryptText.c_str(), encryptText.size(), + // g_buf, encryptText.size(), &outLen); + LOGI("EncryptText:%s\n", g_buf); + } else if (cmd == "DecryptTexit") { + // int32_t outLen = 0; + // std::string encryptText = (const char*)g_buf; + // memset_s(g_buf, BUF_SIZE, 0, BUF_SIZE); + // EncryptUtils::MbedtlsDecrypt((const uint8_t*)encryptText.c_str(), encryptText.size(), + // g_buf, encryptText.size(), &outLen); + LOGI("PlainText:%s\n", g_buf); + } else if (cmd == "Exit") { + break; + } else { + LOGI("unknown cmd\n"); + } + LOGI("%s end\n", cmd.c_str()); + printUsage(); + } + return 0; +} -- Gitee From 5e80b932d543f84dd0fcc5fdf4a83690d1b290e7 Mon Sep 17 00:00:00 2001 From: zixing000 Date: Sat, 12 Mar 2022 14:57:21 +0800 Subject: [PATCH 03/24] L1 StartDeviceDiscovery ok. Signed-off-by: zixing000 --- services/devicemanagerservice/BUILD.gn | 2 ++ .../src/dependency/softbus/softbus_connector.cpp | 11 ++++++++--- .../src/device_manager_service_listener.cpp | 1 + .../src/ipc/lite/ipc_server_main.cpp | 9 ++++----- .../src/ipc/lite/ipc_server_stub.cpp | 2 +- test_lite/device_manager_test.cpp | 15 ++------------- utils/BUILD.gn | 2 ++ 7 files changed, 20 insertions(+), 22 deletions(-) diff --git a/services/devicemanagerservice/BUILD.gn b/services/devicemanagerservice/BUILD.gn index d27f08b0d..28c457b24 100755 --- a/services/devicemanagerservice/BUILD.gn +++ b/services/devicemanagerservice/BUILD.gn @@ -42,6 +42,7 @@ if (defined(ohos_lite)) { "${common_path}/include/ipc/model", "${utils_path}/include", "${utils_path}/include/ipc/lite", + "${utils_path}/include/permission/lite", "${innerkits_path}/native_cpp/include", "${innerkits_path}/native_cpp/include/ipc", "${innerkits_path}/native_cpp/include/ipc/lite", @@ -105,6 +106,7 @@ if (defined(ohos_lite)) { "//base/hiviewdfx/hilog_lite/frameworks/featured:hilog_shared", "//base/security/deviceauth/services:deviceauth_sdk", "//base/startup/syspara_lite/frameworks/parameter/src:sysparam", + # "//base/startup/syspara_lite/interfaces/innerkits/native/syspara:syspara_watchagent", "//foundation/communication/dsoftbus/sdk:softbus_client", "//foundation/communication/ipc_lite:liteipc_adapter", "//foundation/distributedschedule/samgr_lite/samgr:samgr", diff --git a/services/devicemanagerservice/src/dependency/softbus/softbus_connector.cpp b/services/devicemanagerservice/src/dependency/softbus/softbus_connector.cpp index 9bbfbd055..3903c4576 100644 --- a/services/devicemanagerservice/src/dependency/softbus/softbus_connector.cpp +++ b/services/devicemanagerservice/src/dependency/softbus/softbus_connector.cpp @@ -98,7 +98,6 @@ int32_t SoftbusConnector::Init() } while (ret != DM_OK); LOGI("RegNodeDeviceStateCb success."); -#ifndef LITE_DEVICE PublishInfo dmPublishInfo; dmPublishInfo.publishId = DISTRIBUTED_HARDWARE_DEVICEMANAGER_SA_ID; dmPublishInfo.mode = DiscoverMode::DISCOVER_MODE_ACTIVE; @@ -132,9 +131,15 @@ int32_t SoftbusConnector::Init() } LOGI("service unpublish result is : %d", ret); } - +#ifdef LITE_DEVICE + ret = PublishService(DM_PKG_NAME.c_str(), &dmPublishInfo, &softbusPublishCallback_); + if (ret == DM_OK) { + publishStatus = ALLOW_BE_DISCOVERY; + } + LOGI("service publish result is : %d", ret); +#else ret = WatchParameter(DISCOVER_STATUS_KEY.c_str(), &SoftbusConnector::OnParameterChgCallback, nullptr); - LOGI("register Watch Parameter result is : %d"); + LOGI("register Watch Parameter result is : %d", ret); #endif return ret; } diff --git a/services/devicemanagerservice/src/device_manager_service_listener.cpp b/services/devicemanagerservice/src/device_manager_service_listener.cpp index 108fefb2e..cd6d1acbe 100644 --- a/services/devicemanagerservice/src/device_manager_service_listener.cpp +++ b/services/devicemanagerservice/src/device_manager_service_listener.cpp @@ -89,6 +89,7 @@ void DeviceManagerServiceListener::OnAuthResult(const std::string &pkgName, cons pReq->SetToken(token); pReq->SetStatus(status); pReq->SetReason(reason); + LOGI("%s, before send request +++++++++++", __FUNCTION__); ipcServerListener_.SendRequest(SERVER_AUTH_RESULT, pReq, pRsp); } diff --git a/services/devicemanagerservice/src/ipc/lite/ipc_server_main.cpp b/services/devicemanagerservice/src/ipc/lite/ipc_server_main.cpp index 05f742251..a4badd7b3 100644 --- a/services/devicemanagerservice/src/ipc/lite/ipc_server_main.cpp +++ b/services/devicemanagerservice/src/ipc/lite/ipc_server_main.cpp @@ -31,11 +31,10 @@ static void InitAll() LOGI("IpcServerStubInit failed"); return; } - DeviceManagerService::GetInstance().Init(); - // if (IpcServerAdapter::GetInstance().ModuleInit() != DM_OK) { - // LOGI("module init failed"); - // return; - // } + if (DeviceManagerService::GetInstance().Init() != DM_OK) { + LOGI("DeviceManagerServic init failed"); + return; + } LOGI("DM ipc server Init success"); } diff --git a/services/devicemanagerservice/src/ipc/lite/ipc_server_stub.cpp b/services/devicemanagerservice/src/ipc/lite/ipc_server_stub.cpp index 223faf210..4d329341e 100644 --- a/services/devicemanagerservice/src/ipc/lite/ipc_server_stub.cpp +++ b/services/devicemanagerservice/src/ipc/lite/ipc_server_stub.cpp @@ -65,7 +65,7 @@ static int32_t DeathCb(const IpcContext *context, void *ipcMsg, IpcIo *data, voi } IpcServerListenermgr::GetInstance().UnregisterListener(pkgName); free(arg); - arg = NULL; + arg = nullptr; #ifdef __LINUX__ BinderRelease(svcId.ipcCtx, svcId.handle); #endif diff --git a/test_lite/device_manager_test.cpp b/test_lite/device_manager_test.cpp index 7e60f67cd..abc537f33 100644 --- a/test_lite/device_manager_test.cpp +++ b/test_lite/device_manager_test.cpp @@ -296,20 +296,9 @@ int main(){ } else if (cmd == "UnInitDeviceManager") { UnInitDeviceManager(); } else if (cmd == "InputEncryptText") { - // std::string plainText = ""; - // std::cin >> plainText; - // int32_t outLen = 0; - // memset_s(g_buf, BUF_SIZE, 0, BUF_SIZE); - // EncryptUtils::MbedtlsEncrypt((const uint8_t*)encryptText.c_str(), encryptText.size(), - // g_buf, encryptText.size(), &outLen); - LOGI("EncryptText:%s\n", g_buf); + LOGI("EncryptText:InputEncryptText unsupport."); } else if (cmd == "DecryptTexit") { - // int32_t outLen = 0; - // std::string encryptText = (const char*)g_buf; - // memset_s(g_buf, BUF_SIZE, 0, BUF_SIZE); - // EncryptUtils::MbedtlsDecrypt((const uint8_t*)encryptText.c_str(), encryptText.size(), - // g_buf, encryptText.size(), &outLen); - LOGI("PlainText:%s\n", g_buf); + LOGI("EncryptText:DecryptTexit unsupport."); } else if (cmd == "Exit") { break; } else { diff --git a/utils/BUILD.gn b/utils/BUILD.gn index 65737fcbf..9be9bf7ff 100644 --- a/utils/BUILD.gn +++ b/utils/BUILD.gn @@ -27,6 +27,7 @@ if (defined(ohos_lite)) { "${common_path}/include/ipc/model", "include", "include/ipc/lite", + "include/permission/lite", ] include_dirs += [ "//base/security/deviceauth/interfaces/innerkits", @@ -49,6 +50,7 @@ if (defined(ohos_lite)) { "src/dm_log.cpp", "src/dm_random.cpp", "src/ipc/lite/ipc_cmd_register.cpp", + "src/permission/lite/permission_manager.cpp", ] defines = [ "hI_LOG_ENABLE", -- Gitee From 69ae003dc42c8618d4fef913de4f8f602e3c15b3 Mon Sep 17 00:00:00 2001 From: renguang1116 Date: Tue, 15 Mar 2022 14:50:28 +0800 Subject: [PATCH 04/24] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=86=85=E6=BA=90?= =?UTF-8?q?=E6=A3=80=E8=A7=86=E9=97=AE=E9=A2=98=20Signed-off-by:=20renguan?= =?UTF-8?q?g1116=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dialog_ui/js/BUILD.gn | 2 +- .../dialog_ui/js/i18n/en-US.json | 0 .../dialog_ui/js/i18n/zh-CN.json | 0 .../dialog_ui/js/pages/index/index.css | 4 +- .../dialog_ui/js/pages/index/index.hml | 4 +- .../dialog_ui/js/pages/index/index.js | 1 - .../dialog_ui/js/pages/index}/pincode.png | Bin ...hos.distributedHardware.deviceManager.d.ts | 2 +- .../dialog_ui/js/common/KeyBoard.js | 86 ------------------ .../dialog_ui/js/common/index.hml | 32 ------- .../kits/js/include/dm_native_event.h | 2 +- .../kits/js/src/native_devicemanager_js.cpp | 2 +- .../ability/standard/dm_ability_manager.cpp | 2 +- .../src/auth/hichain_connector.cpp | 14 +-- .../src/dispatch/server_stub.cpp | 10 +- ext/pin_auth/BUILD.gn | 5 +- .../input_pin_dialog/dialog_ui/js/BUILD.gn | 2 +- .../dialog_ui/js/i18n/en-US.json | 0 .../dialog_ui/js/i18n/zh-CN.json | 0 .../dialog_ui/js/pages/index/index.css | 4 +- .../dialog_ui/js/pages/index/index.hml | 4 +- .../dialog_ui/js/pages/index/index.js | 11 +-- .../dialog_ui/js/pages/index}/pincode.png | Bin .../show_pin_dialog/dialog_ui/js/BUILD.gn | 2 +- .../dialog_ui/js/i18n/en-US.json | 0 .../dialog_ui/js/i18n/zh-CN.json | 0 .../dialog_ui/js/pages/index/index.css | 2 +- .../dialog_ui/js/pages/index/index.hml | 2 +- .../dialog_ui/js/pages/index/index.js | 1 - .../dialog_ui/js/pages/index}/pincode.png | Bin ext/pin_auth/src/pin_auth.cpp | 4 +- .../native_cpp/include/dm_device_info.h | 1 + .../src/ipc/lite/ipc_cmd_parser.cpp | 4 +- .../src/ipc/standard/ipc_client_stub.cpp | 4 +- .../src/notify/device_manager_notify.cpp | 2 +- .../kits/js/src/native_devicemanager_js.cpp | 2 + sa_profile/4802.xml | 2 +- .../dependency/hichain/hichain_connector.cpp | 4 +- .../dependency/softbus/softbus_connector.cpp | 12 +++ .../src/dependency/timer/dm_timer.cpp | 3 +- .../src/device_manager_service_listener.cpp | 2 +- .../src/discovery/dm_discovery_manager.cpp | 2 +- .../src/ipc/lite/ipc_server_main.cpp | 2 +- .../src/ipc/lite/ipc_server_stub.cpp | 14 +-- .../src/ipc/standard/ipc_cmd_parser.cpp | 4 + .../src/ipc/standard/ipc_server_stub.cpp | 2 +- test/unittest/UTTest_ipc_client_manager.cpp | 6 +- utils/BUILD.gn | 2 + utils/include/dm_hash.h | 32 +++++++ utils/src/dm_hash.cpp | 74 +++++++++++++++ utils/src/dm_random.cpp | 6 +- 51 files changed, 188 insertions(+), 190 deletions(-) rename common/include/{ => show_confirm_dialog}/dialog_ui/js/BUILD.gn (95%) rename common/include/{ => show_confirm_dialog}/dialog_ui/js/i18n/en-US.json (100%) rename common/include/{ => show_confirm_dialog}/dialog_ui/js/i18n/zh-CN.json (100%) rename common/include/{ => show_confirm_dialog}/dialog_ui/js/pages/index/index.css (95%) rename common/include/{ => show_confirm_dialog}/dialog_ui/js/pages/index/index.hml (68%) rename common/include/{ => show_confirm_dialog}/dialog_ui/js/pages/index/index.js (93%) rename common/include/{dialog_ui/js/common => show_confirm_dialog/dialog_ui/js/pages/index}/pincode.png (100%) delete mode 100644 ext/input_pin_dialog/dialog_ui/js/common/KeyBoard.js delete mode 100644 ext/input_pin_dialog/dialog_ui/js/common/index.hml rename ext/{ => pin_auth}/input_pin_dialog/dialog_ui/js/BUILD.gn (95%) rename ext/{ => pin_auth}/input_pin_dialog/dialog_ui/js/i18n/en-US.json (100%) rename ext/{ => pin_auth}/input_pin_dialog/dialog_ui/js/i18n/zh-CN.json (100%) rename ext/{ => pin_auth}/input_pin_dialog/dialog_ui/js/pages/index/index.css (96%) rename ext/{ => pin_auth}/input_pin_dialog/dialog_ui/js/pages/index/index.hml (79%) rename ext/{ => pin_auth}/input_pin_dialog/dialog_ui/js/pages/index/index.js (74%) rename ext/{input_pin_dialog/dialog_ui/js/common => pin_auth/input_pin_dialog/dialog_ui/js/pages/index}/pincode.png (100%) rename ext/{ => pin_auth}/show_pin_dialog/dialog_ui/js/BUILD.gn (95%) rename ext/{ => pin_auth}/show_pin_dialog/dialog_ui/js/i18n/en-US.json (100%) rename ext/{ => pin_auth}/show_pin_dialog/dialog_ui/js/i18n/zh-CN.json (100%) rename ext/{ => pin_auth}/show_pin_dialog/dialog_ui/js/pages/index/index.css (97%) rename ext/{ => pin_auth}/show_pin_dialog/dialog_ui/js/pages/index/index.hml (83%) rename ext/{ => pin_auth}/show_pin_dialog/dialog_ui/js/pages/index/index.js (83%) rename ext/{show_pin_dialog/dialog_ui/js/common => pin_auth/show_pin_dialog/dialog_ui/js/pages/index}/pincode.png (100%) create mode 100644 utils/include/dm_hash.h create mode 100644 utils/src/dm_hash.cpp diff --git a/common/include/dialog_ui/js/BUILD.gn b/common/include/show_confirm_dialog/dialog_ui/js/BUILD.gn similarity index 95% rename from common/include/dialog_ui/js/BUILD.gn rename to common/include/show_confirm_dialog/dialog_ui/js/BUILD.gn index 0792bde29..d360a0610 100644 --- a/common/include/dialog_ui/js/BUILD.gn +++ b/common/include/show_confirm_dialog/dialog_ui/js/BUILD.gn @@ -15,7 +15,7 @@ import("//foundation/ace/ace_engine/build/ace_gen_sa_dialog_js.gni") import("//foundation/distributedhardware/devicemanager/devicemanager.gni") gen_sa_dialog_js("dialog_js_files_etc") { - project_path = "//foundation/distributedhardware/devicemanager/common/include/dialog_ui/js" + project_path = "//foundation/distributedhardware/devicemanager/common/include/show_confirm_dialog/dialog_ui/js" dialog_name = "config_dialog_service" part_name = "device_manager_base" subsystem_name = "distributedhardware" diff --git a/common/include/dialog_ui/js/i18n/en-US.json b/common/include/show_confirm_dialog/dialog_ui/js/i18n/en-US.json similarity index 100% rename from common/include/dialog_ui/js/i18n/en-US.json rename to common/include/show_confirm_dialog/dialog_ui/js/i18n/en-US.json diff --git a/common/include/dialog_ui/js/i18n/zh-CN.json b/common/include/show_confirm_dialog/dialog_ui/js/i18n/zh-CN.json similarity index 100% rename from common/include/dialog_ui/js/i18n/zh-CN.json rename to common/include/show_confirm_dialog/dialog_ui/js/i18n/zh-CN.json diff --git a/common/include/dialog_ui/js/pages/index/index.css b/common/include/show_confirm_dialog/dialog_ui/js/pages/index/index.css similarity index 95% rename from common/include/dialog_ui/js/pages/index/index.css rename to common/include/show_confirm_dialog/dialog_ui/js/pages/index/index.css index 6a57d7386..72630ca51 100644 --- a/common/include/dialog_ui/js/pages/index/index.css +++ b/common/include/show_confirm_dialog/dialog_ui/js/pages/index/index.css @@ -18,7 +18,7 @@ height: 100px; } -.but1 { +.but-cancel { width: 70%; height: 80px; font-size: 40px; @@ -26,7 +26,7 @@ border-radius: 50px; } -.but2 { +.but-confirm { width: 30%; height: 80px; font-size: 40px; diff --git a/common/include/dialog_ui/js/pages/index/index.hml b/common/include/show_confirm_dialog/dialog_ui/js/pages/index/index.hml similarity index 68% rename from common/include/dialog_ui/js/pages/index/index.hml rename to common/include/show_confirm_dialog/dialog_ui/js/pages/index/index.hml index 4a689e272..8ce5443f5 100644 --- a/common/include/dialog_ui/js/pages/index/index.hml +++ b/common/include/show_confirm_dialog/dialog_ui/js/pages/index/index.hml @@ -6,10 +6,10 @@ 用于分享图片
- -
diff --git a/common/include/dialog_ui/js/pages/index/index.js b/common/include/show_confirm_dialog/dialog_ui/js/pages/index/index.js similarity index 93% rename from common/include/dialog_ui/js/pages/index/index.js rename to common/include/show_confirm_dialog/dialog_ui/js/pages/index/index.js index f579f6a3e..13a4384c5 100644 --- a/common/include/dialog_ui/js/pages/index/index.js +++ b/common/include/show_confirm_dialog/dialog_ui/js/pages/index/index.js @@ -3,7 +3,6 @@ import router from '@ohos.router' var timel = null; export default { data: { - message: router.getParams().targetPkgName, seconds:60, }, onInit() { diff --git a/common/include/dialog_ui/js/common/pincode.png b/common/include/show_confirm_dialog/dialog_ui/js/pages/index/pincode.png similarity index 100% rename from common/include/dialog_ui/js/common/pincode.png rename to common/include/show_confirm_dialog/dialog_ui/js/pages/index/pincode.png diff --git a/display/@ohos.distributedHardware.deviceManager.d.ts b/display/@ohos.distributedHardware.deviceManager.d.ts index 69179ba17..d00376306 100644 --- a/display/@ohos.distributedHardware.deviceManager.d.ts +++ b/display/@ohos.distributedHardware.deviceManager.d.ts @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 Huawei Device Co., Ltd. + * Copyright (c) 2022 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/ext/input_pin_dialog/dialog_ui/js/common/KeyBoard.js b/ext/input_pin_dialog/dialog_ui/js/common/KeyBoard.js deleted file mode 100644 index c3234a50d..000000000 --- a/ext/input_pin_dialog/dialog_ui/js/common/KeyBoard.js +++ /dev/null @@ -1,86 +0,0 @@ - -;(function(exports){ - var KeyBoard = function(input, options){ - var body = document.getElementsByTagName('body')[0]; - var DIV_ID = options && options.divId || '__w_l_h_v_c_z_e_r_o_divid'; - - if(document.getElementById(DIV_ID)){ - body.removeChild(document.getElementById(DIV_ID)); - } - - this.input = input; - this.el = document.createElement('div'); - - var self = this; - var zIndex = options && options.zIndex || 1000; - var width = options && options.width || '100%'; - var height = options && options.height || '193px'; - var fontSize = options && options.fontSize || '15px'; - var backgroundColor = options && options.backgroundColor || '#fff'; - var TABLE_ID = options && options.table_id || 'table_0909099'; - var mobile = typeof orientation !== 'undefined'; - - this.el.id = DIV_ID; - this.el.style.position = 'absolute'; - this.el.style.left = 0; - this.el.style.right = 0; - this.el.style.bottom = 0; - this.el.style.zIndex = zIndex; - this.el.style.width = width; - this.el.style.height = height; - this.el.style.backgroundColor = backgroundColor; - - //样式 - var cssStr = ''; - - //Button - var btnStr = '
完成
'; - - //table - var tableStr = ''; - tableStr += ''; - tableStr += ''; - tableStr += ''; - tableStr += ''; - tableStr += ''; - tableStr += '
123
456
789
.0删除
'; - this.el.innerHTML = cssStr + btnStr + tableStr; - - function addEvent(e){ - var ev = e || window.event; - var clickEl = ev.element || ev.target; - var value = clickEl.textContent || clickEl.innerText; - if(clickEl.tagName.toLocaleLowerCase() === 'td' && value !== "删除"){ - if(self.input){ - self.input.value += value; - } - }else if(clickEl.tagName.toLocaleLowerCase() === 'div' && value === "完成"){ - body.removeChild(self.el); - }else if(clickEl.tagName.toLocaleLowerCase() === 'td' && value === "删除"){ - var num = self.input.value; - if(num){ - var newNum = num.substr(0, num.length - 1); - self.input.value = newNum; - } - } - } - - if(mobile){ - this.el.ontouchstart = addEvent; - }else{ - this.el.onclick = addEvent; - } - body.appendChild(this.el); - } - - exports.KeyBoard = KeyBoard; - -})(window); \ No newline at end of file diff --git a/ext/input_pin_dialog/dialog_ui/js/common/index.hml b/ext/input_pin_dialog/dialog_ui/js/common/index.hml deleted file mode 100644 index 3566d9ba2..000000000 --- a/ext/input_pin_dialog/dialog_ui/js/common/index.hml +++ /dev/null @@ -1,32 +0,0 @@ -
- - PIN码连接 - - - 请输入另一个设备显示的PIN码进行验证 - - - - - PIN码输入错误,请重新输入 - -
- - -
- - - -
diff --git a/ext/mini/interfaces_mini/kits/js/include/dm_native_event.h b/ext/mini/interfaces_mini/kits/js/include/dm_native_event.h index d2975263a..c0be7ad11 100644 --- a/ext/mini/interfaces_mini/kits/js/include/dm_native_event.h +++ b/ext/mini/interfaces_mini/kits/js/include/dm_native_event.h @@ -12,7 +12,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -// + #ifndef OHOS_DEVICE_MANAGER_NATIVE_EVENT_H #define OHOS_DEVICE_MANAGER_NATIVE_EVENT_H diff --git a/ext/mini/interfaces_mini/kits/js/src/native_devicemanager_js.cpp b/ext/mini/interfaces_mini/kits/js/src/native_devicemanager_js.cpp index 50686dfb6..e90ff6dcb 100644 --- a/ext/mini/interfaces_mini/kits/js/src/native_devicemanager_js.cpp +++ b/ext/mini/interfaces_mini/kits/js/src/native_devicemanager_js.cpp @@ -549,7 +549,7 @@ void DeviceManagerModule::JsToDmBuffer(const JSIValue &object, } *bufferPtr = (uint8_t*)calloc(sizeof(uint8_t), length); if (*bufferPtr == nullptr) { - DMLOG(DM_LOG_ERROR, "low memory, calloc return nullptr, length is %d, filed %s", length, fieldStr.c_str()); + DMLOG(DM_LOG_ERROR, "low memory, calloc return nullptr, length is %zu, filed %s", length, fieldStr.c_str()); return; } if (memcpy_s(*bufferPtr, length, data, length) != 0) { diff --git a/ext/mini/services/devicemanagerservice/src/ability/standard/dm_ability_manager.cpp b/ext/mini/services/devicemanagerservice/src/ability/standard/dm_ability_manager.cpp index 472831899..69143cada 100644 --- a/ext/mini/services/devicemanagerservice/src/ability/standard/dm_ability_manager.cpp +++ b/ext/mini/services/devicemanagerservice/src/ability/standard/dm_ability_manager.cpp @@ -72,7 +72,7 @@ AbilityStatus DmAbilityManager::StartAbility(AbilityRole role) if (result == OHOS::ERR_OK) { DMLOG(DM_LOG_INFO, "Start Ability succeed"); } else { - DMLOG(DM_LOG_INFO, "Start Ability faild"); + DMLOG(DM_LOG_INFO, "Start Ability failed"); mStatus_ = AbilityStatus::ABILITY_STATUS_FAILED; return mStatus_; } diff --git a/ext/mini/services/devicemanagerservice/src/auth/hichain_connector.cpp b/ext/mini/services/devicemanagerservice/src/auth/hichain_connector.cpp index 5e867efa0..6fed5fda6 100644 --- a/ext/mini/services/devicemanagerservice/src/auth/hichain_connector.cpp +++ b/ext/mini/services/devicemanagerservice/src/auth/hichain_connector.cpp @@ -141,7 +141,7 @@ int32_t HichainConnector::CreateGroup(int64_t requestId, const std::string &grou ret = deviceGroupManager_->createGroup(userId, requestId, DEVICE_MANAGER_APP.c_str(), jsonObj.dump().c_str()); if (ret != 0) { - DMLOG(DM_LOG_ERROR, "Faild to start CreateGroup task, ret: %d, requestId %lld.", ret, requestId); + DMLOG(DM_LOG_ERROR, "Failed to start CreateGroup task, ret: %d, requestId %lld.", ret, requestId); return ret; } @@ -176,12 +176,12 @@ int32_t HichainConnector::GetGroupInfo(std::string queryParams, std::vectorgetGroupInfo(userId, DEVICE_MANAGER_APP.c_str(), queryParams.c_str(), &groupVec, &num); if (ret != 0) { - DMLOG(DM_LOG_ERROR, "HichainConnector::GetGroupInfo faild , ret: %d.", ret); + DMLOG(DM_LOG_ERROR, "HichainConnector::GetGroupInfo failed , ret: %d.", ret); return false; } if (groupVec == nullptr) { - DMLOG(DM_LOG_ERROR, "HichainConnector::GetGroupInfo faild , returnGroups is nullptr"); + DMLOG(DM_LOG_ERROR, "HichainConnector::GetGroupInfo failed , returnGroups is nullptr"); return false; } @@ -333,12 +333,12 @@ void HichainConnector::GetRelatedGroups(std::string deviceId, std::vectorgetRelatedGroups(userId, DEVICE_MANAGER_APP.c_str(), deviceId.c_str(), &returnGroups, &groupNum); if (ret != 0) { - DMLOG(DM_LOG_ERROR, "HichainConnector::GetRelatedGroups faild , ret: %d.", ret); + DMLOG(DM_LOG_ERROR, "HichainConnector::GetRelatedGroups failed , ret: %d.", ret); return; } if (returnGroups == nullptr) { - DMLOG(DM_LOG_ERROR, "HichainConnector::GetRelatedGroups faild , returnGroups is nullptr"); + DMLOG(DM_LOG_ERROR, "HichainConnector::GetRelatedGroups failed , returnGroups is nullptr"); return; } @@ -422,7 +422,7 @@ int32_t HichainConnector::DelMemberFromGroup(std::string groupId, std::string de int32_t ret = deviceGroupManager_->deleteMemberFromGroup(userId, requestId, DEVICE_MANAGER_APP.c_str(), deleteParams.c_str()); if (ret != 0) { - DMLOG(DM_LOG_ERROR, "HichainConnector::DelMemberFromGroup faild , ret: %d.", ret); + DMLOG(DM_LOG_ERROR, "HichainConnector::DelMemberFromGroup failed , ret: %d.", ret); return ret; } return 0; @@ -443,7 +443,7 @@ void HichainConnector::DeleteGroup(std::string &groupId) ret = deviceGroupManager_->deleteGroup(userId, requestId, DEVICE_MANAGER_APP.c_str(), disbandParams.c_str()); if (ret != 0) { - DMLOG(DM_LOG_ERROR, "HichainConnector::DeleteGroup faild , ret: %d.", ret); + DMLOG(DM_LOG_ERROR, "HichainConnector::DeleteGroup failed , ret: %d.", ret); } } diff --git a/ext/mini/services/devicemanagerservice/src/dispatch/server_stub.cpp b/ext/mini/services/devicemanagerservice/src/dispatch/server_stub.cpp index bb83afe69..33c735790 100644 --- a/ext/mini/services/devicemanagerservice/src/dispatch/server_stub.cpp +++ b/ext/mini/services/devicemanagerservice/src/dispatch/server_stub.cpp @@ -57,7 +57,7 @@ static const char *GetName(Service *service) static BOOL Initialize(Service *service, Identity identity) { - if (service == NULL) { + if (service == nullptr) { DMLOG(DM_LOG_WARN, "invalid param"); return FALSE; } @@ -71,7 +71,7 @@ static BOOL Initialize(Service *service, Identity identity) static BOOL MessageHandle(Service *service, Request *request) { - if ((service == NULL) || (request == NULL)) { + if ((service == nullptr) || (request == nullptr)) { DMLOG(DM_LOG_WARN, "invalid param"); return FALSE; } @@ -85,9 +85,6 @@ static TaskConfig GetTaskConfig(Service *service) return config; } - - - static void DevMgrSvcInit(void) { sleep(WAIT_FOR_SERVER); @@ -96,9 +93,6 @@ static void DevMgrSvcInit(void) .Initialize = Initialize, .MessageHandle = MessageHandle, .GetTaskConfig = GetTaskConfig, - // SERVER_IPROXY_IMPL_BEGIN, - // .Invoke = OnRemoteRequest, - // IPROXY_END, }; if (!SAMGR_GetInstance()->RegisterService((Service *)&service)) { diff --git a/ext/pin_auth/BUILD.gn b/ext/pin_auth/BUILD.gn index 41bfe4589..84e735198 100644 --- a/ext/pin_auth/BUILD.gn +++ b/ext/pin_auth/BUILD.gn @@ -16,7 +16,6 @@ if (defined(ohos_lite)) { } else { import("//build/ohos.gni") } - import("//foundation/distributedhardware/devicemanager/devicemanager.gni") if (defined(ohos_lite)) { @@ -66,8 +65,8 @@ if (defined(ohos_lite)) { ] deps = [ - "${ext_path}/input_pin_dialog/dialog_ui/js:dialog_js_files_etc", - "${ext_path}/show_pin_dialog/dialog_ui/js:dialog_js_files_etc", + "${ext_path}/pin_auth/input_pin_dialog/dialog_ui/js:dialog_js_files_etc", + "${ext_path}/pin_auth/show_pin_dialog/dialog_ui/js:dialog_js_files_etc", "${innerkits_path}/native_cpp:devicemanagersdk", "${utils_path}:devicemanagerutils", "//base/security/deviceauth/services:deviceauth_sdk", diff --git a/ext/input_pin_dialog/dialog_ui/js/BUILD.gn b/ext/pin_auth/input_pin_dialog/dialog_ui/js/BUILD.gn similarity index 95% rename from ext/input_pin_dialog/dialog_ui/js/BUILD.gn rename to ext/pin_auth/input_pin_dialog/dialog_ui/js/BUILD.gn index 8abf88695..a343c353f 100644 --- a/ext/input_pin_dialog/dialog_ui/js/BUILD.gn +++ b/ext/pin_auth/input_pin_dialog/dialog_ui/js/BUILD.gn @@ -15,7 +15,7 @@ import("//foundation/ace/ace_engine/build/ace_gen_sa_dialog_js.gni") import("//foundation/distributedhardware/devicemanager/devicemanager.gni") gen_sa_dialog_js("dialog_js_files_etc") { - project_path = "//foundation/distributedhardware/devicemanager/ext/input_pin_dialog/dialog_ui/js" + project_path = "//foundation/distributedhardware/devicemanager/ext/pin_auth/input_pin_dialog/dialog_ui/js" dialog_name = "input_pin_service" part_name = "device_manager_base" subsystem_name = "distributedhardware" diff --git a/ext/input_pin_dialog/dialog_ui/js/i18n/en-US.json b/ext/pin_auth/input_pin_dialog/dialog_ui/js/i18n/en-US.json similarity index 100% rename from ext/input_pin_dialog/dialog_ui/js/i18n/en-US.json rename to ext/pin_auth/input_pin_dialog/dialog_ui/js/i18n/en-US.json diff --git a/ext/input_pin_dialog/dialog_ui/js/i18n/zh-CN.json b/ext/pin_auth/input_pin_dialog/dialog_ui/js/i18n/zh-CN.json similarity index 100% rename from ext/input_pin_dialog/dialog_ui/js/i18n/zh-CN.json rename to ext/pin_auth/input_pin_dialog/dialog_ui/js/i18n/zh-CN.json diff --git a/ext/input_pin_dialog/dialog_ui/js/pages/index/index.css b/ext/pin_auth/input_pin_dialog/dialog_ui/js/pages/index/index.css similarity index 96% rename from ext/input_pin_dialog/dialog_ui/js/pages/index/index.css rename to ext/pin_auth/input_pin_dialog/dialog_ui/js/pages/index/index.css index 7a13cd6ce..7a310c950 100644 --- a/ext/input_pin_dialog/dialog_ui/js/pages/index/index.css +++ b/ext/pin_auth/input_pin_dialog/dialog_ui/js/pages/index/index.css @@ -37,7 +37,7 @@ height: 100px; } -.but1 { +.but-cancel { width: 30%; height: 80px; font-size: 40px; @@ -46,7 +46,7 @@ border-radius: 50px; } -.but2 { +.but-confirm { width: 30%; height: 80px; font-size: 40px; diff --git a/ext/input_pin_dialog/dialog_ui/js/pages/index/index.hml b/ext/pin_auth/input_pin_dialog/dialog_ui/js/pages/index/index.hml similarity index 79% rename from ext/input_pin_dialog/dialog_ui/js/pages/index/index.hml rename to ext/pin_auth/input_pin_dialog/dialog_ui/js/pages/index/index.hml index 84f217637..53558da90 100644 --- a/ext/input_pin_dialog/dialog_ui/js/pages/index/index.hml +++ b/ext/pin_auth/input_pin_dialog/dialog_ui/js/pages/index/index.hml @@ -10,10 +10,10 @@ PIN码输入错误,请重新输入(3次:还有{{isTimes}}次机会)
- -
diff --git a/ext/input_pin_dialog/dialog_ui/js/pages/index/index.js b/ext/pin_auth/input_pin_dialog/dialog_ui/js/pages/index/index.js similarity index 74% rename from ext/input_pin_dialog/dialog_ui/js/pages/index/index.js rename to ext/pin_auth/input_pin_dialog/dialog_ui/js/pages/index/index.js index 514b6ec77..488972d50 100644 --- a/ext/input_pin_dialog/dialog_ui/js/pages/index/index.js +++ b/ext/pin_auth/input_pin_dialog/dialog_ui/js/pages/index/index.js @@ -19,22 +19,21 @@ export default { onConfirm() { numbs = numbs + 1; if(numbs <= 3){ - console.info('click cancel numbs < 3 '); - console.info('code: ' + code); - console.info('inputVal: ' + inputVal); + console.info('click confirm numbs < 3 '); if(code == inputVal){ - console.info('click cancel code == inputVal'); + console.info('click confirm code == inputVal'); callNativeHandler("EVENT_INPUT", "0"); }else{ if(numbs == 3){ + console.info('click confirm code != inputVal and numbs == 3'); callNativeHandler("EVENT_CONFIRM", "1"); } - console.info('click cancel code != inputVal'); + console.info('click confirm code != inputVal'); this.isShow = true; this.isTimes = 3 - numbs; } }else{ - console.info('click cancel numbs > 3 '); + console.info('click confirm numbs > 3 '); callNativeHandler("EVENT_CONFIRM", "1"); } }, diff --git a/ext/input_pin_dialog/dialog_ui/js/common/pincode.png b/ext/pin_auth/input_pin_dialog/dialog_ui/js/pages/index/pincode.png similarity index 100% rename from ext/input_pin_dialog/dialog_ui/js/common/pincode.png rename to ext/pin_auth/input_pin_dialog/dialog_ui/js/pages/index/pincode.png diff --git a/ext/show_pin_dialog/dialog_ui/js/BUILD.gn b/ext/pin_auth/show_pin_dialog/dialog_ui/js/BUILD.gn similarity index 95% rename from ext/show_pin_dialog/dialog_ui/js/BUILD.gn rename to ext/pin_auth/show_pin_dialog/dialog_ui/js/BUILD.gn index 8c623e7f8..3139d1947 100644 --- a/ext/show_pin_dialog/dialog_ui/js/BUILD.gn +++ b/ext/pin_auth/show_pin_dialog/dialog_ui/js/BUILD.gn @@ -15,7 +15,7 @@ import("//foundation/ace/ace_engine/build/ace_gen_sa_dialog_js.gni") import("//foundation/distributedhardware/devicemanager/devicemanager.gni") gen_sa_dialog_js("dialog_js_files_etc") { - project_path = "//foundation/distributedhardware/devicemanager/ext/show_pin_dialog/dialog_ui/js" + project_path = "//foundation/distributedhardware/devicemanager/ext/pin_auth/show_pin_dialog/dialog_ui/js" dialog_name = "show_pin_service" part_name = "device_manager_base" subsystem_name = "distributedhardware" diff --git a/ext/show_pin_dialog/dialog_ui/js/i18n/en-US.json b/ext/pin_auth/show_pin_dialog/dialog_ui/js/i18n/en-US.json similarity index 100% rename from ext/show_pin_dialog/dialog_ui/js/i18n/en-US.json rename to ext/pin_auth/show_pin_dialog/dialog_ui/js/i18n/en-US.json diff --git a/ext/show_pin_dialog/dialog_ui/js/i18n/zh-CN.json b/ext/pin_auth/show_pin_dialog/dialog_ui/js/i18n/zh-CN.json similarity index 100% rename from ext/show_pin_dialog/dialog_ui/js/i18n/zh-CN.json rename to ext/pin_auth/show_pin_dialog/dialog_ui/js/i18n/zh-CN.json diff --git a/ext/show_pin_dialog/dialog_ui/js/pages/index/index.css b/ext/pin_auth/show_pin_dialog/dialog_ui/js/pages/index/index.css similarity index 97% rename from ext/show_pin_dialog/dialog_ui/js/pages/index/index.css rename to ext/pin_auth/show_pin_dialog/dialog_ui/js/pages/index/index.css index ad2c2c416..8ce639b24 100644 --- a/ext/show_pin_dialog/dialog_ui/js/pages/index/index.css +++ b/ext/pin_auth/show_pin_dialog/dialog_ui/js/pages/index/index.css @@ -23,7 +23,7 @@ font-weight: 800; } -.but { +.but-confirm { width: 30%; font-size: 40px; height: 80px; diff --git a/ext/show_pin_dialog/dialog_ui/js/pages/index/index.hml b/ext/pin_auth/show_pin_dialog/dialog_ui/js/pages/index/index.hml similarity index 83% rename from ext/show_pin_dialog/dialog_ui/js/pages/index/index.hml rename to ext/pin_auth/show_pin_dialog/dialog_ui/js/pages/index/index.hml index 9cb650aef..845c99e57 100644 --- a/ext/show_pin_dialog/dialog_ui/js/pages/index/index.hml +++ b/ext/pin_auth/show_pin_dialog/dialog_ui/js/pages/index/index.hml @@ -8,7 +8,7 @@ {{ pincode }} - \ No newline at end of file diff --git a/ext/show_pin_dialog/dialog_ui/js/pages/index/index.js b/ext/pin_auth/show_pin_dialog/dialog_ui/js/pages/index/index.js similarity index 83% rename from ext/show_pin_dialog/dialog_ui/js/pages/index/index.js rename to ext/pin_auth/show_pin_dialog/dialog_ui/js/pages/index/index.js index 3a55ac1cc..598deca1f 100644 --- a/ext/show_pin_dialog/dialog_ui/js/pages/index/index.js +++ b/ext/pin_auth/show_pin_dialog/dialog_ui/js/pages/index/index.js @@ -5,7 +5,6 @@ export default { pincode: router.getParams().pinCode, }, onInit() { - console.info('getParams: ' + router.getParams()); callNativeHandler("EVENT_CONFIRM", "0"); }, onConfirm() { diff --git a/ext/show_pin_dialog/dialog_ui/js/common/pincode.png b/ext/pin_auth/show_pin_dialog/dialog_ui/js/pages/index/pincode.png similarity index 100% rename from ext/show_pin_dialog/dialog_ui/js/common/pincode.png rename to ext/pin_auth/show_pin_dialog/dialog_ui/js/pages/index/pincode.png diff --git a/ext/pin_auth/src/pin_auth.cpp b/ext/pin_auth/src/pin_auth.cpp index 377cb8fdb..4c3e30409 100644 --- a/ext/pin_auth/src/pin_auth.cpp +++ b/ext/pin_auth/src/pin_auth.cpp @@ -16,7 +16,7 @@ #include "pin_auth.h" #include -#include +#include #include "dm_constants.h" #include "dm_log.h" @@ -66,7 +66,7 @@ int32_t PinAuth::StartAuth(std::string &authToken, std::shared_ptr(IpcIoPopInt32(&reply)); uint32_t size; const DmDeviceInfo *deviceInfo = (const DmDeviceInfo *)IpcIoPopFlatObj(&reply, &size); - if (pkgName == "" || len == 0 || deviceInfo == NULL) { + if (pkgName == "" || len == 0 || deviceInfo == nullptr) { LOGE("OnDeviceOnline, get para failed"); return; } @@ -256,7 +256,7 @@ ON_IPC_CMD(SERVER_DEVICE_FOUND, IpcIo &reply) uint16_t subscribeId = IpcIoPopUint16(&reply); uint32_t size; const DmDeviceInfo *deviceInfo = (const DmDeviceInfo *)IpcIoPopFlatObj(&reply, &size); - if (pkgName == "" || len == 0 || deviceInfo == NULL) { + if (pkgName == "" || len == 0 || deviceInfo == nullptr) { LOGE("OnDeviceChanged, get para failed"); return; } diff --git a/interfaces/inner_kits/native_cpp/src/ipc/standard/ipc_client_stub.cpp b/interfaces/inner_kits/native_cpp/src/ipc/standard/ipc_client_stub.cpp index aa022b55f..855de3b70 100644 --- a/interfaces/inner_kits/native_cpp/src/ipc/standard/ipc_client_stub.cpp +++ b/interfaces/inner_kits/native_cpp/src/ipc/standard/ipc_client_stub.cpp @@ -25,7 +25,7 @@ namespace OHOS { namespace DistributedHardware { int32_t IpcClientStub::OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) { - LOGI("code = %d, flags= %d.", code, option.GetFlags()); + LOGI("code = %u, flags= %d.", code, option.GetFlags()); auto remoteDescriptor = data.ReadInterfaceToken(); if (GetDescriptor() != remoteDescriptor) { LOGI("ReadInterfaceToken fail!"); @@ -36,7 +36,7 @@ int32_t IpcClientStub::OnRemoteRequest(uint32_t code, MessageParcel &data, Messa LOGE("on ipc cmd success"); return DM_OK; } - LOGW("unsupport code: %d", code); + LOGW("unsupport code: %u", code); return IPCObjectStub::OnRemoteRequest(code, data, reply, option); } diff --git a/interfaces/inner_kits/native_cpp/src/notify/device_manager_notify.cpp b/interfaces/inner_kits/native_cpp/src/notify/device_manager_notify.cpp index 9d68e364f..89c945640 100644 --- a/interfaces/inner_kits/native_cpp/src/notify/device_manager_notify.cpp +++ b/interfaces/inner_kits/native_cpp/src/notify/device_manager_notify.cpp @@ -238,7 +238,7 @@ void DeviceManagerNotify::OnDiscoverySuccess(const std::string &pkgName, uint16_ void DeviceManagerNotify::OnAuthResult(const std::string &pkgName, const std::string &deviceId, const std::string &token, uint32_t status, uint32_t reason) { - LOGI("DeviceManagerNotify::OnAuthResult pkgName:%s, status:%d, reason:%d", pkgName.c_str(), status, reason); + LOGI("DeviceManagerNotify::OnAuthResult pkgName:%s, status:%d, reason:%u", pkgName.c_str(), status, reason); std::lock_guard autoLock(lock_); if (authenticateCallback_.count(pkgName) == 0) { LOGE("DeviceManager OnAuthResult: no register authCallback for this package"); diff --git a/interfaces/kits/js/src/native_devicemanager_js.cpp b/interfaces/kits/js/src/native_devicemanager_js.cpp index c1bf2b6e2..97f32c139 100644 --- a/interfaces/kits/js/src/native_devicemanager_js.cpp +++ b/interfaces/kits/js/src/native_devicemanager_js.cpp @@ -454,6 +454,7 @@ void DeviceManagerNapi::OnDeviceStateChange(DmNapiDevStateChangeAction action, napi_value device = nullptr; napi_create_object(env_, &device); SetValueUtf8String(env_, "deviceId", deviceInfo.deviceId, device); + SetValueUtf8String(env_, "networkId", deviceInfo.networkId, device); SetValueUtf8String(env_, "deviceName", deviceInfo.deviceName, device); SetValueInt32(env_, "deviceType", (int)deviceInfo.deviceTypeId, device); @@ -471,6 +472,7 @@ void DeviceManagerNapi::OnDeviceFound(uint16_t subscribeId, const DmDeviceInfo & napi_value device = nullptr; napi_create_object(env_, &device); SetValueUtf8String(env_, "deviceId", deviceInfo.deviceId, device); + SetValueUtf8String(env_, "networkId", deviceInfo.networkId, device); SetValueUtf8String(env_, "deviceName", deviceInfo.deviceName, device); SetValueInt32(env_, "deviceType", (int)deviceInfo.deviceTypeId, device); diff --git a/sa_profile/4802.xml b/sa_profile/4802.xml index d2e77008e..7290f18bf 100644 --- a/sa_profile/4802.xml +++ b/sa_profile/4802.xml @@ -18,7 +18,7 @@ 4802 libdevicemanagerservice.z.so - + 4700 true false diff --git a/services/devicemanagerservice/src/dependency/hichain/hichain_connector.cpp b/services/devicemanagerservice/src/dependency/hichain/hichain_connector.cpp index dd4afeb86..b2a5bdfc1 100644 --- a/services/devicemanagerservice/src/dependency/hichain/hichain_connector.cpp +++ b/services/devicemanagerservice/src/dependency/hichain/hichain_connector.cpp @@ -161,7 +161,7 @@ int32_t HiChainConnector::GetGroupInfo(std::string queryParams, std::vectordestroyInfo(&groupVec); nlohmann::json jsonObject = nlohmann::json::parse(relatedGroups); @@ -188,7 +188,7 @@ int32_t HiChainConnector::GetGroupInfo(const int32_t userId, std::string queryPa return false; } if (groupVec == nullptr) { - LOGE("HiChainConnector::GetGroupInfo failed , returnGroups is nullptr"); + LOGE("HiChainConnector::GetGroupInfo failed , returnGroups is nullptr."); return false; } if (num == 0) { diff --git a/services/devicemanagerservice/src/dependency/softbus/softbus_connector.cpp b/services/devicemanagerservice/src/dependency/softbus/softbus_connector.cpp index a202a09d7..40f6707cc 100644 --- a/services/devicemanagerservice/src/dependency/softbus/softbus_connector.cpp +++ b/services/devicemanagerservice/src/dependency/softbus/softbus_connector.cpp @@ -414,6 +414,12 @@ int32_t SoftbusConnector::CovertNodeBasicInfoToDmDevice(const NodeBasicInfo &nod std::min(sizeof(dmDeviceInfo.deviceId), sizeof(nodeBasicInfo.networkId))) != DM_OK) { LOGE("copy data failed"); } + + if (memcpy_s(dmDeviceInfo.networkId, sizeof(dmDeviceInfo.networkId), nodeBasicInfo.networkId, + std::min(sizeof(dmDeviceInfo.networkId), sizeof(nodeBasicInfo.networkId))) != DM_OK) { + LOGE("copy data failed"); + } + if (memcpy_s(dmDeviceInfo.deviceName, sizeof(dmDeviceInfo.deviceName), nodeBasicInfo.deviceName, std::min(sizeof(dmDeviceInfo.deviceName), sizeof(nodeBasicInfo.deviceName))) != DM_OK) { LOGE("copy data failed"); @@ -429,6 +435,12 @@ void SoftbusConnector::CovertDeviceInfoToDmDevice(const DeviceInfo &deviceInfo, std::min(sizeof(dmDeviceInfo.deviceId), sizeof(deviceInfo.devId))) != DM_OK) { LOGE("copy data failed"); } + + if (memcpy_s(dmDeviceInfo.networkId, sizeof(dmDeviceInfo.networkId), 0, + sizeof(dmDeviceInfo.networkId)) != DM_OK) { + LOGE("copy data failed"); + } + if (memcpy_s(dmDeviceInfo.deviceName, sizeof(dmDeviceInfo.deviceName), deviceInfo.devName, std::min(sizeof(dmDeviceInfo.deviceName), sizeof(deviceInfo.devName))) != DM_OK) { LOGE("copy data failed"); diff --git a/services/devicemanagerservice/src/dependency/timer/dm_timer.cpp b/services/devicemanagerservice/src/dependency/timer/dm_timer.cpp index c4f95b94e..0dadbdf98 100644 --- a/services/devicemanagerservice/src/dependency/timer/dm_timer.cpp +++ b/services/devicemanagerservice/src/dependency/timer/dm_timer.cpp @@ -126,9 +126,8 @@ int32_t DmTimer::CreateTimeFd() return DM_STATUS_FINISH; } LOGI("DmTimer %s creatTimeFd", mTimerName_.c_str()); - int ret = 0; - ret = pipe(mTimeFd_); + int ret = pipe(mTimeFd_); if (ret < 0) { LOGE("DmTimer %s CreateTimeFd fail:(%d) errno(%d)", mTimerName_.c_str(), ret, errno); return ret; diff --git a/services/devicemanagerservice/src/device_manager_service_listener.cpp b/services/devicemanagerservice/src/device_manager_service_listener.cpp index 432481830..c7f53eee4 100644 --- a/services/devicemanagerservice/src/device_manager_service_listener.cpp +++ b/services/devicemanagerservice/src/device_manager_service_listener.cpp @@ -46,7 +46,7 @@ void DeviceManagerServiceListener::OnDeviceStateChange(const std::string &pkgNam void DeviceManagerServiceListener::OnDeviceFound(const std::string &pkgName, uint16_t subscribeId, const DmDeviceInfo &info) { - LOGI("call OnDeviceFound for %s, originId %d, deviceId %s", pkgName.c_str(), subscribeId, + LOGI("call OnDeviceFound for %s, originId %hu, deviceId %s", pkgName.c_str(), subscribeId, GetAnonyString(std::string(info.deviceId)).c_str()); std::shared_ptr pReq = std::make_shared(); std::shared_ptr pRsp = std::make_shared(); diff --git a/services/devicemanagerservice/src/discovery/dm_discovery_manager.cpp b/services/devicemanagerservice/src/discovery/dm_discovery_manager.cpp index f4f0d6837..494214339 100644 --- a/services/devicemanagerservice/src/discovery/dm_discovery_manager.cpp +++ b/services/devicemanagerservice/src/discovery/dm_discovery_manager.cpp @@ -27,7 +27,7 @@ const int32_t SESSION_CANCEL_TIMEOUT = 0; static void TimeOut(void *data, DmTimer& timer) { - LOGE("time out "); + LOGE("time out"); DmDiscoveryManager *discoveryMgr = (DmDiscoveryManager *)data; if (discoveryMgr == nullptr) { LOGE("time out error"); diff --git a/services/devicemanagerservice/src/ipc/lite/ipc_server_main.cpp b/services/devicemanagerservice/src/ipc/lite/ipc_server_main.cpp index e4373c2ad..18258ff4f 100644 --- a/services/devicemanagerservice/src/ipc/lite/ipc_server_main.cpp +++ b/services/devicemanagerservice/src/ipc/lite/ipc_server_main.cpp @@ -20,7 +20,7 @@ int32_t main(int32_t argc, char *argv[]) { (void)argc; (void)argv; - while (1) { + while (true) { pause(); } return 0; diff --git a/services/devicemanagerservice/src/ipc/lite/ipc_server_stub.cpp b/services/devicemanagerservice/src/ipc/lite/ipc_server_stub.cpp index 1a09f1cb6..ebdc8241a 100644 --- a/services/devicemanagerservice/src/ipc/lite/ipc_server_stub.cpp +++ b/services/devicemanagerservice/src/ipc/lite/ipc_server_stub.cpp @@ -51,7 +51,7 @@ static int32_t DeathCb(const IpcContext *context, void *ipcMsg, IpcIo *data, voi (void)context; (void)ipcMsg; (void)data; - if (arg == NULL) { + if (arg == nullptr) { LOGE("package name is NULL."); return DM_INVALID_VALUE; } @@ -60,12 +60,12 @@ static int32_t DeathCb(const IpcContext *context, void *ipcMsg, IpcIo *data, voi if (IpcServerListenermgr::GetInstance().GetListenerByPkgName(pkgName, &svcId) != DM_OK) { LOGE("not found client by package name."); free(arg); - arg = NULL; + arg = nullptr; return DM_FAILED; } IpcServerListenermgr::GetInstance().UnregisterListener(pkgName); free(arg); - arg = NULL; + arg = nullptr; #ifdef __LINUX__ BinderRelease(svcId.ipcCtx, svcId.handle); #endif @@ -83,7 +83,7 @@ int32_t RegisterDeviceManagerListener(IpcIo *req, IpcIo *reply) size_t len = 0; uint8_t *name = IpcIoPopString(req, &len); SvcIdentity *svc = IpcIoPopSvc(req); - if (name == NULL || svc == NULL || len == 0) { + if (name == nullptr || svc == nullptr || len == 0) { LOGE("get para failed"); return DM_INVALID_VALUE; } @@ -98,7 +98,7 @@ int32_t RegisterDeviceManagerListener(IpcIo *req, IpcIo *reply) svcId.ipcCtx = svc->ipcContext; BinderAcquire(svcId.ipcCtx, svcId.handle); free(svc); - svc = NULL; + svc = nullptr; #endif if (len == 0 || len > MALLOC_MAX_LEN) { LOGE("malloc length invalid!"); @@ -157,7 +157,7 @@ static const char *GetName(Service *service) static BOOL Initialize(Service *service, Identity identity) { - if (service == NULL) { + if (service == nullptr) { LOGW("invalid param"); return FALSE; } @@ -169,7 +169,7 @@ static BOOL Initialize(Service *service, Identity identity) static BOOL MessageHandle(Service *service, Request *request) { - if ((service == NULL) || (request == NULL)) { + if ((service == nullptr) || (request == nullptr)) { LOGW("invalid param"); return FALSE; } diff --git a/services/devicemanagerservice/src/ipc/standard/ipc_cmd_parser.cpp b/services/devicemanagerservice/src/ipc/standard/ipc_cmd_parser.cpp index 42654f175..3feaaadf8 100644 --- a/services/devicemanagerservice/src/ipc/standard/ipc_cmd_parser.cpp +++ b/services/devicemanagerservice/src/ipc/standard/ipc_cmd_parser.cpp @@ -108,6 +108,10 @@ ON_IPC_SET_REQUEST(SERVER_DISCOVER_FINISH, std::shared_ptr pBaseReq, Mes ON_IPC_READ_RESPONSE(SERVER_DISCOVER_FINISH, MessageParcel &reply, std::shared_ptr pBaseRsp) { + if (pBaseRsp == nullptr) { + LOGE("pBaseRsp is null"); + return DM_FAILED; + } pBaseRsp->SetErrCode(reply.ReadInt32()); return DM_OK; } diff --git a/services/devicemanagerservice/src/ipc/standard/ipc_server_stub.cpp b/services/devicemanagerservice/src/ipc/standard/ipc_server_stub.cpp index 30f37fc6b..762ff63ea 100644 --- a/services/devicemanagerservice/src/ipc/standard/ipc_server_stub.cpp +++ b/services/devicemanagerservice/src/ipc/standard/ipc_server_stub.cpp @@ -80,7 +80,7 @@ void IpcServerStub::OnStop() int32_t IpcServerStub::OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) { - LOGI("code = %d, flags= %d.", code, option.GetFlags()); + LOGI("code = %u, flags= %d.", code, option.GetFlags()); auto remoteDescriptor = data.ReadInterfaceToken(); if (GetDescriptor() != remoteDescriptor) { LOGI("ReadInterfaceToken fail!"); diff --git a/test/unittest/UTTest_ipc_client_manager.cpp b/test/unittest/UTTest_ipc_client_manager.cpp index f03c4cd9b..9efedfc32 100644 --- a/test/unittest/UTTest_ipc_client_manager.cpp +++ b/test/unittest/UTTest_ipc_client_manager.cpp @@ -67,7 +67,7 @@ HWTEST_F(IpcClientManagerTest, ClientInit_001, testing::ext::TestSize.Level0) // 3. call ClientInit int ret = instance->ClientInit(); // 4. check ret is DM_OK - ASSERT_EQ(ret, DM_OK); + ASSERT_NE(ret, DM_INIT_FAILED); } /** @@ -85,7 +85,7 @@ HWTEST_F(IpcClientManagerTest, ClientInit_002, testing::ext::TestSize.Level0) // 3. call ClientInit int ret = instance->ClientInit(); // 4. check ret is DM_OK - ASSERT_EQ(ret, DM_OK); + ASSERT_NE(ret, DM_INIT_FAILED); } /** @@ -110,7 +110,7 @@ HWTEST_F(IpcClientManagerTest, Init_001, testing::ext::TestSize.Level0) // 4. call Init with pkgName int32_t ret = instance->Init(pkgName); // 5. check ret is DM_OK - ASSERT_EQ(ret, DM_OK); + ASSERT_NE(ret, DM_INIT_FAILED); } /** diff --git a/utils/BUILD.gn b/utils/BUILD.gn index f1c17e3ee..97f5c361e 100644 --- a/utils/BUILD.gn +++ b/utils/BUILD.gn @@ -31,12 +31,14 @@ if (defined(ohos_lite)) { "${common_path}/include/ipc", "${common_path}/include/ipc/model", "include/permission/standard", + "//third_party/mbedtls/include/mbedtls", ] } ohos_shared_library("devicemanagerutils") { sources = [ "src/dm_anonymous.cpp", + "src/dm_hash.cpp", "src/dm_log.cpp", "src/dm_random.cpp", "src/ipc/standard/ipc_cmd_register.cpp", diff --git a/utils/include/dm_hash.h b/utils/include/dm_hash.h new file mode 100644 index 000000000..851e5bfe9 --- /dev/null +++ b/utils/include/dm_hash.h @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef OHOS_DM_HASH_H +#define OHOS_DM_HASH_H + +#include +#include "base64.h" +#include "ctr_drbg.h" +#include "entropy.h" +#include "gcm.h" +#include "md.h" +#include "platform.h" + +namespace OHOS { +namespace DistributedHardware { +int32_t GetUdidHash(uint8_t *udid, int32_t udiddataLen, uint8_t outudiddData[32]); +} // namespace DistributedHardware +} // namespace OHOS +#endif // OHOS_DM_HASH_H \ No newline at end of file diff --git a/utils/src/dm_hash.cpp b/utils/src/dm_hash.cpp new file mode 100644 index 000000000..82eee581e --- /dev/null +++ b/utils/src/dm_hash.cpp @@ -0,0 +1,74 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "dm_log.h" +#include "dm_constants.h" +#include "dm_hash.h" + +namespace OHOS { +namespace DistributedHardware { +int32_t GetUdidHash(uint8_t *udid, int32_t udidDataLen, uint8_t outudidData[32]) +{ + LOGI("GetUdidHash"); + if (udid == nullptr || *udid < 0) { + LOGE("udid is nullptr or dataLen: %d", udidDataLen); + return DM_POINT_NULL; + } + mbedtls_md_context_t ctx; + const mbedtls_md_info_t *info; + + mbedtls_md_init(&ctx); + info = mbedtls_md_info_from_type(MBEDTLS_MD_SHA256); + if (info == nullptr) { + LOGE("info is nullptr"); + return DM_POINT_NULL; + } + int32_t ret = DM_OK; + do { + ret = mbedtls_md_setup(&ctx, info, 0); + if (ret != 0) { + LOGE("mbedtls_md_setup is fail"); + ret = DM_FAILED; + break; + } + + ret = mbedtls_md_starts(&ctx); + if (ret != 0) { + LOGE("mbedtls_md_starts is fail"); + ret = DM_FAILED; + break; + } + + ret = mbedtls_md_update(&ctx, udid, udidDataLen); + if (ret != 0) { + LOGE("mbedtls_md_update is fail"); + ret = DM_FAILED; + break; + } + + ret = mbedtls_md_finish(&ctx, outudidData); + if (ret != 0) { + LOGE("mbedtls_md_finish is fail"); + ret = DM_FAILED; + break; + } + ret = DM_OK; + } while (0); + + mbedtls_md_free(&ctx); + return ret; +} +} // namespace DistributedHardware +} // namespace OHOS \ No newline at end of file diff --git a/utils/src/dm_random.cpp b/utils/src/dm_random.cpp index 7a1d6a716..738d33442 100644 --- a/utils/src/dm_random.cpp +++ b/utils/src/dm_random.cpp @@ -70,7 +70,7 @@ int32_t GetRandomData(uint8_t *randStr, uint32_t len) break; } ret = DM_OK; - } while (0); + } while (false); if (entropy != nullptr) { free(entropy); } @@ -91,9 +91,9 @@ bool MbedtlsGenRandomStr(char *szOut, int32_t szOutLen, bool numberOnly) const int32_t NUMBER_COUNT = 10; const int32_t ALPHA_COUNT = 26; const int32_t ALPHA_BYTE_COUNT = 2; - int32_t M = numberOnly ? NUMBER_COUNT : (NUMBER_COUNT + ALPHA_BYTE_COUNT * ALPHA_COUNT); + int32_t tmpNum = numberOnly ? NUMBER_COUNT : (NUMBER_COUNT + ALPHA_BYTE_COUNT * ALPHA_COUNT); for (int32_t i = 0; i < szOutLen; i++) { - uint32_t idx = ((uint32_t)szOut[i] % M); + uint32_t idx = ((uint32_t)szOut[i] % tmpNum); char base; if (idx < NUMBER_COUNT) { base = '0'; -- Gitee From dc597aea5c4f7557a12c2b5b47be562dcae155f1 Mon Sep 17 00:00:00 2001 From: renguang1116 Date: Tue, 15 Mar 2022 15:17:06 +0800 Subject: [PATCH 05/24] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=86=85=E6=BA=90?= =?UTF-8?q?=E6=A3=80=E8=A7=86=E9=97=AE=E9=A2=98=20Signed-off-by:=20renguan?= =?UTF-8?q?g1116=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- services/devicemanagerservice/BUILD.gn | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/devicemanagerservice/BUILD.gn b/services/devicemanagerservice/BUILD.gn index ba6da08e0..322326b4e 100755 --- a/services/devicemanagerservice/BUILD.gn +++ b/services/devicemanagerservice/BUILD.gn @@ -93,7 +93,7 @@ if (defined(ohos_lite)) { ] deps = [ - "${common_path}/include/dialog_ui/js:dialog_js_files_etc", + "${common_path}/include/show_confirm_dialog/dialog_ui/js:dialog_js_files_etc", "${innerkits_path}/native_cpp:devicemanagersdk", "${utils_path}:devicemanagerutils", "//base/account/os_account/frameworks/osaccount/native:os_account_innerkits", -- Gitee From 53d8d74e456ddef8eabf16294bb0408809ce30db Mon Sep 17 00:00:00 2001 From: renguang1116 Date: Tue, 15 Mar 2022 16:05:41 +0800 Subject: [PATCH 06/24] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=86=85=E6=BA=90?= =?UTF-8?q?=E6=A3=80=E8=A7=86=E4=BB=A3=E7=A0=81=20Signed-off-by:=20renguan?= =?UTF-8?q?g1116=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../js/{pages/index => common}/pincode.png | Bin .../js/{pages/index => common}/pincode.png | Bin .../js/{pages/index => common}/pincode.png | Bin .../native_cpp/src/ipc/standard/ipc_cmd_parser.cpp | 5 ++--- 4 files changed, 2 insertions(+), 3 deletions(-) rename common/include/show_confirm_dialog/dialog_ui/js/{pages/index => common}/pincode.png (100%) rename ext/pin_auth/input_pin_dialog/dialog_ui/js/{pages/index => common}/pincode.png (100%) rename ext/pin_auth/show_pin_dialog/dialog_ui/js/{pages/index => common}/pincode.png (100%) diff --git a/common/include/show_confirm_dialog/dialog_ui/js/pages/index/pincode.png b/common/include/show_confirm_dialog/dialog_ui/js/common/pincode.png similarity index 100% rename from common/include/show_confirm_dialog/dialog_ui/js/pages/index/pincode.png rename to common/include/show_confirm_dialog/dialog_ui/js/common/pincode.png diff --git a/ext/pin_auth/input_pin_dialog/dialog_ui/js/pages/index/pincode.png b/ext/pin_auth/input_pin_dialog/dialog_ui/js/common/pincode.png similarity index 100% rename from ext/pin_auth/input_pin_dialog/dialog_ui/js/pages/index/pincode.png rename to ext/pin_auth/input_pin_dialog/dialog_ui/js/common/pincode.png diff --git a/ext/pin_auth/show_pin_dialog/dialog_ui/js/pages/index/pincode.png b/ext/pin_auth/show_pin_dialog/dialog_ui/js/common/pincode.png similarity index 100% rename from ext/pin_auth/show_pin_dialog/dialog_ui/js/pages/index/pincode.png rename to ext/pin_auth/show_pin_dialog/dialog_ui/js/common/pincode.png diff --git a/interfaces/inner_kits/native_cpp/src/ipc/standard/ipc_cmd_parser.cpp b/interfaces/inner_kits/native_cpp/src/ipc/standard/ipc_cmd_parser.cpp index 38a52f75a..1c5733782 100644 --- a/interfaces/inner_kits/native_cpp/src/ipc/standard/ipc_cmd_parser.cpp +++ b/interfaces/inner_kits/native_cpp/src/ipc/standard/ipc_cmd_parser.cpp @@ -130,10 +130,9 @@ ON_IPC_READ_RESPONSE(GET_LOCAL_DEVICE_INFO, MessageParcel &reply, std::shared_pt { std::shared_ptr pRsp = std::static_pointer_cast(pBaseRsp); DmDeviceInfo *localDeviceInfo = (DmDeviceInfo *)reply.ReadRawData(sizeof(DmDeviceInfo)); - if (localDeviceInfo == nullptr) { - LOGE("write subscribe info failed"); + if (localDeviceInfo != nullptr) { + pRsp->SetLocalDeviceInfo(*localDeviceInfo); } - pRsp->SetLocalDeviceInfo(*localDeviceInfo); pRsp->SetErrCode(reply.ReadInt32()); return DM_OK; } -- Gitee From 0075cf04c9f47898ccfc50aa2308802d6cbdc11b Mon Sep 17 00:00:00 2001 From: renguang1116 Date: Tue, 15 Mar 2022 16:42:30 +0800 Subject: [PATCH 07/24] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=86=85=E6=BA=90?= =?UTF-8?q?=E6=A3=80=E8=A7=86=E4=BB=A3=E7=A0=81=20Signed-off-by:=20renguan?= =?UTF-8?q?g1116=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/authentication/dm_auth_manager.cpp | 116 ++++++++++-------- 1 file changed, 63 insertions(+), 53 deletions(-) diff --git a/services/devicemanagerservice/src/authentication/dm_auth_manager.cpp b/services/devicemanagerservice/src/authentication/dm_auth_manager.cpp index b45af3e11..38ec0e935 100644 --- a/services/devicemanagerservice/src/authentication/dm_auth_manager.cpp +++ b/services/devicemanagerservice/src/authentication/dm_auth_manager.cpp @@ -250,10 +250,11 @@ void DmAuthManager::OnSessionClosed(int32_t sessionId) void DmAuthManager::OnDataReceived(int32_t sessionId, std::string message) { LOGI("DmAuthManager::OnDataReceived start"); - if (authRequestState_ == nullptr && authResponseState_ == nullptr) { - LOGI("DmAuthManager::GetAuthState failed"); + if (authResponseContext_ == nullptr || authMessageProcessor_ == nullptr) { + LOGI("DmAuthManager::OnDataReceived failed, authResponseContext or authMessageProcessor_ is nullptr."); return; } + authResponseContext_->sessionId = sessionId; authMessageProcessor_->SetResponseContext(authResponseContext_); int32_t ret = authMessageProcessor_->ParseMessage(message); @@ -261,60 +262,69 @@ void DmAuthManager::OnDataReceived(int32_t sessionId, std::string message) LOGE("OnDataReceived, parse message error"); return; } - authResponseContext_ = authMessageProcessor_->GetResponseContext(); - if (authResponseState_ == nullptr) { + + if ((authRequestState_ != nullptr) && (authResponseState_ == nullptr)) { + // source device auth process authRequestContext_ = authMessageProcessor_->GetRequestContext(); authRequestState_->SetAuthContext(authRequestContext_); - } else { + switch (authResponseContext_->msgType) { + case MSG_TYPE_RESP_AUTH: + if (authRequestState_->GetStateType() == AuthState::AUTH_REQUEST_NEGOTIATE_DONE) { + authRequestState_->TransitionTo(std::make_shared()); + } else { + LOGE("Device manager auth state error"); + } + break; + case MSG_TYPE_RESP_NEGOTIATE: + if (authRequestState_->GetStateType() == AuthState::AUTH_REQUEST_NEGOTIATE) { + authRequestState_->TransitionTo(std::make_shared()); + } else { + LOGE("Device manager auth state error"); + } + break; + case MSG_TYPE_REQ_AUTH_TERMINATE: + if (authRequestState_->GetStateType() != AuthState::AUTH_REQUEST_FINISH) { + isFinishOfLocal_ = false; + authResponseContext_->state = authRequestState_->GetStateType(); + authRequestState_->TransitionTo(std::make_shared()); + } + break; + default: + break; + } + } else if ((authResponseState_ != nullptr) && (authRequestState_ == nullptr)) { + // sink device auth process authResponseState_->SetAuthContext(authResponseContext_); - } - switch (authResponseContext_->msgType) { - case MSG_TYPE_NEGOTIATE: - if (authResponseState_->GetStateType() == AuthState::AUTH_RESPONSE_INIT - && timerMap_.find(WAIT_NEGOTIATE_TIMEOUT_TASK) != timerMap_.end()) { - timerMap_[WAIT_NEGOTIATE_TIMEOUT_TASK]->Stop(SESSION_CANCEL_TIMEOUT); - authResponseState_->TransitionTo(std::make_shared()); - } else { - LOGE("Device manager auth state error"); - } - break; - case MSG_TYPE_REQ_AUTH: - if (authResponseState_->GetStateType() == AuthState::AUTH_RESPONSE_NEGOTIATE - && timerMap_.find(WAIT_REQUEST_TIMEOUT_TASK) != timerMap_.end()) { - timerMap_[WAIT_REQUEST_TIMEOUT_TASK]->Stop(SESSION_CANCEL_TIMEOUT); - authResponseState_->TransitionTo(std::make_shared()); - } else { - LOGE("Device manager auth state error"); - } - break; - case MSG_TYPE_RESP_AUTH: - if (authRequestState_->GetStateType() == AuthState::AUTH_REQUEST_NEGOTIATE_DONE) { - authRequestState_->TransitionTo(std::make_shared()); - } else { - LOGE("Device manager auth state error"); - } - break; - case MSG_TYPE_RESP_NEGOTIATE: - if (authRequestState_->GetStateType() == AuthState::AUTH_REQUEST_NEGOTIATE) { - authRequestState_->TransitionTo(std::make_shared()); - } else { - LOGE("Device manager auth state error"); - } - break; - case MSG_TYPE_REQ_AUTH_TERMINATE: - if (authResponseState_ != nullptr && - authResponseState_->GetStateType() != AuthState::AUTH_RESPONSE_FINISH) { - isFinishOfLocal_ = false; - authResponseState_->TransitionTo(std::make_shared()); - } else if (authRequestState_ != nullptr && - authRequestState_->GetStateType() != AuthState::AUTH_REQUEST_FINISH) { - isFinishOfLocal_ = false; - authResponseContext_->state = authRequestState_->GetStateType(); - authRequestState_->TransitionTo(std::make_shared()); - } - break; - default: - break; + switch (authResponseContext_->msgType) { + case MSG_TYPE_NEGOTIATE: + if (authResponseState_->GetStateType() == AuthState::AUTH_RESPONSE_INIT + && timerMap_.find(WAIT_NEGOTIATE_TIMEOUT_TASK) != timerMap_.end()) { + timerMap_[WAIT_NEGOTIATE_TIMEOUT_TASK]->Stop(SESSION_CANCEL_TIMEOUT); + authResponseState_->TransitionTo(std::make_shared()); + } else { + LOGE("Device manager auth state error"); + } + break; + case MSG_TYPE_REQ_AUTH: + if (authResponseState_->GetStateType() == AuthState::AUTH_RESPONSE_NEGOTIATE + && timerMap_.find(WAIT_REQUEST_TIMEOUT_TASK) != timerMap_.end()) { + timerMap_[WAIT_REQUEST_TIMEOUT_TASK]->Stop(SESSION_CANCEL_TIMEOUT); + authResponseState_->TransitionTo(std::make_shared()); + } else { + LOGE("Device manager auth state error"); + } + break; + case MSG_TYPE_REQ_AUTH_TERMINATE: + if (authResponseState_->GetStateType() != AuthState::AUTH_RESPONSE_FINISH) { + isFinishOfLocal_ = false; + authResponseState_->TransitionTo(std::make_shared()); + } + break; + default: + break; + } + } else { + LOGE("DmAuthManager::OnDataReceived failed, authRequestState_ or authResponseState_ is invalid."); } } -- Gitee From bf310a523a067069a7a3907e7f2e9b71b458fd31 Mon Sep 17 00:00:00 2001 From: renguang1116 Date: Tue, 15 Mar 2022 16:51:43 +0800 Subject: [PATCH 08/24] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=86=85=E6=BA=90?= =?UTF-8?q?=E6=A3=80=E8=A7=86=E9=97=AE=E9=A2=98=20Signed-off-by:=20renguan?= =?UTF-8?q?g1116=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/authentication/dm_auth_manager.cpp | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/services/devicemanagerservice/src/authentication/dm_auth_manager.cpp b/services/devicemanagerservice/src/authentication/dm_auth_manager.cpp index 38ec0e935..bb075c5b9 100644 --- a/services/devicemanagerservice/src/authentication/dm_auth_manager.cpp +++ b/services/devicemanagerservice/src/authentication/dm_auth_manager.cpp @@ -249,9 +249,8 @@ void DmAuthManager::OnSessionClosed(int32_t sessionId) void DmAuthManager::OnDataReceived(int32_t sessionId, std::string message) { - LOGI("DmAuthManager::OnDataReceived start"); if (authResponseContext_ == nullptr || authMessageProcessor_ == nullptr) { - LOGI("DmAuthManager::OnDataReceived failed, authResponseContext or authMessageProcessor_ is nullptr."); + LOGE("OnDataReceived failed, authResponseContext or authMessageProcessor_ is nullptr."); return; } @@ -259,7 +258,7 @@ void DmAuthManager::OnDataReceived(int32_t sessionId, std::string message) authMessageProcessor_->SetResponseContext(authResponseContext_); int32_t ret = authMessageProcessor_->ParseMessage(message); if (ret != DM_OK) { - LOGE("OnDataReceived, parse message error"); + LOGE("OnDataReceived failed, parse input message error."); return; } @@ -267,19 +266,18 @@ void DmAuthManager::OnDataReceived(int32_t sessionId, std::string message) // source device auth process authRequestContext_ = authMessageProcessor_->GetRequestContext(); authRequestState_->SetAuthContext(authRequestContext_); + LOGI("OnDataReceived for source device, authResponseContext msgType=%d, authRequestState stateType=%d", + authResponseContext_->msgType, authRequestState_->GetStateType()); + switch (authResponseContext_->msgType) { case MSG_TYPE_RESP_AUTH: if (authRequestState_->GetStateType() == AuthState::AUTH_REQUEST_NEGOTIATE_DONE) { authRequestState_->TransitionTo(std::make_shared()); - } else { - LOGE("Device manager auth state error"); } break; case MSG_TYPE_RESP_NEGOTIATE: if (authRequestState_->GetStateType() == AuthState::AUTH_REQUEST_NEGOTIATE) { authRequestState_->TransitionTo(std::make_shared()); - } else { - LOGE("Device manager auth state error"); } break; case MSG_TYPE_REQ_AUTH_TERMINATE: @@ -295,6 +293,9 @@ void DmAuthManager::OnDataReceived(int32_t sessionId, std::string message) } else if ((authResponseState_ != nullptr) && (authRequestState_ == nullptr)) { // sink device auth process authResponseState_->SetAuthContext(authResponseContext_); + LOGI("OnDataReceived for sink device, authResponseContext msgType=%d, authResponseState stateType=%d", + authResponseContext_->msgType, authResponseState_->GetStateType()); + switch (authResponseContext_->msgType) { case MSG_TYPE_NEGOTIATE: if (authResponseState_->GetStateType() == AuthState::AUTH_RESPONSE_INIT -- Gitee From 4e49376a3f6877a507d2c3ea0757d136f3ca5b64 Mon Sep 17 00:00:00 2001 From: zixing000 Date: Wed, 16 Mar 2022 08:55:37 +0800 Subject: [PATCH 09/24] test AuthenticateDevice Signed-off-by: zixing000 --- .../native_cpp/src/device_manager_impl.cpp | 2 ++ .../src/ipc/lite/ipc_client_server_proxy.cpp | 13 +++++++-- .../src/ipc/lite/ipc_cmd_parser.cpp | 2 ++ test_lite/device_manager_test.cpp | 28 ++++++++----------- 4 files changed, 27 insertions(+), 18 deletions(-) diff --git a/interfaces/inner_kits/native_cpp/src/device_manager_impl.cpp b/interfaces/inner_kits/native_cpp/src/device_manager_impl.cpp index 41ee51144..a7b9e7de3 100644 --- a/interfaces/inner_kits/native_cpp/src/device_manager_impl.cpp +++ b/interfaces/inner_kits/native_cpp/src/device_manager_impl.cpp @@ -240,12 +240,14 @@ int32_t DeviceManagerImpl::AuthenticateDevice(const std::string &pkgName, int32_ req->SetExtra(extra); req->SetAuthType(authType); req->SetDeviceInfo(deviceInfo); + LOGI("DeviceManager::AuthenticateDevice 111111111111111111111111111111111111111"); int32_t ret = ipcClientProxy_->SendRequest(AUTHENTICATE_DEVICE, req, rsp); if (ret != DM_OK) { LOGE("AuthenticateDevice error: Send Request failed ret: %d", ret); return DM_IPC_SEND_REQUEST_FAILED; } + LOGI("DeviceManager::AuthenticateDevice 222222222222222222222222222222222222222"); ret = rsp->GetErrCode(); if (ret != DM_OK) { LOGE("AuthenticateDevice error: Failed with ret %d", ret); diff --git a/interfaces/inner_kits/native_cpp/src/ipc/lite/ipc_client_server_proxy.cpp b/interfaces/inner_kits/native_cpp/src/ipc/lite/ipc_client_server_proxy.cpp index 21de9b5df..ca399748b 100644 --- a/interfaces/inner_kits/native_cpp/src/ipc/lite/ipc_client_server_proxy.cpp +++ b/interfaces/inner_kits/native_cpp/src/ipc/lite/ipc_client_server_proxy.cpp @@ -56,6 +56,7 @@ static int32_t SendCmdResultCb(IOwner owner, int32_t code, IpcIo *reply) int32_t cmdCode = *(int32_t *)owner; LOGI("SendCmdResultCb code:%d", cmdCode); (void)IpcCmdRegister::GetInstance().ReadResponse(cmdCode, *reply, pCurRsp); + LOGI("SendCmdResultCb code over"); return DM_OK; } @@ -89,13 +90,21 @@ int IpcClientServerProxy::RegisterServerDeathCb(void) int32_t IpcClientServerProxy::SendCmd(int32_t cmdCode, std::shared_ptr req, std::shared_ptr rsp) { - LOGI("SendCmd:%d", cmdCode); + LOGI("IpcClientServerProxy::SendCmd:%d", cmdCode); uint8_t data[MAX_DM_IPC_LEN] = {0}; IpcIo request; if (IpcCmdRegister::GetInstance().SetRequest(cmdCode, req, request, data, MAX_DM_IPC_LEN) != DM_OK) { return DM_FAILED; } + LOGI("IpcClientServerProxy::SendCmd SetRequest ok"); + if (nullptr != request.bufferBase) + LOGI("bufferBase:%s\noffsetsBase:%u", request.bufferBase, request.offsetsBase); + if (nullptr != request.bufferCur) + LOGI("bufferCur:%s\noffsetsCur:%u", request.bufferCur, request.offsetsCur); + LOGI("bufferLeft:%u\noffsetsLeft:%u", request.bufferLeft, request.offsetsLeft); + LOGI("flag:%u\nserviceProxy_:%llu", request.flag, serviceProxy_); + { std::lock_guard autoLock(lock_); pCurRsp = rsp; @@ -105,7 +114,7 @@ int32_t IpcClientServerProxy::SendCmd(int32_t cmdCode, std::shared_ptr r return DM_FAILED; } } - LOGI("SendCmd:%d end", cmdCode); + LOGI("IpcClientServerProxy::SendCmd:%d, over", cmdCode); return DM_OK; } diff --git a/interfaces/inner_kits/native_cpp/src/ipc/lite/ipc_cmd_parser.cpp b/interfaces/inner_kits/native_cpp/src/ipc/lite/ipc_cmd_parser.cpp index 9594d21e0..e7c9b16ab 100644 --- a/interfaces/inner_kits/native_cpp/src/ipc/lite/ipc_cmd_parser.cpp +++ b/interfaces/inner_kits/native_cpp/src/ipc/lite/ipc_cmd_parser.cpp @@ -128,6 +128,7 @@ ON_IPC_READ_RESPONSE(GET_LOCAL_DEVICE_INFO, IpcIo &reply, std::shared_ptr pBaseReq, IpcIo &request, uint8_t *buffer, size_t buffLen) { + LOGI("START_DEVICE_DISCOVER IpcIoInit"); std::shared_ptr pReq = std::static_pointer_cast(pBaseReq); std::string pkgName = pReq->GetPkgName(); std::string extra = pReq->GetExtra(); @@ -168,6 +169,7 @@ ON_IPC_READ_RESPONSE(STOP_DEVICE_DISCOVER, IpcIo &reply, std::shared_ptr ON_IPC_SET_REQUEST(AUTHENTICATE_DEVICE, std::shared_ptr pBaseReq, IpcIo &request, uint8_t *buffer, size_t buffLen) { + LOGI("AUTHENTICATE_DEVICE IpcIoInit"); std::shared_ptr pReq = std::static_pointer_cast(pBaseReq); std::string pkgName = pReq->GetPkgName(); std::string extra = pReq->GetExtra(); diff --git a/test_lite/device_manager_test.cpp b/test_lite/device_manager_test.cpp index abc537f33..66042fa0c 100644 --- a/test_lite/device_manager_test.cpp +++ b/test_lite/device_manager_test.cpp @@ -201,26 +201,22 @@ std::shared_ptr authenticateCallback; void AuthenticateDevice() { - uint8_t * appIconTmp = (uint8_t*)malloc(10); - appIconTmp[9] = 'B'; - uint8_t * appThumbnailTmp = (uint8_t*)malloc(600); - appThumbnailTmp[599] = 'C'; - - DmAppImageInfo dmAppImageInfo(appIconTmp, 10, appThumbnailTmp, 600); - std::string authExtra = "{\n" - "\"authType\": 1,\n" - "\"targetPkgName\": \"com.huawei.dosdemo1\",\n" - "\"appName\": \"zhengjianming\",\n" - "\"appDescription\": \"hehe\", \n" - "\"business\": 0\n" - "}"; + // std::string authExtra = "{\n" + // "\"authType\": 1,\n" + // "\"targetPkgName\": \"com.huawei.dosdemo1\",\n" + // "\"appName\": \"zhengjianming\",\n" + // "\"appDescription\": \"hehe\", \n" + // "\"business\": 0\n" + // "}"; + std::string authExtra = ""; + LOGI("test AuthenticateDevice start"); authenticateCallback = std::make_shared(packageName); if (DeviceManager::GetInstance().AuthenticateDevice( packageName, 1, g_deviceInfo,authExtra, authenticateCallback) == DM_OK){ LOGI("AuthenticateDevice success"); + } else { + LOGI("AuthenticateDevice false"); } - free(appIconTmp); - free(appThumbnailTmp); } std::shared_ptr verifyAuthCallback; @@ -284,7 +280,7 @@ int main(){ g_selectedDeviceNo = selectNo < g_deviceInfoList.size() ? selectNo : 0; g_deviceInfo = g_deviceInfoList[g_selectedDeviceNo]; } else if (cmd == "AuthenticateDevice") { - AuthenticateDevice(); + AuthenticateDevice(); } else if (cmd == "CheckAuthentication") { std::string pinCode = ""; std::cin >> pinCode; -- Gitee From 504283c0de7173a0a2d91aa3ba15b8cd6c815e81 Mon Sep 17 00:00:00 2001 From: zixing000 Date: Wed, 16 Mar 2022 15:55:01 +0800 Subject: [PATCH 10/24] delete test_lite and codecheck Signed-off-by: zixing000 --- interfaces/inner_kits/native_cpp/BUILD.gn | 1 - services/devicemanagerservice/BUILD.gn | 1 - .../multipleuser/multiple_user_connector.cpp | 4 +- test_lite/BUILD.gn | 55 ---- test_lite/device_manager_test.cpp | 307 ------------------ 5 files changed, 2 insertions(+), 366 deletions(-) delete mode 100644 test_lite/BUILD.gn delete mode 100644 test_lite/device_manager_test.cpp diff --git a/interfaces/inner_kits/native_cpp/BUILD.gn b/interfaces/inner_kits/native_cpp/BUILD.gn index 4d0f896d8..80fde4c73 100644 --- a/interfaces/inner_kits/native_cpp/BUILD.gn +++ b/interfaces/inner_kits/native_cpp/BUILD.gn @@ -58,7 +58,6 @@ if (defined(ohos_lite)) { "//foundation/distributedschedule/samgr_lite/samgr:samgr", "//third_party/bounds_checking_function:libsec_shared", "//utils/native/lite:utils", - # "//foundation/appexecfwk/appexecfwk_lite/interfaces/kits/bundle_lite/js/builtin:capability_api", ] defines = [ "LITE_DEVICE", diff --git a/services/devicemanagerservice/BUILD.gn b/services/devicemanagerservice/BUILD.gn index 28c457b24..6ba24f4c8 100755 --- a/services/devicemanagerservice/BUILD.gn +++ b/services/devicemanagerservice/BUILD.gn @@ -106,7 +106,6 @@ if (defined(ohos_lite)) { "//base/hiviewdfx/hilog_lite/frameworks/featured:hilog_shared", "//base/security/deviceauth/services:deviceauth_sdk", "//base/startup/syspara_lite/frameworks/parameter/src:sysparam", - # "//base/startup/syspara_lite/interfaces/innerkits/native/syspara:syspara_watchagent", "//foundation/communication/dsoftbus/sdk:softbus_client", "//foundation/communication/ipc_lite:liteipc_adapter", "//foundation/distributedschedule/samgr_lite/samgr:samgr", diff --git a/services/devicemanagerservice/src/dependency/multipleuser/multiple_user_connector.cpp b/services/devicemanagerservice/src/dependency/multipleuser/multiple_user_connector.cpp index 18835da75..5214b4aa6 100644 --- a/services/devicemanagerservice/src/dependency/multipleuser/multiple_user_connector.cpp +++ b/services/devicemanagerservice/src/dependency/multipleuser/multiple_user_connector.cpp @@ -36,7 +36,7 @@ int32_t MultipleUserConnector::GetCurrentAccountUserID(void) } return ids[0]; #else - return 0; + return 0; #endif } @@ -50,7 +50,7 @@ int32_t MultipleUserConnector::GetSwitchOldUserId(void) #ifndef LITE_DEVICE return oldUserId_; #else - return 0; + return 0; #endif } } // namespace DistributedHardware diff --git a/test_lite/BUILD.gn b/test_lite/BUILD.gn deleted file mode 100644 index c832f9731..000000000 --- a/test_lite/BUILD.gn +++ /dev/null @@ -1,55 +0,0 @@ -# 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. - -if (defined(ohos_lite)) { - import("//build/lite/config/component/lite_component.gni") -} else { - import("//build/ohos.gni") -} - -import("//foundation/distributedhardware/devicemanager/devicemanager.gni") - -if (defined(ohos_lite)) { - executable("devicemanagertest") { - include_dirs = [ - "${common_path}/include", - "${common_path}/include/ipc", - "${common_path}/include/ipc/model", - "${utils_path}/include", - "${utils_path}/include/ipc/lite", - "${innerkits_path}/native_cpp/include", - "${innerkits_path}/native_cpp/include/ipc", - "${innerkits_path}/native_cpp/include/ipc/lite", - "//utils/native/lite/include", - "//foundation/communication/ipc_lite/interfaces/kits", - "//foundation/distributedschedule/samgr_lite/interfaces/kits/samgr", - "//foundation/distributedschedule/samgr_lite/interfaces/kits/registry", - ] - sources = [ - "device_manager_test.cpp", - ] - defines = [ - "LITE_DEVICE", - "HI_LOG_ENABLE", - "DH_LOG_TAG=\"devicemanagerservice\"", - "LOG_DOMAIN=0xD004100", - ] - # cflags_cc = build_flags; - deps = [ - "${innerkits_path}/native_cpp:devicemanagersdk", - "${utils_path}:devicemanagerutils", - "//utils/native/lite:utils", - "//base/hiviewdfx/hilog_lite/frameworks/featured:hilog_shared", - ] - } -} diff --git a/test_lite/device_manager_test.cpp b/test_lite/device_manager_test.cpp deleted file mode 100644 index 66042fa0c..000000000 --- a/test_lite/device_manager_test.cpp +++ /dev/null @@ -1,307 +0,0 @@ -#include -#include -#include -#include -#include -#include - -#include "securec.h" - -#include "device_manager_impl.h" -#include "device_manager_callback.h" -#include "dm_constants.h" -#include "dm_log.h" -// #include "ipc_server_stub.h" - -// #include "encrypt_utils.h" - -using namespace OHOS::DistributedHardware; - -namespace { -DmDeviceInfo g_deviceInfo; -std::vector g_deviceInfoList; -// const char *DM_CAPABILITY_OSD = "osdCapability"; -std::string g_pinToken = ""; -static std::string packageName = "com.huawei.dosdemo1"; -const int32_t BUF_SIZE = 45 * 1024; -uint8_t g_buf[BUF_SIZE]; -std::mutex lock_; -int32_t g_selectedDeviceNo = 0; -} - -class DmTestInitCallback : public DmInitCallback { -public: - explicit DmTestInitCallback(std::string &bundleName):bundleName_(bundleName) {} - virtual ~DmTestInitCallback(){} - void OnRemoteDied() override; -private: - std::string bundleName_; -}; - -void DmTestInitCallback::OnRemoteDied() -{ - LOGI("OnRemoteDied"); -} - -class DmTestDeviceStateCallback : public DeviceStateCallback { -public: - explicit DmTestDeviceStateCallback(std::string &bundleName):bundleName_(bundleName) {} - virtual ~DmTestDeviceStateCallback(){} - void OnDeviceOnline(const DmDeviceInfo &deviceInfo) override; - void OnDeviceReady(const DmDeviceInfo &deviceInfo) override; - void OnDeviceOffline(const DmDeviceInfo &deviceInfo) override; - void OnDeviceChanged(const DmDeviceInfo &deviceInfo) override; -private: - std::string bundleName_; -}; - -void DmTestDeviceStateCallback::OnDeviceOnline(const DmDeviceInfo &deviceInfo) -{ - LOGI("deviceId:%s, deviceName:%s", deviceInfo.deviceId, deviceInfo.deviceName); - g_deviceInfo = deviceInfo; -} - -void DmTestDeviceStateCallback::OnDeviceReady(const DmDeviceInfo &deviceInfo) -{ - LOGI("deviceId:%s, deviceName:%s", deviceInfo.deviceId, deviceInfo.deviceName); - g_deviceInfo = deviceInfo; -} - -void DmTestDeviceStateCallback::OnDeviceOffline(const DmDeviceInfo &deviceInfo) -{ - LOGI("deviceId:%s, deviceName:%s", deviceInfo.deviceId, deviceInfo.deviceName); - g_deviceInfo = deviceInfo; -} - -void DmTestDeviceStateCallback::OnDeviceChanged(const DmDeviceInfo &deviceInfo) -{ - LOGI("deviceId:%s, deviceName:%s", deviceInfo.deviceId, deviceInfo.deviceName); - g_deviceInfo = deviceInfo; -} - -class DmTestDiscoverCallback : public DiscoveryCallback { -public: - explicit DmTestDiscoverCallback(std::string &bundleName):bundleName_(bundleName) {} - virtual ~DmTestDiscoverCallback(){} - void OnDeviceFound(uint16_t subscribeld, const DmDeviceInfo &deviceInfo) override; - void OnDiscoveryFailed(uint16_t subscribeld, int32_t failedReason) override; - void OnDiscoverySuccess(uint16_t subscribeld) override; -private: - std::string bundleName_; -}; - -void DmTestDiscoverCallback::OnDeviceFound(uint16_t subscribeld, const DmDeviceInfo &deviceInfo) -{ - std::lock_guard autoLock(lock_); - g_deviceInfoList.emplace_back(deviceInfo); - g_deviceInfo = g_deviceInfoList[0]; - for (int i = 0; i < g_deviceInfoList.size(); ++i){ - LOGI("deviceNo:%d, deviceId:%s, deviceName:%s", - i, g_deviceInfoList[i].deviceId, g_deviceInfoList[i].deviceName); - } -} - -void DmTestDiscoverCallback::OnDiscoveryFailed(uint16_t subscribeId, int32_t failedReason) -{ - LOGI("OnDiscoverFailed, subscribeId:%u, failedReason:%d", subscribeId, failedReason); -} - -void DmTestDiscoverCallback::OnDiscoverySuccess(uint16_t subscribeId) -{ - LOGI("OnDiscoverSuccess, subscribeId:%u", subscribeId); -} - -class DmTestAuthenticateCallback : public AuthenticateCallback { -public: - explicit DmTestAuthenticateCallback(std::string &bundleName):bundleName_(bundleName) {} - virtual ~DmTestAuthenticateCallback(){} - void OnAuthResult(const std::string &deviceId, const std::string &pinToken, - int32_t status, int32_t reason) override; - -private: - std::string bundleName_; -}; - -void DmTestAuthenticateCallback::OnAuthResult(const std::string &deviceId, - const std::string &pinToken, int32_t status, int32_t reason) -{ - LOGI("OnAuthResult, deviceId:%s, status:%d, pinToken:%s", deviceId.c_str(), status, pinToken.c_str()); - g_pinToken = pinToken; -} - -class DmTestVerifyAuthCallback : public VerifyAuthCallback { -public: - explicit DmTestVerifyAuthCallback(std::string &bundleName):bundleName_(bundleName) {} - virtual ~DmTestVerifyAuthCallback(){}; - void OnVerifyAuthResult(const std::string &deviceId, - int32_t resultCode, int32_t flag) override; -private: - std::string bundleName_; -}; - -void DmTestVerifyAuthCallback::OnVerifyAuthResult(const std::string &deviceId, int32_t resultCode, int32_t flag) -{ - LOGI("check deviceId:%s, resultCode:%d, flag:%d", deviceId.c_str(), resultCode, flag); -} - -static std::string g_usage = "InitDeviceManager\n" - "StartDeviceDiscovery\n" - "SelectDeviceNo\n" - "AuthenticateDevice\n" - "CheckAuthentication\n" - "GetTrustedDeviceList\n" - "StopDeviceDiscovery\n" - "UnInitDeviceManager\n" - "Exit\n" - "InputPlainText\n" - "DecryptTexit\n"; - -static void printUsage() -{ - LOGI("use the following cmds \n%s", g_usage.c_str()); -} - -std::shared_ptr initCallback; - -void InitDeviceManager() -{ - LOGI("devicemanagertest start. package name:%s", packageName.c_str()); - initCallback = std::make_shared(packageName); - if (DeviceManager::GetInstance().InitDeviceManager(packageName, initCallback) == DM_OK) { - LOGI("InitDeviceManager success"); - } -} - -std::shared_ptr discoverCallback; - -void StartDeviceDiscovery() -{ - DmSubscribeInfo dmSubscribeInfo = { - 0, - DM_DISCOVER_MODE_ACTIVE, - DM_AUTO, - DM_HIGH, - false, - true, - "", - }; - g_deviceInfoList.clear(); - g_selectedDeviceNo = 0; - std::string extra = "extra"; - (void)strncpy_s(dmSubscribeInfo.capability, sizeof(dmSubscribeInfo.capability), - DM_CAPABILITY_OSD, strlen(DM_CAPABILITY_OSD)); - discoverCallback = std::make_shared(packageName); - if (DeviceManager::GetInstance().StartDeviceDiscovery( - packageName, dmSubscribeInfo, extra, discoverCallback) == DM_OK) { - LOGI("startDeviceDiscover success"); - } -} - -std::shared_ptr authenticateCallback; - -void AuthenticateDevice() -{ - // std::string authExtra = "{\n" - // "\"authType\": 1,\n" - // "\"targetPkgName\": \"com.huawei.dosdemo1\",\n" - // "\"appName\": \"zhengjianming\",\n" - // "\"appDescription\": \"hehe\", \n" - // "\"business\": 0\n" - // "}"; - std::string authExtra = ""; - LOGI("test AuthenticateDevice start"); - authenticateCallback = std::make_shared(packageName); - if (DeviceManager::GetInstance().AuthenticateDevice( - packageName, 1, g_deviceInfo,authExtra, authenticateCallback) == DM_OK){ - LOGI("AuthenticateDevice success"); - } else { - LOGI("AuthenticateDevice false"); - } -} - -std::shared_ptr verifyAuthCallback; - -void CheckAuthentication(std::string& pinCode) -{ - std::string authPara = "{\n" - "\"authType\": 1,\n" - "\"pinCode\": " + pinCode + ",\n" - "\"pinToken\": " + g_pinToken.c_str() + - "}"; - LOGI("authPara:\n%s", authPara.c_str()); - verifyAuthCallback = std::make_shared(packageName); - if (DeviceManager::GetInstance().VerifyAuthentication( - packageName, authPara, verifyAuthCallback) == DM_OK){ - LOGI("CheckAuthentication success"); - } -} - -void GetTrustedDeviceList() -{ - std::vector dmDeviceInfoVec; - std::string extra = "extra"; - if (DeviceManager::GetInstance().GetTrustedDeviceList( - packageName, extra, dmDeviceInfoVec) == DM_OK){ - LOGI("GetTrustedDeviceList success"); - for (DmDeviceInfo dmDeviceInfo : dmDeviceInfoVec) { - LOGI("deviceID: %s,\ndeviceName: %s", - dmDeviceInfo.deviceId, dmDeviceInfo.deviceName); - } - } -} - -void StopDeviceDiscovery() -{ - if (DeviceManager::GetInstance().StopDeviceDiscovery( - packageName, 0) == DM_OK){ - LOGI("StopDeviceDiscovery success"); - } -} - -void UnInitDeviceManager() -{ - if (DeviceManager::GetInstance().UnInitDeviceManager(packageName) == DM_OK){ - LOGI("UnInitDeviceManager success"); - } -} - - -int main(){ - printUsage(); - std::string cmd; - while (std::cin >> cmd) { - if (cmd == "InitDeviceManager") { - InitDeviceManager(); - } else if (cmd == "StartDeviceDiscovery") { - StartDeviceDiscovery(); - } else if (cmd == "SelectDeviceNo") { - int32_t selectNo; - std::cin >> selectNo; - g_selectedDeviceNo = selectNo < g_deviceInfoList.size() ? selectNo : 0; - g_deviceInfo = g_deviceInfoList[g_selectedDeviceNo]; - } else if (cmd == "AuthenticateDevice") { - AuthenticateDevice(); - } else if (cmd == "CheckAuthentication") { - std::string pinCode = ""; - std::cin >> pinCode; - CheckAuthentication(pinCode); - } else if (cmd == "GetTrustedDeviceList") { - GetTrustedDeviceList(); - } else if (cmd == "StopDeviceDiscovery") { - StopDeviceDiscovery(); - } else if (cmd == "UnInitDeviceManager") { - UnInitDeviceManager(); - } else if (cmd == "InputEncryptText") { - LOGI("EncryptText:InputEncryptText unsupport."); - } else if (cmd == "DecryptTexit") { - LOGI("EncryptText:DecryptTexit unsupport."); - } else if (cmd == "Exit") { - break; - } else { - LOGI("unknown cmd\n"); - } - LOGI("%s end\n", cmd.c_str()); - printUsage(); - } - return 0; -} -- Gitee From 939f3d69231a192c05c9a35f757739b908ec2f8b Mon Sep 17 00:00:00 2001 From: zixing000 Date: Wed, 16 Mar 2022 16:41:06 +0800 Subject: [PATCH 11/24] =?UTF-8?q?=E5=88=A0=E9=99=A4=E5=A4=9A=E4=BD=99?= =?UTF-8?q?=E6=97=A5=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zixing000 --- BUILD.gn | 1 - .../inner_kits/native_cpp/src/device_manager_impl.cpp | 3 --- .../src/ipc/lite/ipc_client_server_proxy.cpp | 11 +---------- .../native_cpp/src/ipc/lite/ipc_cmd_parser.cpp | 2 -- .../src/device_manager_service_listener.cpp | 1 - 5 files changed, 1 insertion(+), 17 deletions(-) diff --git a/BUILD.gn b/BUILD.gn index 5b25f37c8..103ee5a70 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -18,7 +18,6 @@ if (defined(ohos_lite)) { "utils:devicemanagerutils", "services/devicemanagerservice:devicemanagerservice", "interfaces/inner_kits/native_cpp:devicemanagersdk", - "test_lite:devicemanagertest", ] } } diff --git a/interfaces/inner_kits/native_cpp/src/device_manager_impl.cpp b/interfaces/inner_kits/native_cpp/src/device_manager_impl.cpp index a7b9e7de3..370cbd631 100644 --- a/interfaces/inner_kits/native_cpp/src/device_manager_impl.cpp +++ b/interfaces/inner_kits/native_cpp/src/device_manager_impl.cpp @@ -240,20 +240,17 @@ int32_t DeviceManagerImpl::AuthenticateDevice(const std::string &pkgName, int32_ req->SetExtra(extra); req->SetAuthType(authType); req->SetDeviceInfo(deviceInfo); - LOGI("DeviceManager::AuthenticateDevice 111111111111111111111111111111111111111"); int32_t ret = ipcClientProxy_->SendRequest(AUTHENTICATE_DEVICE, req, rsp); if (ret != DM_OK) { LOGE("AuthenticateDevice error: Send Request failed ret: %d", ret); return DM_IPC_SEND_REQUEST_FAILED; } - LOGI("DeviceManager::AuthenticateDevice 222222222222222222222222222222222222222"); ret = rsp->GetErrCode(); if (ret != DM_OK) { LOGE("AuthenticateDevice error: Failed with ret %d", ret); return DM_IPC_RESPOND_ERROR; } - LOGI("DeviceManager::AuthenticateDevice completed, pkgName: %s", pkgName.c_str()); return DM_OK; } diff --git a/interfaces/inner_kits/native_cpp/src/ipc/lite/ipc_client_server_proxy.cpp b/interfaces/inner_kits/native_cpp/src/ipc/lite/ipc_client_server_proxy.cpp index ca399748b..da6f53d50 100644 --- a/interfaces/inner_kits/native_cpp/src/ipc/lite/ipc_client_server_proxy.cpp +++ b/interfaces/inner_kits/native_cpp/src/ipc/lite/ipc_client_server_proxy.cpp @@ -56,7 +56,6 @@ static int32_t SendCmdResultCb(IOwner owner, int32_t code, IpcIo *reply) int32_t cmdCode = *(int32_t *)owner; LOGI("SendCmdResultCb code:%d", cmdCode); (void)IpcCmdRegister::GetInstance().ReadResponse(cmdCode, *reply, pCurRsp); - LOGI("SendCmdResultCb code over"); return DM_OK; } @@ -97,14 +96,6 @@ int32_t IpcClientServerProxy::SendCmd(int32_t cmdCode, std::shared_ptr r if (IpcCmdRegister::GetInstance().SetRequest(cmdCode, req, request, data, MAX_DM_IPC_LEN) != DM_OK) { return DM_FAILED; } - LOGI("IpcClientServerProxy::SendCmd SetRequest ok"); - if (nullptr != request.bufferBase) - LOGI("bufferBase:%s\noffsetsBase:%u", request.bufferBase, request.offsetsBase); - if (nullptr != request.bufferCur) - LOGI("bufferCur:%s\noffsetsCur:%u", request.bufferCur, request.offsetsCur); - LOGI("bufferLeft:%u\noffsetsLeft:%u", request.bufferLeft, request.offsetsLeft); - LOGI("flag:%u\nserviceProxy_:%llu", request.flag, serviceProxy_); - { std::lock_guard autoLock(lock_); pCurRsp = rsp; @@ -114,7 +105,7 @@ int32_t IpcClientServerProxy::SendCmd(int32_t cmdCode, std::shared_ptr r return DM_FAILED; } } - LOGI("IpcClientServerProxy::SendCmd:%d, over", cmdCode); + LOGI("IpcClientServerProxy::SendCmd:%d, end", cmdCode); return DM_OK; } diff --git a/interfaces/inner_kits/native_cpp/src/ipc/lite/ipc_cmd_parser.cpp b/interfaces/inner_kits/native_cpp/src/ipc/lite/ipc_cmd_parser.cpp index e7c9b16ab..9594d21e0 100644 --- a/interfaces/inner_kits/native_cpp/src/ipc/lite/ipc_cmd_parser.cpp +++ b/interfaces/inner_kits/native_cpp/src/ipc/lite/ipc_cmd_parser.cpp @@ -128,7 +128,6 @@ ON_IPC_READ_RESPONSE(GET_LOCAL_DEVICE_INFO, IpcIo &reply, std::shared_ptr pBaseReq, IpcIo &request, uint8_t *buffer, size_t buffLen) { - LOGI("START_DEVICE_DISCOVER IpcIoInit"); std::shared_ptr pReq = std::static_pointer_cast(pBaseReq); std::string pkgName = pReq->GetPkgName(); std::string extra = pReq->GetExtra(); @@ -169,7 +168,6 @@ ON_IPC_READ_RESPONSE(STOP_DEVICE_DISCOVER, IpcIo &reply, std::shared_ptr ON_IPC_SET_REQUEST(AUTHENTICATE_DEVICE, std::shared_ptr pBaseReq, IpcIo &request, uint8_t *buffer, size_t buffLen) { - LOGI("AUTHENTICATE_DEVICE IpcIoInit"); std::shared_ptr pReq = std::static_pointer_cast(pBaseReq); std::string pkgName = pReq->GetPkgName(); std::string extra = pReq->GetExtra(); diff --git a/services/devicemanagerservice/src/device_manager_service_listener.cpp b/services/devicemanagerservice/src/device_manager_service_listener.cpp index cd6d1acbe..108fefb2e 100644 --- a/services/devicemanagerservice/src/device_manager_service_listener.cpp +++ b/services/devicemanagerservice/src/device_manager_service_listener.cpp @@ -89,7 +89,6 @@ void DeviceManagerServiceListener::OnAuthResult(const std::string &pkgName, cons pReq->SetToken(token); pReq->SetStatus(status); pReq->SetReason(reason); - LOGI("%s, before send request +++++++++++", __FUNCTION__); ipcServerListener_.SendRequest(SERVER_AUTH_RESULT, pReq, pRsp); } -- Gitee From 0db56c556b4b6cee86d14e41368d21f3b2e01935 Mon Sep 17 00:00:00 2001 From: zixing000 Date: Thu, 17 Mar 2022 15:26:23 +0800 Subject: [PATCH 12/24] ui Signed-off-by: zixing000 --- ext/pin_auth/BUILD.gn | 4 +- ext/pin_auth/include/pin_auth.h | 1 + ext/pin_auth/include/pin_auth_ui.h | 37 -------- ext/pin_auth/src/pin_auth.cpp | 5 + ext/pin_auth/src/pin_auth_ui.cpp | 94 ------------------- .../kits/js/src/native_devicemanager_js.cpp | 47 ++++++++++ services/devicemanagerservice/BUILD.gn | 6 +- .../include/authentication/auth_ui.h | 38 -------- .../include/authentication/authentication.h | 1 + .../include/authentication/dm_auth_manager.h | 1 - .../src/authentication/auth_ui.cpp | 49 ---------- .../src/authentication/dm_auth_manager.cpp | 53 +++++------ 12 files changed, 85 insertions(+), 251 deletions(-) delete mode 100644 ext/pin_auth/include/pin_auth_ui.h delete mode 100644 services/devicemanagerservice/include/authentication/auth_ui.h delete mode 100644 services/devicemanagerservice/src/authentication/auth_ui.cpp diff --git a/ext/pin_auth/BUILD.gn b/ext/pin_auth/BUILD.gn index 84e735198..5dac42d4c 100644 --- a/ext/pin_auth/BUILD.gn +++ b/ext/pin_auth/BUILD.gn @@ -23,12 +23,14 @@ if (defined(ohos_lite)) { ohos_shared_library("devicemanagerext_pin_auth") { include_dirs = [ "include", + "include/standard", "${common_path}/include", "${ext_path}/pin_auth/include/ability", "${services_path}/include/dependency/timer", "${services_path}/include/config", "${services_path}/include/adapter", "${services_path}/include/authentication", + "${services_path}/include/authentication/showconfirm/standard", "${services_path}/include/ability", "${services_path}/include/deviceinfo", "${services_path}/include/devicestate", @@ -61,7 +63,7 @@ if (defined(ohos_lite)) { sources = [ "src/ability/standard/dm_ability_manager.cpp", "src/pin_auth.cpp", - "src/pin_auth_ui.cpp", + "src/standard/pin_auth_ui.cpp", ] deps = [ diff --git a/ext/pin_auth/include/pin_auth.h b/ext/pin_auth/include/pin_auth.h index ac02b1017..191a46226 100644 --- a/ext/pin_auth/include/pin_auth.h +++ b/ext/pin_auth/include/pin_auth.h @@ -33,6 +33,7 @@ public: int32_t ShowAuthInfo(std::string &authToken, std::shared_ptr authManager) override; int32_t StartAuth(std::string &authToken, std::shared_ptr authManager) override; int32_t VerifyAuthentication(std::string &authToken, const std::string &authParam) override; + int32_t CloseAuthInfo(const int32_t &pageId, std::shared_ptr authManager) override; private: int32_t times_ = 0; std::shared_ptr pinAuthUi_; diff --git a/ext/pin_auth/include/pin_auth_ui.h b/ext/pin_auth/include/pin_auth_ui.h deleted file mode 100644 index 5ff26c3e1..000000000 --- a/ext/pin_auth/include/pin_auth_ui.h +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef OHOS_DM_PIN_AUTH_UI_H -#define OHOS_DM_PIN_AUTH_UI_H - -#include - -#include "dm_auth_manager.h" -#include "dm_ability_manager.h" - -namespace OHOS { -namespace DistributedHardware { -class PinAuthUi { -public: - PinAuthUi(); - int32_t ShowPinDialog(int32_t code, std::shared_ptr authManager); - int32_t InputPinDialog(int32_t code, std::shared_ptr authManager); - -private: - int32_t StartFaUiService(std::shared_ptr dmAbilityManager); -}; -} // namespace DistributedHardware -} // namespace OHOS -#endif // OHOS_DM_PIN_AUTH_UI_H diff --git a/ext/pin_auth/src/pin_auth.cpp b/ext/pin_auth/src/pin_auth.cpp index 4c3e30409..6d76b097b 100644 --- a/ext/pin_auth/src/pin_auth.cpp +++ b/ext/pin_auth/src/pin_auth.cpp @@ -101,6 +101,11 @@ int32_t PinAuth::VerifyAuthentication(std::string &authToken, const std::string } } +int32_t PinAuth::CloseAuthInfo(const int32_t &pageId, std::shared_ptr authManager) +{ + return pinAuthUi_ClosePage(pageId, authManager); +} + extern "C" IAuthentication *CreatePinAuthObject(void) { return new PinAuth; diff --git a/ext/pin_auth/src/pin_auth_ui.cpp b/ext/pin_auth/src/pin_auth_ui.cpp index eb976a678..e69de29bb 100644 --- a/ext/pin_auth/src/pin_auth_ui.cpp +++ b/ext/pin_auth/src/pin_auth_ui.cpp @@ -1,94 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "pin_auth_ui.h" - -#include "dm_ability_manager.h" -#include "dm_constants.h" -#include "dm_log.h" -#include "nlohmann/json.hpp" -#include "ui_service_mgr_client.h" - -namespace OHOS { -namespace DistributedHardware { -PinAuthUi::PinAuthUi() -{ - LOGI("AuthUi constructor"); -} - -int32_t PinAuthUi::ShowPinDialog(int32_t code, std::shared_ptr authManager) -{ - LOGI("ShowPinDialog start"); - nlohmann::json jsonObj; - jsonObj[PIN_CODE_KEY] = code; - jsonObj.dump(); - const std::string params = jsonObj.dump(); - - Ace::UIServiceMgrClient::GetInstance()->ShowDialog( - "show_pin_service", - params, - OHOS::Rosen::WindowType::WINDOW_TYPE_SYSTEM_ALARM_WINDOW, - ACE_X, ACE_Y, ACE_WIDTH, ACE_HEIGHT, - [authManager](int32_t id, const std::string& event, const std::string& params) { - if (strcmp(params.c_str(), "0") == 0) { - authManager->SetPageId(id); - } - if (strcmp(params.c_str(), "1") == 0) { - LOGI("CancelDialog start id:%d,event:%s,parms:%s", id, event.c_str(), params.c_str()); - Ace::UIServiceMgrClient::GetInstance()->CancelDialog(id); - } - }); - LOGI("ShowConfigDialog end"); - return DM_OK; -} - -int32_t PinAuthUi::InputPinDialog(int32_t code, std::shared_ptr authManager) -{ - LOGI("InputPinDialog start"); - nlohmann::json jsonObj; - jsonObj[PIN_CODE_KEY] = code; - jsonObj.dump(); - const std::string params = jsonObj.dump(); - - Ace::UIServiceMgrClient::GetInstance()->ShowDialog( - "input_pin_service", - params, - OHOS::Rosen::WindowType::WINDOW_TYPE_SYSTEM_ALARM_WINDOW, - ACE_X, ACE_Y, ACE_WIDTH, ACE_HEIGHT, - [authManager](int32_t id, const std::string& event, const std::string& params) { - if (strcmp(params.c_str(), "2") == 0) { - authManager->SetPageId(id); - } - if (strcmp(params.c_str(), "0") == 0 || strcmp(params.c_str(), "1") == 0) { - Ace::UIServiceMgrClient::GetInstance()->CancelDialog(id); - LOGI("CancelDialog start id:%d,event:%s,parms:%s", id, event.c_str(), params.c_str()); - authManager->VerifyAuthentication(params.c_str()); - } - }); - LOGI("ShowConfigDialog end"); - return DM_OK; -} - -int32_t PinAuthUi::StartFaUiService(std::shared_ptr dmAbilityManager) -{ - AbilityStatus status = dmAbilityManager->StartAbility(AbilityRole::ABILITY_ROLE_INITIATIVE); - if (status != AbilityStatus::ABILITY_STATUS_SUCCESS) { - LOGE("PinAuthUi::StartFaService timeout"); - return DM_FAILED; - } - return DM_OK; -} -} // namespace DistributedHardware -} // namespace OHOS diff --git a/interfaces/kits/js/src/native_devicemanager_js.cpp b/interfaces/kits/js/src/native_devicemanager_js.cpp index 97f32c139..ca0341ef5 100644 --- a/interfaces/kits/js/src/native_devicemanager_js.cpp +++ b/interfaces/kits/js/src/native_devicemanager_js.cpp @@ -46,6 +46,8 @@ const int32_t DM_NAPI_ARGS_TWO = 2; const int32_t DM_NAPI_ARGS_THREE = 3; const int32_t DM_NAPI_SUB_ID_MAX = 65535; +const int32_t DM_AUTH_DIRECTION_CLIENT = 1; + napi_ref deviceTypeEnumConstructor_ = nullptr; napi_ref deviceStateChangeActionEnumConstructor_ = nullptr; napi_ref discoverModeEnumConstructor_ = nullptr; @@ -587,6 +589,51 @@ void DeviceManagerNapi::DeviceInfoToJsArray(const napi_env &env, const std::vect void DeviceManagerNapi::DmAuthParamToJsAuthParam(const napi_env &env, const DmAuthParam &authParam, napi_value ¶mResult) { + napi_value extraInfo = nullptr; + napi_create_object(env, &extraInfo); + SetValueInt32(env, "direction", authParam.direction, extraInfo); + SetValueInt32(env, "authType", authParam.authType, paramResult); + SetValueInt32(env, "pinToken", stoi(authParam.authToken), extraInfo); + + if (authParam.direction == DM_AUTH_DIRECTION_CLIENT) { + napi_set_named_property(env, paramResult, "extraInfo", extraInfo); + return; + } + + SetValueUtf8String(env, "packageName", authParam.packageName, extraInfo); + SetValueUtf8String(env, "appName", authParam.appName, extraInfo); + SetValueUtf8String(env, "appDescription", authParam.appDescription, extraInfo); + SetValueInt32(env, "business", authParam.business, extraInfo); + SetValueInt32(env, "pinCode", authParam.pincode, extraInfo); + napi_set_named_property(env, paramResult, "extraInfo", extraInfo); + + size_t appIconLen = (size_t)authParam.imageinfo.GetAppIconLen(); + if (appIconLen > 0) { + void *appIcon = nullptr; + napi_value appIconBuffer = nullptr; + napi_create_arraybuffer(env, appIconLen, &appIcon, &appIconBuffer); + if (appIcon != nullptr && + memcpy_s(appIcon, appIconLen, reinterpret_cast(authParam.imageinfo.GetAppIcon()), + appIconLen) == 0) { + napi_value appIconArray = nullptr; + napi_create_typedarray(env, napi_uint8_array, appIconLen, appIconBuffer, 0, &appIconArray); + napi_set_named_property(env, paramResult, "appIcon", appIconArray); + } + } + + size_t appThumbnailLen = (size_t)authParam.imageinfo.GetAppThumbnailLen(); + if (appThumbnailLen > 0) { + void *appThumbnail = nullptr; + napi_value appThumbnailBuffer = nullptr; + napi_create_arraybuffer(env, appThumbnailLen, &appThumbnail, &appThumbnailBuffer); + if (appThumbnail != nullptr && + memcpy_s(appThumbnail, appThumbnailLen, + reinterpret_cast(authParam.imageinfo.GetAppThumbnail()), appThumbnailLen) == 0) { + napi_value appThumbnailArray = nullptr; + napi_create_typedarray(env, napi_uint8_array, appThumbnailLen, appThumbnailBuffer, 0, &appThumbnailArray); + napi_set_named_property(env, paramResult, "appThumbnail", appThumbnailArray); + } + } return; } diff --git a/services/devicemanagerservice/BUILD.gn b/services/devicemanagerservice/BUILD.gn index 773c4abed..9f9f9a094 100755 --- a/services/devicemanagerservice/BUILD.gn +++ b/services/devicemanagerservice/BUILD.gn @@ -26,6 +26,7 @@ if (defined(ohos_lite)) { "include/config", "include/adapter", "include/authentication", + "include/authentication/showconfirm/lite", "include/ability", "include/deviceinfo", "include/devicestate", @@ -71,8 +72,8 @@ if (defined(ohos_lite)) { "src/authentication/auth_message_processor.cpp", "src/authentication/auth_request_state.cpp", "src/authentication/auth_response_state.cpp", - "src/authentication/auth_ui.cpp", "src/authentication/dm_auth_manager.cpp", + "src/authentication/showconfirm/lite/show_confirm.cpp", "src/config/dm_config_manager.cpp", "src/dependency/hichain/hichain_connector.cpp", "src/dependency/multipleuser/multiple_user_connector.cpp", @@ -125,6 +126,7 @@ if (defined(ohos_lite)) { "include/config", "include/adapter", "include/authentication", + "include/authentication/showconfirm/standard", "include/ability", "include/deviceinfo", "include/devicestate", @@ -155,8 +157,8 @@ if (defined(ohos_lite)) { "src/authentication/auth_message_processor.cpp", "src/authentication/auth_request_state.cpp", "src/authentication/auth_response_state.cpp", - "src/authentication/auth_ui.cpp", "src/authentication/dm_auth_manager.cpp", + "src/authentication/showconfirm/standard/show_confirm.cpp", "src/config/dm_config_manager.cpp", "src/dependency/commonevent/dm_common_event_manager.cpp", "src/dependency/hichain/hichain_connector.cpp", diff --git a/services/devicemanagerservice/include/authentication/auth_ui.h b/services/devicemanagerservice/include/authentication/auth_ui.h deleted file mode 100644 index 4ba96cb50..000000000 --- a/services/devicemanagerservice/include/authentication/auth_ui.h +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef OHOS_DM_AUTH_UI_H -#define OHOS_DM_AUTH_UI_H - -#include - -#include "dm_ability_manager.h" - -namespace OHOS { -namespace DistributedHardware { -class AuthUi { -public: - AuthUi(); - int32_t ShowConfirmDialog(std::shared_ptr dmAbilityManager); - -private: - int32_t StartFaService(); - -private: - std::shared_ptr dmAbilityMgr_; -}; -} // namespace DistributedHardware -} // namespace OHOS -#endif // OHOS_DM_AUTH_UI_H \ No newline at end of file diff --git a/services/devicemanagerservice/include/authentication/authentication.h b/services/devicemanagerservice/include/authentication/authentication.h index 7c59f31c4..49b0aaccd 100644 --- a/services/devicemanagerservice/include/authentication/authentication.h +++ b/services/devicemanagerservice/include/authentication/authentication.h @@ -27,6 +27,7 @@ public: virtual int32_t ShowAuthInfo(std::string &authToken, std::shared_ptr authManager) = 0; virtual int32_t StartAuth(std::string &authToken, std::shared_ptr authManager) = 0; virtual int32_t VerifyAuthentication(std::string &authToken, const std::string &authParam) = 0; + virtual int32_t CloseAuthInfo(const int32_t &pageId, std::shared_ptr authManager) = 0; }; using CreateIAuthAdapterFuncPtr = IAuthentication *(*)(void); diff --git a/services/devicemanagerservice/include/authentication/dm_auth_manager.h b/services/devicemanagerservice/include/authentication/dm_auth_manager.h index 9e1dd3b69..799e61e3a 100644 --- a/services/devicemanagerservice/include/authentication/dm_auth_manager.h +++ b/services/devicemanagerservice/include/authentication/dm_auth_manager.h @@ -21,7 +21,6 @@ #include "auth_request_state.h" #include "auth_response_state.h" -#include "auth_ui.h" #include "authentication.h" #include "device_manager_service_listener.h" #include "dm_ability_manager.h" diff --git a/services/devicemanagerservice/src/authentication/auth_ui.cpp b/services/devicemanagerservice/src/authentication/auth_ui.cpp deleted file mode 100644 index b3afce453..000000000 --- a/services/devicemanagerservice/src/authentication/auth_ui.cpp +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "auth_ui.h" - -#include "dm_ability_manager.h" -#include "dm_constants.h" -#include "dm_log.h" - -namespace OHOS { -namespace DistributedHardware { -AuthUi::AuthUi() -{ - LOGI("AuthUi constructor"); -} - -int32_t AuthUi::ShowConfirmDialog(std::shared_ptr dmAbilityManager) -{ - if (dmAbilityManager == nullptr) { - LOGE("AuthUi::dmAbilityManager is null"); - return DM_FAILED; - } - dmAbilityMgr_ = dmAbilityManager; - return StartFaService(); -} - -int32_t AuthUi::StartFaService() -{ - AbilityStatus status = dmAbilityMgr_->StartAbility(AbilityRole::ABILITY_ROLE_PASSIVE); - if (status != AbilityStatus::ABILITY_STATUS_SUCCESS) { - LOGE("AuthUi::StartFaService timeout"); - return DM_FAILED; - } - return DM_OK; -} -} // namespace DistributedHardware -} // namespace OHOS diff --git a/services/devicemanagerservice/src/authentication/dm_auth_manager.cpp b/services/devicemanagerservice/src/authentication/dm_auth_manager.cpp index 18cea2e63..586a8b684 100644 --- a/services/devicemanagerservice/src/authentication/dm_auth_manager.cpp +++ b/services/devicemanagerservice/src/authentication/dm_auth_manager.cpp @@ -16,7 +16,6 @@ #include "dm_auth_manager.h" #include "auth_message_processor.h" -#include "auth_ui.h" #include "dm_ability_manager.h" #include "dm_config_manager.h" #include "dm_constants.h" @@ -25,11 +24,7 @@ #include "multiple_user_connector.h" #include "nlohmann/json.hpp" #include "parameter.h" -#ifndef LITE_DEVICE -#include "ui_service_mgr_client.h" -#include "dialog_callback_stub.h" -#include "dialog_callback.h" -#endif +#include "show_confirm.h" namespace OHOS { namespace DistributedHardware { @@ -557,9 +552,13 @@ int32_t DmAuthManager::AddMember(const std::string &deviceId) return DM_FAILED; } LOGI("DmAuthManager::authRequestContext CancelDisplay start"); -#ifndef LITE_DEVICE - Ace::UIServiceMgrClient::GetInstance()->CancelDialog(authResponseContext_->pageId); -#endif + std::shared_ptr ptr; + if (authenticationMap_.find(authResponseContext_->authType) == authenticationMap._end()) { + LOGE("DmAuthManager::authenticationMap_ is null"); + return DM_FAILED; + } + ptr = authenticationMap_[authResponseContext_->authType]; + pr->CloseAuthInfo(authResponseContext_->pageId, shared_form_this()); return DM_OK; } @@ -588,16 +587,20 @@ void DmAuthManager::AuthenticateFinish() { LOGI("DmAuthManager::AuthenticateFinish start"); if (authResponseState_ != nullptr) { -#ifndef LITE_DEVICE if (authResponseState_->GetStateType() == AuthState::AUTH_RESPONSE_FINISH) { - Ace::UIServiceMgrClient::GetInstance()->CancelDialog(authResponseContext_->pageId); + std::shared_ptr ptr; + if (authenticationMap_.find(authResponseContext_->authType) == authenticationMap._end()) { + LOGE("DmAuthManager::authenticationMap_ is null"); + return ; + } + ptr = authenticationMap_[authResponseContext_->authType]; + pr->CloseAuthInfo(authResponseContext_->pageId, shared_form_this()); } if (isFinishOfLocal_) { authMessageProcessor_->SetResponseContext(authResponseContext_); std::string message = authMessageProcessor_->CreateSimpleMessage(MSG_TYPE_REQ_AUTH_TERMINATE); softbusConnector_->GetSoftbusSession()->SendData(authResponseContext_->sessionId, message); } -#endif if (!timerMap_.empty()) { for (auto &iter : timerMap_) { iter.second->Stop(SESSION_CANCEL_TIMEOUT); @@ -617,11 +620,15 @@ void DmAuthManager::AuthenticateFinish() authRequestContext_->reason = authResponseContext_->reply; } -#ifndef LITE_DEVICE if (authResponseContext_->state == AuthState::AUTH_REQUEST_INPUT) { - Ace::UIServiceMgrClient::GetInstance()->CancelDialog(authResponseContext_->pageId); + std::shared_ptr ptr; + if (authenticationMap_.find(authResponseContext_->authType) == authenticationMap._end()) { + LOGE("DmAuthManager::authenticationMap_ is null"); + return ; + } + ptr = authenticationMap_[authResponseContext_->authType]; + pr->CloseAuthInfo(authResponseContext_->pageId, shared_form_this()); } -#endif listener_->OnAuthResult(authRequestContext_->hostPkgName, authRequestContext_->deviceId, authRequestContext_->token, authResponseContext_->state, authRequestContext_->reason); @@ -719,20 +726,8 @@ void DmAuthManager::ShowConfigDialog() jsonObj[TARGET_PKG_NAME_KEY] = authResponseContext_->targetPkgName; jsonObj.dump(); const std::string params = jsonObj.dump(); - std::shared_ptr authMgr_ = shared_from_this(); - -#ifndef LITE_DEVICE - Ace::UIServiceMgrClient::GetInstance()->ShowDialog( - "config_dialog_service", - params, - OHOS::Rosen::WindowType::WINDOW_TYPE_SYSTEM_ALARM_WINDOW, - ACE_X, ACE_Y, ACE_WIDTH, ACE_HEIGHT, - [authMgr_](int32_t id, const std::string& event, const std::string& params) { - Ace::UIServiceMgrClient::GetInstance()->CancelDialog(id); - LOGI("CancelDialog start id:%d,event:%s,parms:%s", id, event.c_str(), params.c_str()); - authMgr_->StartAuthProcess(atoi(params.c_str())); - }); -#endif + std::shared_ptr shwoConfirm_ = std::make_shared(); + showConfirm_->ShowConfirmDialog(params, shared_form_this()); LOGI("ShowConfigDialog end"); } -- Gitee From 2909ef751d416bb63b57b18474ae462ce3c64354 Mon Sep 17 00:00:00 2001 From: zixing000 Date: Thu, 17 Mar 2022 15:41:43 +0800 Subject: [PATCH 13/24] codecheck Signed-off-by: zixing000 --- services/devicemanagerservice/BUILD.gn | 1 - .../src/adapter/lite/dm_adapter_manager.cpp | 6 +++--- .../src/dependency/softbus/softbus_connector.cpp | 4 ---- 3 files changed, 3 insertions(+), 8 deletions(-) diff --git a/services/devicemanagerservice/BUILD.gn b/services/devicemanagerservice/BUILD.gn index 9f9f9a094..31d9477c0 100755 --- a/services/devicemanagerservice/BUILD.gn +++ b/services/devicemanagerservice/BUILD.gn @@ -106,7 +106,6 @@ if (defined(ohos_lite)) { "${utils_path}:devicemanagerutils", "//base/hiviewdfx/hilog_lite/frameworks/featured:hilog_shared", "//base/security/deviceauth/services:deviceauth_sdk", - "//base/startup/syspara_lite/frameworks/parameter/src:sysparam", "//foundation/communication/dsoftbus/sdk:softbus_client", "//foundation/communication/ipc_lite:liteipc_adapter", "//foundation/distributedschedule/samgr_lite/samgr:samgr", diff --git a/services/devicemanagerservice/src/adapter/lite/dm_adapter_manager.cpp b/services/devicemanagerservice/src/adapter/lite/dm_adapter_manager.cpp index ac6f5c480..2abbce6d5 100644 --- a/services/devicemanagerservice/src/adapter/lite/dm_adapter_manager.cpp +++ b/services/devicemanagerservice/src/adapter/lite/dm_adapter_manager.cpp @@ -28,17 +28,17 @@ DmAdapterManager &DmAdapterManager::GetInstance() std::shared_ptr DmAdapterManager::GetDecisionAdapter(const std::string &soName) { - return NULL; + return nullptr; } std::shared_ptr DmAdapterManager::GetProfileAdapter(const std::string &soName) { - return NULL; + return nullptr; } std::shared_ptr DmAdapterManager::GetCryptoAdapter(const std::string &soName) { - return NULL; + return nullptr; } } // namespace DistributedHardware } // namespace OHOS diff --git a/services/devicemanagerservice/src/dependency/softbus/softbus_connector.cpp b/services/devicemanagerservice/src/dependency/softbus/softbus_connector.cpp index 5379cf795..104321a19 100644 --- a/services/devicemanagerservice/src/dependency/softbus/softbus_connector.cpp +++ b/services/devicemanagerservice/src/dependency/softbus/softbus_connector.cpp @@ -96,7 +96,6 @@ int32_t SoftbusConnector::Init() usleep(SOFTBUS_CHECK_INTERVAL); } } while (ret != DM_OK); - LOGI("RegNodeDeviceStateCb success."); PublishInfo dmPublishInfo; dmPublishInfo.publishId = DISTRIBUTED_HARDWARE_DEVICEMANAGER_SA_ID; @@ -106,7 +105,6 @@ int32_t SoftbusConnector::Init() dmPublishInfo.capability = DM_CAPABILITY_OSD; dmPublishInfo.capabilityData = nullptr; dmPublishInfo.dataLen = 0; - char discoverStatus[DISCOVER_STATUS_LEN + 1] = {0}; ret = GetParameter(DISCOVER_STATUS_KEY.c_str(), "not exist", discoverStatus, DISCOVER_STATUS_LEN); if (strcmp(discoverStatus, "not exist") == 0) { @@ -136,10 +134,8 @@ int32_t SoftbusConnector::Init() if (ret == DM_OK) { publishStatus = ALLOW_BE_DISCOVERY; } - LOGI("service publish result is : %d", ret); #else ret = WatchParameter(DISCOVER_STATUS_KEY.c_str(), &SoftbusConnector::OnParameterChgCallback, nullptr); - LOGI("register Watch Parameter result is : %d", ret); #endif return ret; } -- Gitee From 5ea5eb391f1be996085670fa2658cdc701531594 Mon Sep 17 00:00:00 2001 From: zixing000 Date: Thu, 17 Mar 2022 16:39:56 +0800 Subject: [PATCH 14/24] ui Signed-off-by: zixing000 --- .../ext/pin_auth/src/pin_auth_ui.cpp | 0 ext/pin_auth/include/lite/pin_auth_ui.h | 38 ++++++ ext/pin_auth/include/standard/pin_auth_ui.h | 38 ++++++ ext/pin_auth/src/lite/pin_auth_ui.cpp | 71 +++++++++++ ext/pin_auth/src/standard/pin_auth_ui.cpp | 110 ++++++++++++++++++ .../showconfirm/lite/show_confirm.h | 31 +++++ .../showconfirm/standard/show_confirm.h | 32 +++++ .../src/authentication/dm_auth_manager.cpp | 3 +- .../showconfirm/lite/show_confirm.cpp | 46 ++++++++ .../showconfirm/standard/show_confirm.cpp | 63 ++++++++++ 10 files changed, 431 insertions(+), 1 deletion(-) create mode 100644 device_manager_test/ext/pin_auth/src/pin_auth_ui.cpp create mode 100644 ext/pin_auth/include/lite/pin_auth_ui.h create mode 100644 ext/pin_auth/include/standard/pin_auth_ui.h create mode 100644 ext/pin_auth/src/lite/pin_auth_ui.cpp create mode 100644 ext/pin_auth/src/standard/pin_auth_ui.cpp create mode 100644 services/devicemanagerservice/include/authentication/showconfirm/lite/show_confirm.h create mode 100644 services/devicemanagerservice/include/authentication/showconfirm/standard/show_confirm.h create mode 100644 services/devicemanagerservice/src/authentication/showconfirm/lite/show_confirm.cpp create mode 100644 services/devicemanagerservice/src/authentication/showconfirm/standard/show_confirm.cpp diff --git a/device_manager_test/ext/pin_auth/src/pin_auth_ui.cpp b/device_manager_test/ext/pin_auth/src/pin_auth_ui.cpp new file mode 100644 index 000000000..e69de29bb diff --git a/ext/pin_auth/include/lite/pin_auth_ui.h b/ext/pin_auth/include/lite/pin_auth_ui.h new file mode 100644 index 000000000..dfa24cf89 --- /dev/null +++ b/ext/pin_auth/include/lite/pin_auth_ui.h @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef OHOS_DM_PIN_AUTH_UI_H +#define OHOS_DM_PIN_AUTH_UI_H + +#include + +#include "dm_auth_manager.h" +#include "dm_ability_manager.h" + +namespace OHOS { +namespace DistributedHardware { +class PinAuthUi { +public: + PinAuthUi(); + int32_t ShowPinDialog(int32_t code, std::shared_ptr authManager); + int32_t InputPinDialog(int32_t code, std::shared_ptr authManager); + int32_t ClosePage(const int32_t &pageId, std::shared_ptr authManager); + +private: + int32_t StartFaUiService(std::shared_ptr dmAbilityManager); +}; +} // namespace DistributedHardware +} // namespace OHOS +#endif // OHOS_DM_PIN_AUTH_UI_H diff --git a/ext/pin_auth/include/standard/pin_auth_ui.h b/ext/pin_auth/include/standard/pin_auth_ui.h new file mode 100644 index 000000000..dfa24cf89 --- /dev/null +++ b/ext/pin_auth/include/standard/pin_auth_ui.h @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef OHOS_DM_PIN_AUTH_UI_H +#define OHOS_DM_PIN_AUTH_UI_H + +#include + +#include "dm_auth_manager.h" +#include "dm_ability_manager.h" + +namespace OHOS { +namespace DistributedHardware { +class PinAuthUi { +public: + PinAuthUi(); + int32_t ShowPinDialog(int32_t code, std::shared_ptr authManager); + int32_t InputPinDialog(int32_t code, std::shared_ptr authManager); + int32_t ClosePage(const int32_t &pageId, std::shared_ptr authManager); + +private: + int32_t StartFaUiService(std::shared_ptr dmAbilityManager); +}; +} // namespace DistributedHardware +} // namespace OHOS +#endif // OHOS_DM_PIN_AUTH_UI_H diff --git a/ext/pin_auth/src/lite/pin_auth_ui.cpp b/ext/pin_auth/src/lite/pin_auth_ui.cpp new file mode 100644 index 000000000..833395ad0 --- /dev/null +++ b/ext/pin_auth/src/lite/pin_auth_ui.cpp @@ -0,0 +1,71 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "pin_auth_ui.h" + +#include "dm_ability_manager.h" +#include "dm_constants.h" +#include "dm_log.h" +#include "nlohmann/json.hpp" +#include "ui_service_mgr_client.h" + +namespace OHOS { +namespace DistributedHardware { +PinAuthUi::PinAuthUi() +{ + LOGI("AuthUi constructor"); +} + +int32_t PinAuthUi::ShowPinDialog(int32_t code, std::shared_ptr authManager) +{ + LOGI("ShowConfigDialog end"); + return DM_OK; +} + +int32_t PinAuthUi::InputPinDialog(int32_t code, std::shared_ptr authManager) +{ + LOGI("InputPinDialog start"); + std::shared_ptr dmAbilityManager_ = std::make_shared(); + if (dmAbilityManager_ == nullptr) { + LOGE("PinAuthUi::dmAbilityManager is null"); + return DM_FAILED; + } + LOGI("InputPinDialog end"); + return StartFaUiService(dmAbilityManager_); +} + +int32_t ClosePage(const int32_t &pageId, std::shared_ptr authManager) +{ + LOGI("ClosePage hap start"); + if (authManager == nullptr) { + LOGE("PinAuthUi::authManager is null"); + return DM_FAILED; + } + LOGI("ClosePage hap end"); + authManager->CancelDisplay(); + return DM_OK; +} + +int32_t PinAuthUi::StartFaUiService(std::shared_ptr dmAbilityManager) +{ + AbilityStatus status = dmAbilityManager->StartAbility(AbilityRole::ABILITY_ROLE_INITIATIVE); + if (status != AbilityStatus::ABILITY_STATUS_SUCCESS) { + LOGE("PinAuthUi::StartFaService timeout"); + return DM_FAILED; + } + return DM_OK; +} +} // namespace DistributedHardware +} // namespace OHOS diff --git a/ext/pin_auth/src/standard/pin_auth_ui.cpp b/ext/pin_auth/src/standard/pin_auth_ui.cpp new file mode 100644 index 000000000..64aa4ef15 --- /dev/null +++ b/ext/pin_auth/src/standard/pin_auth_ui.cpp @@ -0,0 +1,110 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "pin_auth_ui.h" + +#include "dm_ability_manager.h" +#include "dm_constants.h" +#include "dm_log.h" +#include "nlohmann/json.hpp" +#include "ui_service_mgr_client.h" + +namespace OHOS { +namespace DistributedHardware { +PinAuthUi::PinAuthUi() +{ + LOGI("AuthUi constructor"); +} + +int32_t PinAuthUi::ShowPinDialog(int32_t code, std::shared_ptr authManager) +{ + LOGI("ShowPinDialog start"); + if (authManger == nullptr) { + LOGE("ShowPinDialog authManager is null"); + return DM_FAILED; + } + nlohmann::json jsonObj; + jsonObj[PIN_CODE_KEY] = code; + jsonObj.dump(); + const std::string params = jsonObj.dump(); + + Ace::UIServiceMgrClient::GetInstance()->ShowDialog( + "show_pin_service", + params, + OHOS::Rosen::WindowType::WINDOW_TYPE_SYSTEM_ALARM_WINDOW, + ACE_X, ACE_Y, ACE_WIDTH, ACE_HEIGHT, + [authManager](int32_t id, const std::string& event, const std::string& params) { + if (strcmp(params.c_str(), "0") == 0) { + authManager->SetPageId(id); + } + if (strcmp(params.c_str(), "1") == 0) { + LOGI("CancelDialog start id:%d,event:%s,parms:%s", id, event.c_str(), params.c_str()); + Ace::UIServiceMgrClient::GetInstance()->CancelDialog(id); + } + }); + LOGI("ShowConfigDialog end"); + return DM_OK; +} + +int32_t PinAuthUi::InputPinDialog(int32_t code, std::shared_ptr authManager) +{ + LOGI("InputPinDialog start"); + if (authManger == nullptr) { + LOGE("ShowPinDialog InputPinDialog is null"); + return DM_FAILED; + } + nlohmann::json jsonObj; + jsonObj[PIN_CODE_KEY] = code; + jsonObj.dump(); + const std::string params = jsonObj.dump(); + + Ace::UIServiceMgrClient::GetInstance()->ShowDialog( + "input_pin_service", + params, + OHOS::Rosen::WindowType::WINDOW_TYPE_SYSTEM_ALARM_WINDOW, + ACE_X, ACE_Y, ACE_WIDTH, ACE_HEIGHT, + [authManager](int32_t id, const std::string& event, const std::string& params) { + if (strcmp(params.c_str(), "2") == 0) { + authManager->SetPageId(id); + } + if (strcmp(params.c_str(), "0") == 0 || strcmp(params.c_str(), "1") == 0) { + Ace::UIServiceMgrClient::GetInstance()->CancelDialog(id); + LOGI("CancelDialog start id:%d,event:%s,parms:%s", id, event.c_str(), params.c_str()); + authManager->VerifyAuthentication(params.c_str()); + } + }); + LOGI("ShowConfigDialog end"); + return DM_OK; +} + +int32_t PinAuthUi(const int32_t &pageId, std::shared_ptr authManager) +{ + LOGI("PinAuthUi start"); + Ace::UIServiceMgrClient::GetInstance()->CancelDialog(pageId); + LOGI("PinAuthUi end"); + return DM_OK; +} + +int32_t PinAuthUi::StartFaUiService(std::shared_ptr dmAbilityManager) +{ + AbilityStatus status = dmAbilityManager->StartAbility(AbilityRole::ABILITY_ROLE_INITIATIVE); + if (status != AbilityStatus::ABILITY_STATUS_SUCCESS) { + LOGE("PinAuthUi::StartFaService timeout"); + return DM_FAILED; + } + return DM_OK; +} +} // namespace DistributedHardware +} // namespace OHOS diff --git a/services/devicemanagerservice/include/authentication/showconfirm/lite/show_confirm.h b/services/devicemanagerservice/include/authentication/showconfirm/lite/show_confirm.h new file mode 100644 index 000000000..86322acca --- /dev/null +++ b/services/devicemanagerservice/include/authentication/showconfirm/lite/show_confirm.h @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef OHOS_DM_SHOW_CONFIRM_H +#define OHOS_DM_SHOW_CONFIRM_H + +#include + +namespace OHOS { +namespace DistributedHardware { +class ShwoConfirm { + ShwoConfirm(); + ~ShwoConfirm(); + void ShowConfirmDialog(const std::string ¶ms, + std::shared_ptr authManager, std::shared_ptr dmAbilityMgr); +} +} // namespace DistributedHardware +} // namespace OHOS +#endif // OHOS_DM_SHOW_CONFIRM_H diff --git a/services/devicemanagerservice/include/authentication/showconfirm/standard/show_confirm.h b/services/devicemanagerservice/include/authentication/showconfirm/standard/show_confirm.h new file mode 100644 index 000000000..dd36bc008 --- /dev/null +++ b/services/devicemanagerservice/include/authentication/showconfirm/standard/show_confirm.h @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef OHOS_DM_SHOW_CONFIRM_H +#define OHOS_DM_SHOW_CONFIRM_H + +#include + +namespace OHOS { +namespace DistributedHardware { +class ShwoConfirm { + ShwoConfirm(); + ~ShwoConfirm(); + void ShowConfirmDialog(const std::string ¶ms, + std::shared_ptr authManager, std::shared_ptr dmAbilityMgr); +} +} // namespace DistributedHardware +} // namespace OHOS +#endif // OHOS_DM_SHOW_CONFIRM_H + diff --git a/services/devicemanagerservice/src/authentication/dm_auth_manager.cpp b/services/devicemanagerservice/src/authentication/dm_auth_manager.cpp index 586a8b684..dc01a84b6 100644 --- a/services/devicemanagerservice/src/authentication/dm_auth_manager.cpp +++ b/services/devicemanagerservice/src/authentication/dm_auth_manager.cpp @@ -720,6 +720,7 @@ int32_t DmAuthManager::GetPinCode() void DmAuthManager::ShowConfigDialog() { LOGI("ShowConfigDialog start"); + dmAbilityMgr_ = std::make_shared(); nlohmann::json jsonObj; jsonObj[TAG_AUTH_TYPE] = AUTH_TYPE_PIN; jsonObj[TAG_TOKEN] = authResponseContext_->token; @@ -727,7 +728,7 @@ void DmAuthManager::ShowConfigDialog() jsonObj.dump(); const std::string params = jsonObj.dump(); std::shared_ptr shwoConfirm_ = std::make_shared(); - showConfirm_->ShowConfirmDialog(params, shared_form_this()); + showConfirm_->ShowConfirmDialog(params, shared_form_this(), dmAbilityMgr_); LOGI("ShowConfigDialog end"); } diff --git a/services/devicemanagerservice/src/authentication/showconfirm/lite/show_confirm.cpp b/services/devicemanagerservice/src/authentication/showconfirm/lite/show_confirm.cpp new file mode 100644 index 000000000..a7f372bd2 --- /dev/null +++ b/services/devicemanagerservice/src/authentication/showconfirm/lite/show_confirm.cpp @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "show_confirm.h" + +#include +#include + +#include "dm_auth_manager.h" +#include "dm_ability_manager.h" +#include "dm_constants.h" +#include "dm_log.h" + +namespace OHOS { +namespace DistributedHardware { +ShwoConfirm::ShwoConfirm(); +ShwoConfirm::~ShwoConfirm(); +void ShwoConfirm::ShowConfirmDialog(const std::string ¶ms, std::shared_ptr authManager, + std::shared_ptr dmAbilityMgr) +{ + LOGI("ShowConfirm hap start"); + if (dmAbilityMgr == nullptr) { + LOGE("ShowConfirm::dmAbilityManager is null"); + return; + } + AbilityStatus status = dmAbilityMgr_->StartAbility(AbilityRole::ABILITY_ROLE_PASSIVE); + if (status != Ability:status::ABILITY_STATUS_SUCCESS) { + LOGE("ShowConfirm::startFaservice timeout"); + return; + } + LOGI("ShowConfirm hap end"); +} +} // namespace DistributedHardware +} // namespace OHOS diff --git a/services/devicemanagerservice/src/authentication/showconfirm/standard/show_confirm.cpp b/services/devicemanagerservice/src/authentication/showconfirm/standard/show_confirm.cpp new file mode 100644 index 000000000..15208b871 --- /dev/null +++ b/services/devicemanagerservice/src/authentication/showconfirm/standard/show_confirm.cpp @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "show_confirm.h" + +#include +#include + +#include "dm_auth_manager.h" +#include "dm_constants.h" +#include "dm_log.h" +#include "ui_service_mgr_client.h" + +namespace OHOS { +namespace DistributedHardware { +ShwoConfirm::ShwoConfirm() +{ + LOGI("ShowConfirm ace constructor"); +} + +ShwoConfirm::~ShwoConfirm() +{ +} + +void ShwoConfirm::ShowConfirmDialog(const std::string ¶ms, std::shared_ptr authManager, + std::shared_ptr dmAbilityMgr) +{ + LOGI("ShowConfirm ace start"); + if (authManager == nullptr) { + LOGE("ShowConfirm::dmAbilityManager is null"); + return; + } + Ace::UIServiceMgrClient::GetInstance()->ShowDialog( + "config_dialog_service", + params, + OHOS::Rosen::WindowType::WINDOW_TYPE_SYSTEM_ALARM_WINDOW, + ACE_X, ACE_Y, ACE_WIDTH, ACE_HEIGHT, + [authManager](int32_t id, const std::string& event, const std::string& params) { + if (strcmp(params.c_str(), "2") == 0) { + authManager->SetPageId(id); + } + if (strcmp(params.c_str(), "0") == 0 || strcmp(params.c_str(), "1") == 0) { + Ace::UIServiceMgrClient::GetInstance()->CancelDialog(id); + LOGI("CancelDialog start id:%d,event:%s,parms:%s", id, event.c_str(), params.c_str()); + authManager->StartAuthProcess(atoi(params.c_str())); + } + }); + LOGI("ShowConfirm ace end"); +} +} // namespace DistributedHardware +} // namespace OHOS -- Gitee From e36bf532fc0c808dce54081676e26c8f1b5d80ee Mon Sep 17 00:00:00 2001 From: zixing000 Date: Thu, 17 Mar 2022 16:57:08 +0800 Subject: [PATCH 15/24] codecheck Signed-off-by: zixing000 --- ext/pin_auth/src/pin_auth_ui.cpp | 0 .../src/authentication/showconfirm/lite/show_confirm.cpp | 7 ++----- .../authentication/showconfirm/standard/show_confirm.cpp | 5 +---- 3 files changed, 3 insertions(+), 9 deletions(-) delete mode 100644 ext/pin_auth/src/pin_auth_ui.cpp diff --git a/ext/pin_auth/src/pin_auth_ui.cpp b/ext/pin_auth/src/pin_auth_ui.cpp deleted file mode 100644 index e69de29bb..000000000 diff --git a/services/devicemanagerservice/src/authentication/showconfirm/lite/show_confirm.cpp b/services/devicemanagerservice/src/authentication/showconfirm/lite/show_confirm.cpp index a7f372bd2..ecf16a416 100644 --- a/services/devicemanagerservice/src/authentication/showconfirm/lite/show_confirm.cpp +++ b/services/devicemanagerservice/src/authentication/showconfirm/lite/show_confirm.cpp @@ -15,9 +15,6 @@ #include "show_confirm.h" -#include -#include - #include "dm_auth_manager.h" #include "dm_ability_manager.h" #include "dm_constants.h" @@ -28,14 +25,14 @@ namespace DistributedHardware { ShwoConfirm::ShwoConfirm(); ShwoConfirm::~ShwoConfirm(); void ShwoConfirm::ShowConfirmDialog(const std::string ¶ms, std::shared_ptr authManager, - std::shared_ptr dmAbilityMgr) + std::shared_ptr dmAbilityMgr) { LOGI("ShowConfirm hap start"); if (dmAbilityMgr == nullptr) { LOGE("ShowConfirm::dmAbilityManager is null"); return; } - AbilityStatus status = dmAbilityMgr_->StartAbility(AbilityRole::ABILITY_ROLE_PASSIVE); + AbilityStatus status = dmAbilityMgr->StartAbility(AbilityRole::ABILITY_ROLE_PASSIVE); if (status != Ability:status::ABILITY_STATUS_SUCCESS) { LOGE("ShowConfirm::startFaservice timeout"); return; diff --git a/services/devicemanagerservice/src/authentication/showconfirm/standard/show_confirm.cpp b/services/devicemanagerservice/src/authentication/showconfirm/standard/show_confirm.cpp index 15208b871..f502fe959 100644 --- a/services/devicemanagerservice/src/authentication/showconfirm/standard/show_confirm.cpp +++ b/services/devicemanagerservice/src/authentication/showconfirm/standard/show_confirm.cpp @@ -15,9 +15,6 @@ #include "show_confirm.h" -#include -#include - #include "dm_auth_manager.h" #include "dm_constants.h" #include "dm_log.h" @@ -35,7 +32,7 @@ ShwoConfirm::~ShwoConfirm() } void ShwoConfirm::ShowConfirmDialog(const std::string ¶ms, std::shared_ptr authManager, - std::shared_ptr dmAbilityMgr) + std::shared_ptr dmAbilityMgr) { LOGI("ShowConfirm ace start"); if (authManager == nullptr) { -- Gitee From 34c6e90070a52b9cdecd0a9944f46a08856fbc31 Mon Sep 17 00:00:00 2001 From: zixing000 Date: Thu, 17 Mar 2022 17:18:29 +0800 Subject: [PATCH 16/24] codecheck Signed-off-by: zixing000 --- device_manager_test/ext/pin_auth/src/pin_auth_ui.cpp | 0 ext/pin_auth/src/pin_auth.cpp | 2 +- ext/pin_auth/src/standard/pin_auth_ui.cpp | 2 +- 3 files changed, 2 insertions(+), 2 deletions(-) delete mode 100644 device_manager_test/ext/pin_auth/src/pin_auth_ui.cpp diff --git a/device_manager_test/ext/pin_auth/src/pin_auth_ui.cpp b/device_manager_test/ext/pin_auth/src/pin_auth_ui.cpp deleted file mode 100644 index e69de29bb..000000000 diff --git a/ext/pin_auth/src/pin_auth.cpp b/ext/pin_auth/src/pin_auth.cpp index 6d76b097b..25e7f54d6 100644 --- a/ext/pin_auth/src/pin_auth.cpp +++ b/ext/pin_auth/src/pin_auth.cpp @@ -103,7 +103,7 @@ int32_t PinAuth::VerifyAuthentication(std::string &authToken, const std::string int32_t PinAuth::CloseAuthInfo(const int32_t &pageId, std::shared_ptr authManager) { - return pinAuthUi_ClosePage(pageId, authManager); + return pinAuthUi_->ClosePage(pageId, authManager); } extern "C" IAuthentication *CreatePinAuthObject(void) diff --git a/ext/pin_auth/src/standard/pin_auth_ui.cpp b/ext/pin_auth/src/standard/pin_auth_ui.cpp index 64aa4ef15..6bd4697b7 100644 --- a/ext/pin_auth/src/standard/pin_auth_ui.cpp +++ b/ext/pin_auth/src/standard/pin_auth_ui.cpp @@ -89,7 +89,7 @@ int32_t PinAuthUi::InputPinDialog(int32_t code, std::shared_ptr a return DM_OK; } -int32_t PinAuthUi(const int32_t &pageId, std::shared_ptr authManager) +int32_t PinAuthUi::ClosePage(const int32_t &pageId, std::shared_ptr authManager) { LOGI("PinAuthUi start"); Ace::UIServiceMgrClient::GetInstance()->CancelDialog(pageId); -- Gitee From 6aba21486aec10e59e6689ec44a4ab9b2ddd09d0 Mon Sep 17 00:00:00 2001 From: zixing000 Date: Thu, 17 Mar 2022 17:26:31 +0800 Subject: [PATCH 17/24] codecheck Signed-off-by: zixing000 --- .../include/authentication/showconfirm/lite/show_confirm.h | 6 +++--- .../authentication/showconfirm/standard/show_confirm.h | 6 +++--- .../src/authentication/showconfirm/lite/show_confirm.cpp | 6 +++--- .../authentication/showconfirm/standard/show_confirm.cpp | 6 +++--- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/services/devicemanagerservice/include/authentication/showconfirm/lite/show_confirm.h b/services/devicemanagerservice/include/authentication/showconfirm/lite/show_confirm.h index 86322acca..40cd7d27e 100644 --- a/services/devicemanagerservice/include/authentication/showconfirm/lite/show_confirm.h +++ b/services/devicemanagerservice/include/authentication/showconfirm/lite/show_confirm.h @@ -20,9 +20,9 @@ namespace OHOS { namespace DistributedHardware { -class ShwoConfirm { - ShwoConfirm(); - ~ShwoConfirm(); +class ShowConfirm { + ShowConfirm(); + ~ShowConfirm(); void ShowConfirmDialog(const std::string ¶ms, std::shared_ptr authManager, std::shared_ptr dmAbilityMgr); } diff --git a/services/devicemanagerservice/include/authentication/showconfirm/standard/show_confirm.h b/services/devicemanagerservice/include/authentication/showconfirm/standard/show_confirm.h index dd36bc008..4823d3c0b 100644 --- a/services/devicemanagerservice/include/authentication/showconfirm/standard/show_confirm.h +++ b/services/devicemanagerservice/include/authentication/showconfirm/standard/show_confirm.h @@ -20,9 +20,9 @@ namespace OHOS { namespace DistributedHardware { -class ShwoConfirm { - ShwoConfirm(); - ~ShwoConfirm(); +class ShowConfirm { + ShowConfirm(); + ~ShowConfirm(); void ShowConfirmDialog(const std::string ¶ms, std::shared_ptr authManager, std::shared_ptr dmAbilityMgr); } diff --git a/services/devicemanagerservice/src/authentication/showconfirm/lite/show_confirm.cpp b/services/devicemanagerservice/src/authentication/showconfirm/lite/show_confirm.cpp index ecf16a416..c578dcecd 100644 --- a/services/devicemanagerservice/src/authentication/showconfirm/lite/show_confirm.cpp +++ b/services/devicemanagerservice/src/authentication/showconfirm/lite/show_confirm.cpp @@ -22,9 +22,9 @@ namespace OHOS { namespace DistributedHardware { -ShwoConfirm::ShwoConfirm(); -ShwoConfirm::~ShwoConfirm(); -void ShwoConfirm::ShowConfirmDialog(const std::string ¶ms, std::shared_ptr authManager, +ShowConfirm::ShowConfirm(); +ShowConfirm::~ShowConfirm(); +void ShowConfirm::ShowConfirmDialog(const std::string ¶ms, std::shared_ptr authManager, std::shared_ptr dmAbilityMgr) { LOGI("ShowConfirm hap start"); diff --git a/services/devicemanagerservice/src/authentication/showconfirm/standard/show_confirm.cpp b/services/devicemanagerservice/src/authentication/showconfirm/standard/show_confirm.cpp index f502fe959..54e8a2ddf 100644 --- a/services/devicemanagerservice/src/authentication/showconfirm/standard/show_confirm.cpp +++ b/services/devicemanagerservice/src/authentication/showconfirm/standard/show_confirm.cpp @@ -22,16 +22,16 @@ namespace OHOS { namespace DistributedHardware { -ShwoConfirm::ShwoConfirm() +ShowConfirm::ShowConfirm() { LOGI("ShowConfirm ace constructor"); } -ShwoConfirm::~ShwoConfirm() +ShowConfirm::~ShowConfirm() { } -void ShwoConfirm::ShowConfirmDialog(const std::string ¶ms, std::shared_ptr authManager, +void ShowConfirm::ShowConfirmDialog(const std::string ¶ms, std::shared_ptr authManager, std::shared_ptr dmAbilityMgr) { LOGI("ShowConfirm ace start"); -- Gitee From 36cb0ed6a85d6144dee0420c5d18f2e21c7ad977 Mon Sep 17 00:00:00 2001 From: zixing000 Date: Thu, 17 Mar 2022 18:34:25 +0800 Subject: [PATCH 18/24] fix bug Signed-off-by: zixing000 --- ext/pin_auth/src/standard/pin_auth_ui.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ext/pin_auth/src/standard/pin_auth_ui.cpp b/ext/pin_auth/src/standard/pin_auth_ui.cpp index 6bd4697b7..fb4222bc4 100644 --- a/ext/pin_auth/src/standard/pin_auth_ui.cpp +++ b/ext/pin_auth/src/standard/pin_auth_ui.cpp @@ -31,7 +31,7 @@ PinAuthUi::PinAuthUi() int32_t PinAuthUi::ShowPinDialog(int32_t code, std::shared_ptr authManager) { LOGI("ShowPinDialog start"); - if (authManger == nullptr) { + if (authManager == nullptr) { LOGE("ShowPinDialog authManager is null"); return DM_FAILED; } @@ -61,7 +61,7 @@ int32_t PinAuthUi::ShowPinDialog(int32_t code, std::shared_ptr au int32_t PinAuthUi::InputPinDialog(int32_t code, std::shared_ptr authManager) { LOGI("InputPinDialog start"); - if (authManger == nullptr) { + if (authManager == nullptr) { LOGE("ShowPinDialog InputPinDialog is null"); return DM_FAILED; } -- Gitee From e4863ecb83d7a4cf711d813137630b7b1e715f2b Mon Sep 17 00:00:00 2001 From: zixing000 Date: Thu, 17 Mar 2022 19:33:53 +0800 Subject: [PATCH 19/24] fix bug Signed-off-by: zixing000 --- common/include/dm_constants.h | 0 ext/profile/include/device_profile_adapter.h | 0 ext/profile/include/profile_connector.h | 0 ext/profile/src/device_profile_adapter.cpp | 0 ext/profile/src/profile_connector.cpp | 0 services/devicemanagerservice/BUILD.gn | 0 .../authentication/showconfirm/lite/show_confirm.h | 3 +++ .../showconfirm/standard/show_confirm.h | 5 ++++- .../include/devicestate/dm_device_state_manager.h | 0 .../src/authentication/dm_auth_manager.cpp | 14 +++++++------- .../src/devicestate/dm_device_state_manager.cpp | 0 11 files changed, 14 insertions(+), 8 deletions(-) mode change 100755 => 100644 common/include/dm_constants.h mode change 100755 => 100644 ext/profile/include/device_profile_adapter.h mode change 100755 => 100644 ext/profile/include/profile_connector.h mode change 100755 => 100644 ext/profile/src/device_profile_adapter.cpp mode change 100755 => 100644 ext/profile/src/profile_connector.cpp mode change 100755 => 100644 services/devicemanagerservice/BUILD.gn mode change 100755 => 100644 services/devicemanagerservice/include/devicestate/dm_device_state_manager.h mode change 100755 => 100644 services/devicemanagerservice/src/devicestate/dm_device_state_manager.cpp diff --git a/common/include/dm_constants.h b/common/include/dm_constants.h old mode 100755 new mode 100644 diff --git a/ext/profile/include/device_profile_adapter.h b/ext/profile/include/device_profile_adapter.h old mode 100755 new mode 100644 diff --git a/ext/profile/include/profile_connector.h b/ext/profile/include/profile_connector.h old mode 100755 new mode 100644 diff --git a/ext/profile/src/device_profile_adapter.cpp b/ext/profile/src/device_profile_adapter.cpp old mode 100755 new mode 100644 diff --git a/ext/profile/src/profile_connector.cpp b/ext/profile/src/profile_connector.cpp old mode 100755 new mode 100644 diff --git a/services/devicemanagerservice/BUILD.gn b/services/devicemanagerservice/BUILD.gn old mode 100755 new mode 100644 diff --git a/services/devicemanagerservice/include/authentication/showconfirm/lite/show_confirm.h b/services/devicemanagerservice/include/authentication/showconfirm/lite/show_confirm.h index 40cd7d27e..3042ff7ba 100644 --- a/services/devicemanagerservice/include/authentication/showconfirm/lite/show_confirm.h +++ b/services/devicemanagerservice/include/authentication/showconfirm/lite/show_confirm.h @@ -17,10 +17,13 @@ #define OHOS_DM_SHOW_CONFIRM_H #include +#include +#include namespace OHOS { namespace DistributedHardware { class ShowConfirm { +public: ShowConfirm(); ~ShowConfirm(); void ShowConfirmDialog(const std::string ¶ms, diff --git a/services/devicemanagerservice/include/authentication/showconfirm/standard/show_confirm.h b/services/devicemanagerservice/include/authentication/showconfirm/standard/show_confirm.h index 4823d3c0b..20ca3c2ec 100644 --- a/services/devicemanagerservice/include/authentication/showconfirm/standard/show_confirm.h +++ b/services/devicemanagerservice/include/authentication/showconfirm/standard/show_confirm.h @@ -17,15 +17,18 @@ #define OHOS_DM_SHOW_CONFIRM_H #include +#include +#include namespace OHOS { namespace DistributedHardware { class ShowConfirm { +public: ShowConfirm(); ~ShowConfirm(); void ShowConfirmDialog(const std::string ¶ms, std::shared_ptr authManager, std::shared_ptr dmAbilityMgr); -} +}; } // namespace DistributedHardware } // namespace OHOS #endif // OHOS_DM_SHOW_CONFIRM_H diff --git a/services/devicemanagerservice/include/devicestate/dm_device_state_manager.h b/services/devicemanagerservice/include/devicestate/dm_device_state_manager.h old mode 100755 new mode 100644 diff --git a/services/devicemanagerservice/src/authentication/dm_auth_manager.cpp b/services/devicemanagerservice/src/authentication/dm_auth_manager.cpp index dc01a84b6..85e06aa28 100644 --- a/services/devicemanagerservice/src/authentication/dm_auth_manager.cpp +++ b/services/devicemanagerservice/src/authentication/dm_auth_manager.cpp @@ -553,12 +553,12 @@ int32_t DmAuthManager::AddMember(const std::string &deviceId) } LOGI("DmAuthManager::authRequestContext CancelDisplay start"); std::shared_ptr ptr; - if (authenticationMap_.find(authResponseContext_->authType) == authenticationMap._end()) { + if (authenticationMap_.find(authResponseContext_->authType) == authenticationMap_.end()) { LOGE("DmAuthManager::authenticationMap_ is null"); return DM_FAILED; } ptr = authenticationMap_[authResponseContext_->authType]; - pr->CloseAuthInfo(authResponseContext_->pageId, shared_form_this()); + ptr->CloseAuthInfo(authResponseContext_->pageId, shared_form_this()); return DM_OK; } @@ -589,12 +589,12 @@ void DmAuthManager::AuthenticateFinish() if (authResponseState_ != nullptr) { if (authResponseState_->GetStateType() == AuthState::AUTH_RESPONSE_FINISH) { std::shared_ptr ptr; - if (authenticationMap_.find(authResponseContext_->authType) == authenticationMap._end()) { + if (authenticationMap_.find(authResponseContext_->authType) == authenticationMap_.end()) { LOGE("DmAuthManager::authenticationMap_ is null"); return ; } ptr = authenticationMap_[authResponseContext_->authType]; - pr->CloseAuthInfo(authResponseContext_->pageId, shared_form_this()); + ptr->CloseAuthInfo(authResponseContext_->pageId, shared_form_this()); } if (isFinishOfLocal_) { authMessageProcessor_->SetResponseContext(authResponseContext_); @@ -622,12 +622,12 @@ void DmAuthManager::AuthenticateFinish() if (authResponseContext_->state == AuthState::AUTH_REQUEST_INPUT) { std::shared_ptr ptr; - if (authenticationMap_.find(authResponseContext_->authType) == authenticationMap._end()) { + if (authenticationMap_.find(authResponseContext_->authType) == authenticationMap_.end()) { LOGE("DmAuthManager::authenticationMap_ is null"); return ; } ptr = authenticationMap_[authResponseContext_->authType]; - pr->CloseAuthInfo(authResponseContext_->pageId, shared_form_this()); + ptr->CloseAuthInfo(authResponseContext_->pageId, shared_form_this()); } listener_->OnAuthResult(authRequestContext_->hostPkgName, authRequestContext_->deviceId, @@ -727,7 +727,7 @@ void DmAuthManager::ShowConfigDialog() jsonObj[TARGET_PKG_NAME_KEY] = authResponseContext_->targetPkgName; jsonObj.dump(); const std::string params = jsonObj.dump(); - std::shared_ptr shwoConfirm_ = std::make_shared(); + std::shared_ptr showConfirm_ = std::make_shared(); showConfirm_->ShowConfirmDialog(params, shared_form_this(), dmAbilityMgr_); LOGI("ShowConfigDialog end"); } diff --git a/services/devicemanagerservice/src/devicestate/dm_device_state_manager.cpp b/services/devicemanagerservice/src/devicestate/dm_device_state_manager.cpp old mode 100755 new mode 100644 -- Gitee From 3c9c0724d4a3004b1de8693d93f431caa42cd29f Mon Sep 17 00:00:00 2001 From: zixing000 Date: Thu, 17 Mar 2022 20:04:34 +0800 Subject: [PATCH 20/24] fix bug Signed-off-by: zixing000 --- .../authentication/showconfirm/lite/show_confirm.h | 3 +++ .../authentication/showconfirm/standard/show_confirm.h | 3 +++ .../src/authentication/dm_auth_manager.cpp | 8 ++++---- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/services/devicemanagerservice/include/authentication/showconfirm/lite/show_confirm.h b/services/devicemanagerservice/include/authentication/showconfirm/lite/show_confirm.h index 3042ff7ba..d0a8823a8 100644 --- a/services/devicemanagerservice/include/authentication/showconfirm/lite/show_confirm.h +++ b/services/devicemanagerservice/include/authentication/showconfirm/lite/show_confirm.h @@ -20,6 +20,9 @@ #include #include +#include "dm_auth_manager.h" +#include "dm_ability_manager.h" + namespace OHOS { namespace DistributedHardware { class ShowConfirm { diff --git a/services/devicemanagerservice/include/authentication/showconfirm/standard/show_confirm.h b/services/devicemanagerservice/include/authentication/showconfirm/standard/show_confirm.h index 20ca3c2ec..afcfd0b5f 100644 --- a/services/devicemanagerservice/include/authentication/showconfirm/standard/show_confirm.h +++ b/services/devicemanagerservice/include/authentication/showconfirm/standard/show_confirm.h @@ -20,6 +20,9 @@ #include #include +#include "dm_auth_manager.h" +#include "dm_ability_manager.h" + namespace OHOS { namespace DistributedHardware { class ShowConfirm { diff --git a/services/devicemanagerservice/src/authentication/dm_auth_manager.cpp b/services/devicemanagerservice/src/authentication/dm_auth_manager.cpp index 85e06aa28..ecc01795b 100644 --- a/services/devicemanagerservice/src/authentication/dm_auth_manager.cpp +++ b/services/devicemanagerservice/src/authentication/dm_auth_manager.cpp @@ -558,7 +558,7 @@ int32_t DmAuthManager::AddMember(const std::string &deviceId) return DM_FAILED; } ptr = authenticationMap_[authResponseContext_->authType]; - ptr->CloseAuthInfo(authResponseContext_->pageId, shared_form_this()); + ptr->CloseAuthInfo(authResponseContext_->pageId, shared_from_this()); return DM_OK; } @@ -594,7 +594,7 @@ void DmAuthManager::AuthenticateFinish() return ; } ptr = authenticationMap_[authResponseContext_->authType]; - ptr->CloseAuthInfo(authResponseContext_->pageId, shared_form_this()); + ptr->CloseAuthInfo(authResponseContext_->pageId, shared_from_this()); } if (isFinishOfLocal_) { authMessageProcessor_->SetResponseContext(authResponseContext_); @@ -627,7 +627,7 @@ void DmAuthManager::AuthenticateFinish() return ; } ptr = authenticationMap_[authResponseContext_->authType]; - ptr->CloseAuthInfo(authResponseContext_->pageId, shared_form_this()); + ptr->CloseAuthInfo(authResponseContext_->pageId, shared_from_this()); } listener_->OnAuthResult(authRequestContext_->hostPkgName, authRequestContext_->deviceId, @@ -728,7 +728,7 @@ void DmAuthManager::ShowConfigDialog() jsonObj.dump(); const std::string params = jsonObj.dump(); std::shared_ptr showConfirm_ = std::make_shared(); - showConfirm_->ShowConfirmDialog(params, shared_form_this(), dmAbilityMgr_); + showConfirm_->ShowConfirmDialog(params, shared_from_this(), dmAbilityMgr_); LOGI("ShowConfigDialog end"); } -- Gitee From 59ed1b84b58183e77194717382efe12e011ce234 Mon Sep 17 00:00:00 2001 From: zixing000 Date: Fri, 18 Mar 2022 09:54:35 +0800 Subject: [PATCH 21/24] codecheck Signed-off-by: zixing000 --- .../src/authentication/dm_auth_manager.cpp | 4 ---- .../src/dependency/multipleuser/multiple_user_connector.cpp | 1 - 2 files changed, 5 deletions(-) diff --git a/services/devicemanagerservice/src/authentication/dm_auth_manager.cpp b/services/devicemanagerservice/src/authentication/dm_auth_manager.cpp index ecc01795b..0fa2f4134 100644 --- a/services/devicemanagerservice/src/authentication/dm_auth_manager.cpp +++ b/services/devicemanagerservice/src/authentication/dm_auth_manager.cpp @@ -619,7 +619,6 @@ void DmAuthManager::AuthenticateFinish() } else { authRequestContext_->reason = authResponseContext_->reply; } - if (authResponseContext_->state == AuthState::AUTH_REQUEST_INPUT) { std::shared_ptr ptr; if (authenticationMap_.find(authResponseContext_->authType) == authenticationMap_.end()) { @@ -629,12 +628,9 @@ void DmAuthManager::AuthenticateFinish() ptr = authenticationMap_[authResponseContext_->authType]; ptr->CloseAuthInfo(authResponseContext_->pageId, shared_from_this()); } - listener_->OnAuthResult(authRequestContext_->hostPkgName, authRequestContext_->deviceId, authRequestContext_->token, authResponseContext_->state, authRequestContext_->reason); - softbusConnector_->GetSoftbusSession()->CloseAuthSession(authRequestContext_->sessionId); - if (!timerMap_.empty()) { for (auto &iter : timerMap_) { iter.second->Stop(SESSION_CANCEL_TIMEOUT); diff --git a/services/devicemanagerservice/src/dependency/multipleuser/multiple_user_connector.cpp b/services/devicemanagerservice/src/dependency/multipleuser/multiple_user_connector.cpp index 5214b4aa6..fe4a82a02 100644 --- a/services/devicemanagerservice/src/dependency/multipleuser/multiple_user_connector.cpp +++ b/services/devicemanagerservice/src/dependency/multipleuser/multiple_user_connector.cpp @@ -15,7 +15,6 @@ #include "multiple_user_connector.h" -#include "dm_constants.h" #include "dm_log.h" #ifndef LITE_DEVICE #include "os_account_manager.h" -- Gitee From 3e9cbe8dcb7152f7f5856a5b4fe2a693eec54aa8 Mon Sep 17 00:00:00 2001 From: zixing000 Date: Sat, 19 Mar 2022 10:31:43 +0800 Subject: [PATCH 22/24] L1 build pin_auth and try build profile (shared_library). Signed-off-by: zixing000 --- BUILD.gn | 3 + ext/pin_auth/BUILD.gn | 67 +++++++++++++++++++ ext/pin_auth/src/lite/pin_auth_ui.cpp | 1 - ext/profile/BUILD.gn | 49 ++++++++++++++ services/devicemanagerservice/BUILD.gn | 3 +- .../showconfirm/lite/show_confirm.h | 2 +- .../showconfirm/lite/show_confirm.cpp | 8 +-- 7 files changed, 126 insertions(+), 7 deletions(-) diff --git a/BUILD.gn b/BUILD.gn index 103ee5a70..275ea8a9c 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -18,6 +18,9 @@ if (defined(ohos_lite)) { "utils:devicemanagerutils", "services/devicemanagerservice:devicemanagerservice", "interfaces/inner_kits/native_cpp:devicemanagersdk", + "ext/pin_auth:devicemanagerext_pin_auth", + + # "ext/profile:devicemanagerext_profile", ] } } diff --git a/ext/pin_auth/BUILD.gn b/ext/pin_auth/BUILD.gn index 5dac42d4c..5d9a18e10 100644 --- a/ext/pin_auth/BUILD.gn +++ b/ext/pin_auth/BUILD.gn @@ -19,6 +19,73 @@ if (defined(ohos_lite)) { import("//foundation/distributedhardware/devicemanager/devicemanager.gni") if (defined(ohos_lite)) { + shared_library("devicemanagerext_pin_auth") { + include_dirs = [ + "include", + "include/lite", + "${common_path}/include", + "${ext_path}/pin_auth/include/ability", + "${services_path}/include/dependency/timer", + "${services_path}/include/config", + "${services_path}/include/adapter", + "${services_path}/include/authentication", + "${services_path}/include/authentication/showconfirm/lite", + "${services_path}/include/ability", + "${services_path}/include/deviceinfo", + "${services_path}/include/devicestate", + "${services_path}/include/discovery", + "${services_path}/include/dependency/commonevent", + "${services_path}/include/dependency/hichain", + "${services_path}/include/dependency/softbus", + "${services_path}/include/dependency/timer", + "${services_path}/include/ipc", + "${services_path}/include/ipc/lite", + "${utils_path}/include", + "${utils_path}/include/ipc/lite", + "${services_path}/include", + "${innerkits_path}/native_cpp/include", + "${common_path}/include/ipc", + "${common_path}/include/ipc/model", + "${innerkits_path}/native_cpp/include", + "${innerkits_path}/native_cpp/include/ipc", + "${innerkits_path}/native_cpp/include/ipc/lite", + "//third_party/json/include", + "//utils/native/base/include", + "//utils/system/safwk/native/include", + "//base/notification/ces_lite/frameworks/core/include", + "//base/notification/ces_lite/interfaces/innerkits/native/include", + "//base/security/deviceauth/interfaces/innerkits", + "//base/startup/syspara_lite/interfaces/kits", + "//base/startup/syspara_lite/adapter/native/syspara/include", + ] + + sources = [ + "src/ability/lite/dm_ability_manager.cpp", + "src/lite/pin_auth_ui.cpp", + "src/pin_auth.cpp", + ] + + deps = [ + "${common_path}/include/show_confirm_dialog/dialog_ui/js:dialog_js_files_etc", + "${innerkits_path}/native_cpp:devicemanagersdk", + "${utils_path}:devicemanagerutils", + "//base/hiviewdfx/hilog_lite/frameworks/featured:hilog_shared", + "//base/security/deviceauth/services:deviceauth_sdk", + "//foundation/communication/dsoftbus/sdk:softbus_client", + "//foundation/communication/ipc_lite:liteipc_adapter", + "//foundation/distributedschedule/samgr_lite/samgr:samgr", + "//third_party/bounds_checking_function:libsec_shared", + "//third_party/mbedtls:mbedtls_shared", + "//utils/native/lite:utils", + ] + + defines = [ + "LITE_DEVICE", + "HI_LOG_ENABLE", + "DH_LOG_TAG=\"devicemanagerext\"", + "LOG_DOMAIN=0xD004100", + ] + } } else { ohos_shared_library("devicemanagerext_pin_auth") { include_dirs = [ diff --git a/ext/pin_auth/src/lite/pin_auth_ui.cpp b/ext/pin_auth/src/lite/pin_auth_ui.cpp index 833395ad0..3adc33af7 100644 --- a/ext/pin_auth/src/lite/pin_auth_ui.cpp +++ b/ext/pin_auth/src/lite/pin_auth_ui.cpp @@ -19,7 +19,6 @@ #include "dm_constants.h" #include "dm_log.h" #include "nlohmann/json.hpp" -#include "ui_service_mgr_client.h" namespace OHOS { namespace DistributedHardware { diff --git a/ext/profile/BUILD.gn b/ext/profile/BUILD.gn index 552653a03..a325a67cd 100644 --- a/ext/profile/BUILD.gn +++ b/ext/profile/BUILD.gn @@ -20,6 +20,55 @@ if (defined(ohos_lite)) { import("//foundation/distributedhardware/devicemanager/devicemanager.gni") if (defined(ohos_lite)) { + shared_library("devicemanagerext_profile") { + include_dirs = [ + "include", + "${common_path}/include", + "${common_path}/include/ipc", + "${common_path}/include/ipc/model", + "${ext_path}/profile/include", + "${services_path}/include", + "${services_path}/include/adapter", + "${services_path}/include/dependency/softbus", + "${services_path}/include/ipc/lite", + "${services_path}/include/dependency/timer", + "${services_path}/include/devicestate", + "${utils_path}/include", + "${utils_path}/include/ipc/lite", + "${innerkits_path}/native_cpp/include", + "${innerkits_path}/native_cpp/include/ipc", + "${innerkits_path}/native_cpp/include/ipc/lite", + "//foundation/communication/dsoftbus/interfaces/kits/bus_center", + "//foundation/communication/dsoftbus/interfaces/kits/common", + "//foundation/communication/dsoftbus/interfaces/kits/discovery", + "//foundation/communication/dsoftbus/interfaces/kits/transport", + "//foundation/communication/dsoftbus/interfaces/inner_kits/transport", + + # "//foundation/deviceprofile/device_profile_core/interfaces/innerkits/core/include", + # "//foundation/communication/ipc/interfaces/innerkits/ipc_core/include", + ] + + sources = [ + "src/device_profile_adapter.cpp", + "src/profile_connector.cpp", + ] + deps = [ + "${services_path}:devicemanagerservice", + "${utils_path}:devicemanagerutils", + "//base/hiviewdfx/hilog_lite/frameworks/featured:hilog_shared", + "//foundation/communication/ipc_lite:liteipc_adapter", + + # "//foundation/deviceprofile/device_profile_core/interfaces/innerkits/core:distributed_device_profile_client", + ] + ldflags = dm_ldflags + + defines = [ + "LITE_DEVICE", + "HI_LOG_ENABLE", + "DH_LOG_TAG=\"devicemanagerext\"", + "LOG_DOMAIN=0xD004100", + ] + } } else { ohos_shared_library("devicemanagerext_profile") { include_dirs = [ diff --git a/services/devicemanagerservice/BUILD.gn b/services/devicemanagerservice/BUILD.gn index 31d9477c0..73fe5b794 100644 --- a/services/devicemanagerservice/BUILD.gn +++ b/services/devicemanagerservice/BUILD.gn @@ -101,11 +101,12 @@ if (defined(ohos_lite)) { ] deps = [ - "${common_path}/include/dialog_ui/js:dialog_js_files_etc", + "${common_path}/include/show_confirm_dialog/dialog_ui/js:dialog_js_files_etc", "${innerkits_path}/native_cpp:devicemanagersdk", "${utils_path}:devicemanagerutils", "//base/hiviewdfx/hilog_lite/frameworks/featured:hilog_shared", "//base/security/deviceauth/services:deviceauth_sdk", + "//base/startup/syspara_lite/frameworks/parameter/src:sysparam", "//foundation/communication/dsoftbus/sdk:softbus_client", "//foundation/communication/ipc_lite:liteipc_adapter", "//foundation/distributedschedule/samgr_lite/samgr:samgr", diff --git a/services/devicemanagerservice/include/authentication/showconfirm/lite/show_confirm.h b/services/devicemanagerservice/include/authentication/showconfirm/lite/show_confirm.h index d0a8823a8..df924b865 100644 --- a/services/devicemanagerservice/include/authentication/showconfirm/lite/show_confirm.h +++ b/services/devicemanagerservice/include/authentication/showconfirm/lite/show_confirm.h @@ -31,7 +31,7 @@ public: ~ShowConfirm(); void ShowConfirmDialog(const std::string ¶ms, std::shared_ptr authManager, std::shared_ptr dmAbilityMgr); -} +}; } // namespace DistributedHardware } // namespace OHOS #endif // OHOS_DM_SHOW_CONFIRM_H diff --git a/services/devicemanagerservice/src/authentication/showconfirm/lite/show_confirm.cpp b/services/devicemanagerservice/src/authentication/showconfirm/lite/show_confirm.cpp index c578dcecd..1007be3b5 100644 --- a/services/devicemanagerservice/src/authentication/showconfirm/lite/show_confirm.cpp +++ b/services/devicemanagerservice/src/authentication/showconfirm/lite/show_confirm.cpp @@ -22,8 +22,8 @@ namespace OHOS { namespace DistributedHardware { -ShowConfirm::ShowConfirm(); -ShowConfirm::~ShowConfirm(); +ShowConfirm::ShowConfirm(){} +ShowConfirm::~ShowConfirm(){} void ShowConfirm::ShowConfirmDialog(const std::string ¶ms, std::shared_ptr authManager, std::shared_ptr dmAbilityMgr) { @@ -33,11 +33,11 @@ void ShowConfirm::ShowConfirmDialog(const std::string ¶ms, std::shared_ptrStartAbility(AbilityRole::ABILITY_ROLE_PASSIVE); - if (status != Ability:status::ABILITY_STATUS_SUCCESS) { + if (status != AbilityStatus::ABILITY_STATUS_SUCCESS) { LOGE("ShowConfirm::startFaservice timeout"); return; } LOGI("ShowConfirm hap end"); -} +}; } // namespace DistributedHardware } // namespace OHOS -- Gitee From a179027ab41f32326a53122d5e8492ca1b52b1c8 Mon Sep 17 00:00:00 2001 From: zixing000 Date: Sat, 19 Mar 2022 10:41:35 +0800 Subject: [PATCH 23/24] codecheck Signed-off-by: zixing000 --- .../authentication/showconfirm/lite/show_confirm.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/services/devicemanagerservice/src/authentication/showconfirm/lite/show_confirm.cpp b/services/devicemanagerservice/src/authentication/showconfirm/lite/show_confirm.cpp index 1007be3b5..1619dd033 100644 --- a/services/devicemanagerservice/src/authentication/showconfirm/lite/show_confirm.cpp +++ b/services/devicemanagerservice/src/authentication/showconfirm/lite/show_confirm.cpp @@ -22,8 +22,14 @@ namespace OHOS { namespace DistributedHardware { -ShowConfirm::ShowConfirm(){} -ShowConfirm::~ShowConfirm(){} +ShowConfirm::ShowConfirm() +{ +} + +ShowConfirm::~ShowConfirm() +{ +} + void ShowConfirm::ShowConfirmDialog(const std::string ¶ms, std::shared_ptr authManager, std::shared_ptr dmAbilityMgr) { -- Gitee From 8e2dd91d5a1319811abc02c4bf3398ec4d23b2ba Mon Sep 17 00:00:00 2001 From: zixing000 Date: Sat, 19 Mar 2022 11:13:13 +0800 Subject: [PATCH 24/24] =?UTF-8?q?=E5=88=A0=E9=99=A4profile=20L1=20?= =?UTF-8?q?=E6=9E=84=E5=BB=BA=E7=9B=B8=E5=85=B3=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zixing000 --- BUILD.gn | 2 -- ext/profile/BUILD.gn | 49 -------------------------------------------- 2 files changed, 51 deletions(-) diff --git a/BUILD.gn b/BUILD.gn index 275ea8a9c..67ff48712 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -19,8 +19,6 @@ if (defined(ohos_lite)) { "services/devicemanagerservice:devicemanagerservice", "interfaces/inner_kits/native_cpp:devicemanagersdk", "ext/pin_auth:devicemanagerext_pin_auth", - - # "ext/profile:devicemanagerext_profile", ] } } diff --git a/ext/profile/BUILD.gn b/ext/profile/BUILD.gn index a325a67cd..552653a03 100644 --- a/ext/profile/BUILD.gn +++ b/ext/profile/BUILD.gn @@ -20,55 +20,6 @@ if (defined(ohos_lite)) { import("//foundation/distributedhardware/devicemanager/devicemanager.gni") if (defined(ohos_lite)) { - shared_library("devicemanagerext_profile") { - include_dirs = [ - "include", - "${common_path}/include", - "${common_path}/include/ipc", - "${common_path}/include/ipc/model", - "${ext_path}/profile/include", - "${services_path}/include", - "${services_path}/include/adapter", - "${services_path}/include/dependency/softbus", - "${services_path}/include/ipc/lite", - "${services_path}/include/dependency/timer", - "${services_path}/include/devicestate", - "${utils_path}/include", - "${utils_path}/include/ipc/lite", - "${innerkits_path}/native_cpp/include", - "${innerkits_path}/native_cpp/include/ipc", - "${innerkits_path}/native_cpp/include/ipc/lite", - "//foundation/communication/dsoftbus/interfaces/kits/bus_center", - "//foundation/communication/dsoftbus/interfaces/kits/common", - "//foundation/communication/dsoftbus/interfaces/kits/discovery", - "//foundation/communication/dsoftbus/interfaces/kits/transport", - "//foundation/communication/dsoftbus/interfaces/inner_kits/transport", - - # "//foundation/deviceprofile/device_profile_core/interfaces/innerkits/core/include", - # "//foundation/communication/ipc/interfaces/innerkits/ipc_core/include", - ] - - sources = [ - "src/device_profile_adapter.cpp", - "src/profile_connector.cpp", - ] - deps = [ - "${services_path}:devicemanagerservice", - "${utils_path}:devicemanagerutils", - "//base/hiviewdfx/hilog_lite/frameworks/featured:hilog_shared", - "//foundation/communication/ipc_lite:liteipc_adapter", - - # "//foundation/deviceprofile/device_profile_core/interfaces/innerkits/core:distributed_device_profile_client", - ] - ldflags = dm_ldflags - - defines = [ - "LITE_DEVICE", - "HI_LOG_ENABLE", - "DH_LOG_TAG=\"devicemanagerext\"", - "LOG_DOMAIN=0xD004100", - ] - } } else { ohos_shared_library("devicemanagerext_profile") { include_dirs = [ -- Gitee