• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021-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 #ifndef OHOS_ABILITY_RUNTIME_LIFECYCLE_STATE_INFO_H
17 #define OHOS_ABILITY_RUNTIME_LIFECYCLE_STATE_INFO_H
18 
19 #include <string>
20 
21 #include "ability_start_setting.h"
22 #include "caller_info.h"
23 #include "launch_param.h"
24 #include "parcel.h"
25 
26 namespace OHOS {
27 namespace AAFwk {
28 /**
29  * @enum AbilityLifeCycleState
30  * AbilityLifeCycleState defines the life cycle state of ability.
31  */
32 enum AbilityLifeCycleState {
33     ABILITY_STATE_INITIAL = 0,
34     ABILITY_STATE_INACTIVE,
35     ABILITY_STATE_ACTIVE,
36     ABILITY_STATE_BACKGROUND,
37     ABILITY_STATE_STARTED_NEW,
38     ABILITY_STATE_FOREGROUND_NEW,
39     ABILITY_STATE_BACKGROUND_NEW,
40     ABILITY_STATE_STOPED_NEW,
41     ABILITY_STATE_FOREGROUND_FAILED,
42     ABILITY_STATE_BACKGROUND_FAILED,
43     ABILITY_STATE_INVALID_WINDOW_MODE,
44     ABILITY_STATE_WINDOW_FREEZED,
45     ABILITY_STATE_DO_NOTHING,
46 };
47 
48 enum class ErrorLifecycleState {
49     ABILITY_STATE_LOAD_TIMEOUT = 0,
50     ABILITY_STATE_FOREGROUND_TIMEOUT,
51     ABILITY_STATE_DIED,
52 };
53 
54 /**
55  * @struct LifeCycleStateInfo
56  * LifeCycleStateInfo is used to save information about ability life cycle state.
57  */
58 struct LifeCycleStateInfo : public Parcelable {
59     AbilityLifeCycleState state = AbilityLifeCycleState::ABILITY_STATE_INITIAL;
60     bool isNewWant = false;
61     int missionId = -1;
62     CallerInfo caller;
63     std::shared_ptr<AbilityStartSetting> setting = nullptr;
64     LaunchParam launchParam;
65     uint32_t sceneFlag = 0;
66     uint32_t sceneFlagBak = 0;
67 
68     bool ReadFromParcel(Parcel &parcel);
69     virtual bool Marshalling(Parcel &parcel) const override;
70     static LifeCycleStateInfo *Unmarshalling(Parcel &parcel);
71 };
72 }  // namespace AAFwk
73 }  // namespace OHOS
74 #endif  // OHOS_ABILITY_RUNTIME_LIFECYCLE_STATE_INFO_H
75