未验证 提交 f32d4844 编写于 作者: O openharmony_ci 提交者: Gitee

!21267 修改policy文档示例代码

Merge pull request !21267 from 徐杰/xj_0722
...@@ -531,17 +531,21 @@ setNetQuotaPolicies(quotaPolicies: Array\<NetQuotaPolicy>, callback: AsyncCallba ...@@ -531,17 +531,21 @@ setNetQuotaPolicies(quotaPolicies: Array\<NetQuotaPolicy>, callback: AsyncCallba
import connection from '@ohos.net.connection'; import connection from '@ohos.net.connection';
let netQuotaPolicyList = [] let netQuotaPolicyList = []
let netquotapolicy = { let netquotapolicy = {
netType: connection.NetBearType.BEARER_CELLULAR, networkMatchRule: {
simId: 1, netType: connection.NetBearType.BEARER_CELLULAR,
identity: "", identity:"",
periodDuration: "M1", simId:"1"
warningBytes: 40000, },
limitBytes: 50000, quotaPolicy: {
metered: true, periodDuration: "M1",
limitAction: policy.LimitAction.LIMIT_ACTION_NONE warningBytes: 40000,
}; limitBytes: 50000,
metered: true,
limitAction: policy.LimitAction.LIMIT_ACTION_NONE
},
}
netQuotaPolicyList.push(netquotapolicy); netQuotaPolicyList.push(netquotapolicy);
policy.setNetQuotaPolicies(netQuotaPolicyList, (error) => { policy.setNetQuotaPolicies(netQuotaPolicyList, (error) => {
...@@ -590,17 +594,21 @@ setNetQuotaPolicies(quotaPolicies: Array\<NetQuotaPolicy>): Promise\<void>; ...@@ -590,17 +594,21 @@ setNetQuotaPolicies(quotaPolicies: Array\<NetQuotaPolicy>): Promise\<void>;
import connection from '@ohos.net.connection'; import connection from '@ohos.net.connection';
let netQuotaPolicyList = [] let netQuotaPolicyList = []
let netquotapolicy = { let netquotapolicy = {
netType: connection.NetBearType.BEARER_CELLULAR, networkMatchRule: {
simId: 1, netType: connection.NetBearType.BEARER_CELLULAR,
identity: "", identity:"",
periodDuration: "M1", simId:"1"
warningBytes: 40000, },
limitBytes: 50000, quotaPolicy: {
metered: true, periodDuration: "M1",
limitAction: policy.LimitAction.LIMIT_ACTION_NONE warningBytes: 40000,
}; limitBytes: 50000,
metered: true,
limitAction: policy.LimitAction.LIMIT_ACTION_NONE
},
}
netQuotaPolicyList.push(netquotapolicy); netQuotaPolicyList.push(netquotapolicy);
policy.setNetQuotaPolicies(netQuotaPolicyList).then(function (error) { policy.setNetQuotaPolicies(netQuotaPolicyList).then(function (error) {
...@@ -1051,7 +1059,7 @@ resetPolicies(simId: string, callback: AsyncCallback\<void>): void ...@@ -1051,7 +1059,7 @@ resetPolicies(simId: string, callback: AsyncCallback\<void>): void
**示例:** **示例:**
```js ```js
policy.resetPolicies(1, (error) => { policy.resetPolicies('1', (error) => {
console.log(JSON.stringify(error)) console.log(JSON.stringify(error))
}); });
``` ```
...@@ -1094,7 +1102,7 @@ resetPolicies(simId: string): Promise\<void>; ...@@ -1094,7 +1102,7 @@ resetPolicies(simId: string): Promise\<void>;
**示例:** **示例:**
```js ```js
policy.resetPolicies(1).then(function (error) { policy.resetPolicies('1').then(function (error) {
console.log(JSON.stringify(error)) console.log(JSON.stringify(error))
}) })
``` ```
...@@ -1135,7 +1143,7 @@ updateRemindPolicy(netType: NetBearType, simId: string, remindType: RemindType, ...@@ -1135,7 +1143,7 @@ updateRemindPolicy(netType: NetBearType, simId: string, remindType: RemindType,
```js ```js
import connection from '@ohos.net.connection'; import connection from '@ohos.net.connection';
policy.updateRemindPolicy(connection.NetBearType.BEARER_CELLULAR, 1, policy.NetUidPolicy.NET_POLICY_NONE, (error) => { policy.updateRemindPolicy(connection.NetBearType.BEARER_CELLULAR, '1', policy.RemindType.REMIND_TYPE_WARNING, (error) => {
console.log(JSON.stringify(error)) console.log(JSON.stringify(error))
}); });
``` ```
...@@ -1181,7 +1189,7 @@ updateRemindPolicy(netType: NetBearType, simId: string, remindType: RemindType): ...@@ -1181,7 +1189,7 @@ updateRemindPolicy(netType: NetBearType, simId: string, remindType: RemindType):
```js ```js
import connection from '@ohos.net.connection'; import connection from '@ohos.net.connection';
policy.updateRemindPolicy(connection.NetBearType.BEARER_CELLULAR, 1, policy.NetUidPolicy.NET_POLICY_NONE).then(function (error) { policy.updateRemindPolicy(connection.NetBearType.BEARER_CELLULAR, '1', policy.RemindType.REMIND_TYPE_WARNING).then(function (error) {
console.log(JSON.stringify(error)) console.log(JSON.stringify(error))
}) })
``` ```
...@@ -1220,9 +1228,6 @@ setPowerSaveTrustlist(uids: Array\<number>, isAllowed: boolean, callback: AsyncC ...@@ -1220,9 +1228,6 @@ setPowerSaveTrustlist(uids: Array\<number>, isAllowed: boolean, callback: AsyncC
**示例:** **示例:**
```js ```js
let param = {
uids: [11111,22222], isAllowed: true
}
policy.setDeviceIdleTrustlist([11111,22222], true, (error) => { policy.setDeviceIdleTrustlist([11111,22222], true, (error) => {
console.log(JSON.stringify(error)) console.log(JSON.stringify(error))
}); });
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册