11ebd3d54Sopenharmony_ci/*
21ebd3d54Sopenharmony_ci * Copyright (c) 2022 Huawei Device Co., Ltd.
31ebd3d54Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
41ebd3d54Sopenharmony_ci * you may not use this file except in compliance with the License.
51ebd3d54Sopenharmony_ci * You may obtain a copy of the License at
61ebd3d54Sopenharmony_ci *
71ebd3d54Sopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
81ebd3d54Sopenharmony_ci *
91ebd3d54Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software
101ebd3d54Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
111ebd3d54Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
121ebd3d54Sopenharmony_ci * See the License for the specific language governing permissions and
131ebd3d54Sopenharmony_ci * limitations under the License.
141ebd3d54Sopenharmony_ci */
151ebd3d54Sopenharmony_ci
161ebd3d54Sopenharmony_ci#ifndef FOUNDATION_RESOURCESCHEDULE_BACKGROUND_TASK_MGR_SERVICES_TRANSIENT_TASK_INCLUDE_WATCHDOG_H
171ebd3d54Sopenharmony_ci#define FOUNDATION_RESOURCESCHEDULE_BACKGROUND_TASK_MGR_SERVICES_TRANSIENT_TASK_INCLUDE_WATCHDOG_H
181ebd3d54Sopenharmony_ci
191ebd3d54Sopenharmony_ci#include <event_handler.h>
201ebd3d54Sopenharmony_ci#include <event_runner.h>
211ebd3d54Sopenharmony_ci#include <refbase.h>
221ebd3d54Sopenharmony_ci
231ebd3d54Sopenharmony_ci#include "appmgr/app_mgr_client.h"
241ebd3d54Sopenharmony_ci
251ebd3d54Sopenharmony_ci#include "decision_maker.h"
261ebd3d54Sopenharmony_ci#include "key_info.h"
271ebd3d54Sopenharmony_ci
281ebd3d54Sopenharmony_cinamespace OHOS {
291ebd3d54Sopenharmony_cinamespace BackgroundTaskMgr {
301ebd3d54Sopenharmony_ciclass BackgroundTaskMgrService;
311ebd3d54Sopenharmony_ci
321ebd3d54Sopenharmony_ciclass Watchdog : public AppExecFwk::EventHandler {
331ebd3d54Sopenharmony_cipublic:
341ebd3d54Sopenharmony_ci    Watchdog(const wptr<BackgroundTaskMgrService>& service, const std::shared_ptr<DecisionMaker>& decision,
351ebd3d54Sopenharmony_ci        const std::shared_ptr<AppExecFwk::EventRunner>& runner);
361ebd3d54Sopenharmony_ci    ~Watchdog() override = default;
371ebd3d54Sopenharmony_ci    bool AddWatchdog(int32_t requestId, const std::shared_ptr<KeyInfo>& info, int32_t interval);
381ebd3d54Sopenharmony_ci    void RemoveWatchdog(int32_t requestId);
391ebd3d54Sopenharmony_ci    void ProcessEvent(const AppExecFwk::InnerEvent::Pointer& event) override;
401ebd3d54Sopenharmony_ci
411ebd3d54Sopenharmony_ciprivate:
421ebd3d54Sopenharmony_ci    bool KillApplicationByUid(const std::string &bundleName, const int32_t uid);
431ebd3d54Sopenharmony_ci
441ebd3d54Sopenharmony_ci    wptr<BackgroundTaskMgrService> service_;
451ebd3d54Sopenharmony_ci    std::unique_ptr<AppExecFwk::AppMgrClient> appMgrClient_;
461ebd3d54Sopenharmony_ci    std::shared_ptr<DecisionMaker> decision_ {nullptr};
471ebd3d54Sopenharmony_ci};
481ebd3d54Sopenharmony_ci}  // namespace BackgroundTaskMgr
491ebd3d54Sopenharmony_ci}  // namespace OHOS
501ebd3d54Sopenharmony_ci#endif  // FOUNDATION_RESOURCESCHEDULE_BACKGROUND_TASK_MGR_SERVICES_TRANSIENT_TASK_INCLUDE_WATCHDOG_H