1eace7efcSopenharmony_ci/*
2eace7efcSopenharmony_ci * Copyright (c) 2024 Huawei Device Co., Ltd.
3eace7efcSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
4eace7efcSopenharmony_ci * you may not use this file except in compliance with the License.
5eace7efcSopenharmony_ci * You may obtain a copy of the License at
6eace7efcSopenharmony_ci *
7eace7efcSopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
8eace7efcSopenharmony_ci *
9eace7efcSopenharmony_ci * Unless required by applicable law or agreed to in writing, software
10eace7efcSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
11eace7efcSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12eace7efcSopenharmony_ci * See the License for the specific language governing permissions and
13eace7efcSopenharmony_ci * limitations under the License.
14eace7efcSopenharmony_ci */
15eace7efcSopenharmony_ci
16eace7efcSopenharmony_ci#ifndef OHOS_ABILITY_RUNTIME_APP_MGR_EVENT_H
17eace7efcSopenharmony_ci#define OHOS_ABILITY_RUNTIME_APP_MGR_EVENT_H
18eace7efcSopenharmony_ci
19eace7efcSopenharmony_ci#include "ability_info.h"
20eace7efcSopenharmony_ci#include "app_running_record.h"
21eace7efcSopenharmony_ci#include "child_process_record.h"
22eace7efcSopenharmony_ci#include "event_report.h"
23eace7efcSopenharmony_ci
24eace7efcSopenharmony_cinamespace OHOS {
25eace7efcSopenharmony_cinamespace AppExecFwk {
26eace7efcSopenharmony_cienum class ProcessStartFailedReason {
27eace7efcSopenharmony_ci    UNKNOWN = 0,
28eace7efcSopenharmony_ci    APPSPAWN_FAILED = 1,
29eace7efcSopenharmony_ci    CREATE_START_MSG_FAILED = 2,
30eace7efcSopenharmony_ci    GET_SPAWN_CLIENT_FAILED = 3,
31eace7efcSopenharmony_ci    GENERATE_RENDER_UID_FAILED = 4,
32eace7efcSopenharmony_ci    CHECK_CHILD_FDS_FAILED = 5,
33eace7efcSopenharmony_ci};
34eace7efcSopenharmony_ci
35eace7efcSopenharmony_ciclass AppMgrEventUtil {
36eace7efcSopenharmony_cipublic:
37eace7efcSopenharmony_ci    static bool SendCreateAtomicServiceProcessEvent(const std::shared_ptr<AppRunningRecord> &callerAppRecord,
38eace7efcSopenharmony_ci        const std::shared_ptr<AppRunningRecord> &appRecord, const std::string &moduleName,
39eace7efcSopenharmony_ci        const std::string &abilityName);
40eace7efcSopenharmony_ci
41eace7efcSopenharmony_ci    static bool SendProcessStartEvent(const std::shared_ptr<AppRunningRecord> &callerAppRecord,
42eace7efcSopenharmony_ci        const std::shared_ptr<AppRunningRecord> &appRecord, AAFwk::EventInfo &eventInfo);
43eace7efcSopenharmony_ci
44eace7efcSopenharmony_ci    static bool SendProcessStartFailedEvent(std::shared_ptr<AppRunningRecord> callerAppRecord,
45eace7efcSopenharmony_ci        std::shared_ptr<AppRunningRecord> appRecord, AAFwk::EventInfo &eventInfo);
46eace7efcSopenharmony_ci
47eace7efcSopenharmony_ci    static bool SendChildProcessStartFailedEvent(std::shared_ptr<ChildProcessRecord> childRecord,
48eace7efcSopenharmony_ci        ProcessStartFailedReason reason, int32_t subReason);
49eace7efcSopenharmony_ci
50eace7efcSopenharmony_ci    static bool SendRenderProcessStartFailedEvent(std::shared_ptr<RenderRecord> renderRecord,
51eace7efcSopenharmony_ci        ProcessStartFailedReason reason, int32_t subReason);
52eace7efcSopenharmony_ci
53eace7efcSopenharmony_ci    static void SendReStartProcessEvent(AAFwk::EventInfo &eventInfo, int32_t appUid, int64_t restartTime);
54eace7efcSopenharmony_ci
55eace7efcSopenharmony_ciprivate:
56eace7efcSopenharmony_ci    static int32_t GetCallerPid(const std::shared_ptr<AppRunningRecord> &callerAppRecord);
57eace7efcSopenharmony_ci
58eace7efcSopenharmony_ci    static void UpdateStartupType(const std::shared_ptr<AbilityInfo> &abilityInfo, int32_t &abilityType,
59eace7efcSopenharmony_ci        int32_t &extensionType);
60eace7efcSopenharmony_ci
61eace7efcSopenharmony_ci    static void UpdateCallerInfo(AAFwk::EventInfo &eventInfo, std::shared_ptr<AppRunningRecord> callerAppRecord,
62eace7efcSopenharmony_ci        std::shared_ptr<AppRunningRecord> appRecord);
63eace7efcSopenharmony_ci};
64eace7efcSopenharmony_ci}
65eace7efcSopenharmony_ci}
66eace7efcSopenharmony_ci#endif  // OHOS_ABILITY_RUNTIME_APP_MGR_EVENT_H