diff --git a/BUILD.gn b/BUILD.gn index 7e5dfc76c562adc8cc23b22f6b9a1ff6c989cacb..67ff48712b112a59bf740f46f827f1aef3d07365 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -11,13 +11,14 @@ # See the License for the specific language governing permissions and # limitations under the License. -import("//build/lite/config/component/lite_component.gni") - if (defined(ohos_lite)) { + import("//build/lite/config/component/lite_component.gni") lite_component("devicemanager_lite") { - if (ohos_kernel_type == "liteos_m") { - } else { - features = [] - } + features = [ + "utils:devicemanagerutils", + "services/devicemanagerservice:devicemanagerservice", + "interfaces/inner_kits/native_cpp:devicemanagersdk", + "ext/pin_auth:devicemanagerext_pin_auth", + ] } } diff --git a/common/include/dm_constants.h b/common/include/dm_constants.h old mode 100755 new mode 100644 diff --git a/ext/pin_auth/BUILD.gn b/ext/pin_auth/BUILD.gn index 84e735198536199ec4277f4899c6008773d7ca09..5d9a18e1070768e852314f2186760a44c530cade 100644 --- a/ext/pin_auth/BUILD.gn +++ b/ext/pin_auth/BUILD.gn @@ -19,16 +19,85 @@ 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 = [ "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 +130,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_ui.h b/ext/pin_auth/include/lite/pin_auth_ui.h similarity index 92% rename from ext/pin_auth/include/pin_auth_ui.h rename to ext/pin_auth/include/lite/pin_auth_ui.h index 5ff26c3e1634b9bfb1ae370b8349b8c0ebab3ebe..dfa24cf89ad4d96a2b6eddc0d972130cd6cc08e6 100644 --- a/ext/pin_auth/include/pin_auth_ui.h +++ b/ext/pin_auth/include/lite/pin_auth_ui.h @@ -28,6 +28,7 @@ public: PinAuthUi(); int32_t ShowPinDialog(int32_t code, std::shared_ptr authManager); int32_t InputPinDialog(int32_t code, std::shared_ptr authManager); + int32_t ClosePage(const int32_t &pageId, std::shared_ptr authManager); private: int32_t StartFaUiService(std::shared_ptr dmAbilityManager); diff --git a/ext/pin_auth/include/pin_auth.h b/ext/pin_auth/include/pin_auth.h index ac02b101789ce4aad956095c5acf6fd32cbedb56..191a462263b29303726c5c7ceb64fa321c15179c 100644 --- a/ext/pin_auth/include/pin_auth.h +++ b/ext/pin_auth/include/pin_auth.h @@ -33,6 +33,7 @@ public: int32_t ShowAuthInfo(std::string &authToken, std::shared_ptr authManager) override; int32_t StartAuth(std::string &authToken, std::shared_ptr authManager) override; int32_t VerifyAuthentication(std::string &authToken, const std::string &authParam) override; + int32_t CloseAuthInfo(const int32_t &pageId, std::shared_ptr authManager) override; private: int32_t times_ = 0; std::shared_ptr pinAuthUi_; diff --git a/ext/pin_auth/include/standard/pin_auth_ui.h b/ext/pin_auth/include/standard/pin_auth_ui.h new file mode 100644 index 0000000000000000000000000000000000000000..dfa24cf89ad4d96a2b6eddc0d972130cd6cc08e6 --- /dev/null +++ b/ext/pin_auth/include/standard/pin_auth_ui.h @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef OHOS_DM_PIN_AUTH_UI_H +#define OHOS_DM_PIN_AUTH_UI_H + +#include + +#include "dm_auth_manager.h" +#include "dm_ability_manager.h" + +namespace OHOS { +namespace DistributedHardware { +class PinAuthUi { +public: + PinAuthUi(); + int32_t ShowPinDialog(int32_t code, std::shared_ptr authManager); + int32_t InputPinDialog(int32_t code, std::shared_ptr authManager); + int32_t ClosePage(const int32_t &pageId, std::shared_ptr authManager); + +private: + int32_t StartFaUiService(std::shared_ptr dmAbilityManager); +}; +} // namespace DistributedHardware +} // namespace OHOS +#endif // OHOS_DM_PIN_AUTH_UI_H diff --git a/ext/pin_auth/src/lite/pin_auth_ui.cpp b/ext/pin_auth/src/lite/pin_auth_ui.cpp new file mode 100644 index 0000000000000000000000000000000000000000..3adc33af7ef5b6fe8eebe3d8318263ebf4b07c8c --- /dev/null +++ b/ext/pin_auth/src/lite/pin_auth_ui.cpp @@ -0,0 +1,70 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "pin_auth_ui.h" + +#include "dm_ability_manager.h" +#include "dm_constants.h" +#include "dm_log.h" +#include "nlohmann/json.hpp" + +namespace OHOS { +namespace DistributedHardware { +PinAuthUi::PinAuthUi() +{ + LOGI("AuthUi constructor"); +} + +int32_t PinAuthUi::ShowPinDialog(int32_t code, std::shared_ptr authManager) +{ + LOGI("ShowConfigDialog end"); + return DM_OK; +} + +int32_t PinAuthUi::InputPinDialog(int32_t code, std::shared_ptr authManager) +{ + LOGI("InputPinDialog start"); + std::shared_ptr dmAbilityManager_ = std::make_shared(); + if (dmAbilityManager_ == nullptr) { + LOGE("PinAuthUi::dmAbilityManager is null"); + return DM_FAILED; + } + LOGI("InputPinDialog end"); + return StartFaUiService(dmAbilityManager_); +} + +int32_t ClosePage(const int32_t &pageId, std::shared_ptr authManager) +{ + LOGI("ClosePage hap start"); + if (authManager == nullptr) { + LOGE("PinAuthUi::authManager is null"); + return DM_FAILED; + } + LOGI("ClosePage hap end"); + authManager->CancelDisplay(); + return DM_OK; +} + +int32_t PinAuthUi::StartFaUiService(std::shared_ptr dmAbilityManager) +{ + AbilityStatus status = dmAbilityManager->StartAbility(AbilityRole::ABILITY_ROLE_INITIATIVE); + if (status != AbilityStatus::ABILITY_STATUS_SUCCESS) { + LOGE("PinAuthUi::StartFaService timeout"); + return DM_FAILED; + } + return DM_OK; +} +} // namespace DistributedHardware +} // namespace OHOS diff --git a/ext/pin_auth/src/pin_auth.cpp b/ext/pin_auth/src/pin_auth.cpp index 4c3e3040964568eca1a2df2b93d81a3ec2ce05a8..25e7f54d6d113718ca71fc90cf97115d7768e0eb 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/standard/pin_auth_ui.cpp similarity index 87% rename from ext/pin_auth/src/pin_auth_ui.cpp rename to ext/pin_auth/src/standard/pin_auth_ui.cpp index eb976a67898c97ed963f8228bf400323baa920f8..fb4222bc4126784f9f619c7420ca2b4fe2c4c93c 100644 --- a/ext/pin_auth/src/pin_auth_ui.cpp +++ b/ext/pin_auth/src/standard/pin_auth_ui.cpp @@ -31,6 +31,10 @@ PinAuthUi::PinAuthUi() int32_t PinAuthUi::ShowPinDialog(int32_t code, std::shared_ptr authManager) { LOGI("ShowPinDialog start"); + if (authManager == nullptr) { + LOGE("ShowPinDialog authManager is null"); + return DM_FAILED; + } nlohmann::json jsonObj; jsonObj[PIN_CODE_KEY] = code; jsonObj.dump(); @@ -57,6 +61,10 @@ int32_t PinAuthUi::ShowPinDialog(int32_t code, std::shared_ptr au int32_t PinAuthUi::InputPinDialog(int32_t code, std::shared_ptr authManager) { LOGI("InputPinDialog start"); + if (authManager == nullptr) { + LOGE("ShowPinDialog InputPinDialog is null"); + return DM_FAILED; + } nlohmann::json jsonObj; jsonObj[PIN_CODE_KEY] = code; jsonObj.dump(); @@ -81,6 +89,14 @@ int32_t PinAuthUi::InputPinDialog(int32_t code, std::shared_ptr a return DM_OK; } +int32_t PinAuthUi::ClosePage(const int32_t &pageId, std::shared_ptr authManager) +{ + LOGI("PinAuthUi start"); + Ace::UIServiceMgrClient::GetInstance()->CancelDialog(pageId); + LOGI("PinAuthUi end"); + return DM_OK; +} + int32_t PinAuthUi::StartFaUiService(std::shared_ptr dmAbilityManager) { AbilityStatus status = dmAbilityManager->StartAbility(AbilityRole::ABILITY_ROLE_INITIATIVE); diff --git a/ext/profile/include/device_profile_adapter.h b/ext/profile/include/device_profile_adapter.h old mode 100755 new mode 100644 diff --git a/ext/profile/include/profile_connector.h b/ext/profile/include/profile_connector.h old mode 100755 new mode 100644 diff --git a/ext/profile/src/device_profile_adapter.cpp b/ext/profile/src/device_profile_adapter.cpp old mode 100755 new mode 100644 diff --git a/ext/profile/src/profile_connector.cpp b/ext/profile/src/profile_connector.cpp old mode 100755 new mode 100644 diff --git a/interfaces/inner_kits/native_cpp/BUILD.gn b/interfaces/inner_kits/native_cpp/BUILD.gn index a842f4b22d1860015ff9a3330a20bd4cdc946eae..80fde4c7356c3b6d846ed1bddaa537517a8194e9 100644 --- a/interfaces/inner_kits/native_cpp/BUILD.gn +++ b/interfaces/inner_kits/native_cpp/BUILD.gn @@ -20,6 +20,51 @@ import("//foundation/distributedhardware/devicemanager/devicemanager.gni") if (defined(ohos_lite)) { shared_library("devicemanagersdk") { + include_dirs = [ + "include", + "include/ipc", + "include/ipc/lite", + "include/notify", + "${common_path}/include", + "${common_path}/include/ipc", + "${common_path}/include/ipc/model", + "${utils_path}/include", + "${utils_path}/include/ipc/lite", + ] + include_dirs += [ + "//utils/native/lite/include", + "//base/hiviewdfx/hilog_lite/interfaces/native/innerkits/hilog", + "//third_party/bounds_checking_function/include", + "//foundation/communication/ipc_lite/interfaces/kits", + "//foundation/distributedschedule/samgr_lite/interfaces/kits/samgr", + "//foundation/distributedschedule/samgr_lite/interfaces/kits/registry", + "//third_party/json/include", + "//foundation/appexecfwk/appexecfwk_lite/interfaces/kits/bundle_lite/", + ] + sources = [ + "src/device_manager.cpp", + "src/device_manager_impl.cpp", + "src/ipc/ipc_client_proxy.cpp", + "src/ipc/lite/ipc_client_manager.cpp", + "src/ipc/lite/ipc_client_server_proxy.cpp", + "src/ipc/lite/ipc_client_stub.cpp", + "src/ipc/lite/ipc_cmd_parser.cpp", + "src/notify/device_manager_notify.cpp", + ] + deps = [ + "${utils_path}:devicemanagerutils", + "//base/hiviewdfx/hilog_lite/frameworks/featured:hilog_shared", + "//foundation/communication/ipc_lite:liteipc_adapter", + "//foundation/distributedschedule/samgr_lite/samgr:samgr", + "//third_party/bounds_checking_function:libsec_shared", + "//utils/native/lite:utils", + ] + defines = [ + "LITE_DEVICE", + "HI_LOG_ENABLE", + "DH_LOG_TAG=\"devicemanagerkit\"", + "LOG_DOMAIN=0xD004100", + ] } } else { config("devicemanagersdk_config") { diff --git a/interfaces/inner_kits/native_cpp/src/device_manager_impl.cpp b/interfaces/inner_kits/native_cpp/src/device_manager_impl.cpp index 91fd9fbe72f6d7f164f98f8bf201c7197085ede4..6d7e8f1bce21abd7f141fca2dd375d1aa5410d59 100644 --- a/interfaces/inner_kits/native_cpp/src/device_manager_impl.cpp +++ b/interfaces/inner_kits/native_cpp/src/device_manager_impl.cpp @@ -27,7 +27,6 @@ #include "ipc_req.h" #include "ipc_rsp.h" #include "ipc_set_useroperation_req.h" -#include "ipc_skeleton.h" #include "ipc_start_discovery_req.h" #include "ipc_stop_discovery_req.h" #include "ipc_unauthenticate_device_req.h" @@ -258,7 +257,6 @@ int32_t DeviceManagerImpl::AuthenticateDevice(const std::string &pkgName, int32_ LOGE("AuthenticateDevice error: Failed with ret %d", ret); return DM_IPC_RESPOND_ERROR; } - LOGI("DeviceManager::AuthenticateDevice completed, pkgName: %s", pkgName.c_str()); return DM_OK; } diff --git a/interfaces/inner_kits/native_cpp/src/ipc/lite/ipc_client_server_proxy.cpp b/interfaces/inner_kits/native_cpp/src/ipc/lite/ipc_client_server_proxy.cpp index 0df3527995b6d80a42e6643cc376446f1bb72072..da6f53d50579ee2b8b7625cdea12e84c216cb474 100644 --- a/interfaces/inner_kits/native_cpp/src/ipc/lite/ipc_client_server_proxy.cpp +++ b/interfaces/inner_kits/native_cpp/src/ipc/lite/ipc_client_server_proxy.cpp @@ -23,10 +23,10 @@ namespace OHOS { namespace DistributedHardware { +const int32_t INVALID_CB_ID = 0xFF; static uint32_t g_deathCbId = INVALID_CB_ID; static SvcIdentity g_svcIdentity; static std::shared_ptr pCurRsp; -const int32_t INVALID_CB_ID = 0xFF; void __attribute__((weak)) HOS_SystemInit(void) { @@ -89,7 +89,7 @@ int IpcClientServerProxy::RegisterServerDeathCb(void) int32_t IpcClientServerProxy::SendCmd(int32_t cmdCode, std::shared_ptr req, std::shared_ptr rsp) { - LOGI("SendCmd:%d", cmdCode); + LOGI("IpcClientServerProxy::SendCmd:%d", cmdCode); uint8_t data[MAX_DM_IPC_LEN] = {0}; IpcIo request; @@ -105,7 +105,7 @@ int32_t IpcClientServerProxy::SendCmd(int32_t cmdCode, std::shared_ptr r return DM_FAILED; } } - LOGI("SendCmd:%d end", cmdCode); + LOGI("IpcClientServerProxy::SendCmd:%d, end", cmdCode); return DM_OK; } diff --git a/interfaces/inner_kits/native_cpp/src/ipc/lite/ipc_cmd_parser.cpp b/interfaces/inner_kits/native_cpp/src/ipc/lite/ipc_cmd_parser.cpp index 659df2210b1cf166c26ee0d81de933d5e19c1ecc..980d919923b7cc62812bbfe239e1f5ee123fe38a 100644 --- a/interfaces/inner_kits/native_cpp/src/ipc/lite/ipc_cmd_parser.cpp +++ b/interfaces/inner_kits/native_cpp/src/ipc/lite/ipc_cmd_parser.cpp @@ -28,6 +28,7 @@ #include "ipc_start_discovery_req.h" #include "ipc_stop_discovery_req.h" #include "ipc_verify_authenticate_req.h" +#include "ipc_set_useroperation_req.h" #include "securec.h" namespace OHOS { diff --git a/interfaces/kits/js/src/native_devicemanager_js.cpp b/interfaces/kits/js/src/native_devicemanager_js.cpp index 97f32c139dd64e37f4a10fbc91c04a650615eb29..ca0341ef5b41b038671336aa5e5deb9c92aa93e5 100644 --- a/interfaces/kits/js/src/native_devicemanager_js.cpp +++ b/interfaces/kits/js/src/native_devicemanager_js.cpp @@ -46,6 +46,8 @@ const int32_t DM_NAPI_ARGS_TWO = 2; const int32_t DM_NAPI_ARGS_THREE = 3; const int32_t DM_NAPI_SUB_ID_MAX = 65535; +const int32_t DM_AUTH_DIRECTION_CLIENT = 1; + napi_ref deviceTypeEnumConstructor_ = nullptr; napi_ref deviceStateChangeActionEnumConstructor_ = nullptr; napi_ref discoverModeEnumConstructor_ = nullptr; @@ -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 old mode 100755 new mode 100644 index 322326b4e41c4f9716ca0ac6d3e2e460de9d5bbb..73fe5b7941cb85abe91e0e7c47fff0d7dade0cbc --- a/services/devicemanagerservice/BUILD.gn +++ b/services/devicemanagerservice/BUILD.gn @@ -21,7 +21,99 @@ import("//foundation/distributedhardware/devicemanager/devicemanager.gni") if (defined(ohos_lite)) { executable("devicemanagerservice") { - sources = [ "src/ipc/lite/ipc_server_main.cpp" ] + include_dirs = [ + "include", + "include/config", + "include/adapter", + "include/authentication", + "include/authentication/showconfirm/lite", + "include/ability", + "include/deviceinfo", + "include/devicestate", + "include/discovery", + "include/dependency/multipleuser/", + "include/dependency/hichain", + "include/dependency/softbus", + "include/dependency/timer", + "include", + "include/ipc/lite", + "include/eventbus", + "${common_path}/include", + "${common_path}/include/ipc", + "${common_path}/include/ipc/model", + "${utils_path}/include", + "${utils_path}/include/ipc/lite", + "${utils_path}/include/permission/lite", + "${innerkits_path}/native_cpp/include", + "${innerkits_path}/native_cpp/include/ipc", + "${innerkits_path}/native_cpp/include/ipc/lite", + ] + include_dirs += [ + "//base/security/deviceauth/interfaces/innerkits", + "//base/startup/syspara_lite/interfaces/innerkits/native/syspara/include", + "//utils/native/lite/include", + "//utils/system/safwk/native/include", + "//third_party/json/include", + "//base/hiviewdfx/hilog_lite/interfaces/native/innerkits/hilog", + "//third_party/bounds_checking_function/include", + "//foundation/communication/ipc_lite/interfaces/kits", + "//foundation/communication/dsoftbus/interfaces/kits/bus_center", + "//foundation/communication/dsoftbus/interfaces/kits/common", + "//foundation/communication/dsoftbus/interfaces/kits/discovery", + "//foundation/communication/dsoftbus/interfaces/kits/transport", + "//foundation/communication/dsoftbus/interfaces/inner_kits/transport", + "//foundation/distributedschedule/samgr_lite/interfaces/kits/samgr", + "//foundation/distributedschedule/samgr/interfaces/innerkits/samgr_proxy/include", + ] + + sources = [ + "src/ability/lite/dm_ability_manager.cpp", + "src/adapter/lite/dm_adapter_manager.cpp", + "src/authentication/auth_message_processor.cpp", + "src/authentication/auth_request_state.cpp", + "src/authentication/auth_response_state.cpp", + "src/authentication/dm_auth_manager.cpp", + "src/authentication/showconfirm/lite/show_confirm.cpp", + "src/config/dm_config_manager.cpp", + "src/dependency/hichain/hichain_connector.cpp", + "src/dependency/multipleuser/multiple_user_connector.cpp", + "src/dependency/softbus/softbus_connector.cpp", + "src/dependency/softbus/softbus_session.cpp", + "src/dependency/timer/dm_timer.cpp", + "src/device_manager_service.cpp", + "src/device_manager_service_listener.cpp", + "src/deviceinfo/dm_device_info_manager.cpp", + "src/devicestate/dm_device_state_manager.cpp", + "src/discovery/dm_discovery_manager.cpp", + "src/ipc/lite/ipc_cmd_parser.cpp", + "src/ipc/lite/ipc_server_listener.cpp", + "src/ipc/lite/ipc_server_listenermgr.cpp", + "src/ipc/lite/ipc_server_main.cpp", + "src/ipc/lite/ipc_server_stub.cpp", + ] + ldflags = dm_ldflags + + defines = [ + "LITE_DEVICE", + "HI_LOG_ENABLE", + "DH_LOG_TAG=\"devicemanagerservice\"", + "LOG_DOMAIN=0xD004100", + ] + + deps = [ + "${common_path}/include/show_confirm_dialog/dialog_ui/js:dialog_js_files_etc", + "${innerkits_path}/native_cpp:devicemanagersdk", + "${utils_path}:devicemanagerutils", + "//base/hiviewdfx/hilog_lite/frameworks/featured:hilog_shared", + "//base/security/deviceauth/services:deviceauth_sdk", + "//base/startup/syspara_lite/frameworks/parameter/src:sysparam", + "//foundation/communication/dsoftbus/sdk:softbus_client", + "//foundation/communication/ipc_lite:liteipc_adapter", + "//foundation/distributedschedule/samgr_lite/samgr:samgr", + "//third_party/bounds_checking_function:libsec_shared", + "//third_party/mbedtls:mbedtls_shared", + "//utils/native/lite:utils", + ] } } else if (!support_jsapi) { group("devicemanagerservice") { @@ -34,6 +126,7 @@ if (defined(ohos_lite)) { "include/config", "include/adapter", "include/authentication", + "include/authentication/showconfirm/standard", "include/ability", "include/deviceinfo", "include/devicestate", @@ -64,8 +157,8 @@ if (defined(ohos_lite)) { "src/authentication/auth_message_processor.cpp", "src/authentication/auth_request_state.cpp", "src/authentication/auth_response_state.cpp", - "src/authentication/auth_ui.cpp", "src/authentication/dm_auth_manager.cpp", + "src/authentication/showconfirm/standard/show_confirm.cpp", "src/config/dm_config_manager.cpp", "src/dependency/commonevent/dm_common_event_manager.cpp", "src/dependency/hichain/hichain_connector.cpp", diff --git a/services/devicemanagerservice/include/authentication/authentication.h b/services/devicemanagerservice/include/authentication/authentication.h index 7c59f31c49fe03087aa33a5f99a1ab6663f45866..49b0aaccd18af78e0d19ff8dcfb3c19c3545c913 100644 --- a/services/devicemanagerservice/include/authentication/authentication.h +++ b/services/devicemanagerservice/include/authentication/authentication.h @@ -27,6 +27,7 @@ public: virtual int32_t ShowAuthInfo(std::string &authToken, std::shared_ptr authManager) = 0; virtual int32_t StartAuth(std::string &authToken, std::shared_ptr authManager) = 0; virtual int32_t VerifyAuthentication(std::string &authToken, const std::string &authParam) = 0; + virtual int32_t CloseAuthInfo(const int32_t &pageId, std::shared_ptr authManager) = 0; }; using CreateIAuthAdapterFuncPtr = IAuthentication *(*)(void); diff --git a/services/devicemanagerservice/include/authentication/dm_auth_manager.h b/services/devicemanagerservice/include/authentication/dm_auth_manager.h index 9e1dd3b69b87226ad14636df7e4f07bcac202678..799e61e3aeba43f9ef2da02d95719d3cc9b41081 100644 --- a/services/devicemanagerservice/include/authentication/dm_auth_manager.h +++ b/services/devicemanagerservice/include/authentication/dm_auth_manager.h @@ -21,7 +21,6 @@ #include "auth_request_state.h" #include "auth_response_state.h" -#include "auth_ui.h" #include "authentication.h" #include "device_manager_service_listener.h" #include "dm_ability_manager.h" diff --git a/services/devicemanagerservice/include/authentication/showconfirm/lite/show_confirm.h b/services/devicemanagerservice/include/authentication/showconfirm/lite/show_confirm.h new file mode 100644 index 0000000000000000000000000000000000000000..df924b865e5b788a5c1e99937f1bdff29ed60ac1 --- /dev/null +++ b/services/devicemanagerservice/include/authentication/showconfirm/lite/show_confirm.h @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef OHOS_DM_SHOW_CONFIRM_H +#define OHOS_DM_SHOW_CONFIRM_H + +#include +#include +#include + +#include "dm_auth_manager.h" +#include "dm_ability_manager.h" + +namespace OHOS { +namespace DistributedHardware { +class ShowConfirm { +public: + ShowConfirm(); + ~ShowConfirm(); + void ShowConfirmDialog(const std::string ¶ms, + std::shared_ptr authManager, std::shared_ptr dmAbilityMgr); +}; +} // namespace DistributedHardware +} // namespace OHOS +#endif // OHOS_DM_SHOW_CONFIRM_H diff --git a/services/devicemanagerservice/include/authentication/auth_ui.h b/services/devicemanagerservice/include/authentication/showconfirm/standard/show_confirm.h similarity index 65% rename from services/devicemanagerservice/include/authentication/auth_ui.h rename to services/devicemanagerservice/include/authentication/showconfirm/standard/show_confirm.h index 4ba96cb50c9680afaa424212760915ad8bf64968..afcfd0b5fec17180a0f5da677ee76ab2d957e2eb 100644 --- a/services/devicemanagerservice/include/authentication/auth_ui.h +++ b/services/devicemanagerservice/include/authentication/showconfirm/standard/show_confirm.h @@ -13,26 +13,26 @@ * limitations under the License. */ -#ifndef OHOS_DM_AUTH_UI_H -#define OHOS_DM_AUTH_UI_H +#ifndef OHOS_DM_SHOW_CONFIRM_H +#define OHOS_DM_SHOW_CONFIRM_H -#include +#include +#include +#include +#include "dm_auth_manager.h" #include "dm_ability_manager.h" namespace OHOS { namespace DistributedHardware { -class AuthUi { +class ShowConfirm { public: - AuthUi(); - int32_t ShowConfirmDialog(std::shared_ptr dmAbilityManager); - -private: - int32_t StartFaService(); - -private: - std::shared_ptr dmAbilityMgr_; + ShowConfirm(); + ~ShowConfirm(); + void ShowConfirmDialog(const std::string ¶ms, + std::shared_ptr authManager, std::shared_ptr dmAbilityMgr); }; } // namespace DistributedHardware } // namespace OHOS -#endif // OHOS_DM_AUTH_UI_H \ No newline at end of file +#endif // OHOS_DM_SHOW_CONFIRM_H + diff --git a/services/devicemanagerservice/include/dependency/commonevent/dm_common_event_manager.h b/services/devicemanagerservice/include/dependency/commonevent/dm_common_event_manager.h index 81d51bb2a6482ffc0f1d329b4cb260503905db5f..3f4ee0567cd73d9d3c32226782694c1e79af5632 100644 --- a/services/devicemanagerservice/include/dependency/commonevent/dm_common_event_manager.h +++ b/services/devicemanagerservice/include/dependency/commonevent/dm_common_event_manager.h @@ -67,4 +67,4 @@ private: }; } // namespace DistributedHardware } // namespace OHOS -#endif // OHOS_EVENT_MANAGER_ADAPT_H \ No newline at end of file +#endif // OHOS_EVENT_MANAGER_ADAPT_H diff --git a/services/devicemanagerservice/include/devicestate/dm_device_state_manager.h b/services/devicemanagerservice/include/devicestate/dm_device_state_manager.h old mode 100755 new mode 100644 diff --git a/services/devicemanagerservice/src/adapter/lite/dm_adapter_manager.cpp b/services/devicemanagerservice/src/adapter/lite/dm_adapter_manager.cpp index 9cca6510986513d820768192558861880f128209..2abbce6d5a0c061f1b0420a1e23b572cae98329e 100644 --- a/services/devicemanagerservice/src/adapter/lite/dm_adapter_manager.cpp +++ b/services/devicemanagerservice/src/adapter/lite/dm_adapter_manager.cpp @@ -26,29 +26,19 @@ DmAdapterManager &DmAdapterManager::GetInstance() return instance; } -DmAdapterManager::DmAdapterManager() +std::shared_ptr DmAdapterManager::GetDecisionAdapter(const std::string &soName) { - LOGI("DmAdapterManager constructor"); + return nullptr; } -DmAdapterManager::~DmAdapterManager() +std::shared_ptr DmAdapterManager::GetProfileAdapter(const std::string &soName) { - LOGI("DmAdapterManager destructor"); + return nullptr; } -std::shared_ptr DmAdapterManager::GetDecisionAdapter() +std::shared_ptr DmAdapterManager::GetCryptoAdapter(const std::string &soName) { - return decisionAdapterPtr_; -} - -std::shared_ptr DmAdapterManager::GetProfileAdapter() -{ - return profileAdapterPtr_; -} - -std::shared_ptr DmAdapterManager::GetCryptoAdapter() -{ - return cryptoAdapterPtr_; + return nullptr; } } // namespace DistributedHardware } // namespace OHOS diff --git a/services/devicemanagerservice/src/authentication/dm_auth_manager.cpp b/services/devicemanagerservice/src/authentication/dm_auth_manager.cpp index bb075c5b98ab08045d520c72ccf794811e03fc19..0fa2f41346197df96617f0274bb20833897cf63d 100644 --- a/services/devicemanagerservice/src/authentication/dm_auth_manager.cpp +++ b/services/devicemanagerservice/src/authentication/dm_auth_manager.cpp @@ -16,7 +16,6 @@ #include "dm_auth_manager.h" #include "auth_message_processor.h" -#include "auth_ui.h" #include "dm_ability_manager.h" #include "dm_config_manager.h" #include "dm_constants.h" @@ -25,9 +24,7 @@ #include "multiple_user_connector.h" #include "nlohmann/json.hpp" #include "parameter.h" -#include "ui_service_mgr_client.h" -#include "dialog_callback_stub.h" -#include "dialog_callback.h" +#include "show_confirm.h" namespace OHOS { namespace DistributedHardware { @@ -555,7 +552,13 @@ int32_t DmAuthManager::AddMember(const std::string &deviceId) return DM_FAILED; } LOGI("DmAuthManager::authRequestContext CancelDisplay start"); - Ace::UIServiceMgrClient::GetInstance()->CancelDialog(authResponseContext_->pageId); + std::shared_ptr ptr; + if (authenticationMap_.find(authResponseContext_->authType) == authenticationMap_.end()) { + LOGE("DmAuthManager::authenticationMap_ is null"); + return DM_FAILED; + } + ptr = authenticationMap_[authResponseContext_->authType]; + ptr->CloseAuthInfo(authResponseContext_->pageId, shared_from_this()); return DM_OK; } @@ -585,7 +588,13 @@ void DmAuthManager::AuthenticateFinish() LOGI("DmAuthManager::AuthenticateFinish start"); if (authResponseState_ != nullptr) { if (authResponseState_->GetStateType() == AuthState::AUTH_RESPONSE_FINISH) { - Ace::UIServiceMgrClient::GetInstance()->CancelDialog(authResponseContext_->pageId); + std::shared_ptr ptr; + if (authenticationMap_.find(authResponseContext_->authType) == authenticationMap_.end()) { + LOGE("DmAuthManager::authenticationMap_ is null"); + return ; + } + ptr = authenticationMap_[authResponseContext_->authType]; + ptr->CloseAuthInfo(authResponseContext_->pageId, shared_from_this()); } if (isFinishOfLocal_) { authMessageProcessor_->SetResponseContext(authResponseContext_); @@ -610,16 +619,18 @@ void DmAuthManager::AuthenticateFinish() } else { authRequestContext_->reason = authResponseContext_->reply; } - if (authResponseContext_->state == AuthState::AUTH_REQUEST_INPUT) { - Ace::UIServiceMgrClient::GetInstance()->CancelDialog(authResponseContext_->pageId); + std::shared_ptr ptr; + if (authenticationMap_.find(authResponseContext_->authType) == authenticationMap_.end()) { + LOGE("DmAuthManager::authenticationMap_ is null"); + return ; + } + ptr = authenticationMap_[authResponseContext_->authType]; + ptr->CloseAuthInfo(authResponseContext_->pageId, shared_from_this()); } - listener_->OnAuthResult(authRequestContext_->hostPkgName, authRequestContext_->deviceId, authRequestContext_->token, authResponseContext_->state, authRequestContext_->reason); - softbusConnector_->GetSoftbusSession()->CloseAuthSession(authRequestContext_->sessionId); - if (!timerMap_.empty()) { for (auto &iter : timerMap_) { iter.second->Stop(SESSION_CANCEL_TIMEOUT); @@ -705,24 +716,15 @@ int32_t DmAuthManager::GetPinCode() void DmAuthManager::ShowConfigDialog() { LOGI("ShowConfigDialog start"); + dmAbilityMgr_ = std::make_shared(); nlohmann::json jsonObj; jsonObj[TAG_AUTH_TYPE] = AUTH_TYPE_PIN; jsonObj[TAG_TOKEN] = authResponseContext_->token; jsonObj[TARGET_PKG_NAME_KEY] = authResponseContext_->targetPkgName; jsonObj.dump(); const std::string params = jsonObj.dump(); - std::shared_ptr authMgr_ = shared_from_this(); - - Ace::UIServiceMgrClient::GetInstance()->ShowDialog( - "config_dialog_service", - params, - OHOS::Rosen::WindowType::WINDOW_TYPE_SYSTEM_ALARM_WINDOW, - ACE_X, ACE_Y, ACE_WIDTH, ACE_HEIGHT, - [authMgr_](int32_t id, const std::string& event, const std::string& params) { - Ace::UIServiceMgrClient::GetInstance()->CancelDialog(id); - LOGI("CancelDialog start id:%d,event:%s,parms:%s", id, event.c_str(), params.c_str()); - authMgr_->StartAuthProcess(atoi(params.c_str())); - }); + std::shared_ptr showConfirm_ = std::make_shared(); + showConfirm_->ShowConfirmDialog(params, shared_from_this(), dmAbilityMgr_); LOGI("ShowConfigDialog end"); } diff --git a/services/devicemanagerservice/src/authentication/auth_ui.cpp b/services/devicemanagerservice/src/authentication/showconfirm/lite/show_confirm.cpp similarity index 57% rename from services/devicemanagerservice/src/authentication/auth_ui.cpp rename to services/devicemanagerservice/src/authentication/showconfirm/lite/show_confirm.cpp index b3afce4537a85d43c4046347277ef0b71f0cacfd..1619dd03361c6040663be2b89054122e8d4ff9eb 100644 --- a/services/devicemanagerservice/src/authentication/auth_ui.cpp +++ b/services/devicemanagerservice/src/authentication/showconfirm/lite/show_confirm.cpp @@ -13,37 +13,37 @@ * limitations under the License. */ -#include "auth_ui.h" +#include "show_confirm.h" +#include "dm_auth_manager.h" #include "dm_ability_manager.h" #include "dm_constants.h" #include "dm_log.h" namespace OHOS { namespace DistributedHardware { -AuthUi::AuthUi() +ShowConfirm::ShowConfirm() { - LOGI("AuthUi constructor"); } -int32_t AuthUi::ShowConfirmDialog(std::shared_ptr dmAbilityManager) +ShowConfirm::~ShowConfirm() { - if (dmAbilityManager == nullptr) { - LOGE("AuthUi::dmAbilityManager is null"); - return DM_FAILED; - } - dmAbilityMgr_ = dmAbilityManager; - return StartFaService(); } -int32_t AuthUi::StartFaService() +void ShowConfirm::ShowConfirmDialog(const std::string ¶ms, std::shared_ptr authManager, + std::shared_ptr dmAbilityMgr) { - AbilityStatus status = dmAbilityMgr_->StartAbility(AbilityRole::ABILITY_ROLE_PASSIVE); + LOGI("ShowConfirm hap start"); + if (dmAbilityMgr == nullptr) { + LOGE("ShowConfirm::dmAbilityManager is null"); + return; + } + AbilityStatus status = dmAbilityMgr->StartAbility(AbilityRole::ABILITY_ROLE_PASSIVE); if (status != AbilityStatus::ABILITY_STATUS_SUCCESS) { - LOGE("AuthUi::StartFaService timeout"); - return DM_FAILED; + LOGE("ShowConfirm::startFaservice timeout"); + return; } - return DM_OK; -} + LOGI("ShowConfirm hap end"); +}; } // namespace DistributedHardware } // namespace OHOS diff --git a/services/devicemanagerservice/src/authentication/showconfirm/standard/show_confirm.cpp b/services/devicemanagerservice/src/authentication/showconfirm/standard/show_confirm.cpp new file mode 100644 index 0000000000000000000000000000000000000000..54e8a2ddf0680631887e37c1ec752556c65d86e2 --- /dev/null +++ b/services/devicemanagerservice/src/authentication/showconfirm/standard/show_confirm.cpp @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "show_confirm.h" + +#include "dm_auth_manager.h" +#include "dm_constants.h" +#include "dm_log.h" +#include "ui_service_mgr_client.h" + +namespace OHOS { +namespace DistributedHardware { +ShowConfirm::ShowConfirm() +{ + LOGI("ShowConfirm ace constructor"); +} + +ShowConfirm::~ShowConfirm() +{ +} + +void ShowConfirm::ShowConfirmDialog(const std::string ¶ms, std::shared_ptr authManager, + std::shared_ptr dmAbilityMgr) +{ + LOGI("ShowConfirm ace start"); + if (authManager == nullptr) { + LOGE("ShowConfirm::dmAbilityManager is null"); + return; + } + Ace::UIServiceMgrClient::GetInstance()->ShowDialog( + "config_dialog_service", + params, + OHOS::Rosen::WindowType::WINDOW_TYPE_SYSTEM_ALARM_WINDOW, + ACE_X, ACE_Y, ACE_WIDTH, ACE_HEIGHT, + [authManager](int32_t id, const std::string& event, const std::string& params) { + if (strcmp(params.c_str(), "2") == 0) { + authManager->SetPageId(id); + } + if (strcmp(params.c_str(), "0") == 0 || strcmp(params.c_str(), "1") == 0) { + Ace::UIServiceMgrClient::GetInstance()->CancelDialog(id); + LOGI("CancelDialog start id:%d,event:%s,parms:%s", id, event.c_str(), params.c_str()); + authManager->StartAuthProcess(atoi(params.c_str())); + } + }); + LOGI("ShowConfirm ace end"); +} +} // namespace DistributedHardware +} // namespace OHOS diff --git a/services/devicemanagerservice/src/dependency/multipleuser/multiple_user_connector.cpp b/services/devicemanagerservice/src/dependency/multipleuser/multiple_user_connector.cpp index 4168ce99e76bc27fcbde613d5885c5f965145e1f..fe4a82a02e6da26a4560b57c428b5607c461b3f0 100644 --- a/services/devicemanagerservice/src/dependency/multipleuser/multiple_user_connector.cpp +++ b/services/devicemanagerservice/src/dependency/multipleuser/multiple_user_connector.cpp @@ -15,11 +15,11 @@ #include "multiple_user_connector.h" -#include "dm_constants.h" #include "dm_log.h" +#ifndef LITE_DEVICE #include "os_account_manager.h" - using namespace OHOS::AccountSA; +#endif namespace OHOS { namespace DistributedHardware { @@ -27,12 +27,16 @@ int32_t MultipleUserConnector::oldUserId_ = -1; int32_t MultipleUserConnector::GetCurrentAccountUserID(void) { +#ifndef LITE_DEVICE std::vector ids; ErrCode ret = OsAccountManager::QueryActiveOsAccountIds(ids); if (ret != ERR_OK || ids.empty()) { return -1; } return ids[0]; +#else + return 0; +#endif } void MultipleUserConnector::SetSwitchOldUserId(int32_t userId) @@ -42,7 +46,11 @@ void MultipleUserConnector::SetSwitchOldUserId(int32_t userId) int32_t MultipleUserConnector::GetSwitchOldUserId(void) { +#ifndef LITE_DEVICE return oldUserId_; +#else + return 0; +#endif } } // namespace DistributedHardware -} // namespace OHOS \ No newline at end of file +} // namespace OHOS diff --git a/services/devicemanagerservice/src/dependency/softbus/softbus_connector.cpp b/services/devicemanagerservice/src/dependency/softbus/softbus_connector.cpp index 40f6707ccff6f44e2c9430af44c6c3331166db42..104321a19be2482c482a46004a9f05f59f7540b3 100644 --- a/services/devicemanagerservice/src/dependency/softbus/softbus_connector.cpp +++ b/services/devicemanagerservice/src/dependency/softbus/softbus_connector.cpp @@ -96,7 +96,6 @@ int32_t SoftbusConnector::Init() usleep(SOFTBUS_CHECK_INTERVAL); } } while (ret != DM_OK); - LOGI("RegNodeDeviceStateCb success."); PublishInfo dmPublishInfo; dmPublishInfo.publishId = DISTRIBUTED_HARDWARE_DEVICEMANAGER_SA_ID; @@ -106,7 +105,6 @@ int32_t SoftbusConnector::Init() dmPublishInfo.capability = DM_CAPABILITY_OSD; dmPublishInfo.capabilityData = nullptr; dmPublishInfo.dataLen = 0; - char discoverStatus[DISCOVER_STATUS_LEN + 1] = {0}; ret = GetParameter(DISCOVER_STATUS_KEY.c_str(), "not exist", discoverStatus, DISCOVER_STATUS_LEN); if (strcmp(discoverStatus, "not exist") == 0) { @@ -131,9 +129,14 @@ int32_t SoftbusConnector::Init() } LOGI("service unpublish result is : %d", ret); } - +#ifdef LITE_DEVICE + ret = PublishService(DM_PKG_NAME.c_str(), &dmPublishInfo, &softbusPublishCallback_); + if (ret == DM_OK) { + publishStatus = ALLOW_BE_DISCOVERY; + } +#else ret = WatchParameter(DISCOVER_STATUS_KEY.c_str(), &SoftbusConnector::OnParameterChgCallback, nullptr); - LOGI("register Watch Parameter result is : %d"); +#endif return ret; } @@ -222,6 +225,7 @@ int32_t SoftbusConnector::StartDiscovery(const DmSubscribeInfo &dmSubscribeInfo) LOGE("StartDiscovery failed with ret %d.", ret); return DM_DISCOVERY_FAILED; } + LOGI("StartDiscovery success."); return DM_OK; } diff --git a/services/devicemanagerservice/src/device_manager_service.cpp b/services/devicemanagerservice/src/device_manager_service.cpp index cda681629c4ac9db5dee1f4785e55dff8109a551..0571d79dbf4a3a48398f6cafa6d340e29030c424 100644 --- a/services/devicemanagerservice/src/device_manager_service.cpp +++ b/services/devicemanagerservice/src/device_manager_service.cpp @@ -17,16 +17,20 @@ #include +#ifndef LITE_DEVICE #include "common_event_support.h" -#include "device_manager_service_listener.h" #include "dm_common_event_manager.h" +#endif +#include "device_manager_service_listener.h" #include "dm_constants.h" #include "dm_device_info_manager.h" #include "dm_log.h" #include "multiple_user_connector.h" #include "permission_manager.h" +#ifndef LITE_DEVICE using namespace OHOS::EventFwk; +#endif namespace OHOS { namespace DistributedHardware { @@ -35,10 +39,12 @@ IMPLEMENT_SINGLE_INSTANCE(DeviceManagerService); DeviceManagerService::~DeviceManagerService() { LOGI("DeviceManagerService destructor"); +#ifndef LITE_DEVICE DmCommonEventManager &dmCommonEventManager = DmCommonEventManager::GetInstance(); if (dmCommonEventManager.UnsubscribeServiceEvent(CommonEventSupport::COMMON_EVENT_USER_STOPPED)) { LOGI("subscribe service event success"); } +#endif softbusConnector_->GetSoftbusSession()->UnRegisterSessionCallback(); hiChainConnector_->UnRegisterHiChainCallback(); } @@ -113,13 +119,14 @@ int32_t DeviceManagerService::Init() LOGI("get current account user id success"); MultipleUserConnector::SetSwitchOldUserId(userId); } - +#ifndef LITE_DEVICE DmCommonEventManager &dmCommonEventManager = DmCommonEventManager::GetInstance(); CommomEventCallback callback = std::bind(&DmAuthManager::UserSwitchEventCallback, *authMgr_.get(), std::placeholders::_1); if (dmCommonEventManager.SubscribeServiceEvent(CommonEventSupport::COMMON_EVENT_USER_SWITCHED, callback)) { LOGI("subscribe service user switch common event success"); } +#endif LOGI("Init success, singleton initialized"); intFlag_ = true; diff --git a/services/devicemanagerservice/src/devicestate/dm_device_state_manager.cpp b/services/devicemanagerservice/src/devicestate/dm_device_state_manager.cpp old mode 100755 new mode 100644 diff --git a/services/devicemanagerservice/src/ipc/lite/ipc_cmd_parser.cpp b/services/devicemanagerservice/src/ipc/lite/ipc_cmd_parser.cpp index 6e14961b372fb70bf8f008de6d6064e8c27a888b..be07c9ba82653275d5cc726c7fa4ff3b6c5f49bc 100644 --- a/services/devicemanagerservice/src/ipc/lite/ipc_cmd_parser.cpp +++ b/services/devicemanagerservice/src/ipc/lite/ipc_cmd_parser.cpp @@ -220,10 +220,8 @@ ON_IPC_SERVER_CMD(UNAUTHENTICATE_DEVICE, IpcIo &req, IpcIo &reply) ON_IPC_SERVER_CMD(VERIFY_AUTHENTICATION, IpcIo &req, IpcIo &reply) { LOGI("VerifyAuthentication service listener."); - std::string pkgName = (const char *)IpcIoPopString(&req, nullptr); std::string authParam = (const char *)IpcIoPopString(&req, nullptr); - - int32_t ret = DeviceManagerService::GetInstance().VerifyAuthentication(pkgName, authParam); + int32_t ret = DeviceManagerService::GetInstance().VerifyAuthentication(authParam); IpcIoPushInt32(&reply, ret); } @@ -246,11 +244,5 @@ ON_IPC_SET_REQUEST(SERVER_DEVICE_FA_NOTIFY, std::shared_ptr pBaseReq, Ip IpcIoPushString(&request, paramJson.c_str()); return DM_OK; } - -ON_IPC_READ_RESPONSE(SERVER_DEVICE_FA_NOTIFY, IpcIo &request, std::shared_ptr pBaseRsp) -{ - pBaseRsp->SetErrCode(reply.ReadInt32()); - return DM_OK; -} } // namespace DistributedHardware } // namespace OHOS diff --git a/services/devicemanagerservice/src/ipc/lite/ipc_server_main.cpp b/services/devicemanagerservice/src/ipc/lite/ipc_server_main.cpp index 18258ff4faa9aa9d0d183dbf6085d1c041278913..b10f008f45498c74d3ce5beef04c37532a7a0bb6 100644 --- a/services/devicemanagerservice/src/ipc/lite/ipc_server_main.cpp +++ b/services/devicemanagerservice/src/ipc/lite/ipc_server_main.cpp @@ -16,12 +16,35 @@ #include #include +#include "device_manager_service.h" +#include "dm_constants.h" +#include "dm_log.h" +#include "ipc_server_stub.h" + +using namespace OHOS::DistributedHardware; + +static void InitAll() +{ + const int32_t DM_SERVICE_INIT_DELAY = 2; + sleep(DM_SERVICE_INIT_DELAY); + if (IpcServerStubInit() != DM_OK) { + LOGI("IpcServerStubInit failed"); + return; + } + if (DeviceManagerService::GetInstance().Init() != DM_OK) { + LOGI("DeviceManagerServic init failed"); + return; + } + LOGI("DM ipc server Init success"); +} + int32_t main(int32_t argc, char *argv[]) { (void)argc; (void)argv; + InitAll(); while (true) { pause(); } return 0; -} \ No newline at end of file +} diff --git a/services/devicemanagerservice/src/ipc/lite/ipc_server_stub.cpp b/services/devicemanagerservice/src/ipc/lite/ipc_server_stub.cpp index ebdc8241ac1fbffd4abb907e8c525c0feadd6724..6bbfe2d98d91b69dccb1549f8028b8612fb9e128 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 97f5c361e461e48393454d1ae35bfcdfed7537d9..652199e996b4d7fdc3ab8a8dd9fe57fe04ab10f0 100644 --- a/utils/BUILD.gn +++ b/utils/BUILD.gn @@ -21,6 +21,52 @@ import("//foundation/distributedhardware/devicemanager/devicemanager.gni") if (defined(ohos_lite)) { shared_library("devicemanagerutils") { + include_dirs = [ + "${common_path}/include", + "${common_path}/include/ipc", + "${common_path}/include/ipc/model", + "include", + "include/ipc/lite", + "include/permission/lite", + ] + include_dirs += [ + "//base/security/deviceauth/interfaces/innerkits", + "//base/startup/syspara_lite/interfaces/innerkits/native/syspara/include", + "//utils/native/lite/include", + "//utils/system/safwk/native/include", + "//third_party/json/include", + "//base/hiviewdfx/hilog_lite/interfaces/native/innerkits", + "//third_party/bounds_checking_function/include", + "//foundation/communication/ipc_lite/interfaces/kits", + "//foundation/communication/dsoftbus/interfaces/kits/bus_center", + "//foundation/communication/dsoftbus/interfaces/kits/common", + "//foundation/communication/dsoftbus/interfaces/kits/discovery", + "//foundation/communication/dsoftbus/interfaces/kits/transport", + "//foundation/communication/dsoftbus/interfaces/inner_kits/transport", + "//foundation/distributedschedule/samgr_lite/interfaces/kits/samgr", + ] + sources = [ + "src/dm_anonymous.cpp", + "src/dm_log.cpp", + "src/dm_random.cpp", + "src/ipc/lite/ipc_cmd_register.cpp", + "src/permission/lite/permission_manager.cpp", + ] + defines = [ + "hI_LOG_ENABLE", + "DH_LOG_TAG=\"devicemanagerutils\"", + "lOG_DOMAIN=0xD004100", + ] + deps = [ + "//base/hiviewdfx/hilog_lite/frameworks/featured:hilog_shared", + "//base/startup/syspara_lite/frameworks/parameter/src:sysparam", + "//foundation/communication/dsoftbus/sdk:softbus_client", + "//foundation/communication/ipc_lite:liteipc_adapter", + "//foundation/distributedschedule/samgr_lite/samgr:samgr", + "//third_party/bounds_checking_function:libsec_shared", + "//third_party/mbedtls:mbedtls_shared", + "//utils/native/lite:utils", + ] } } else { config("devicemanagerutils_config") {