Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Docs
提交
22af3007
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看板
提交
22af3007
编写于
7月 29, 2023
作者:
Y
yaobaohua
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
edm sync beta2
Signed-off-by:
N
yaobaohua
<
yaobaohua1@huawei.com
>
上级
070dc8cf
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
0 addition
and
561 deletion
+0
-561
zh-cn/application-dev/reference/apis/Readme-CN.md
zh-cn/application-dev/reference/apis/Readme-CN.md
+0
-1
zh-cn/application-dev/reference/apis/enterpriseDeviceManagement-overview.md
...dev/reference/apis/enterpriseDeviceManagement-overview.md
+0
-1
zh-cn/application-dev/reference/apis/js-apis-enterprise-deviceSettings.md
...n-dev/reference/apis/js-apis-enterprise-deviceSettings.md
+0
-229
zh-cn/application-dev/reference/apis/js-apis-enterprise-networkManager.md
...n-dev/reference/apis/js-apis-enterprise-networkManager.md
+0
-203
zh-cn/application-dev/reference/apis/js-apis-enterprise-usbManager.md
...ation-dev/reference/apis/js-apis-enterprise-usbManager.md
+0
-127
未找到文件。
zh-cn/application-dev/reference/apis/Readme-CN.md
浏览文件 @
22af3007
...
...
@@ -447,7 +447,6 @@
-
[
@ohos.enterprise.EnterpriseAdminExtensionAbility (企业设备管理扩展能力)
](
js-apis-EnterpriseAdminExtensionAbility.md
)
-
[
@ohos.enterprise.networkManager (网络管理)
](
js-apis-enterprise-networkManager.md
)
-
[
@ohos.enterprise.restrictions (限制类策略)
](
js-apis-enterprise-restrictions.md
)
-
[
@ohos.enterprise.usbManager (USB管理)
](
js-apis-enterprise-usbManager.md
)
-
[
@ohos.enterprise.wifiManager (WiFi管理)
](
js-apis-enterprise-wifiManager.md
)
-
语言基础类库
...
...
zh-cn/application-dev/reference/apis/enterpriseDeviceManagement-overview.md
浏览文件 @
22af3007
...
...
@@ -42,5 +42,4 @@ OpenHarmony通过企业设备管理(Enterprise Device Management)API支持
-
[
@ohos.enterprise.EnterpriseAdminExtensionAbility (企业设备管理扩展能力)
](
js-apis-EnterpriseAdminExtensionAbility.md
)
-
[
@ohos.enterprise.networkManager (网络管理)
](
js-apis-enterprise-networkManager.md
)
-
[
@ohos.enterprise.restrictions (限制类策略)
](
js-apis-enterprise-restrictions.md
)
-
[
@ohos.enterprise.usbManager (USB管理)
](
js-apis-enterprise-usbManager.md
)
-
[
@ohos.enterprise.wifiManager (WiFi管理)
](
js-apis-enterprise-wifiManager.md
)
\ No newline at end of file
zh-cn/application-dev/reference/apis/js-apis-enterprise-deviceSettings.md
浏览文件 @
22af3007
...
...
@@ -108,232 +108,3 @@ deviceSettings.getScreenOffTime(wantTemp).then((result) => {
console
.
error
(
`Failed to get screen off time. Code:
${
err
.
code
}
, message:
${
err
.
message
}
`
);
});
```
## deviceSettings.installUserCertificate
installUserCertificate(admin: Want, certificate: CertBlob, callback: AsyncCallback
<
string
>
): void
指定设备管理应用安装用户证书,使用callback异步回调。
**需要权限:**
ohos.permission.ENTERPRISE_MANAGE_CERTIFICATE
**系统能力:**
SystemCapability.Customization.EnterpriseDeviceManager
**系统API**
: 此接口为系统接口。
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ---------------------------------------- | ---- | ------------------------------- |
| admin |
[
Want
](
js-apis-app-ability-want.md
)
| 是 | 设备管理应用。 |
| certificate |
[
CertBlob
](
#certblob
)
| 是 | 证书信息。 |
| callback | AsyncCallback
<
string
>
| 是 | 回调函数,当接口调用成功,err为null,否则为错误对象。 |
**错误码**
:
以下错误码的详细介绍请参见
[
企业设备管理错误码
](
../errorcodes/errorcode-enterpriseDeviceManager.md
)
| 错误码ID | 错误信息 |
| ------- | ---------------------------------------------------------------------------- |
| 9200001 | the application is not an administrator of the device. |
| 9200002 | the administrator application does not have permission to manage the device. |
| 9201001 | manage certificate failed |
**示例:**
```
js
let
wantTemp
=
{
bundleName
:
'
com.example.myapplication
'
,
abilityName
:
'
EntryAbility
'
,
};
var
certFileArray
:
Uint8Array
;
// The variable context needs to be initialized in MainAbility's onCreate callback function
// test.cer needs to be placed in the rawfile directory
await
globalThis
.
context
.
resourceManager
.
getRawFileContent
(
"
test.cer
"
)
.
then
(
value
=>
{
certFileArray
=
value
})
.
catch
(
error
=>
{
console
.
error
(
`Failed to get row file content. message:
${
error
.
message
}
`
);
return
});
new
Promise
((
resolve
,
reject
)
=>
{
deviceSettings
.
installUserCertificate
(
wantTemp
,
{
inData
:
certFileArray
,
alias
:
"
cert_alias_xts
"
},
(
err
,
result
)
=>
{
if
(
err
)
{
console
.
error
(
`Failed to install user certificate. Code:
${
err
.
code
}
, message:
${
err
.
message
}
`
);
}
else
{
console
.
info
(
`Succeeded in installing user certificate, result :
${
JSON
.
stringify
(
result
)}
`
);
}
});
});
```
## deviceSettings.installUserCertificate
installUserCertificate(admin: Want, certificate: CertBlob): Promise
<
string
>
指定设备管理应用安装用户证书,使用Promise异步回调。
**需要权限:**
ohos.permission.ENTERPRISE_MANAGE_CERTIFICATE
**系统能力:**
SystemCapability.Customization.EnterpriseDeviceManager
**系统API**
: 此接口为系统接口。
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ----- | ----------------------------------- | ---- | ------- |
| admin |
[
Want
](
js-apis-app-ability-want.md
)
| 是 | 设备管理应用。 |
| certificate |
[
CertBlob
](
#certblob
)
| 是 | 证书信息。 |
**返回值:**
| 类型 | 说明 |
| --------------------- | ------------------------- |
| Promise
<
string
>
| Promise对象,返回当前证书安装后的uri,用于卸载证书。 |
**错误码**
:
以下错误码的详细介绍请参见
[
企业设备管理错误码
](
../errorcodes/errorcode-enterpriseDeviceManager.md
)
| 错误码ID | 错误信息 |
| ------- | ---------------------------------------------------------------------------- |
| 9200001 | the application is not an administrator of the device. |
| 9200002 | the administrator application does not have permission to manage the device. |
| 9201001 | manage certificate failed |
**示例:**
```
js
let
wantTemp
=
{
bundleName
:
'
com.example.myapplication
'
,
abilityName
:
'
EntryAbility
'
,
};
var
certFileArray
:
Uint8Array
// The variable context needs to be initialized in MainAbility's onCreate callback function
// test.cer needs to be placed in the rawfile directory
await
globalThis
.
context
.
resourceManager
.
getRawFileContent
(
"
test.cer
"
)
.
then
(
data
=>
{
certFileArray
=
data
}).
catch
(
error
=>
{
console
.
log
(
'
getRawFileContent error
'
+
error
)
return
})
deviceSettings
.
installUserCertificate
(
wantTemp
,
{
inData
:
certFileArray
,
alias
:
"
cert_alias_xts
"
})
.
then
((
result
)
=>
{
console
.
info
(
`Succeeded in installing user certificate, result :
${
JSON
.
stringify
(
result
)}
`
);
}).
catch
(
err
=>
{
console
.
error
(
`Failed to install user certificate. Code:
${
err
.
code
}
, message:
${
err
.
message
}
`
);
})
```
## CertBlob
证书信息。
**系统能力:**
SystemCapability.Customization.EnterpriseDeviceManager
**系统API**
: 此接口为系统接口。
| 名称 | 类型 | 必填 | 说明 |
| ----------- | --------| ----- | ------------------------------- |
| inData | Uint8Array | 是 | 证书的二进制内容。 |
| alias | string | 是 | 证书别名。 |
## deviceSettings.uninstallUserCertificate
uninstallUserCertificate(admin: Want, certUri: string, callback: AsyncCallback
<
void
>
): void
指定设备管理应用卸载用户证书,使用callback异步回调。
**需要权限:**
ohos.permission.ENTERPRISE_MANAGE_CERTIFICATE
**系统能力:**
SystemCapability.Customization.EnterpriseDeviceManager
**系统API**
: 此接口为系统接口。
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ---------------------------------------- | ---- | ------------------------------- |
| admin |
[
Want
](
js-apis-app-ability-want.md
)
| 是 | 设备管理应用。 |
| certUri | string | 是 | 证书uri,由安装用户证书接口返回。 |
| callback | AsyncCallback
<
void
>
| 是 | 回调函数,当接口调用成功,err为null,否则为错误对象。 |
**错误码**
:
以下错误码的详细介绍请参见
[
企业设备管理错误码
](
../errorcodes/errorcode-enterpriseDeviceManager.md
)
| 错误码ID | 错误信息 |
| ------- | ---------------------------------------------------------------------------- |
| 9200001 | the application is not an administrator of the device. |
| 9200002 | the administrator application does not have permission to manage the device. |
| 9201001 | manage certificate failed |
**示例:**
```
js
let
wantTemp
=
{
bundleName
:
'
com.example.myapplication
'
,
abilityName
:
'
EntryAbility
'
,
};
let
aliasStr
=
"
certName
"
deviceSettings
.
uninstallUserCertificate
(
wantTemp
,
aliasStr
,
(
err
)
=>
{
if
(
err
)
{
console
.
error
(
`Failed to uninstall user certificate. Code:
${
err
.
code
}
, message:
${
err
.
message
}
`
);
return
;
}
console
.
info
(
`Succeeded in uninstalling user certificate`
);
});
```
## deviceSettings.uninstallUserCertificate
uninstallUserCertificate(admin: Want, certUri: string): Promise
<
void
>
指定设备管理应用卸载用户证书,使用Promise异步回调。
**需要权限:**
ohos.permission.ENTERPRISE_MANAGE_CERTIFICATE
**系统能力:**
SystemCapability.Customization.EnterpriseDeviceManager
**系统API**
: 此接口为系统接口。
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ----- | ----------------------------------- | ---- | ------- |
| admin |
[
Want
](
js-apis-app-ability-want.md
)
| 是 | 设备管理应用。 |
| certUri | string | 是 | 证书uri,由安装用户证书接口返回。 |
**返回值:**
| 类型 | 说明 |
| --------------------- | ------------------------- |
| Promise
<
void
>
| 无返回结果的Promise对象。当指定设备管理应用卸载用户证书失败时会抛出错误对象。 |
**错误码**
:
以下错误码的详细介绍请参见
[
企业设备管理错误码
](
../errorcodes/errorcode-enterpriseDeviceManager.md
)
| 错误码ID | 错误信息 |
| ------- | ---------------------------------------------------------------------------- |
| 9200001 | the application is not an administrator of the device. |
| 9200002 | the administrator application does not have permission to manage the device. |
| 9201001 | manage certificate failed |
**示例:**
```
js
let
wantTemp
=
{
bundleName
:
'
com.example.myapplication
'
,
abilityName
:
'
EntryAbility
'
,
};
let
aliasStr
=
"
certName
"
deviceSettings
.
uninstallUserCertificate
(
wantTemp
,
aliasStr
).
then
(()
=>
{
console
.
info
(
`Succeeded in uninstalling user certificate`
);
}).
catch
((
err
)
=>
{
console
.
error
(
`Failed to uninstall user certificate. Code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
});
```
\ No newline at end of file
zh-cn/application-dev/reference/apis/js-apis-enterprise-networkManager.md
浏览文件 @
22af3007
...
...
@@ -491,209 +491,6 @@ networkManager.setNetworkInterfaceDisabled(wantTemp, 'eth0', true).then(() => {
});
```
## networkManager.setGlobalProxy
setGlobalProxy(admin: Want, httpProxy: connection.HttpProxy, callback: AsyncCallback
\<
void>): void
指定设备管理应用设置网络全局代理,使用callback异步回调。
**需要权限:**
ohos.permission.ENTERPRISE_MANAGE_NETWORK
**系统能力:**
SystemCapability.Customization.EnterpriseDeviceManager
**系统API**
: 此接口为系统接口。
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ---------------------------------------- | ---- | ------------------------------- |
| admin |
[
Want
](
js-apis-app-ability-want.md
)
| 是 | 设备管理应用。 |
| httpProxy |
[
connection.HttpProxy
](
js-apis-net-connection.md#httpproxy10
)
| 是 | 网络全局Http代理配置信息。 |
| callback | AsyncCallback
<
void
>
| 是 | 回调函数。当接口调用成功,err为null,否则err为错误对象。 |
**错误码**
:
以下错误码的详细介绍请参见
[
企业设备管理错误码
](
../errorcodes/errorcode-enterpriseDeviceManager.md
)
| 错误码ID | 错误信息 |
| ------- | ---------------------------------------------------------------------------- |
| 9200001 | the application is not an administrator of the device. |
| 9200002 | the administrator application does not have permission to manage the device. |
**示例:**
```
js
let
wantTemp
=
{
bundleName
:
'
com.example.myapplication
'
,
abilityName
:
'
EntryAbility
'
,
};
let
exclusionStr
=
"
192.168,baidu.com
"
let
exclusionArray
=
exclusionStr
.
split
(
'
,
'
);
let
httpProxy
=
{
host
:
"
192.168.xx.xxx
"
,
port
:
8080
,
exclusionList
:
exclusionArray
};
networkManager
.
setGlobalProxy
(
wantTemp
,
httpProxy
,
(
err
)
=>
{
if
(
err
)
{
console
.
error
(
`Failed to set network global proxy. Code:
${
err
.
code
}
, message:
${
err
.
message
}
`
);
return
;
}
console
.
info
(
`Succeeded in setting network global proxy`
);
});
```
## networkManager.setGlobalProxy
setGlobalProxy(admin: Want, httpProxy: connection.HttpProxy): Promise
\<
void>
指定设备管理应用设置网络全局代理,使用Promise异步回调。
**需要权限:**
ohos.permission.ENTERPRISE_MANAGE_NETWORK
**系统能力:**
SystemCapability.Customization.EnterpriseDeviceManager
**系统API**
: 此接口为系统接口。
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ----- | ----------------------------------- | ---- | ------- |
| admin |
[
Want
](
js-apis-app-ability-want.md
)
| 是 | 设备管理应用。 |
| httpProxy |
[
connection.HttpProxy
](
js-apis-net-connection.md#httpproxy10
)
| 是 | 网络全局Http代理配置信息。 |
| isDisabled | boolean | 是 | true表示禁用该网络接口,false表示开启该网络接口。 |
**返回值:**
| 类型 | 说明 |
| --------------------- | ------------------------- |
| Promise
<
void
>
| 无返回结果的Promise对象。当设置网络全局代理失败时抛出错误对象 |
**错误码**
:
以下错误码的详细介绍请参见
[
企业设备管理错误码
](
../errorcodes/errorcode-enterpriseDeviceManager.md
)
| 错误码ID | 错误信息 |
| ------- | ---------------------------------------------------------------------------- |
| 9200001 | the application is not an administrator of the device. |
| 9200002 | the administrator application does not have permission to manage the device. |
**示例:**
```
js
let
wantTemp
=
{
bundleName
:
'
com.example.myapplication
'
,
abilityName
:
'
EntryAbility
'
,
};
let
exclusionStr
=
"
192.168,baidu.com
"
let
exclusionArray
=
exclusionStr
.
split
(
'
,
'
);
let
httpProxy
=
{
host
:
"
192.168.xx.xxx
"
,
port
:
8080
,
exclusionList
:
exclusionArray
};
networkManager
.
setGlobalProxy
(
wantTemp
,
httpProxy
).
then
(()
=>
{
console
.
info
(
`Succeeded in setting network global proxy`
);
}).
catch
((
err
)
=>
{
console
.
error
(
`Failed to set network global proxy. Code:
${
err
.
code
}
, message:
${
err
.
message
}
`
);
});
```
## networkManager.getGlobalProxy
getGlobalProxy(admin: Want, callback: AsyncCallback
\<
connection.HttpProxy>): void
指定设备管理应用获取网络全局代理,使用callback异步回调。
**需要权限:**
ohos.permission.ENTERPRISE_MANAGE_NETWORK
**系统能力:**
SystemCapability.Customization.EnterpriseDeviceManager
**系统API**
: 此接口为系统接口。
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ---------------------------------------- | ---- | ------------------------------- |
| admin |
[
Want
](
js-apis-app-ability-want.md
)
| 是 | 设备管理应用。 |
| callback | AsyncCallback
<
[connection.HttpProxy](js-apis-net-connection.md#httpproxy10)
>
| 是 | 回调函数。当接口调用成功,err为null,否则err为错误对象。 |
**错误码**
:
以下错误码的详细介绍请参见
[
企业设备管理错误码
](
../errorcodes/errorcode-enterpriseDeviceManager.md
)
| 错误码ID | 错误信息 |
| ------- | ---------------------------------------------------------------------------- |
| 9200001 | the application is not an administrator of the device. |
| 9200002 | the administrator application does not have permission to manage the device. |
**示例:**
```
js
let
wantTemp
=
{
bundleName
:
'
com.example.myapplication
'
,
abilityName
:
'
EntryAbility
'
,
};
networkManager
.
getGlobalProxy
(
wantTemp
,
(
err
,
result
)
=>
{
if
(
err
)
{
console
.
error
(
`Failed to get network global proxy. Code:
${
err
.
code
}
, message:
${
err
.
message
}
`
);
return
;
}
console
.
info
(
`Succeeded in getting network global proxy, result :
${
JSON
.
stringify
(
result
)}
`
);
});
```
## networkManager.getGlobalProxy
getGlobalProxy(admin: Want): Promise
\<
connection.HttpProxy>
指定设备管理应用获取网络全局代理,使用Promise异步回调。
**需要权限:**
ohos.permission.ENTERPRISE_MANAGE_NETWORK
**系统能力:**
SystemCapability.Customization.EnterpriseDeviceManager
**系统API**
: 此接口为系统接口。
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ----- | ----------------------------------- | ---- | ------- |
| admin |
[
Want
](
js-apis-app-ability-want.md
)
| 是 | 设备管理应用。 |
**返回值:**
| 类型 | 说明 |
| --------------------- | ------------------------- |
| Promise
<
[connection.HttpProxy](js-apis-net-connection.md#httpproxy10)
>
| Promise对象,返回网络全局Http代理配置信息。 |
**错误码**
:
以下错误码的详细介绍请参见
[
企业设备管理错误码
](
../errorcodes/errorcode-enterpriseDeviceManager.md
)
| 错误码ID | 错误信息 |
| ------- | ---------------------------------------------------------------------------- |
| 9200001 | the application is not an administrator of the device. |
| 9200002 | the administrator application does not have permission to manage the device. |
**示例:**
```
js
let
wantTemp
=
{
bundleName
:
'
com.example.myapplication
'
,
abilityName
:
'
EntryAbility
'
,
};
networkManager
.
getGlobalProxy
(
wantTemp
).
then
(()
=>
{
console
.
info
(
`Succeeded in getting network global proxy`
);
}).
catch
((
err
)
=>
{
console
.
error
(
`Failed to get network global proxy. Code:
${
err
.
code
}
, message:
${
err
.
message
}
`
);
});
```
## networkManager.addIptablesFilterRule
addIptablesFilterRule(admin: Want, filterRule: AddFilterRule, callback: AsyncCallback
\<
void>): void
...
...
zh-cn/application-dev/reference/apis/js-apis-enterprise-usbManager.md
已删除
100644 → 0
浏览文件 @
070dc8cf
# @ohos.enterprise.usbManager (USB管理)
本模块提供USB管理能力。
> **说明**:
>
> 本模块首批接口从API version 10开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
>
> 本模块接口仅可在Stage模型下使用。
>
> 本模块接口仅对[设备管理应用](enterpriseDeviceManagement-overview.md#基本概念)开放,需将[设备管理应用激活](js-apis-enterprise-adminManager.md#adminmanagerenableadmin)后调用,实现相应功能。
## 导入模块
```
js
import
usbManager
from
'
@ohos.enterprise.usbManager
'
```
## usbManager.setUsbPolicy
setUsbPolicy(admin: Want, usbPolicy: UsbPolicy, callback: AsyncCallback
\<
void>): void
指定设备管理应用设置USB的读写策略。使用callback异步回调。
**需要权限:**
ohos.permission.ENTERPRISE_MANAGE_USB
**系统能力:**
SystemCapability.Customization.EnterpriseDeviceManager
**系统API**
: 此接口为系统接口。
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ----- | ----------------------------------- | ---- | ------- |
| admin |
[
Want
](
js-apis-app-ability-want.md
)
| 是 | 设备管理应用。 |
| usbPolicy |
[
UsbPolicy
](
#usbpolicy
)
| 是 | USB读写策略。 |
| callback | AsyncCallback
\<
void> | 是 | 回调函数。当接口调用成功,err为null,否则为错误对象。 |
**错误码**
:
以下错误码的详细介绍请参见
[
企业设备管理错误码
](
../errorcodes/errorcode-enterpriseDeviceManager.md
)
| 错误码ID | 错误信息 |
| ------- | ---------------------------------------------------------------------------- |
| 9200001 | the application is not an administrator of the device. |
| 9200002 | the administrator application does not have permission to manage the device. |
**示例:**
```
js
let
wantTemp
=
{
bundleName
:
'
bundleName
'
,
abilityName
:
'
abilityName
'
,
};
let
policy
=
usbManager
.
UsbPolicy
.
READ_WRITE
usbManager
.
setUsbPolicy
(
wantTemp
,
policy
,
(
err
)
=>
{
if
(
err
)
{
console
.
error
(
`Failed to set usb policy. Code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
return
;
}
console
.
info
(
'
Succeeded in setting usb policy
'
);
})
```
## usbManager.setUsbPolicy
setUsbPolicy(admin: Want, usbPolicy: UsbPolicy): Promise
\<
void>
指定设备管理应用设置USB的读写策略。使用Promise异步回调。
**需要权限:**
ohos.permission.ENTERPRISE_MANAGE_USB
**系统能力:**
SystemCapability.Customization.EnterpriseDeviceManager
**系统API**
: 此接口为系统接口。
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ----- | ----------------------------------- | ---- | ------- |
| admin |
[
Want
](
js-apis-app-ability-want.md
)
| 是 | 设备管理应用。 |
| usbPolicy |
[
UsbPolicy
](
#usbpolicy
)
| 是 | USB读写策略。 |
**返回值:**
| 类型 | 说明 |
| ----- | ----------------------------------- |
| Promise
\<
void> | 无返回结果的Promise对象。当指定设备管理应用设置USB策略失败时抛出错误对象。 |
**错误码**
:
以下错误码的详细介绍请参见
[
企业设备管理错误码
](
../errorcodes/errorcode-enterpriseDeviceManager.md
)
| 错误码ID | 错误信息 |
| ------- | ---------------------------------------------------------------------------- |
| 9200001 | the application is not an administrator of the device. |
| 9200002 | the administrator application does not have permission to manage the device. |
**示例:**
```
js
let
wantTemp
=
{
bundleName
:
'
bundleName
'
,
abilityName
:
'
abilityName
'
,
};
let
policy
=
usbManager
.
UsbPolicy
.
READ_WRITE
usbManager
.
setUsbPolicy
(
wantTemp
,
policy
).
then
(()
=>
{
console
.
info
(
'
Succeeded in setting usb policy
'
);
}).
catch
((
err
)
=>
{
console
.
error
(
`Failed to set usb policy. Code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
})
```
## UsbPolicy
USB读写策略的枚举。
**系统能力:**
SystemCapability.Customization.EnterpriseDeviceManager
**系统API**
: 此接口为系统接口。
| 名称 | 值 | 说明 |
| -------- | -------- | -------- |
| READ_WRITE | 0 | 可读可写。 |
| READ_ONLY | 1 | 只读。 |
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录