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 PRIVACY_MANAGER_PROXY_H 17 #define PRIVACY_MANAGER_PROXY_H 18 19 #include <string> 20 21 #include "i_privacy_manager.h" 22 #include "iremote_proxy.h" 23 24 namespace OHOS { 25 namespace Security { 26 namespace AccessToken { 27 class PrivacyManagerProxy : public IRemoteProxy<IPrivacyManager> { 28 public: 29 explicit PrivacyManagerProxy(const sptr<IRemoteObject>& impl); 30 ~PrivacyManagerProxy() override; 31 32 int32_t AddPermissionUsedRecord( 33 AccessTokenID tokenID, const std::string& permissionName, int32_t successCount, int32_t failCount) override; 34 int32_t StartUsingPermission(AccessTokenID tokenID, const std::string& permissionName) override; 35 int32_t StartUsingPermission(AccessTokenID tokenID, const std::string& permissionName, 36 const sptr<IRemoteObject>& callback) override; 37 int32_t StopUsingPermission(AccessTokenID tokenID, const std::string& permissionName) override; 38 int32_t RemovePermissionUsedRecords(AccessTokenID tokenID, const std::string& deviceID) override; 39 int32_t GetPermissionUsedRecords( 40 const PermissionUsedRequestParcel& request, PermissionUsedResultParcel& result) override; 41 int32_t GetPermissionUsedRecords(const PermissionUsedRequestParcel& request, 42 const sptr<OnPermissionUsedRecordCallback>& callback) override; 43 int32_t RegisterPermActiveStatusCallback( 44 std::vector<std::string>& permList, const sptr<IRemoteObject>& callback) override; 45 int32_t UnRegisterPermActiveStatusCallback(const sptr<IRemoteObject>& callback) override; 46 bool IsAllowedUsingPermission(AccessTokenID tokenID, const std::string& permissionName) override; 47 48 private: 49 bool SendRequest(IPrivacyManager::InterfaceCode code, MessageParcel& data, MessageParcel& reply); 50 static inline BrokerDelegator<PrivacyManagerProxy> delegator_; 51 }; 52 } // namespace AccessToken 53 } // namespace Security 54 } // namespace OHOS 55 #endif // PRIVACY_MANAGER_PROXY_H