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 CPU_LOAD, 39 PERFORMANCE_CONTROL, 40 RESOURCE_CONTROL 41 }; 42 43 class AppFreezeType { 44 public: 45 static constexpr char LIFECYCLE_HALF_TIMEOUT[] = "LIFECYCLE_HALF_TIMEOUT"; 46 static constexpr char LIFECYCLE_HALF_TIMEOUT_WARNING[] = "LIFECYCLE_HALF_TIMEOUT_WARNING"; 47 static constexpr char LIFECYCLE_TIMEOUT[] = "LIFECYCLE_TIMEOUT"; 48 static constexpr char LIFECYCLE_TIMEOUT_WARNING[] = "LIFECYCLE_TIMEOUT_WARNING"; 49 static constexpr char APP_LIFECYCLE_TIMEOUT[] = "APP_LIFECYCLE_TIMEOUT"; 50 static constexpr char THREAD_BLOCK_3S[] = "THREAD_BLOCK_3S"; 51 static constexpr char THREAD_BLOCK_6S[] = "THREAD_BLOCK_6S"; 52 static constexpr char APP_INPUT_BLOCK[] = "APP_INPUT_BLOCK"; 53 static constexpr char BUSSINESS_THREAD_BLOCK_3S[] = "BUSSINESS_THREAD_BLOCK_3S"; 54 static constexpr char BUSSINESS_THREAD_BLOCK_6S[] = "BUSSINESS_THREAD_BLOCK_6S"; 55 }; 56 /** 57 * @struct FaultData 58 * FaultData is used to save information about faultdata. 59 */ 60 struct FaultData : public Parcelable { 61 bool ReadFromParcel(Parcel &parcel); 62 bool ReadContent(Parcel &parcel); 63 virtual bool Marshalling(Parcel &parcel) const override; 64 bool WriteContent(Parcel &parcel) const; 65 static FaultData *Unmarshalling(Parcel &parcel); 66 // error object 67 ErrorObject errorObject; 68 FaultDataType faultType = FaultDataType::UNKNOWN; 69 std::string timeoutMarkers; 70 bool waitSaveState = false; 71 bool notifyApp = false; 72 bool forceExit = false; 73 bool needKillProcess = true; 74 uint32_t state = 0; 75 int32_t eventId = -1; 76 int32_t tid = -1; 77 uint32_t stuckTimeout = 0; 78 sptr<IRemoteObject> token = nullptr; 79 std::string appfreezeInfo; 80 std::string appRunningUniqueId; 81 std::string procStatm; 82 }; 83 84 /** 85 * @struct AppFaultDataBySA 86 * AppFaultDataBySA is used to save information about faultdata notified by SA. 87 */ 88 struct AppFaultDataBySA : public Parcelable { 89 bool ReadFromParcel(Parcel &parcel); 90 bool ReadContent(Parcel &parcel); 91 virtual bool Marshalling(Parcel &parcel) const override; 92 bool WriteErrorObject(Parcel &parcel) const; 93 bool WriteContent(Parcel &parcel) const; 94 static AppFaultDataBySA *Unmarshalling(Parcel &parcel); 95 bool waitSaveState = false; 96 bool notifyApp = false; 97 bool forceExit = false; 98 bool needKillProcess = true; 99 // error object 100 ErrorObject errorObject; 101 FaultDataType faultType = FaultDataType::UNKNOWN; 102 int32_t pid = -1; 103 uint32_t state = 0; 104 int32_t eventId = -1; 105 sptr<IRemoteObject> token = nullptr; 106 std::string timeoutMarkers; 107 std::string appfreezeInfo; 108 std::string appRunningUniqueId; 109 std::string procStatm; 110 }; 111 } // namespace AppExecFwk 112 } // namespace OHOS 113 #endif // OHOS_ABILITY_RUNTIME_FAULT_DATA_H