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 ACCESS_PROCESS_DATA_H 17 #define ACCESS_PROCESS_DATA_H 18 19 #include <sys/types.h> 20 21 #include "parcel.h" 22 #include "iremote_object.h" 23 24 namespace OHOS { 25 namespace Security { 26 namespace AccessToken { 27 enum class AppProcessState { 28 APP_STATE_CREATE = 0, 29 APP_STATE_READY, 30 APP_STATE_FOREGROUND, 31 APP_STATE_FOCUS, 32 APP_STATE_BACKGROUND, 33 APP_STATE_TERMINATED, 34 APP_STATE_END, 35 }; 36 37 enum class ProcessType { 38 NORMAL = 0, 39 EXTENSION, 40 RENDER, 41 }; 42 43 struct ProcessData : public Parcelable { 44 /** 45 * @brief read this Sequenceable object from a Parcel. 46 * 47 * @param inParcel Indicates the Parcel object into which the Sequenceable object has been marshaled. 48 * @return Returns true if read successed; returns false otherwise. 49 */ 50 bool ReadFromParcel(Parcel &parcel); 51 52 /** 53 * @brief Marshals this Sequenceable object into a Parcel. 54 * 55 * @param outParcel Indicates the Parcel object to which the Sequenceable object will be marshaled. 56 */ 57 virtual bool Marshalling(Parcel &parcel) const override; 58 59 /** 60 * @brief Unmarshals this Sequenceable object from a Parcel. 61 * 62 * @param inParcel Indicates the Parcel object into which the Sequenceable object has been marshaled. 63 */ 64 static ProcessData *Unmarshalling(Parcel &parcel); 65 66 std::string bundleName; 67 int32_t pid = 0; 68 int32_t uid = 0; // host uid 69 int32_t hostPid = 0; 70 int32_t gpuPid = 0; 71 int32_t renderUid = -1; 72 AppProcessState state; 73 bool isContinuousTask = false; 74 bool isKeepAlive = false; 75 bool isFocused = false; 76 int32_t requestProcCode = 0; 77 int32_t processChangeReason = 0; 78 std::string processName; 79 ProcessType processType = ProcessType::NORMAL; 80 int32_t extensionType = 0; 81 uint32_t accessTokenId = 0; 82 bool isTestMode = false; // Indicates whether the process is started by aa test 83 int32_t exitReason = 0; 84 std::string exitMsg = ""; 85 int32_t childUid = -1; 86 bool isPreload = false; 87 bool isPreloadModule = false; 88 }; 89 } // namespace AccessToken 90 } // namespace Security 91 } // namespace OHOS 92 #endif // ACCESS_PROCESS_DATA_H 93