1 /* 2 * Copyright (c) 2025 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_CONTINUOUS_TASK_INFO_H 17 #define FOUNDATION_RESOURCESCHEDULE_BACKGROUND_TASK_MGR_INTERFACES_INNERKITS_INCLUDE_CONTINUOUS_TASK_INFO_H 18 19 #include <string> 20 #include <memory> 21 22 #include "parcel.h" 23 24 namespace OHOS { 25 namespace BackgroundTaskMgr { 26 class ContinuousTaskInfo : public Parcelable { 27 public: 28 ContinuousTaskInfo() = default; ContinuousTaskInfo(std::string abilityName,int32_t uid,int32_t pid,bool isFromWebView,std::vector<uint32_t> backgroundModes,std::vector<uint32_t> backgroundSubModes,int32_t notificationId,int32_t continuousTaskId,int32_t abilityId,std::string wantAgentBundleName,std::string wantAgentAbilityName)29 ContinuousTaskInfo(std::string abilityName, int32_t uid, int32_t pid, bool isFromWebView, 30 std::vector<uint32_t> backgroundModes, std::vector<uint32_t> backgroundSubModes, int32_t notificationId, 31 int32_t continuousTaskId, int32_t abilityId, std::string wantAgentBundleName, std::string wantAgentAbilityName) 32 : abilityName_(abilityName), uid_(uid), pid_(pid), isFromWebView_(isFromWebView), 33 backgroundModes_(backgroundModes), backgroundSubModes_(backgroundSubModes), notificationId_(notificationId), 34 continuousTaskId_(continuousTaskId), abilityId_(abilityId), wantAgentBundleName_(wantAgentBundleName), 35 wantAgentAbilityName_(wantAgentAbilityName) {} 36 37 /** 38 * @brief Unmarshals a purpose from a Parcel. 39 * 40 * @param parcel Indicates the parcel object for unmarshalling. 41 * @return The info continuous task. 42 */ 43 static ContinuousTaskInfo* Unmarshalling(Parcel& in); 44 45 /** 46 * @brief Marshals a purpose into a parcel. 47 * 48 * @param parcel Indicates the parcel object for marshalling. 49 * @return True if success, else false. 50 */ 51 bool Marshalling(Parcel& out) const override; 52 53 /** 54 * @brief Get the ability name. 55 * 56 * @return the ability name. 57 */ 58 std::string GetAbilityName() const; 59 60 /** 61 * @brief Get the want agent bundle name. 62 * 63 * @return the want agent bundle name. 64 */ 65 std::string GetWantAgentBundleName() const; 66 67 /** 68 * @brief Get the want agent ability name. 69 * 70 * @return the want agent ability name. 71 */ 72 std::string GetWantAgentAbilityName() const; 73 /** 74 * @brief Get the uid. 75 * 76 * @return the uid. 77 */ 78 int32_t GetUid() const; 79 80 /** 81 * @brief Get the pid. 82 * 83 * @return the pid. 84 */ 85 int32_t GetPid() const; 86 87 /** 88 * @brief Get the notificationId. 89 * 90 * @return the notification Id. 91 */ 92 int32_t GetNotificationId() const; 93 94 /** 95 * @brief Get the continuousTaskId. 96 * 97 * @return the continuousTask Id. 98 */ 99 int32_t GetContinuousTaskId() const; 100 101 /** 102 * @brief Get the abilityId. 103 * 104 * @return the ability Id. 105 */ 106 int32_t GetAbilityId() const; 107 108 /** 109 * @brief Get the backgroundModes. 110 * 111 * @return the background modes. 112 */ 113 std::vector<uint32_t> GetBackgroundModes() const; 114 /** 115 * @brief Get the backgroundSubModes_. 116 * 117 * @return the background sub modes. 118 */ 119 std::vector<uint32_t> GetBackgroundSubModes() const; 120 121 /** 122 * @brief Get the isFromWebView. 123 * 124 * @return the is from webview. 125 */ 126 bool IsFromWebView() const; 127 128 /** 129 * @brief Get suspendState. 130 * 131 * @return the suspend state. 132 */ 133 bool GetSuspendState() const; 134 135 std::string ToString(const std::vector<uint32_t> &modes) const; 136 137 private: 138 bool ReadFromParcel(Parcel& in); 139 140 std::string abilityName_ {""}; 141 int32_t uid_ {0}; 142 int32_t pid_ {0}; 143 bool isFromWebView_ {false}; 144 std::vector<uint32_t> backgroundModes_ {}; 145 std::vector<uint32_t> backgroundSubModes_ {}; 146 int32_t notificationId_ {-1}; 147 int32_t continuousTaskId_ {-1}; 148 int32_t abilityId_ {-1}; 149 std::string wantAgentBundleName_ {""}; 150 std::string wantAgentAbilityName_ {""}; 151 bool suspendState_ {false}; 152 }; 153 } // namespace BackgroundTaskMgr 154 } // namespace OHOS 155 #endif // FOUNDATION_RESOURCESCHEDULE_BACKGROUND_TASK_MGR_INTERFACES_INNERKITS_INCLUDE_CONTINUOUS_TASK_INFO_H