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 virtual bool Marshalling(Parcel &parcel) const override; 60 static FaultData *Unmarshalling(Parcel &parcel); 61 // error object 62 ErrorObject errorObject; 63 FaultDataType faultType = FaultDataType::UNKNOWN; 64 std::string timeoutMarkers; 65 bool waitSaveState = false; 66 bool notifyApp = false; 67 bool forceExit = false; 68 uint32_t state = 0; 69 int32_t eventId = -1; 70 int32_t tid = 0; 71 sptr<IRemoteObject> token = nullptr; 72 }; 73 74 /** 75 * @struct AppFaultDataBySA 76 * AppFaultDataBySA is used to save information about faultdata notified by SA. 77 */ 78 struct AppFaultDataBySA : public Parcelable { 79 bool ReadFromParcel(Parcel &parcel); 80 virtual bool Marshalling(Parcel &parcel) const override; 81 static AppFaultDataBySA *Unmarshalling(Parcel &parcel); 82 // error object 83 ErrorObject errorObject; 84 FaultDataType faultType = FaultDataType::UNKNOWN; 85 int32_t pid = -1; 86 std::string timeoutMarkers; 87 bool waitSaveState = false; 88 bool notifyApp = false; 89 bool forceExit = false; 90 uint32_t state = 0; 91 int32_t eventId = -1; 92 sptr<IRemoteObject> token = nullptr; 93 }; 94 } // namespace AppExecFwk 95 } // namespace OHOS 96 #endif // OHOS_ABILITY_RUNTIME_FAULT_DATA_H