1 /* 2 * Copyright (c) 2022-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 OHOS_ABILITY_RUNTIME_URI_PERMISSION_MANAGER_PROXY_H 17 #define OHOS_ABILITY_RUNTIME_URI_PERMISSION_MANAGER_PROXY_H 18 19 #include <vector> 20 #include "iremote_proxy.h" 21 #include "uri_permission_manager_interface.h" 22 23 namespace OHOS { 24 namespace AAFwk { 25 class UriPermissionManagerProxy : public IRemoteProxy<IUriPermissionManager> { 26 public: 27 explicit UriPermissionManagerProxy(const sptr<IRemoteObject> &impl); 28 virtual ~UriPermissionManagerProxy() = default; 29 30 virtual int GrantUriPermission(const Uri &uri, unsigned int flag, 31 const std::string targetBundleName, int32_t appIndex = 0, uint32_t initiatorTokenId = 0) override; 32 33 virtual int GrantUriPermission(const std::vector<Uri> &uriVec, unsigned int flag, 34 const std::string targetBundleName, int32_t appIndex = 0, uint32_t initiatorTokenId = 0) override; 35 36 virtual int32_t GrantUriPermissionPrivileged(const std::vector<Uri> &uriVec, uint32_t flag, 37 const std::string &targetBundleName, int32_t appIndex, uint32_t initiatorTokenId, 38 int32_t hideSensitiveType) override; 39 40 virtual int RevokeAllUriPermissions(const uint32_t tokenId) override; 41 virtual int RevokeUriPermissionManually(const Uri &uri, const std::string bundleName, 42 int32_t appIndex = 0) override; 43 virtual bool VerifyUriPermission(const Uri &uri, uint32_t flag, uint32_t tokenId) override; 44 virtual std::vector<bool> CheckUriAuthorization(const std::vector<std::string> &uriVec, 45 uint32_t flag, uint32_t tokenId) override; 46 virtual int32_t ClearPermissionTokenByMap(const uint32_t tokenId) override; 47 #ifdef ABILITY_RUNTIME_FEATURE_SANDBOXMANAGER 48 virtual int32_t Active(const std::vector<PolicyInfo> &policy, std::vector<uint32_t> &result) override; 49 #endif // ABILITY_RUNTIME_FEATURE_SANDBOXMANAGER 50 51 private: 52 static inline BrokerDelegator<UriPermissionManagerProxy> delegator_; 53 int32_t SendTransactCmd(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option); 54 bool WriteBatchUris(MessageParcel &data, const std::vector<Uri> &uriVec); 55 }; 56 } // namespace AAFwk 57 } // namespace OHOS 58 #endif // OHOS_ABILITY_RUNTIME_URI_PERMISSION_MANAGER_PROXY_H 59