• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #ifndef POST_EVENT_UTILS_H
16 #define POST_EVENT_UTILS_H
17 #include <map>
18 #include <string>
19 #include <variant>
20 
21 #include "singleton.h"
22 namespace OHOS {
23 namespace Media {
24 #define COMPILE_HIDDEN __attribute__ ((visibility ("hidden")))
25 const std::string KEY_OPT_TYPE = "optType";
26 
27 const std::string KEY_ERR_FILE = "errFile";
28 const std::string KEY_ERR_LINE = "errLine";
29 const std::string KEY_ERR_CODE = "errCode";
30 const std::string KEY_OPT_FILE = "optFile";
31 
32 const std::string KEY_GNUMS = "gnums";
33 const std::string KEY_ANUMS = "anums";
34 
35 const std::string KEY_PRE_VERSION = "preVersion";
36 const std::string KEY_AFTER_VERSION = "afterVersion";
37 
38 const std::string KEY_COUNT = "count";
39 
40 const std::string KEY_TIME_INTERVAL = "TIME_INTERVAL";
41 
42 const std::string KEY_CALLING_PACKAGE = "CALLING_PACKAGE";
43 const std::string KEY_HIGH_QUALITY_COUNT = "HIGH_QUALITY_COUNT";
44 const std::string KEY_BALANCE_QUALITY_COUNT = "BALANCE_QUALITY_COUNT";
45 const std::string KEY_EMERGENCY_QUALITY_COUNT = "EMERGENCY_QUALITY_COUNT";
46 
47 const std::string KEY_THIRD_PART_COUNT = "THIRD_PART_COUNT";
48 const std::string KEY_AUTO_COUNT = "AUTO_COUNT";
49 
50 const std::string KEY_PHOTO_ID = "PHOTO_ID";
51 const std::string KEY_TOTAL_TIME_COST = "TOTAL_TIME_COST";
52 
53 const std::string KEY_RESULT = "RESULT";
54 
55 enum OptType {
56     CREATE = 0,
57     THUMB,
58     SCAN,
59     QUERY,
60 };
61 
62 enum ErrType {
63     DEFAULT_ERR = 0,
64     FILE_OPT_ERR,
65     DB_OPT_ERR,
66     DB_UPGRADE_ERR,
67 };
68 
69 enum StatType {
70     DEFAULT_STAT = 0,
71     THUMBNAIL_STAT,
72     DB_UPGRADE_STAT,
73     SYNC_STAT,
74     AGING_STAT,
75     MSC_FIRST_VISIT_STAT,
76     MSC_REQUEST_POLICY_STAT,
77     MSC_TRIGGER_RATIO_STAT,
78     MSC_TOTAL_TIME_COST_STAT,
79     MSC_RESULT_STAT,
80 };
81 using VariantMap = std::map<std::string, std::variant<int32_t, int64_t, std::string>>;
82 
83 class PostEventUtils : public Singleton<PostEventUtils> {
84 public:
85     void PostErrorProcess(const uint32_t &errType, const VariantMap &error);
86     void PostStatProcess(const uint32_t &statType, const VariantMap &stat);
87 
88 private:
89     COMPILE_HIDDEN std::string GetOptType(const uint32_t &optType);
90     COMPILE_HIDDEN void PostFileOptError(const VariantMap &errMap);
91     COMPILE_HIDDEN void PostDbOptError(const VariantMap &errMap);
92     COMPILE_HIDDEN void PostDbUpgradeError(const VariantMap &errMap);
93     COMPILE_HIDDEN void PostThumbnailStat(const VariantMap &stat);
94     COMPILE_HIDDEN void PostDbUpgradeStat(const VariantMap &stat);
95     COMPILE_HIDDEN void PostSyncStat();
96     COMPILE_HIDDEN void PostAgingStat(const VariantMap &stat);
97     COMPILE_HIDDEN void PostMscFirstVisitStat(const VariantMap &stat);
98     COMPILE_HIDDEN void PostMscRequestPolicyStat(const VariantMap &stat);
99     COMPILE_HIDDEN void PostMscTriggerRatioStat(const VariantMap &stat);
100     COMPILE_HIDDEN void PostMscTotalTimeCostStat(const VariantMap &stat);
101     COMPILE_HIDDEN void PostMscResultStat(const VariantMap &stat);
102 
103     COMPILE_HIDDEN int GetIntValue(const std::string &key, const VariantMap &map);
104     COMPILE_HIDDEN int64_t GetInt64Value(const std::string &key, const VariantMap &map);
105     COMPILE_HIDDEN std::string GetStringValue(const std::string &key, const VariantMap &map);
106 
107     COMPILE_HIDDEN uint32_t thumbnailTimes_ = 0;
108     COMPILE_HIDDEN uint32_t dbUpgradeTimes_ = 0;
109     COMPILE_HIDDEN uint32_t syncTimes_ = 0;
110     COMPILE_HIDDEN uint32_t recycleTimes_ = 0;
111 };
112 } // namespace Media
113 } // namespace OHOS
114 #endif