1/*
2 * Copyright (c) 2023 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_APP_STATE_OBSERVER_H
17#define OHOS_APP_STATE_OBSERVER_H
18
19#include "application_state_observer_stub.h"
20
21namespace OHOS {
22namespace DistributedSchedule {
23class AppStateObserver : public AppExecFwk::ApplicationStateObserverStub {
24public:
25    /**
26     * Application foreground state changed callback.
27     *
28     * @param appStateData Application Process data.
29     */
30    void OnForegroundApplicationChanged(const AppExecFwk::AppStateData& appStateData) override;
31
32    /**
33     * Will be called when the ability state changes.
34     *
35     * @param abilityStateData Ability state data.
36     */
37    void OnAbilityStateChanged(const AppExecFwk::AbilityStateData& abilityStateData) override;
38
39    /**
40     * Will be called when the extension state changes.
41     *
42     * @param abilityStateData Extension state data.
43     */
44    void OnExtensionStateChanged(const AppExecFwk::AbilityStateData& abilityStateData) override;
45
46    /**
47     * Will be called when the process start.
48     *
49     * @param processData Process data.
50     */
51    void OnProcessCreated(const AppExecFwk::ProcessData& processData) override;
52
53    /**
54     * Will be called when the process die.
55     *
56     * @param processData Process data.
57     */
58    void OnProcessDied(const AppExecFwk::ProcessData& processData) override;
59private:
60    std::mutex countLock_;
61    std::map<sptr<IRemoteObject>, int32_t> connectAbilityMap_;
62};
63} // namespace DistributedSchedule
64} // namespace OHOS
65#endif // OHOS_APP_STATE_OBSERVER_H
66