1/* 2 * Copyright (C) 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/** 17 * @file 18 * @kit NetworkKit 19 */ 20 21import type { AsyncCallback, Callback } from './@ohos.base'; 22import type connection from './@ohos.net.connection'; 23 24/** 25 * Provides interfaces to manage network policy rules. 26 * @namespace policy 27 * @syscap SystemCapability.Communication.NetManager.Core 28 * @since 10 29 */ 30declare namespace policy { 31 /** 32 * Get network bear type. 33 * @syscap SystemCapability.Communication.NetManager.Core 34 * @since 10 35 */ 36 type NetBearType = connection.NetBearType; 37 38 /** 39 * Control if applications can use data on background. 40 * @permission ohos.permission.MANAGE_NET_STRATEGY 41 * @param { boolean } isAllowed - Allow applications to use data on background. 42 * @param { AsyncCallback<void> } callback - the callback of setBackgroundAllowed. 43 * @throws { BusinessError } 201 - Permission denied. 44 * @throws { BusinessError } 202 - Non-system applications use system APIs. 45 * @throws { BusinessError } 401 - Parameter error. 46 * @throws { BusinessError } 2100001 - Invalid parameter value. 47 * @throws { BusinessError } 2100002 - Operation failed. Cannot connect to service. 48 * @throws { BusinessError } 2100003 - System internal error. 49 * @syscap SystemCapability.Communication.NetManager.Core 50 * @systemapi Hide this for inner system use. 51 * @since 10 52 */ 53 function setBackgroundAllowed(isAllowed: boolean, callback: AsyncCallback<void>): void; 54 55 /** 56 * Control if applications can use data on background. 57 * @permission ohos.permission.MANAGE_NET_STRATEGY 58 * @param { boolean } isAllowed - Allow applications to use data on background. 59 * @returns { Promise<void> } The promise returned by the function. 60 * @throws { BusinessError } 201 - Permission denied. 61 * @throws { BusinessError } 202 - Non-system applications use system APIs. 62 * @throws { BusinessError } 401 - Parameter error. 63 * @throws { BusinessError } 2100001 - Invalid parameter value. 64 * @throws { BusinessError } 2100002 - Operation failed. Cannot connect to service. 65 * @throws { BusinessError } 2100003 - System internal error. 66 * @syscap SystemCapability.Communication.NetManager.Core 67 * @systemapi Hide this for inner system use. 68 * @since 10 69 */ 70 function setBackgroundAllowed(isAllowed: boolean): Promise<void>; 71 72 /** 73 * Get the status if applications can use data on background. 74 * @permission ohos.permission.MANAGE_NET_STRATEGY 75 * @param { AsyncCallback<boolean> } callback - the callback of allowed or not to use data on background. 76 * @throws { BusinessError } 201 - Permission denied. 77 * @throws { BusinessError } 202 - Non-system applications use system APIs. 78 * @throws { BusinessError } 401 - Parameter error. 79 * @throws { BusinessError } 2100001 - Invalid parameter value. 80 * @throws { BusinessError } 2100002 - Operation failed. Cannot connect to service. 81 * @throws { BusinessError } 2100003 - System internal error. 82 * @syscap SystemCapability.Communication.NetManager.Core 83 * @systemapi Hide this for inner system use. 84 * @since 10 85 */ 86 function isBackgroundAllowed(callback: AsyncCallback<boolean>): void; 87 88 /** 89 * Get the status if applications can use data on background. 90 * @permission ohos.permission.MANAGE_NET_STRATEGY 91 * @returns { Promise<boolean> } The promise returned by the function. 92 * @throws { BusinessError } 201 - Permission denied. 93 * @throws { BusinessError } 202 - Non-system applications use system APIs. 94 * @throws { BusinessError } 401 - Parameter error. 95 * @throws { BusinessError } 2100001 - Invalid parameter value. 96 * @throws { BusinessError } 2100002 - Operation failed. Cannot connect to service. 97 * @throws { BusinessError } 2100003 - System internal error. 98 * @syscap SystemCapability.Communication.NetManager.Core 99 * @systemapi Hide this for inner system use. 100 * @since 10 101 */ 102 function isBackgroundAllowed(): Promise<boolean>; 103 104 /** 105 * Get the background network policy for the specified uid. 106 * @permission ohos.permission.MANAGE_NET_STRATEGY 107 * @param { number } uid - The specified UID of application. 108 * @param { AsyncCallback<NetBackgroundPolicy> } callback - the callback of getBackgroundPolicyByUid. 109 * @throws { BusinessError } 201 - Permission denied. 110 * @throws { BusinessError } 202 - Non-system applications use system APIs. 111 * @throws { BusinessError } 401 - Parameter error. 112 * @throws { BusinessError } 2100001 - Invalid parameter value. 113 * @throws { BusinessError } 2100002 - Operation failed. Cannot connect to service. 114 * @throws { BusinessError } 2100003 - System internal error. 115 * @syscap SystemCapability.Communication.NetManager.Core 116 * @systemapi Hide this for inner system use. 117 * @since 10 118 */ 119 function getBackgroundPolicyByUid(uid: number, callback: AsyncCallback<NetBackgroundPolicy>): void; 120 121 /** 122 * Get the background network policy for the specified uid. 123 * @permission ohos.permission.MANAGE_NET_STRATEGY 124 * @param { number } uid - The specified UID of application. 125 * @returns { Promise<NetBackgroundPolicy> } The promise returned by the function. 126 * @throws { BusinessError } 201 - Permission denied. 127 * @throws { BusinessError } 202 - Non-system applications use system APIs. 128 * @throws { BusinessError } 401 - Parameter error. 129 * @throws { BusinessError } 2100001 - Invalid parameter value. 130 * @throws { BusinessError } 2100002 - Operation failed. Cannot connect to service. 131 * @throws { BusinessError } 2100003 - System internal error. 132 * @syscap SystemCapability.Communication.NetManager.Core 133 * @systemapi Hide this for inner system use. 134 * @since 10 135 */ 136 function getBackgroundPolicyByUid(uid: number): Promise<NetBackgroundPolicy>; 137 138 /** 139 * Set the policy for the specified UID. 140 * @permission ohos.permission.MANAGE_NET_STRATEGY 141 * @param { number } uid - the specified UID of application. 142 * @param { NetUidPolicy } policy - the policy of the current UID of application.For details, see {@link NetUidPolicy}. 143 * @param { AsyncCallback<void> } callback - the callback of setPolicyByUid. 144 * @throws { BusinessError } 201 - Permission denied. 145 * @throws { BusinessError } 202 - Non-system applications use system APIs. 146 * @throws { BusinessError } 401 - Parameter error. 147 * @throws { BusinessError } 2100001 - Invalid parameter value. 148 * @throws { BusinessError } 2100002 - Operation failed. Cannot connect to service. 149 * @throws { BusinessError } 2100003 - System internal error. 150 * @syscap SystemCapability.Communication.NetManager.Core 151 * @systemapi Hide this for inner system use. 152 * @since 10 153 */ 154 function setPolicyByUid(uid: number, policy: NetUidPolicy, callback: AsyncCallback<void>): void; 155 156 /** 157 * Set the policy for the specified UID. 158 * @permission ohos.permission.MANAGE_NET_STRATEGY 159 * @param { number } uid - the specified UID of application. 160 * @param { NetUidPolicy } policy - the policy of the current UID of application.For details, see {@link NetUidPolicy}. 161 * @returns { Promise<void> } The promise returned by the function. 162 * @throws { BusinessError } 201 - Permission denied. 163 * @throws { BusinessError } 202 - Non-system applications use system APIs. 164 * @throws { BusinessError } 401 - Parameter error. 165 * @throws { BusinessError } 2100001 - Invalid parameter value. 166 * @throws { BusinessError } 2100002 - Operation failed. Cannot connect to service. 167 * @throws { BusinessError } 2100003 - System internal error. 168 * @syscap SystemCapability.Communication.NetManager.Core 169 * @systemapi Hide this for inner system use. 170 * @since 10 171 */ 172 function setPolicyByUid(uid: number, policy: NetUidPolicy): Promise<void>; 173 174 /** 175 * Query the policy of the specified UID. 176 * @permission ohos.permission.MANAGE_NET_STRATEGY 177 * @param { number } uid - the specified UID of application. 178 * @param { AsyncCallback<NetUidPolicy> } callback - the callback of getPolicyByUid. 179 * @throws { BusinessError } 201 - Permission denied. 180 * @throws { BusinessError } 202 - Non-system applications use system APIs. 181 * @throws { BusinessError } 401 - Parameter error. 182 * @throws { BusinessError } 2100001 - Invalid parameter value. 183 * @throws { BusinessError } 2100002 - Operation failed. Cannot connect to service. 184 * @throws { BusinessError } 2100003 - System internal error. 185 * @syscap SystemCapability.Communication.NetManager.Core 186 * @systemapi Hide this for inner system use. 187 * @since 10 188 */ 189 function getPolicyByUid(uid: number, callback: AsyncCallback<NetUidPolicy>): void; 190 191 /** 192 * Query the policy of the specified UID. 193 * @permission ohos.permission.MANAGE_NET_STRATEGY 194 * @param { number } uid - the specified UID of application. 195 * @returns { Promise<NetUidPolicy> } The promise returned by the function. 196 * @throws { BusinessError } 201 - Permission denied. 197 * @throws { BusinessError } 202 - Non-system applications use system APIs. 198 * @throws { BusinessError } 401 - Parameter error. 199 * @throws { BusinessError } 2100001 - Invalid parameter value. 200 * @throws { BusinessError } 2100002 - Operation failed. Cannot connect to service. 201 * @throws { BusinessError } 2100003 - System internal error. 202 * @syscap SystemCapability.Communication.NetManager.Core 203 * @systemapi Hide this for inner system use. 204 * @since 10 205 */ 206 function getPolicyByUid(uid: number): Promise<NetUidPolicy>; 207 208 /** 209 * Query the application UIDs of the specified policy. 210 * @permission ohos.permission.MANAGE_NET_STRATEGY 211 * @param { NetUidPolicy } policy - the policy of the current UID of application.For details, see {@link NetUidPolicy}. 212 * @param { AsyncCallback<Array<number>> } callback - the callback of getUidsByPolicy. 213 * @throws { BusinessError } 201 - Permission denied. 214 * @throws { BusinessError } 202 - Non-system applications use system APIs. 215 * @throws { BusinessError } 401 - Parameter error. 216 * @throws { BusinessError } 2100001 - Invalid parameter value. 217 * @throws { BusinessError } 2100002 - Operation failed. Cannot connect to service. 218 * @throws { BusinessError } 2100003 - System internal error. 219 * @syscap SystemCapability.Communication.NetManager.Core 220 * @systemapi Hide this for inner system use. 221 * @since 10 222 */ 223 function getUidsByPolicy(policy: NetUidPolicy, callback: AsyncCallback<Array<number>>): void; 224 225 /** 226 * Query the application UIDs of the specified policy. 227 * @permission ohos.permission.MANAGE_NET_STRATEGY 228 * @param { NetUidPolicy } policy - the policy of the current UID of application.For details, see {@link NetUidPolicy}. 229 * @returns { Promise<Array<number>> } The promise returned by the function. 230 * @throws { BusinessError } 201 - Permission denied. 231 * @throws { BusinessError } 202 - Non-system applications use system APIs. 232 * @throws { BusinessError } 401 - Parameter error. 233 * @throws { BusinessError } 2100001 - Invalid parameter value. 234 * @throws { BusinessError } 2100002 - Operation failed. Cannot connect to service. 235 * @throws { BusinessError } 2100003 - System internal error. 236 * @syscap SystemCapability.Communication.NetManager.Core 237 * @systemapi Hide this for inner system use. 238 * @since 10 239 */ 240 function getUidsByPolicy(policy: NetUidPolicy): Promise<Array<number>>; 241 242 /** 243 * Get the status whether the uid app can access the metered network or non-metered network. 244 * @permission ohos.permission.MANAGE_NET_STRATEGY 245 * @param { number } uid - The specified UID of application. 246 * @param { boolean } isMetered - Indicates metered network or non-metered network. 247 * @param { AsyncCallback<boolean> } callback - the callback of isUidNetAllowed. 248 * @throws { BusinessError } 201 - Permission denied. 249 * @throws { BusinessError } 202 - Non-system applications use system APIs. 250 * @throws { BusinessError } 401 - Parameter error. 251 * @throws { BusinessError } 2100001 - Invalid parameter value. 252 * @throws { BusinessError } 2100002 - Operation failed. Cannot connect to service. 253 * @throws { BusinessError } 2100003 - System internal error. 254 * @syscap SystemCapability.Communication.NetManager.Core 255 * @systemapi Hide this for inner system use. 256 * @since 10 257 */ 258 function isUidNetAllowed(uid: number, isMetered: boolean, callback: AsyncCallback<boolean>): void; 259 260 /** 261 * Get the status whether the uid app can access the metered network or non-metered network. 262 * @permission ohos.permission.MANAGE_NET_STRATEGY 263 * @param { number } uid - The specified UID of application. 264 * @param { boolean } isMetered - Indicates metered network or non-metered network. 265 * @returns { Promise<boolean> } The promise returned by the function. 266 * @throws { BusinessError } 201 - Permission denied. 267 * @throws { BusinessError } 202 - Non-system applications use system APIs. 268 * @throws { BusinessError } 401 - Parameter error. 269 * @throws { BusinessError } 2100001 - Invalid parameter value. 270 * @throws { BusinessError } 2100002 - Operation failed. Cannot connect to service. 271 * @throws { BusinessError } 2100003 - System internal error. 272 * @syscap SystemCapability.Communication.NetManager.Core 273 * @systemapi Hide this for inner system use. 274 * @since 10 275 */ 276 function isUidNetAllowed(uid: number, isMetered: boolean): Promise<boolean>; 277 278 /** 279 * Get the status of whether the specified uid can access the specified network. 280 * @permission ohos.permission.MANAGE_NET_STRATEGY 281 * @param { number } uid - The specified UID of application. 282 * @param { string } iface - The specified network interface name. 283 * @param { AsyncCallback<boolean> } callback - the callback of isUidNetAllowed. 284 * @throws { BusinessError } 201 - Permission denied. 285 * @throws { BusinessError } 202 - Non-system applications use system APIs. 286 * @throws { BusinessError } 401 - Parameter error. 287 * @throws { BusinessError } 2100001 - Invalid parameter value. 288 * @throws { BusinessError } 2100002 - Operation failed. Cannot connect to service. 289 * @throws { BusinessError } 2100003 - System internal error. 290 * @syscap SystemCapability.Communication.NetManager.Core 291 * @systemapi Hide this for inner system use. 292 * @since 10 293 */ 294 function isUidNetAllowed(uid: number, iface: string, callback: AsyncCallback<boolean>): void; 295 296 /** 297 * Get the status of whether the specified uid can access the specified network. 298 * @permission ohos.permission.MANAGE_NET_STRATEGY 299 * @param { number } uid - The specified UID of application. 300 * @param { string } iface - The specified network interface name. 301 * @returns { Promise<boolean> } The promise returned by the function. 302 * @throws { BusinessError } 201 - Permission denied. 303 * @throws { BusinessError } 202 - Non-system applications use system APIs. 304 * @throws { BusinessError } 401 - Parameter error. 305 * @throws { BusinessError } 2100001 - Invalid parameter value. 306 * @throws { BusinessError } 2100002 - Operation failed. Cannot connect to service. 307 * @throws { BusinessError } 2100003 - System internal error. 308 * @syscap SystemCapability.Communication.NetManager.Core 309 * @systemapi Hide this for inner system use. 310 * @since 10 311 */ 312 function isUidNetAllowed(uid: number, iface: string): Promise<boolean>; 313 314 /** 315 * Set metered network quota policies. 316 * @permission ohos.permission.MANAGE_NET_STRATEGY 317 * @param { Array<NetQuotaPolicy> } quotaPolicies - Indicates {@link NetQuotaPolicy}. 318 * @param { AsyncCallback<void> } callback - the callback of setNetQuotaPolicies. 319 * @throws { BusinessError } 201 - Permission denied. 320 * @throws { BusinessError } 202 - Non-system applications use system APIs. 321 * @throws { BusinessError } 401 - Parameter error. 322 * @throws { BusinessError } 2100001 - Invalid parameter value. 323 * @throws { BusinessError } 2100002 - Operation failed. Cannot connect to service. 324 * @throws { BusinessError } 2100003 - System internal error. 325 * @syscap SystemCapability.Communication.NetManager.Core 326 * @systemapi Hide this for inner system use. 327 * @since 10 328 */ 329 function setNetQuotaPolicies(quotaPolicies: Array<NetQuotaPolicy>, callback: AsyncCallback<void>): void; 330 331 /** 332 * Set metered network quota policies. 333 * @permission ohos.permission.MANAGE_NET_STRATEGY 334 * @param { Array<NetQuotaPolicy> } quotaPolicies - Indicates {@link NetQuotaPolicy}. 335 * @returns { Promise<void> } The promise returned by the function. 336 * @throws { BusinessError } 201 - Permission denied. 337 * @throws { BusinessError } 202 - Non-system applications use system APIs. 338 * @throws { BusinessError } 401 - Parameter error. 339 * @throws { BusinessError } 2100001 - Invalid parameter value. 340 * @throws { BusinessError } 2100002 - Operation failed. Cannot connect to service. 341 * @throws { BusinessError } 2100003 - System internal error. 342 * @syscap SystemCapability.Communication.NetManager.Core 343 * @systemapi Hide this for inner system use. 344 * @since 10 345 */ 346 function setNetQuotaPolicies(quotaPolicies: Array<NetQuotaPolicy>): Promise<void>; 347 348 /** 349 * Get metered network quota policies. 350 * @permission ohos.permission.MANAGE_NET_STRATEGY 351 * @param { AsyncCallback<Array<NetQuotaPolicy>> } callback - the callback of getNetQuotaPolicies. 352 * @throws { BusinessError } 201 - Permission denied. 353 * @throws { BusinessError } 202 - Non-system applications use system APIs. 354 * @throws { BusinessError } 401 - Parameter error. 355 * @throws { BusinessError } 2100001 - Invalid parameter value. 356 * @throws { BusinessError } 2100002 - Operation failed. Cannot connect to service. 357 * @throws { BusinessError } 2100003 - System internal error. 358 * @syscap SystemCapability.Communication.NetManager.Core 359 * @systemapi Hide this for inner system use. 360 * @since 10 361 */ 362 function getNetQuotaPolicies(callback: AsyncCallback<Array<NetQuotaPolicy>>): void; 363 364 /** 365 * Get metered network quota policies. 366 * @permission ohos.permission.MANAGE_NET_STRATEGY 367 * @returns { Promise<Array<NetQuotaPolicy>> } The promise returned by the function. 368 * @throws { BusinessError } 201 - Permission denied. 369 * @throws { BusinessError } 202 - Non-system applications use system APIs. 370 * @throws { BusinessError } 401 - Parameter error. 371 * @throws { BusinessError } 2100002 - Operation failed. Cannot connect to service. 372 * @throws { BusinessError } 2100003 - System internal error. 373 * @syscap SystemCapability.Communication.NetManager.Core 374 * @systemapi Hide this for inner system use. 375 * @since 10 376 */ 377 function getNetQuotaPolicies(): Promise<Array<NetQuotaPolicy>>; 378 379 /** 380 * Update the policy when the quota reaches the upper limit. 381 * @permission ohos.permission.MANAGE_NET_STRATEGY 382 * @param { NetBearType } netType - {@link NetBearType}. 383 * @param { string } simId - Specify the matched simId of quota policy when netType is cellular. 384 * @param { RemindType } remindType - {@link RemindType}. 385 * @param { AsyncCallback<void> } callback - the callback of updateRemindPolicy. 386 * @throws { BusinessError } 201 - Permission denied. 387 * @throws { BusinessError } 202 - Non-system applications use system APIs. 388 * @throws { BusinessError } 401 - Parameter error. 389 * @throws { BusinessError } 2100001 - Invalid parameter value. 390 * @throws { BusinessError } 2100002 - Operation failed. Cannot connect to service. 391 * @throws { BusinessError } 2100003 - System internal error. 392 * @syscap SystemCapability.Communication.NetManager.Core 393 * @systemapi Hide this for inner system use. 394 * @since 10 395 */ 396 function updateRemindPolicy(netType: NetBearType, simId: string, remindType: RemindType, callback: AsyncCallback<void>): void; 397 398 /** 399 * Update the policy when the quota reaches the upper limit. 400 * @permission ohos.permission.MANAGE_NET_STRATEGY 401 * @param { NetBearType } netType - {@link NetBearType}. 402 * @param { string } simId - Specify the matched simId of quota policy when netType is cellular. 403 * @param { RemindType } remindType - {@link RemindType}. 404 * @returns { Promise<void> } The promise returned by the function. 405 * @throws { BusinessError } 201 - Permission denied. 406 * @throws { BusinessError } 202 - Non-system applications use system APIs. 407 * @throws { BusinessError } 401 - Parameter error. 408 * @throws { BusinessError } 2100001 - Invalid parameter value. 409 * @throws { BusinessError } 2100002 - Operation failed. Cannot connect to service. 410 * @throws { BusinessError } 2100003 - System internal error. 411 * @syscap SystemCapability.Communication.NetManager.Core 412 * @systemapi Hide this for inner system use. 413 * @since 10 414 */ 415 function updateRemindPolicy(netType: NetBearType, simId: string, remindType: RemindType): Promise<void>; 416 417 /** 418 * Set the list of uids that are allowed to access the Internet in hibernation mode. 419 * @permission ohos.permission.MANAGE_NET_STRATEGY 420 * @param { Array<number> } uids - The specified uids of application. 421 * @param { boolean } isAllowed - Whether to allow Uids in the list to access the Internet. 422 * @param { AsyncCallback<void> } callback - the callback of setDeviceIdleTrustlist. 423 * @throws { BusinessError } 201 - Permission denied. 424 * @throws { BusinessError } 202 - Non-system applications use system APIs. 425 * @throws { BusinessError } 401 - Parameter error. 426 * @throws { BusinessError } 2100001 - Invalid parameter value. 427 * @throws { BusinessError } 2100002 - Operation failed. Cannot connect to service. 428 * @throws { BusinessError } 2100003 - System internal error. 429 * @syscap SystemCapability.Communication.NetManager.Core 430 * @systemapi Hide this for inner system use. 431 * @since 10 432 */ 433 function setDeviceIdleTrustlist(uids: Array<number>, isAllowed: boolean, callback: AsyncCallback<void>): void; 434 435 /** 436 * Set the list of uids that are allowed to access the Internet in hibernation mode. 437 * @permission ohos.permission.MANAGE_NET_STRATEGY 438 * @param { Array<number> } uids - The specified uids of application. 439 * @param { boolean } isAllowed - Whether to allow Uids in the list to access the Internet. 440 * @returns { Promise<void> } The promise returned by the function. 441 * @throws { BusinessError } 201 - Permission denied. 442 * @throws { BusinessError } 202 - Non-system applications use system APIs. 443 * @throws { BusinessError } 401 - Parameter error. 444 * @throws { BusinessError } 2100001 - Invalid parameter value. 445 * @throws { BusinessError } 2100002 - Operation failed. Cannot connect to service. 446 * @throws { BusinessError } 2100003 - System internal error. 447 * @syscap SystemCapability.Communication.NetManager.Core 448 * @systemapi Hide this for inner system use. 449 * @since 10 450 */ 451 function setDeviceIdleTrustlist(uids: Array<number>, isAllowed: boolean): Promise<void>; 452 453 /** 454 * Obtain the list of uids that are allowed to access the Internet in hibernation mode. 455 * @permission ohos.permission.MANAGE_NET_STRATEGY 456 * @param { AsyncCallback<Array<number>> } callback - the callback of getDeviceIdleTrustlist. 457 * @throws { BusinessError } 201 - Permission denied. 458 * @throws { BusinessError } 202 - Non-system applications use system APIs. 459 * @throws { BusinessError } 401 - Parameter error. 460 * @throws { BusinessError } 2100001 - Invalid parameter value. 461 * @throws { BusinessError } 2100002 - Operation failed. Cannot connect to service. 462 * @throws { BusinessError } 2100003 - System internal error. 463 * @syscap SystemCapability.Communication.NetManager.Core 464 * @systemapi Hide this for inner system use. 465 * @since 10 466 */ 467 function getDeviceIdleTrustlist(callback: AsyncCallback<Array<number>>): void; 468 469 /** 470 * Obtain the list of uids that are allowed to access the Internet in hibernation mode. 471 * @permission ohos.permission.MANAGE_NET_STRATEGY 472 * @returns { Promise<Array<number>> } The promise returned by the function. 473 * @throws { BusinessError } 201 - Permission denied. 474 * @throws { BusinessError } 202 - Non-system applications use system APIs. 475 * @throws { BusinessError } 401 - Parameter error. 476 * @throws { BusinessError } 2100002 - Operation failed. Cannot connect to service. 477 * @throws { BusinessError } 2100003 - System internal error. 478 * @syscap SystemCapability.Communication.NetManager.Core 479 * @systemapi Hide this for inner system use. 480 * @since 10 481 */ 482 function getDeviceIdleTrustlist(): Promise<Array<number>>; 483 484 /** 485 * Set the list of uids that are allowed to access the Internet in power saving mode. 486 * @permission ohos.permission.MANAGE_NET_STRATEGY 487 * @param { Array<number> } uids - The specified uids of application. 488 * @param { boolean } isAllowed - Whether to allow Uids in the list to access the Internet. 489 * @param { AsyncCallback<void> } callback - the callback of setPowerSaveTrustlist. 490 * @throws { BusinessError } 201 - Permission denied. 491 * @throws { BusinessError } 202 - Non-system applications use system APIs. 492 * @throws { BusinessError } 401 - Parameter error. 493 * @throws { BusinessError } 2100001 - Invalid parameter value. 494 * @throws { BusinessError } 2100002 - Operation failed. Cannot connect to service. 495 * @throws { BusinessError } 2100003 - System internal error. 496 * @syscap SystemCapability.Communication.NetManager.Core 497 * @systemapi Hide this for inner system use. 498 * @since 10 499 */ 500 function setPowerSaveTrustlist(uids: Array<number>, isAllowed: boolean, callback: AsyncCallback<void>): void; 501 502 /** 503 * Set the list of uids that are allowed to access the Internet in power saving mode. 504 * @permission ohos.permission.MANAGE_NET_STRATEGY 505 * @param { Array<number> } uids - The specified uids of application. 506 * @param { boolean } isAllowed - Whether to allow Uids in the list to access the Internet. 507 * @returns { Promise<void> } The promise returned by the function. 508 * @throws { BusinessError } 201 - Permission denied. 509 * @throws { BusinessError } 202 - Non-system applications use system APIs. 510 * @throws { BusinessError } 401 - Parameter error. 511 * @throws { BusinessError } 2100001 - Invalid parameter value. 512 * @throws { BusinessError } 2100002 - Operation failed. Cannot connect to service. 513 * @throws { BusinessError } 2100003 - System internal error. 514 * @syscap SystemCapability.Communication.NetManager.Core 515 * @systemapi Hide this for inner system use. 516 * @since 10 517 */ 518 function setPowerSaveTrustlist(uids: Array<number>, isAllowed: boolean): Promise<void>; 519 520 /** 521 * Obtain the list of uids that are allowed to access the Internet in power saving mode. 522 * @permission ohos.permission.MANAGE_NET_STRATEGY 523 * @param { AsyncCallback<Array<number>> } callback - the callback of UIDs list. 524 * @throws { BusinessError } 201 - Permission denied. 525 * @throws { BusinessError } 202 - Non-system applications use system APIs. 526 * @throws { BusinessError } 401 - Parameter error. 527 * @throws { BusinessError } 2100001 - Invalid parameter value. 528 * @throws { BusinessError } 2100002 - Operation failed. Cannot connect to service. 529 * @throws { BusinessError } 2100003 - System internal error. 530 * @syscap SystemCapability.Communication.NetManager.Core 531 * @systemapi Hide this for inner system use. 532 * @since 10 533 */ 534 function getPowerSaveTrustlist(callback: AsyncCallback<Array<number>>): void; 535 536 /** 537 * Obtain the list of uids that are allowed to access the Internet in power saving mode. 538 * @permission ohos.permission.MANAGE_NET_STRATEGY 539 * @returns { Promise<Array<number>> } The promise returned by the function. 540 * @throws { BusinessError } 201 - Permission denied. 541 * @throws { BusinessError } 202 - Non-system applications use system APIs. 542 * @throws { BusinessError } 401 - Parameter error. 543 * @throws { BusinessError } 2100002 - Operation failed. Cannot connect to service. 544 * @throws { BusinessError } 2100003 - System internal error. 545 * @syscap SystemCapability.Communication.NetManager.Core 546 * @systemapi Hide this for inner system use. 547 * @since 10 548 */ 549 function getPowerSaveTrustlist(): Promise<Array<number>>; 550 551 /** 552 * Reset network policies\rules\quota policies\firewall rules. 553 * @permission ohos.permission.MANAGE_NET_STRATEGY 554 * @param { string } simId - Specify the matched simId of quota policy. 555 * @param { AsyncCallback<void> } callback - the callback of resetPolicies. 556 * @throws { BusinessError } 201 - Permission denied. 557 * @throws { BusinessError } 202 - Non-system applications use system APIs. 558 * @throws { BusinessError } 401 - Parameter error. 559 * @throws { BusinessError } 2100001 - Invalid parameter value. 560 * @throws { BusinessError } 2100002 - Operation failed. Cannot connect to service. 561 * @throws { BusinessError } 2100003 - System internal error. 562 * @syscap SystemCapability.Communication.NetManager.Core 563 * @systemapi Hide this for inner system use. 564 * @since 10 565 */ 566 function resetPolicies(simId: string, callback: AsyncCallback<void>): void; 567 568 /** 569 * Reset network policies\rules\quota policies\firewall rules. 570 * @permission ohos.permission.MANAGE_NET_STRATEGY 571 * @param { string } simId - Specify the matched simId of quota policy. 572 * @returns { Promise<void> } The promise returned by the function. 573 * @throws { BusinessError } 201 - Permission denied. 574 * @throws { BusinessError } 202 - Non-system applications use system APIs. 575 * @throws { BusinessError } 401 - Parameter error. 576 * @throws { BusinessError } 2100001 - Invalid parameter value. 577 * @throws { BusinessError } 2100002 - Operation failed. Cannot connect to service. 578 * @throws { BusinessError } 2100003 - System internal error. 579 * @syscap SystemCapability.Communication.NetManager.Core 580 * @systemapi Hide this for inner system use. 581 * @since 10 582 */ 583 function resetPolicies(simId: string): Promise<void>; 584 585 /** 586 * Register uid policy change listener. 587 * @permission ohos.permission.MANAGE_NET_STRATEGY 588 * @param { 'netUidPolicyChange' } type - Indicates Event name. 589 * @param { Callback<{ uid: number, policy: NetUidPolicy }> } callback - the callback of on. 590 * @throws { BusinessError } 201 - Permission denied. 591 * @throws { BusinessError } 202 - Non-system applications use system APIs. 592 * @throws { BusinessError } 401 - Parameter error. 593 * @throws { BusinessError } 2100001 - Invalid parameter value. 594 * @throws { BusinessError } 2100002 - Operation failed. Cannot connect to service. 595 * @throws { BusinessError } 2100003 - System internal error. 596 * @syscap SystemCapability.Communication.NetManager.Core 597 * @systemapi Hide this for inner system use. 598 * @since 10 599 */ 600 /** 601 * Register uid policy change listener. 602 * @permission ohos.permission.MANAGE_NET_STRATEGY 603 * @param { 'netUidPolicyChange' } type - Indicates Event name. 604 * @param { Callback<NetUidPolicyInfo> } callback - the callback of on. 605 * @throws { BusinessError } 201 - Permission denied. 606 * @throws { BusinessError } 202 - Non-system applications use system APIs. 607 * @throws { BusinessError } 401 - Parameter error. 608 * @throws { BusinessError } 2100001 - Invalid parameter value. 609 * @throws { BusinessError } 2100002 - Operation failed. Cannot connect to service. 610 * @throws { BusinessError } 2100003 - System internal error. 611 * @syscap SystemCapability.Communication.NetManager.Core 612 * @systemapi Hide this for inner system use. 613 * @since 11 614 */ 615 function on(type: 'netUidPolicyChange', callback: Callback<NetUidPolicyInfo>): void; 616 617 /** 618 * Unregister uid policy change listener. 619 * @permission ohos.permission.MANAGE_NET_STRATEGY 620 * @param { 'netUidPolicyChange' } type - Indicates Event name. 621 * @param { Callback<{ uid: number, policy: NetUidPolicy }> } callback - the callback of off. 622 * @throws { BusinessError } 201 - Permission denied. 623 * @throws { BusinessError } 202 - Non-system applications use system APIs. 624 * @throws { BusinessError } 401 - Parameter error. 625 * @throws { BusinessError } 2100001 - Invalid parameter value. 626 * @throws { BusinessError } 2100002 - Operation failed. Cannot connect to service. 627 * @throws { BusinessError } 2100003 - System internal error. 628 * @syscap SystemCapability.Communication.NetManager.Core 629 * @systemapi Hide this for inner system use. 630 * @since 10 631 */ 632 /** 633 * Unregister uid policy change listener. 634 * @permission ohos.permission.MANAGE_NET_STRATEGY 635 * @param { 'netUidPolicyChange' } type - Indicates Event name. 636 * @param { Callback<NetUidPolicyInfo> } callback - the callback of off. 637 * @throws { BusinessError } 201 - Permission denied. 638 * @throws { BusinessError } 202 - Non-system applications use system APIs. 639 * @throws { BusinessError } 401 - Parameter error. 640 * @throws { BusinessError } 2100001 - Invalid parameter value. 641 * @throws { BusinessError } 2100002 - Operation failed. Cannot connect to service. 642 * @throws { BusinessError } 2100003 - System internal error. 643 * @syscap SystemCapability.Communication.NetManager.Core 644 * @systemapi Hide this for inner system use. 645 * @since 11 646 */ 647 function off(type: 'netUidPolicyChange', callback?: Callback<NetUidPolicyInfo>): void; 648 649 /** 650 * Register uid rule change listener. 651 * @permission ohos.permission.MANAGE_NET_STRATEGY 652 * @param { 'netUidRuleChange' } type - Indicates Event name. 653 * @param { Callback<{ uid: number, rule: NetUidRule }> } callback - the callback of on. 654 * @throws { BusinessError } 201 - Permission denied. 655 * @throws { BusinessError } 202 - Non-system applications use system APIs. 656 * @throws { BusinessError } 401 - Parameter error. 657 * @throws { BusinessError } 2100001 - Invalid parameter value. 658 * @throws { BusinessError } 2100002 - Operation failed. Cannot connect to service. 659 * @throws { BusinessError } 2100003 - System internal error. 660 * @syscap SystemCapability.Communication.NetManager.Core 661 * @systemapi Hide this for inner system use. 662 * @since 10 663 */ 664 /** 665 * Register uid rule change listener. 666 * @permission ohos.permission.MANAGE_NET_STRATEGY 667 * @param { 'netUidRuleChange' } type - Indicates Event name. 668 * @param { Callback<NetUidRuleInfo> } callback - the callback of on. 669 * @throws { BusinessError } 201 - Permission denied. 670 * @throws { BusinessError } 202 - Non-system applications use system APIs. 671 * @throws { BusinessError } 401 - Parameter error. 672 * @throws { BusinessError } 2100001 - Invalid parameter value. 673 * @throws { BusinessError } 2100002 - Operation failed. Cannot connect to service. 674 * @throws { BusinessError } 2100003 - System internal error. 675 * @syscap SystemCapability.Communication.NetManager.Core 676 * @systemapi Hide this for inner system use. 677 * @since 11 678 */ 679 function on(type: 'netUidRuleChange', callback: Callback<NetUidRuleInfo>): void; 680 681 /** 682 * Unregister uid rule change listener. 683 * @permission ohos.permission.MANAGE_NET_STRATEGY 684 * @param { 'netUidRuleChange' } type - Indicates Event name. 685 * @param { Callback<{ uid: number, rule: NetUidRule }> } callback - the callback of off. 686 * @throws { BusinessError } 201 - Permission denied. 687 * @throws { BusinessError } 202 - Non-system applications use system APIs. 688 * @throws { BusinessError } 401 - Parameter error. 689 * @throws { BusinessError } 2100001 - Invalid parameter value. 690 * @throws { BusinessError } 2100002 - Operation failed. Cannot connect to service. 691 * @throws { BusinessError } 2100003 - System internal error. 692 * @syscap SystemCapability.Communication.NetManager.Core 693 * @systemapi Hide this for inner system use. 694 * @since 10 695 */ 696 /** 697 * Unregister uid rule change listener. 698 * @permission ohos.permission.MANAGE_NET_STRATEGY 699 * @param { 'netUidRuleChange' } type - Indicates Event name. 700 * @param { Callback<NetUidRuleInfo> } callback - the callback of off. 701 * @throws { BusinessError } 201 - Permission denied. 702 * @throws { BusinessError } 202 - Non-system applications use system APIs. 703 * @throws { BusinessError } 401 - Parameter error. 704 * @throws { BusinessError } 2100001 - Invalid parameter value. 705 * @throws { BusinessError } 2100002 - Operation failed. Cannot connect to service. 706 * @throws { BusinessError } 2100003 - System internal error. 707 * @syscap SystemCapability.Communication.NetManager.Core 708 * @systemapi Hide this for inner system use. 709 * @since 11 710 */ 711 function off(type: 'netUidRuleChange', callback?: Callback<NetUidRuleInfo>): void; 712 713 /** 714 * Register metered ifaces change listener. 715 * @permission ohos.permission.MANAGE_NET_STRATEGY 716 * @param { 'netMeteredIfacesChange' } type - Indicates Event name. 717 * @param { Callback<Array<string>> } callback - the callback of on. 718 * @throws { BusinessError } 201 - Permission denied. 719 * @throws { BusinessError } 202 - Non-system applications use system APIs. 720 * @throws { BusinessError } 401 - Parameter error. 721 * @throws { BusinessError } 2100001 - Invalid parameter value. 722 * @throws { BusinessError } 2100002 - Operation failed. Cannot connect to service. 723 * @throws { BusinessError } 2100003 - System internal error. 724 * @syscap SystemCapability.Communication.NetManager.Core 725 * @systemapi Hide this for inner system use. 726 * @since 10 727 */ 728 function on(type: 'netMeteredIfacesChange', callback: Callback<Array<string>>): void; 729 730 /** 731 * Unregister metered ifaces change listener. 732 * @permission ohos.permission.MANAGE_NET_STRATEGY 733 * @param { 'netMeteredIfacesChange' } type - Indicates Event name. 734 * @param { Callback<Array<string>> } callback - the callback of off. 735 * @throws { BusinessError } 201 - Permission denied. 736 * @throws { BusinessError } 202 - Non-system applications use system APIs. 737 * @throws { BusinessError } 401 - Parameter error. 738 * @throws { BusinessError } 2100001 - Invalid parameter value. 739 * @throws { BusinessError } 2100002 - Operation failed. Cannot connect to service. 740 * @throws { BusinessError } 2100003 - System internal error. 741 * @syscap SystemCapability.Communication.NetManager.Core 742 * @systemapi Hide this for inner system use. 743 * @since 10 744 */ 745 function off(type: 'netMeteredIfacesChange', callback?: Callback<Array<string>>): void; 746 747 /** 748 * Register quota policies change listener. 749 * @permission ohos.permission.MANAGE_NET_STRATEGY 750 * @param { 'netQuotaPolicyChange' } type - Indicates Event name. 751 * @param { Callback<Array<NetQuotaPolicy>> } callback the callback of on. 752 * @throws { BusinessError } 201 - Permission denied. 753 * @throws { BusinessError } 202 - Non-system applications use system APIs. 754 * @throws { BusinessError } 401 - Parameter error. 755 * @throws { BusinessError } 2100001 - Invalid parameter value. 756 * @throws { BusinessError } 2100002 - Operation failed. Cannot connect to service. 757 * @throws { BusinessError } 2100003 - System internal error. 758 * @syscap SystemCapability.Communication.NetManager.Core 759 * @systemapi Hide this for inner system use. 760 * @since 10 761 */ 762 function on(type: 'netQuotaPolicyChange', callback: Callback<Array<NetQuotaPolicy>>): void; 763 764 /** 765 * Unregister quota policies change listener. 766 * @permission ohos.permission.MANAGE_NET_STRATEGY 767 * @param { 'netQuotaPolicyChange' } type - Indicates Event name. 768 * @param { Callback<Array<NetQuotaPolicy>> } callback - the callback of off. 769 * @throws { BusinessError } 201 - Permission denied. 770 * @throws { BusinessError } 202 - Non-system applications use system APIs. 771 * @throws { BusinessError } 401 - Parameter error. 772 * @throws { BusinessError } 2100001 - Invalid parameter value. 773 * @throws { BusinessError } 2100002 - Operation failed. Cannot connect to service. 774 * @throws { BusinessError } 2100003 - System internal error. 775 * @syscap SystemCapability.Communication.NetManager.Core 776 * @systemapi Hide this for inner system use. 777 * @since 10 778 */ 779 function off(type: 'netQuotaPolicyChange', callback?: Callback<Array<NetQuotaPolicy>>): void; 780 781 /** 782 * Register network background policy change listener. 783 * @permission ohos.permission.MANAGE_NET_STRATEGY 784 * @param { 'netBackgroundPolicyChange' } type - Indicates Event name. 785 * @param { Callback<boolean> } callback - the callback of on. 786 * @throws { BusinessError } 201 - Permission denied. 787 * @throws { BusinessError } 202 - Non-system applications use system APIs. 788 * @throws { BusinessError } 401 - Parameter error. 789 * @throws { BusinessError } 2100001 - Invalid parameter value. 790 * @throws { BusinessError } 2100002 - Operation failed. Cannot connect to service. 791 * @throws { BusinessError } 2100003 - System internal error. 792 * @syscap SystemCapability.Communication.NetManager.Core 793 * @systemapi Hide this for inner system use. 794 * @since 10 795 */ 796 function on(type: 'netBackgroundPolicyChange', callback: Callback<boolean>): void; 797 798 /** 799 * Unregister network background policy change listener. 800 * @permission ohos.permission.MANAGE_NET_STRATEGY 801 * @param { 'netBackgroundPolicyChange' } type - Indicates Event name. 802 * @param { Callback<boolean> } callback - the callback of off. 803 * @throws { BusinessError } 201 - Permission denied. 804 * @throws { BusinessError } 202 - Non-system applications use system APIs. 805 * @throws { BusinessError } 401 - Parameter error. 806 * @throws { BusinessError } 2100001 - Invalid parameter value. 807 * @throws { BusinessError } 2100002 - Operation failed. Cannot connect to service. 808 * @throws { BusinessError } 2100003 - System internal error. 809 * @syscap SystemCapability.Communication.NetManager.Core 810 * @systemapi Hide this for inner system use. 811 * @since 10 812 */ 813 function off(type: 'netBackgroundPolicyChange', callback?: Callback<boolean>): void; 814 815 /** 816 * Indicate whether the application can use metered networks in background. 817 * @enum {number} 818 * @syscap SystemCapability.Communication.NetManager.Core 819 * @systemapi Hide this for inner system use. 820 * @since 10 821 */ 822 export enum NetBackgroundPolicy { 823 /** 824 * Default value. 825 * @syscap SystemCapability.Communication.NetManager.Core 826 * @systemapi Hide this for inner system use. 827 * @since 10 828 */ 829 NET_BACKGROUND_POLICY_NONE = 0, 830 831 /** 832 * Apps can use metered networks on background. 833 * @syscap SystemCapability.Communication.NetManager.Core 834 * @systemapi Hide this for inner system use. 835 * @since 10 836 */ 837 NET_BACKGROUND_POLICY_ENABLE = 1, 838 839 /** 840 * Apps can't use metered networks on background. 841 * @syscap SystemCapability.Communication.NetManager.Core 842 * @systemapi Hide this for inner system use. 843 * @since 10 844 */ 845 NET_BACKGROUND_POLICY_DISABLE = 2, 846 847 /** 848 * Only apps in trustlist can use metered networks on background. 849 * @syscap SystemCapability.Communication.NetManager.Core 850 * @systemapi Hide this for inner system use. 851 * @since 10 852 */ 853 NET_BACKGROUND_POLICY_TRUSTLIST = 3, 854 } 855 856 /** 857 * Net quota policies, including matching network rule usage periods, restrictions, and warnings. 858 * @interface NetQuotaPolicy 859 * @syscap SystemCapability.Communication.NetManager.Core 860 * @systemapi Hide this for inner system use. 861 * @since 10 862 */ 863 export interface NetQuotaPolicy { 864 /** 865 * The matching rules of network quota policies. 866 * @type {NetworkMatchRule} 867 * @syscap SystemCapability.Communication.NetManager.Core 868 * @systemapi Hide this for inner system use. 869 * @since 10 870 */ 871 networkMatchRule: NetworkMatchRule; 872 873 /** 874 * Policies that limit network quota. 875 * @type {QuotaPolicy} 876 * @syscap SystemCapability.Communication.NetManager.Core 877 * @systemapi Hide this for inner system use. 878 * @since 10 879 */ 880 quotaPolicy: QuotaPolicy; 881 } 882 883 /** 884 * Policies that limit network quota. 885 * @interface QuotaPolicy 886 * @syscap SystemCapability.Communication.NetManager.Core 887 * @systemapi Hide this for inner system use. 888 * @since 10 889 */ 890 export interface QuotaPolicy { 891 /** 892 * The period and the start time for quota policy, default: "M1" (Monthly cycle). 893 * @type {string} 894 * @syscap SystemCapability.Communication.NetManager.Core 895 * @systemapi Hide this for inner system use. 896 * @since 10 897 */ 898 periodDuration: string; 899 900 /** 901 * The warning threshold of traffic, default: DATA_USAGE_UNKNOWN. 902 * @type {number} 903 * @syscap SystemCapability.Communication.NetManager.Core 904 * @systemapi Hide this for inner system use. 905 * @since 10 906 */ 907 warningBytes: number; 908 909 /** 910 * The limit threshold of traffic, default: DATA_USAGE_UNKNOWN. 911 * @type {number} 912 * @syscap SystemCapability.Communication.NetManager.Core 913 * @systemapi Hide this for inner system use. 914 * @since 10 915 */ 916 limitBytes: number; 917 918 /** 919 * Is metered network or not. 920 * @type {boolean} 921 * @syscap SystemCapability.Communication.NetManager.Core 922 * @systemapi Hide this for inner system use. 923 * @since 10 924 */ 925 metered: boolean; 926 927 /** 928 * The action while the used bytes reach the limit, see {@link LimitAction}. 929 * @type {LimitAction} 930 * @syscap SystemCapability.Communication.NetManager.Core 931 * @systemapi Hide this for inner system use. 932 * @since 10 933 */ 934 limitAction: LimitAction; 935 936 /** 937 * The time of the last warning reminder. For notifying only, default: REMIND_NEVER. 938 * @type {?number} 939 * @syscap SystemCapability.Communication.NetManager.Core 940 * @systemapi Hide this for inner system use. 941 * @since 10 942 */ 943 lastWarningRemind?: number; 944 945 /** 946 * The time of the last limit reminder. For notifying only, default: REMIND_NEVER. 947 * @type {?number} 948 * @syscap SystemCapability.Communication.NetManager.Core 949 * @systemapi Hide this for inner system use. 950 * @since 10 951 */ 952 lastLimitRemind?: number; 953 } 954 955 /** 956 * The matching rules of network quota policies. 957 * @interface NetworkMatchRule 958 * @syscap SystemCapability.Communication.NetManager.Core 959 * @systemapi Hide this for inner system use. 960 * @since 10 961 */ 962 export interface NetworkMatchRule { 963 /** 964 * netType see {@link NetBearType}. 965 * @type {NetBearType} 966 * @syscap SystemCapability.Communication.NetManager.Core 967 * @systemapi Hide this for inner system use. 968 * @since 10 969 */ 970 netType: NetBearType; 971 972 /** 973 * To specify the identity of network, such as different WLAN. 974 * @type {string} 975 * @syscap SystemCapability.Communication.NetManager.Core 976 * @systemapi Hide this for inner system use. 977 * @since 10 978 */ 979 identity: string; 980 981 /** 982 * The ID of the target card, valid when netType is BEARER_CELLULAR. 983 * @type {string} 984 * @syscap SystemCapability.Communication.NetManager.Core 985 * @systemapi Hide this for inner system use. 986 * @since 10 987 */ 988 simId: string; 989 } 990 991 /** 992 * The interface is used to generate network unique identifiers. 993 * @interface NetUidRuleInfo 994 * @syscap SystemCapability.Communication.NetManager.Core 995 * @systemapi Hide this for inner system use. 996 * @since 11 997 */ 998 export interface NetUidRuleInfo { 999 /** 1000 * The warning threshold of traffic, default: DATA_USAGE_UNKNOWN. 1001 * @type { number } 1002 * @syscap SystemCapability.Communication.NetManager.Core 1003 * @systemapi Hide this for inner system use. 1004 * @since 11 1005 */ 1006 uid: number; 1007 /** 1008 * Rules whether an uid can access to a metered or non-metered network. 1009 * @type { NetUidRule } 1010 * @syscap SystemCapability.Communication.NetManager.Core 1011 * @systemapi Hide this for inner system use. 1012 * @since 11 1013 */ 1014 rule: NetUidRule; 1015 } 1016 1017 /** 1018 * Callback function for registering network UID policy changes. 1019 * @interface NetUidPolicyInfo 1020 * @syscap SystemCapability.Communication.NetManager.Core 1021 * @systemapi Hide this for inner system use. 1022 * @since 11 1023 */ 1024 export interface NetUidPolicyInfo { 1025 /** 1026 * The warning threshold of traffic, default: DATA_USAGE_UNKNOWN. 1027 * @type { number } 1028 * @syscap SystemCapability.Communication.NetManager.Core 1029 * @systemapi Hide this for inner system use. 1030 * @since 11 1031 */ 1032 uid: number; 1033 /** 1034 * Uid Specifies the Internet access policy in background mode. 1035 * @type { NetUidPolicy } 1036 * @syscap SystemCapability.Communication.NetManager.Core 1037 * @systemapi Hide this for inner system use. 1038 * @since 11 1039 */ 1040 policy: NetUidPolicy; 1041 } 1042 1043 /** 1044 * The action when quota policy hit the limit. 1045 * @enum {number} 1046 * @syscap SystemCapability.Communication.NetManager.Core 1047 * @systemapi Hide this for inner system use. 1048 * @since 10 1049 */ 1050 export enum LimitAction { 1051 /** 1052 * Default action, do nothing. 1053 * @syscap SystemCapability.Communication.NetManager.Core 1054 * @systemapi Hide this for inner system use. 1055 * @since 10 1056 */ 1057 LIMIT_ACTION_NONE = -1, 1058 1059 /** 1060 * When the quota policy reaches the limit, the system prohibits users from accessing the network. 1061 * @syscap SystemCapability.Communication.NetManager.Core 1062 * @systemapi Hide this for inner system use. 1063 * @since 10 1064 */ 1065 LIMIT_ACTION_ACCESS_DISABLED = 0, 1066 1067 /** 1068 * When the quota policy reaches the upper limit, the system notifies the user. 1069 * @syscap SystemCapability.Communication.NetManager.Core 1070 * @systemapi Hide this for inner system use. 1071 * @since 10 1072 */ 1073 LIMIT_ACTION_ALERT_ONLY = 1, 1074 } 1075 1076 /** 1077 * Rules whether an uid can access to a metered or non-metered network. 1078 * @enum {number} 1079 * @syscap SystemCapability.Communication.NetManager.Core 1080 * @systemapi Hide this for inner system use. 1081 * @since 10 1082 */ 1083 export enum NetUidRule { 1084 /** 1085 * Default uid rule. 1086 * @syscap SystemCapability.Communication.NetManager.Core 1087 * @systemapi Hide this for inner system use. 1088 * @since 10 1089 */ 1090 NET_RULE_NONE = 0, 1091 1092 /** 1093 * Allow traffic on metered networks while app is foreground. 1094 * @syscap SystemCapability.Communication.NetManager.Core 1095 * @systemapi Hide this for inner system use. 1096 * @since 10 1097 */ 1098 NET_RULE_ALLOW_METERED_FOREGROUND = 1 << 0, 1099 1100 /** 1101 * Allow traffic on metered network. 1102 * @syscap SystemCapability.Communication.NetManager.Core 1103 * @systemapi Hide this for inner system use. 1104 * @since 10 1105 */ 1106 NET_RULE_ALLOW_METERED = 1 << 1, 1107 1108 /** 1109 * Reject traffic on metered network. 1110 * @syscap SystemCapability.Communication.NetManager.Core 1111 * @systemapi Hide this for inner system use. 1112 * @since 10 1113 */ 1114 NET_RULE_REJECT_METERED = 1 << 2, 1115 1116 /** 1117 * Allow traffic on all network (metered or non-metered). 1118 * @syscap SystemCapability.Communication.NetManager.Core 1119 * @systemapi Hide this for inner system use. 1120 * @since 10 1121 */ 1122 NET_RULE_ALLOW_ALL = 1 << 5, 1123 1124 /** 1125 * Reject traffic on all network. 1126 * @syscap SystemCapability.Communication.NetManager.Core 1127 * @systemapi Hide this for inner system use. 1128 * @since 10 1129 */ 1130 NET_RULE_REJECT_ALL = 1 << 6, 1131 } 1132 1133 /** 1134 * Specify the remind type, see {@link updateRemindPolicy}. 1135 * @enum {number} 1136 * @syscap SystemCapability.Communication.NetManager.Core 1137 * @systemapi Hide this for inner system use. 1138 * @since 10 1139 */ 1140 export enum RemindType { 1141 /** 1142 * Warning alerts when the limit is reached. 1143 * @syscap SystemCapability.Communication.NetManager.Core 1144 * @systemapi Hide this for inner system use. 1145 * @since 10 1146 */ 1147 REMIND_TYPE_WARNING = 1, 1148 1149 /** 1150 * Limit alerts when the limit is reached. 1151 * @syscap SystemCapability.Communication.NetManager.Core 1152 * @systemapi Hide this for inner system use. 1153 * @since 10 1154 */ 1155 REMIND_TYPE_LIMIT = 2, 1156 } 1157 1158 /** 1159 * Uid Specifies the Internet access policy in background mode. 1160 * @enum {number} 1161 * @syscap SystemCapability.Communication.NetManager.Core 1162 * @systemapi Hide this for inner system use. 1163 * @since 10 1164 */ 1165 export enum NetUidPolicy { 1166 /** 1167 * Default net policy. 1168 * @syscap SystemCapability.Communication.NetManager.Core 1169 * @systemapi Hide this for inner system use. 1170 * @since 10 1171 */ 1172 NET_POLICY_NONE = 0, 1173 1174 /** 1175 * Allow on metered networks when app in background. 1176 * @syscap SystemCapability.Communication.NetManager.Core 1177 * @systemapi Hide this for inner system use. 1178 * @since 10 1179 */ 1180 NET_POLICY_ALLOW_METERED_BACKGROUND = 1 << 0, 1181 1182 /** 1183 * Reject on metered networks when app in background. 1184 * @syscap SystemCapability.Communication.NetManager.Core 1185 * @systemapi Hide this for inner system use. 1186 * @since 10 1187 */ 1188 NET_POLICY_REJECT_METERED_BACKGROUND = 1 << 1, 1189 } 1190} 1191 1192export default policy; 1193