1 /* 2 * Copyright (c) 2021-2022 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef OHOS_FORM_FWK_FORM_DUMP_MGR_H 17 #define OHOS_FORM_FWK_FORM_DUMP_MGR_H 18 19 #include <singleton.h> 20 21 #include "form_constants.h" 22 #include "form_db_info.h" 23 #include "form_host_record.h" 24 #include "form_info_mgr.h" 25 #include "running_form_info.h" 26 27 namespace OHOS { 28 namespace AppExecFwk { 29 /** 30 * @class FormDumpMgr 31 * Form dump mgr. 32 */ 33 class FormDumpMgr final : public DelayedRefSingleton<FormDumpMgr> { 34 DECLARE_DELAYED_REF_SINGLETON(FormDumpMgr) 35 public: 36 DISALLOW_COPY_AND_MOVE(FormDumpMgr); 37 38 /** 39 * @brief Dump all of form storage infos. 40 * @param storageInfos Form storage infos 41 * @param formInfos Form storage dump info. 42 */ 43 void DumpStorageFormInfos(const std::vector<FormDBInfo> &storageInfos, std::string &formInfos) const; 44 /** 45 * @brief Dump all of temporary form infos. 46 * @param formRecordInfos Form record infos. 47 * @param formInfos Form dump infos. 48 */ 49 void DumpTemporaryFormInfos(const std::vector<FormRecord> &formRecordInfos, std::string &formInfos) const; 50 /** 51 * @brief Dump form infos of all bundles, this is static info. 52 * @param bundleFormInfos Form infos from bundle. 53 * @param formInfos Form dump infos. 54 */ 55 void DumpStaticBundleFormInfos(const std::vector<FormInfo> &bundleFormInfos, std::string &formInfos) const; 56 57 /** 58 * @brief Dump has form visible with bundleInfo. 59 * @param tokenId *Unique identifaication of application. 60 * @param bundleName Bundle name. 61 * @param userId User ID. 62 * @param instIndex Index of application instance. 63 * @param formInfos Form dump infos. 64 */ 65 void DumpHasFormVisible( 66 const uint32_t tokenId, 67 const std::string &bundleName, 68 const int32_t userId, 69 const int32_t instIndex, 70 std::string &formInfos) const; 71 72 /** 73 * @brief Dump form infos. 74 * @param formRecordInfos Form record infos. 75 * @param formInfos Form dump infos. 76 */ 77 void DumpFormInfos(const std::vector<FormRecord> &formRecordInfos, std::string &formInfos) const; 78 /** 79 * @brief Dump form infos. 80 * @param formRecordInfo Form Host record info. 81 * @param formInfo Form dump info. 82 */ 83 void DumpFormHostInfo(const FormHostRecord &formHostRecord, std::string &formInfo) const; 84 /** 85 * @brief Dump form infos. 86 * @param formRecordInfo Form record info. 87 * @param formInfo Form dump info. 88 */ 89 void DumpFormInfo(const FormRecord &formRecordInfo, std::string &formInfo) const; 90 91 /** 92 * @brief Dump form subscribe info. 93 * @param subscribedKeys Form subscribe key info. 94 * @param count Form received data count 95 * @param formInfo Form dump info. 96 */ 97 void DumpFormSubscribeInfo( 98 const std::vector<std::string> &subscribedKeys, const int64_t &count, std::string &formInfo) const; 99 100 /** 101 * @brief Dump running form information. 102 * @param runningFormInfos All the running form information 103 * @param infosResult The dump info of all the running form info. 104 */ 105 void DumpRunningFormInfos(const std::vector<RunningFormInfo> &runningFormInfos, 106 std::string &infosResult) const; 107 108 private: 109 void AppendBundleFormInfo(const FormRecord &formRecordInfo, std::string &formInfo) const; 110 void AppendRecycleStatus(const RecycleStatus recycleStatus, std::string &formInfo) const; 111 void AppendRunningFormInfos(const std::string &formHostBundleName, 112 const std::vector<RunningFormInfo> &runningFormInfos, 113 std::string &infosResult) const; 114 void AppendFormLocation(Constants::FormLocation formLocation, std::string &infosResult) const; 115 void AppendBundleType(const BundleType formBundleType, std::string &formInfo) const; 116 }; 117 } // namespace AppExecFwk 118 } // namespace OHOS 119 120 #endif // OHOS_FORM_FWK_FORM_DUMP_MGR_H 121