1 /* 2 * Copyright (c) 2023-2024 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 SANDBOX_MANAGER_PROXY_H 17 #define SANDBOX_MANAGER_PROXY_H 18 19 #include "iremote_object.h" 20 #include "iremote_proxy.h" 21 #include "i_sandbox_manager.h" 22 #include "refbase.h" 23 #include "sandboxmanager_service_ipc_interface_code.h" 24 #include "system_ability_definition.h" 25 26 namespace OHOS { 27 namespace AccessControl { 28 namespace SandboxManager { 29 class SandboxManagerProxy : public IRemoteProxy<ISandboxManager> { 30 public: 31 explicit SandboxManagerProxy(const sptr<IRemoteObject> &impl); 32 ~SandboxManagerProxy() override; 33 34 int32_t CleanPersistPolicyByPath(const std::vector<std::string>& filePathList) override; 35 int32_t PersistPolicy(const std::vector<PolicyInfo> &policy, std::vector<uint32_t> &result) override; 36 int32_t UnPersistPolicy(const std::vector<PolicyInfo> &policy, std::vector<uint32_t> &result) override; 37 int32_t SetPolicy(uint32_t tokenId, const std::vector<PolicyInfo> &policy, uint64_t policyFlag, 38 std::vector<uint32_t> &result, uint64_t timestamp) override; 39 int32_t UnSetPolicy(uint32_t tokenId, const PolicyInfo &policy) override; 40 int32_t SetPolicyAsync(uint32_t tokenId, const std::vector<PolicyInfo> &policy, uint64_t policyFlag, 41 uint64_t timestamp) override; 42 int32_t UnSetPolicyAsync(uint32_t tokenId, const PolicyInfo &policy) override; 43 int32_t CheckPolicy(uint32_t tokenId, const std::vector<PolicyInfo> &policy, std::vector<bool> &result) override; 44 int32_t StartAccessingPolicy(const std::vector<PolicyInfo> &policy, std::vector<uint32_t> &result, 45 bool useCallerToken, uint32_t tokenId, uint64_t timestamp) override; 46 int32_t StopAccessingPolicy(const std::vector<PolicyInfo> &policy, std::vector<uint32_t> &result) override; 47 int32_t CheckPersistPolicy( 48 uint32_t tokenId, const std::vector<PolicyInfo> &policy, std::vector<bool> &result) override; 49 int32_t PersistPolicyByTokenId( 50 uint32_t tokenId, const std::vector<PolicyInfo> &policy, std::vector<uint32_t> &result) override; 51 int32_t UnPersistPolicyByTokenId( 52 uint32_t tokenId, const std::vector<PolicyInfo> &policy, std::vector<uint32_t> &result) override; 53 int32_t StartAccessingByTokenId(uint32_t tokenId, uint64_t timestamp) override; 54 int32_t UnSetAllPolicyByToken(uint32_t tokenId, uint64_t timestamp) override; 55 private: 56 int32_t SendRequest(SandboxManagerInterfaceCode code, MessageParcel &data, MessageParcel &reply); 57 int32_t SendRequest(SandboxManagerInterfaceCode code, MessageParcel &data, MessageParcel &reply, 58 MessageOption &option); 59 static inline BrokerDelegator<SandboxManagerProxy> delegator_; 60 }; 61 } // namespace SandboxManager 62 } // namespace AccessControl 63 } // namespace OHOS 64 #endif // SANDBOX_MANAGER_PROXY_H 65