1 /* 2 * Copyright (c) 2022-2024 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 RESSCHED_SERVICES_RESSCHEDSERVICE_INCLUDE_RES_SCHED_SERVICE_ABILITY_H 17 #define RESSCHED_SERVICES_RESSCHEDSERVICE_INCLUDE_RES_SCHED_SERVICE_ABILITY_H 18 19 #include "system_ability.h" 20 #include "res_sched_service.h" 21 #include "singleton.h" 22 23 namespace OHOS { 24 namespace ResourceSchedule { 25 class ResSchedServiceAbility : public SystemAbility, 26 public std::enable_shared_from_this<ResSchedServiceAbility> { 27 DECLARE_SYSTEM_ABILITY(ResSchedServiceAbility); 28 DECLARE_DELAYED_SINGLETON(ResSchedServiceAbility); 29 public: ResSchedServiceAbility(int32_t sysAbilityId,bool runOnCreate)30 ResSchedServiceAbility(int32_t sysAbilityId, bool runOnCreate) : SystemAbility(sysAbilityId, runOnCreate) {} 31 32 private: 33 void OnStart() override; 34 35 void OnStop() override; 36 37 void OnAddSystemAbility(int32_t systemAbilityId, const std::string& deviceId) override; 38 39 void OnRemoveSystemAbility(int32_t systemAbilityId, const std::string& deviceId) override; 40 41 void OnDeviceLevelChanged(int32_t type, int32_t level, std::string& action) override; 42 43 void ReclaimProcessMemory(); 44 45 void SystemAbilityListenerInit(); 46 47 sptr<ResSchedService> service_; 48 49 DISALLOW_COPY_AND_MOVE(ResSchedServiceAbility); 50 }; 51 } // namespace ResourceSchedule 52 } // namespace OHOS 53 54 #endif // RESSCHED_SERVICES_RESSCHEDSERVICE_INCLUDE_RES_SCHED_SERVICE_ABILITY_H 55