• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2024 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 #ifndef OHOS_ABILITY_RUNTIME_APP_MGR_EVENT_H
17 #define OHOS_ABILITY_RUNTIME_APP_MGR_EVENT_H
18 
19 #include "ability_info.h"
20 #include "app_running_record.h"
21 #ifdef SUPPORT_CHILD_PROCESS
22 #include "child_process_record.h"
23 #endif // SUPPORT_CHILD_PROCESS
24 #include "event_report.h"
25 
26 namespace OHOS {
27 namespace AppExecFwk {
28 enum class ProcessStartFailedReason {
29     UNKNOWN = 0,
30     APPSPAWN_FAILED = 1,
31     CREATE_START_MSG_FAILED = 2,
32     GET_SPAWN_CLIENT_FAILED = 3,
33     GENERATE_RENDER_UID_FAILED = 4,
34     CHECK_CHILD_FDS_FAILED = 5,
35 };
36 
37 class AppMgrEventUtil {
38 public:
39     static bool SendCreateAtomicServiceProcessEvent(const std::shared_ptr<AppRunningRecord> &callerAppRecord,
40         const std::shared_ptr<AppRunningRecord> &appRecord, const std::string &moduleName,
41         const std::string &abilityName);
42 
43     static bool SendProcessStartEvent(const std::shared_ptr<AppRunningRecord> &callerAppRecord,
44         const std::shared_ptr<AppRunningRecord> &appRecord, AAFwk::EventInfo &eventInfo);
45 
46     static bool SendProcessStartFailedEvent(std::shared_ptr<AppRunningRecord> callerAppRecord,
47         std::shared_ptr<AppRunningRecord> appRecord, AAFwk::EventInfo &eventInfo);
48 
49 #ifdef SUPPORT_CHILD_PROCESS
50     static bool SendChildProcessStartFailedEvent(std::shared_ptr<ChildProcessRecord> childRecord,
51         ProcessStartFailedReason reason, int32_t subReason);
52 #endif // SUPPORT_CHILD_PROCESS
53 
54     static bool SendRenderProcessStartFailedEvent(std::shared_ptr<RenderRecord> renderRecord,
55         ProcessStartFailedReason reason, int32_t subReason);
56 
57     static void SendReStartProcessEvent(AAFwk::EventInfo &eventInfo, int32_t appUid, int64_t restartTime);
58 
59 private:
60     static int32_t GetCallerPid(const std::shared_ptr<AppRunningRecord> &callerAppRecord);
61 
62     static void UpdateStartupType(const std::shared_ptr<AbilityInfo> &abilityInfo, int32_t &abilityType,
63         int32_t &extensionType);
64 
65     static void UpdateCallerInfo(AAFwk::EventInfo &eventInfo, std::shared_ptr<AppRunningRecord> callerAppRecord,
66         std::shared_ptr<AppRunningRecord> appRecord);
67 };
68 }
69 }
70 #endif  // OHOS_ABILITY_RUNTIME_APP_MGR_EVENT_H