• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
26 namespace OHOS {
27 namespace NetManagerStandard {
28 class INetPolicyCallback : public IRemoteBroker {
29 public:
30     virtual ~INetPolicyCallback() = default;
31 
32 public:
33     DECLARE_INTERFACE_DESCRIPTOR(u"OHOS.NetManagerStandard.INetPolicyCallback");
34     enum {
35         NOTIFY_NET_UID_POLICY_CHANGE = 1,
36         NOTIFY_NET_UID_RULE_CHANGE = 2,
37         NOTIFY_NET_QUOTA_POLICY_CHANGE = 3,
38         NET_POLICY_STRATEGYSWITCH_CHANGE = 4,
39         NOTIFY_NET_METERED_IFACES_CHANGE = 5,
40         NOTIFY_BACKGROUND_POLICY_CHANGE = 6,
41     };
42 
43 public:
44     /**
45      * Notify the net uid policy change
46      *
47      * @param uid The specified UID of app.
48      * @param policy The network policy for application.
49      *      For details, see {@link NetUidPolicy}.
50      * @return Returns 0 success. Otherwise fail, {@link NetPolicyResultCode}.
51      */
52     virtual int32_t NetUidPolicyChange(uint32_t uid, uint32_t policy) = 0;
53 
54     /**
55      * Notify the net uid rule change
56      *
57      * @param uid The specified UID of app.
58      * @param rule The network rule for application.
59      *      For details, see {@link NetUidRule}.
60      * @return Returns 0 success. Otherwise fail, {@link NetPolicyResultCode}.
61      */
62     virtual int32_t NetUidRuleChange(uint32_t uid, uint32_t rule) = 0;
63 
64     /**
65      * Notify the quota policy change
66      *
67      * @param quotaPolicies The list of network quota policy, {@link NetQuotaPolicy}.
68      * @return Returns 0 success. Otherwise fail, {@link NetPolicyResultCode}.
69      */
70     virtual int32_t NetQuotaPolicyChange(const std::vector<NetQuotaPolicy> &quotaPolicies) = 0;
71 
72     /**
73      * Notify the metered ifaces change
74      *
75      * @param ifaces The vector of metered ifaces
76      * @return Returns 0 success. Otherwise fail, {@link NetPolicyResultCode}.
77      */
78     virtual int32_t NetMeteredIfacesChange(std::vector<std::string> &ifaces) = 0;
79 
80     /**
81      * Notify the background policy change
82      *
83      * @param isBackgroundPolicyAllow The background is allow or not
84      * @return Returns 0 success. Otherwise fail, {@link NetPolicyResultCode}.
85      */
86     virtual int32_t NetBackgroundPolicyChange(bool isBackgroundPolicyAllow) = 0;
87 
88     /**
89      * @deprecated
90      */
91     virtual int32_t NetStrategySwitch(const std::string &simId, bool enable) = 0;
92 };
93 } // namespace NetManagerStandard
94 } // namespace OHOS
95 #endif // I_NET_POLICY_CALLBACK_H