• 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 "iremote_object.h"
23 #include "parcel.h"
24 
25 namespace OHOS {
26 namespace AppExecFwk {
27 
28 /**
29  * @enum FaultDataType
30  * FaultDataType defines the type of FaultData.
31  */
32 enum class FaultDataType {
33     UNKNOWN = -1,
34     CPP_CRASH,
35     JS_ERROR,
36     CJ_ERROR,
37     APP_FREEZE,
38     PERFORMANCE_CONTROL,
39     RESOURCE_CONTROL
40 };
41 
42 class AppFreezeType {
43 public:
44     static constexpr char LIFECYCLE_HALF_TIMEOUT[] = "LIFECYCLE_HALF_TIMEOUT";
45     static constexpr char LIFECYCLE_TIMEOUT[] = "LIFECYCLE_TIMEOUT";
46     static constexpr char APP_LIFECYCLE_TIMEOUT[] = "APP_LIFECYCLE_TIMEOUT";
47     static constexpr char THREAD_BLOCK_3S[] = "THREAD_BLOCK_3S";
48     static constexpr char THREAD_BLOCK_6S[] = "THREAD_BLOCK_6S";
49     static constexpr char APP_INPUT_BLOCK[] = "APP_INPUT_BLOCK";
50     static constexpr char BUSSINESS_THREAD_BLOCK_3S[] = "BUSSINESS_THREAD_BLOCK_3S";
51     static constexpr char BUSSINESS_THREAD_BLOCK_6S[] = "BUSSINESS_THREAD_BLOCK_6S";
52 };
53 /**
54  * @struct FaultData
55  * FaultData is used to save information about faultdata.
56  */
57 struct FaultData : public Parcelable {
58     bool ReadFromParcel(Parcel &parcel);
59     bool WriteContent(Parcel &parcel) const;
60     virtual bool Marshalling(Parcel &parcel) const override;
61     static FaultData *Unmarshalling(Parcel &parcel);
62     // error object
63     ErrorObject errorObject;
64     FaultDataType faultType = FaultDataType::UNKNOWN;
65     std::string timeoutMarkers;
66     bool waitSaveState = false;
67     bool notifyApp = false;
68     bool forceExit = false;
69     uint32_t state = 0;
70     int32_t eventId = -1;
71     int32_t tid = -1;
72     uint32_t stuckTimeout = 0;
73     sptr<IRemoteObject> token = nullptr;
74 };
75 
76 /**
77  * @struct AppFaultDataBySA
78  * AppFaultDataBySA is used to save information about faultdata notified by SA.
79  */
80 struct AppFaultDataBySA : public Parcelable {
81     bool ReadFromParcel(Parcel &parcel);
82     bool waitSaveState = false;
83     bool notifyApp = false;
84     bool forceExit = false;
85     virtual bool Marshalling(Parcel &parcel) const override;
86     static AppFaultDataBySA *Unmarshalling(Parcel &parcel);
87     // error object
88     ErrorObject errorObject;
89     FaultDataType faultType = FaultDataType::UNKNOWN;
90     int32_t pid = -1;
91     uint32_t state = 0;
92     int32_t eventId = -1;
93     sptr<IRemoteObject> token = nullptr;
94     std::string timeoutMarkers;
95 };
96 }  // namespace AppExecFwk
97 }  // namespace OHOS
98 #endif  // OHOS_ABILITY_RUNTIME_FAULT_DATA_H