• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_ABILITY_RUNTIME_FAULT_DATA_H
17 #define OHOS_ABILITY_RUNTIME_FAULT_DATA_H
18 
19 #include <string>
20 
21 #include "ierror_observer.h"
22 #include "parcel.h"
23 
24 namespace OHOS {
25 namespace AppExecFwk {
26 
27 /**
28  * @enum FaultDataType
29  * FaultDataType defines the type of FaultData.
30  */
31 enum class FaultDataType {
32     UNKNOWN = -1,
33     CPP_CRASH,
34     JS_ERROR,
35     APP_FREEZE,
36     PERFORMANCE_CONTROL,
37     RESOURCE_CONTROL
38 };
39 
40 class AppFreezeType {
41 public:
42     static constexpr char LIFECYCLE_HALF_TIMEOUT[] = "LIFECYCLE_HALF_TIMEOUT";
43     static constexpr char LIFECYCLE_TIMEOUT[] = "LIFECYCLE_TIMEOUT";
44     static constexpr char APP_LIFECYCLE_TIMEOUT[] = "APP_LIFECYCLE_TIMEOUT";
45     static constexpr char THREAD_BLOCK_3S[] = "THREAD_BLOCK_3S";
46     static constexpr char THREAD_BLOCK_6S[] = "THREAD_BLOCK_6S";
47     static constexpr char APP_INPUT_BLOCK[] = "APP_INPUT_BLOCK";
48 };
49 /**
50  * @struct FaultData
51  * FaultData is used to save information about faultdata.
52  */
53 struct FaultData : public Parcelable {
54     bool ReadFromParcel(Parcel &parcel);
55     virtual bool Marshalling(Parcel &parcel) const override;
56     static FaultData *Unmarshalling(Parcel &parcel);
57     // error object
58     ErrorObject errorObject;
59     FaultDataType faultType = FaultDataType::UNKNOWN;
60     std::string timeoutMarkers;
61     bool waitSaveState = false;
62     bool notifyApp = false;
63     bool forceExit = false;
64 };
65 
66 /**
67  * @struct AppFaultDataBySA
68  * AppFaultDataBySA is used to save information about faultdata notified by SA.
69  */
70 struct AppFaultDataBySA : public Parcelable {
71     bool ReadFromParcel(Parcel &parcel);
72     virtual bool Marshalling(Parcel &parcel) const override;
73     static AppFaultDataBySA *Unmarshalling(Parcel &parcel);
74     // error object
75     ErrorObject errorObject;
76     FaultDataType faultType = FaultDataType::UNKNOWN;
77     int32_t pid = -1;
78     std::string timeoutMarkers;
79     bool waitSaveState = false;
80     bool notifyApp = false;
81     bool forceExit = false;
82 };
83 }  // namespace AppExecFwk
84 }  // namespace OHOS
85 #endif  // OHOS_ABILITY_RUNTIME_FAULT_DATA_H