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_LONGTIME_TASK_EVENT_DATA_H 17 #define FOUNDATION_RESOURCESCHEDULE_BACKGROUND_TASK_MGR_INTERFACES_INNERKITS_INCLUDE_LONGTIME_TASK_EVENT_DATA_H 18 19 #include <cstdint> 20 #include <sys/types.h> 21 #include <string> 22 #include "parcel.h" 23 24 namespace OHOS { 25 namespace BackgroundTaskMgr { 26 class ContinuousTaskCallbackInfo : public Parcelable { 27 public: 28 ContinuousTaskCallbackInfo(); 29 ContinuousTaskCallbackInfo(uint32_t typeId, int32_t creatorUid, 30 pid_t creatorPid, std::string abilityName, bool isFromWebview = false, bool isBatchApi = false, 31 const std::vector<uint32_t> &typeIds = {}, int32_t abilityId = -1, uint64_t tokenId = 0) 32 : typeId_(typeId), creatorUid_(creatorUid), creatorPid_(creatorPid), abilityName_(abilityName), 33 isFromWebview_(isFromWebview), isBatchApi_(isBatchApi), typeIds_(typeIds), abilityId_(abilityId), 34 tokenId_(tokenId) {} 35 36 /** 37 * @brief Get the id of type. 38 * 39 * @return The id of type. 40 */ 41 uint32_t GetTypeId() const; 42 43 /** 44 * @brief Get the uid of notification creator. 45 * 46 * @return The uid of the notification creator. 47 */ 48 int32_t GetCreatorUid() const; 49 50 /** 51 * @brief Get the pid of notification creator. 52 * 53 * @return The pid of the notification creator. 54 */ 55 pid_t GetCreatorPid() const; 56 57 /** 58 * @brief Get the name of ability. 59 * 60 * @return The name of ability. 61 */ 62 std::string GetAbilityName() const; 63 64 /** 65 * @brief Judge whether this ability come from webview. 66 * 67 * @return True if success, else false. 68 */ 69 bool IsFromWebview() const; 70 71 /** 72 * @brief Get the id of types. 73 * 74 * @return The id of types. 75 */ 76 const std::vector<uint32_t>& GetTypeIds() const; 77 78 /** 79 * @brief Get the batch api flag. 80 * 81 * @return The flag of batch api. 82 */ 83 bool IsBatchApi() const; 84 85 /** 86 * @brief Get the id of ability. 87 * 88 * @return The id of ability. 89 */ 90 int32_t GetAbilityId() const; 91 92 /** 93 * @brief Get the tokenId. 94 * 95 * @return The tokenId. 96 */ 97 uint64_t GetTokenId() const; 98 99 /** 100 * @brief Marshals a purpose into a parcel. 101 * 102 * @param parcel Indicates the parcel object for marshalling. 103 * @return True if success, else false. 104 */ 105 bool Marshalling(Parcel &parcel) const override; 106 static ContinuousTaskCallbackInfo *Unmarshalling(Parcel &parcel); 107 108 private: 109 bool ReadFromParcel(Parcel &parcel); 110 111 private: 112 uint32_t typeId_ {0}; 113 int32_t creatorUid_ {0}; 114 pid_t creatorPid_ {0}; 115 std::string abilityName_ {""}; 116 bool isFromWebview_ {false}; 117 bool isBatchApi_ {false}; 118 std::vector<uint32_t> typeIds_ {}; 119 int32_t abilityId_ {-1}; 120 uint64_t tokenId_ {0}; 121 }; 122 } // namespace BackgroundTaskMgr 123 } // namespace OHOS 124 #endif // FOUNDATION_RESOURCESCHEDULE_BACKGROUND_TASK_MGR_INTERFACES_INNERKITS_INCLUDE_LONGTIME_TASK_EVENT_DATA_H