1 /*
2  * Copyright (c) 2021 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_RUNNING_PROCESS_INFO_H
17 #define OHOS_ABILITY_RUNTIME_RUNNING_PROCESS_INFO_H
18 
19 #include <string>
20 #include <vector>
21 
22 #include "ability_info.h"
23 #include "app_mgr_constants.h"
24 #include "parcel.h"
25 
26 namespace OHOS {
27 namespace AppExecFwk {
28 enum class AppProcessState {
29     APP_STATE_CREATE = 0,
30     APP_STATE_READY,
31     APP_STATE_FOREGROUND,
32     APP_STATE_FOCUS,
33     APP_STATE_BACKGROUND,
34     APP_STATE_TERMINATED,
35     APP_STATE_END,
36     APP_STATE_CACHED = 100,
37 };
38 
39 enum class WeightReasonCode {
40     REASON_UNKNOWN = 0,
41     WEIGHT_FOREGROUND = 100,
42     WEIGHT_FOREGROUND_SERVICE = 125,
43     WEIGHT_VISIBLE = 200,
44     WEIGHT_PERCEPTIBLE = 230,
45     WEIGHT_SERVICE = 300,
46     WEIGHT_TOP_SLEEPING = 325,
47     WEIGHT_CANT_SAVE_STATE = 350,
48     WEIGHT_CACHED = 400,
49     WEIGHT_GONE = 1000,
50 };
51 
52 struct RunningProcessInfo : public Parcelable {
53     std::string processName_;
54     std::int32_t pid_;
55     std::int32_t uid_;
56     AppProcessState state_;
57     std::vector<std::string> bundleNames;
58     std::int64_t startTimeMillis_;
59     bool isContinuousTask = false;
60     bool isKeepAlive = false;
61     bool isFocused = false;
62     bool isTestProcess = false;
63     bool isAbilityForegrounding = false;
64     bool isTestMode = false;
65     bool isStrictMode = false;
66     std::int32_t bundleType = 0;
67     std::int32_t appCloneIndex = -1;
68 
69     bool ReadFromParcel(Parcel &parcel);
70     virtual bool Marshalling(Parcel &parcel) const override;
71     static RunningProcessInfo *Unmarshalling(Parcel &parcel);
72     ProcessType processType_ = ProcessType::NORMAL;
73     ExtensionAbilityType extensionType_ = ExtensionAbilityType::UNSPECIFIED;
74 };
75 }  // namespace AppExecFwk
76 }  // namespace OHOS
77 
78 #endif  // OHOS_ABILITY_RUNTIME_RUNNING_PROCESS_INFO_H
79