• 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 
16 #include "event_reporter.h"
17 
18 #include <hisysevent.h>
19 
20 using namespace OHOS::HiviewDFX;
21 namespace OHOS {
22 namespace system {
23 constexpr char KEY_PROCESS_EXIT[] = "PROCESS_EXIT";
24 constexpr char KEY_NAME[] = "PROCESS_NAME";
25 constexpr char KEY_PID[] = "PID";
26 constexpr char KEY_UID[] = "UID";
27 constexpr char KEY_STATUS[] = "STATUS";
28 constexpr int32_t MAX_NAME_LENGTH = 1024;
29 
ReportProcessExitInfo(const char * processName,int pid,int uid,int status)30 void ReportProcessExitInfo(const char* processName, int pid, int uid, int status)
31 {
32     std::string pname = "Unknown";
33     if ((processName != NULL) && (strlen(processName) <= MAX_NAME_LENGTH)) {
34         pname = std::string(processName, strlen(processName));
35     }
36 
37     HiSysEvent::Write(HiSysEvent::Domain::STARTUP, KEY_PROCESS_EXIT, HiSysEvent::EventType::BEHAVIOR,
38         KEY_NAME, pname, KEY_PID, pid, KEY_UID, uid, KEY_STATUS, status);
39 }
40 }  // namespace system
41 }  // namespace OHOS
42 
ReportProcessExitInfo(const char * processName,int pid,int uid,int status)43 void ReportProcessExitInfo(const char* processName, int pid, int uid, int status)
44 {
45     OHOS::system::ReportProcessExitInfo(processName, pid, uid, status);
46 }
47