1 /*
2 * Copyright (c) 2022-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 "inputmethod_sysevent.h"
17
18 #include "hisysevent.h"
19
20 namespace OHOS {
21 namespace MiscServices {
22 namespace {
23 using HiSysEventNameSpace = OHOS::HiviewDFX::HiSysEvent;
24 const std::string DOMAIN_STR = std::string(HiSysEventNameSpace::Domain::INPUTMETHOD);
25 } // namespace
26
FaultReporter(int32_t userId,std::string bundname,int32_t errCode)27 void FaultReporter(int32_t userId, std::string bundname, int32_t errCode)
28 {
29 int ret = HiSysEventNameSpace::Write(DOMAIN_STR, "SERVICE_INIT_FAILED", HiSysEventNameSpace::EventType::FAULT,
30 "USER_ID", userId, "COMPONENT_ID", bundname, "ERROR_CODE", errCode);
31 if (ret != 0) {
32 IMSA_HILOGE("hisysevent FaultReporter failed! ret %{public}d,errCode %{public}d", ret, errCode);
33 }
34 }
35
CreateComponentFailed(int32_t userId,int32_t errCode)36 void CreateComponentFailed(int32_t userId, int32_t errCode)
37 {
38 int ret = HiSysEventNameSpace::Write(DOMAIN_STR, "CREATE_COMPONENT_FAILED", HiSysEventNameSpace::EventType::FAULT,
39 "USER_ID", userId, "ERROR_CODE", errCode);
40 if (ret != 0) {
41 IMSA_HILOGE("hisysevent CreateComponentFailed failed! ret %{public}d,errCode %{public}d", ret, errCode);
42 }
43 }
44
BehaviourReporter(std::string ActiveName,const std::string & inputmethodName)45 void BehaviourReporter(std::string ActiveName, const std::string &inputmethodName)
46 {
47 int ret = HiSysEventNameSpace::Write(DOMAIN_STR, "INPUTMETHOD_USING", HiSysEventNameSpace::EventType::BEHAVIOR,
48 "ACTIVE_NAME", ActiveName, "INPUTMETHOD_NAME", inputmethodName);
49 if (ret != 0) {
50 IMSA_HILOGE("hisysevent BehaviourReporter failed! ret %{public}d", ret);
51 }
52 }
53 } // namespace MiscServices
54 } // namespace OHOS