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_SERVICES_CONTINUOUS_TASK_INCLUDE_CONTINUOUS_TASK_INFO_H 17 #define FOUNDATION_RESOURCESCHEDULE_BACKGROUND_TASK_MGR_SERVICES_CONTINUOUS_TASK_INCLUDE_CONTINUOUS_TASK_INFO_H 18 19 #include "iremote_object.h" 20 #include "nlohmann/json.hpp" 21 #include "parcel.h" 22 #include "want_agent.h" 23 24 namespace OHOS { 25 namespace BackgroundTaskMgr { 26 extern const char *g_continuousTaskModeName[10]; 27 28 struct WantAgentInfo { 29 std::string bundleName_ {""}; 30 std::string abilityName_ {""}; 31 }; 32 33 class ContinuousTaskRecord { 34 public: 35 ContinuousTaskRecord() = default; 36 ContinuousTaskRecord(const std::string &bundleName, const std::string &abilityName, 37 int32_t uid, int32_t pid, uint32_t bgModeId); 38 std::string GetBundleName() const; 39 std::string GetAbilityName() const; 40 bool IsNewApi() const; 41 bool IsFromWebview() const; 42 uint32_t GetBgModeId() const; 43 int32_t GetUserId() const; 44 int32_t GetUid() const; 45 pid_t GetPid() const; 46 std::string GetNotificationLabel() const; 47 std::shared_ptr<AbilityRuntime::WantAgent::WantAgent> GetWantAgent() const; 48 std::string ParseToJsonStr(); 49 bool ParseFromJson(const nlohmann::json &value); 50 51 private: 52 std::string bundleName_ {""}; 53 std::string abilityName_ {""}; 54 std::shared_ptr<AbilityRuntime::WantAgent::WantAgent> wantAgent_ {nullptr}; 55 int32_t userId_ {0}; 56 int32_t uid_ {0}; 57 pid_t pid_ {0}; 58 uint32_t bgModeId_ {0}; 59 bool isNewApi_ {false}; 60 bool isFromWebview_ {false}; 61 std::string notificationLabel_ {""}; 62 std::shared_ptr<WantAgentInfo> wantAgentInfo_ {nullptr}; 63 std::string appName_ {""}; 64 uint64_t fullTokenId_ {0}; 65 66 friend class BgContinuousTaskMgr; 67 friend class NotificationTools; 68 }; 69 } // namespace BackgroundTaskMgr 70 } // namespace OHOS 71 #endif // FOUNDATION_RESOURCESCHEDULE_BACKGROUND_TASK_MGR_SERVICES_CONTINUOUS_TASK_INCLUDE_CONTINUOUS_TASK_INFO_H