1 /* 2 * Copyright (c) 2021 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_APP_TASK_INFO_H 17 #define OHOS_ABILITY_RUNTIME_APP_TASK_INFO_H 18 19 #include <sys/types.h> 20 #include <string> 21 22 #include "parcel.h" 23 24 namespace OHOS { 25 namespace AppExecFwk { 26 class AppTaskInfo : public Parcelable { 27 public: 28 /** 29 * @brief Obtains the app name. 30 * 31 * @return Returns the app name. 32 */ 33 const std::string &GetName() const; 34 35 /** 36 * @brief Obtains the process name. 37 * 38 * @return Returns the process name. 39 */ 40 const std::string &GetProcessName() const; 41 42 /** 43 * @brief Obtains the app pid. 44 * 45 * @return Returns the app pid. 46 */ 47 pid_t GetPid() const; 48 49 /** 50 * @brief Obtains the app record id. 51 * 52 * @return Returns app record id. 53 */ 54 int32_t GetRecordId() const; 55 56 /** 57 * @brief Setting name for app. 58 * 59 * @param appName, the app name. 60 */ 61 void SetName(const std::string &appName); 62 63 /** 64 * @brief Setting name for process. 65 * 66 * @param int32_t, the process name. 67 */ 68 void SetProcessName(const std::string &processName); 69 70 /** 71 * @brief Setting pid for app. 72 * 73 * @param int32_t, the app pid. 74 */ 75 void SetPid(const pid_t pid); 76 77 /** 78 * @brief Setting id for app record. 79 * 80 * @param int32_t, the app record id. 81 */ 82 void SetRecordId(const int32_t appRecordId); 83 84 /** 85 * @brief read this Sequenceable object from a Parcel. 86 * 87 * @param inParcel Indicates the Parcel object into which the Sequenceable object has been marshaled. 88 * @return Returns true if read succeeded; returns false otherwise. 89 */ 90 bool ReadFromParcel(Parcel &parcel); 91 92 /** 93 * @brief Marshals this Sequenceable object into a Parcel. 94 * 95 * @param outParcel Indicates the Parcel object to which the Sequenceable object will be marshaled. 96 */ 97 virtual bool Marshalling(Parcel &parcel) const override; 98 99 /** 100 * @brief Unmarshals this Sequenceable object from a Parcel. 101 * 102 * @param inParcel Indicates the Parcel object into which the Sequenceable object has been marshaled. 103 */ 104 static AppTaskInfo *Unmarshalling(Parcel &parcel); 105 106 private: 107 std::string appName_; 108 std::string processName_; 109 pid_t pid_ = 0; 110 int32_t appRecordId_ = 0; 111 }; 112 } // namespace AppExecFwk 113 } // namespace OHOS 114 #endif // OHOS_ABILITY_RUNTIME_APP_TASK_INFO_H 115