• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #ifdef RESOURCESCHEDULE_BGTASKMGR_ENABLE
16 #include "scheduler_bg_task_subscriber.h"
17 #include "resource_type.h"
18 #include "resource_callback_info.h"
19 #include "work_scheduler_service.h"
20 #include "work_sched_hilog.h"
21 
22 namespace OHOS {
23 namespace WorkScheduler {
24 using namespace OHOS::BackgroundTaskMgr;
OnConnected()25 void SchedulerBgTaskSubscriber::OnConnected()
26 {
27     WS_HILOGD("OnConnected called");
28 }
29 
OnDisconnected()30 void SchedulerBgTaskSubscriber::OnDisconnected()
31 {
32     WS_HILOGD("OnDisconnected called");
33 }
34 
OnProcEfficiencyResourcesApply(const std::shared_ptr<BackgroundTaskMgr::ResourceCallbackInfo> & resourceInfo)35 void SchedulerBgTaskSubscriber::OnProcEfficiencyResourcesApply(
36     const std::shared_ptr<BackgroundTaskMgr::ResourceCallbackInfo> &resourceInfo)
37 {
38     WS_HILOGD("OnProcEfficiencyResourcesApply called");
39     if (!resourceInfo || (resourceInfo->GetResourceNumber() & BackgroundTaskMgr::ResourceType::WORK_SCHEDULER) == 0) {
40         WS_HILOGI("called with null efficiency callback info");
41         return;
42     }
43     int32_t uid = resourceInfo->GetUid();
44     DelayedSpSingleton<WorkSchedulerService>::GetInstance()->UpdateEffiResApplyInfo(uid, true);
45 }
46 
OnProcEfficiencyResourcesReset(const std::shared_ptr<BackgroundTaskMgr::ResourceCallbackInfo> & resourceInfo)47 void SchedulerBgTaskSubscriber::OnProcEfficiencyResourcesReset(
48     const std::shared_ptr<BackgroundTaskMgr::ResourceCallbackInfo> &resourceInfo)
49 {
50     WS_HILOGD("OnProcEfficiencyResourcesReset called");
51     if (!resourceInfo || (resourceInfo->GetResourceNumber() & BackgroundTaskMgr::ResourceType::WORK_SCHEDULER) == 0) {
52         WS_HILOGI("called with null efficiency callback info");
53         return;
54     }
55     int32_t uid = resourceInfo->GetUid();
56     DelayedSpSingleton<WorkSchedulerService>::GetInstance()->UpdateEffiResApplyInfo(uid, false);
57 }
58 
OnAppEfficiencyResourcesApply(const std::shared_ptr<BackgroundTaskMgr::ResourceCallbackInfo> & resourceInfo)59 void SchedulerBgTaskSubscriber::OnAppEfficiencyResourcesApply(
60     const std::shared_ptr<BackgroundTaskMgr::ResourceCallbackInfo> &resourceInfo)
61 {
62     OnProcEfficiencyResourcesApply(resourceInfo);
63 }
64 
OnAppEfficiencyResourcesReset(const std::shared_ptr<BackgroundTaskMgr::ResourceCallbackInfo> & resourceInfo)65 void SchedulerBgTaskSubscriber::OnAppEfficiencyResourcesReset(
66     const std::shared_ptr<BackgroundTaskMgr::ResourceCallbackInfo> &resourceInfo)
67 {
68     OnProcEfficiencyResourcesReset(resourceInfo);
69 }
70 
OnRemoteDied(const wptr<IRemoteObject> & object)71 void SchedulerBgTaskSubscriber::OnRemoteDied(const wptr<IRemoteObject> &object)
72 {
73     WS_HILOGE("called");
74 }
75 } // namespace Memory
76 } // namespace OHOS
77 #endif