Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Docs
提交
9f0665c9
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看板
提交
9f0665c9
编写于
11月 23, 2022
作者:
L
liwuli
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
update EDM API docs
Signed-off-by:
N
liwuli
<
liwuli@huawei.com
>
上级
bbc278c1
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
251 addition
and
253 deletion
+251
-253
zh-cn/application-dev/reference/apis/js-apis-EnterpriseAdminExtensionAbility.md
...reference/apis/js-apis-EnterpriseAdminExtensionAbility.md
+1
-1
zh-cn/application-dev/reference/apis/js-apis-enterprise-adminManager.md
...ion-dev/reference/apis/js-apis-enterprise-adminManager.md
+43
-125
zh-cn/application-dev/reference/apis/js-apis-enterprise-dateTimeManager.md
...-dev/reference/apis/js-apis-enterprise-dateTimeManager.md
+103
-127
zh-cn/application-dev/reference/apis/js-apis-enterprise-deviceInfo.md
...ation-dev/reference/apis/js-apis-enterprise-deviceInfo.md
+104
-0
未找到文件。
zh-cn/application-dev/reference/apis/js-apis-EnterpriseAdminExtensionAbility.md
浏览文件 @
9f0665c9
...
...
@@ -13,7 +13,7 @@
## 导入模块
```
ts
import
EnterpriseAdminExtensionAbility
from
'
@ohos.EnterpriseAdminExtensionAbility
'
import
EnterpriseAdminExtensionAbility
from
'
@ohos.
enterprise.
EnterpriseAdminExtensionAbility
'
```
## EnterpriseAdminExtensionAbility.onAdminEnabled
...
...
zh-cn/application-dev/reference/apis/js-apis-enterprise-
device-m
anager.md
→
zh-cn/application-dev/reference/apis/js-apis-enterprise-
adminM
anager.md
浏览文件 @
9f0665c9
...
...
@@ -9,10 +9,10 @@
## 导入模块
```
js
import
enterpriseDeviceManager
from
'
@ohos.enterpriseDevice
Manager
'
;
import
adminManager
from
'
@ohos.enterprise.admin
Manager
'
;
```
##
enterpriseDevice
Manager.enableAdmin
##
admin
Manager.enableAdmin
enableAdmin(admin: Want, enterpriseInfo: EnterpriseInfo, type: AdminType, callback: AsyncCallback
\<
void>): void
...
...
@@ -54,7 +54,7 @@ let enterpriseInfo = {
name
:
"
enterprise name
"
,
description
:
"
enterprise description
"
}
enterpriseDeviceManager
.
enableAdmin
(
wantTemp
,
enterpriseInfo
,
enterpriseDevice
Manager
.
AdminType
.
ADMIN_TYPE_NORMAL
,
error
=>
{
adminManager
.
enableAdmin
(
wantTemp
,
enterpriseInfo
,
admin
Manager
.
AdminType
.
ADMIN_TYPE_NORMAL
,
error
=>
{
if
(
error
!=
null
)
{
console
.
log
(
"
error occurs
"
+
error
);
return
;
...
...
@@ -63,7 +63,7 @@ enterpriseDeviceManager.enableAdmin(wantTemp, enterpriseInfo, enterpriseDeviceMa
});
```
##
enterpriseDevice
Manager.enableAdmin
##
admin
Manager.enableAdmin
enableAdmin(admin: Want, enterpriseInfo: EnterpriseInfo, type: AdminType, userId: number, callback: AsyncCallback
\<
void>): void
...
...
@@ -106,7 +106,7 @@ let enterpriseInfo = {
name
:
"
enterprise name
"
,
description
:
"
enterprise description
"
}
enterpriseDeviceManager
.
enableAdmin
(
wantTemp
,
enterpriseInfo
,
enterpriseDevice
Manager
.
AdminType
.
ADMIN_TYPE_NORMAL
,
100
,
error
=>
{
adminManager
.
enableAdmin
(
wantTemp
,
enterpriseInfo
,
admin
Manager
.
AdminType
.
ADMIN_TYPE_NORMAL
,
100
,
error
=>
{
if
(
error
!=
null
)
{
console
.
log
(
"
error occurs
"
+
error
);
return
;
...
...
@@ -115,7 +115,7 @@ enterpriseDeviceManager.enableAdmin(wantTemp, enterpriseInfo, enterpriseDeviceMa
});
```
##
enterpriseDevice
Manager.enableAdmin
##
admin
Manager.enableAdmin
enableAdmin(admin: Want, enterpriseInfo: EnterpriseInfo, type: AdminType, userId?: number): Promise
\<
void>
...
...
@@ -163,13 +163,13 @@ let enterpriseInfo = {
name
:
"
enterprise name
"
,
description
:
"
enterprise description
"
}
enterpriseDeviceManager
.
enableAdmin
(
wantTemp
,
enterpriseInfo
,
enterpriseDevice
Manager
.
AdminType
.
ADMIN_TYPE_NORMAL
,
100
)
adminManager
.
enableAdmin
(
wantTemp
,
enterpriseInfo
,
admin
Manager
.
AdminType
.
ADMIN_TYPE_NORMAL
,
100
)
.
catch
(
error
=>
{
console
.
log
(
"
error occurs
"
+
error
);
});
```
##
enterpriseDevice
Manager.disableAdmin
##
admin
Manager.disableAdmin
disableAdmin(admin: Want, callback: AsyncCallback
\<
void>): void
...
...
@@ -203,7 +203,7 @@ let wantTemp = {
bundleName
:
"
bundleName
"
,
abilityName
:
"
abilityName
"
,
};
enterpriseDevice
Manager
.
disableAdmin
(
wantTemp
,
error
=>
{
admin
Manager
.
disableAdmin
(
wantTemp
,
error
=>
{
if
(
error
!=
null
)
{
console
.
log
(
"
error occurs
"
+
error
);
return
;
...
...
@@ -212,7 +212,7 @@ enterpriseDeviceManager.disableAdmin(wantTemp, error => {
});
```
##
enterpriseDevice
Manager.disableAdmin
##
admin
Manager.disableAdmin
disableAdmin(admin: Want, userId: number, callback: AsyncCallback
\<
void>): void
...
...
@@ -247,7 +247,7 @@ let wantTemp = {
bundleName
:
"
bundleName
"
,
abilityName
:
"
abilityName
"
,
};
enterpriseDevice
Manager
.
disableAdmin
(
wantTemp
,
100
,
error
=>
{
admin
Manager
.
disableAdmin
(
wantTemp
,
100
,
error
=>
{
if
(
error
!=
null
)
{
console
.
log
(
"
error occurs
"
+
error
);
return
;
...
...
@@ -256,7 +256,7 @@ enterpriseDeviceManager.disableAdmin(wantTemp, 100, error => {
});
```
##
enterpriseDevice
Manager.disableAdmin
##
admin
Manager.disableAdmin
disableAdmin(admin: Want, userId?: number): Promise
\<
void>
...
...
@@ -296,12 +296,12 @@ let wantTemp = {
bundleName
:
"
bundleName
"
,
abilityName
:
"
abilityName
"
,
};
enterpriseDevice
Manager
.
disableAdmin
(
wantTemp
,
100
).
catch
(
error
=>
{
admin
Manager
.
disableAdmin
(
wantTemp
,
100
).
catch
(
error
=>
{
console
.
log
(
"
error occurs
"
+
error
);
});
```
##
enterpriseDevice
Manager.disableSuperAdmin
##
admin
Manager.disableSuperAdmin
disableSuperAdmin(bundleName: String, callback: AsyncCallback
\<
void>): void
...
...
@@ -332,7 +332,7 @@ disableSuperAdmin(bundleName: String, callback: AsyncCallback\<void>): void
```
js
let
bundleName
=
"
com.example.myapplication
"
;
enterpriseDevice
Manager
.
disableSuperAdmin
(
bundleName
,
error
=>
{
admin
Manager
.
disableSuperAdmin
(
bundleName
,
error
=>
{
if
(
error
!=
null
)
{
console
.
log
(
"
error occurs
"
+
error
);
return
;
...
...
@@ -341,7 +341,7 @@ enterpriseDeviceManager.disableSuperAdmin(bundleName, error => {
});
```
##
enterpriseDevice
Manager.disableSuperAdmin
##
admin
Manager.disableSuperAdmin
disableSuperAdmin(bundleName: String): Promise
\<
void>
...
...
@@ -377,12 +377,12 @@ disableSuperAdmin(bundleName: String): Promise\<void>
```
js
let
bundleName
=
"
com.example.myapplication
"
;
enterpriseDevice
Manager
.
disableSuperAdmin
(
bundleName
).
catch
(
error
=>
{
admin
Manager
.
disableSuperAdmin
(
bundleName
).
catch
(
error
=>
{
console
.
log
(
"
error occurs
"
+
error
);
});
```
##
enterpriseDevice
Manager.isAdminEnabled
##
admin
Manager.isAdminEnabled
isAdminEnabled(admin: Want, callback: AsyncCallback
\<
boolean>): void
...
...
@@ -414,7 +414,7 @@ let wantTemp = {
bundleName
:
"
bundleName
"
,
abilityName
:
"
abilityName
"
,
};
enterpriseDevice
Manager
.
isAdminEnabled
(
wantTemp
,
(
error
,
result
)
=>
{
admin
Manager
.
isAdminEnabled
(
wantTemp
,
(
error
,
result
)
=>
{
if
(
error
!=
null
)
{
console
.
log
(
"
error occurs
"
+
error
);
return
;
...
...
@@ -423,7 +423,7 @@ enterpriseDeviceManager.isAdminEnabled(wantTemp, (error, result) => {
});
```
##
enterpriseDevice
Manager.isAdminEnabled
##
admin
Manager.isAdminEnabled
isAdminEnabled(admin: Want, userId: number, callback: AsyncCallback
\<
boolean>): void
...
...
@@ -448,7 +448,7 @@ let wantTemp = {
bundleName
:
"
bundleName
"
,
abilityName
:
"
abilityName
"
,
};
enterpriseDevice
Manager
.
isAdminEnabled
(
wantTemp
,
100
,
(
error
,
result
)
=>
{
admin
Manager
.
isAdminEnabled
(
wantTemp
,
100
,
(
error
,
result
)
=>
{
if
(
error
!=
null
)
{
console
.
log
(
"
error occurs
"
+
error
);
return
;
...
...
@@ -457,7 +457,7 @@ enterpriseDeviceManager.isAdminEnabled(wantTemp, 100, (error, result) => {
});
```
##
enterpriseDevice
Manager.isAdminEnabled
##
admin
Manager.isAdminEnabled
isAdminEnabled(admin: Want, userId?: number): Promise
\<
boolean>
...
...
@@ -487,14 +487,14 @@ let wantTemp = {
bundleName
:
"
bundleName
"
,
abilityName
:
"
abilityName
"
,
};
enterpriseDevice
Manager
.
isAdminEnabled
(
wantTemp
,
100
).
then
((
result
)
=>
{
admin
Manager
.
isAdminEnabled
(
wantTemp
,
100
).
then
((
result
)
=>
{
console
.
log
(
"
result is
"
+
result
);
}).
catch
(
error
=>
{
console
.
log
(
"
error occurs
"
+
error
);
});
```
##
enterpriseDevice
Manager.isSuperAdmin
##
admin
Manager.isSuperAdmin
isSuperAdmin(bundleName: String, callback: AsyncCallback
\<
boolean>): void
...
...
@@ -515,7 +515,7 @@ isSuperAdmin(bundleName: String, callback: AsyncCallback\<boolean>): void
```
js
let
bundleName
=
"
com.example.myapplication
"
;
enterpriseDevice
Manager
.
isSuperAdmin
(
bundleName
,
(
error
,
result
)
=>
{
admin
Manager
.
isSuperAdmin
(
bundleName
,
(
error
,
result
)
=>
{
if
(
error
!=
null
)
{
console
.
log
(
"
error occurs
"
+
error
);
return
;
...
...
@@ -524,7 +524,7 @@ enterpriseDeviceManager.isSuperAdmin(bundleName, (error, result) => {
});
```
##
enterpriseDevice
Manager.isSuperAdmin
##
admin
Manager.isSuperAdmin
isSuperAdmin(bundleName: String): Promise
\<
boolean>
...
...
@@ -550,96 +550,14 @@ isSuperAdmin(bundleName: String): Promise\<boolean>
```
js
let
bundleName
=
"
com.example.myapplication
"
;
enterpriseDevice
Manager
.
isSuperAdmin
(
bundleName
).
then
((
result
)
=>
{
admin
Manager
.
isSuperAdmin
(
bundleName
).
then
((
result
)
=>
{
console
.
log
(
"
result is
"
+
result
);
}).
catch
(
error
=>
{
console
.
log
(
"
error occurs
"
+
error
);
});
```
## enterpriseDeviceManager.getDeviceSettingsManager
getDeviceSettingsManager(callback: AsyncCallback
<
DeviceSettingsManager
>
): void
获取DeviceSettingsManager对象,使用callback形式返回DeviceSettingsManager对象。
**系统能力:**
SystemCapability.Customization.EnterpriseDeviceManager
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | --------------------------------------- | ---- | ----------------------------------- |
| callback | AsyncCallback<
[
DeviceSettingsManager
](
js-apis-enterpriseDeviceManager-DeviceSettingsManager.md
)
>
| 是 | callback方式返回DeviceSettingsManager对象 |
**错误码**
:
以下的错误码的详细介绍请参见
[
企业设备管理错误码
](
../errorcodes/errorcode-enterpriseDeviceManager.md
)
| 类型 | 说明 |
| ------- | ---------------------------------------------------------------------------- |
| 9200001 | The application is not a administrator of the device. |
| 9200002 | The administrator application does not have permission to manage the device. |
**示例:**
```
js
let
wantTemp
=
{
bundleName
:
"
bundleName
"
,
abilityName
:
"
abilityName
"
,
};
enterpriseDeviceManager
.
getDeviceSettingsManager
((
error
,
mgr
)
=>
{
if
(
error
!=
null
)
{
console
.
log
(
"
error code:
"
+
error
.
code
);
return
;
}
mgr
.
setDateTime
(
wantTemp
,
1526003846000
,
(
error
)
=>
{
if
(
error
!=
null
)
{
console
.
log
(
"
error code:
"
+
error
.
code
);
}
});
});
```
## enterpriseDeviceManager.getDeviceSettingsManager
getDeviceSettingsManager(): Promise
<
DeviceSettingsManager
>
获取DeviceSettingsManager对象,使用Promise形式返回DeviceSettingsManager对象。
**系统能力:**
SystemCapability.Customization.EnterpriseDeviceManager
**返回值:**
| 类型 | 说明 |
| ------------------------------------ | ---------------------------------- |
| Promise
<
[DeviceSettingsManager](js-apis-enterpriseDeviceManager-DeviceSettingsManager.md)
>
| Promise方式返回DeviceSettingsManager对象 |
**错误码**
:
以下的错误码的详细介绍请参见
[
企业设备管理错误码
](
../errorcodes/errorcode-enterpriseDeviceManager.md
)
| 类型 | 说明 |
| ------- | ---------------------------------------------------------------------------- |
| 9200001 | The application is not a administrator of the device. |
| 9200002 | The administrator application does not have permission to manage the device. |
**示例:**
```
js
let
wantTemp
=
{
bundleName
:
"
bundleName
"
,
abilityName
:
"
abilityName
"
,
};
enterpriseDeviceManager
.
getDeviceSettingsManager
().
then
((
mgr
)
=>
{
mgr
.
setDateTime
(
wantTemp
,
1526003846000
).
catch
((
error
)
=>
{
console
.
log
(
"
error code:
"
+
error
.
code
);
})
}).
catch
((
error
)
=>
{
console
.
log
(
"
error code:
"
+
error
.
code
);
})
```
## enterpriseDeviceManager.setEnterpriseInfo
## adminManager.setEnterpriseInfo
setEnterpriseInfo(admin: Want, enterpriseInfo: EnterpriseInfo, callback: AsyncCallback
\<
void>;): void
...
...
@@ -678,7 +596,7 @@ let enterpriseInfo = {
name
:
"
enterprise name
"
,
description
:
"
enterprise description
"
}
enterpriseDevice
Manager
.
setEnterpriseInfo
(
wantTemp
,
enterpriseInfo
,
error
=>
{
admin
Manager
.
setEnterpriseInfo
(
wantTemp
,
enterpriseInfo
,
error
=>
{
if
(
error
!=
null
)
{
console
.
log
(
"
error occurs
"
+
error
);
return
;
...
...
@@ -687,7 +605,7 @@ enterpriseDeviceManager.setEnterpriseInfo(wantTemp, enterpriseInfo, error => {
});
```
##
enterpriseDevice
Manager.setEnterpriseInfo
##
admin
Manager.setEnterpriseInfo
setEnterpriseInfo(admin: Want, enterpriseInfo: EnterpriseInfo): Promise
\<
void>;
...
...
@@ -731,12 +649,12 @@ let enterpriseInfo = {
name
:
"
enterprise name
"
,
description
:
"
enterprise description
"
}
enterpriseDevice
Manager
.
setEnterpriseInfo
(
wantTemp
,
enterpriseInfo
).
catch
(
error
=>
{
admin
Manager
.
setEnterpriseInfo
(
wantTemp
,
enterpriseInfo
).
catch
(
error
=>
{
console
.
log
(
"
error occurs
"
+
error
);
});
```
##
enterpriseDevice
Manager.getEnterpriseInfo
##
admin
Manager.getEnterpriseInfo
getEnterpriseInfo(admin: Want, callback: AsyncCallback
<
EnterpriseInfo
>
): void
...
...
@@ -768,7 +686,7 @@ let wantTemp = {
bundleName
:
"
com.example.myapplication
"
,
abilityName
:
"
com.example.myapplication.MainAbility
"
,
};
enterpriseDevice
Manager
.
getEnterpriseInfo
(
wantTemp
,
(
error
,
result
)
=>
{
admin
Manager
.
getEnterpriseInfo
(
wantTemp
,
(
error
,
result
)
=>
{
if
(
error
!=
null
)
{
console
.
log
(
"
error occurs
"
+
error
);
return
;
...
...
@@ -778,7 +696,7 @@ enterpriseDeviceManager.getEnterpriseInfo(wantTemp, (error, result) => {
});
```
##
enterpriseDevice
Manager.getEnterpriseInfo
##
admin
Manager.getEnterpriseInfo
getEnterpriseInfo(admin: Want): Promise
<
EnterpriseInfo
>
...
...
@@ -815,7 +733,7 @@ let wantTemp = {
bundleName
:
"
com.example.myapplication
"
,
abilityName
:
"
com.example.myapplication.MainAbility
"
,
};
enterpriseDevice
Manager
.
getEnterpriseInfo
(
wantTemp
).
then
((
result
)
=>
{
admin
Manager
.
getEnterpriseInfo
(
wantTemp
).
then
((
result
)
=>
{
console
.
log
(
result
.
name
);
console
.
log
(
result
.
description
);
}).
catch
(
error
=>
{
...
...
@@ -823,7 +741,7 @@ enterpriseDeviceManager.getEnterpriseInfo(wantTemp).then((result) => {
});
```
##
enterpriseDevice
Manager.subscribeManagedEvent
##
admin
Manager.subscribeManagedEvent
subscribeManagedEvent(admin: Want, managedEvents: Array
\<
ManagedEvent>, callback: AsyncCallback
\<
void>): void
...
...
@@ -851,14 +769,14 @@ let wantTemp = {
abilityName
:
"
abilityName
"
,
};
let
events
=
[
0
,
1
];
enterpriseDevice
Manager
.
subscribeManagedEvent
(
wantTemp
,
events
,
(
error
)
=>
{
admin
Manager
.
subscribeManagedEvent
(
wantTemp
,
events
,
(
error
)
=>
{
if
(
error
)
{
console
.
log
(
"
error code:
"
+
error
.
code
+
"
error message:
"
+
error
.
message
);
}
});
```
##
enterpriseDevice
Manager.subscribeManagedEvent
##
admin
Manager.subscribeManagedEvent
subscribeManagedEvent(admin: Want, managedEvents: Array
\<
ManagedEvent>): Promise
\<
void>
...
...
@@ -891,13 +809,13 @@ let wantTemp = {
abilityName
:
"
abilityName
"
,
};
let
events
=
[
0
,
1
];
enterpriseDevice
Manager
.
subscribeManagedEvent
(
wantTemp
,
events
).
then
(()
=>
{
admin
Manager
.
subscribeManagedEvent
(
wantTemp
,
events
).
then
(()
=>
{
}).
catch
((
error
)
=>
{
console
.
log
(
"
error code:
"
+
error
.
code
+
"
error message:
"
+
error
.
message
);
})
```
##
enterpriseDevice
Manager.unsubscribeManagedEvent
##
admin
Manager.unsubscribeManagedEvent
unsubscribeManagedEvent(admin: Want, managedEvents: Array
\<
ManagedEvent>, callback: AsyncCallback
\<
void>): void
...
...
@@ -925,14 +843,14 @@ let wantTemp = {
abilityName
:
"
abilityName
"
,
};
let
events
=
[
0
,
1
];
enterpriseDevice
Manager
.
unsubscribeManagedEvent
(
wantTemp
,
events
,
(
error
)
=>
{
admin
Manager
.
unsubscribeManagedEvent
(
wantTemp
,
events
,
(
error
)
=>
{
if
(
error
)
{
console
.
log
(
"
error code:
"
+
error
.
code
+
"
error message:
"
+
error
.
message
);
}
});
```
##
enterpriseDevice
Manager.unsubscribeManagedEvent
##
admin
Manager.unsubscribeManagedEvent
unsubscribeManagedEvent(admin: Want, managedEvents: Array
\<
ManagedEvent>): Promise
\<
void>
...
...
@@ -965,7 +883,7 @@ let wantTemp = {
abilityName
:
"
abilityName
"
,
};
let
events
=
[
0
,
1
];
enterpriseDevice
Manager
.
unsubscribeManagedEvent
(
wantTemp
,
events
).
then
(()
=>
{
admin
Manager
.
unsubscribeManagedEvent
(
wantTemp
,
events
).
then
(()
=>
{
}).
catch
((
error
)
=>
{
console
.
log
(
"
error code:
"
+
error
.
code
+
"
error message:
"
+
error
.
message
);
})
...
...
zh-cn/application-dev/reference/apis/js-apis-enterprise
DeviceManager-DeviceSettings
Manager.md
→
zh-cn/application-dev/reference/apis/js-apis-enterprise
-dateTime
Manager.md
浏览文件 @
9f0665c9
# 设备设置管理
本模块提供设备设置管理能力,包括设置时间等。仅企业设备管理员应用才能调用。
> **说明**:
>
> 本模块首批接口从API version 9 开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
## 使用说明
通过enterpriseDeviceManager中getDeviceSettingsManager方法获取。
```
js
import
enterpriseDeviceManager
from
'
@ohos.enterpriseDeviceManager
'
enterpriseDeviceManager
.
getDeviceSettingsManager
((
error
,
mgr
)
=>
{
if
(
error
)
{
console
.
log
(
"
error code:
"
+
error
.
code
+
"
error message:
"
+
error
.
message
);
return
;
}
let
deviceMgr
=
mgr
;
});
```
## DeviceSettingsManager.setDateTime
setDateTime(admin: Want, time: number, callback: AsyncCallback
\<
void>): void
设置系统时间。使用callback异步回调。
**需要权限:**
ohos.permission.ENTERPRISE_SET_DATETIME
**系统能力:**
SystemCapability.Customization.EnterpriseDeviceManager
**系统API**
: 此接口为系统接口。
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ----- | ----------------------------------- | ---- | ------- |
| admin |
[
Want
](
js-apis-application-Want.md
)
| 是 | 设备管理员应用。 |
| time | number | 是 | 时间戳(ms)。 |
| callback | AsyncCallback
\<
void> | 是 | 回调函数。当系统时间设置成功err为null,否则为错误对象。 |
**错误码**
:
以下的错误码的详细介绍请参见
[
企业设备管理错误码
](
../errorcodes/errorcode-enterpriseDeviceManager.md
)
| 类型 | 说明 |
| ------- | ---------------------------------------------------------------------------- |
| 9200001 | The application is not a administrator of the device. |
| 9200002 | The administrator application does not have permission to manage the device. |
**示例:**
```
js
import
enterpriseDeviceManager
from
'
@ohos.enterpriseDeviceManager
'
let
wantTemp
=
{
bundleName
:
"
bundleName
"
,
abilityName
:
"
abilityName
"
,
};
enterpriseDeviceManager
.
getDeviceSettingsManager
((
error
,
mgr
)
=>
{
if
(
error
)
{
console
.
log
(
"
error code:
"
+
error
.
code
+
"
error message:
"
+
error
.
message
);
return
;
}
mgr
.
setDateTime
(
wantTemp
,
1526003846000
,
(
error
)
=>
{
if
(
error
)
{
console
.
log
(
"
error code:
"
+
error
.
code
+
"
error message:
"
+
error
.
message
);
}
});
});
```
## DeviceSettingsManager.setDateTime
setDateTime(admin: Want, time: number): Promise
\<
void>
设置系统时间。使用Promise异步回调。
**需要权限:**
ohos.permission.ENTERPRISE_SET_DATETIME
**系统能力:**
SystemCapability.Customization.EnterpriseDeviceManager
**系统API**
: 此接口为系统接口。
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ----- | ----------------------------------- | ---- | ------- |
| admin |
[
Want
](
js-apis-application-Want.md
)
| 是 | 设备管理员应用。 |
| time | number | 是 | 时间戳(ms)。 |
**返回值:**
| 类型 | 说明 |
| ----- | ----------------------------------- |
| Promise
\<
void> | Promise对象。无返回结果的Promise对象。 |
**错误码**
:
以下的错误码的详细介绍请参见
[
企业设备管理错误码
](
../errorcodes/errorcode-enterpriseDeviceManager.md
)
| 类型 | 说明 |
| ------- | ---------------------------------------------------------------------------- |
| 9200001 | The application is not a administrator of the device. |
| 9200002 | The administrator application does not have permission to manage the device. |
**示例:**
```
js
import
enterpriseDeviceManager
from
'
@ohos.enterpriseDeviceManager
'
let
wantTemp
=
{
bundleName
:
"
bundleName
"
,
abilityName
:
"
abilityName
"
,
};
enterpriseDeviceManager
.
getDeviceSettingsManager
().
then
((
mgr
)
=>
{
mgr
.
setDateTime
(
wantTemp
,
1526003846000
).
then
(()
=>
{
}).
catch
((
error
)
=>
{
console
.
log
(
"
error code:
"
+
error
.
code
+
"
error message:
"
+
error
.
message
);
})
}).
catch
((
error
)
=>
{
console
.
log
(
"
error code:
"
+
error
.
code
+
"
error message:
"
+
error
.
message
);
})
```
# 设备设置管理
本模块提供设备设置管理能力,包括设置时间等。仅企业设备管理员应用才能调用。
> **说明**:
>
> 本模块首批接口从API version 9 开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
## 导入模块
```
js
import
dateTimeManager
from
'
@ohos.enterprise.dateTimeManager
'
```
## dateTimeManager.setDateTime
setDateTime(admin: Want, time: number, callback: AsyncCallback
\<
void>): void
设置系统时间。使用callback异步回调。
**需要权限:**
ohos.permission.ENTERPRISE_SET_DATETIME
**系统能力:**
SystemCapability.Customization.EnterpriseDeviceManager
**系统API**
: 此接口为系统接口。
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ----- | ----------------------------------- | ---- | ------- |
| admin |
[
Want
](
js-apis-application-Want.md
)
| 是 | 设备管理员应用。 |
| time | number | 是 | 时间戳(ms)。 |
| callback | AsyncCallback
\<
void> | 是 | 回调函数。当系统时间设置成功err为null,否则为错误对象。 |
**错误码**
:
以下的错误码的详细介绍请参见
[
企业设备管理错误码
](
../errorcodes/errorcode-enterpriseDeviceManager.md
)
| 类型 | 说明 |
| ------- | ---------------------------------------------------------------------------- |
| 9200001 | The application is not a administrator of the device. |
| 9200002 | The administrator application does not have permission to manage the device. |
**示例:**
```
js
let
wantTemp
=
{
bundleName
:
"
bundleName
"
,
abilityName
:
"
abilityName
"
,
};
dateTimeManager
.
setDateTime
(
wantTemp
,
1526003846000
,
(
error
)
=>
{
if
(
error
)
{
console
.
log
(
"
error code:
"
+
error
.
code
+
"
error message:
"
+
error
.
message
);
}
})
```
## dateTimeManager.setDateTime
setDateTime(admin: Want, time: number): Promise
\<
void>
设置系统时间。使用Promise异步回调。
**需要权限:**
ohos.permission.ENTERPRISE_SET_DATETIME
**系统能力:**
SystemCapability.Customization.EnterpriseDeviceManager
**系统API**
: 此接口为系统接口。
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ----- | ----------------------------------- | ---- | ------- |
| admin |
[
Want
](
js-apis-application-Want.md
)
| 是 | 设备管理员应用。 |
| time | number | 是 | 时间戳(ms)。 |
**返回值:**
| 类型 | 说明 |
| ----- | ----------------------------------- |
| Promise
\<
void> | Promise对象。无返回结果的Promise对象。 |
**错误码**
:
以下的错误码的详细介绍请参见
[
企业设备管理错误码
](
../errorcodes/errorcode-enterpriseDeviceManager.md
)
| 类型 | 说明 |
| ------- | ---------------------------------------------------------------------------- |
| 9200001 | The application is not a administrator of the device. |
| 9200002 | The administrator application does not have permission to manage the device. |
**示例:**
```
js
let
wantTemp
=
{
bundleName
:
"
bundleName
"
,
abilityName
:
"
abilityName
"
,
};
dateTimeManager
.
setDateTime
(
admin
,
1526003846000
).
then
(()
=>
{
}).
catch
((
error
)
=>
{
console
.
log
(
"
error code:
"
+
error
.
code
+
"
error message:
"
+
error
.
message
);
})
```
zh-cn/application-dev/reference/apis/js-apis-enterprise-deviceInfo.md
0 → 100644
浏览文件 @
9f0665c9
# 企业设备信息管理
本模块提供企业设备信息管理能力,包括获取设备序列号等。仅企业设备管理员应用才能调用。
> **说明:**
>
> 本模块首批接口从API version 9开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
## 导入模块
```
js
import
deviceInfo
from
'
@ohos.enterprise.deviceInfo
'
;
```
## deviceInfo.getDeviceSerial
getDeviceSerial(admin: Want, callback: AsyncCallback
<string>
): void
获取设备序列号,使用callback形式返回设备序列号。
**需要权限:**
ohos.permission.ENTERPRISE_GET_DEVICE_INFO
**系统能力:**
SystemCapability.Customization.EnterpriseDeviceManager
**系统API**
: 此接口为系统接口。
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ---------------------------------------- | ---- | ------------------------------- |
| admin |
[
Want
](
js-apis-application-Want.md
)
| 是 | 设备管理员应用 |
| callback | AsyncCallback
<
string
>
| 是 | callback方式返回设备序列号 |
**错误码**
:
以下的错误码的详细介绍请参见
[
企业设备管理错误码
](
../errorcodes/errorcode-enterpriseDeviceManager.md
)
| 类型 | 说明 |
| ------- | ---------------------------------------------------------------------------- |
| 9200001 | The application is not a administrator of the device. |
| 9200002 | the administrator application does not have permission to manage the device. |
**示例:**
```
js
let
wantTemp
=
{
bundleName
:
"
com.example.myapplication
"
,
abilityName
:
"
com.example.myapplication.MainAbility
"
,
};
deviceInfo
.
getDeviceSerial
(
wantTemp
,
(
error
,
result
)
=>
{
if
(
error
!=
null
)
{
console
.
log
(
"
error code:
"
+
error
.
code
+
"
error message:
"
+
error
.
message
);
return
;
}
console
.
log
(
result
);
});
```
## deviceInfo.getDeviceSerial
getDeviceSerial(admin: Want, callback: AsyncCallback
<string>
): void
获取设备序列号,使用callback形式返回设备序列号。
**需要权限:**
ohos.permission.ENTERPRISE_GET_DEVICE_INFO
**系统能力:**
SystemCapability.Customization.EnterpriseDeviceManager
**系统API**
: 此接口为系统接口。
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ----- | ----------------------------------- | ---- | ------- |
| admin |
[
Want
](
js-apis-application-Want.md
)
| 是 | 设备管理员应用 |
**返回值:**
| 类型 | 说明 |
| --------------------- | ------------------------- |
| Promise
<
string
>
| Promise方式返回设备序列号 |
**错误码**
:
以下的错误码的详细介绍请参见
[
企业设备管理错误码
](
../errorcodes/errorcode-enterpriseDeviceManager.md
)
| 类型 | 说明 |
| ------- | ---------------------------------------------------------------------------- |
| 9200001 | The application is not a administrator of the device. |
| 9200002 | the administrator application does not have permission to manage the device. |
**示例:**
```
js
let
wantTemp
=
{
bundleName
:
"
com.example.myapplication
"
,
abilityName
:
"
com.example.myapplication.MainAbility
"
,
};
deviceInfo
.
getDeviceSerial
(
wantTemp
).
then
((
result
)
=>
{
console
.
log
(
result
);
}).
catch
(
error
=>
{
console
.
log
(
"
error code:
"
+
error
.
code
+
"
error message:
"
+
error
.
message
);
});
```
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录