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 APP_FREEZE, 37 PERFORMANCE_CONTROL, 38 RESOURCE_CONTROL 39 }; 40 41 class AppFreezeType { 42 public: 43 static constexpr char LIFECYCLE_HALF_TIMEOUT[] = "LIFECYCLE_HALF_TIMEOUT"; 44 static constexpr char LIFECYCLE_TIMEOUT[] = "LIFECYCLE_TIMEOUT"; 45 static constexpr char APP_LIFECYCLE_TIMEOUT[] = "APP_LIFECYCLE_TIMEOUT"; 46 static constexpr char THREAD_BLOCK_3S[] = "THREAD_BLOCK_3S"; 47 static constexpr char THREAD_BLOCK_6S[] = "THREAD_BLOCK_6S"; 48 static constexpr char APP_INPUT_BLOCK[] = "APP_INPUT_BLOCK"; 49 }; 50 /** 51 * @struct FaultData 52 * FaultData is used to save information about faultdata. 53 */ 54 struct FaultData : public Parcelable { 55 bool ReadFromParcel(Parcel &parcel); 56 virtual bool Marshalling(Parcel &parcel) const override; 57 static FaultData *Unmarshalling(Parcel &parcel); 58 // error object 59 ErrorObject errorObject; 60 FaultDataType faultType = FaultDataType::UNKNOWN; 61 std::string timeoutMarkers; 62 bool waitSaveState = false; 63 bool notifyApp = false; 64 bool forceExit = false; 65 uint32_t state = 0; 66 sptr<IRemoteObject> token = nullptr; 67 }; 68 69 /** 70 * @struct AppFaultDataBySA 71 * AppFaultDataBySA is used to save information about faultdata notified by SA. 72 */ 73 struct AppFaultDataBySA : public Parcelable { 74 bool ReadFromParcel(Parcel &parcel); 75 virtual bool Marshalling(Parcel &parcel) const override; 76 static AppFaultDataBySA *Unmarshalling(Parcel &parcel); 77 // error object 78 ErrorObject errorObject; 79 FaultDataType faultType = FaultDataType::UNKNOWN; 80 int32_t pid = -1; 81 std::string timeoutMarkers; 82 bool waitSaveState = false; 83 bool notifyApp = false; 84 bool forceExit = false; 85 uint32_t state = 0; 86 sptr<IRemoteObject> token = nullptr; 87 }; 88 } // namespace AppExecFwk 89 } // namespace OHOS 90 #endif // OHOS_ABILITY_RUNTIME_FAULT_DATA_H