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_APP_STATE_SUBSCRIBER_PROXY_H 17 #define OHOS_MEMORY_MEMMGR_APP_STATE_SUBSCRIBER_PROXY_H 18 19 #include <iremote_proxy.h> 20 21 #include "iapp_state_subscriber.h" 22 23 namespace OHOS { 24 namespace Memory { 25 class AppStateSubscriberProxy : public IRemoteProxy<IAppStateSubscriber> { 26 public: 27 AppStateSubscriberProxy() = delete; 28 explicit AppStateSubscriberProxy(const sptr<IRemoteObject> &impl); 29 ~AppStateSubscriberProxy() override; 30 DISALLOW_COPY_AND_MOVE(AppStateSubscriberProxy); 31 32 /* * 33 * @brief Called back when the subscriber is connected to Memory Manager Service. 34 */ 35 void OnConnected() override; 36 37 /* * 38 * @brief Called back when the subscriber is disconnected to Memory Manager Service. 39 */ 40 void OnDisconnected() override; 41 42 /* * 43 * @brief Called back when app state change. 44 * 45 * @param pid pid of the process whose state is changed. 46 * @param uid uid of the process whose state is changed. 47 * @param state new state of the app. 48 */ 49 void OnAppStateChanged(int32_t pid, int32_t uid, int32_t state) override; 50 51 /* * 52 * @brief Called back when need to reclaim memory. 53 * 54 * @param pid pid of the process which need to reclaim. 55 * @param uid uid of the process which need to reclaim. 56 */ 57 void ForceReclaim(int32_t pid, int32_t uid) override; 58 59 /* * 60 * @brief Called back when get systemMemoryLevel message. 61 * 62 * @param level current memory level. 63 */ 64 void OnTrim(SystemMemoryLevel level) override; 65 66 private: 67 static inline BrokerDelegator<AppStateSubscriberProxy> delegator_; 68 }; 69 } // namespace Memory 70 } // namespace OHOS 71 #endif // OHOS_MEMORY_MEMMGR_APP_STATE_SUBSCRIBER_PROXY_H 72