From 61bffdfa19deea4e9cef1b159ca87c0a51dbaf5e Mon Sep 17 00:00:00 2001 From: openharmony_ci <120357966@qq.com> Date: Thu, 21 Aug 2025 12:06:46 +0000 Subject: [PATCH 1/2] =?UTF-8?q?!2743=20=E5=BB=BA=E5=8D=A1=E6=B5=81?= =?UTF-8?q?=E7=A8=8B=E7=BB=B4=E6=B5=8B=E5=A2=9E=E5=BC=BA=20Merge=20pull=20?= =?UTF-8?q?request=20!2743=20from=20xiangcong/master?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- BUILD.gn | 5 +- .../inner_api/include}/form_event_report.h | 0 .../include/form_event_report_define.h | 16 +++- interfaces/inner_api/include/form_file_util.h | 30 ++++++++ .../inner_api/include/form_mgr_errors.h | 1 + .../inner_api/src}/form_event_report.cpp | 9 ++- interfaces/inner_api/src/form_file_util.cpp | 73 +++++++++++++++++++ interfaces/kits/native/src/form_mgr.cpp | 13 +++- .../src/form_render_event_report.cpp | 2 +- .../src/form_render_record.cpp | 20 +++-- .../include/common/event/form_event_util.h | 2 - services/include/form_mgr/form_mgr_adapter.h | 2 - .../connection/form_ability_connection.cpp | 2 +- services/src/common/event/form_event_util.cpp | 42 ----------- .../src/common/timer_mgr/form_timer_mgr.cpp | 2 +- services/src/common/util/form_report.cpp | 2 +- .../database/form_rdb_data_mgr.cpp | 6 +- services/src/data_center/form_data_mgr.cpp | 6 +- .../src/data_center/form_data_proxy_mgr.cpp | 4 +- .../data_center/form_data_proxy_record.cpp | 2 +- .../data_center/form_info/form_info_mgr.cpp | 2 +- .../form_info/form_info_rdb_storage_mgr.cpp | 24 +++--- .../form_record/form_record_report.cpp | 2 +- .../feature/memory_mgr/form_render_report.cpp | 2 +- services/src/form_mgr/form_mgr_adapter.cpp | 14 +--- services/src/form_mgr/form_mgr_service.cpp | 6 +- .../src/form_provider/form_provider_mgr.cpp | 2 +- .../src/form_refresh/form_refresh_mgr.cpp | 2 +- services/src/form_render/form_render_mgr.cpp | 2 +- .../src/form_render/form_render_mgr_inner.cpp | 5 +- .../src/form_render/form_render_task_mgr.cpp | 2 +- .../form_status_task_mgr.cpp | 4 +- .../fms_form_event_report_test.cpp | 2 +- .../fms_form_mgr_adapter_test3.cpp | 25 ------- .../form_bundle_distributed_mgr_test/BUILD.gn | 2 +- .../form_bundle_forbid_mgr_test/BUILD.gn | 2 +- test/unittest/form_report_test/BUILD.gn | 2 +- .../form_report_test/form_report_test.cpp | 2 +- 38 files changed, 197 insertions(+), 144 deletions(-) rename {services/include/common/event => interfaces/inner_api/include}/form_event_report.h (100%) create mode 100644 interfaces/inner_api/include/form_file_util.h rename {services/src/common/event => interfaces/inner_api/src}/form_event_report.cpp (99%) create mode 100644 interfaces/inner_api/src/form_file_util.cpp diff --git a/BUILD.gn b/BUILD.gn index 34881857a1..88f54502e3 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -110,7 +110,6 @@ ohos_shared_library("libfms") { "services/src/common/connection/form_ability_connection_reporter.cpp", "services/src/common/event/form_event_handler.cpp", "services/src/common/event/form_event_notify_connection.cpp", - "services/src/common/event/form_event_report.cpp", "services/src/common/event/form_event_util.cpp", "services/src/common/event/system_event/form_sys_event_receiver.cpp", "services/src/common/event/system_event/form_systemload_listener.cpp", @@ -364,6 +363,7 @@ ohos_shared_library("fmskit_native") { "hitrace:hitrace_meter", "ipc:ipc_core", "samgr:samgr_proxy", + "hisysevent:libhisysevent", ] public_external_deps = [ @@ -484,6 +484,8 @@ ohos_shared_library("form_manager") { "interfaces/inner_api/src/provider_connect_proxy.cpp", "interfaces/inner_api/src/provider_connect_stub.cpp", "interfaces/inner_api/src/running_form_info.cpp", + "interfaces/inner_api/src/form_event_report.cpp", + "interfaces/inner_api/src/form_file_util.cpp", ] configs = [ ":formmgr_log_config" ] @@ -514,6 +516,7 @@ ohos_shared_library("form_manager") { "napi:ace_napi", "os_account:os_account_innerkits", "samgr:samgr_proxy", + "hisysevent:libhisysevent", ] subsystem_name = "ability" diff --git a/services/include/common/event/form_event_report.h b/interfaces/inner_api/include/form_event_report.h similarity index 100% rename from services/include/common/event/form_event_report.h rename to interfaces/inner_api/include/form_event_report.h diff --git a/interfaces/inner_api/include/form_event_report_define.h b/interfaces/inner_api/include/form_event_report_define.h index f37a0c2ef3..c56314ef1d 100644 --- a/interfaces/inner_api/include/form_event_report_define.h +++ b/interfaces/inner_api/include/form_event_report_define.h @@ -33,7 +33,7 @@ struct FormEventInfo { bool distributedForm = false; }; -enum class CallDbFiledErrorType : int64_t { +enum class CallDbFailedErrorType : int64_t { LOAD_DATABASE_FAILED = 1, DATABASE_RESET_CONNECT_FAILED, DATABASE_SAVE_FORMID_FAILED, @@ -42,16 +42,25 @@ enum class CallDbFiledErrorType : int64_t { DATABASE_EXIT_ABNORMAL, }; -enum class InitFmsFiledErrorType : int64_t { +enum class InitFmsFailedErrorType : int64_t { LOAD_FORM_DB_FAILED = 1, PUBLISH_SER_FAILED, }; -enum class AddFormFiledErrorType : int64_t { +enum class AddFormFailedErrorType : int64_t { NUMBER_EXCEEDING_LIMIT = 1, CONNECT_FORM_RENDER_FAILED, CONNECT_FORM_PROVIDER_FAILED, SUBSCRIBE_DATA_SHARE_FAILED, + // Sending the card addition request to FMS failed or FMS failed to process the card addition request + ADD_FORM_FAILED, + // Sending a RenderForm request to FRS failed or an exception occurred while FRS processed the RenderForm request + RENDER_FORM_FAILED, + // Failed to create SurfaceNode + UI_CONTENT_INIT_FAILED, + // Failed to mount SurfaceNode + SURFACE_NODE_CREATE_FAILED, + SURFACE_NODE_REUSE_FAILED, }; enum class UpdateFormErrorType : int64_t { @@ -151,6 +160,7 @@ enum class FormEventName { REQUEST_PUBLIC_FORM, CONNECT_FORM_ABILITY_FAILED, RELOAD_FORM_FAILED, + RENDER_FORM_FAILED, }; enum class RequestFormType : int8_t { diff --git a/interfaces/inner_api/include/form_file_util.h b/interfaces/inner_api/include/form_file_util.h new file mode 100644 index 0000000000..8c38cc0cd3 --- /dev/null +++ b/interfaces/inner_api/include/form_file_util.h @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2025 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_FORM_FWK_FORM_FILE_UTIL_H +#define OHOS_FORM_FWK_FORM_FILE_UTIL_H + +#include +#include + +namespace OHOS { +namespace AppExecFwk { +class FormFileUtil { +public: + static void GetDirFiles(const std::string &path, std::vector &files); + static int64_t GetFilesSize(const std::vector &files, std::vector &filesSize); +}; +} // namespace AppExecFwk +} // namespace OHOS +#endif // OHOS_FORM_FWK_FORM_FILE_UTIL_H \ No newline at end of file diff --git a/interfaces/inner_api/include/form_mgr_errors.h b/interfaces/inner_api/include/form_mgr_errors.h index 9181030230..79855e6f9d 100644 --- a/interfaces/inner_api/include/form_mgr_errors.h +++ b/interfaces/inner_api/include/form_mgr_errors.h @@ -27,6 +27,7 @@ enum { constexpr ErrCode AAFWK_FORMMGR_ERR_OFFSET = ErrCodeOffset(SUBSYS_AAFWK, AAFWK_MODULE_FORMMGR); enum { + // 2293761 ERR_APPEXECFWK_FORM_COMMON_CODE = AAFWK_FORMMGR_ERR_OFFSET + 1, ERR_APPEXECFWK_FORM_PERMISSION_DENY, ERR_APPEXECFWK_FORM_PERMISSION_DENY_BUNDLE, diff --git a/services/src/common/event/form_event_report.cpp b/interfaces/inner_api/src/form_event_report.cpp similarity index 99% rename from services/src/common/event/form_event_report.cpp rename to interfaces/inner_api/src/form_event_report.cpp index 52c14b4bdb..48ba20b9d4 100644 --- a/services/src/common/event/form_event_report.cpp +++ b/interfaces/inner_api/src/form_event_report.cpp @@ -13,11 +13,11 @@ * limitations under the License. */ -#include "common/event/form_event_report.h" -#include "common/event/form_event_util.h" +#include "form_event_report.h" #include +#include "form_file_util.h" #include "fms_log_wrapper.h" #include "form_constants.h" @@ -393,13 +393,14 @@ void FormEventReport::SendDiskUseEvent() { std::vector files; std::vector filesSize; - FormEventUtil::GetDirFiles(FORM_STORAGE_DIR_PATH, files); + FormFileUtil::GetDirFiles(FORM_STORAGE_DIR_PATH, files); if (files.empty()) { HILOG_ERROR("files is empty, not report disk use info"); return; } - FormEventUtil::GetFilesSize(files, filesSize); + auto totalSize = FormFileUtil::GetFilesSize(files, filesSize); files.push_back(FORM_STORAGE_DIR_PATH); + filesSize.emplace_back(totalSize); HiSysEventWrite(HiSysEvent::Domain::FILEMANAGEMENT, "USER_DATA_SIZE", HiSysEvent::EventType::STATISTIC, "COMPONENT_NAME", "form_fwk", diff --git a/interfaces/inner_api/src/form_file_util.cpp b/interfaces/inner_api/src/form_file_util.cpp new file mode 100644 index 0000000000..2a79d1c500 --- /dev/null +++ b/interfaces/inner_api/src/form_file_util.cpp @@ -0,0 +1,73 @@ +/* + * Copyright (c) 2025 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 "form_file_util.h" + +#include +#include "directory_ex.h" + +#include "fms_log_wrapper.h" + +namespace OHOS { +namespace AppExecFwk { + +void FormFileUtil::GetDirFiles(const std::string &path, std::vector &files) +{ + DIR *dir = opendir(path.c_str()); + if (dir == nullptr) { + HILOG_ERROR("failed to open file: %{public}s, error: %{public}d", path.c_str(), errno); + return; + } + + std::string pathStringWithDelimiter; + bool shouldExit = false; + while (!shouldExit) { + struct dirent *ptr = readdir(dir); + if (ptr == nullptr) { + HILOG_INFO("The file has been traversed"); + shouldExit = true; + break; + } + + // current dir OR parent dir + if ((strcmp(ptr->d_name, ".") == 0) || (strcmp(ptr->d_name, "..") == 0)) { + continue; + } else if (ptr->d_type == DT_DIR) { + pathStringWithDelimiter = IncludeTrailingPathDelimiter(path) + std::string(ptr->d_name); + GetDirFiles(pathStringWithDelimiter, files); + } else { + files.push_back(IncludeTrailingPathDelimiter(path) + std::string(ptr->d_name)); + } + } + closedir(dir); +} + +int64_t FormFileUtil::GetFilesSize(const std::vector &files, std::vector &filesSize) +{ + struct stat statbuf = {0}; + uint64_t totalSize = 0; + for (auto &file : files) { + auto ret = stat(file.c_str(), &statbuf); + if (ret == 0) { + filesSize.emplace_back(static_cast(statbuf.st_size)); + totalSize += static_cast(statbuf.st_size); + } else { + HILOG_WARN("failed to stat file, errno: %{public}d", errno); + } + } + return totalSize; +} +} // namespace AppExecFwk +} // namespace OHOS diff --git a/interfaces/kits/native/src/form_mgr.cpp b/interfaces/kits/native/src/form_mgr.cpp index a4e8050f8a..4cd0bb5489 100644 --- a/interfaces/kits/native/src/form_mgr.cpp +++ b/interfaces/kits/native/src/form_mgr.cpp @@ -22,6 +22,7 @@ #include "form_event_hiappevent.h" #endif #include "form_errors.h" +#include "form_event_report.h" #include "form_mgr_errors.h" #include "running_form_info.h" #include "if_system_ability_manager.h" @@ -87,7 +88,17 @@ int FormMgr::AddForm( HILOG_ERROR("null remoteProxy_"); return ERR_APPEXECFWK_FORM_COMMON_CODE; } - return remoteProxy_->AddForm(formId, want, callerToken, formInfo); + + errCode = remoteProxy_->AddForm(formId, want, callerToken, formInfo); + if (errCode != ERR_OK) { + FormEventReport::SendFormFailedEvent(FormEventName::ADD_FORM_FAILED, + formInfo.formId, + formInfo.bundleName, + formInfo.formName, + static_cast(AddFormFailedErrorType::ADD_FORM_FAILED), + errCode); + } + return errCode; } /** diff --git a/services/form_render_service/src/form_render_event_report.cpp b/services/form_render_service/src/form_render_event_report.cpp index 1613dbc5c3..37cada5585 100644 --- a/services/form_render_service/src/form_render_event_report.cpp +++ b/services/form_render_service/src/form_render_event_report.cpp @@ -136,7 +136,7 @@ void FormRenderEventReport::StartReleaseTimeoutReportTimer(int64_t formId, const const std::string taskName = "FRS_WaitReleaseRenderer_" + std::to_string(formId); int32_t timerId = HiviewDFX::XCollie::GetInstance().SetTimer(taskName, WAIT_RELEASE_RENDERER_TIMEOUT, timeoutCallback, nullptr, HiviewDFX::XCOLLIE_FLAG_NOOP); - HILOG_INFO("waiting form release, formId: %{public}" PRId64 "timerId: %{public}d", formId, timerId); + HILOG_INFO("waiting form release, formId: %{public}" PRId64 ", timerId: %{public}d", formId, timerId); FormRenderEventReport::waitReleaseTimerMap_.emplace(formId, timerId); } diff --git a/services/form_render_service/src/form_render_record.cpp b/services/form_render_service/src/form_render_record.cpp index 018a97a1b5..504d81cb54 100644 --- a/services/form_render_service/src/form_render_record.cpp +++ b/services/form_render_service/src/form_render_record.cpp @@ -426,7 +426,8 @@ int32_t FormRenderRecord::UpdateRenderRecord(const FormJsInfo &formJsInfo, const if (renderType == Constants::RENDER_FORM) { // Manager delegate proxy invalid, do not render form if (!CheckManagerDelegateValid(formJsInfo, want)) { - return RENDER_FORM_FAILED; + HILOG_WARN("Form node has been released"); + return ERR_APPEXECFWK_FORM_FORM_NODE_RELEASED; } renderFormTasksNum++; bool formIsVisible = want.GetBoolParam(Constants::FORM_IS_VISIBLE, false); @@ -439,14 +440,14 @@ int32_t FormRenderRecord::UpdateRenderRecord(const FormJsInfo &formJsInfo, const // Some resources need to be initialized in a JS thread if (!CheckEventHandler(true, formJsInfo.isDynamic)) { HILOG_ERROR("null eventHandler_ "); - return RENDER_FORM_FAILED; + return ERR_APPEXECFWK_FORM_EVENT_HANDLER_NULL; } std::shared_ptr eventHandler = GetEventHandler(); sptr formSupplyClient = GetFormSupplyClient(); if (formSupplyClient == nullptr) { HILOG_ERROR("null formSupplyClient"); - return RENDER_FORM_FAILED; + return ERR_APPEXECFWK_FORM_COMMON_CODE; } UpdateFormRequest(formJsInfo, want); @@ -472,10 +473,6 @@ int32_t FormRenderRecord::UpdateRenderRecord(const FormJsInfo &formJsInfo, const eventHandler->PostTask(task, "UpdateRenderRecord"); } - if (hostRemoteObj == nullptr) { - HILOG_WARN("null hostRemoteObj"); - return ERR_OK; - } return AddHostByFormId(formJsInfo.formId, hostRemoteObj); } @@ -855,7 +852,7 @@ void FormRenderRecord::MergeFormData(Ace::FormRequest &formRequest, const FormJs std::map> imageMap = formRequest.formJsInfo.imageDataMap; formRequest.formJsInfo = formJsInfo; - //if imageDataMap of formJsInfo is empty, do not replace + // if imageDataMap of formJsInfo is empty, do not replace if (formJsInfo.imageDataMap.size() == 0) { formRequest.formJsInfo.imageDataMap = imageMap; } @@ -1848,6 +1845,8 @@ void FormRenderRecord::UpdateFormSizeOfGroups(const int64_t &formId, float width if (search != formRendererGroupMap_.end()) { auto group = search->second; group->UpdateFormSizeOfFormRequests(width, height, borderWidth); + } else { + HILOG_WARN("formRendererGroup not find, formId:%{public}" PRId64, formId); } } @@ -1900,6 +1899,11 @@ std::shared_ptr FormRenderRecord::GetEventHandler() int32_t FormRenderRecord::AddHostByFormId(int64_t formId, const sptr hostRemoteObj) { + if (hostRemoteObj == nullptr) { + HILOG_WARN("null hostRemoteObj"); + return ERR_OK; + } + std::lock_guard lock(hostsMapMutex_); auto iter = hostsMapForFormId_.find(formId); if (iter == hostsMapForFormId_.end()) { diff --git a/services/include/common/event/form_event_util.h b/services/include/common/event/form_event_util.h index 1c7ba79d99..c1ef53849b 100644 --- a/services/include/common/event/form_event_util.h +++ b/services/include/common/event/form_event_util.h @@ -58,8 +58,6 @@ public: std::map &removedFormsMap); static void HandleOnUnlock(int32_t userId); static bool HandleAdditionalInfoChanged(const std::string &bundleName); - static void GetDirFiles(const std::string &path, std::vector &files); - static void GetFilesSize(std::vector &files, std::vector &filesSize); private: static void UpdateMultiUpdateTime(std::string multiScheduledUpdateTime, FormRecord &formRecord); diff --git a/services/include/form_mgr/form_mgr_adapter.h b/services/include/form_mgr/form_mgr_adapter.h index c54ded5321..f7c23b17c9 100644 --- a/services/include/form_mgr/form_mgr_adapter.h +++ b/services/include/form_mgr/form_mgr_adapter.h @@ -1256,8 +1256,6 @@ private: void CancelAddFormRequestTimeOutTask(const int64_t formId, const int result); - AddFormResultErrorCode GetFormResultErrCode(const int64_t formId); - ErrCode CheckAddFormTaskTimeoutOrFailed(const int64_t formId, AddFormResultErrorCode &formStates); void RemoveFormIdMapElement(const int64_t formId); diff --git a/services/src/common/connection/form_ability_connection.cpp b/services/src/common/connection/form_ability_connection.cpp index c81432a86d..1166403264 100644 --- a/services/src/common/connection/form_ability_connection.cpp +++ b/services/src/common/connection/form_ability_connection.cpp @@ -23,7 +23,7 @@ #include "bms_mgr/form_bms_helper.h" #include "data_center/form_data_mgr.h" #include "data_center/database/form_db_cache.h" -#include "common/event/form_event_report.h" +#include "form_event_report.h" #include "form_info.h" #include "data_center/form_info/form_info_mgr.h" #include "form_provider/form_supply_callback.h" diff --git a/services/src/common/event/form_event_util.cpp b/services/src/common/event/form_event_util.cpp index 14d07a0be7..1aae67a2f8 100644 --- a/services/src/common/event/form_event_util.cpp +++ b/services/src/common/event/form_event_util.cpp @@ -741,47 +741,5 @@ void FormEventUtil::UpdateFormRecord(const AbilityFormInfo &formInfo, FormRecord HILOG_DEBUG("formId:%{public}" PRId64 "", formRecord.formId); FormDataMgr::GetInstance().UpdateFormRecord(formRecord.formId, formRecord); } - -void FormEventUtil::GetDirFiles(const std::string &path, std::vector &files) -{ - DIR *dir = opendir(path.c_str()); - if (dir == nullptr) { - HILOG_ERROR("failed to open file: %{public}s, error: %{public}d", path.c_str(), errno); - return; - } - - std::string pathStringWithDelimiter; - while (true) { - struct dirent *ptr = readdir(dir); - if (ptr == nullptr) { - HILOG_INFO("The file has been traversed"); - break; - } - - // current dir OR parent dir - if ((strcmp(ptr->d_name, ".") == 0) || (strcmp(ptr->d_name, "..") == 0)) { - continue; - } else if (ptr->d_type == DT_DIR) { - pathStringWithDelimiter = IncludeTrailingPathDelimiter(path) + std::string(ptr->d_name); - GetDirFiles(pathStringWithDelimiter, files); - } else { - files.push_back(IncludeTrailingPathDelimiter(path) + std::string(ptr->d_name)); - } - } - closedir(dir); -} - -void FormEventUtil::GetFilesSize(std::vector &files, std::vector &filesSize) -{ - struct stat statbuf = {0}; - uint64_t totalSize = 0; - for (auto &file : files) { - if (stat(file.c_str(), &statbuf) == 0) { - filesSize.emplace_back(static_cast(statbuf.st_size)); - totalSize += static_cast(statbuf.st_size); - } - } - filesSize.emplace_back(totalSize); -} } // namespace AppExecFwk } // namespace OHOS diff --git a/services/src/common/timer_mgr/form_timer_mgr.cpp b/services/src/common/timer_mgr/form_timer_mgr.cpp index 87c00f3d94..29b6c2bf04 100644 --- a/services/src/common/timer_mgr/form_timer_mgr.cpp +++ b/services/src/common/timer_mgr/form_timer_mgr.cpp @@ -32,7 +32,7 @@ #include "time_service_client.h" #include "time_common.h" #include "want.h" -#include "common/event/form_event_report.h" +#include "form_event_report.h" #include "data_center/form_record/form_record_report.h" #include "data_center/form_data_mgr.h" #include "form_refresh/form_refresh_mgr.h" diff --git a/services/src/common/util/form_report.cpp b/services/src/common/util/form_report.cpp index 74fa17691d..c51035b5f8 100644 --- a/services/src/common/util/form_report.cpp +++ b/services/src/common/util/form_report.cpp @@ -17,7 +17,7 @@ #include "data_center/form_record/form_record_report.h" #include "fms_log_wrapper.h" -#include "common/event/form_event_report.h" +#include "form_event_report.h" #include "form_render/form_render_mgr.h" namespace OHOS { diff --git a/services/src/data_center/database/form_rdb_data_mgr.cpp b/services/src/data_center/database/form_rdb_data_mgr.cpp index 7d45658a33..2300f995d8 100644 --- a/services/src/data_center/database/form_rdb_data_mgr.cpp +++ b/services/src/data_center/database/form_rdb_data_mgr.cpp @@ -25,7 +25,7 @@ #include "form_mgr_errors.h" #include "common/util/form_util.h" #include "common/util/scope_guard.h" -#include "common/event/form_event_report.h" +#include "form_event_report.h" namespace OHOS { namespace AppExecFwk { @@ -78,7 +78,7 @@ int32_t RdbStoreDataCallBackFormInfoStorage::OnOpen(NativeRdb::RdbStore &rdbStor int32_t RdbStoreDataCallBackFormInfoStorage::onCorruption(std::string databaseFile) { FormEventReport::SendFormFailedEvent(FormEventName::CALLEN_DB_FAILED, HiSysEventType::FAULT, - static_cast(CallDbFiledErrorType::DATABASE_EXIT_ABNORMAL)); + static_cast(CallDbFailedErrorType::DATABASE_EXIT_ABNORMAL)); return NativeRdb::E_OK; } @@ -718,7 +718,7 @@ ErrCode FormRdbDataMgr::LoadRdbStore() if (errCode != NativeRdb::E_OK) { HILOG_ERROR("Form rdb store init fail, err code is %{public}" PRId32 "", errCode); FormEventReport::SendFormFailedEvent(FormEventName::CALLEN_DB_FAILED, HiSysEventType::FAULT, - static_cast(CallDbFiledErrorType::DATABASE_RESET_CONNECT_FAILED)); + static_cast(CallDbFailedErrorType::DATABASE_RESET_CONNECT_FAILED)); rdbStore_ = nullptr; return ERR_APPEXECFWK_FORM_COMMON_CODE; } diff --git a/services/src/data_center/form_data_mgr.cpp b/services/src/data_center/form_data_mgr.cpp index 5f707a7231..c5a7a6bc10 100644 --- a/services/src/data_center/form_data_mgr.cpp +++ b/services/src/data_center/form_data_mgr.cpp @@ -38,7 +38,7 @@ #include "js_form_state_observer_interface.h" #include "running_form_info.h" #include "data_center/form_record/form_record_report.h" -#include "common/event/form_event_report.h" +#include "form_event_report.h" #include "common/util/form_task_common.h" #include "form_mgr/form_mgr_queue.h" #include "status_mgr_center/form_status.h" @@ -371,7 +371,7 @@ int FormDataMgr::CheckTempEnoughForm() const if (GetTempFormCount() >= maxTempSize) { HILOG_WARN("already exist %{public}d temp forms in system", maxTempSize); FormEventReport::SendFormFailedEvent(FormEventName::ADD_FORM_FAILED, 0, "", "", - static_cast(AddFormFiledErrorType::NUMBER_EXCEEDING_LIMIT), + static_cast(AddFormFailedErrorType::NUMBER_EXCEEDING_LIMIT), ERR_APPEXECFWK_FORM_MAX_SYSTEM_TEMP_FORMS); return ERR_APPEXECFWK_FORM_MAX_SYSTEM_TEMP_FORMS; } @@ -410,7 +410,7 @@ int FormDataMgr::CheckEnoughForm(const int callingUid, const int32_t currentUser if (formDbInfoSize >= maxFormsSize) { HILOG_WARN("exceeds max form number %{public}d", maxFormsSize); FormEventReport::SendFormFailedEvent(FormEventName::ADD_FORM_FAILED, 0, "", "", - static_cast(AddFormFiledErrorType::NUMBER_EXCEEDING_LIMIT), + static_cast(AddFormFailedErrorType::NUMBER_EXCEEDING_LIMIT), ERR_APPEXECFWK_FORM_MAX_SYSTEM_FORMS); return ERR_APPEXECFWK_FORM_MAX_SYSTEM_FORMS; } diff --git a/services/src/data_center/form_data_proxy_mgr.cpp b/services/src/data_center/form_data_proxy_mgr.cpp index 2fcfe69aae..133c37eb4e 100644 --- a/services/src/data_center/form_data_proxy_mgr.cpp +++ b/services/src/data_center/form_data_proxy_mgr.cpp @@ -20,7 +20,7 @@ #include "data_center/form_data_mgr.h" #include "data_center/form_data_proxy_record.h" #include "common/util/form_util.h" -#include "common/event/form_event_report.h" +#include "form_event_report.h" #include "form_mgr_errors.h" namespace OHOS { @@ -68,7 +68,7 @@ ErrCode FormDataProxyMgr::SubscribeFormData(int64_t formId, const std::vector(AddFormFiledErrorType::SUBSCRIBE_DATA_SHARE_FAILED), ret); + static_cast(AddFormFailedErrorType::SUBSCRIBE_DATA_SHARE_FAILED), ret); return ret; } std::lock_guard lock(formDataProxyRecordMutex_); diff --git a/services/src/data_center/form_data_proxy_record.cpp b/services/src/data_center/form_data_proxy_record.cpp index 8170e92ee4..0514cc1f6a 100644 --- a/services/src/data_center/form_data_proxy_record.cpp +++ b/services/src/data_center/form_data_proxy_record.cpp @@ -28,7 +28,7 @@ #include "common/util/form_util.h" #include "ipc_skeleton.h" #include "accesstoken_kit.h" -#include "common/event/form_event_report.h" +#include "form_event_report.h" #include "form_mgr/form_mgr_queue.h" namespace OHOS { diff --git a/services/src/data_center/form_info/form_info_mgr.cpp b/services/src/data_center/form_info/form_info_mgr.cpp index 3bd9063afb..cf3d93d9f7 100644 --- a/services/src/data_center/form_info/form_info_mgr.cpp +++ b/services/src/data_center/form_info/form_info_mgr.cpp @@ -29,7 +29,7 @@ #include "ipc_skeleton.h" #include "json_serializer.h" #include "permission_verification.h" -#include "common/event/form_event_report.h" +#include "form_event_report.h" #include "common_event.h" #include "common_event_manager.h" #include "feature/bundle_distributed/form_distributed_mgr.h" diff --git a/services/src/data_center/form_info/form_info_rdb_storage_mgr.cpp b/services/src/data_center/form_info/form_info_rdb_storage_mgr.cpp index 2029818970..b8d4b4950c 100644 --- a/services/src/data_center/form_info/form_info_rdb_storage_mgr.cpp +++ b/services/src/data_center/form_info/form_info_rdb_storage_mgr.cpp @@ -20,7 +20,7 @@ #include #include "fms_log_wrapper.h" #include "form_constants.h" -#include "common/event/form_event_report.h" +#include "form_event_report.h" namespace OHOS { namespace AppExecFwk { @@ -41,7 +41,7 @@ FormInfoRdbStorageMgr::FormInfoRdbStorageMgr() if (FormRdbDataMgr::GetInstance().InitFormRdbTable(formRdbTableConfig) != ERR_OK) { HILOG_ERROR("Form info rdb storage mgr init form rdb table fail"); FormEventReport::SendFormFailedEvent(FormEventName::INIT_FMS_FAILED, HiSysEventType::FAULT, - static_cast(InitFmsFiledErrorType::LOAD_FORM_DB_FAILED)); + static_cast(InitFmsFailedErrorType::LOAD_FORM_DB_FAILED)); } } @@ -58,7 +58,7 @@ ErrCode FormInfoRdbStorageMgr::LoadFormInfos(std::vector(CallDbFiledErrorType::LOAD_DATABASE_FAILED)); + static_cast(CallDbFailedErrorType::LOAD_DATABASE_FAILED)); return ERR_APPEXECFWK_FORM_COMMON_CODE; } @@ -133,7 +133,7 @@ ErrCode FormInfoRdbStorageMgr::LoadFormData(std::vector &innerFor if (result != ERR_OK) { HILOG_ERROR("get entries error"); FormEventReport::SendFormFailedEvent(FormEventName::CALLEN_DB_FAILED, HiSysEventType::FAULT, - static_cast(CallDbFiledErrorType::LOAD_DATABASE_FAILED)); + static_cast(CallDbFailedErrorType::LOAD_DATABASE_FAILED)); return ERR_APPEXECFWK_FORM_COMMON_CODE; } SaveEntries(value, innerFormInfos); @@ -152,7 +152,7 @@ ErrCode FormInfoRdbStorageMgr::SaveStorageFormData(const InnerFormInfo &innerFor if (result != ERR_OK) { HILOG_ERROR("put innerFormInfo to RdbStore error"); FormEventReport::SendFormFailedEvent(FormEventName::CALLEN_DB_FAILED, HiSysEventType::FAULT, - static_cast(CallDbFiledErrorType::DATABASE_SAVE_FORMID_FAILED)); + static_cast(CallDbFailedErrorType::DATABASE_SAVE_FORMID_FAILED)); return ERR_APPEXECFWK_FORM_COMMON_CODE; } return ERR_OK; @@ -178,7 +178,7 @@ ErrCode FormInfoRdbStorageMgr::DeleteStorageFormData(const std::string &formId) if (result != ERR_OK) { HILOG_ERROR("delete key error"); FormEventReport::SendFormFailedEvent(FormEventName::CALLEN_DB_FAILED, HiSysEventType::FAULT, - static_cast(CallDbFiledErrorType::DATABASE_DELETE_FORMID_FAILED)); + static_cast(CallDbFailedErrorType::DATABASE_DELETE_FORMID_FAILED)); return ERR_APPEXECFWK_FORM_COMMON_CODE; } @@ -187,7 +187,7 @@ ErrCode FormInfoRdbStorageMgr::DeleteStorageFormData(const std::string &formId) if (result != ERR_OK) { HILOG_ERROR("delete status data of %{public}s failed", formId.c_str()); FormEventReport::SendFormFailedEvent(FormEventName::CALLEN_DB_FAILED, HiSysEventType::FAULT, - static_cast(CallDbFiledErrorType::DATABASE_DELETE_FORMID_FAILED)); + static_cast(CallDbFailedErrorType::DATABASE_DELETE_FORMID_FAILED)); return ERR_APPEXECFWK_FORM_COMMON_CODE; } @@ -209,7 +209,7 @@ ErrCode FormInfoRdbStorageMgr::LoadStatusData(const std::string &formId, std::st if (result != ERR_OK) { HILOG_ERROR("load status data of %{public}s failed, code is %{public}d", formId.c_str(), result); FormEventReport::SendFormFailedEvent(FormEventName::CALLEN_DB_FAILED, HiSysEventType::FAULT, - static_cast(CallDbFiledErrorType::DATABASE_QUERY_FORMID_FAILED)); + static_cast(CallDbFailedErrorType::DATABASE_QUERY_FORMID_FAILED)); return ERR_APPEXECFWK_FORM_COMMON_CODE; } @@ -243,7 +243,7 @@ ErrCode FormInfoRdbStorageMgr::GetFormVersionCode(std::string &versionCode) if (result != ERR_OK) { HILOG_ERROR("get form version code failed, code is %{public}d", result); FormEventReport::SendFormFailedEvent(FormEventName::CALLEN_DB_FAILED, HiSysEventType::FAULT, - static_cast(CallDbFiledErrorType::LOAD_DATABASE_FAILED)); + static_cast(CallDbFailedErrorType::LOAD_DATABASE_FAILED)); return ERR_APPEXECFWK_FORM_COMMON_CODE; } HILOG_INFO("get form version code success. versionCode:%{public}s", versionCode.c_str()); @@ -258,7 +258,7 @@ ErrCode FormInfoRdbStorageMgr::UpdateFormVersionCode() if (result != ERR_OK) { HILOG_ERROR("update form version code to rdbstore failed, code is %{public}d", result); FormEventReport::SendFormFailedEvent(FormEventName::CALLEN_DB_FAILED, HiSysEventType::FAULT, - static_cast(CallDbFiledErrorType::DATABASE_SAVE_FORMID_FAILED)); + static_cast(CallDbFailedErrorType::DATABASE_SAVE_FORMID_FAILED)); return ERR_APPEXECFWK_FORM_COMMON_CODE; } return ERR_OK; @@ -272,7 +272,7 @@ ErrCode FormInfoRdbStorageMgr::GetMultiAppFormVersionCode(const std::string &bun if (result != ERR_OK) { HILOG_ERROR("get multi app form version code failed, code is %{public}d", result); FormEventReport::SendFormFailedEvent(FormEventName::CALLEN_DB_FAILED, HiSysEventType::FAULT, - static_cast(CallDbFiledErrorType::LOAD_DATABASE_FAILED)); + static_cast(CallDbFailedErrorType::LOAD_DATABASE_FAILED)); return ERR_APPEXECFWK_FORM_COMMON_CODE; } HILOG_INFO("get multi app form version code success."); @@ -288,7 +288,7 @@ ErrCode FormInfoRdbStorageMgr::UpdateMultiAppFormVersionCode(const std::string & if (result != ERR_OK) { HILOG_ERROR("update multi app form version code to rdbstore failed, code is %{public}d", result); FormEventReport::SendFormFailedEvent(FormEventName::CALLEN_DB_FAILED, HiSysEventType::FAULT, - static_cast(CallDbFiledErrorType::DATABASE_SAVE_FORMID_FAILED)); + static_cast(CallDbFailedErrorType::DATABASE_SAVE_FORMID_FAILED)); return ERR_APPEXECFWK_FORM_COMMON_CODE; } return ERR_OK; diff --git a/services/src/data_center/form_record/form_record_report.cpp b/services/src/data_center/form_record/form_record_report.cpp index 224992a218..bb0377903a 100644 --- a/services/src/data_center/form_record/form_record_report.cpp +++ b/services/src/data_center/form_record/form_record_report.cpp @@ -15,7 +15,7 @@ #include "data_center/form_record/form_record_report.h" #include "fms_log_wrapper.h" -#include "common/event/form_event_report.h" +#include "form_event_report.h" #include "data_center/form_basic_info_mgr.h" namespace OHOS { diff --git a/services/src/feature/memory_mgr/form_render_report.cpp b/services/src/feature/memory_mgr/form_render_report.cpp index 3d2513e0f6..d365e9dc44 100644 --- a/services/src/feature/memory_mgr/form_render_report.cpp +++ b/services/src/feature/memory_mgr/form_render_report.cpp @@ -14,7 +14,7 @@ */ #include "feature/memory_mgr/form_render_report.h" -#include "common/event/form_event_report.h" +#include "form_event_report.h" #include "common/util/form_util.h" #include "data_center/form_data_mgr.h" #include "fms_log_wrapper.h" diff --git a/services/src/form_mgr/form_mgr_adapter.cpp b/services/src/form_mgr/form_mgr_adapter.cpp index e05af83a7a..fa45706bbb 100644 --- a/services/src/form_mgr/form_mgr_adapter.cpp +++ b/services/src/form_mgr/form_mgr_adapter.cpp @@ -75,7 +75,7 @@ #include "os_account_manager.h" #include "parameters.h" #include "system_ability_definition.h" -#include "common/event/form_event_report.h" +#include "form_event_report.h" #include "common/util/form_report.h" #include "data_center/form_cust_config_mgr.h" #include "data_center/form_record/form_record_report.h" @@ -402,16 +402,6 @@ void FormMgrAdapter::CancelAddFormRequestTimeOutTask(const int64_t formId, const } } -AddFormResultErrorCode FormMgrAdapter::GetFormResultErrCode(const int64_t formId) -{ - std::lock_guard lock(formResultMutex_); - const auto iter = formIdMap_.find(formId); - if (iter != formIdMap_.end()) { - return iter->second; - } - return AddFormResultErrorCode::SUCCESS; -} - ErrCode FormMgrAdapter::CheckAddFormTaskTimeoutOrFailed(const int64_t formId, AddFormResultErrorCode &formStates) { std::lock_guard lock(formResultMutex_); @@ -1286,7 +1276,7 @@ ErrCode FormMgrAdapter::HandleCastTempForm(const int64_t formId, const FormRecor formId, record.bundleName, record.formName, - static_cast(AddFormFiledErrorType::CONNECT_FORM_PROVIDER_FAILED)); + static_cast(AddFormFailedErrorType::CONNECT_FORM_PROVIDER_FAILED)); return ERR_APPEXECFWK_FORM_BIND_PROVIDER_FAILED; } return ERR_OK; diff --git a/services/src/form_mgr/form_mgr_service.cpp b/services/src/form_mgr/form_mgr_service.cpp index 2786dae29a..8dec9cd21d 100644 --- a/services/src/form_mgr/form_mgr_service.cpp +++ b/services/src/form_mgr/form_mgr_service.cpp @@ -25,6 +25,8 @@ #include "common_event_manager.h" #include "common_event_support.h" #include "fms_log_wrapper.h" +#include "form_event_report.h" +#include "form_mgr_errors.h" #include "ams_mgr/form_ams_helper.h" #include "bms_mgr/form_bms_helper.h" #include "feature/bundle_forbidden/form_bundle_forbid_mgr.h" @@ -34,11 +36,9 @@ #include "data_center/form_data_proxy_mgr.h" #include "data_center/database/form_db_cache.h" #include "common/event/form_event_handler.h" -#include "common/event/form_event_report.h" #include "data_center/form_info/form_info_mgr.h" #include "form_mgr/form_mgr_adapter.h" #include "form_instance.h" -#include "form_mgr_errors.h" #include "common/util/form_serial_queue.h" #include "feature/form_share/form_share_mgr.h" #include "common/timer_mgr/form_timer_mgr.h" @@ -923,7 +923,7 @@ ErrCode FormMgrService::Init() * so it can't affect the TDD test program */ if (!Publish(DelayedSingleton::GetInstance().get())) { FormEventReport::SendFormFailedEvent(FormEventName::INIT_FMS_FAILED, HiSysEventType::FAULT, - static_cast(InitFmsFiledErrorType::PUBLISH_SER_FAILED)); + static_cast(InitFmsFailedErrorType::PUBLISH_SER_FAILED)); HILOG_ERROR("FormMgrService::Init Publish failed"); return ERR_INVALID_OPERATION; } diff --git a/services/src/form_provider/form_provider_mgr.cpp b/services/src/form_provider/form_provider_mgr.cpp index 701564c899..5f6e3a80cf 100644 --- a/services/src/form_provider/form_provider_mgr.cpp +++ b/services/src/form_provider/form_provider_mgr.cpp @@ -41,7 +41,7 @@ #include "form_mgr/form_mgr_queue.h" #include "form_mgr/form_mgr_queue.h" #include "common/util/form_task_common.h" -#include "common/event/form_event_report.h" +#include "form_event_report.h" namespace OHOS { namespace AppExecFwk { diff --git a/services/src/form_refresh/form_refresh_mgr.cpp b/services/src/form_refresh/form_refresh_mgr.cpp index ba7266b844..87ddc3d317 100644 --- a/services/src/form_refresh/form_refresh_mgr.cpp +++ b/services/src/form_refresh/form_refresh_mgr.cpp @@ -17,7 +17,7 @@ #include "fms_log_wrapper.h" #include "form_mgr_errors.h" -#include "common/event/form_event_report.h" +#include "form_event_report.h" #include "form_refresh/refresh_impl/form_host_refresh_impl.h" #include "form_refresh/refresh_impl/form_net_conn_refresh_impl.h" #include "form_refresh/refresh_impl/form_next_time_refresh_impl.h" diff --git a/services/src/form_render/form_render_mgr.cpp b/services/src/form_render/form_render_mgr.cpp index 339562c5d9..429c944464 100644 --- a/services/src/form_render/form_render_mgr.cpp +++ b/services/src/form_render/form_render_mgr.cpp @@ -25,7 +25,7 @@ #include "form_constants.h" #include "data_center/form_data_mgr.h" #include "data_center/form_info/form_info_mgr.h" -#include "common/event/form_event_report.h" +#include "form_event_report.h" #include "form_host_interface.h" #include "form_mgr_errors.h" #include "form_render/form_sandbox_render_mgr_inner.h" diff --git a/services/src/form_render/form_render_mgr_inner.cpp b/services/src/form_render/form_render_mgr_inner.cpp index 2f96c85f41..5318a526ee 100644 --- a/services/src/form_render/form_render_mgr_inner.cpp +++ b/services/src/form_render/form_render_mgr_inner.cpp @@ -24,7 +24,7 @@ #include "data_center/form_cache_mgr.h" #include "form_constants.h" #include "data_center/form_data_mgr.h" -#include "common/event/form_event_report.h" +#include "form_event_report.h" #include "form_host_interface.h" #include "form_mgr_errors.h" #include "form_render/form_render_task_mgr.h" @@ -101,7 +101,8 @@ ErrCode FormRenderMgrInner::RenderForm( formRecord.formId, formRecord.bundleName, formRecord.formName, - static_cast(AddFormFiledErrorType::CONNECT_FORM_RENDER_FAILED)); + static_cast(AddFormFailedErrorType::CONNECT_FORM_RENDER_FAILED), + errorCode); return ERR_APPEXECFWK_FORM_BIND_PROVIDER_FAILED; } return ERR_OK; diff --git a/services/src/form_render/form_render_task_mgr.cpp b/services/src/form_render/form_render_task_mgr.cpp index ce9ca80b8f..b293c3c143 100644 --- a/services/src/form_render/form_render_task_mgr.cpp +++ b/services/src/form_render/form_render_task_mgr.cpp @@ -20,7 +20,7 @@ #include "form_constants.h" #include "fms_log_wrapper.h" #include "form_render/form_render_queue.h" -#include "common/event/form_event_report.h" +#include "form_event_report.h" #include "data_center/form_data_mgr.h" #include "data_center/form_record/form_record.h" diff --git a/services/src/status_mgr_center/form_status_task_mgr.cpp b/services/src/status_mgr_center/form_status_task_mgr.cpp index 18fd22fe94..78d64f1ace 100644 --- a/services/src/status_mgr_center/form_status_task_mgr.cpp +++ b/services/src/status_mgr_center/form_status_task_mgr.cpp @@ -17,7 +17,7 @@ #include "form_render_interface.h" #include "fms_log_wrapper.h" #include "common/util/form_util.h" -#include "common/event/form_event_report.h" +#include "form_event_report.h" #include "status_mgr_center/form_status_queue.h" #include "status_mgr_center/form_status_mgr.h" #include "status_mgr_center/form_status.h" @@ -332,7 +332,7 @@ void FormStatusTaskMgr::RenderForm( formRecord.formId, HiSysEventPointType::TYPE_INVISIBLE_UPDATE); } if (error != ERR_OK) { - HILOG_ERROR("StopRenderingForm fail formId: %{public}" PRId64 " error: %{public}d", formRecord.formId, error); + HILOG_ERROR("RenderForm fail formId: %{public}" PRId64 " error: %{public}d", formRecord.formId, error); RemoveConnection(connectId); FormStatusMgr::GetInstance().CancelFormEventTimeout(formRecord.formId, eventId); FormStatusMgr::GetInstance().PostFormEvent(formRecord.formId, FormFsmEvent::RENDER_FORM_FAIL); diff --git a/test/unittest/fms_form_event_report_test/fms_form_event_report_test.cpp b/test/unittest/fms_form_event_report_test/fms_form_event_report_test.cpp index 1386ff0561..c7892c0cd7 100644 --- a/test/unittest/fms_form_event_report_test/fms_form_event_report_test.cpp +++ b/test/unittest/fms_form_event_report_test/fms_form_event_report_test.cpp @@ -17,7 +17,7 @@ #include "fms_log_wrapper.h" #define private public -#include "common/event/form_event_report.h" +#include "form_event_report.h" #undef private using namespace testing; diff --git a/test/unittest/fms_form_mgr_adapter_test/fms_form_mgr_adapter_test3.cpp b/test/unittest/fms_form_mgr_adapter_test/fms_form_mgr_adapter_test3.cpp index 0f1e3fbff0..58ee59ba3c 100644 --- a/test/unittest/fms_form_mgr_adapter_test/fms_form_mgr_adapter_test3.cpp +++ b/test/unittest/fms_form_mgr_adapter_test/fms_form_mgr_adapter_test3.cpp @@ -780,31 +780,6 @@ HWTEST_F(FmsFormMgrAdapterTest3, FormMgrAdapter_0274, TestSize.Level0) EXPECT_EQ(ret, 2293761); GTEST_LOG_(INFO) << "FormMgrAdapter_0278 end"; } - - /** - * @tc.name: FormMgrAdapter_0278_0 - * @tc.desc: test AllotForm function. - * @tc.type: FUNC - */ -HWTEST_F(FmsFormMgrAdapterTest3, FormMgrAdapter_0278_0, TestSize.Level1) -{ - GTEST_LOG_(INFO) << "FormMgrAdapter_0278_0 start"; - FormMgrAdapter formMgrAdapter; - int64_t formId = 0; - Want want; - want.SetParam(Constants::KEY_DIRECT_CALL_INAPP, true); - want.SetParam(Constants::PARAM_PAGE_ROUTER_SERVICE_CODE, Constants::PAGE_ROUTER_SERVICE_CODE_FORM_MANAGE); - formItemInfo_->SetProviderBundleName("providerBundle"); - formItemInfo_->SetHostBundleName("providerBundle"); - ErrCode ret = formMgrAdapter.AllotForm(formId, want, *callerToken_, *formJsInfo_, *formItemInfo_); - formMgrAdapter.formIdMap_.insert(std::make_pair(formId, AddFormResultErrorCode::UNKNOWN)); - formMgrAdapter.GetFormResultErrCode(formId); - formMgrAdapter.StartAbilityByFms(want); - formMgrAdapter.IsForegroundApp(); - formMgrAdapter.GetAppMgr(); - EXPECT_NE(ret, ERR_OK); - GTEST_LOG_(INFO) << "FormMgrAdapter_0278_0 end"; -} /** * @tc.name: FormMgrAdapter_0279 diff --git a/test/unittest/form_bundle_distributed_mgr_test/BUILD.gn b/test/unittest/form_bundle_distributed_mgr_test/BUILD.gn index 495281f91f..062b81d109 100644 --- a/test/unittest/form_bundle_distributed_mgr_test/BUILD.gn +++ b/test/unittest/form_bundle_distributed_mgr_test/BUILD.gn @@ -24,7 +24,7 @@ ohos_unittest("FormBundleDistributedTest") { configs = [ ":Form_Bundle_Distributed_config" ] sources = [ - "${form_fwk_path}/services/src/common/event/form_event_report.cpp", + "${form_fwk_path}/interfaces/inner_api/src/form_event_report.cpp", "${form_fwk_path}/services/src/common/util/form_util.cpp", "${form_fwk_path}/services/src/data_center/database/form_rdb_data_mgr.cpp", "${form_fwk_path}/services/src/feature/bundle_distributed/form_distributed_mgr.cpp", diff --git a/test/unittest/form_bundle_forbid_mgr_test/BUILD.gn b/test/unittest/form_bundle_forbid_mgr_test/BUILD.gn index 84bddb4e74..25abe751dc 100644 --- a/test/unittest/form_bundle_forbid_mgr_test/BUILD.gn +++ b/test/unittest/form_bundle_forbid_mgr_test/BUILD.gn @@ -24,7 +24,7 @@ ohos_unittest("FormBundleForbidTest") { configs = [ ":Form_Bundle_Forbid_config" ] sources = [ - "${form_fwk_path}/services/src/common/event/form_event_report.cpp", + "${form_fwk_path}/interfaces/inner_api/src/form_event_report.cpp", "${form_fwk_path}/services/src/common/util/form_util.cpp", "${form_fwk_path}/services/src/data_center/database/form_rdb_data_mgr.cpp", "${form_fwk_path}/services/src/feature/bundle_forbidden/form_bundle_forbid_mgr.cpp", diff --git a/test/unittest/form_report_test/BUILD.gn b/test/unittest/form_report_test/BUILD.gn index 834240ca18..55972cbf64 100644 --- a/test/unittest/form_report_test/BUILD.gn +++ b/test/unittest/form_report_test/BUILD.gn @@ -28,7 +28,7 @@ ohos_unittest("FormReportTest") { configs = [ ":form_report_test_config" ] sources = [ - "${form_fwk_path}/services/src/common/event/form_event_report.cpp", + "${form_fwk_path}/interfaces/inner_api/src/form_event_report.cpp", "${form_fwk_path}/services/src/common/util/form_report.cpp", "${form_fwk_path}/services/src/data_center/form_record/form_record_report.cpp", "form_report_test.cpp", diff --git a/test/unittest/form_report_test/form_report_test.cpp b/test/unittest/form_report_test/form_report_test.cpp index e8aaeaa59a..24c2aa8e65 100644 --- a/test/unittest/form_report_test/form_report_test.cpp +++ b/test/unittest/form_report_test/form_report_test.cpp @@ -15,7 +15,7 @@ #include #include "common/util/form_report.h" #include "want.h" -#include "common/event/form_event_report.h" +#include "form_event_report.h" using namespace testing::ext; using namespace OHOS; -- Gitee From 1ee8c6e5909a4d85d4615cd1e250093380f9d50d Mon Sep 17 00:00:00 2001 From: xiangcong Date: Thu, 11 Sep 2025 17:02:57 +0800 Subject: [PATCH 2/2] =?UTF-8?q?AddForm=E6=B5=81=E7=A8=8B=E7=BB=B4=E6=B5=8B?= =?UTF-8?q?=E5=A2=9E=E5=BC=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: xiangcong --- .../include/form_event_report_define.h | 18 +++++++------- interfaces/inner_api/include/form_file_util.h | 2 +- .../inner_api/src/form_event_report.cpp | 8 +++---- interfaces/inner_api/src/form_file_util.cpp | 5 ++-- interfaces/kits/native/src/form_mgr.cpp | 4 +++- .../fms_form_mgr_adapter_test3.cpp | 24 +++++++++++++++++++ 6 files changed, 44 insertions(+), 17 deletions(-) diff --git a/interfaces/inner_api/include/form_event_report_define.h b/interfaces/inner_api/include/form_event_report_define.h index c56314ef1d..3e0bdff7e5 100644 --- a/interfaces/inner_api/include/form_event_report_define.h +++ b/interfaces/inner_api/include/form_event_report_define.h @@ -33,7 +33,7 @@ struct FormEventInfo { bool distributedForm = false; }; -enum class CallDbFailedErrorType : int64_t { +enum class CallDbFailedErrorType : int32_t { LOAD_DATABASE_FAILED = 1, DATABASE_RESET_CONNECT_FAILED, DATABASE_SAVE_FORMID_FAILED, @@ -42,12 +42,12 @@ enum class CallDbFailedErrorType : int64_t { DATABASE_EXIT_ABNORMAL, }; -enum class InitFmsFailedErrorType : int64_t { +enum class InitFmsFailedErrorType : int32_t { LOAD_FORM_DB_FAILED = 1, PUBLISH_SER_FAILED, }; -enum class AddFormFailedErrorType : int64_t { +enum class AddFormFailedErrorType : int32_t { NUMBER_EXCEEDING_LIMIT = 1, CONNECT_FORM_RENDER_FAILED, CONNECT_FORM_PROVIDER_FAILED, @@ -63,7 +63,7 @@ enum class AddFormFailedErrorType : int64_t { SURFACE_NODE_REUSE_FAILED, }; -enum class UpdateFormErrorType : int64_t { +enum class UpdateFormErrorType : int32_t { REQUEST_FORM_FAILED = 1, UPDATE_FORM_FAILED, PROXY_UPDATE_FORM_FAILED, @@ -71,25 +71,25 @@ enum class UpdateFormErrorType : int64_t { FORM_VISIBLE_UPDATE_FAILED, }; -enum class DeleteFormErrorType : int64_t { +enum class DeleteFormErrorType : int32_t { DELETE_THEME_FORM_FAILED = 1, DELETE_TEMP_FORM_FAILED, DELETE_NORMAL_FORM_FAILED, }; -enum class RecycleRecoverFormErrorType : int64_t { +enum class RecycleRecoverFormErrorType : int32_t { RECYCLE_FORM_FAILED = 1, RECOVER_FORM_FAILED, RELEASE_FORM_FAILED, CHECK_FORM_STATUS_FAILED }; -enum class ConnectFormAbilityErrorType : int64_t { +enum class ConnectFormAbilityErrorType : int32_t { ACQUIRE_FORM_FAILED = 1, UPDATE_FORM_FAILED, }; -enum class ReloadFormErrorType : int64_t { +enum class ReloadFormErrorType : int32_t { RELOAD_FORM_FRS_DEAD = 1, RELOAD_FORM_IPC_ERROR, RELOAD_FORM_RELOAD_FORM_ERROR, @@ -160,7 +160,7 @@ enum class FormEventName { REQUEST_PUBLIC_FORM, CONNECT_FORM_ABILITY_FAILED, RELOAD_FORM_FAILED, - RENDER_FORM_FAILED, + FORM_NODE_ERROR, }; enum class RequestFormType : int8_t { diff --git a/interfaces/inner_api/include/form_file_util.h b/interfaces/inner_api/include/form_file_util.h index 8c38cc0cd3..8dbeecfda2 100644 --- a/interfaces/inner_api/include/form_file_util.h +++ b/interfaces/inner_api/include/form_file_util.h @@ -23,7 +23,7 @@ namespace AppExecFwk { class FormFileUtil { public: static void GetDirFiles(const std::string &path, std::vector &files); - static int64_t GetFilesSize(const std::vector &files, std::vector &filesSize); + static uint64_t GetFilesSize(const std::vector &files, std::vector &filesSize); }; } // namespace AppExecFwk } // namespace OHOS diff --git a/interfaces/inner_api/src/form_event_report.cpp b/interfaces/inner_api/src/form_event_report.cpp index 48ba20b9d4..2809d6dee7 100644 --- a/interfaces/inner_api/src/form_event_report.cpp +++ b/interfaces/inner_api/src/form_event_report.cpp @@ -86,8 +86,7 @@ const std::map EVENT_NAME_MAP = { std::map::value_type(FormEventName::INIT_FMS_FAILED, "INIT_FMS_FAILED"), std::map::value_type(FormEventName::CALLEN_DB_FAILED, "CALLEN_DB_FAILED"), std::map::value_type(FormEventName::ADD_FORM_FAILED, "ADD_FORM_FAILED"), - std::map::value_type( - FormEventName::FIRST_ADD_FORM_DURATION, "FIRST_ADD_FORM_DURATION"), + std::map::value_type(FormEventName::FIRST_ADD_FORM_DURATION, "FIRST_ADD_FORM_DURATION"), std::map::value_type( FormEventName::FIRST_UPDATE_FORM_DURATION, "FIRST_UPDATE_FORM_DURATION"), std::map::value_type( @@ -96,8 +95,7 @@ const std::map EVENT_NAME_MAP = { std::map::value_type( FormEventName::INVALID_PUBLISH_FORM_TO_HOST, "INVALID_PUBLISH_FORM_TO_HOST"), std::map::value_type(FormEventName::UNBIND_FORM_APP, "UNBIND_FORM_APP"), - std::map::value_type( - FormEventName::CONDITION_UPDATE_FORM, "CONDITION_UPDATE_FORM"), + std::map::value_type(FormEventName::CONDITION_UPDATE_FORM, "CONDITION_UPDATE_FORM"), std::map::value_type( FormEventName::LOAD_STAGE_FORM_CONFIG_INFO, "LOAD_STAGE_FORM_CONFIG_INFO"), std::map::value_type(FormEventName::DELETE_FORM_FAILED, "DELETE_FORM_FAILED"), @@ -107,6 +105,7 @@ const std::map EVENT_NAME_MAP = { std::map::value_type(FormEventName::REQUEST_PUBLIC_FORM, "REQUEST_PUBLIC_FORM"), std::map::value_type( FormEventName::CONNECT_FORM_ABILITY_FAILED, "CONNECT_FORM_ABILITY_FAILED"), + std::map::value_type(FormEventName::FORM_NODE_ERROR, "FORM_NODE_ERROR"), }; } @@ -434,6 +433,7 @@ void FormEventReport::SendFormFailedEvent(const FormEventName &eventName, int64_ case FormEventName::UPDATE_FORM_FAILED: case FormEventName::RECYCLE_RECOVER_FORM_FAILED: case FormEventName::CONNECT_FORM_ABILITY_FAILED: + case FormEventName::FORM_NODE_ERROR: HiSysEventWrite( HiSysEvent::Domain::FORM_MANAGER, FORM_ERROR, HiSysEventType::FAULT, diff --git a/interfaces/inner_api/src/form_file_util.cpp b/interfaces/inner_api/src/form_file_util.cpp index 2a79d1c500..a453c1f351 100644 --- a/interfaces/inner_api/src/form_file_util.cpp +++ b/interfaces/inner_api/src/form_file_util.cpp @@ -54,17 +54,18 @@ void FormFileUtil::GetDirFiles(const std::string &path, std::vector closedir(dir); } -int64_t FormFileUtil::GetFilesSize(const std::vector &files, std::vector &filesSize) +uint64_t FormFileUtil::GetFilesSize(const std::vector &files, std::vector &filesSize) { struct stat statbuf = {0}; uint64_t totalSize = 0; for (auto &file : files) { auto ret = stat(file.c_str(), &statbuf); + int err = errno; if (ret == 0) { filesSize.emplace_back(static_cast(statbuf.st_size)); totalSize += static_cast(statbuf.st_size); } else { - HILOG_WARN("failed to stat file, errno: %{public}d", errno); + HILOG_WARN("failed to stat file, errno: %{public}d", err); } } return totalSize; diff --git a/interfaces/kits/native/src/form_mgr.cpp b/interfaces/kits/native/src/form_mgr.cpp index 4cd0bb5489..d2f27b6489 100644 --- a/interfaces/kits/native/src/form_mgr.cpp +++ b/interfaces/kits/native/src/form_mgr.cpp @@ -90,7 +90,9 @@ int FormMgr::AddForm( } errCode = remoteProxy_->AddForm(formId, want, callerToken, formInfo); - if (errCode != ERR_OK) { + if (errCode != ERR_OK && errCode != ERR_APPEXECFWK_FORM_MAX_SYSTEM_FORMS && + errCode != ERR_APPEXECFWK_FORM_MAX_SYSTEM_TEMP_FORMS) { + // The fault of card quantity exceeds the limit is not reported here FormEventReport::SendFormFailedEvent(FormEventName::ADD_FORM_FAILED, formInfo.formId, formInfo.bundleName, diff --git a/test/unittest/fms_form_mgr_adapter_test/fms_form_mgr_adapter_test3.cpp b/test/unittest/fms_form_mgr_adapter_test/fms_form_mgr_adapter_test3.cpp index 58ee59ba3c..ec3d9f9d22 100644 --- a/test/unittest/fms_form_mgr_adapter_test/fms_form_mgr_adapter_test3.cpp +++ b/test/unittest/fms_form_mgr_adapter_test/fms_form_mgr_adapter_test3.cpp @@ -672,6 +672,30 @@ HWTEST_F(FmsFormMgrAdapterTest3, FormMgrAdapter_0274, TestSize.Level0) GTEST_LOG_(INFO) << "FormMgrAdapter_0274 end"; } + /** + * @tc.name: FormMgrAdapter_0278_0 + * @tc.desc: test AllotForm function. + * @tc.type: FUNC + */ +HWTEST_F(FmsFormMgrAdapterTest3, FormMgrAdapter_0278_0, TestSize.Level1) +{ + GTEST_LOG_(INFO) << "FormMgrAdapter_0278_0 start"; + FormMgrAdapter formMgrAdapter; + int64_t formId = 0; + Want want; + want.SetParam(Constants::KEY_DIRECT_CALL_INAPP, true); + want.SetParam(Constants::PARAM_PAGE_ROUTER_SERVICE_CODE, Constants::PAGE_ROUTER_SERVICE_CODE_FORM_MANAGE); + formItemInfo_->SetProviderBundleName("providerBundle"); + formItemInfo_->SetHostBundleName("providerBundle"); + ErrCode ret = formMgrAdapter.AllotForm(formId, want, *callerToken_, *formJsInfo_, *formItemInfo_); + formMgrAdapter.formIdMap_.insert(std::make_pair(formId, AddFormResultErrorCode::UNKNOWN)); + formMgrAdapter.StartAbilityByFms(want); + formMgrAdapter.IsForegroundApp(); + formMgrAdapter.GetAppMgr(); + EXPECT_NE(ret, ERR_OK); + GTEST_LOG_(INFO) << "FormMgrAdapter_0278_0 end"; +} + /** * @tc.name: FormMgrAdapter_0275 * @tc.desc: test AllotForm function. -- Gitee