From 9e8c1a0e750d5abdff89ed823159f3196e56fd03 Mon Sep 17 00:00:00 2001 From: xujie Date: Sat, 22 Jul 2023 11:34:12 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9policy-md=20bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: xujie --- .../reference/apis/js-apis-net-policy.md | 95 ++++++------------- 1 file changed, 30 insertions(+), 65 deletions(-) diff --git a/zh-cn/application-dev/reference/apis/js-apis-net-policy.md b/zh-cn/application-dev/reference/apis/js-apis-net-policy.md index 4d0e101965..59dd069dbf 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-net-policy.md +++ b/zh-cn/application-dev/reference/apis/js-apis-net-policy.md @@ -204,10 +204,7 @@ setPolicyByUid(uid: number, policy: NetUidPolicy, callback: AsyncCallback\ **示例:** ```js -let param = { - uid: Number.parseInt(11111), policy: Number.parseInt(policy.NetUidPolicy.NET_POLICY_NONE) -} -policy.setPolicyByUid(param, (error) => { +policy.setPolicyByUid(11111, policy.NetUidPolicy.NET_POLICY_NONE, (error) => { console.log(JSON.stringify(error)) }); ``` @@ -251,10 +248,7 @@ setPolicyByUid(uid: number, policy: NetUidPolicy): Promise\; **示例:** ```js -let param = { - uid: Number.parseInt(11111), policy: Number.parseInt(policy.NetUidPolicy.NET_POLICY_NONE) -} -policy.setPolicyByUid(param).then(function (error) { +policy.setPolicyByUid(11111, policy.NetUidPolicy.NET_POLICY_NONE).then(function (error) { console.log(JSON.stringify(error)) }) ``` @@ -292,7 +286,7 @@ getPolicyByUid(uid: number, callback: AsyncCallback\): void **示例:** ```js -policy.getPolicyByUid(Number.parseInt(11111), (error, data) => { +policy.getPolicyByUid(11111, (error, data) => { console.log(JSON.stringify(error)) console.log(JSON.stringify(data)) }); @@ -336,7 +330,7 @@ getPolicyByUid(uid: number): Promise\; **示例:** ```js -policy.getPolicyByUid(Number.parseInt(11111)).then(function (error, data) { +policy.getPolicyByUid(11111).then(function (error, data) { console.log(JSON.stringify(error)) console.log(JSON.stringify(data)) }) @@ -375,7 +369,7 @@ getUidsByPolicy(policy: NetUidPolicy, callback: AsyncCallback\>): **示例:** ```js -policy.getUidsByPolicy(Number.parseInt(11111), (error, data) => { +policy.getUidsByPolicy(11111, (error, data) => { console.log(JSON.stringify(error)) console.log(JSON.stringify(data)) }); @@ -419,7 +413,7 @@ getUidsByPolicy(policy: NetUidPolicy): Promise\>; **示例:** ```js -policy.getUidsByPolicy(Number.parseInt(11111)).then(function (error, data) { +policy.getUidsByPolicy(11111).then(function (error, data) { console.log(JSON.stringify(error)) console.log(JSON.stringify(data)) }) @@ -538,17 +532,17 @@ import connection from '@ohos.net.connection'; let netQuotaPolicyList = [] -let param = { - netType: Number.parseInt(connection.NetBearType.BEARER_CELLULAR), +let netquotapolicy = { + netType: connection.NetBearType.BEARER_CELLULAR, simId: 1, identity: "", periodDuration: "M1", - warningBytes: Number.parseInt(40000), - limitBytes: Number.parseInt(50000), - metered: Boolean(Number.parseInt(true)), + warningBytes: 40000, + limitBytes: 50000, + metered: true, limitAction: policy.LimitAction.LIMIT_ACTION_NONE }; -netQuotaPolicyList.push(param); +netQuotaPolicyList.push(netquotapolicy); policy.setNetQuotaPolicies(netQuotaPolicyList, (error) => { console.log(JSON.stringify(error)) @@ -597,17 +591,17 @@ import connection from '@ohos.net.connection'; let netQuotaPolicyList = [] -let param = { - netType: Number.parseInt(connection.NetBearType.BEARER_CELLULAR), +let netquotapolicy = { + netType: connection.NetBearType.BEARER_CELLULAR, simId: 1, identity: "", periodDuration: "M1", - warningBytes: Number.parseInt(40000), - limitBytes: Number.parseInt(50000), - metered: Boolean(Number.parseInt(true)), + warningBytes: 40000, + limitBytes: 50000, + metered: true, limitAction: policy.LimitAction.LIMIT_ACTION_NONE }; -netQuotaPolicyList.push(param); +netQuotaPolicyList.push(netquotapolicy); policy.setNetQuotaPolicies(netQuotaPolicyList).then(function (error) { console.log(JSON.stringify(error)) @@ -648,10 +642,7 @@ isUidNetAllowed(uid: number, isMetered: boolean, callback: AsyncCallback\ { +policy.isUidNetAllowed(11111, true, (error, data) => { console.log(JSON.stringify(error)) console.log(JSON.stringify(data)) }); @@ -696,10 +687,7 @@ isUidNetAllowed(uid: number, isMetered: boolean): Promise\; **示例:** ```js -let param = { - uid: Number.parseInt(11111), isMetered: true -} -policy.isUidNetAllowed(param).then(function (error, data) { +policy.isUidNetAllowed(11111, true).then(function (error, data) { console.log(JSON.stringify(error)) console.log(JSON.stringify(data)) }) @@ -739,10 +727,7 @@ isUidNetAllowed(uid: number, iface: string, callback: AsyncCallback\): **示例:** ```js -let param = { - uid: Number.parseInt(11111), iface: 'wlan0' -} -policy.isUidNetAllowed(param, (error, data) => { +policy.isUidNetAllowed(11111, 'wlan0', (error, data) => { console.log(JSON.stringify(error)) console.log(JSON.stringify(data)) }); @@ -787,10 +772,7 @@ isUidNetAllowed(uid: number, iface: string): Promise\; **示例:** ```js -let param = { - uid: Number.parseInt(11111), iface: 'wlan0' -} -policy.isUidNetAllowed(param).then(function (error, data) { +policy.isUidNetAllowed(11111, 'wlan0').then(function (error, data) { console.log(JSON.stringify(error)) console.log(JSON.stringify(data)) }) @@ -830,10 +812,7 @@ setDeviceIdleTrustlist(uids: Array\, isAllowed: boolean, callback: Async **示例:** ```js -let param = { - uids: [11111,22222], isAllowed: true -} -policy.setDeviceIdleTrustlist(param, (error) => { +policy.setDeviceIdleTrustlist([11111,22222], true, (error) => { console.log(JSON.stringify(error)) }); ``` @@ -877,10 +856,7 @@ setDeviceIdleTrustlist(uids: Array\, isAllowed: boolean): Promise\ **示例:** ```js -let param = { - uids: [11111,22222], isAllowed: true -} -policy.setDeviceIdleTrustlist(param).then(function (error) { +policy.setDeviceIdleTrustlist([11111,22222], true).then(function (error) { console.log(JSON.stringify(error)) }) ``` @@ -992,7 +968,7 @@ getBackgroundPolicyByUid(uid: number, callback: AsyncCallback\ { +policy.getBackgroundPolicyByUid(11111, (error, data) => { console.log(JSON.stringify(error)) console.log(JSON.stringify(data)) }); @@ -1036,7 +1012,7 @@ getBackgroundPolicyByUid(uid: number): Promise\; **示例:** ```js -policy.getBackgroundPolicyByUid(Number.parseInt(11111)).then(function (error, data) { +policy.getBackgroundPolicyByUid(11111).then(function (error, data) { console.log(JSON.stringify(error)) console.log(JSON.stringify(data)) }) @@ -1159,11 +1135,7 @@ updateRemindPolicy(netType: NetBearType, simId: string, remindType: RemindType, ```js import connection from '@ohos.net.connection'; - -let param = { - netType: Number.parseInt(connection.NetBearType.BEARER_CELLULAR), simId: 1, remindType: policy.NetUidPolicy.NET_POLICY_NONE -} -policy.updateRemindPolicy(param, (error) => { +policy.updateRemindPolicy(connection.NetBearType.BEARER_CELLULAR, 1, policy.NetUidPolicy.NET_POLICY_NONE, (error) => { console.log(JSON.stringify(error)) }); ``` @@ -1209,11 +1181,7 @@ updateRemindPolicy(netType: NetBearType, simId: string, remindType: RemindType): ```js import connection from '@ohos.net.connection'; - -let param = { - netType: Number.parseInt(connection.NetBearType.BEARER_CELLULAR), simId: 1, remindType: policy.NetUidPolicy.NET_POLICY_NONE -} -policy.updateRemindPolicy(param).then(function (error) { +policy.updateRemindPolicy(connection.NetBearType.BEARER_CELLULAR, 1, policy.NetUidPolicy.NET_POLICY_NONE).then(function (error) { console.log(JSON.stringify(error)) }) ``` @@ -1255,7 +1223,7 @@ setPowerSaveTrustlist(uids: Array\, isAllowed: boolean, callback: AsyncC let param = { uids: [11111,22222], isAllowed: true } -policy.setDeviceIdleTrustlist(param, (error) => { +policy.setDeviceIdleTrustlist([11111,22222], true, (error) => { console.log(JSON.stringify(error)) }); ``` @@ -1299,10 +1267,7 @@ setPowerSaveTrustlist(uids: Array\, isAllowed: boolean): Promise\; **示例:** ```js -let param = { - uids: [11111,22222], isAllowed: true -} -policy.setDeviceIdleTrustlist(param).then(function (error) { +policy.setDeviceIdleTrustlist([11111,22222], true).then(function (error) { console.log(JSON.stringify(error)) }) ``` -- GitLab