• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022-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 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(AccessTokenID tokenID, const std::string& permissionName,
33         int32_t successCount, int32_t failCount, bool asyncMode = false) 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 #ifdef SECURITY_COMPONENT_ENHANCE_ENABLE
48     int32_t RegisterSecCompEnhance(const SecCompEnhanceDataParcel& enhance) override;
49     int32_t DepositSecCompEnhance(const std::vector<SecCompEnhanceDataParcel>& enhanceParcelList) override;
50     int32_t RecoverSecCompEnhance(std::vector<SecCompEnhanceDataParcel>& enhanceParcelList) override;
51 #endif
52 
53 private:
54     bool SendRequest(PrivacyInterfaceCode code, MessageParcel& data, MessageParcel& reply, bool asyncMode = false);
55     static inline BrokerDelegator<PrivacyManagerProxy> delegator_;
56 };
57 } // namespace AccessToken
58 } // namespace Security
59 } // namespace OHOS
60 #endif // PRIVACY_MANAGER_PROXY_H
61