1 /* 2 * Copyright (c) 2022 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 FOUNDATION_RESOURCESCHEDULE_BACKGROUND_TASK_MGR_INTERFACES_INNERKITS_INCLUDE_TRANSIENT_TASK_APP_INFO_H 17 #define FOUNDATION_RESOURCESCHEDULE_BACKGROUND_TASK_MGR_INTERFACES_INNERKITS_INCLUDE_TRANSIENT_TASK_APP_INFO_H 18 19 #include <string> 20 21 #include <message_parcel.h> 22 23 namespace OHOS { 24 namespace BackgroundTaskMgr { 25 constexpr int INVAILD_PID = -1; 26 constexpr int INVAILD_UID = -1; 27 28 class TransientTaskAppInfo final { 29 public: TransientTaskAppInfo(std::string packageName,int32_t uid,int32_t pid)30 TransientTaskAppInfo(std::string packageName, int32_t uid, int32_t pid) 31 : packageName_(packageName), uid_(uid), pid_(pid) {} 32 TransientTaskAppInfo() = default; 33 ~TransientTaskAppInfo() = default; 34 35 bool Marshalling(MessageParcel& out) const; 36 static std::shared_ptr<TransientTaskAppInfo> Unmarshalling(MessageParcel& in); 37 GetPackageName()38 inline std::string& GetPackageName() 39 { 40 return packageName_; 41 } 42 GetUid()43 inline int32_t GetUid() 44 { 45 return uid_; 46 } 47 GetPid()48 inline int32_t GetPid() 49 { 50 return pid_; 51 } 52 53 private: 54 bool ReadFromParcel(MessageParcel& in); 55 56 std::string packageName_; 57 int32_t uid_; 58 int32_t pid_; 59 }; 60 } // namespace BackgroundTaskMgr 61 } // namespace OHOS 62 #endif // FOUNDATION_RESOURCESCHEDULE_BACKGROUND_TASK_MGR_INTERFACES_INNERKITS_INCLUDE_TRANSIENT_TASK_APP_INFO_H