• 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     ABILITY_STATE_PERMISSION_UPDATE,
53     ABILITY_STATE_LOW_MEMORY_KILL,
54     ABILITY_STATE_SKIP_KILL_IN_STARTUP,
55 };
56 
57 /**
58  * @struct LifeCycleStateInfo
59  * LifeCycleStateInfo is used to save information about ability life cycle state.
60  */
61 struct LifeCycleStateInfo : public Parcelable {
62     bool isNewWant = false;
63     int missionId = -1;
64     uint32_t sceneFlag = 0;
65     uint32_t sceneFlagBak = 0;
66     AbilityLifeCycleState state = AbilityLifeCycleState::ABILITY_STATE_INITIAL;
67     std::shared_ptr<AbilityStartSetting> setting = nullptr;
68     LaunchParam launchParam;
69     CallerInfo caller;
70 
71     bool ReadFromParcel(Parcel &parcel);
72     virtual bool Marshalling(Parcel &parcel) const override;
73     static LifeCycleStateInfo *Unmarshalling(Parcel &parcel);
74 };
75 }  // namespace AAFwk
76 }  // namespace OHOS
77 #endif  // OHOS_ABILITY_RUNTIME_LIFECYCLE_STATE_INFO_H
78