• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# @ohos.enterprise.EnterpriseAdminExtensionAbility (EnterpriseAdminExtensionAbility)
2
3The **EnterpriseAdminExtensionAbility** module provides extended enterprise device management capabilities.
4
5To have the capabilities provided by this module, for example, to receive a notification when a device administrator application is enabled or disabled, you need to create an **EnterpriseAdminExtensionAbility** instance for the device administrator application and overload related APIs.
6
7> **NOTE**
8>
9> - 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.
10>
11> - The APIs of this module can be used only in the stage model.
12>
13
14## Modules to Import
15
16```ts
17import { EnterpriseAdminExtensionAbility } from '@kit.MDMKit'
18```
19
20## EnterpriseAdminExtensionAbility.onAdminEnabled
21
22onAdminEnabled(): void
23
24Called when the device administrator application is enabled by the enterprise administrator or employee. Upon receiving the event notification from the system, the device administrator application can set initialization policies in this callback.
25
26**System capability**: SystemCapability.Customization.EnterpriseDeviceManager
27
28
29
30**Example**
31
32```ts
33export default class EnterpriseAdminAbility extends EnterpriseAdminExtensionAbility {
34  onAdminEnabled() {
35  }
36};
37```
38
39## EnterpriseAdminExtensionAbility.onAdminDisabled
40
41onAdminDisabled(): void
42
43Called when the device administrator application is disabled by the enterprise administrator or employee. Upon receiving the event notification from the system, the device administrator application can use this callback to notify the enterprise administrator that the device is no longer under management.
44
45**System capability**: SystemCapability.Customization.EnterpriseDeviceManager
46
47
48
49**Example**
50
51```ts
52export default class EnterpriseAdminAbility extends EnterpriseAdminExtensionAbility {
53  onAdminDisabled() {
54  }
55};
56```
57
58## EnterpriseAdminExtensionAbility.onBundleAdded
59
60onBundleAdded(bundleName: string): void
61
62Called when applications are installed. The application bundle name is included. You should register the **MANAGED_EVENT_BUNDLE_ADDED** event through [adminManager.subscribeManagedEventSync](js-apis-enterprise-adminManager.md#adminmanagersubscribemanagedeventsync). The enterprise administrator application can subscribe to application installation events. When an application is installed on an enterprise device, the device administrator application reports the event in this callback to notify the enterprise administrator.
63
64**System capability**: SystemCapability.Customization.EnterpriseDeviceManager
65
66
67
68**Parameters**
69
70| Name  | Type                                 | Mandatory  | Description     |
71| ----- | ----------------------------------- | ---- | ------- |
72| bundleName | string | Yes   | Bundle name of the application installed.|
73
74**Example**
75
76```ts
77export default class EnterpriseAdminAbility extends EnterpriseAdminExtensionAbility {
78  onBundleAdded(bundleName: string) {
79    console.info(`Succeeded in calling onBundleAdded callback, added bundle name : ${bundleName}`);
80  }
81};
82```
83
84## EnterpriseAdminExtensionAbility.onBundleAdded<sup>14+</sup>
85
86onBundleAdded(bundleName: string, accountId: number): void
87
88Called when applications are installed. The application bundle name and account ID are included. You should register the **MANAGED_EVENT_BUNDLE_ADDED** event through [adminManager.subscribeManagedEventSync](js-apis-enterprise-adminManager.md#adminmanagersubscribemanagedeventsync). The enterprise administrator application can subscribe to application installation events. When an application is installed on an enterprise device, the device administrator application reports the event in this callback to notify the enterprise administrator.
89
90**System capability**: SystemCapability.Customization.EnterpriseDeviceManager
91
92
93
94**Parameters**
95
96| Name  | Type                                 | Mandatory  | Description     |
97| ----- | ----------------------------------- | ---- | ------- |
98| bundleName | string | Yes   | Bundle name of the application installed.|
99| accountId | number | Yes   | Account ID of the application installed.|
100
101**Example**
102
103```ts
104export default class EnterpriseAdminAbility extends EnterpriseAdminExtensionAbility {
105  onBundleAdded(bundleName: string, accountId: number) {
106    console.info(`Succeeded in calling onBundleAdded callback, added bundle name : ${bundleName}, accountId: ${accountId}`);
107  }
108};
109```
110
111## EnterpriseAdminExtensionAbility.onBundleRemoved
112
113onBundleRemoved(bundleName: string): void
114
115Called when applications are uninstalled. The application bundle name is included. You should register the **MANAGED_EVENT_BUNDLE_REMOVED** event through [adminManager.subscribeManagedEventSync](js-apis-enterprise-adminManager.md#adminmanagersubscribemanagedeventsync). The enterprise administrator application can subscribe to application uninstallation events. When an application is uninstalled from an enterprise device, the device administrator application reports the event in this callback to notify the enterprise administrator.
116
117**System capability**: SystemCapability.Customization.EnterpriseDeviceManager
118
119
120
121**Parameters**
122
123| Name  | Type                                 | Mandatory  | Description     |
124| ----- | ----------------------------------- | ---- | ------- |
125| bundleName | string | Yes   | Bundle name of the application uninstalled.|
126
127**Example**
128
129```ts
130export default class EnterpriseAdminAbility extends EnterpriseAdminExtensionAbility {
131  onBundleRemoved(bundleName: string) {
132    console.info(`Succeeded in calling onBundleRemoved callback, removed bundle name : ${bundleName}`);
133  }
134};
135```
136
137## EnterpriseAdminExtensionAbility.onBundleRemoved<sup>14+</sup>
138
139onBundleRemoved(bundleName: string, accountId: number): void
140
141Called when applications are uninstalled. The application bundle name and account ID are included. You should register the **MANAGED_EVENT_BUNDLE_REMOVED** event through [adminManager.subscribeManagedEventSync](js-apis-enterprise-adminManager.md#adminmanagersubscribemanagedeventsync). The enterprise administrator application can subscribe to application uninstallation events. When an application is uninstalled from an enterprise device, the device administrator application reports the event in this callback to notify the enterprise administrator.
142
143**System capability**: SystemCapability.Customization.EnterpriseDeviceManager
144
145
146
147**Parameters**
148
149| Name  | Type                                 | Mandatory  | Description     |
150| ----- | ----------------------------------- | ---- | ------- |
151| bundleName | string | Yes   | Bundle name of the application uninstalled.|
152| accountId | number | Yes   | Account ID of the application uninstalled.|
153
154**Example**
155
156```ts
157export default class EnterpriseAdminAbility extends EnterpriseAdminExtensionAbility {
158  onBundleRemoved(bundleName: string, accountId: number) {
159    console.info(`Succeeded in calling onBundleRemoved callback, removed bundle name : ${bundleName}, accountId: ${accountId}`);
160  }
161};
162```
163
164## EnterpriseAdminExtensionAbility.onAppStart
165
166onAppStart(bundleName: string): void
167
168Called when an application is started. You should register the **MANAGED_EVENT_APP_START** event through [adminManager.subscribeManagedEventSync](js-apis-enterprise-adminManager.md#adminmanagersubscribemanagedeventsync). The enterprise administrator application can subscribe to application start events. When an application is started on an enterprise device, the device administrator application reports the event in this callback to notify the enterprise administrator.
169
170**System capability**: SystemCapability.Customization.EnterpriseDeviceManager
171
172
173
174**Parameters**
175
176| Name  | Type                                 | Mandatory  | Description     |
177| ----- | ----------------------------------- | ---- | ------- |
178| bundleName | string | Yes   | Bundle name of the application started.|
179
180**Example**
181
182```ts
183export default class EnterpriseAdminAbility extends EnterpriseAdminExtensionAbility {
184  onAppStart(bundleName: string) {
185    console.info(`Succeeded in calling onAppStart callback, started bundle name : ${bundleName}`);
186  }
187};
188```
189
190## EnterpriseAdminExtensionAbility.onAppStop
191
192onAppStop(bundleName: string): void
193
194Called when an application is stopped. You should register the **MANAGED_EVENT_APP_STOP** event through [adminManager.subscribeManagedEventSync](js-apis-enterprise-adminManager.md#adminmanagersubscribemanagedeventsync). The enterprise administrator application can subscribe to application stop events. When an application is stopped on an enterprise device, the device administrator application reports the event in this callback to notify the enterprise administrator.
195
196**System capability**: SystemCapability.Customization.EnterpriseDeviceManager
197
198
199
200**Parameters**
201
202| Name  | Type                                 | Mandatory  | Description     |
203| ----- | ----------------------------------- | ---- | ------- |
204| bundleName | string | Yes   | Bundle name of the application stopped.|
205
206**Example**
207
208```ts
209export default class EnterpriseAdminAbility extends EnterpriseAdminExtensionAbility {
210  onAppStop(bundleName: string) {
211    console.info(`Succeeded in calling onAppStop callback, stopped bundle name : ${bundleName}`);
212  }
213};
214```
215## EnterpriseAdminExtensionAbility.onSystemUpdate
216
217onSystemUpdate(systemUpdateInfo: systemManager.SystemUpdateInfo): void
218
219Called to report a system update event. You should register the **MANAGED_EVENT_SYSTEM_UPDATE** event through [adminManager.subscribeManagedEventSync](js-apis-enterprise-adminManager.md#adminmanagersubscribemanagedeventsync). The enterprise administrator application can subscribe to application update events. When an application is updated on an enterprise device, the device administrator application reports the event in this callback to notify the enterprise administrator.
220
221**System capability**: SystemCapability.Customization.EnterpriseDeviceManager
222
223
224
225**Parameters**
226
227| Name          | Type                                                        | Mandatory| Description                |
228| ---------------- | ------------------------------------------------------------ | ---- | -------------------- |
229| systemUpdateInfo | [systemManager.SystemUpdateInfo](js-apis-enterprise-systemManager.md#systemupdateinfo) | Yes  | Information about the version update.|
230
231**Example**
232
233```ts
234import { systemManager } from '@kit.MDMKit';
235export default class EnterpriseAdminAbility extends EnterpriseAdminExtensionAbility {
236  onSystemUpdate(systemUpdateInfo: systemManager.SystemUpdateInfo) {
237    console.info(`Succeeded in calling onSystemUpdate callback, version name  : ${systemUpdateInfo.versionName}`);
238  }
239};
240```
241
242## EnterpriseAdminExtensionAbility.onStart
243
244onStart(): void
245
246Called when EnterpriseAdminExtensionAbility starts.
247
248**System capability**: SystemCapability.Customization.EnterpriseDeviceManager
249
250
251
252**Example**
253
254```ts
255export default class EnterpriseAdminAbility extends EnterpriseAdminExtensionAbility {
256  onStart() {
257    console.info(`Succeeded in calling onStart callback.`);
258  }
259};
260```
261
262## EnterpriseAdminExtensionAbility.onAccountAdded<sup>18+</sup>
263
264onAccountAdded(accountId: number): void
265
266Called when a system account is added. You should register the **MANAGED_EVENT_ACCOUNT_ADDED** event through [adminManager.subscribeManagedEventSync](js-apis-enterprise-adminManager.md#adminmanagersubscribemanagedeventsync). The enterprise administrator application can subscribe to system account addition events. When a system account is added on an enterprise device, the device administrator application reports the event in this callback to notify the enterprise administrator.
267
268**System capability**: SystemCapability.Customization.EnterpriseDeviceManager
269
270**Parameters**
271
272| Name  | Type                                 | Mandatory  | Description     |
273| ----- | ----------------------------------- | ---- | ------- |
274| accountId | number | Yes   | Account ID added.|
275
276**Example**
277
278```ts
279export default class EnterpriseAdminAbility extends EnterpriseAdminExtensionAbility {
280  onAccountAdded(accountId: number) {
281    console.info(`Succeeded in calling onAccountAdded callback, added accountId: ${accountId}`);
282  }
283};
284```
285
286## EnterpriseAdminExtensionAbility.onAccountSwitched<sup>18+</sup>
287
288onAccountSwitched(accountId: number): void
289
290Called when the system account is switched. You should register the **MANAGED_EVENT_ACCOUNT_SWITCHED** event through [adminManager.subscribeManagedEventSync](js-apis-enterprise-adminManager.md#adminmanagersubscribemanagedeventsync). The enterprise administrator application can subscribe to system account switch events. When a system account is switched on an enterprise device, the device administrator application reports the event in this callback to notify the enterprise administrator.
291
292**System capability**: SystemCapability.Customization.EnterpriseDeviceManager
293
294**Parameters**
295
296| Name  | Type                                 | Mandatory  | Description     |
297| ----- | ----------------------------------- | ---- | ------- |
298| accountId | number | Yes   | Account ID switched.|
299
300**Example**
301
302```ts
303export default class EnterpriseAdminAbility extends EnterpriseAdminExtensionAbility {
304  onAccountSwitched(accountId: number) {
305    console.info(`Succeeded in calling onAccountSwitched callback, switched accountId: ${accountId}`);
306  }
307};
308```
309
310## EnterpriseAdminExtensionAbility.onAccountRemoved<sup>18+</sup>
311
312onAccountRemoved(accountId: number): void
313
314Called when the system account is removed. You should register the **MANAGED_EVENT_ACCOUNT_REMOVED** event through [adminManager.subscribeManagedEventSync](js-apis-enterprise-adminManager.md#adminmanagersubscribemanagedeventsync). The enterprise administrator application can subscribe to system account remove events. When a system account is removed from an enterprise device, the device administrator application reports the event in this callback to notify the enterprise administrator.
315
316**System capability**: SystemCapability.Customization.EnterpriseDeviceManager
317
318**Parameters**
319
320| Name  | Type                                 | Mandatory  | Description     |
321| ----- | ----------------------------------- | ---- | ------- |
322| accountId | number | Yes   | Account ID removed.|
323
324**Example**
325
326```ts
327export default class EnterpriseAdminAbility extends EnterpriseAdminExtensionAbility {
328  onAccountRemoved(accountId: number) {
329    console.info(`Succeeded in calling onAccountRemoved callback, removed accountId: ${accountId}`);
330  }
331};
332```
333
334## EnterpriseAdminExtensionAbility.onKioskModeEntering<sup>20+</sup>
335
336onKioskModeEntering(bundleName: string, accountId: number): void
337
338Called when an application enters the kiosk mode. This callback contains the application bundle name and account ID.
339
340Kiosk mode is a system-level runtime mode that restricts a device to a single application or a set of applications. It controls the lock screen, status bar, gestures, and key features to prevent users from launching other applications or performing other operations on the device.
341
342**System capability**: SystemCapability.Customization.EnterpriseDeviceManager
343
344**Parameters**
345
346| Name  | Type                                 | Mandatory  | Description     |
347| ----- | ----------------------------------- | ---- | ------- |
348| bundleName | string | Yes   | Bundle name of the application that enters the kiosk mode.|
349| accountId | number | Yes   | Account ID of the application that enters the kiosk mode.|
350
351**Example**
352
353```ts
354import { EnterpriseAdminExtensionAbility } from '@kit.MDMKit';
355
356export default class EnterpriseAdminAbility extends EnterpriseAdminExtensionAbility {
357  onKioskModeEntering(bundleName: string, accountId: number): void {
358    console.info(`Succeeded in calling onKioskModeEntering callback, bundleName:${bundleName}, accountId:${accountId}`);
359  }
360};
361```
362
363## EnterpriseAdminExtensionAbility.onKioskModeExiting<sup>20+</sup>
364
365onKioskModeExiting(bundleName: string, accountId: number): void
366
367Called when an application exits the kiosk mode. This callback contains the application bundle name and account ID.
368
369**System capability**: SystemCapability.Customization.EnterpriseDeviceManager
370
371**Parameters**
372
373| Name  | Type                                 | Mandatory  | Description     |
374| ----- | ----------------------------------- | ---- | ------- |
375| bundleName | string | Yes   | Bundle name of the application that exits the kiosk mode.|
376| accountId | number | Yes   | Account ID of the application that exits the kiosk mode.|
377
378**Example**
379
380```ts
381import { EnterpriseAdminExtensionAbility } from '@kit.MDMKit';
382
383export default class EnterpriseAdminAbility extends EnterpriseAdminExtensionAbility {
384  onKioskModeExiting(bundleName: string, accountId: number): void {
385    console.info(`Succeeded in calling onKioskModeExiting callback, bundleName:${bundleName}, accountId:${accountId}`);
386  }
387};
388```
389