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/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 TYPE_DISABLE_FORM_INTERCEPT, 38 }; 39 40 struct FormRecordReportInfo { 41 int32_t dailyRefreshTimes; 42 int32_t invisibleRefreshTimes; 43 int32_t hfRefreshBlockTimes; 44 int32_t invisibleRefreshBlockTimes; 45 int32_t highLoadRefreshBlockTimes; 46 int32_t activeRecoverRefreshTimes; 47 int32_t passiveRecoverRefreshTimes; 48 int32_t hfRecoverRefreshTimes; 49 int32_t offloadRecoverRefreshTimes; 50 int32_t disableFormRefreshTimes; 51 }; 52 53 class FormRecordReport final : public DelayedRefSingleton<FormRecordReport> { 54 DECLARE_DELAYED_REF_SINGLETON(FormRecordReport) 55 public: 56 DISALLOW_COPY_AND_MOVE(FormRecordReport); 57 public: 58 void ClearReportInfo(); 59 void IncreaseUpdateTimes(int64_t formId, HiSysEventPointType type); 60 std::map<int64_t, std::queue<FormRecordReportInfo>> &GetFormRecords(); 61 void SetFormRecordRecordInfo(int64_t formId, const Want &want); 62 void HandleFormRefreshCount(); 63 void AddNewDayReportInfo(); 64 private: 65 mutable std::mutex formRecordReportMutex_; 66 std::map<int64_t, std::queue<FormRecordReportInfo>> formRecordReportMap_; 67 }; 68 } // namespace AppExecFwk 69 } // namespace OHOS 70 #endif // OHOS_FORM_FWK_FORM_RECORD_REPORT_H