1 /* 2 * Copyright (c) 2021-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 I_NET_POLICY_CALLBACK_H 17 #define I_NET_POLICY_CALLBACK_H 18 19 #include <string> 20 21 #include "iremote_broker.h" 22 23 #include "net_policy_constants.h" 24 #include "net_quota_policy.h" 25 #include "policy_ipc_interface_code.h" 26 27 namespace OHOS { 28 namespace NetManagerStandard { 29 class INetPolicyCallback : public IRemoteBroker { 30 public: 31 virtual ~INetPolicyCallback() = default; 32 33 public: 34 DECLARE_INTERFACE_DESCRIPTOR(u"OHOS.NetManagerStandard.INetPolicyCallback"); 35 36 public: 37 /** 38 * Notify the net uid policy change 39 * 40 * @param uid The specified UID of app. 41 * @param policy The network policy for application. 42 * For details, see {@link NetUidPolicy}. 43 * @return Returns 0 success. Otherwise fail, {@link NetPolicyResultCode}. 44 */ 45 virtual int32_t NetUidPolicyChange(uint32_t uid, uint32_t policy) = 0; 46 47 /** 48 * Notify the net uid rule change 49 * 50 * @param uid The specified UID of app. 51 * @param rule The network rule for application. 52 * For details, see {@link NetUidRule}. 53 * @return Returns 0 success. Otherwise fail, {@link NetPolicyResultCode}. 54 */ 55 virtual int32_t NetUidRuleChange(uint32_t uid, uint32_t rule) = 0; 56 57 /** 58 * Notify the quota policy change 59 * 60 * @param quotaPolicies The list of network quota policy, {@link NetQuotaPolicy}. 61 * @return Returns 0 success. Otherwise fail, {@link NetPolicyResultCode}. 62 */ 63 virtual int32_t NetQuotaPolicyChange(const std::vector<NetQuotaPolicy> "aPolicies) = 0; 64 65 /** 66 * Notify the metered ifaces change 67 * 68 * @param ifaces The vector of metered ifaces 69 * @return Returns 0 success. Otherwise fail, {@link NetPolicyResultCode}. 70 */ 71 virtual int32_t NetMeteredIfacesChange(std::vector<std::string> &ifaces) = 0; 72 73 /** 74 * Notify the background policy change 75 * 76 * @param isBackgroundPolicyAllow The background is allow or not 77 * @return Returns 0 success. Otherwise fail, {@link NetPolicyResultCode}. 78 */ 79 virtual int32_t NetBackgroundPolicyChange(bool isBackgroundPolicyAllow) = 0; 80 81 /** 82 * @deprecated 83 */ 84 virtual int32_t NetStrategySwitch(const std::string &simId, bool enable) = 0; 85 }; 86 } // namespace NetManagerStandard 87 } // namespace OHOS 88 #endif // I_NET_POLICY_CALLBACK_H