• 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 NET_POLICY_DEFINE_H
17 #define NET_POLICY_DEFINE_H
18 
19 #include "common_event_manager.h"
20 #include "common_event_support.h"
21 
22 #include "net_quota_policy.h"
23 
24 namespace OHOS {
25 namespace NetManagerStandard {
26 const std::string COMMON_EVENT_NET_QUOTA_LIMIT = "usual.event.NET_QUOTA_LIMIT";
27 const std::string COMMON_EVENT_NET_QUOTA_LIMIT_REMINDED = "usual.event.NET_QUOTA_LIMIT_REMINDED";
28 const std::string COMMON_EVENT_NET_QUOTA_WARNING = "usual.event.QUOTA_WARNING";
29 const std::string COMMON_EVENT_POWER_SAVE_MODE_CHANGED =
30     EventFwk::CommonEventSupport::COMMON_EVENT_POWER_SAVE_MODE_CHANGED;
31 const std::string COMMON_EVENT_DEVICE_IDLE_MODE_CHANGED =
32     EventFwk::CommonEventSupport::COMMON_EVENT_DEVICE_IDLE_MODE_CHANGED;
33 const std::string COMMON_EVENT_UID_REMOVED = EventFwk::CommonEventSupport::COMMON_EVENT_UID_REMOVED;
34 
35 const mode_t CHOWN_RWX_USR_GRP = 0770;
36 constexpr int16_t PERIODDURATION_POS_NUM_ONE = 1;
37 constexpr int16_t DAY_ONE = 1;
38 constexpr int16_t DAY_THIRTY_ONE = 31;
39 constexpr int16_t LIMIT_ACTION_ONE = 1;
40 constexpr int16_t LIMIT_ACTION_THREE = 3;
41 constexpr int16_t LIMIT_CALLBACK_NUM = 200;
42 constexpr const char *POLICY_FILE_NAME = "/data/service/el1/public/netmanager/net_policy.json";
43 constexpr const char *CONFIG_HOS_VERSION = "hosVersion";
44 constexpr const char *CONFIG_UID_POLICY = "uidPolicy";
45 constexpr const char *CONFIG_UID = "uid";
46 constexpr const char *CONFIG_POLICY = "policy";
47 constexpr const char *HOS_VERSION = "1.0";
48 constexpr const char *CONFIG_BACKGROUND_POLICY = "backgroundPolicy";
49 constexpr const char *CONFIG_BACKGROUND_POLICY_STATUS = "status";
50 constexpr const char *CONFIG_QUOTA_POLICY = "quotaPolicy";
51 constexpr const char *CONFIG_QUOTA_POLICY_NETTYPE = "netType";
52 constexpr const char *CONFIG_QUOTA_POLICY_SUBSCRIBERID = "iccid";
53 constexpr const char *CONFIG_QUOTA_POLICY_PERIODSTARTTIME = "periodStartTime";
54 constexpr const char *CONFIG_QUOTA_POLICY_PERIODDURATION = "periodDuration";
55 constexpr const char *CONFIG_QUOTA_POLICY_WARNINGBYTES = "warningBytes";
56 constexpr const char *CONFIG_QUOTA_POLICY_LIMITBYTES = "limitBytes";
57 constexpr const char *CONFIG_QUOTA_POLICY_LASTLIMITSNOOZE = "lastLimitSnooze";
58 constexpr const char *CONFIG_QUOTA_POLICY_METERED = "metered";
59 constexpr const char *CONFIG_QUOTA_POLICY_SOURCE = "source";
60 constexpr const char *CONFIG_CELLULAR_POLICY = "cellularPolicy";
61 constexpr const char *CONFIG_CELLULAR_POLICY_SUBSCRIBERID = "iccid";
62 constexpr const char *CONFIG_CELLULAR_POLICY_PERIODSTARTTIME = "periodStartTime";
63 constexpr const char *CONFIG_CELLULAR_POLICY_PERIODDURATION = "periodDuration";
64 constexpr const char *CONFIG_CELLULAR_POLICY_TITLE = "title";
65 constexpr const char *CONFIG_CELLULAR_POLICY_SUMMARY = "summary";
66 constexpr const char *CONFIG_CELLULAR_POLICY_LIMITBYTES = "limitBytes";
67 constexpr const char *CONFIG_CELLULAR_POLICY_LIMITACTION = "limitAction";
68 constexpr const char *CONFIG_CELLULAR_POLICY_USEDBYTES = "usedBytes";
69 constexpr const char *CONFIG_CELLULAR_POLICY_USEDTIMEDURATION = "usedTimeDuration";
70 constexpr const char *CONFIG_CELLULAR_POLICY_POSSESSOR = "possessor";
71 constexpr const char *BACKGROUND_POLICY_ALLOW = "allow";
72 constexpr const char *BACKGROUND_POLICY_REJECT = "reject";
73 constexpr const char *IDENT_PREFIX_CELLULAR = "simId";
74 constexpr const char *IDENT_PREFIX_WIFI = "ssId";
75 
76 constexpr const char *FIREWALL_CHAIN_NAME_DEVICE_IDLE = "deviceidle";
77 
78 constexpr const char *UNKNOW_IFACE = "";
79 
80 constexpr const char *NET_POLICY_SERVICE_NAME = "NetPolicyService";
81 
82 enum {
83     FIREWALL_CHAIN_NONE = 0,         // ChainType::CHAIN_NONE
84     FIREWALL_CHAIN_DEVICE_IDLE = 16, // ChainType::CHAIN_OHFW_DOZABLE
85     FIREWALL_CHAIN_POWER_SAVE = 17,  // ChainType::CHAIN_OHFW_UNDOZABLE
86 };
87 
88 enum {
89     FIREWALL_RULE_ALLOW = 1,
90     FIREWALL_RULE_DENY = 2,
91 };
92 
93 struct UidPolicy {
94     std::string uid;
95     std::string policy;
96 };
97 
98 struct NetPolicyQuota {
99     std::string netType;
100     std::string iccid;
101     std::string periodStartTime;
102     std::string periodDuration;
103     std::string warningBytes;
104     std::string limitBytes;
105     std::string lastLimitSnooze;
106     std::string metered;
107     std::string source;
108 };
109 
110 struct NetPolicyCellular {
111     std::string iccid;
112     std::string periodStartTime;
113     std::string periodDuration;
114     std::string title;
115     std::string summary;
116     std::string limitBytes;
117     std::string limitAction;
118     std::string usedBytes;
119     std::string usedTimeDuration;
120     std::string possessor;
121 };
122 
123 struct NetPolicy {
124     std::string hosVersion;
125     std::vector<UidPolicy> uidPolicies;
126     std::string backgroundPolicyStatus;
127     std::vector<NetPolicyQuota> netQuotaPolicies;
128 };
129 
130 // link power_mode_module.h
131 enum {
132     POWER_MODE_MIN = 600,
133     NORMAL_MODE = POWER_MODE_MIN,
134     SAVE_MODE,
135     EXTREME_MODE,
136     LOWPOWER_MODE,
137     POWER_MODE_MAX = LOWPOWER_MODE
138 };
139 } // namespace NetManagerStandard
140 } // namespace OHOS
141 #endif // NET_POLICY_DEFINE_H