1 /* 2 * Copyright (c) 2021-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 17 #ifndef INTERFACES_INNERKITS_SAMGR_INCLUDE_SYSTEM_ABILITY_MANAGER_PROXY_H_ 18 #define INTERFACES_INNERKITS_SAMGR_INCLUDE_SYSTEM_ABILITY_MANAGER_PROXY_H_ 19 20 #include <string> 21 #include "if_system_ability_manager.h" 22 23 namespace OHOS { 24 class SystemAbilityManagerProxy : public IRemoteProxy<ISystemAbilityManager> { 25 public: SystemAbilityManagerProxy(const sptr<IRemoteObject> & impl)26 explicit SystemAbilityManagerProxy(const sptr<IRemoteObject>& impl) 27 : IRemoteProxy<ISystemAbilityManager>(impl) {} 28 ~SystemAbilityManagerProxy() = default; 29 std::vector<std::u16string> ListSystemAbilities(unsigned int dumpFlags) override; 30 31 // IntToString adapter interface 32 sptr<IRemoteObject> GetSystemAbility(int32_t systemAbilityId) override; 33 sptr<IRemoteObject> CheckSystemAbility(int32_t systemAbilityId) override; 34 int32_t RemoveSystemAbility(int32_t systemAbilityId) override; 35 int32_t SubscribeSystemAbility(int32_t systemAbilityId, const sptr<ISystemAbilityStatusChange>& listener) override; 36 int32_t UnSubscribeSystemAbility(int32_t systemAbilityId, 37 const sptr<ISystemAbilityStatusChange> &listener) override; 38 sptr<IRemoteObject> GetSystemAbility(int32_t systemAbilityId, const std::string& deviceId) override; 39 sptr<IRemoteObject> CheckSystemAbility(int32_t systemAbilityId, const std::string& deviceId) override; 40 int32_t AddOnDemandSystemAbilityInfo(int32_t systemAbilityId, 41 const std::u16string& localAbilityManagerName) override; 42 sptr<IRemoteObject> CheckSystemAbility(int32_t systemAbilityId, bool& isExist) override; 43 int32_t AddSystemAbility(int32_t systemAbilityId, const sptr<IRemoteObject>& ability, 44 const SAExtraProp& extraProp) override; 45 46 int32_t AddSystemProcess(const std::u16string& procName, const sptr<IRemoteObject>& procObject) override; 47 int32_t LoadSystemAbility(int32_t systemAbilityId, const sptr<ISystemAbilityLoadCallback>& callback) override; 48 int32_t LoadSystemAbility(int32_t systemAbilityId, const std::string& deviceId, 49 const sptr<ISystemAbilityLoadCallback>& callback) override; 50 private: 51 sptr<IRemoteObject> GetSystemAbilityWrapper(int32_t systemAbilityId, const std::string& deviceId = ""); 52 sptr<IRemoteObject> CheckSystemAbilityWrapper(int32_t code, MessageParcel& data); 53 int32_t MarshalSAExtraProp(const SAExtraProp& extraProp, MessageParcel& data) const; 54 int32_t AddSystemAbilityWrapper(int32_t code, MessageParcel& data); 55 int32_t RemoveSystemAbilityWrapper(int32_t code, MessageParcel& data); 56 private: 57 static inline BrokerDelegator<SystemAbilityManagerProxy> delegator_; 58 }; 59 } // namespace OHOS 60 61 #endif // !defined(INTERFACES_INNERKITS_SAMGR_INCLUDE_SYSTEM_ABILITY_MANAGER_PROXY_H_) 62