1/* 2 * Copyright (c) 2021-2023 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 INTERFACES_INNERKITS_SAMGR_INCLUDE_STATUS_CHANGE_WRAPPER_H 17#define INTERFACES_INNERKITS_SAMGR_INCLUDE_STATUS_CHANGE_WRAPPER_H 18 19#include <memory> 20 21#include "cxx.h" 22#include "if_system_ability_manager.h" 23#include "ipc_object_stub.h" 24#include "system_ability_status_change_stub.h" 25 26namespace OHOS { 27namespace SamgrRust { 28struct SystemProcessInfo; 29class SystemAbilityStatusChangeWrapper : public SystemAbilityStatusChangeStub { 30public: 31 SystemAbilityStatusChangeWrapper(const rust::Fn<void(int32_t systemAbilityId, const rust::str deviceId)> onAdd, 32 const rust::Fn<void(int32_t systemAbilityId, const rust::str deviceId)> onRemove); 33 ~SystemAbilityStatusChangeWrapper() = default; 34 void OnAddSystemAbility(int32_t systemAbilityId, const std::string &deviceId) override; 35 void OnRemoveSystemAbility(int32_t systemAbilityId, const std::string &deviceId) override; 36 37private: 38 rust::Fn<void(int32_t systemAbilityId, const rust::str deviceId)> onAdd_; 39 rust::Fn<void(int32_t systemAbilityId, const rust::str deviceId)> onRemove_; 40}; 41 42class SystemProcessStatusChangeWrapper : public IRemoteProxy<ISystemProcessStatusChange> { 43public: 44 SystemProcessStatusChangeWrapper(const sptr<IRemoteObject> &impl, 45 const rust::Fn<void(const OHOS::SamgrRust::SystemProcessInfo &systemProcessInfo)> onStart, 46 const rust::Fn<void(const OHOS::SamgrRust::SystemProcessInfo &systemProcessInfo)> onStop); 47 ~SystemProcessStatusChangeWrapper() = default; 48 49 void OnSystemProcessStarted(OHOS::SystemProcessInfo &systemProcessInfo) override; 50 void OnSystemProcessStopped(OHOS::SystemProcessInfo &systemProcessInfo) override; 51 52private: 53 rust::Fn<void(const OHOS::SamgrRust::SystemProcessInfo &systemProcessInfo)> onStart_; 54 rust::Fn<void(const OHOS::SamgrRust::SystemProcessInfo &systemProcessInfo)> onStop_; 55}; 56 57class UnSubscribeSystemAbilityHandler { 58public: 59 UnSubscribeSystemAbilityHandler(int32_t systemAbilityId, sptr<ISystemAbilityStatusChange> listener); 60 void UnSubscribe(); 61 62private: 63 int32_t said_; 64 sptr<ISystemAbilityStatusChange> listener_; 65}; 66 67class UnSubscribeSystemProcessHandler { 68public: 69 UnSubscribeSystemProcessHandler(sptr<ISystemProcessStatusChange> listener); 70 void UnSubscribe(); 71 72private: 73 sptr<ISystemProcessStatusChange> listener_; 74}; 75 76} // namespace SamgrRust 77} // namespace OHOS 78 79#endif