1 /* 2 * Copyright (c) 2023 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_EVENT_REPORT_H 17 #define OHOS_FORM_FWK_FORM_EVENT_REPORT_H 18 19 #include <string> 20 21 #include "hisysevent.h" 22 #include "want.h" 23 24 using HiSysEventType = OHOS::HiviewDFX::HiSysEvent::EventType; 25 using HiSysEvent = OHOS::HiviewDFX::HiSysEvent; 26 using Want = OHOS::AAFwk::Want; 27 28 namespace OHOS { 29 namespace AppExecFwk { 30 struct FormEventInfo { 31 int64_t formId = -1; 32 std::string bundleName; 33 std::string moduleName; 34 std::string abilityName; 35 std::string hostBundleName = ""; 36 int32_t formAppPid = -1; 37 int64_t timeStamp = 0; 38 }; 39 40 enum class CallDbFiledErrorType : int64_t { 41 LOAD_DATABASE_FAILED = 1, 42 DATABASE_RESET_CONNECT_FAILED, 43 DATABASE_SAVE_FORMID_FAILED, 44 DATABASE_DELETE_FORMID_FAILED, 45 DATABASE_QUERY_FORMID_FAILED, 46 DATABASE_EXIT_ABNORMA, 47 }; 48 49 enum class InitFmsFiledErrorType : int64_t { 50 LOAD_FORM_DB_FAILED = 1, 51 PUBLISH_SER_FAILED, 52 }; 53 54 enum class AddFormFiledErrorType : int64_t { 55 NUMBER_EXCEEDING_LIMIT = 1, 56 }; 57 58 struct NewFormEventInfo { 59 int64_t formId = -1; 60 std::string bundleName; 61 std::string moduleName; 62 std::string abilityName; 63 std::string hostBundleName = ""; 64 int64_t sessionId; 65 int64_t bindDuration; 66 int64_t getDuration; 67 std::string formName; 68 int64_t formDimension; 69 int64_t acquireDuration; 70 int64_t duration; 71 int64_t durationType; 72 int32_t dailyRefreshTimes; 73 int32_t invisibleRefreshTimes; 74 int32_t hfRefreshBlockTimes; 75 int32_t invisibleRefreshBlockTimes; 76 int32_t highLoadRefreshBlockTimes; 77 int32_t activeRecoverRefreshTimes; 78 int32_t passiveRecoverRefreshTimes; 79 int32_t hfRecoverRefreshTimes; 80 int32_t offloadRecoverRefreshTimes; 81 std::string clientBundleName = ""; 82 std::string formBundleName = ""; 83 }; 84 85 enum class FormEventName { 86 // form behavior event 87 ADD_FORM, 88 REQUEST_FORM, 89 DELETE_FORM, 90 CASTTEMP_FORM, 91 ACQUIREFORMSTATE_FORM, 92 MESSAGE_EVENT_FORM, 93 ROUTE_EVENT_FORM, 94 BACKGROUND_EVENT_FORM, 95 RELEASE_FORM, 96 DELETE_INVALID_FORM, 97 SET_NEXT_REFRESH_TIME_FORM, 98 FORM_RENDER_BLOCK, 99 INIT_FMS_FAILED, 100 CALLEN_DB_FAILED, 101 ADD_FORM_FAILED, 102 FIRST_ADD_FORM_DURATION, 103 FIRST_UPDATE_FORM_DURATION, 104 UPDATE_FORM_REFRESH_TIMES, 105 PROXY_UPDATE_FORM, 106 INVALID_PUBLISH_FORM_TO_HOST, 107 LAUNCH_FORM_APP, 108 UNBIND_FORM_APP, 109 }; 110 111 class FormEventReport { 112 public: 113 static void SendFormEvent(const FormEventName &eventName, HiSysEventType type, const FormEventInfo &eventInfo); 114 static void SendSecondFormEvent(const FormEventName &eventName, HiSysEventType type, 115 const FormEventInfo &eventInfo); 116 static void SendThirdFormEvent(const FormEventName &eventName, HiSysEventType type, 117 const FormEventInfo &eventInfo); 118 static void SendFormFailedEvent(const FormEventName &eventName, HiSysEventType type, int64_t errorType); 119 static void SendFirstAddFormEvent(const FormEventName &eventName, HiSysEventType type, 120 const NewFormEventInfo &eventInfo); 121 static void SendFirstUpdateFormEvent(const FormEventName &eventName, HiSysEventType type, 122 const NewFormEventInfo &eventInfo); 123 static void SendFourthFormEvent(const FormEventName &eventName, HiSysEventType type, 124 const NewFormEventInfo &eventInfo, const Want &want); 125 static void SendFormRefreshCountEvent(const FormEventName &eventName, HiSysEventType type, 126 const NewFormEventInfo &eventInfo); 127 private: 128 static std::string ConvertEventName(const FormEventName &eventName); 129 }; 130 } // namespace AppExecFwk 131 } // namespace OHOS 132 #endif // OHOS_FORM_FWK_FORM_EVENT_REPORT_H 133