1 /* 2 * Copyright (c) 2024 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_RECORD_REPORT_H 17 #define OHOS_FORM_FWK_FORM_RECORD_REPORT_H 18 19 #include <singleton.h> 20 #include <string> 21 #include <mutex> 22 #include <map> 23 #include "form_render_mgr.h" 24 25 namespace OHOS { 26 namespace AppExecFwk { 27 enum HiSysEventPointType { 28 TYPE_DAILY_REFRESH, 29 TYPE_INVISIBLE_UPDATE, 30 TYPE_HIGH_FREQUENCY, 31 TYPE_INVISIBLE_INTERCEPT, 32 TYPE_HIGH_LOAD, 33 TYPE_ACTIVE_RECVOER_UPDATE, 34 TYPE_PASSIVE_RECOVER_UPDATE, 35 TYPE_HF_RECOVER_UPDATE, 36 TYPE_OFFLOAD_RECOVER_UPDATE 37 }; 38 39 struct FormRecordReportInfo { 40 std::string bundleName; 41 std::string moduleName; 42 std::string formName; 43 int32_t dailyRefreshTimes; 44 int32_t invisibleRefreshTimes; 45 int32_t hfRefreshBlockTimes; 46 int32_t invisibleRefreshBlockTimes; 47 int32_t highLoadRefreshBlockTimes; 48 int32_t activeRecoverRefreshTimes; 49 int32_t passiveRecoverRefreshTimes; 50 int32_t hfRecoverRefreshTimes; 51 int32_t offloadRecoverRefreshTimes; 52 }; 53 54 class FormRecordReport final : public DelayedRefSingleton<FormRecordReport> { 55 DECLARE_DELAYED_REF_SINGLETON(FormRecordReport) 56 public: 57 DISALLOW_COPY_AND_MOVE(FormRecordReport); 58 public: 59 void ClearReportInfo(); 60 void IncreaseUpdateTimes(int64_t formId, HiSysEventPointType type); 61 std::map<int64_t, FormRecordReportInfo> &GetFormRecords(); 62 void SetFormRecordRecordInfo(int64_t formId, const Want &want); 63 void HandleFormRefreshCount(); 64 private: 65 mutable std::mutex formRecordReportMutex_; 66 std::map<int64_t, FormRecordReportInfo> formRecordReportMap_; 67 }; 68 } // namespace AppExecFwk 69 } // namespace OHOS 70 #endif // OHOS_FORM_FWK_FORM_RECORD_REPORT_H