1e41f4b71Sopenharmony_ci# @ohos.enterprise.systemManager (System Management) 2e41f4b71Sopenharmony_ci 3e41f4b71Sopenharmony_ciThe **systemManager** module provides system management capabilities. 4e41f4b71Sopenharmony_ci 5e41f4b71Sopenharmony_ci> **NOTE** 6e41f4b71Sopenharmony_ci> 7e41f4b71Sopenharmony_ci> The initial APIs of this module are supported since API version 12. Newly added APIs will be marked with a superscript to indicate their earliest API version. 8e41f4b71Sopenharmony_ci> 9e41f4b71Sopenharmony_ci> The APIs of this module can be used only in the stage model. 10e41f4b71Sopenharmony_ci> 11e41f4b71Sopenharmony_ci> The APIs of this module can be called only by a [device administrator application](../../mdm/mdm-kit-guide.md#introduction) that is enabled. 12e41f4b71Sopenharmony_ci 13e41f4b71Sopenharmony_ci## Modules to Import 14e41f4b71Sopenharmony_ci 15e41f4b71Sopenharmony_ci```ts 16e41f4b71Sopenharmony_ciimport { systemManager } from '@kit.MDMKit'; 17e41f4b71Sopenharmony_ci``` 18e41f4b71Sopenharmony_ci 19e41f4b71Sopenharmony_ci## systemManager.setNTPServer 20e41f4b71Sopenharmony_ci 21e41f4b71Sopenharmony_cisetNTPServer(admin: Want, server: string): void 22e41f4b71Sopenharmony_ci 23e41f4b71Sopenharmony_ciSets the NTP server information through the specified device administrator application. 24e41f4b71Sopenharmony_ci 25e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.ENTERPRISE_MANAGE_SYSTEM 26e41f4b71Sopenharmony_ci 27e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Customization.EnterpriseDeviceManager 28e41f4b71Sopenharmony_ci 29e41f4b71Sopenharmony_ci**Parameters** 30e41f4b71Sopenharmony_ci 31e41f4b71Sopenharmony_ci| Name | Type | Mandatory | Description | 32e41f4b71Sopenharmony_ci| ----- | ----------------------------------- | ---- | ------- | 33e41f4b71Sopenharmony_ci| admin | [Want](../apis-ability-kit/js-apis-app-ability-want.md) | Yes | Device administrator application.| 34e41f4b71Sopenharmony_ci| server | string | Yes| NTP server addresses separated by a comma (,). For example, **ntpserver1.com,ntpserver2.com**.| 35e41f4b71Sopenharmony_ci 36e41f4b71Sopenharmony_ci**Error codes** 37e41f4b71Sopenharmony_ci 38e41f4b71Sopenharmony_ciFor details about the error codes, see [Enterprise Device Management Error Codes](errorcode-enterpriseDeviceManager.md) and [Universal Error Codes](../errorcode-universal.md). 39e41f4b71Sopenharmony_ci 40e41f4b71Sopenharmony_ci| ID| Error Message | 41e41f4b71Sopenharmony_ci| ------- | ---------------------------------------------------------------------------- | 42e41f4b71Sopenharmony_ci| 9200001 | The application is not an administrator application of the device. | 43e41f4b71Sopenharmony_ci| 9200002 | The administrator application does not have permission to manage the device. | 44e41f4b71Sopenharmony_ci| 201 | Permission verification failed. The application does not have the permission required to call the API. | 45e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 46e41f4b71Sopenharmony_ci 47e41f4b71Sopenharmony_ci**Example** 48e41f4b71Sopenharmony_ci 49e41f4b71Sopenharmony_ci```ts 50e41f4b71Sopenharmony_ciimport { systemManager } from '@kit.MDMKit'; 51e41f4b71Sopenharmony_ciimport { Want } from '@kit.AbilityKit'; 52e41f4b71Sopenharmony_cilet wantTemp: Want = { 53e41f4b71Sopenharmony_ci bundleName: 'com.example.myapplication', 54e41f4b71Sopenharmony_ci abilityName: 'EntryAbility', 55e41f4b71Sopenharmony_ci}; 56e41f4b71Sopenharmony_cilet server: string = "ntpserver.com"; 57e41f4b71Sopenharmony_citry { 58e41f4b71Sopenharmony_ci systemManager.setNTPServer(wantTemp, server); 59e41f4b71Sopenharmony_ci console.info('Succeeded in setting NTPserver.'); 60e41f4b71Sopenharmony_ci} catch (err) { 61e41f4b71Sopenharmony_ci console.error(`Failed to set usb policy. Code is ${err.code}, message is ${err.message}`); 62e41f4b71Sopenharmony_ci} 63e41f4b71Sopenharmony_ci``` 64e41f4b71Sopenharmony_ci 65e41f4b71Sopenharmony_ci## systemManager.getNTPServer 66e41f4b71Sopenharmony_ci 67e41f4b71Sopenharmony_cigetNTPServer(admin: Want): string 68e41f4b71Sopenharmony_ci 69e41f4b71Sopenharmony_ciObtains the NTP server information through the specified device administrator application. 70e41f4b71Sopenharmony_ci 71e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.ENTERPRISE_MANAGE_SYSTEM 72e41f4b71Sopenharmony_ci 73e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Customization.EnterpriseDeviceManager 74e41f4b71Sopenharmony_ci 75e41f4b71Sopenharmony_ci**Parameters** 76e41f4b71Sopenharmony_ci 77e41f4b71Sopenharmony_ci| Name| Type | Mandatory| Description | 78e41f4b71Sopenharmony_ci| ------ | ----------------------------------- | ---- | -------------- | 79e41f4b71Sopenharmony_ci| admin | [Want](../apis-ability-kit/js-apis-app-ability-want.md) | Yes | Device administrator application.| 80e41f4b71Sopenharmony_ci 81e41f4b71Sopenharmony_ci**Return value** 82e41f4b71Sopenharmony_ci 83e41f4b71Sopenharmony_ci| Type | Description | 84e41f4b71Sopenharmony_ci| ------ | ------------------------------- | 85e41f4b71Sopenharmony_ci| string | NTP server information obtained.| 86e41f4b71Sopenharmony_ci 87e41f4b71Sopenharmony_ci**Error codes** 88e41f4b71Sopenharmony_ci 89e41f4b71Sopenharmony_ciFor details about the error codes, see [Enterprise Device Management Error Codes](errorcode-enterpriseDeviceManager.md) and [Universal Error Codes](../errorcode-universal.md). 90e41f4b71Sopenharmony_ci 91e41f4b71Sopenharmony_ci| ID| Error Message | 92e41f4b71Sopenharmony_ci| -------- | ------------------------------------------------------------ | 93e41f4b71Sopenharmony_ci| 9200001 | The application is not an administrator application of the device. | 94e41f4b71Sopenharmony_ci| 9200002 | The administrator application does not have permission to manage the device. | 95e41f4b71Sopenharmony_ci| 201 | Permission verification failed. The application does not have the permission required to call the API. | 96e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 97e41f4b71Sopenharmony_ci 98e41f4b71Sopenharmony_ci**Example** 99e41f4b71Sopenharmony_ci 100e41f4b71Sopenharmony_ci```ts 101e41f4b71Sopenharmony_ciimport { systemManager } from '@kit.MDMKit'; 102e41f4b71Sopenharmony_ciimport { Want } from '@kit.AbilityKit'; 103e41f4b71Sopenharmony_ciimport { BusinessError } from '@ohos.base'; 104e41f4b71Sopenharmony_cilet wantTemp: Want = { 105e41f4b71Sopenharmony_ci bundleName: 'com.example.myapplication', 106e41f4b71Sopenharmony_ci abilityName: 'EntryAbility', 107e41f4b71Sopenharmony_ci}; 108e41f4b71Sopenharmony_citry { 109e41f4b71Sopenharmony_ci systemManager.getNTPServer(wantTemp); 110e41f4b71Sopenharmony_ci console.info('Succeeded in getting NTP server.'); 111e41f4b71Sopenharmony_ci} catch (err) { 112e41f4b71Sopenharmony_ci console.error(`Failed to set usb policy. Code is ${err.code}, message is ${err.message}`); 113e41f4b71Sopenharmony_ci} 114e41f4b71Sopenharmony_ci``` 115e41f4b71Sopenharmony_ci 116e41f4b71Sopenharmony_ci## systemManager.setOtaUpdatePolicy 117e41f4b71Sopenharmony_ci 118e41f4b71Sopenharmony_cisetOtaUpdatePolicy(admin: Want, policy: OtaUpdatePolicy): void 119e41f4b71Sopenharmony_ci 120e41f4b71Sopenharmony_ciSets the over-the-air (OTA) update policy through the specified device administrator application. 121e41f4b71Sopenharmony_ci 122e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.ENTERPRISE_MANAGE_SYSTEM 123e41f4b71Sopenharmony_ci 124e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Customization.EnterpriseDeviceManager 125e41f4b71Sopenharmony_ci 126e41f4b71Sopenharmony_ci**Parameters** 127e41f4b71Sopenharmony_ci 128e41f4b71Sopenharmony_ci| Name | Type | Mandatory | Description | 129e41f4b71Sopenharmony_ci| ----- | ----------------------------------- | ---- | ------- | 130e41f4b71Sopenharmony_ci| admin | [Want](../apis-ability-kit/js-apis-app-ability-want.md) | Yes | Device administrator application.| 131e41f4b71Sopenharmony_ci| policy | [OtaUpdatePolicy](#otaupdatepolicy) | Yes| OTA update policy to set.| 132e41f4b71Sopenharmony_ci 133e41f4b71Sopenharmony_ci**Error codes** 134e41f4b71Sopenharmony_ci 135e41f4b71Sopenharmony_ciFor details about the error codes, see [Enterprise Device Management Error Codes](errorcode-enterpriseDeviceManager.md) and [Universal Error Codes](../errorcode-universal.md). 136e41f4b71Sopenharmony_ci 137e41f4b71Sopenharmony_ci| ID| Error Message | 138e41f4b71Sopenharmony_ci| ------- | ---------------------------------------------------------------------------- | 139e41f4b71Sopenharmony_ci| 9200001 | The application is not an administrator application of the device. | 140e41f4b71Sopenharmony_ci| 9200002 | The administrator application does not have permission to manage the device. | 141e41f4b71Sopenharmony_ci| 201 | Permission verification failed. The application does not have the permission required to call the API. | 142e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.| 143e41f4b71Sopenharmony_ci 144e41f4b71Sopenharmony_ci**Example** 145e41f4b71Sopenharmony_ci 146e41f4b71Sopenharmony_ci```ts 147e41f4b71Sopenharmony_ciimport { systemManager } from '@kit.MDMKit'; 148e41f4b71Sopenharmony_ciimport { Want } from '@kit.AbilityKit'; 149e41f4b71Sopenharmony_cilet wantTemp: Want = { 150e41f4b71Sopenharmony_ci bundleName: 'com.example.myapplication', 151e41f4b71Sopenharmony_ci abilityName: 'EntryAbility', 152e41f4b71Sopenharmony_ci}; 153e41f4b71Sopenharmony_ci// Default update policy. 154e41f4b71Sopenharmony_cilet otaUpdatePolicy1: systemManager.OtaUpdatePolicy = { 155e41f4b71Sopenharmony_ci "policyType": systemManager.PolicyType.DEFAULT, 156e41f4b71Sopenharmony_ci "version": "version_1.0.0.0", 157e41f4b71Sopenharmony_ci}; 158e41f4b71Sopenharmony_citry { 159e41f4b71Sopenharmony_ci systemManager.setOtaUpdatePolicy(wantTemp, otaUpdatePolicy1); 160e41f4b71Sopenharmony_ci console.info('Succeeded in setting ota update policy.'); 161e41f4b71Sopenharmony_ci} catch (err) { 162e41f4b71Sopenharmony_ci console.error(`Failed to set ota update policy. Code is ${err.code}, message is ${err.message}`); 163e41f4b71Sopenharmony_ci} 164e41f4b71Sopenharmony_ci// Prohibit update. 165e41f4b71Sopenharmony_cilet otaUpdatePolicy2: systemManager.OtaUpdatePolicy = { 166e41f4b71Sopenharmony_ci "policyType": systemManager.PolicyType.PROHIBIT, 167e41f4b71Sopenharmony_ci "version": "version_1.0.0.1", 168e41f4b71Sopenharmony_ci}; 169e41f4b71Sopenharmony_citry { 170e41f4b71Sopenharmony_ci systemManager.setOtaUpdatePolicy(wantTemp, otaUpdatePolicy2); 171e41f4b71Sopenharmony_ci console.info('Succeeded in setting ota update policy.'); 172e41f4b71Sopenharmony_ci} catch (err) { 173e41f4b71Sopenharmony_ci console.error(`Failed to set ota update policy. Code is ${err.code}, message is ${err.message}`); 174e41f4b71Sopenharmony_ci} 175e41f4b71Sopenharmony_ci// Enforce update. 176e41f4b71Sopenharmony_cilet otaUpdatePolicy3: systemManager.OtaUpdatePolicy = { 177e41f4b71Sopenharmony_ci "policyType": systemManager.PolicyType.UPDATE_TO_SPECIFIC_VERSION, 178e41f4b71Sopenharmony_ci "version": "version_1.0.0.2", 179e41f4b71Sopenharmony_ci "latestUpdateTime": 1716343200, // Timestamp 180e41f4b71Sopenharmony_ci}; 181e41f4b71Sopenharmony_citry { 182e41f4b71Sopenharmony_ci systemManager.setOtaUpdatePolicy(wantTemp, otaUpdatePolicy3); 183e41f4b71Sopenharmony_ci console.info('Succeeded in setting ota update policy.'); 184e41f4b71Sopenharmony_ci} catch (err) { 185e41f4b71Sopenharmony_ci console.error(`Failed to set ota update policy. Code is ${err.code}, message is ${err.message}`); 186e41f4b71Sopenharmony_ci} 187e41f4b71Sopenharmony_ci// Update at the specified time period. 188e41f4b71Sopenharmony_cilet otaUpdatePolicy4: systemManager.OtaUpdatePolicy = { 189e41f4b71Sopenharmony_ci "policyType": systemManager.PolicyType.WINDOWS, 190e41f4b71Sopenharmony_ci "version": "version_1.0.0.3", 191e41f4b71Sopenharmony_ci "installStartTime": 1716281049, // Timestamp 192e41f4b71Sopenharmony_ci "installEndTime": 1716343200, // Timestamp 193e41f4b71Sopenharmony_ci}; 194e41f4b71Sopenharmony_citry { 195e41f4b71Sopenharmony_ci systemManager.setOtaUpdatePolicy(wantTemp, otaUpdatePolicy4); 196e41f4b71Sopenharmony_ci console.info('Succeeded in setting ota update policy.'); 197e41f4b71Sopenharmony_ci} catch (err) { 198e41f4b71Sopenharmony_ci console.error(`Failed to set ota update policy. Code is ${err.code}, message is ${err.message}`); 199e41f4b71Sopenharmony_ci} 200e41f4b71Sopenharmony_ci// Delay the update. 201e41f4b71Sopenharmony_cilet otaUpdatePolicy5: systemManager.OtaUpdatePolicy = { 202e41f4b71Sopenharmony_ci "policyType": systemManager.PolicyType.POSTPONE, 203e41f4b71Sopenharmony_ci "version": "version_1.0.0.4", 204e41f4b71Sopenharmony_ci "delayUpdateTime": 5, // Time for which the update is delayed, in hours. 205e41f4b71Sopenharmony_ci}; 206e41f4b71Sopenharmony_citry { 207e41f4b71Sopenharmony_ci systemManager.setOtaUpdatePolicy(wantTemp, otaUpdatePolicy5); 208e41f4b71Sopenharmony_ci console.info('Succeeded in setting ota update policy.'); 209e41f4b71Sopenharmony_ci} catch (err) { 210e41f4b71Sopenharmony_ci console.error(`Failed to set ota update policy. Code is ${err.code}, message is ${err.message}`); 211e41f4b71Sopenharmony_ci} 212e41f4b71Sopenharmony_ci 213e41f4b71Sopenharmony_ci``` 214e41f4b71Sopenharmony_ci 215e41f4b71Sopenharmony_ci## systemManager.getOtaUpdatePolicy 216e41f4b71Sopenharmony_ci 217e41f4b71Sopenharmony_cigetOtaUpdatePolicy(admin: Want): OtaUpdatePolicy 218e41f4b71Sopenharmony_ci 219e41f4b71Sopenharmony_ciObtains the OTA update policy through the specified device administrator application. 220e41f4b71Sopenharmony_ci 221e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.ENTERPRISE_MANAGE_SYSTEM 222e41f4b71Sopenharmony_ci 223e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Customization.EnterpriseDeviceManager 224e41f4b71Sopenharmony_ci 225e41f4b71Sopenharmony_ci**Parameters** 226e41f4b71Sopenharmony_ci 227e41f4b71Sopenharmony_ci| Name| Type | Mandatory| Description | 228e41f4b71Sopenharmony_ci| ------ | ----------------------------------- | ---- | -------------- | 229e41f4b71Sopenharmony_ci| admin | [Want](../apis-ability-kit/js-apis-app-ability-want.md) | Yes | Device administrator application.| 230e41f4b71Sopenharmony_ci 231e41f4b71Sopenharmony_ci**Return value** 232e41f4b71Sopenharmony_ci 233e41f4b71Sopenharmony_ci| Type | Description | 234e41f4b71Sopenharmony_ci| ------ | ------------------------------- | 235e41f4b71Sopenharmony_ci| [OtaUpdatePolicy](#otaupdatepolicy) | **OtaUpdatePolicy** object containing the update policy obtained.| 236e41f4b71Sopenharmony_ci 237e41f4b71Sopenharmony_ci**Error codes** 238e41f4b71Sopenharmony_ci 239e41f4b71Sopenharmony_ciFor details about the error codes, see [Enterprise Device Management Error Codes](errorcode-enterpriseDeviceManager.md) and [Universal Error Codes](../errorcode-universal.md). 240e41f4b71Sopenharmony_ci 241e41f4b71Sopenharmony_ci| ID| Error Message | 242e41f4b71Sopenharmony_ci| -------- | ------------------------------------------------------------ | 243e41f4b71Sopenharmony_ci| 9200001 | The application is not an administrator application of the device. | 244e41f4b71Sopenharmony_ci| 9200002 | The administrator application does not have permission to manage the device. | 245e41f4b71Sopenharmony_ci| 201 | Permission verification failed. The application does not have the permission required to call the API. | 246e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.| 247e41f4b71Sopenharmony_ci 248e41f4b71Sopenharmony_ci**Example** 249e41f4b71Sopenharmony_ci 250e41f4b71Sopenharmony_ci```ts 251e41f4b71Sopenharmony_ciimport { systemManager } from '@kit.MDMKit'; 252e41f4b71Sopenharmony_ciimport { Want } from '@kit.AbilityKit'; 253e41f4b71Sopenharmony_cilet wantTemp: Want = { 254e41f4b71Sopenharmony_ci bundleName: 'com.example.myapplication', 255e41f4b71Sopenharmony_ci abilityName: 'EntryAbility', 256e41f4b71Sopenharmony_ci}; 257e41f4b71Sopenharmony_citry { 258e41f4b71Sopenharmony_ci let policy: systemManager.OtaUpdatePolicy= systemManager.getOtaUpdatePolicy(wantTemp); 259e41f4b71Sopenharmony_ci console.info(`Succeeded in getting update policy: ${JSON.stringify(policy)}`); 260e41f4b71Sopenharmony_ci} catch (err) { 261e41f4b71Sopenharmony_ci console.error(`Failed to get update policy. Code is ${err.code}, message is ${err.message}`); 262e41f4b71Sopenharmony_ci} 263e41f4b71Sopenharmony_ci``` 264e41f4b71Sopenharmony_ci 265e41f4b71Sopenharmony_ci## systemManager.notifyUpdatePackages 266e41f4b71Sopenharmony_ci 267e41f4b71Sopenharmony_cinotifyUpdatePackages(admin: Want, packageInfo: UpdatePackageInfo): Promise<void> 268e41f4b71Sopenharmony_ci 269e41f4b71Sopenharmony_ciNotifies the system of the update packages. 270e41f4b71Sopenharmony_ci 271e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.ENTERPRISE_MANAGE_SYSTEM 272e41f4b71Sopenharmony_ci 273e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Customization.EnterpriseDeviceManager 274e41f4b71Sopenharmony_ci 275e41f4b71Sopenharmony_ci**Parameters** 276e41f4b71Sopenharmony_ci 277e41f4b71Sopenharmony_ci| Name| Type | Mandatory| Description | 278e41f4b71Sopenharmony_ci| ------ | ----------------------------------- | ---- | -------------- | 279e41f4b71Sopenharmony_ci| admin | [Want](../apis-ability-kit/js-apis-app-ability-want.md) | Yes | Device administrator application.| 280e41f4b71Sopenharmony_ci| packageInfo | [UpdatePackageInfo](#updatepackageinfo) | Yes | Information about the system update packages.| 281e41f4b71Sopenharmony_ci 282e41f4b71Sopenharmony_ci**Return value** 283e41f4b71Sopenharmony_ci 284e41f4b71Sopenharmony_ci| Type | Description | 285e41f4b71Sopenharmony_ci| --------------------- | ------------------------- | 286e41f4b71Sopenharmony_ci| Promise<void> | Promise that returns no value. An error object will be thrown if the operation fails.| 287e41f4b71Sopenharmony_ci 288e41f4b71Sopenharmony_ci**Error codes** 289e41f4b71Sopenharmony_ci 290e41f4b71Sopenharmony_ciFor details about the error codes, see [Enterprise Device Management Error Codes](errorcode-enterpriseDeviceManager.md) and [Universal Error Codes](../errorcode-universal.md). 291e41f4b71Sopenharmony_ci 292e41f4b71Sopenharmony_ci| ID| Error Message | 293e41f4b71Sopenharmony_ci| -------- | ------------------------------------------------------------ | 294e41f4b71Sopenharmony_ci| 9200001 | The application is not an administrator application of the device. | 295e41f4b71Sopenharmony_ci| 9200002 | The administrator application does not have permission to manage the device. | 296e41f4b71Sopenharmony_ci| 9201004 | The update packages do not exist or analyzing failed. | 297e41f4b71Sopenharmony_ci| 201 | Permission verification failed. The application does not have the permission required to call the API. | 298e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.| 299e41f4b71Sopenharmony_ci 300e41f4b71Sopenharmony_ci**Example** 301e41f4b71Sopenharmony_ci 302e41f4b71Sopenharmony_ci```ts 303e41f4b71Sopenharmony_ciimport { systemManager } from '@kit.MDMKit'; 304e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit'; 305e41f4b71Sopenharmony_ciimport { Want } from '@kit.AbilityKit'; 306e41f4b71Sopenharmony_cilet wantTemp: Want = { 307e41f4b71Sopenharmony_ci bundleName: 'com.example.myapplication', 308e41f4b71Sopenharmony_ci abilityName: 'EntryAbility', 309e41f4b71Sopenharmony_ci}; 310e41f4b71Sopenharmony_cilet notify: systemManager.NotifyDescription = { 311e41f4b71Sopenharmony_ci "installTips": "installTips", 312e41f4b71Sopenharmony_ci "installTipsDetail": "installTips detail" 313e41f4b71Sopenharmony_ci} 314e41f4b71Sopenharmony_cilet description: systemManager.PackageDescription = { 315e41f4b71Sopenharmony_ci "notify": notify, 316e41f4b71Sopenharmony_ci} 317e41f4b71Sopenharmony_cilet updatePackages: Array<systemManager.Package> = [{ 318e41f4b71Sopenharmony_ci "type": systemManager.PackageType.FIRMWARE, 319e41f4b71Sopenharmony_ci "path": "path", 320e41f4b71Sopenharmony_ci "fd": 60, 321e41f4b71Sopenharmony_ci}] 322e41f4b71Sopenharmony_cilet updatePackageInfo: systemManager.UpdatePackageInfo = { 323e41f4b71Sopenharmony_ci "version" : "1.0", 324e41f4b71Sopenharmony_ci "packages" : updatePackages, 325e41f4b71Sopenharmony_ci "description" : description, 326e41f4b71Sopenharmony_ci}; 327e41f4b71Sopenharmony_cisystemManager.notifyUpdatePackages(wantTemp, updatePackageInfo).then(() => { 328e41f4b71Sopenharmony_ci console.info('Succeeded in notifying update packages.'); 329e41f4b71Sopenharmony_ci}).catch ((error: BusinessError) => { 330e41f4b71Sopenharmony_ci console.error(`Failed to notify update packages. Code is ${error.code},message is ${error.message}`); 331e41f4b71Sopenharmony_ci}); 332e41f4b71Sopenharmony_ci``` 333e41f4b71Sopenharmony_ci 334e41f4b71Sopenharmony_ci## systemManager.getUpdateResult 335e41f4b71Sopenharmony_ci 336e41f4b71Sopenharmony_cigetUpdateResult(admin: Want, version: string): Promise<UpdateResult> 337e41f4b71Sopenharmony_ci 338e41f4b71Sopenharmony_ciObtains the system update result. 339e41f4b71Sopenharmony_ci 340e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.ENTERPRISE_MANAGE_SYSTEM 341e41f4b71Sopenharmony_ci 342e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Customization.EnterpriseDeviceManager 343e41f4b71Sopenharmony_ci 344e41f4b71Sopenharmony_ci**Parameters** 345e41f4b71Sopenharmony_ci 346e41f4b71Sopenharmony_ci| Name| Type | Mandatory| Description | 347e41f4b71Sopenharmony_ci| ------ | ----------------------------------- | ---- | -------------- | 348e41f4b71Sopenharmony_ci| admin | [Want](../apis-ability-kit/js-apis-app-ability-want.md) | Yes | Device administrator application.| 349e41f4b71Sopenharmony_ci| version | string | Yes | Version of the update package.| 350e41f4b71Sopenharmony_ci 351e41f4b71Sopenharmony_ci**Return value** 352e41f4b71Sopenharmony_ci 353e41f4b71Sopenharmony_ci| Type | Description | 354e41f4b71Sopenharmony_ci| --------------------- | ------------------------- | 355e41f4b71Sopenharmony_ci| Promise<[UpdateResult](#updateresult)> | Promise used to return the system update result.| 356e41f4b71Sopenharmony_ci 357e41f4b71Sopenharmony_ci**Error codes** 358e41f4b71Sopenharmony_ci 359e41f4b71Sopenharmony_ciFor details about the error codes, see [Enterprise Device Management Error Codes](errorcode-enterpriseDeviceManager.md) and [Universal Error Codes](../errorcode-universal.md). 360e41f4b71Sopenharmony_ci 361e41f4b71Sopenharmony_ci| ID| Error Message | 362e41f4b71Sopenharmony_ci| -------- | ------------------------------------------------------------ | 363e41f4b71Sopenharmony_ci| 9200001 | The application is not an administrator application of the device. | 364e41f4b71Sopenharmony_ci| 9200002 | The administrator application does not have permission to manage the device. | 365e41f4b71Sopenharmony_ci| 201 | Permission verification failed. The application does not have the permission required to call the API. | 366e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.| 367e41f4b71Sopenharmony_ci 368e41f4b71Sopenharmony_ci**Example** 369e41f4b71Sopenharmony_ci 370e41f4b71Sopenharmony_ci```ts 371e41f4b71Sopenharmony_ciimport { systemManager } from '@kit.MDMKit'; 372e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit'; 373e41f4b71Sopenharmony_ciimport { Want } from '@kit.AbilityKit'; 374e41f4b71Sopenharmony_cilet wantTemp: Want = { 375e41f4b71Sopenharmony_ci bundleName: 'com.example.myapplication', 376e41f4b71Sopenharmony_ci abilityName: 'EntryAbility', 377e41f4b71Sopenharmony_ci}; 378e41f4b71Sopenharmony_cisystemManager.getUpdateResult(wantTemp, "1.0").then((result:systemManager.UpdateResult) => { 379e41f4b71Sopenharmony_ci console.info(`Succeeded in getting update result: ${JSON.stringify(result)}`); 380e41f4b71Sopenharmony_ci }).catch((error: BusinessError) => { 381e41f4b71Sopenharmony_ci console.error(`Get update result failed. Code is ${error.code},message is ${error.message}`); 382e41f4b71Sopenharmony_ci }); 383e41f4b71Sopenharmony_ci``` 384e41f4b71Sopenharmony_ci 385e41f4b71Sopenharmony_ci## SystemUpdateInfo 386e41f4b71Sopenharmony_ci 387e41f4b71Sopenharmony_ciRepresents information about the system version to update. 388e41f4b71Sopenharmony_ci 389e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Customization.EnterpriseDeviceManager 390e41f4b71Sopenharmony_ci 391e41f4b71Sopenharmony_ci| Name | Type | Mandatory | Description | 392e41f4b71Sopenharmony_ci| ----------------- | ------ | --- | ------------- | 393e41f4b71Sopenharmony_ci| versionName | string | Yes | System version to update. | 394e41f4b71Sopenharmony_ci| firstReceivedTime | number | Yes | Time when the system update package is received for the first time.| 395e41f4b71Sopenharmony_ci| packageType | string | Yes | Type of the system update package to update. | 396e41f4b71Sopenharmony_ci 397e41f4b71Sopenharmony_ci## OtaUpdatePolicy 398e41f4b71Sopenharmony_ci 399e41f4b71Sopenharmony_ciRepresents an OTA update policy. 400e41f4b71Sopenharmony_ci 401e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Customization.EnterpriseDeviceManager 402e41f4b71Sopenharmony_ci 403e41f4b71Sopenharmony_ci| Name | Type | Mandatory| Description | 404e41f4b71Sopenharmony_ci| ----------- | --------| ---- | ------------------------------- | 405e41f4b71Sopenharmony_ci| policyType | [PolicyType](#policytype) | Yes | Type of the update policy.| 406e41f4b71Sopenharmony_ci| version | string | Yes | Version of the software to update.| 407e41f4b71Sopenharmony_ci| latestUpdateTime | number | No | Latest update time (timestamp).| 408e41f4b71Sopenharmony_ci| delayUpdateTime | number | No | Period for which the update is postponed, in hours.| 409e41f4b71Sopenharmony_ci| installStartTime | number | No | Start time (timestamp) of the installation window.| 410e41f4b71Sopenharmony_ci| installEndTime | number | No | End time (timestamp) of the installation window.| 411e41f4b71Sopenharmony_ci 412e41f4b71Sopenharmony_ci## PolicyType 413e41f4b71Sopenharmony_ci 414e41f4b71Sopenharmony_ciEnumerates the update policy types. 415e41f4b71Sopenharmony_ci 416e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Customization.EnterpriseDeviceManager 417e41f4b71Sopenharmony_ci 418e41f4b71Sopenharmony_ci| Name | Value | Description | 419e41f4b71Sopenharmony_ci| ----------------- | ---- | ----- | 420e41f4b71Sopenharmony_ci| DEFAULT | 0 | Default update policy, which periodically notifies the user of the update and starts the update after user confirmation.| 421e41f4b71Sopenharmony_ci| PROHIBIT | 1 | Prohibit updates.| 422e41f4b71Sopenharmony_ci| UPDATE_TO_SPECIFIC_VERSION | 2 | Enforce updates. In this case, **latestUpdateTime** must be specified.| 423e41f4b71Sopenharmony_ci| WINDOWS | 3 | Update at the specified time window. In this case, **installStartTime** and **installEndTime** must be specified.| 424e41f4b71Sopenharmony_ci| POSTPONE | 4 | Postpone updates. After the time specified by **delayUpdateTime** is over, the default update policy is used.| 425e41f4b71Sopenharmony_ci 426e41f4b71Sopenharmony_ci## UpdatePackageInfo 427e41f4b71Sopenharmony_ci 428e41f4b71Sopenharmony_ciRepresents information about the system update packages. 429e41f4b71Sopenharmony_ci 430e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Customization.EnterpriseDeviceManager 431e41f4b71Sopenharmony_ci 432e41f4b71Sopenharmony_ci| Name | Type | Mandatory | Description | 433e41f4b71Sopenharmony_ci| ----------------- | ------ | --- | ------------- | 434e41f4b71Sopenharmony_ci| version | string | Yes | Version of the system update package. | 435e41f4b71Sopenharmony_ci| packages | Array<[Package](#package)> | Yes | Details about the system update packages.| 436e41f4b71Sopenharmony_ci| description | [PackageDescription](#packagedescription) | No | Description of the system update packages. | 437e41f4b71Sopenharmony_ci 438e41f4b71Sopenharmony_ci## Package 439e41f4b71Sopenharmony_ci 440e41f4b71Sopenharmony_ciRepresents the details about a system update package. 441e41f4b71Sopenharmony_ci 442e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Customization.EnterpriseDeviceManager 443e41f4b71Sopenharmony_ci 444e41f4b71Sopenharmony_ci| Name | Type | Mandatory | Description | 445e41f4b71Sopenharmony_ci| ----------------- | ------ | --- | ------------- | 446e41f4b71Sopenharmony_ci| type | [PackageType](#packagetype) | Yes | Type of the system update package. | 447e41f4b71Sopenharmony_ci| path | string | Yes | Path of the system update package.| 448e41f4b71Sopenharmony_ci| fd | number | No | File descriptor (FD) of the system update package. | 449e41f4b71Sopenharmony_ci 450e41f4b71Sopenharmony_ci## PackageDescription 451e41f4b71Sopenharmony_ci 452e41f4b71Sopenharmony_ciRepresents the description of a system update package. 453e41f4b71Sopenharmony_ci 454e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Customization.EnterpriseDeviceManager 455e41f4b71Sopenharmony_ci 456e41f4b71Sopenharmony_ci| Name | Type | Mandatory | Description | 457e41f4b71Sopenharmony_ci| ----------------- | ------ | --- | ------------- | 458e41f4b71Sopenharmony_ci| notify | [NotifyDescription](#notifydescription) | No | Update notification defined by an enterprise. | 459e41f4b71Sopenharmony_ci 460e41f4b71Sopenharmony_ci## NotifyDescription 461e41f4b71Sopenharmony_ci 462e41f4b71Sopenharmony_ciRepresents the update notification defined by an enterprise. 463e41f4b71Sopenharmony_ci 464e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Customization.EnterpriseDeviceManager 465e41f4b71Sopenharmony_ci 466e41f4b71Sopenharmony_ci| Name | Type | Mandatory | Description | 467e41f4b71Sopenharmony_ci| ----------------- | ------ | --- | ------------- | 468e41f4b71Sopenharmony_ci| installTips | string | No | Update tips provided by the enterprise. | 469e41f4b71Sopenharmony_ci| installTipsDetail | string | No | Details about the update tips customized by the enterprise. | 470e41f4b71Sopenharmony_ci 471e41f4b71Sopenharmony_ci## UpdateResult 472e41f4b71Sopenharmony_ci 473e41f4b71Sopenharmony_ciRepresents the update result information. 474e41f4b71Sopenharmony_ci 475e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Customization.EnterpriseDeviceManager 476e41f4b71Sopenharmony_ci 477e41f4b71Sopenharmony_ci| Name | Type | Readable | Writable | Description | 478e41f4b71Sopenharmony_ci| ----------------- | ------ | ------ | ------ | ------------- | 479e41f4b71Sopenharmony_ci| version | string | Yes| No|Current version of the system. | 480e41f4b71Sopenharmony_ci| status | [UpdateStatus](#updatestatus) | Yes| No| System update status. | 481e41f4b71Sopenharmony_ci| errorInfo | [ErrorInfo](#errorinfo) | Yes| No| Error information. | 482e41f4b71Sopenharmony_ci 483e41f4b71Sopenharmony_ci## ErrorInfo 484e41f4b71Sopenharmony_ci 485e41f4b71Sopenharmony_ciRepresents the update error information. 486e41f4b71Sopenharmony_ci 487e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Customization.EnterpriseDeviceManager 488e41f4b71Sopenharmony_ci 489e41f4b71Sopenharmony_ci| Name | Type | Readable | Writable| Description | 490e41f4b71Sopenharmony_ci| ----------------- | ------ | ------ | ------ | ------------- | 491e41f4b71Sopenharmony_ci| code | number | Yes| No| Error code. | 492e41f4b71Sopenharmony_ci| message | string | Yes| No| Error message. | 493e41f4b71Sopenharmony_ci 494e41f4b71Sopenharmony_ci## PackageType 495e41f4b71Sopenharmony_ci 496e41f4b71Sopenharmony_ciEnumerates the update package types. 497e41f4b71Sopenharmony_ci 498e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Customization.EnterpriseDeviceManager 499e41f4b71Sopenharmony_ci 500e41f4b71Sopenharmony_ci| Name | Value | Description | 501e41f4b71Sopenharmony_ci| ----------------- | ---- | ----- | 502e41f4b71Sopenharmony_ci| FIRMWARE | 1 | Firmware.| 503e41f4b71Sopenharmony_ci 504e41f4b71Sopenharmony_ci## UpdateStatus 505e41f4b71Sopenharmony_ci 506e41f4b71Sopenharmony_ciEnumerates the system update statuses. 507e41f4b71Sopenharmony_ci 508e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Customization.EnterpriseDeviceManager 509e41f4b71Sopenharmony_ci 510e41f4b71Sopenharmony_ci| Name | Value | Description | 511e41f4b71Sopenharmony_ci| ----------------- | ---- | ----- | 512e41f4b71Sopenharmony_ci| NO_UPDATE_PACKAGE | -4 | The system update package of the specified version does not exist.| 513e41f4b71Sopenharmony_ci| UPDATE_WAITING | -3 | The system update package is waiting to be installed.| 514e41f4b71Sopenharmony_ci| UPDATING | -2 | The system update is being performed.| 515e41f4b71Sopenharmony_ci| UPDATE_FAILURE | -1 | The update failed.| 516e41f4b71Sopenharmony_ci| UPDATE_SUCCESS | 0 | The update is successful.| 517