• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 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 #include "hisysevent_adapter.h"
16 
17 #include <string>
18 
19 #include "def.h"
20 #include "hisysevent.h"
21 #include "sam_log.h"
22 
23 namespace OHOS {
24 using namespace OHOS::HiviewDFX;
25 namespace {
26 const std::string DOMAIN_NAME = std::string(HiSysEvent::Domain::SAMGR);
27 const std::string ADD_SYSTEMABILITY_FAIL = "SAMGR_ADD_SYSTEMABILITY_FAIL";
28 const std::string CALLER_UID = "CALLER_UID";
29 const std::string SAID = "SAID";
30 const std::string COUNT = "COUNT";
31 const std::string FILE_NAME = "FILE_NAME";
32 const std::string GETSA__TAG = "SAMGR_GETSA_FREQUENCY";
33 }
34 
ReportAddSystemAbilityFailed(int32_t said,const std::string & filaName)35 void ReportAddSystemAbilityFailed(int32_t said, const std::string& filaName)
36 {
37     int ret = HiSysEvent::Write(DOMAIN_NAME,
38         ADD_SYSTEMABILITY_FAIL,
39         HiSysEvent::EventType::FAULT,
40         SAID, said,
41         FILE_NAME, filaName);
42     if (ret != 0) {
43         HILOGE("hisysevent report add system ability event failed! ret %{public}d.", ret);
44     }
45 }
46 
ReportGetSAFrequency(uint32_t callerUid,uint32_t said,int32_t count)47 void ReportGetSAFrequency(uint32_t callerUid, uint32_t said, int32_t count)
48 {
49     int ret = HiSysEvent::Write(DOMAIN_NAME,
50         GETSA__TAG,
51         HiSysEvent::EventType::STATISTIC,
52         CALLER_UID, callerUid,
53         SAID, said,
54         COUNT, count);
55     if (ret != 0) {
56         HILOGE("hisysevent report get sa frequency failed! ret %{public}d.", ret);
57     }
58 }
59 } // OHOS
60