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_REPORT_H 17 #define OHOS_FORM_FWK_FORM_REPORT_H 18 19 #include <queue> 20 #include <singleton.h> 21 #include <string> 22 #include <unordered_map> 23 #include <vector> 24 25 #include "form_render_mgr.h" 26 27 namespace OHOS { 28 namespace AppExecFwk { 29 struct FormStatistic { 30 public: 31 std::string bundleName_; 32 std::string moduleName_; 33 std::string abilityName_; 34 std::string formName_; 35 int32_t specificationId_; 36 int32_t dimensionId_; 37 int64_t formId_; 38 int64_t startAquireTime_; 39 int64_t endAquireTime_; 40 int64_t startBindTime_; 41 int64_t endBindTime_; 42 int64_t startGetTime_; 43 int64_t endGetTime_; 44 int64_t durationStartTime_; 45 int64_t durationEndTime_; 46 bool addFormFinish = false; 47 }; 48 49 class FormReport final : public DelayedRefSingleton<FormReport> { 50 DECLARE_DELAYED_REF_SINGLETON(FormReport) 51 public: 52 DISALLOW_COPY_AND_MOVE(FormReport); 53 public: 54 void SetFormRecordInfo(int64_t formId, const Want &want); 55 void SetStartAquireTime(int64_t formId, int64_t startTime); 56 void SetEndAquireTime(int64_t formId, int64_t endTime); 57 void GetEndAquireTime(int64_t formId, int64_t &endTime); 58 void SetStartBindTime(int64_t formId, int64_t startTime); 59 void SetEndBindTime(int64_t formId, int64_t endBindTime_); 60 void SetStartGetTime(int64_t formId, int64_t startTime); 61 void SetEndGetTime(int64_t formId, int64_t endTime); 62 void SetDurationStartTime(int64_t formId, int64_t startTime); 63 void SetDurationEndTime(int64_t formId, int64_t endTime); 64 void GetAddFormFinish(int64_t formId, bool &addFormFinish); 65 void SetAddFormFinish(int64_t formId); 66 void HandleAddFormStatistic(int64_t formId); 67 void HandleFirstUpdateStatistic(int64_t formId); 68 void InsertFormId(int64_t formId); 69 void RemoveFormId(int64_t formId); 70 std::unordered_map<int64_t, FormStatistic>& GetStatistic(); 71 72 private: 73 mutable std::mutex formReport_; 74 mutable std::mutex formIdsMutex_; 75 std::unordered_map<int64_t, FormStatistic> formStatisticMap_; 76 std::set<int64_t> FormIds; 77 }; 78 } // namespace AppExecFwk 79 } // namespace OHOS 80 #endif // OHOS_FORM_FWK_FORM_REPORT_H