1686862fbSopenharmony_ci/*
2686862fbSopenharmony_ci * Copyright (c) 2023 Huawei Device Co., Ltd.
3686862fbSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
4686862fbSopenharmony_ci * you may not use this file except in compliance with the License.
5686862fbSopenharmony_ci * You may obtain a copy of the License at
6686862fbSopenharmony_ci *
7686862fbSopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
8686862fbSopenharmony_ci *
9686862fbSopenharmony_ci * Unless required by applicable law or agreed to in writing, software
10686862fbSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
11686862fbSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12686862fbSopenharmony_ci * See the License for the specific language governing permissions and
13686862fbSopenharmony_ci * limitations under the License.
14686862fbSopenharmony_ci */
15686862fbSopenharmony_ci
16686862fbSopenharmony_ci#ifndef OHOS_APP_STATE_OBSERVER_H
17686862fbSopenharmony_ci#define OHOS_APP_STATE_OBSERVER_H
18686862fbSopenharmony_ci
19686862fbSopenharmony_ci#include "application_state_observer_stub.h"
20686862fbSopenharmony_ci
21686862fbSopenharmony_cinamespace OHOS {
22686862fbSopenharmony_cinamespace DistributedSchedule {
23686862fbSopenharmony_ciclass AppStateObserver : public AppExecFwk::ApplicationStateObserverStub {
24686862fbSopenharmony_cipublic:
25686862fbSopenharmony_ci    /**
26686862fbSopenharmony_ci     * Application foreground state changed callback.
27686862fbSopenharmony_ci     *
28686862fbSopenharmony_ci     * @param appStateData Application Process data.
29686862fbSopenharmony_ci     */
30686862fbSopenharmony_ci    void OnForegroundApplicationChanged(const AppExecFwk::AppStateData& appStateData) override;
31686862fbSopenharmony_ci
32686862fbSopenharmony_ci    /**
33686862fbSopenharmony_ci     * Will be called when the ability state changes.
34686862fbSopenharmony_ci     *
35686862fbSopenharmony_ci     * @param abilityStateData Ability state data.
36686862fbSopenharmony_ci     */
37686862fbSopenharmony_ci    void OnAbilityStateChanged(const AppExecFwk::AbilityStateData& abilityStateData) override;
38686862fbSopenharmony_ci
39686862fbSopenharmony_ci    /**
40686862fbSopenharmony_ci     * Will be called when the extension state changes.
41686862fbSopenharmony_ci     *
42686862fbSopenharmony_ci     * @param abilityStateData Extension state data.
43686862fbSopenharmony_ci     */
44686862fbSopenharmony_ci    void OnExtensionStateChanged(const AppExecFwk::AbilityStateData& abilityStateData) override;
45686862fbSopenharmony_ci
46686862fbSopenharmony_ci    /**
47686862fbSopenharmony_ci     * Will be called when the process start.
48686862fbSopenharmony_ci     *
49686862fbSopenharmony_ci     * @param processData Process data.
50686862fbSopenharmony_ci     */
51686862fbSopenharmony_ci    void OnProcessCreated(const AppExecFwk::ProcessData& processData) override;
52686862fbSopenharmony_ci
53686862fbSopenharmony_ci    /**
54686862fbSopenharmony_ci     * Will be called when the process die.
55686862fbSopenharmony_ci     *
56686862fbSopenharmony_ci     * @param processData Process data.
57686862fbSopenharmony_ci     */
58686862fbSopenharmony_ci    void OnProcessDied(const AppExecFwk::ProcessData& processData) override;
59686862fbSopenharmony_ciprivate:
60686862fbSopenharmony_ci    std::mutex countLock_;
61686862fbSopenharmony_ci    std::map<sptr<IRemoteObject>, int32_t> connectAbilityMap_;
62686862fbSopenharmony_ci};
63686862fbSopenharmony_ci} // namespace DistributedSchedule
64686862fbSopenharmony_ci} // namespace OHOS
65686862fbSopenharmony_ci#endif // OHOS_APP_STATE_OBSERVER_H
66