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_IAPP_STATE_SUBSCRIBER_H 17 #define OHOS_MEMORY_MEMMGR_IAPP_STATE_SUBSCRIBER_H 18 19 #include <ipc_types.h> 20 #include <iremote_broker.h> 21 #include <nocopyable.h> 22 23 #include "errors.h" 24 #include "memmgrservice_ipc_interface_code.h" 25 #include "memory_level_constants.h" 26 #include "refbase.h" 27 28 29 namespace OHOS { 30 namespace Memory { 31 class IAppStateSubscriber : public IRemoteBroker { 32 public: 33 IAppStateSubscriber() = default; 34 ~IAppStateSubscriber() override = default; 35 DISALLOW_COPY_AND_MOVE(IAppStateSubscriber); 36 37 /* * 38 * @brief Called back when the subscriber is connected to Memory Manager Service. 39 */ 40 virtual void OnConnected() = 0; 41 42 /* * 43 * @brief Called back when the subscriber is disconnected to Memory Manager Service. 44 */ 45 virtual void OnDisconnected() = 0; 46 47 /* * 48 * @brief Called back when app state change. 49 * 50 * @param pid pid of the process whose state is changed. 51 * @param uid uid of the process whose state is changed. 52 * @param state new state of the app. 53 */ 54 virtual void OnAppStateChanged(int32_t pid, int32_t uid, int32_t state) = 0; 55 56 /* * 57 * @brief Called back when need to reclaim memory. 58 * 59 * @param pid pid of the process which need to reclaim. 60 * @param uid uid of the process which need to reclaim. 61 */ 62 virtual void ForceReclaim(int32_t pid, int32_t uid) = 0; 63 64 /* * 65 * @brief Called back when get systemMemoryLevel message. 66 * 67 * @param level current memory level. 68 */ 69 virtual void OnTrim(SystemMemoryLevel level) = 0; 70 71 public: 72 DECLARE_INTERFACE_DESCRIPTOR(u"ohos.resourceschedule.IAppStateSubscriber"); 73 }; 74 } // namespace Memory 75 } // namespace OHOS 76 #endif // OHOS_MEMORY_MEMMGR_IAPP_STATE_SUBSCRIBER_H 77