Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Docs
提交
6526bf72
D
Docs
项目概览
OpenHarmony
/
Docs
1 年多 前同步成功
通知
159
Star
292
Fork
28
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
Docs
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
6526bf72
编写于
8月 03, 2023
作者:
O
openharmony_ci
提交者:
Gitee
8月 03, 2023
浏览文件
操作
浏览文件
下载
差异文件
!21839 修改policy-md
Merge pull request !21839 from 徐杰/beta2policy
上级
8d17c19e
d59b39cc
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
80 addition
and
58 deletion
+80
-58
zh-cn/application-dev/reference/apis/js-apis-net-policy.md
zh-cn/application-dev/reference/apis/js-apis-net-policy.md
+80
-58
未找到文件。
zh-cn/application-dev/reference/apis/js-apis-net-policy.md
浏览文件 @
6526bf72
...
...
@@ -89,9 +89,11 @@ setBackgroundAllowed(isAllowed: boolean): Promise\<void>
**示例:**
```
js
policy
.
setBackgroundAllowed
(
true
).
then
(
function
(
error
)
{
console
.
log
(
JSON
.
stringify
(
error
))
})
policy
.
setBackgroundAllowed
(
true
).
then
(()
=>
{
console
.
log
(
"
setBackgroundAllowed success
"
);
}).
catch
(
error
=>
{
console
.
log
(
JSON
.
stringify
(
error
));
});
```
## policy.isBackgroundAllowed<sup>10+</sup>
...
...
@@ -164,10 +166,11 @@ isBackgroundAllowed(): Promise\<boolean>;
**示例:**
```
js
policy
.
isBackgroundAllowed
().
then
(
function
(
error
,
data
)
{
console
.
log
(
JSON
.
stringify
(
error
))
console
.
log
(
JSON
.
stringify
(
data
))
})
policy
.
isBackgroundAllowed
().
then
((
data
)
=>
{
console
.
log
(
JSON
.
stringify
(
data
));
}).
catch
(
error
=>
{
console
.
log
(
JSON
.
stringify
(
error
));
});
```
## policy.setPolicyByUid<sup>10+</sup>
...
...
@@ -248,9 +251,11 @@ setPolicyByUid(uid: number, policy: NetUidPolicy): Promise\<void>;
**示例:**
```
js
policy
.
setPolicyByUid
(
11111
,
policy
.
NetUidPolicy
.
NET_POLICY_NONE
).
then
(
function
(
error
)
{
console
.
log
(
JSON
.
stringify
(
error
))
})
policy
.
setPolicyByUid
(
11111
,
policy
.
NetUidPolicy
.
NET_POLICY_NONE
).
then
(()
=>
{
console
.
log
(
"
setPolicyByUid success
"
);
}).
catch
(
error
=>
{
console
.
log
(
JSON
.
stringify
(
error
));
});
```
## policy.getPolicyByUid<sup>10+</sup>
...
...
@@ -329,10 +334,11 @@ getPolicyByUid(uid: number): Promise\<NetUidPolicy>;
**示例:**
```
js
policy
.
getPolicyByUid
(
11111
).
then
(
function
(
error
,
data
)
{
console
.
log
(
JSON
.
stringify
(
error
))
console
.
log
(
JSON
.
stringify
(
data
))
})
policy
.
getPolicyByUid
(
11111
).
then
((
data
)
=>
{
console
.
log
(
JSON
.
stringify
(
data
));
}).
catch
(
error
=>
{
console
.
log
(
JSON
.
stringify
(
error
));
});
```
## policy.getUidsByPolicy<sup>10+</sup>
...
...
@@ -412,10 +418,11 @@ getUidsByPolicy(policy: NetUidPolicy): Promise\<Array\<number>>;
**示例:**
```
js
policy
.
getUidsByPolicy
(
11111
).
then
(
function
(
error
,
data
)
{
console
.
log
(
JSON
.
stringify
(
error
))
console
.
log
(
JSON
.
stringify
(
data
))
})
policy
.
getUidsByPolicy
(
11111
).
then
((
data
)
=>
{
console
.
log
(
JSON
.
stringify
(
data
));
}).
catch
(
error
=>
{
console
.
log
(
JSON
.
stringify
(
error
));
});
```
## policy.getNetQuotaPolicies<sup>10+</sup>
...
...
@@ -487,11 +494,11 @@ getNetQuotaPolicies(): Promise\<Array\<NetQuotaPolicy>>;
**示例:**
```
js
policy
.
getNetQuotaPolicies
().
then
(
function
(
error
,
data
)
{
console
.
log
(
JSON
.
stringify
(
error
))
console
.
log
(
JSON
.
stringify
(
data
))
})
policy
.
getNetQuotaPolicies
().
then
(
(
data
)
=>
{
console
.
log
(
JSON
.
stringify
(
data
));
}).
catch
(
error
=>
{
console
.
log
(
JSON
.
stringify
(
error
));
});
```
## policy.setNetQuotaPolicies<sup>10+</sup>
...
...
@@ -608,9 +615,11 @@ let netquotapolicy = {
netQuotaPolicyList
.
push
(
netquotapolicy
);
policy
.
setNetQuotaPolicies
(
netQuotaPolicyList
).
then
(
function
(
error
)
{
console
.
log
(
JSON
.
stringify
(
error
))
})
policy
.
setNetQuotaPolicies
(
netQuotaPolicyList
).
then
(()
=>
{
console
.
log
(
"
setNetQuotaPolicies success
"
);
}).
catch
(
error
=>
{
console
.
log
(
JSON
.
stringify
(
error
));
});
```
## policy.isUidNetAllowed<sup>10+</sup>
...
...
@@ -692,10 +701,11 @@ isUidNetAllowed(uid: number, isMetered: boolean): Promise\<boolean>;
**示例:**
```
js
policy
.
isUidNetAllowed
(
11111
,
true
).
then
(
function
(
error
,
data
)
{
console
.
log
(
JSON
.
stringify
(
error
))
console
.
log
(
JSON
.
stringify
(
data
))
})
policy
.
isUidNetAllowed
(
11111
,
true
).
then
((
data
)
=>
{
console
.
log
(
JSON
.
stringify
(
data
));
}).
catch
(
error
=>
{
console
.
log
(
JSON
.
stringify
(
error
));
});
```
## policy.isUidNetAllowed<sup>10+</sup>
...
...
@@ -777,10 +787,11 @@ isUidNetAllowed(uid: number, iface: string): Promise\<boolean>;
**示例:**
```
js
policy
.
isUidNetAllowed
(
11111
,
'
wlan0
'
).
then
(
function
(
error
,
data
)
{
console
.
log
(
JSON
.
stringify
(
error
))
console
.
log
(
JSON
.
stringify
(
data
))
})
policy
.
isUidNetAllowed
(
11111
,
'
wlan0
'
).
then
((
data
)
=>
{
console
.
log
(
JSON
.
stringify
(
data
));
}).
catch
(
error
=>
{
console
.
log
(
JSON
.
stringify
(
error
));
});
```
## policy.setDeviceIdleTrustlist<sup>10+</sup>
...
...
@@ -861,9 +872,11 @@ setDeviceIdleTrustlist(uids: Array\<number>, isAllowed: boolean): Promise\<void>
**示例:**
```
js
policy
.
setDeviceIdleTrustlist
([
11111
,
22222
],
true
).
then
(
function
(
error
)
{
console
.
log
(
JSON
.
stringify
(
error
))
})
policy
.
setDeviceIdleTrustlist
([
11111
,
22222
],
true
).
then
(()
=>
{
console
.
log
(
"
setDeviceIdleTrustlist success
"
);
}).
catch
(
error
=>
{
console
.
log
(
JSON
.
stringify
(
error
));
});
```
## policy.getDeviceIdleTrustlist<sup>10+</sup>
...
...
@@ -934,10 +947,11 @@ getDeviceIdleTrustlist(): Promise\<Array\<number>>;
**示例:**
```
js
policy
.
getDeviceIdleTrustlist
().
then
(
function
(
error
,
data
)
{
console
.
log
(
JSON
.
stringify
(
error
))
console
.
log
(
JSON
.
stringify
(
data
))
})
policy
.
getDeviceIdleTrustlist
().
then
((
data
)
=>
{
console
.
log
(
JSON
.
stringify
(
data
));
}).
catch
(
error
=>
{
console
.
log
(
JSON
.
stringify
(
error
));
});
```
## policy.getBackgroundPolicyByUid<sup>10+</sup>
...
...
@@ -1017,10 +1031,11 @@ getBackgroundPolicyByUid(uid: number): Promise\<NetBackgroundPolicy>;
**示例:**
```
js
policy
.
getBackgroundPolicyByUid
(
11111
).
then
(
function
(
error
,
data
)
{
console
.
log
(
JSON
.
stringify
(
error
))
console
.
log
(
JSON
.
stringify
(
data
))
})
policy
.
getBackgroundPolicyByUid
(
11111
).
then
((
data
)
=>
{
console
.
log
(
JSON
.
stringify
(
data
));
}).
catch
(
error
=>
{
console
.
log
(
JSON
.
stringify
(
error
));
});
```
## policy.resetPolicies<sup>10+</sup>
...
...
@@ -1099,9 +1114,11 @@ resetPolicies(simId: string): Promise\<void>;
**示例:**
```
js
policy
.
resetPolicies
(
'
1
'
).
then
(
function
(
error
)
{
console
.
log
(
JSON
.
stringify
(
error
))
})
policy
.
resetPolicies
(
'
1
'
).
then
(()
=>
{
console
.
log
(
"
resetPolicies success
"
);
}).
catch
(
error
=>
{
console
.
log
(
JSON
.
stringify
(
error
));
});
```
## policy.updateRemindPolicy<sup>10+</sup>
...
...
@@ -1186,9 +1203,11 @@ updateRemindPolicy(netType: NetBearType, simId: string, remindType: RemindType):
```
js
import
connection
from
'
@ohos.net.connection
'
;
policy
.
updateRemindPolicy
(
connection
.
NetBearType
.
BEARER_CELLULAR
,
'
1
'
,
policy
.
RemindType
.
REMIND_TYPE_WARNING
).
then
(
function
(
error
)
{
console
.
log
(
JSON
.
stringify
(
error
))
})
policy
.
updateRemindPolicy
(
connection
.
NetBearType
.
BEARER_CELLULAR
,
'
1
'
,
policy
.
RemindType
.
REMIND_TYPE_WARNING
).
then
(()
=>
{
console
.
log
(
"
updateRemindPolicy success
"
);
}).
catch
(
error
=>
{
console
.
log
(
JSON
.
stringify
(
error
));
});
```
## policy.setPowerSaveTrustlist<sup>10+</sup>
...
...
@@ -1269,9 +1288,11 @@ setPowerSaveTrustlist(uids: Array\<number>, isAllowed: boolean): Promise\<void>;
**示例:**
```
js
policy
.
setPowerSaveTrustlist
([
11111
,
22222
],
true
).
then
(
function
(
error
)
{
console
.
log
(
JSON
.
stringify
(
error
))
})
policy
.
setPowerSaveTrustlist
([
11111
,
22222
],
true
).
then
(()
=>
{
console
.
log
(
"
setPowerSaveTrustlist success
"
);
}).
catch
(
error
=>
{
console
.
log
(
JSON
.
stringify
(
error
));
});
```
## policy.getPowerSaveTrustlist<sup>10+</sup>
...
...
@@ -1343,10 +1364,11 @@ getPowerSaveTrustlist(): Promise\<Array\<number>>;
**示例:**
```
js
policy
.
getPowerSaveTrustlist
().
then
(
function
(
error
,
data
)
{
console
.
log
(
JSON
.
stringify
(
error
))
console
.
log
(
JSON
.
stringify
(
data
))
})
policy
.
getPowerSaveTrustlist
().
then
((
data
)
=>
{
console
.
log
(
JSON
.
stringify
(
data
));
}).
catch
(
error
=>
{
console
.
log
(
JSON
.
stringify
(
error
));
});
```
## policy.on
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录