1 /*
2 * Copyright (c) 2021-2022 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 #include "base/ressched/ressched_report.h"
17
18 namespace OHOS::Ace {
19 namespace {
20 const uint32_t RES_TYPE_CLICK_RECOGNIZE = 9;
21 const uint32_t RES_TYPE_PUSH_PAGE = 10;
22 const uint32_t RES_TYPE_SLIDE = 11;
23 }
24
GetInstance()25 ResSchedReport& ResSchedReport::GetInstance()
26 {
27 static ResSchedReport instance;
28 return instance;
29 }
30
ResSchedDataReport(const char * name)31 void ResSchedReport::ResSchedDataReport(const char* name)
32 {
33 std::unordered_map<std::string, std::string> payload;
34 payload["name"] = name;
35 if (reportDataFunc_ == nullptr) {
36 reportDataFunc_ = LoadReportDataFunc();
37 }
38 if (reportDataFunc_ != nullptr) {
39 if (strcmp(name, "click") == 0) {
40 reportDataFunc_(RES_TYPE_CLICK_RECOGNIZE, 0, payload);
41 } else if (strcmp(name, "push_page") == 0) {
42 reportDataFunc_(RES_TYPE_PUSH_PAGE, 0, payload);
43 } else if (strcmp(name, "slide_on") == 0) {
44 reportDataFunc_(RES_TYPE_SLIDE, 1, payload);
45 } else if (strcmp(name, "slide_off") == 0) {
46 reportDataFunc_(RES_TYPE_SLIDE, 0, payload);
47 }
48 }
49 }
50 } // namespace OHOS::Ace