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 OHOS_MEMORY_MEMMGR_SERVICE_H 17 #define OHOS_MEMORY_MEMMGR_SERVICE_H 18 19 #include "mem_mgr_stub.h" 20 #include "single_instance.h" 21 #include "system_ability.h" 22 23 namespace OHOS { 24 namespace Memory { 25 class MemMgrService : public SystemAbility, public MemMgrStub { 26 DECLARE_SYSTEM_ABILITY(MemMgrService); 27 DECLARE_SINGLE_INSTANCE_BASE(MemMgrService); 28 29 public: 30 MemMgrService(); 31 ~MemMgrService() = default; 32 virtual int32_t GetBundlePriorityList(BundlePriorityList &bundlePrioList) override; 33 virtual int32_t NotifyDistDevStatus(int32_t pid, int32_t uid, const std::string &name, bool connected) override; 34 virtual int32_t GetKillLevelOfLmkd(int32_t &killLevel) override; 35 #ifdef USE_PURGEABLE_MEMORY 36 virtual int32_t RegisterActiveApps(int32_t pid, int32_t uid) override; 37 virtual int32_t DeregisterActiveApps(int32_t pid, int32_t uid) override; 38 virtual int32_t SubscribeAppState(const sptr<IAppStateSubscriber> &subscriber) override; 39 virtual int32_t UnsubscribeAppState(const sptr<IAppStateSubscriber> &subscriber) override; 40 virtual int32_t GetAvailableMemory(int32_t &memSize) override; 41 virtual int32_t GetTotalMemory(int32_t &memSize) override; 42 #endif 43 virtual int32_t OnWindowVisibilityChanged(const std::vector<sptr<MemMgrWindowInfo>> &MemMgrWindowInfo) override; 44 virtual int32_t GetReclaimPriorityByPid(int32_t pid, int32_t &priority) override; 45 virtual int32_t NotifyProcessStateChangedSync(const MemMgrProcessStateInfo &processStateInfo) override; 46 virtual int32_t NotifyProcessStateChangedAsync(const MemMgrProcessStateInfo &processStateInfo) override; 47 virtual int32_t NotifyProcessStatus(int32_t pid, int32_t type, int32_t status, int32_t saId = -1) override; 48 virtual int32_t SetCritical(int32_t pid, bool critical, int32_t saId = -1) override; 49 virtual void OnAddSystemAbility(int32_t systemAbilityId, const std::string& deviceId) override; 50 virtual void OnRemoveSystemAbility(int32_t systemAbilityId, const std::string& deviceId) override; 51 virtual int Dump(int fd, const std::vector<std::u16string> &args) override; 52 53 protected: 54 void OnStart() override; 55 void OnStop() override; 56 57 private: 58 int32_t windowManagerUid_ = 5523; 59 bool Init(); 60 }; 61 } // namespace Memory 62 } // namespace OHOS 63 #endif // OHOS_MEMORY_MEMMGR_SERVICE_H 64