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 std::string GetBundleName() const; 37 std::string GetAbilityName() const; 38 bool IsNewApi() const; 39 uint32_t GetBgModeId() const; 40 int32_t GetUserId() const; 41 int32_t GetUid() const; 42 pid_t GetPid() const; 43 std::string GetNotificationLabel() const; 44 std::shared_ptr<AbilityRuntime::WantAgent::WantAgent> GetWantAgent() const; 45 std::string ParseToJsonStr(); 46 bool ParseFromJson(const nlohmann::json &value); 47 48 private: 49 std::string bundleName_ {""}; 50 std::string abilityName_ {""}; 51 std::shared_ptr<AbilityRuntime::WantAgent::WantAgent> wantAgent_ {nullptr}; 52 int32_t userId_ {0}; 53 int32_t uid_ {0}; 54 pid_t pid_ {0}; 55 uint32_t bgModeId_ {0}; 56 bool isNewApi_ {false}; 57 std::string notificationLabel_ {""}; 58 std::shared_ptr<WantAgentInfo> wantAgentInfo_ {nullptr}; 59 std::string appName_ {""}; 60 61 friend class BgContinuousTaskMgr; 62 friend class NotificationTools; 63 }; 64 } // namespace BackgroundTaskMgr 65 } // namespace OHOS 66 #endif // FOUNDATION_RESOURCESCHEDULE_BACKGROUND_TASK_MGR_SERVICES_CONTINUOUS_TASK_INCLUDE_CONTINUOUS_TASK_INFO_H