/* * Copyright (c) 2022 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef FOUNDATION_RESOURCESCHEDULE_BACKGROUND_TASK_MGR_FRAMEWORKS_INCLUDE_BACKGROUND_TASK_MGR_PROXY_H #define FOUNDATION_RESOURCESCHEDULE_BACKGROUND_TASK_MGR_FRAMEWORKS_INCLUDE_BACKGROUND_TASK_MGR_PROXY_H #include #include #include #include "efficiency_resource_info.h" namespace OHOS { namespace BackgroundTaskMgr { class BackgroundTaskMgrProxy final : public IRemoteProxy { public: explicit BackgroundTaskMgrProxy(const sptr& impl); ~BackgroundTaskMgrProxy() override; DISALLOW_COPY_AND_MOVE(BackgroundTaskMgrProxy); /** * @brief Request delay suspend for background task. * * @param reason Reason of requesting delay suspend. * @param callback Called back to notify the application. * @param delayInfo Info of background which request delay suspend. * @return ERR_OK if success, else fail. */ ErrCode RequestSuspendDelay(const std::u16string& reason, const sptr& callback, std::shared_ptr &delayInfo) override; /** * @brief Cancel delay suspend of background task. * * @param requestId Id of the requested background task. * @return ERR_OK if success, else fail. */ ErrCode CancelSuspendDelay(int32_t requestId) override; /** * @brief Get the time remaining before the background tasks enter the suspended state. * * @param requestId Id of the requested background task. * @param delayTime Remaining time. * @return ERR_OK if success, else fail. */ ErrCode GetRemainingDelayTime(int32_t requestId, int32_t &delayTime) override; /** * @brief Request service to keep running background. * * @param taskParam Request params. * @return ERR_OK if success, else fail. */ ErrCode StartBackgroundRunning(const sptr &taskParam) override; /** * @brief Request service to update running background. * * @param taskParam Request params. * @return ERR_OK if success, else fail. */ ErrCode UpdateBackgroundRunning(const sptr &taskParam) override; /** * @brief Request service to keep or stop running background for inner ability. * * @param taskParam Request params. * @return ERR_OK if success, else fail. */ ErrCode RequestBackgroundRunningForInner(const sptr &taskParam) override; /** * @brief Request service to stop running background. * * @param abilityName Ability name of the requester ability. * @param abilityToken Ability token to mark an unique running ability instance. * @param abilityId Ability identity. * @return ERR_OK if success, else fail. */ ErrCode StopBackgroundRunning(const std::string &abilityName, const sptr &abilityToken, int32_t abilityId) override; /** * @brief Subscribes background task event. * * @param subscriber Subscriber token. * @return ERR_OK if success, else fail. */ ErrCode SubscribeBackgroundTask(const sptr& subscriber) override; /** * @brief Unsubscribes background task event. * * @param subscriber Subscriber token. * @return ERR_OK if success, else fail. */ ErrCode UnsubscribeBackgroundTask(const sptr& subscriber) override; /** * @brief Get transient task applications. * @param list transient task apps. * @return Returns ERR_OK if success, else failure. */ ErrCode GetTransientTaskApps(std::vector> &list) override; /** * @brief Pause transient task time by uid for inner ability. * @param uid app uid. * @return Returns ERR_OK if success, else failure. */ ErrCode PauseTransientTaskTimeForInner(int32_t uid) override; /** * @brief Start transient task time by uid for inner ability. * @param uid app uid. * @return Returns ERR_OK if success, else failure. */ ErrCode StartTransientTaskTimeForInner(int32_t uid) override; /** * @brief Get all continuous task running infos. * @param list continuous task infos. * @return Returns ERR_OK if success, else failure. */ ErrCode GetContinuousTaskApps(std::vector> &list) override; /** * @brief Apply or unapply efficiency resources. * * @param resourceInfo Request params. * @return Returns ERR_OK on success, others on failure. */ ErrCode ApplyEfficiencyResources(const sptr &resourceInfo) override; /** * @brief Reset all efficiency resources. * * @return ERR_OK if success, else fail. */ ErrCode ResetAllEfficiencyResources() override; /** * @brief Get all effficiency resources running infos. * @param appList EFficiency Resources infos of apps. * @param procList EFficiency Resources infos of processes. * @return Returns ERR_OK on success, others on failure. */ ErrCode GetEfficiencyResourcesInfos(std::vector> &appList, std::vector> &procList) override; /** * @brief Request stop continuous task. * @param uid app uid. * @param pid app pid. * @param taskType continuous task type. * @param key continuous task key. * @return Returns ERR_OK if success, else failure. */ ErrCode StopContinuousTask(int32_t uid, int32_t pid, uint32_t taskType, const std::string &key) override; /** * @brief Set background task config. * @param configData config param. * @param sourceType data source. * @return Returns ERR_OK if success, else failure. */ ErrCode SetBgTaskConfig(const std::string &configData, int32_t sourceType) override; private: ErrCode InnerTransact(uint32_t code, MessageOption &flags, MessageParcel &data, MessageParcel &reply); static inline BrokerDelegator delegator_; }; } // namespace BackgroundTaskMgr } // namespace OHOS #endif // FOUNDATION_RESOURCESCHEDULE_BACKGROUND_TASK_MGR_FRAMEWORKS_INCLUDE_BACKGROUND_TASK_MGR_PROXY_H