1 /* 2 * Copyright (c) 2021-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 NET_POLICY_SERVICE_PROXY_H 17 #define NET_POLICY_SERVICE_PROXY_H 18 19 #include "iremote_proxy.h" 20 21 #include "i_net_policy_service.h" 22 #include "net_policy_constants.h" 23 #include "net_quota_policy.h" 24 25 namespace OHOS { 26 namespace NetManagerStandard { 27 class NetPolicyServiceProxy : public IRemoteProxy<INetPolicyService> { 28 public: 29 explicit NetPolicyServiceProxy(const sptr<IRemoteObject> &impl); 30 virtual ~NetPolicyServiceProxy(); 31 int32_t SetPolicyByUid(uint32_t uid, uint32_t policy) override; 32 int32_t GetPolicyByUid(uint32_t uid, uint32_t &policy) override; 33 int32_t GetUidsByPolicy(uint32_t policy, std::vector<uint32_t> &uids) override; 34 int32_t IsUidNetAllowed(uint32_t uid, bool metered, bool &isAllowed) override; 35 int32_t IsUidNetAllowed(uint32_t uid, const std::string &ifaceName, bool &isAllowed) override; 36 int32_t RegisterNetPolicyCallback(const sptr<INetPolicyCallback> &callback) override; 37 int32_t UnregisterNetPolicyCallback(const sptr<INetPolicyCallback> &callback) override; 38 int32_t SetNetQuotaPolicies(const std::vector<NetQuotaPolicy> "aPolicies) override; 39 int32_t GetNetQuotaPolicies(std::vector<NetQuotaPolicy> "aPolicies) override; 40 int32_t ResetPolicies(const std::string &simId) override; 41 int32_t SetBackgroundPolicy(bool allowBackground) override; 42 int32_t GetBackgroundPolicy(bool &backgroundPolicy) override; 43 int32_t GetBackgroundPolicyByUid(uint32_t uid, uint32_t &backgroundPolicyOfUid) override; 44 int32_t UpdateRemindPolicy(int32_t netType, const std::string &simId, uint32_t remindType) override; 45 int32_t SetDeviceIdleTrustlist(const std::vector<uint32_t> &uids, bool isAllowed) override; 46 int32_t GetDeviceIdleTrustlist(std::vector<uint32_t> &uids) override; 47 int32_t SetDeviceIdlePolicy(bool enable) override; 48 int32_t GetPowerSaveTrustlist(std::vector<uint32_t> &uids) override; 49 int32_t SetPowerSaveTrustlist(const std::vector<uint32_t> &uids, bool isAllowed) override; 50 int32_t SetPowerSavePolicy(bool enable) override; 51 int32_t CheckPermission() override; 52 int32_t FactoryResetPolicies() override; 53 int32_t SetNetworkAccessPolicy(uint32_t uid, NetworkAccessPolicy policy, bool reconfirmFlag) override; 54 int32_t GetNetworkAccessPolicy(AccessPolicyParameter parameter, AccessPolicySave& policy) override; 55 int32_t NotifyNetAccessPolicyDiag(uint32_t uid) override; 56 int32_t SetNicTrafficAllowed(const std::vector<std::string> &ifaceNames, bool status) override; 57 58 private: 59 bool WriteInterfaceToken(MessageParcel &data); 60 int32_t SendRequest(sptr<IRemoteObject> &remote, uint32_t code, MessageParcel &data, MessageParcel &reply, 61 MessageOption &option); 62 63 private: 64 static inline BrokerDelegator<NetPolicyServiceProxy> delegator_; 65 }; 66 } // namespace NetManagerStandard 67 } // namespace OHOS 68 #endif // NET_POLICY_SERVICE_PROXY_H 69