• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# @ohos.enterprise.systemManager (System Management)
2
3The **systemManager** module provides system management capabilities.
4
5> **NOTE**
6>
7> - The initial APIs of this module are supported since API version 11. Newly added APIs will be marked with a superscript to indicate their earliest API version.
8>
9> - The APIs of this module can be used only in the stage model.
10>
11> - The APIs provided by this module can be called only by a [device administrator application](enterpriseDeviceManagement-overview.md#basic-concepts) that is [enabled](js-apis-enterprise-adminManager.md#adminmanagerenableadmin).
12
13## Modules to Import
14
15```ts
16import systemManager from '@ohos.enterprise.systemManager';
17```
18
19## systemManager.setNTPServer
20
21setNTPServer(admin: Want, server: string): void
22
23Sets the NTP server information through the specified device administrator application.
24
25**Required permissions**: ohos.permission.ENTERPRISE_MANAGE_SYSTEM
26
27**System capability**: SystemCapability.Customization.EnterpriseDeviceManager
28
29**System API**: This is a system API.
30
31**Parameters**
32
33| Name  | Type                                 | Mandatory  | Description     |
34| ----- | ----------------------------------- | ---- | ------- |
35| admin | [Want](js-apis-app-ability-want.md) | Yes   | Device administrator application.|
36| server | string | Yes| NTP server addresses separated by a comma (,). For example, **ntpserver1.com,ntpserver2.com**.|
37
38**Error codes**
39
40For details about the error codes, see [Enterprise Device Management Error Codes](../errorcodes/errorcode-enterpriseDeviceManager.md).
41
42| ID| Error Message                                                                     |
43| ------- | ---------------------------------------------------------------------------- |
44| 9200001 | the application is not an administrator of the device.                       |
45| 9200002 | the administrator application does not have permission to manage the device. |
46
47**Example**
48
49```ts
50import systemManager from '@ohos.enterprise.systemManager';
51import Want from '@ohos.app.ability.Want';
52let wantTemp: Want = {
53  bundleName: 'com.example.myapplication',
54  abilityName: 'EntryAbility',
55};
56let server: string = "ntpserver.com";
57try {
58  systemManager.setNTPServer(wantTemp, server);
59  console.info('Succeeded in setting NTPserver');
60} catch (err) {
61  console.error(`Failed to set usb policy. Code is ${err.code}, message is ${err.message}`);
62}
63```
64
65## systemManager.getNTPServer
66
67getNTPServer(admin: Want): string
68
69Obtains the NTP server information through the specified device administrator application.
70
71**Required permissions**: ohos.permission.ENTERPRISE_MANAGE_SYSTEM
72
73**System capability**: SystemCapability.Customization.EnterpriseDeviceManager
74
75**System API**: This is a system API.
76
77**Parameters**
78
79| Name| Type                               | Mandatory| Description          |
80| ------ | ----------------------------------- | ---- | -------------- |
81| admin  | [Want](js-apis-app-ability-want.md) | Yes  | Device administrator application.|
82
83**Return value**
84
85| Type  | Description                           |
86| ------ | ------------------------------- |
87| string | NTP server information obtained.|
88
89**Error codes**
90
91For details about the error codes, see [Enterprise Device Management Error Codes](../errorcodes/errorcode-enterpriseDeviceManager.md).
92
93| ID| Error Message                                                    |
94| -------- | ------------------------------------------------------------ |
95| 9200001  | the application is not an administrator of the device.       |
96| 9200002  | the administrator application does not have permission to manage the device. |
97
98**Example**
99
100```ts
101import systemManager from '@ohos.enterprise.systemManager';
102import Want from '@ohos.app.ability.Want';
103import { BusinessError } from '@ohos.base';
104let wantTemp: Want = {
105  bundleName: 'com.example.myapplication',
106  abilityName: 'EntryAbility',
107};
108try {
109  systemManager.getNTPServer(wantTemp);
110  console.info('Succeeded in getting NTP server');
111} catch (err) {
112  console.error(`Failed to set usb policy. Code is ${err.code}, message is ${err.message}`);
113}
114```
115## SystemUpdateInfo<sup>11+</sup>
116
117Represents information about the system version to update.
118
119 **System capability**: SystemCapability.Customization.EnterpriseDeviceManager
120
121 **System API**: This is a system API.
122
123| Name               | Type    | Mandatory | Description           |
124| ----------------- | ------ | --- | ------------- |
125| versionName       | string | Yes  | System version to update.  |
126| firstReceivedTime | number | Yes  | Time when the system update package is received for the first time.|
127| packageType       | string | Yes  | Type of the system update package to update. |
128