1e41f4b71Sopenharmony_ci# @ohos.screen (Screen) (System API)
2e41f4b71Sopenharmony_ci
3e41f4b71Sopenharmony_ciThe **Screen** module implements basic screen management. You can use the APIs of this module to obtain a **Screen** object, listen for screen changes, and create and destroy virtual screens.
4e41f4b71Sopenharmony_ci
5e41f4b71Sopenharmony_ci> **NOTE**
6e41f4b71Sopenharmony_ci>
7e41f4b71Sopenharmony_ci> - The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
8e41f4b71Sopenharmony_ci> 
9e41f4b71Sopenharmony_ci> - The APIs provided by this module are system APIs.
10e41f4b71Sopenharmony_ci
11e41f4b71Sopenharmony_ci## Modules to Import
12e41f4b71Sopenharmony_ci
13e41f4b71Sopenharmony_ci```ts
14e41f4b71Sopenharmony_ciimport { screen } from '@kit.ArkUI';
15e41f4b71Sopenharmony_ci```
16e41f4b71Sopenharmony_ci
17e41f4b71Sopenharmony_ci## screen.getAllScreens
18e41f4b71Sopenharmony_ci
19e41f4b71Sopenharmony_cigetAllScreens(callback: AsyncCallback<Array<Screen>>): void
20e41f4b71Sopenharmony_ci
21e41f4b71Sopenharmony_ciObtains all screens. This API uses an asynchronous callback to return the result.
22e41f4b71Sopenharmony_ci
23e41f4b71Sopenharmony_ci**System capability**: SystemCapability.WindowManager.WindowManager.Core
24e41f4b71Sopenharmony_ci
25e41f4b71Sopenharmony_ci**Parameters**
26e41f4b71Sopenharmony_ci
27e41f4b71Sopenharmony_ci| Name  | Type                                               | Mandatory| Description                                  |
28e41f4b71Sopenharmony_ci| -------- | --------------------------------------------------- | ---- | -------------------------------------- |
29e41f4b71Sopenharmony_ci| callback | AsyncCallback<Array<[Screen](#screen)>> | Yes  | Callback used to return all the **Screen** objects obtained.|
30e41f4b71Sopenharmony_ci
31e41f4b71Sopenharmony_ci**Error codes**
32e41f4b71Sopenharmony_ci
33e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Display Error Codes](errorcode-display.md).
34e41f4b71Sopenharmony_ci
35e41f4b71Sopenharmony_ci| ID| Error Message|
36e41f4b71Sopenharmony_ci| ------- | ----------------------- |
37e41f4b71Sopenharmony_ci| 202     | Permission verification failed. A non-system application calls a system API.|
38e41f4b71Sopenharmony_ci| 1400001 | Invalid display or screen. |
39e41f4b71Sopenharmony_ci
40e41f4b71Sopenharmony_ci**Example**
41e41f4b71Sopenharmony_ci
42e41f4b71Sopenharmony_ci```ts
43e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
44e41f4b71Sopenharmony_ci
45e41f4b71Sopenharmony_cilet screenClass: screen.Screen | null = null;
46e41f4b71Sopenharmony_ciscreen.getAllScreens((err: BusinessError, data: Array<screen.Screen>) => {
47e41f4b71Sopenharmony_ci  const errCode: number = err.code;
48e41f4b71Sopenharmony_ci  if (errCode) {
49e41f4b71Sopenharmony_ci    console.error(`Failed to get all screens. Code:${err.code},message is ${err.message}`);
50e41f4b71Sopenharmony_ci    return;
51e41f4b71Sopenharmony_ci  }
52e41f4b71Sopenharmony_ci  console.info('Succeeded in getting all screens. Data:' + JSON.stringify(data));
53e41f4b71Sopenharmony_ci  screenClass = data[0];
54e41f4b71Sopenharmony_ci});
55e41f4b71Sopenharmony_ci```
56e41f4b71Sopenharmony_ci
57e41f4b71Sopenharmony_ci## screen.getAllScreens
58e41f4b71Sopenharmony_ci
59e41f4b71Sopenharmony_cigetAllScreens(): Promise&lt;Array&lt;Screen&gt;&gt;
60e41f4b71Sopenharmony_ci
61e41f4b71Sopenharmony_ciObtains all screens. This API uses a promise to return the result.
62e41f4b71Sopenharmony_ci
63e41f4b71Sopenharmony_ci**System capability**: SystemCapability.WindowManager.WindowManager.Core
64e41f4b71Sopenharmony_ci
65e41f4b71Sopenharmony_ci**Return value**
66e41f4b71Sopenharmony_ci
67e41f4b71Sopenharmony_ci| Type                                         | Description                                     |
68e41f4b71Sopenharmony_ci| --------------------------------------------- | ----------------------------------------- |
69e41f4b71Sopenharmony_ci| Promise&lt;Array&lt;[Screen](#screen)&gt;&gt; | Promise used to return all the **Screen** objects obtained.|
70e41f4b71Sopenharmony_ci
71e41f4b71Sopenharmony_ci**Error codes**
72e41f4b71Sopenharmony_ci
73e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Display Error Codes](errorcode-display.md).
74e41f4b71Sopenharmony_ci
75e41f4b71Sopenharmony_ci| ID| Error Message|
76e41f4b71Sopenharmony_ci| ------- | ----------------------- |
77e41f4b71Sopenharmony_ci| 202     | Permission verification failed. A non-system application calls a system API.|
78e41f4b71Sopenharmony_ci| 1400001 | Invalid display or screen. |
79e41f4b71Sopenharmony_ci
80e41f4b71Sopenharmony_ci**Example**
81e41f4b71Sopenharmony_ci
82e41f4b71Sopenharmony_ci```ts
83e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
84e41f4b71Sopenharmony_ci
85e41f4b71Sopenharmony_cilet screenClass: screen.Screen | null = null;
86e41f4b71Sopenharmony_cilet promise: Promise<Array<screen.Screen>> = screen.getAllScreens();
87e41f4b71Sopenharmony_cipromise.then((data: Array<screen.Screen>) => {
88e41f4b71Sopenharmony_ci  screenClass = data[0];
89e41f4b71Sopenharmony_ci  console.log('Succeeded in getting all screens. Data:' + JSON.stringify(data));
90e41f4b71Sopenharmony_ci}).catch((err: BusinessError) => {
91e41f4b71Sopenharmony_ci  console.log('Failed to get all screens. Cause: ' + JSON.stringify(err));
92e41f4b71Sopenharmony_ci});
93e41f4b71Sopenharmony_ci```
94e41f4b71Sopenharmony_ci
95e41f4b71Sopenharmony_ci## screen.on('connect' | 'disconnect' | 'change')
96e41f4b71Sopenharmony_ci
97e41f4b71Sopenharmony_cion(eventType: 'connect' | 'disconnect' | 'change', callback: Callback&lt;number&gt;): void
98e41f4b71Sopenharmony_ci
99e41f4b71Sopenharmony_ciSubscribes to events related to the screen state.
100e41f4b71Sopenharmony_ci
101e41f4b71Sopenharmony_ci**System capability**: SystemCapability.WindowManager.WindowManager.Core
102e41f4b71Sopenharmony_ci
103e41f4b71Sopenharmony_ci**Parameters**
104e41f4b71Sopenharmony_ci
105e41f4b71Sopenharmony_ci| Name   | Type                  | Mandatory| Description                                                       |
106e41f4b71Sopenharmony_ci| --------- | ---------------------- | ---- | ----------------------------------------------------------- |
107e41f4b71Sopenharmony_ci| eventType | string                 | Yes  | Event type.<br>- **connect**: an event indicating that the screen is connected.<br>- **disconnect**: an event indicating that the screen is disconnected.<br>- **change**: an event indicating that the screen state changes.|
108e41f4b71Sopenharmony_ci| callback  | Callback&lt;number&gt; | Yes  | Callback used to return the screen ID, which is an integer.                                   |
109e41f4b71Sopenharmony_ci
110e41f4b71Sopenharmony_ci**Error codes**
111e41f4b71Sopenharmony_ci
112e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md).
113e41f4b71Sopenharmony_ci
114e41f4b71Sopenharmony_ci| ID| Error Message|
115e41f4b71Sopenharmony_ci| ------- | ----------------------- |
116e41f4b71Sopenharmony_ci| 202     | Permission verification failed. A non-system application calls a system API.|
117e41f4b71Sopenharmony_ci| 401     | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types.|
118e41f4b71Sopenharmony_ci
119e41f4b71Sopenharmony_ci**Example**
120e41f4b71Sopenharmony_ci
121e41f4b71Sopenharmony_ci```ts
122e41f4b71Sopenharmony_cilet callback: Callback<number> = (data: number) => {
123e41f4b71Sopenharmony_ci  console.info('Succeeded in registering the callback for screen changes. Data: ' + JSON.stringify(data))
124e41f4b71Sopenharmony_ci};
125e41f4b71Sopenharmony_ciscreen.on('connect', callback);
126e41f4b71Sopenharmony_ci```
127e41f4b71Sopenharmony_ci
128e41f4b71Sopenharmony_ci## screen.off('connect' | 'disconnect' | 'change')
129e41f4b71Sopenharmony_ci
130e41f4b71Sopenharmony_cioff(eventType: 'connect' | 'disconnect' | 'change', callback?: Callback&lt;number&gt;): void
131e41f4b71Sopenharmony_ci
132e41f4b71Sopenharmony_ciUnsubscribes from events related to the screen state.
133e41f4b71Sopenharmony_ci
134e41f4b71Sopenharmony_ci**System capability**: SystemCapability.WindowManager.WindowManager.Core
135e41f4b71Sopenharmony_ci
136e41f4b71Sopenharmony_ci**Parameters**
137e41f4b71Sopenharmony_ci
138e41f4b71Sopenharmony_ci| Name   | Type                  | Mandatory| Description                                                        |
139e41f4b71Sopenharmony_ci| --------- | ---------------------- | ---- | ------------------------------------------------------------ |
140e41f4b71Sopenharmony_ci| eventType | string                 | Yes  | Event type.<br>- **connect**: an event indicating that the screen is connected.<br>- **disconnect**: an event indicating that the screen is disconnected.<br>- **change**: an event indicating that the screen state changes.|
141e41f4b71Sopenharmony_ci| callback  | Callback&lt;number&gt; | No  | Callback used to return the screen ID, which is an integer.                                    |
142e41f4b71Sopenharmony_ci
143e41f4b71Sopenharmony_ci**Error codes**
144e41f4b71Sopenharmony_ci
145e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md).
146e41f4b71Sopenharmony_ci
147e41f4b71Sopenharmony_ci| ID| Error Message|
148e41f4b71Sopenharmony_ci| ------- | ----------------------- |
149e41f4b71Sopenharmony_ci| 202     | Permission verification failed. A non-system application calls a system API.|
150e41f4b71Sopenharmony_ci| 401     | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types.|
151e41f4b71Sopenharmony_ci
152e41f4b71Sopenharmony_ci**Example**
153e41f4b71Sopenharmony_ci
154e41f4b71Sopenharmony_ci```ts
155e41f4b71Sopenharmony_cilet callback: Callback<number> = (data: number) => {
156e41f4b71Sopenharmony_ci  console.info('Succeeded in unregistering the callback for screen changes. Data: ' + JSON.stringify(data))
157e41f4b71Sopenharmony_ci};
158e41f4b71Sopenharmony_ciscreen.off('connect', callback);
159e41f4b71Sopenharmony_ciscreen.off('connect');
160e41f4b71Sopenharmony_ci```
161e41f4b71Sopenharmony_ci
162e41f4b71Sopenharmony_ci## screen.makeExpand
163e41f4b71Sopenharmony_ci
164e41f4b71Sopenharmony_cimakeExpand(options:Array&lt;ExpandOption&gt;, callback: AsyncCallback&lt;number&gt;): void
165e41f4b71Sopenharmony_ci
166e41f4b71Sopenharmony_ciSets the screen to the expanded mode. This API uses an asynchronous callback to return the result.
167e41f4b71Sopenharmony_ci
168e41f4b71Sopenharmony_ci**System capability**: SystemCapability.WindowManager.WindowManager.Core
169e41f4b71Sopenharmony_ci
170e41f4b71Sopenharmony_ci**Parameters**
171e41f4b71Sopenharmony_ci
172e41f4b71Sopenharmony_ci| Name  | Type                                      | Mandatory| Description                        |
173e41f4b71Sopenharmony_ci| -------- | ------------------------------------------ | ---- |----------------------------|
174e41f4b71Sopenharmony_ci| options  | Array&lt;[ExpandOption](#expandoption)&gt; | Yes  | Parameters for expanding the screen.              |
175e41f4b71Sopenharmony_ci| callback | AsyncCallback&lt;number&gt;                     | Yes  | Callback used to return the group ID of the expanded screens, which is an integer.|
176e41f4b71Sopenharmony_ci
177e41f4b71Sopenharmony_ci**Error codes**
178e41f4b71Sopenharmony_ci
179e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Display Error Codes](errorcode-display.md).
180e41f4b71Sopenharmony_ci
181e41f4b71Sopenharmony_ci| ID| Error Message|
182e41f4b71Sopenharmony_ci| ------- | ----------------------- |
183e41f4b71Sopenharmony_ci| 202     | Permission verification failed. A non-system application calls a system API.|
184e41f4b71Sopenharmony_ci| 401     | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types.|
185e41f4b71Sopenharmony_ci| 1400001 | Invalid display or screen. |
186e41f4b71Sopenharmony_ci
187e41f4b71Sopenharmony_ci**Example**
188e41f4b71Sopenharmony_ci
189e41f4b71Sopenharmony_ci```ts
190e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
191e41f4b71Sopenharmony_ci
192e41f4b71Sopenharmony_cilet groupId: number | null = null;
193e41f4b71Sopenharmony_ciclass ExpandOption {
194e41f4b71Sopenharmony_ci  screenId: number = 0;
195e41f4b71Sopenharmony_ci  startX: number = 0;
196e41f4b71Sopenharmony_ci  startY: number = 0;
197e41f4b71Sopenharmony_ci}
198e41f4b71Sopenharmony_cilet mainScreenOption: ExpandOption = { screenId: 0, startX: 0, startY: 0 };
199e41f4b71Sopenharmony_cilet otherScreenOption: ExpandOption = { screenId: 1, startX: 1080, startY: 0 };
200e41f4b71Sopenharmony_cilet expandOptionArray : ExpandOption[] = [ mainScreenOption, otherScreenOption ];
201e41f4b71Sopenharmony_ciscreen.makeExpand(expandOptionArray, (err: BusinessError, data: number) => {
202e41f4b71Sopenharmony_ci  const errCode: number = err.code;
203e41f4b71Sopenharmony_ci  if (errCode) {
204e41f4b71Sopenharmony_ci    console.error(`Failed to expand the screen. Code:${err.code},message is ${err.message}`);
205e41f4b71Sopenharmony_ci    return;
206e41f4b71Sopenharmony_ci  }
207e41f4b71Sopenharmony_ci  groupId = data;
208e41f4b71Sopenharmony_ci  console.info('Succeeded in expanding the screen. Data: ' + JSON.stringify(data));
209e41f4b71Sopenharmony_ci});
210e41f4b71Sopenharmony_ci```
211e41f4b71Sopenharmony_ci
212e41f4b71Sopenharmony_ci## screen.makeExpand
213e41f4b71Sopenharmony_ci
214e41f4b71Sopenharmony_cimakeExpand(options:Array&lt;ExpandOption&gt;): Promise&lt;number&gt;
215e41f4b71Sopenharmony_ci
216e41f4b71Sopenharmony_ciSets the screen to the expanded mode. This API uses a promise to return the result.
217e41f4b71Sopenharmony_ci
218e41f4b71Sopenharmony_ci**System capability**: SystemCapability.WindowManager.WindowManager.Core
219e41f4b71Sopenharmony_ci
220e41f4b71Sopenharmony_ci**Parameters**
221e41f4b71Sopenharmony_ci
222e41f4b71Sopenharmony_ci| Name | Type                                      | Mandatory| Description                    |
223e41f4b71Sopenharmony_ci| ------- | ------------------------------------------ | ---- | ------------------------ |
224e41f4b71Sopenharmony_ci| options | Array&lt;[ExpandOption](#expandoption)&gt; | Yes  | Parameters for expanding the screen.|
225e41f4b71Sopenharmony_ci
226e41f4b71Sopenharmony_ci**Return value**
227e41f4b71Sopenharmony_ci
228e41f4b71Sopenharmony_ci| Type                 | Description                             |
229e41f4b71Sopenharmony_ci| --------------------- |---------------------------------|
230e41f4b71Sopenharmony_ci| Promise&lt;number&gt; | Promise used to return the group ID of the expanded screens, which is an integer.|
231e41f4b71Sopenharmony_ci
232e41f4b71Sopenharmony_ci**Error codes**
233e41f4b71Sopenharmony_ci
234e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Display Error Codes](errorcode-display.md).
235e41f4b71Sopenharmony_ci
236e41f4b71Sopenharmony_ci| ID| Error Message|
237e41f4b71Sopenharmony_ci| ------- | ----------------------- |
238e41f4b71Sopenharmony_ci| 202     | Permission verification failed. A non-system application calls a system API.|
239e41f4b71Sopenharmony_ci| 401     | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types.|
240e41f4b71Sopenharmony_ci| 1400001 | Invalid display or screen. |
241e41f4b71Sopenharmony_ci
242e41f4b71Sopenharmony_ci**Example**
243e41f4b71Sopenharmony_ci
244e41f4b71Sopenharmony_ci```ts
245e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
246e41f4b71Sopenharmony_ci
247e41f4b71Sopenharmony_ciclass ExpandOption {
248e41f4b71Sopenharmony_ci  screenId: number = 0;
249e41f4b71Sopenharmony_ci  startX: number = 0;
250e41f4b71Sopenharmony_ci  startY: number = 0;
251e41f4b71Sopenharmony_ci}
252e41f4b71Sopenharmony_cilet mainScreenOption: ExpandOption = { screenId: 0, startX: 0, startY: 0 };
253e41f4b71Sopenharmony_cilet otherScreenOption: ExpandOption = { screenId: 1, startX: 1080, startY: 0 };
254e41f4b71Sopenharmony_cilet expandOptionArray : ExpandOption[] = [ mainScreenOption, otherScreenOption ];
255e41f4b71Sopenharmony_ciscreen.makeExpand(expandOptionArray).then((
256e41f4b71Sopenharmony_ci  data: number) => {
257e41f4b71Sopenharmony_ci  console.info('Succeeded in expanding the screen. Data: ' + JSON.stringify(data));
258e41f4b71Sopenharmony_ci}).catch((err: BusinessError) => {
259e41f4b71Sopenharmony_ci  console.error(`Failed to expand the screen. Code:${err.code},message is ${err.message}`);
260e41f4b71Sopenharmony_ci});
261e41f4b71Sopenharmony_ci```
262e41f4b71Sopenharmony_ci
263e41f4b71Sopenharmony_ci## screen.stopExpand<sup>10+</sup>
264e41f4b71Sopenharmony_ci
265e41f4b71Sopenharmony_cistopExpand(expandScreen:Array&lt;number&gt;, callback: AsyncCallback&lt;void&gt;): void
266e41f4b71Sopenharmony_ci
267e41f4b71Sopenharmony_ciStops the expanded mode. This API uses an asynchronous callback to return the result.
268e41f4b71Sopenharmony_ci
269e41f4b71Sopenharmony_ci**System capability**: SystemCapability.WindowManager.WindowManager.Core
270e41f4b71Sopenharmony_ci
271e41f4b71Sopenharmony_ci**Parameters**
272e41f4b71Sopenharmony_ci
273e41f4b71Sopenharmony_ci| Name| Type| Mandatory| Description                                     |
274e41f4b71Sopenharmony_ci| ------------ | --------------------------- | --- |-----------------------------------------|
275e41f4b71Sopenharmony_ci| expandScreen | Array&lt;number&gt;         | Yes  |  IDs of the expanded screens. Each ID must be an integer. The size of the expandScreen array cannot exceed 1000. |
276e41f4b71Sopenharmony_ci| callback     | AsyncCallback&lt;void&gt; | Yes  | Callback used to return the result. If the expanded mode is stopped, **err** is **undefined**; otherwise, **err** is an error object.|
277e41f4b71Sopenharmony_ci
278e41f4b71Sopenharmony_ci**Error codes**
279e41f4b71Sopenharmony_ci
280e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Display Error Codes](errorcode-display.md).
281e41f4b71Sopenharmony_ci
282e41f4b71Sopenharmony_ci| ID| Error Message|
283e41f4b71Sopenharmony_ci| ------- | ----------------------- |
284e41f4b71Sopenharmony_ci| 202     | Permission verification failed. A non-system application calls a system API.|
285e41f4b71Sopenharmony_ci| 401     | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. 3.Parameter verification failed.|
286e41f4b71Sopenharmony_ci| 1400001 | Invalid display or screen. |
287e41f4b71Sopenharmony_ci
288e41f4b71Sopenharmony_ci**Example**
289e41f4b71Sopenharmony_ci
290e41f4b71Sopenharmony_ci```ts
291e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
292e41f4b71Sopenharmony_ci
293e41f4b71Sopenharmony_cilet expandScreenIds: Array<number> = [1, 2, 3];
294e41f4b71Sopenharmony_ciscreen.stopExpand(expandScreenIds, (err: BusinessError) => {
295e41f4b71Sopenharmony_ci  const errCode: number = err.code;
296e41f4b71Sopenharmony_ci  if (errCode) {
297e41f4b71Sopenharmony_ci    console.error(`Failed to stop expand screens. Code:${err.code},message is ${err.message}`);
298e41f4b71Sopenharmony_ci    return;
299e41f4b71Sopenharmony_ci  }
300e41f4b71Sopenharmony_ci  console.info('Succeeded in stopping expand screens.');
301e41f4b71Sopenharmony_ci});
302e41f4b71Sopenharmony_ci```
303e41f4b71Sopenharmony_ci
304e41f4b71Sopenharmony_ci## screen.stopExpand<sup>10+</sup>
305e41f4b71Sopenharmony_ci
306e41f4b71Sopenharmony_cistopExpand(expandScreen:Array&lt;number&gt;): Promise&lt;void&gt;
307e41f4b71Sopenharmony_ci
308e41f4b71Sopenharmony_ciStops the expanded mode. This API uses a promise to return the result.
309e41f4b71Sopenharmony_ci
310e41f4b71Sopenharmony_ci**System capability**: SystemCapability.WindowManager.WindowManager.Core
311e41f4b71Sopenharmony_ci
312e41f4b71Sopenharmony_ci**Parameters**
313e41f4b71Sopenharmony_ci
314e41f4b71Sopenharmony_ci| Name| Type| Mandatory| Description                |
315e41f4b71Sopenharmony_ci| ------------ | ------------------- | --- |--------------------|
316e41f4b71Sopenharmony_ci| expandScreen | Array&lt;number&gt; | Yes  |  IDs of the expanded screens. Each ID must be an integer. The size of the expandScreen array cannot exceed 1000.|
317e41f4b71Sopenharmony_ci
318e41f4b71Sopenharmony_ci**Return value**
319e41f4b71Sopenharmony_ci
320e41f4b71Sopenharmony_ci| Type| Description|
321e41f4b71Sopenharmony_ci| --------------------- | ----------------------- |
322e41f4b71Sopenharmony_ci| Promise&lt;void&gt; | Promise that returns no value.|
323e41f4b71Sopenharmony_ci
324e41f4b71Sopenharmony_ci**Error codes**
325e41f4b71Sopenharmony_ci
326e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Display Error Codes](errorcode-display.md).
327e41f4b71Sopenharmony_ci
328e41f4b71Sopenharmony_ci| ID| Error Message|
329e41f4b71Sopenharmony_ci| ------- | ----------------------- |
330e41f4b71Sopenharmony_ci| 202     | Permission verification failed. A non-system application calls a system API.|
331e41f4b71Sopenharmony_ci| 401     | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. 3.Parameter verification failed.|
332e41f4b71Sopenharmony_ci| 1400001 | Invalid display or screen. |
333e41f4b71Sopenharmony_ci
334e41f4b71Sopenharmony_ci**Example**
335e41f4b71Sopenharmony_ci
336e41f4b71Sopenharmony_ci```ts
337e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
338e41f4b71Sopenharmony_ci
339e41f4b71Sopenharmony_cilet expandScreenIds: Array<number> = [1, 2, 3];
340e41f4b71Sopenharmony_ciscreen.stopExpand(expandScreenIds).then(() => {
341e41f4b71Sopenharmony_ci  console.info('Succeeded in stopping expand screens.');
342e41f4b71Sopenharmony_ci}).catch((err: BusinessError) => {
343e41f4b71Sopenharmony_ci  console.error(`Failed to stop expand screens. Code:${err.code},message is ${err.message}`);
344e41f4b71Sopenharmony_ci});
345e41f4b71Sopenharmony_ci```
346e41f4b71Sopenharmony_ci
347e41f4b71Sopenharmony_ci## screen.makeMirror
348e41f4b71Sopenharmony_ci
349e41f4b71Sopenharmony_cimakeMirror(mainScreen:number, mirrorScreen:Array&lt;number&gt;, callback: AsyncCallback&lt;number&gt;): void
350e41f4b71Sopenharmony_ci
351e41f4b71Sopenharmony_ciSets screen mirroring. This API uses an asynchronous callback to return the result.
352e41f4b71Sopenharmony_ci
353e41f4b71Sopenharmony_ci**System capability**: SystemCapability.WindowManager.WindowManager.Core
354e41f4b71Sopenharmony_ci
355e41f4b71Sopenharmony_ci**Parameters**
356e41f4b71Sopenharmony_ci
357e41f4b71Sopenharmony_ci| Name      | Type                       | Mandatory| Description                |
358e41f4b71Sopenharmony_ci| ------------ | --------------------------- | ---- |--------------------|
359e41f4b71Sopenharmony_ci| mainScreen   | number                      | Yes  | ID of the primary screen. The value must be an integer. |
360e41f4b71Sopenharmony_ci| mirrorScreen | Array&lt;number&gt;         | Yes  |  IDs of secondary screens. Each ID must be an integer.|
361e41f4b71Sopenharmony_ci| callback     | AsyncCallback&lt;number&gt; | Yes  | Callback used to return the group ID of the secondary screens, which is an integer. |
362e41f4b71Sopenharmony_ci
363e41f4b71Sopenharmony_ci**Error codes**
364e41f4b71Sopenharmony_ci
365e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Display Error Codes](errorcode-display.md).
366e41f4b71Sopenharmony_ci
367e41f4b71Sopenharmony_ci| ID| Error Message|
368e41f4b71Sopenharmony_ci| ------- | ----------------------- |
369e41f4b71Sopenharmony_ci| 202     | Permission verification failed. A non-system application calls a system API.|
370e41f4b71Sopenharmony_ci| 401     | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types.|
371e41f4b71Sopenharmony_ci| 1400001 | Invalid display or screen. |
372e41f4b71Sopenharmony_ci
373e41f4b71Sopenharmony_ci**Example**
374e41f4b71Sopenharmony_ci
375e41f4b71Sopenharmony_ci```ts
376e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
377e41f4b71Sopenharmony_ci
378e41f4b71Sopenharmony_cilet mainScreenId: number = 0;
379e41f4b71Sopenharmony_cilet mirrorScreenIds: Array<number> = [1, 2, 3];
380e41f4b71Sopenharmony_ciscreen.makeMirror(mainScreenId, mirrorScreenIds, (err: BusinessError, data: number) => {
381e41f4b71Sopenharmony_ci  const errCode: number = err.code;
382e41f4b71Sopenharmony_ci  if (errCode) {
383e41f4b71Sopenharmony_ci    console.error(`Failed to set screen mirroring. Code:${err.code},message is ${err.message}`);
384e41f4b71Sopenharmony_ci    return;
385e41f4b71Sopenharmony_ci  }
386e41f4b71Sopenharmony_ci  console.info('Succeeded in setting screen mirroring. Data: ' + JSON.stringify(data));
387e41f4b71Sopenharmony_ci});
388e41f4b71Sopenharmony_ci```
389e41f4b71Sopenharmony_ci
390e41f4b71Sopenharmony_ci## screen.makeMirror
391e41f4b71Sopenharmony_ci
392e41f4b71Sopenharmony_cimakeMirror(mainScreen:number, mirrorScreen:Array&lt;number&gt;): Promise&lt;number&gt;
393e41f4b71Sopenharmony_ci
394e41f4b71Sopenharmony_ciSets screen mirroring. This API uses a promise to return the result.
395e41f4b71Sopenharmony_ci
396e41f4b71Sopenharmony_ci**System capability**: SystemCapability.WindowManager.WindowManager.Core
397e41f4b71Sopenharmony_ci
398e41f4b71Sopenharmony_ci**Parameters**
399e41f4b71Sopenharmony_ci
400e41f4b71Sopenharmony_ci| Name      | Type               | Mandatory| Description                |
401e41f4b71Sopenharmony_ci| ------------ | ------------------- | ---- |--------------------|
402e41f4b71Sopenharmony_ci| mainScreen   | number              | Yes  | ID of the primary screen. The value must be an integer. |
403e41f4b71Sopenharmony_ci| mirrorScreen | Array&lt;number&gt; | Yes  | IDs of secondary screens. Each ID must be an integer.|
404e41f4b71Sopenharmony_ci
405e41f4b71Sopenharmony_ci**Return value**
406e41f4b71Sopenharmony_ci
407e41f4b71Sopenharmony_ci| Type                 | Description                             |
408e41f4b71Sopenharmony_ci| --------------------- |---------------------------------|
409e41f4b71Sopenharmony_ci| Promise&lt;number&gt; | Promise used to return the group ID of the secondary screens, which is an integer.|
410e41f4b71Sopenharmony_ci
411e41f4b71Sopenharmony_ci**Error codes**
412e41f4b71Sopenharmony_ci
413e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Display Error Codes](errorcode-display.md).
414e41f4b71Sopenharmony_ci
415e41f4b71Sopenharmony_ci| ID| Error Message|
416e41f4b71Sopenharmony_ci| ------- | ----------------------- |
417e41f4b71Sopenharmony_ci| 202     | Permission verification failed. A non-system application calls a system API.|
418e41f4b71Sopenharmony_ci| 401     | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types.|
419e41f4b71Sopenharmony_ci| 1400001 | Invalid display or screen. |
420e41f4b71Sopenharmony_ci
421e41f4b71Sopenharmony_ci**Example**
422e41f4b71Sopenharmony_ci
423e41f4b71Sopenharmony_ci```ts
424e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
425e41f4b71Sopenharmony_ci
426e41f4b71Sopenharmony_cilet mainScreenId: number = 0;
427e41f4b71Sopenharmony_cilet mirrorScreenIds: Array<number> = [1, 2, 3];
428e41f4b71Sopenharmony_ciscreen.makeMirror(mainScreenId, mirrorScreenIds).then((data: number) => {
429e41f4b71Sopenharmony_ci  console.info('Succeeded in setting screen mirroring. Data: ' + JSON.stringify(data));
430e41f4b71Sopenharmony_ci}).catch((err: BusinessError) => {
431e41f4b71Sopenharmony_ci  console.error(`Failed to set screen mirroring. Code:${err.code},message is ${err.message}`);
432e41f4b71Sopenharmony_ci});
433e41f4b71Sopenharmony_ci```
434e41f4b71Sopenharmony_ci
435e41f4b71Sopenharmony_ci## screen.stopMirror<sup>10+</sup>
436e41f4b71Sopenharmony_ci
437e41f4b71Sopenharmony_cistopMirror(mirrorScreen:Array&lt;number&gt;, callback: AsyncCallback&lt;void&gt;): void
438e41f4b71Sopenharmony_ci
439e41f4b71Sopenharmony_ciStops screen mirroring. This API uses an asynchronous callback to return the result.
440e41f4b71Sopenharmony_ci
441e41f4b71Sopenharmony_ci**System capability**: SystemCapability.WindowManager.WindowManager.Core
442e41f4b71Sopenharmony_ci
443e41f4b71Sopenharmony_ci**Parameters**
444e41f4b71Sopenharmony_ci
445e41f4b71Sopenharmony_ci| Name| Type| Mandatory| Description                                     |
446e41f4b71Sopenharmony_ci| ------------ | --------------------------- | --- |-----------------------------------------|
447e41f4b71Sopenharmony_ci| mirrorScreen | Array&lt;number&gt;         | Yes  |  IDs of secondary screens. Each ID must be an integer. The size of the mirrorScreen array cannot exceed 1000.|
448e41f4b71Sopenharmony_ci| callback     | AsyncCallback&lt;void&gt; | Yes  | Callback used to return the result. If screen mirroring is stopped, **err** is **undefined**; otherwise, **err** is an error object.|
449e41f4b71Sopenharmony_ci
450e41f4b71Sopenharmony_ci**Error codes**
451e41f4b71Sopenharmony_ci
452e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Display Error Codes](errorcode-display.md).
453e41f4b71Sopenharmony_ci
454e41f4b71Sopenharmony_ci| ID| Error Message|
455e41f4b71Sopenharmony_ci| ------- | ----------------------- |
456e41f4b71Sopenharmony_ci| 202     | Permission verification failed. A non-system application calls a system API.|
457e41f4b71Sopenharmony_ci| 401     | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. 3.Parameter verification failed.|
458e41f4b71Sopenharmony_ci| 1400001 | Invalid display or screen. |
459e41f4b71Sopenharmony_ci
460e41f4b71Sopenharmony_ci**Example**
461e41f4b71Sopenharmony_ci
462e41f4b71Sopenharmony_ci```ts
463e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
464e41f4b71Sopenharmony_ci
465e41f4b71Sopenharmony_cilet mirrorScreenIds: Array<number> = [1, 2, 3];
466e41f4b71Sopenharmony_ciscreen.stopMirror(mirrorScreenIds, (err: BusinessError) => {
467e41f4b71Sopenharmony_ci  const errCode: number = err.code;
468e41f4b71Sopenharmony_ci  if (errCode) {
469e41f4b71Sopenharmony_ci    console.error(`Failed to stop mirror screens. Code:${err.code},message is ${err.message}`);
470e41f4b71Sopenharmony_ci    return;
471e41f4b71Sopenharmony_ci  }
472e41f4b71Sopenharmony_ci  console.info('Succeeded in stopping mirror screens.');
473e41f4b71Sopenharmony_ci});
474e41f4b71Sopenharmony_ci```
475e41f4b71Sopenharmony_ci
476e41f4b71Sopenharmony_ci## screen.stopMirror<sup>10+</sup>
477e41f4b71Sopenharmony_ci
478e41f4b71Sopenharmony_cistopMirror(mirrorScreen:Array&lt;number&gt;): Promise&lt;void&gt;
479e41f4b71Sopenharmony_ci
480e41f4b71Sopenharmony_ciStops screen mirroring. This API uses a promise to return the result.
481e41f4b71Sopenharmony_ci
482e41f4b71Sopenharmony_ci**System capability**: SystemCapability.WindowManager.WindowManager.Core
483e41f4b71Sopenharmony_ci
484e41f4b71Sopenharmony_ci**Parameters**
485e41f4b71Sopenharmony_ci
486e41f4b71Sopenharmony_ci| Name| Type| Mandatory| Description                |
487e41f4b71Sopenharmony_ci| ------------ | ------------------- | --- |--------------------|
488e41f4b71Sopenharmony_ci| mirrorScreen | Array&lt;number&gt; | Yes  |  IDs of secondary screens. Each ID must be an integer. The size of the mirrorScreen array cannot exceed 1000.|
489e41f4b71Sopenharmony_ci
490e41f4b71Sopenharmony_ci**Return value**
491e41f4b71Sopenharmony_ci
492e41f4b71Sopenharmony_ci| Type| Description|
493e41f4b71Sopenharmony_ci| --------------------- | ----------------------- |
494e41f4b71Sopenharmony_ci| Promise&lt;void&gt; | Promise that returns no value.|
495e41f4b71Sopenharmony_ci
496e41f4b71Sopenharmony_ci**Error codes**
497e41f4b71Sopenharmony_ci
498e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Display Error Codes](errorcode-display.md).
499e41f4b71Sopenharmony_ci
500e41f4b71Sopenharmony_ci| ID| Error Message|
501e41f4b71Sopenharmony_ci| ------- | ----------------------- |
502e41f4b71Sopenharmony_ci| 202     | Permission verification failed. A non-system application calls a system API.|
503e41f4b71Sopenharmony_ci| 401     | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. 3.Parameter verification failed.|
504e41f4b71Sopenharmony_ci| 1400001 | Invalid display or screen. |
505e41f4b71Sopenharmony_ci
506e41f4b71Sopenharmony_ci**Example**
507e41f4b71Sopenharmony_ci
508e41f4b71Sopenharmony_ci```ts
509e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
510e41f4b71Sopenharmony_ci
511e41f4b71Sopenharmony_cilet mirrorScreenIds: Array<number> = [1, 2, 3];
512e41f4b71Sopenharmony_ciscreen.stopMirror(mirrorScreenIds).then(() => {
513e41f4b71Sopenharmony_ci  console.info('Succeeded in stopping mirror screens.');
514e41f4b71Sopenharmony_ci}).catch((err: BusinessError) => {
515e41f4b71Sopenharmony_ci  console.error(`Failed to stop mirror screens.Code:${err.code},message is ${err.message}`);
516e41f4b71Sopenharmony_ci});
517e41f4b71Sopenharmony_ci```
518e41f4b71Sopenharmony_ci
519e41f4b71Sopenharmony_ci## screen.createVirtualScreen
520e41f4b71Sopenharmony_ci
521e41f4b71Sopenharmony_cicreateVirtualScreen(options:VirtualScreenOption, callback: AsyncCallback&lt;Screen&gt;): void
522e41f4b71Sopenharmony_ci
523e41f4b71Sopenharmony_ciCreates a virtual screen. This API uses an asynchronous callback to return the result.
524e41f4b71Sopenharmony_ci
525e41f4b71Sopenharmony_ci**System capability**: SystemCapability.WindowManager.WindowManager.Core
526e41f4b71Sopenharmony_ci
527e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.CAPTURE_SCREEN
528e41f4b71Sopenharmony_ci
529e41f4b71Sopenharmony_ci**Parameters**
530e41f4b71Sopenharmony_ci
531e41f4b71Sopenharmony_ci| Name  | Type                                       | Mandatory| Description                              |
532e41f4b71Sopenharmony_ci| -------- | ------------------------------------------- | ---- | ---------------------------------- |
533e41f4b71Sopenharmony_ci| options  | [VirtualScreenOption](#virtualscreenoption) | Yes  | Virtual screen parameters.          |
534e41f4b71Sopenharmony_ci| callback | AsyncCallback&lt;[Screen](#screen)&gt;      | Yes  | Callback used to return the created virtual screen.|
535e41f4b71Sopenharmony_ci
536e41f4b71Sopenharmony_ci**Error codes**
537e41f4b71Sopenharmony_ci
538e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Display Error Codes](errorcode-display.md).
539e41f4b71Sopenharmony_ci
540e41f4b71Sopenharmony_ci| ID| Error Message|
541e41f4b71Sopenharmony_ci| ------- | ----------------------- |
542e41f4b71Sopenharmony_ci| 201 | Permission verification failed. |
543e41f4b71Sopenharmony_ci| 202     | Permission verification failed. A non-system application calls a system API.|
544e41f4b71Sopenharmony_ci| 401     | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types.|
545e41f4b71Sopenharmony_ci| 1400001 | Invalid display or screen. |
546e41f4b71Sopenharmony_ci
547e41f4b71Sopenharmony_ci**Example**
548e41f4b71Sopenharmony_ci
549e41f4b71Sopenharmony_ci```ts
550e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
551e41f4b71Sopenharmony_ci
552e41f4b71Sopenharmony_cilet screenClass: screen.Screen | null = null;
553e41f4b71Sopenharmony_ciclass VirtualScreenOption {
554e41f4b71Sopenharmony_ci  name : string = '';
555e41f4b71Sopenharmony_ci  width : number =  0;
556e41f4b71Sopenharmony_ci  height : number = 0;
557e41f4b71Sopenharmony_ci  density : number = 0;
558e41f4b71Sopenharmony_ci  surfaceId : string = '';
559e41f4b71Sopenharmony_ci}
560e41f4b71Sopenharmony_ci
561e41f4b71Sopenharmony_cilet option : VirtualScreenOption = { 
562e41f4b71Sopenharmony_ci  name: 'screen01',
563e41f4b71Sopenharmony_ci  width: 1080,
564e41f4b71Sopenharmony_ci  height: 2340,
565e41f4b71Sopenharmony_ci  density: 2,
566e41f4b71Sopenharmony_ci  surfaceId: ''
567e41f4b71Sopenharmony_ci};
568e41f4b71Sopenharmony_ciscreen.createVirtualScreen(option, (err: BusinessError, data: screen.Screen) => {
569e41f4b71Sopenharmony_ci  const errCode: number = err.code;
570e41f4b71Sopenharmony_ci  if (errCode) {
571e41f4b71Sopenharmony_ci    console.error(`Failed to create the virtual screen. Code:${err.code},message is ${err.message}`);
572e41f4b71Sopenharmony_ci    return;
573e41f4b71Sopenharmony_ci  }
574e41f4b71Sopenharmony_ci  screenClass = data;
575e41f4b71Sopenharmony_ci  console.info('Succeeded in creating the virtual screen. Data: ' + JSON.stringify(data));
576e41f4b71Sopenharmony_ci});
577e41f4b71Sopenharmony_ci```
578e41f4b71Sopenharmony_ci
579e41f4b71Sopenharmony_ci## screen.createVirtualScreen
580e41f4b71Sopenharmony_ci
581e41f4b71Sopenharmony_cicreateVirtualScreen(options:VirtualScreenOption): Promise&lt;Screen&gt;
582e41f4b71Sopenharmony_ci
583e41f4b71Sopenharmony_ciCreates a virtual screen. This API uses a promise to return the result.
584e41f4b71Sopenharmony_ci
585e41f4b71Sopenharmony_ci**System capability**: SystemCapability.WindowManager.WindowManager.Core
586e41f4b71Sopenharmony_ci
587e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.CAPTURE_SCREEN
588e41f4b71Sopenharmony_ci
589e41f4b71Sopenharmony_ci**Parameters**
590e41f4b71Sopenharmony_ci
591e41f4b71Sopenharmony_ci| Name | Type                                       | Mandatory| Description                    |
592e41f4b71Sopenharmony_ci| ------- | ------------------------------------------- | ---- | ------------------------ |
593e41f4b71Sopenharmony_ci| options | [VirtualScreenOption](#virtualscreenoption) | Yes  | Virtual screen parameters.|
594e41f4b71Sopenharmony_ci
595e41f4b71Sopenharmony_ci**Return value**
596e41f4b71Sopenharmony_ci
597e41f4b71Sopenharmony_ci| Type                            | Description                                 |
598e41f4b71Sopenharmony_ci| -------------------------------- | ------------------------------------- |
599e41f4b71Sopenharmony_ci| Promise&lt;[Screen](#screen)&gt; | Promise used to return the created virtual screen.|
600e41f4b71Sopenharmony_ci
601e41f4b71Sopenharmony_ci**Error codes**
602e41f4b71Sopenharmony_ci
603e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Display Error Codes](errorcode-display.md).
604e41f4b71Sopenharmony_ci
605e41f4b71Sopenharmony_ci| ID| Error Message|
606e41f4b71Sopenharmony_ci| ------- | ----------------------- |
607e41f4b71Sopenharmony_ci| 201 | Permission verification failed. |
608e41f4b71Sopenharmony_ci| 202     | Permission verification failed. A non-system application calls a system API.|
609e41f4b71Sopenharmony_ci| 401     | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types.|
610e41f4b71Sopenharmony_ci| 1400001 | Invalid display or screen. |
611e41f4b71Sopenharmony_ci
612e41f4b71Sopenharmony_ci**Example**
613e41f4b71Sopenharmony_ci
614e41f4b71Sopenharmony_ci```ts
615e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
616e41f4b71Sopenharmony_ci
617e41f4b71Sopenharmony_cilet screenClass: screen.Screen | null = null;
618e41f4b71Sopenharmony_ciclass VirtualScreenOption {
619e41f4b71Sopenharmony_ci  name : string = '';
620e41f4b71Sopenharmony_ci  width : number =  0;
621e41f4b71Sopenharmony_ci  height : number = 0;
622e41f4b71Sopenharmony_ci  density : number = 0;
623e41f4b71Sopenharmony_ci  surfaceId : string = '';
624e41f4b71Sopenharmony_ci}
625e41f4b71Sopenharmony_ci
626e41f4b71Sopenharmony_cilet option : VirtualScreenOption = { 
627e41f4b71Sopenharmony_ci  name: 'screen01',
628e41f4b71Sopenharmony_ci  width: 1080,
629e41f4b71Sopenharmony_ci  height: 2340,
630e41f4b71Sopenharmony_ci  density: 2,
631e41f4b71Sopenharmony_ci  surfaceId: ''
632e41f4b71Sopenharmony_ci};
633e41f4b71Sopenharmony_ci
634e41f4b71Sopenharmony_ciscreen.createVirtualScreen(option).then((data: screen.Screen) => {
635e41f4b71Sopenharmony_ci  screenClass = data;
636e41f4b71Sopenharmony_ci  console.info('Succeeded in creating the virtual screen. Data: ' + JSON.stringify(data));
637e41f4b71Sopenharmony_ci}).catch((err: BusinessError) => {
638e41f4b71Sopenharmony_ci  console.error(`Failed to create the virtual screen. Code:${err.code},message is ${err.message}`);
639e41f4b71Sopenharmony_ci});
640e41f4b71Sopenharmony_ci```
641e41f4b71Sopenharmony_ci
642e41f4b71Sopenharmony_ci## screen.destroyVirtualScreen
643e41f4b71Sopenharmony_ci
644e41f4b71Sopenharmony_cidestroyVirtualScreen(screenId:number, callback: AsyncCallback&lt;void&gt;): void
645e41f4b71Sopenharmony_ci
646e41f4b71Sopenharmony_ciDestroys a virtual screen. This API uses an asynchronous callback to return the result.
647e41f4b71Sopenharmony_ci
648e41f4b71Sopenharmony_ci**System capability**: SystemCapability.WindowManager.WindowManager.Core
649e41f4b71Sopenharmony_ci
650e41f4b71Sopenharmony_ci**Parameters**
651e41f4b71Sopenharmony_ci
652e41f4b71Sopenharmony_ci| Name  | Type                     | Mandatory| Description                                                        |
653e41f4b71Sopenharmony_ci| -------- | ------------------------- | ---- | ------------------------------------------------------------ |
654e41f4b71Sopenharmony_ci| screenId | number                    | Yes  | Screen ID. The value must be an integer.                                                  |
655e41f4b71Sopenharmony_ci| callback | AsyncCallback&lt;void&gt; | Yes  | Callback used to return the result. If the virtual screen is destroyed, **err** is **undefined**; otherwise, **err** is an error object.|
656e41f4b71Sopenharmony_ci
657e41f4b71Sopenharmony_ci**Error codes**
658e41f4b71Sopenharmony_ci
659e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Display Error Codes](errorcode-display.md).
660e41f4b71Sopenharmony_ci
661e41f4b71Sopenharmony_ci| ID| Error Message|
662e41f4b71Sopenharmony_ci| ------- | ----------------------------- |
663e41f4b71Sopenharmony_ci| 202     | Permission verification failed. A non-system application calls a system API.|
664e41f4b71Sopenharmony_ci| 401     | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types.|
665e41f4b71Sopenharmony_ci| 1400002 | Unauthorized operation. |
666e41f4b71Sopenharmony_ci
667e41f4b71Sopenharmony_ci**Example**
668e41f4b71Sopenharmony_ci
669e41f4b71Sopenharmony_ci```ts
670e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
671e41f4b71Sopenharmony_ci
672e41f4b71Sopenharmony_cilet screenId: number = 1;
673e41f4b71Sopenharmony_ciscreen.destroyVirtualScreen(screenId, (err: BusinessError) => {
674e41f4b71Sopenharmony_ci  const errCode: number = err.code;
675e41f4b71Sopenharmony_ci  if (errCode) {
676e41f4b71Sopenharmony_ci    console.error(`Failed to destroy the virtual screen. Code:${err.code},message is ${err.message}`);
677e41f4b71Sopenharmony_ci    return;
678e41f4b71Sopenharmony_ci  }
679e41f4b71Sopenharmony_ci  console.info('Succeeded in destroying the virtual screen.');
680e41f4b71Sopenharmony_ci});
681e41f4b71Sopenharmony_ci```
682e41f4b71Sopenharmony_ci
683e41f4b71Sopenharmony_ci## screen.destroyVirtualScreen
684e41f4b71Sopenharmony_ci
685e41f4b71Sopenharmony_cidestroyVirtualScreen(screenId:number): Promise&lt;void&gt;
686e41f4b71Sopenharmony_ci
687e41f4b71Sopenharmony_ciDestroys a virtual screen. This API uses a promise to return the result.
688e41f4b71Sopenharmony_ci
689e41f4b71Sopenharmony_ci**System capability**: SystemCapability.WindowManager.WindowManager.Core
690e41f4b71Sopenharmony_ci
691e41f4b71Sopenharmony_ci**Parameters**
692e41f4b71Sopenharmony_ci
693e41f4b71Sopenharmony_ci| Name  | Type  | Mandatory| Description      |
694e41f4b71Sopenharmony_ci| -------- | ------ | ---- | ---------- |
695e41f4b71Sopenharmony_ci| screenId | number | Yes  | Screen ID. The value must be an integer.|
696e41f4b71Sopenharmony_ci
697e41f4b71Sopenharmony_ci**Return value**
698e41f4b71Sopenharmony_ci
699e41f4b71Sopenharmony_ci| Type               | Description                     |
700e41f4b71Sopenharmony_ci| ------------------- | ------------------------- |
701e41f4b71Sopenharmony_ci| Promise&lt;void&gt; | Promise that returns no value.|
702e41f4b71Sopenharmony_ci
703e41f4b71Sopenharmony_ci**Error codes**
704e41f4b71Sopenharmony_ci
705e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Display Error Codes](errorcode-display.md).
706e41f4b71Sopenharmony_ci
707e41f4b71Sopenharmony_ci| ID| Error Message|
708e41f4b71Sopenharmony_ci| ------- | ----------------------------- |
709e41f4b71Sopenharmony_ci| 202     | Permission verification failed. A non-system application calls a system API.|
710e41f4b71Sopenharmony_ci| 401     | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types.|
711e41f4b71Sopenharmony_ci| 1400002 | Unauthorized operation. |
712e41f4b71Sopenharmony_ci
713e41f4b71Sopenharmony_ci**Example**
714e41f4b71Sopenharmony_ci
715e41f4b71Sopenharmony_ci```ts
716e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
717e41f4b71Sopenharmony_ci
718e41f4b71Sopenharmony_cilet screenId: number = 1;
719e41f4b71Sopenharmony_ciscreen.destroyVirtualScreen(screenId).then(() => {
720e41f4b71Sopenharmony_ci  console.info('Succeeded in destroying the virtual screen.');
721e41f4b71Sopenharmony_ci}).catch((err: BusinessError) => {
722e41f4b71Sopenharmony_ci  console.error(`Failed to destroy the virtual screen.Code:${err.code},message is ${err.message}`);
723e41f4b71Sopenharmony_ci});
724e41f4b71Sopenharmony_ci```
725e41f4b71Sopenharmony_ci
726e41f4b71Sopenharmony_ci## screen.setVirtualScreenSurface
727e41f4b71Sopenharmony_ci
728e41f4b71Sopenharmony_cisetVirtualScreenSurface(screenId:number, surfaceId: string, callback: AsyncCallback&lt;void&gt;): void
729e41f4b71Sopenharmony_ci
730e41f4b71Sopenharmony_ciSets the surface for a virtual screen. This API uses an asynchronous callback to return the result.
731e41f4b71Sopenharmony_ci
732e41f4b71Sopenharmony_ci**System capability**: SystemCapability.WindowManager.WindowManager.Core
733e41f4b71Sopenharmony_ci
734e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.CAPTURE_SCREEN (available only to system applications)
735e41f4b71Sopenharmony_ci
736e41f4b71Sopenharmony_ci**Parameters**
737e41f4b71Sopenharmony_ci
738e41f4b71Sopenharmony_ci| Name   | Type                     | Mandatory| Description                                                        |
739e41f4b71Sopenharmony_ci| --------- | ------------------------- | ---- | ------------------------------------------------------------ |
740e41f4b71Sopenharmony_ci| screenId  | number                    | Yes  | Screen ID. The value must be an integer.                                                  |
741e41f4b71Sopenharmony_ci| surfaceId | string                    | Yes  | Surface ID of the virtual screen. The value can be customized.                                               |
742e41f4b71Sopenharmony_ci| callback  | AsyncCallback&lt;void&gt; | Yes  | Callback used to return the result. If the virtual screen surface is successfully set, **err** is **undefined**; otherwise, **err** is an error object.|
743e41f4b71Sopenharmony_ci
744e41f4b71Sopenharmony_ci**Error codes**
745e41f4b71Sopenharmony_ci
746e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Display Error Codes](errorcode-display.md).
747e41f4b71Sopenharmony_ci
748e41f4b71Sopenharmony_ci| ID| Error Message|
749e41f4b71Sopenharmony_ci| ------- | ----------------------- |
750e41f4b71Sopenharmony_ci| 201 | Permission verification failed. |
751e41f4b71Sopenharmony_ci| 202     | Permission verification failed. A non-system application calls a system API.|
752e41f4b71Sopenharmony_ci| 401     | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types.|
753e41f4b71Sopenharmony_ci| 1400001 | Invalid display or screen. |
754e41f4b71Sopenharmony_ci
755e41f4b71Sopenharmony_ci**Example**
756e41f4b71Sopenharmony_ci
757e41f4b71Sopenharmony_ci```ts
758e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
759e41f4b71Sopenharmony_ci
760e41f4b71Sopenharmony_cilet screenId: number = 1;
761e41f4b71Sopenharmony_cilet surfaceId: string = '2048';
762e41f4b71Sopenharmony_ciscreen.setVirtualScreenSurface(screenId, surfaceId, (err: BusinessError) => {
763e41f4b71Sopenharmony_ci  const errCode: number = err.code;
764e41f4b71Sopenharmony_ci  if (errCode) {
765e41f4b71Sopenharmony_ci    console.error(`Failed to set the surface for the virtual screen. Code:${err.code},message is ${err.message}`);
766e41f4b71Sopenharmony_ci    return;
767e41f4b71Sopenharmony_ci  }
768e41f4b71Sopenharmony_ci  console.info('Succeeded in setting the surface for the virtual screen.');
769e41f4b71Sopenharmony_ci});
770e41f4b71Sopenharmony_ci```
771e41f4b71Sopenharmony_ci
772e41f4b71Sopenharmony_ci## screen.setVirtualScreenSurface
773e41f4b71Sopenharmony_ci
774e41f4b71Sopenharmony_cisetVirtualScreenSurface(screenId:number, surfaceId: string): Promise&lt;void&gt;
775e41f4b71Sopenharmony_ci
776e41f4b71Sopenharmony_ciSets the surface for a virtual screen. This API uses a promise to return the result.
777e41f4b71Sopenharmony_ci
778e41f4b71Sopenharmony_ci**System capability**: SystemCapability.WindowManager.WindowManager.Core
779e41f4b71Sopenharmony_ci
780e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.CAPTURE_SCREEN (available only to system applications)
781e41f4b71Sopenharmony_ci
782e41f4b71Sopenharmony_ci**Parameters**
783e41f4b71Sopenharmony_ci
784e41f4b71Sopenharmony_ci| Name   | Type  | Mandatory| Description         |
785e41f4b71Sopenharmony_ci| --------- | ------ | ---- | ------------- |
786e41f4b71Sopenharmony_ci| screenId  | number | Yes  | Screen ID. The value must be an integer.   |
787e41f4b71Sopenharmony_ci| surfaceId | string | Yes  | Surface ID of the virtual screen. The value can be customized.|
788e41f4b71Sopenharmony_ci
789e41f4b71Sopenharmony_ci**Return value**
790e41f4b71Sopenharmony_ci
791e41f4b71Sopenharmony_ci| Type               | Description                     |
792e41f4b71Sopenharmony_ci| ------------------- | ------------------------- |
793e41f4b71Sopenharmony_ci| Promise&lt;void&gt; | Promise that returns no value.|
794e41f4b71Sopenharmony_ci
795e41f4b71Sopenharmony_ci**Error codes**
796e41f4b71Sopenharmony_ci
797e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Display Error Codes](errorcode-display.md).
798e41f4b71Sopenharmony_ci
799e41f4b71Sopenharmony_ci| ID| Error Message|
800e41f4b71Sopenharmony_ci| ------- | ----------------------- |
801e41f4b71Sopenharmony_ci| 201 | Permission verification failed. |
802e41f4b71Sopenharmony_ci| 202     | Permission verification failed. A non-system application calls a system API.|
803e41f4b71Sopenharmony_ci| 401     | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types.|
804e41f4b71Sopenharmony_ci| 1400001 | Invalid display or screen. |
805e41f4b71Sopenharmony_ci
806e41f4b71Sopenharmony_ci**Example**
807e41f4b71Sopenharmony_ci
808e41f4b71Sopenharmony_ci```ts
809e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
810e41f4b71Sopenharmony_ci
811e41f4b71Sopenharmony_cilet screenId: number = 1;
812e41f4b71Sopenharmony_cilet surfaceId: string = '2048';
813e41f4b71Sopenharmony_ciscreen.setVirtualScreenSurface(screenId, surfaceId).then(() => {
814e41f4b71Sopenharmony_ci  console.info('Succeeded in setting the surface for the virtual screen.');
815e41f4b71Sopenharmony_ci}).catch((err: BusinessError) => {
816e41f4b71Sopenharmony_ci  console.error(`Failed to set the surface for the virtual screen. Code:${err.code},message is ${err.message}`);
817e41f4b71Sopenharmony_ci});
818e41f4b71Sopenharmony_ci```
819e41f4b71Sopenharmony_ci
820e41f4b71Sopenharmony_ci## screen.isScreenRotationLocked
821e41f4b71Sopenharmony_ci
822e41f4b71Sopenharmony_ciisScreenRotationLocked(): Promise&lt;boolean&gt;
823e41f4b71Sopenharmony_ci
824e41f4b71Sopenharmony_ciChecks whether auto rotate is locked. This API uses a promise to return the result.
825e41f4b71Sopenharmony_ci
826e41f4b71Sopenharmony_ci**System capability**: SystemCapability.WindowManager.WindowManager.Core
827e41f4b71Sopenharmony_ci
828e41f4b71Sopenharmony_ci**Return value**
829e41f4b71Sopenharmony_ci
830e41f4b71Sopenharmony_ci| Type                  | Description                                 |
831e41f4b71Sopenharmony_ci| ---------------------- | ------------------------------------- |
832e41f4b71Sopenharmony_ci| Promise&lt;boolean&gt; | Promise used to return the result. If **true** is returned, auto rotate is locked. If **false** is returned, auto rotate is unlocked.|
833e41f4b71Sopenharmony_ci
834e41f4b71Sopenharmony_ci**Error codes**
835e41f4b71Sopenharmony_ci
836e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md).
837e41f4b71Sopenharmony_ci
838e41f4b71Sopenharmony_ci| ID| Error Message|
839e41f4b71Sopenharmony_ci| ------- | ----------------------- |
840e41f4b71Sopenharmony_ci| 202     | Permission verification failed. A non-system application calls a system API.|
841e41f4b71Sopenharmony_ci
842e41f4b71Sopenharmony_ci**Example**
843e41f4b71Sopenharmony_ci
844e41f4b71Sopenharmony_ci```ts
845e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
846e41f4b71Sopenharmony_ci
847e41f4b71Sopenharmony_ciscreen.isScreenRotationLocked().then((isLocked: boolean) => {
848e41f4b71Sopenharmony_ci  console.info('Succeeded in getting the screen rotation lock status. isLocked:' + JSON.stringify(isLocked));
849e41f4b71Sopenharmony_ci}).catch((err: BusinessError) => {
850e41f4b71Sopenharmony_ci  console.error(`Failed to get the screen rotation lock status. Code:${err.code},message is ${err.message}`);
851e41f4b71Sopenharmony_ci});
852e41f4b71Sopenharmony_ci```
853e41f4b71Sopenharmony_ci
854e41f4b71Sopenharmony_ci## screen.isScreenRotationLocked
855e41f4b71Sopenharmony_ci
856e41f4b71Sopenharmony_ciisScreenRotationLocked(callback: AsyncCallback&lt;boolean&gt;): void
857e41f4b71Sopenharmony_ci
858e41f4b71Sopenharmony_ciChecks whether auto rotate is locked. This API uses an asynchronous callback to return the result.
859e41f4b71Sopenharmony_ci
860e41f4b71Sopenharmony_ci**System capability**: SystemCapability.WindowManager.WindowManager.Core
861e41f4b71Sopenharmony_ci
862e41f4b71Sopenharmony_ci**Parameters**
863e41f4b71Sopenharmony_ci
864e41f4b71Sopenharmony_ci| Name   | Type                         | Mandatory| Description                                                        |
865e41f4b71Sopenharmony_ci| --------- | ---------------------------- | ---- | ------------------------------------------------------------ |
866e41f4b71Sopenharmony_ci| callback  | AsyncCallback&lt;boolean&gt; | Yes  | Callback used to return the result. If **true** is returned, auto rotate is locked. If **false** is returned, auto rotate is unlocked.|
867e41f4b71Sopenharmony_ci
868e41f4b71Sopenharmony_ci**Error codes**
869e41f4b71Sopenharmony_ci
870e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md).
871e41f4b71Sopenharmony_ci
872e41f4b71Sopenharmony_ci| ID| Error Message|
873e41f4b71Sopenharmony_ci| ------- | ----------------------- |
874e41f4b71Sopenharmony_ci| 202     | Permission verification failed. A non-system application calls a system API.|
875e41f4b71Sopenharmony_ci
876e41f4b71Sopenharmony_ci**Example**
877e41f4b71Sopenharmony_ci
878e41f4b71Sopenharmony_ci```ts
879e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
880e41f4b71Sopenharmony_ci
881e41f4b71Sopenharmony_ciscreen.isScreenRotationLocked((err: BusinessError, isLocked: boolean) => {
882e41f4b71Sopenharmony_ciconst errCode: number = err.code;
883e41f4b71Sopenharmony_ciif (errCode) {
884e41f4b71Sopenharmony_ci  console.error(`Failed to get the screen rotation lock status. Code:${err.code},message is ${err.message}`);
885e41f4b71Sopenharmony_ci  return;
886e41f4b71Sopenharmony_ci}
887e41f4b71Sopenharmony_ciconsole.info('Succeeded in getting the screen rotation lock status. isLocked:' + JSON.stringify(isLocked));
888e41f4b71Sopenharmony_ci});
889e41f4b71Sopenharmony_ci```
890e41f4b71Sopenharmony_ci
891e41f4b71Sopenharmony_ci## screen.setScreenRotationLocked
892e41f4b71Sopenharmony_ci
893e41f4b71Sopenharmony_cisetScreenRotationLocked(isLocked: boolean): Promise&lt;void&gt;
894e41f4b71Sopenharmony_ci
895e41f4b71Sopenharmony_ciSets whether to lock auto rotate. This API uses a promise to return the result.
896e41f4b71Sopenharmony_ci
897e41f4b71Sopenharmony_ci**System capability**: SystemCapability.WindowManager.WindowManager.Core
898e41f4b71Sopenharmony_ci
899e41f4b71Sopenharmony_ci**Parameters**
900e41f4b71Sopenharmony_ci
901e41f4b71Sopenharmony_ci| Name   | Type  | Mandatory| Description         |
902e41f4b71Sopenharmony_ci| --------- | ------ | ---- | ------------- |
903e41f4b71Sopenharmony_ci| isLocked  | boolean | Yes  | Whether to lock auto rotate. The value **true** means to lock auto rotate, and **false** means the opposite.|
904e41f4b71Sopenharmony_ci
905e41f4b71Sopenharmony_ci**Return value**
906e41f4b71Sopenharmony_ci
907e41f4b71Sopenharmony_ci| Type               | Description                     |
908e41f4b71Sopenharmony_ci| ------------------- | ------------------------- |
909e41f4b71Sopenharmony_ci| Promise&lt;void&gt; | Promise that returns no value.|
910e41f4b71Sopenharmony_ci
911e41f4b71Sopenharmony_ci**Error codes**
912e41f4b71Sopenharmony_ci
913e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md).
914e41f4b71Sopenharmony_ci
915e41f4b71Sopenharmony_ci| ID| Error Message|
916e41f4b71Sopenharmony_ci| ------- | ----------------------- |
917e41f4b71Sopenharmony_ci| 202     | Permission verification failed. A non-system application calls a system API.|
918e41f4b71Sopenharmony_ci| 401     | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types.|
919e41f4b71Sopenharmony_ci
920e41f4b71Sopenharmony_ci**Example**
921e41f4b71Sopenharmony_ci
922e41f4b71Sopenharmony_ci```ts
923e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
924e41f4b71Sopenharmony_ci
925e41f4b71Sopenharmony_cilet isLocked: boolean = false;
926e41f4b71Sopenharmony_ciscreen.setScreenRotationLocked(isLocked).then(() => {
927e41f4b71Sopenharmony_ci  console.info('Succeeded in unlocking auto rotate');
928e41f4b71Sopenharmony_ci}).catch((err: BusinessError) => {
929e41f4b71Sopenharmony_ci  console.error(`Failed to unlock auto rotate. Code:${err.code},message is ${err.message}`);
930e41f4b71Sopenharmony_ci});
931e41f4b71Sopenharmony_ci```
932e41f4b71Sopenharmony_ci
933e41f4b71Sopenharmony_ci## screen.setScreenRotationLocked
934e41f4b71Sopenharmony_ci
935e41f4b71Sopenharmony_cisetScreenRotationLocked(isLocked: boolean, callback: AsyncCallback&lt;void&gt;): void
936e41f4b71Sopenharmony_ci
937e41f4b71Sopenharmony_ciSets whether to lock auto rotate. This API uses an asynchronous callback to return the result.
938e41f4b71Sopenharmony_ci
939e41f4b71Sopenharmony_ci**System capability**: SystemCapability.WindowManager.WindowManager.Core
940e41f4b71Sopenharmony_ci
941e41f4b71Sopenharmony_ci**Parameters**
942e41f4b71Sopenharmony_ci
943e41f4b71Sopenharmony_ci| Name   | Type                     | Mandatory| Description                                                        |
944e41f4b71Sopenharmony_ci| --------- | ------------------------- | ---- | ------------------------------------------------------------ |
945e41f4b71Sopenharmony_ci| isLocked  | boolean                   | Yes  | Whether to lock auto rotate. The value **true** means to lock auto rotate, and **false** means the opposite.                |
946e41f4b71Sopenharmony_ci| callback  | AsyncCallback&lt;void&gt; | Yes  | Callback used to return the result. If the operation is successful, **err** is **undefined**; otherwise, **err** is an error object.|
947e41f4b71Sopenharmony_ci
948e41f4b71Sopenharmony_ci**Error codes**
949e41f4b71Sopenharmony_ci
950e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md).
951e41f4b71Sopenharmony_ci
952e41f4b71Sopenharmony_ci| ID| Error Message|
953e41f4b71Sopenharmony_ci| ------- | ----------------------- |
954e41f4b71Sopenharmony_ci| 202     | Permission verification failed. A non-system application calls a system API.|
955e41f4b71Sopenharmony_ci| 401     | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types.|
956e41f4b71Sopenharmony_ci
957e41f4b71Sopenharmony_ci**Example**
958e41f4b71Sopenharmony_ci
959e41f4b71Sopenharmony_ci```ts
960e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
961e41f4b71Sopenharmony_ci
962e41f4b71Sopenharmony_cilet isLocked: boolean = false;
963e41f4b71Sopenharmony_ciscreen.setScreenRotationLocked(isLocked, (err: BusinessError) => {
964e41f4b71Sopenharmony_ci  const errCode: number = err.code;
965e41f4b71Sopenharmony_ci  if (errCode) {
966e41f4b71Sopenharmony_ci    console.error(`Failed to unlock auto rotate. Code:${err.code},message is ${err.message}`);
967e41f4b71Sopenharmony_ci    return;
968e41f4b71Sopenharmony_ci  }
969e41f4b71Sopenharmony_ci  console.info('Succeeded in unlocking auto rotate.');
970e41f4b71Sopenharmony_ci});
971e41f4b71Sopenharmony_ci```
972e41f4b71Sopenharmony_ci
973e41f4b71Sopenharmony_ci## ExpandOption
974e41f4b71Sopenharmony_ci
975e41f4b71Sopenharmony_ciDefines the parameters for expanding a screen.
976e41f4b71Sopenharmony_ci
977e41f4b71Sopenharmony_ci**System capability**: SystemCapability.WindowManager.WindowManager.Core
978e41f4b71Sopenharmony_ci
979e41f4b71Sopenharmony_ci| Name    | Type| Readable| Writable| Description               |
980e41f4b71Sopenharmony_ci| -------- | -------- | ---- | ---- | ------------------- |
981e41f4b71Sopenharmony_ci| screenId | number   | Yes  | Yes  | Screen ID. The value must be an integer.         |
982e41f4b71Sopenharmony_ci| startX   | number   | Yes  | Yes  | Start X coordinate of the screen. The value must be an integer.|
983e41f4b71Sopenharmony_ci| startY   | number   | Yes  | Yes  | Start Y coordinate of the screen. The value must be an integer.|
984e41f4b71Sopenharmony_ci
985e41f4b71Sopenharmony_ci## VirtualScreenOption
986e41f4b71Sopenharmony_ci
987e41f4b71Sopenharmony_ciDefines virtual screen parameters.
988e41f4b71Sopenharmony_ci
989e41f4b71Sopenharmony_ci**System capability**: SystemCapability.WindowManager.WindowManager.Core
990e41f4b71Sopenharmony_ci
991e41f4b71Sopenharmony_ci| Name     | Type| Readable| Writable| Description                      |
992e41f4b71Sopenharmony_ci| --------- | -------- | ---- | ---- |--------------------------|
993e41f4b71Sopenharmony_ci| name      | string   | Yes  | Yes  | Name of a virtual screen.              |
994e41f4b71Sopenharmony_ci| width     | number   | Yes  | Yes  | Width of the virtual screen, in px. The value must be an integer.|
995e41f4b71Sopenharmony_ci| height    | number   | Yes  | Yes  | Height of the virtual screen, in px. The value must be an integer.|
996e41f4b71Sopenharmony_ci| density   | number   | Yes  | Yes  | Density of the virtual screen, in px. The value must be a floating point number.|
997e41f4b71Sopenharmony_ci| surfaceId | string   | Yes  | Yes  | Surface ID of the virtual screen.       |
998e41f4b71Sopenharmony_ci
999e41f4b71Sopenharmony_ci## Screen
1000e41f4b71Sopenharmony_ci
1001e41f4b71Sopenharmony_ciImplements a **Screen** instance.
1002e41f4b71Sopenharmony_ci
1003e41f4b71Sopenharmony_ciBefore calling any API in **Screen**, you must use **[getAllScreens()](#screengetallscreens)** or **[createVirtualScreen()](#screencreatevirtualscreen)** to obtain a **Screen** instance.
1004e41f4b71Sopenharmony_ci
1005e41f4b71Sopenharmony_ci### Attributes
1006e41f4b71Sopenharmony_ci
1007e41f4b71Sopenharmony_ci**System capability**: SystemCapability.WindowManager.WindowManager.Core
1008e41f4b71Sopenharmony_ci
1009e41f4b71Sopenharmony_ci| Name             | Type                                      | Readable| Writable| Description                                                         |
1010e41f4b71Sopenharmony_ci| ----------------- | ---------------------------------------------- | ---- | ---- |-------------------------------------------------------------|
1011e41f4b71Sopenharmony_ci| id                | number                                         | Yes  | No  | Screen ID. The value must be an integer.                                             |
1012e41f4b71Sopenharmony_ci| parent            | number                                         | Yes  | No  | ID of the group to which a screen belongs. The value must be an integer.                                         |
1013e41f4b71Sopenharmony_ci| supportedModeInfo | Array&lt;[ScreenModeInfo](#screenmodeinfo)&gt; | Yes  | No  | Mode set supported by the screen.                                                 |
1014e41f4b71Sopenharmony_ci| activeModeIndex   | number                                         | Yes  | No  | Index of the active screen mode. The current value and value range of this parameter vary according to the screen resolution, refresh rate, and device hardware. The value must be an integer.|
1015e41f4b71Sopenharmony_ci| orientation       | [Orientation](#orientation)                     | Yes  | No  | Screen orientation.                                                      |
1016e41f4b71Sopenharmony_ci| sourceMode<sup>10+</sup> | [ScreenSourceMode](#screensourcemode10)            | Yes  | No  | Source mode of the screen.                                                    |
1017e41f4b71Sopenharmony_ci
1018e41f4b71Sopenharmony_ci### setOrientation
1019e41f4b71Sopenharmony_ci
1020e41f4b71Sopenharmony_cisetOrientation(orientation: Orientation, callback: AsyncCallback&lt;void&gt;): void
1021e41f4b71Sopenharmony_ci
1022e41f4b71Sopenharmony_ciSets the screen orientation. This API uses an asynchronous callback to return the result.
1023e41f4b71Sopenharmony_ci
1024e41f4b71Sopenharmony_ci**System capability**: SystemCapability.WindowManager.WindowManager.Core
1025e41f4b71Sopenharmony_ci
1026e41f4b71Sopenharmony_ci| Name     | Type                       | Mandatory| Description                                                        |
1027e41f4b71Sopenharmony_ci| ----------- | --------------------------- | ---- | ------------------------------------------------------------ |
1028e41f4b71Sopenharmony_ci| orientation | [Orientation](#orientation) | Yes  | Screen orientation. The value must be an enumerated value of **Orientation**.               |
1029e41f4b71Sopenharmony_ci| callback    | AsyncCallback&lt;void&gt;   | Yes  | Callback used to return the result. If the screen orientation is successfully set, **err** is **undefined**; otherwise, **err** is an error object.|
1030e41f4b71Sopenharmony_ci
1031e41f4b71Sopenharmony_ci**Error codes**
1032e41f4b71Sopenharmony_ci
1033e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Display Error Codes](errorcode-display.md).
1034e41f4b71Sopenharmony_ci
1035e41f4b71Sopenharmony_ci| ID| Error Message|
1036e41f4b71Sopenharmony_ci| ------- | -------------------------------------------- |
1037e41f4b71Sopenharmony_ci| 202     | Permission verification failed. A non-system application calls a system API.|
1038e41f4b71Sopenharmony_ci| 401     | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. 3.Parameter verification failed.|
1039e41f4b71Sopenharmony_ci| 1400003 | This display manager service works abnormally. |
1040e41f4b71Sopenharmony_ci
1041e41f4b71Sopenharmony_ci**Example**
1042e41f4b71Sopenharmony_ci
1043e41f4b71Sopenharmony_ci```ts
1044e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
1045e41f4b71Sopenharmony_ci
1046e41f4b71Sopenharmony_ciclass VirtualScreenOption {
1047e41f4b71Sopenharmony_ci  name : string = '';
1048e41f4b71Sopenharmony_ci  width : number =  0;
1049e41f4b71Sopenharmony_ci  height : number = 0;
1050e41f4b71Sopenharmony_ci  density : number = 0;
1051e41f4b71Sopenharmony_ci  surfaceId : string = '';
1052e41f4b71Sopenharmony_ci}
1053e41f4b71Sopenharmony_ci
1054e41f4b71Sopenharmony_cilet option : VirtualScreenOption = {
1055e41f4b71Sopenharmony_ci  name: 'screen01',
1056e41f4b71Sopenharmony_ci  width: 1080,
1057e41f4b71Sopenharmony_ci  height: 2340,
1058e41f4b71Sopenharmony_ci  density: 2,
1059e41f4b71Sopenharmony_ci  surfaceId: ''
1060e41f4b71Sopenharmony_ci};
1061e41f4b71Sopenharmony_ci
1062e41f4b71Sopenharmony_ciscreen.createVirtualScreen(option).then((data: screen.Screen) => {
1063e41f4b71Sopenharmony_ci  let screenClass: screen.Screen = data;
1064e41f4b71Sopenharmony_ci  console.info('Succeeded in creating the virtual screen. Data: ' + JSON.stringify(data));
1065e41f4b71Sopenharmony_ci  screenClass.setOrientation(screen.Orientation.VERTICAL, (err: BusinessError) => {
1066e41f4b71Sopenharmony_ci    const errCode: number = err.code;
1067e41f4b71Sopenharmony_ci    if (errCode) {
1068e41f4b71Sopenharmony_ci      console.error(`Failed to set the vertical orientation. Code:${err.code},message is ${err.message}`);
1069e41f4b71Sopenharmony_ci      return;
1070e41f4b71Sopenharmony_ci    }
1071e41f4b71Sopenharmony_ci    console.info('Succeeded in setting the vertical orientation.');
1072e41f4b71Sopenharmony_ci  });
1073e41f4b71Sopenharmony_ci}).catch((err: BusinessError) => {
1074e41f4b71Sopenharmony_ci  console.error(`Failed to create the virtual screen. Code:${err.code},message is ${err.message}`);
1075e41f4b71Sopenharmony_ci});
1076e41f4b71Sopenharmony_ci```
1077e41f4b71Sopenharmony_ci
1078e41f4b71Sopenharmony_ci### setOrientation
1079e41f4b71Sopenharmony_ci
1080e41f4b71Sopenharmony_cisetOrientation(orientation: Orientation): Promise&lt;void&gt;
1081e41f4b71Sopenharmony_ci
1082e41f4b71Sopenharmony_ciSets the screen orientation. This API uses a promise to return the result.
1083e41f4b71Sopenharmony_ci
1084e41f4b71Sopenharmony_ci**System capability**: SystemCapability.WindowManager.WindowManager.Core
1085e41f4b71Sopenharmony_ci
1086e41f4b71Sopenharmony_ci| Name     | Type                       | Mandatory| Description      |
1087e41f4b71Sopenharmony_ci| ----------- | --------------------------- | ---- | ---------- |
1088e41f4b71Sopenharmony_ci| orientation | [Orientation](#orientation) | Yes  | Screen orientation. The value must be an enumerated value of **Orientation**.|
1089e41f4b71Sopenharmony_ci
1090e41f4b71Sopenharmony_ci**Return value**
1091e41f4b71Sopenharmony_ci
1092e41f4b71Sopenharmony_ci| Type               | Description                     |
1093e41f4b71Sopenharmony_ci| ------------------- | ------------------------- |
1094e41f4b71Sopenharmony_ci| Promise&lt;void&gt; | Promise that returns no value.|
1095e41f4b71Sopenharmony_ci
1096e41f4b71Sopenharmony_ci**Error codes**
1097e41f4b71Sopenharmony_ci
1098e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Display Error Codes](errorcode-display.md).
1099e41f4b71Sopenharmony_ci
1100e41f4b71Sopenharmony_ci| ID| Error Message|
1101e41f4b71Sopenharmony_ci| ------- | -------------------------------------------- |
1102e41f4b71Sopenharmony_ci| 202     | Permission verification failed. A non-system application calls a system API.|
1103e41f4b71Sopenharmony_ci| 401     | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. 3.Parameter verification failed.|
1104e41f4b71Sopenharmony_ci| 1400003 | This display manager service works abnormally. |
1105e41f4b71Sopenharmony_ci
1106e41f4b71Sopenharmony_ci**Example**
1107e41f4b71Sopenharmony_ci
1108e41f4b71Sopenharmony_ci```ts
1109e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
1110e41f4b71Sopenharmony_ci
1111e41f4b71Sopenharmony_ciclass VirtualScreenOption {
1112e41f4b71Sopenharmony_ci  name : string = '';
1113e41f4b71Sopenharmony_ci  width : number =  0;
1114e41f4b71Sopenharmony_ci  height : number = 0;
1115e41f4b71Sopenharmony_ci  density : number = 0;
1116e41f4b71Sopenharmony_ci  surfaceId : string = '';
1117e41f4b71Sopenharmony_ci}
1118e41f4b71Sopenharmony_ci
1119e41f4b71Sopenharmony_cilet option : VirtualScreenOption = {
1120e41f4b71Sopenharmony_ci  name: 'screen01',
1121e41f4b71Sopenharmony_ci  width: 1080,
1122e41f4b71Sopenharmony_ci  height: 2340,
1123e41f4b71Sopenharmony_ci  density: 2,
1124e41f4b71Sopenharmony_ci  surfaceId: ''
1125e41f4b71Sopenharmony_ci};
1126e41f4b71Sopenharmony_ci
1127e41f4b71Sopenharmony_ciscreen.createVirtualScreen(option).then((data: screen.Screen) => {
1128e41f4b71Sopenharmony_ci  let screenClass: screen.Screen = data;
1129e41f4b71Sopenharmony_ci  console.info('Succeeded in creating the virtual screen. Data: ' + JSON.stringify(data));
1130e41f4b71Sopenharmony_ci  let promise: Promise<void> = screenClass.setOrientation(screen.Orientation.VERTICAL);
1131e41f4b71Sopenharmony_ci  promise.then(() => {
1132e41f4b71Sopenharmony_ci    console.info('Succeeded in setting the vertical orientation.');
1133e41f4b71Sopenharmony_ci  }).catch((err: BusinessError) => {
1134e41f4b71Sopenharmony_ci    console.error(`Failed to set the vertical orientation. Code:${err.code},message is ${err.message}`);
1135e41f4b71Sopenharmony_ci  });
1136e41f4b71Sopenharmony_ci}).catch((err: BusinessError) => {
1137e41f4b71Sopenharmony_ci  console.error(`Failed to create the virtual screen. Code:${err.code},message is ${err.message}`);
1138e41f4b71Sopenharmony_ci});
1139e41f4b71Sopenharmony_ci```
1140e41f4b71Sopenharmony_ci
1141e41f4b71Sopenharmony_ci### setScreenActiveMode
1142e41f4b71Sopenharmony_ci
1143e41f4b71Sopenharmony_cisetScreenActiveMode(modeIndex: number, callback: AsyncCallback&lt;void&gt;): void
1144e41f4b71Sopenharmony_ci
1145e41f4b71Sopenharmony_ciSets the active mode of the screen. This API uses an asynchronous callback to return the result.
1146e41f4b71Sopenharmony_ci
1147e41f4b71Sopenharmony_ci**System capability**: SystemCapability.WindowManager.WindowManager.Core
1148e41f4b71Sopenharmony_ci
1149e41f4b71Sopenharmony_ci| Name   | Type                     | Mandatory| Description                                                        |
1150e41f4b71Sopenharmony_ci| --------- | ------------------------- | ---- | ------------------------------------------------------------ |
1151e41f4b71Sopenharmony_ci| modeIndex | number                    | Yes  | Index of the mode to set. The current value and value range of this parameter vary according to the screen resolution, refresh rate, and device hardware. The value must be an integer.|
1152e41f4b71Sopenharmony_ci| callback  | AsyncCallback&lt;void&gt; | Yes  | Callback used to return the result. If the active mode is successfully set, **err** is **undefined**; otherwise, **err** is an error object.|
1153e41f4b71Sopenharmony_ci
1154e41f4b71Sopenharmony_ci**Error codes**
1155e41f4b71Sopenharmony_ci
1156e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Display Error Codes](errorcode-display.md).
1157e41f4b71Sopenharmony_ci
1158e41f4b71Sopenharmony_ci| ID| Error Message|
1159e41f4b71Sopenharmony_ci| ------- | -------------------------------------------- |
1160e41f4b71Sopenharmony_ci| 202     | Permission verification failed. A non-system application calls a system API.|
1161e41f4b71Sopenharmony_ci| 401     | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types.|
1162e41f4b71Sopenharmony_ci| 1400003 | This display manager service works abnormally. |
1163e41f4b71Sopenharmony_ci
1164e41f4b71Sopenharmony_ci**Example**
1165e41f4b71Sopenharmony_ci
1166e41f4b71Sopenharmony_ci```ts
1167e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
1168e41f4b71Sopenharmony_ci
1169e41f4b71Sopenharmony_ciclass VirtualScreenOption {
1170e41f4b71Sopenharmony_ci  name : string = '';
1171e41f4b71Sopenharmony_ci  width : number =  0;
1172e41f4b71Sopenharmony_ci  height : number = 0;
1173e41f4b71Sopenharmony_ci  density : number = 0;
1174e41f4b71Sopenharmony_ci  surfaceId : string = '';
1175e41f4b71Sopenharmony_ci}
1176e41f4b71Sopenharmony_ci
1177e41f4b71Sopenharmony_cilet option : VirtualScreenOption = {
1178e41f4b71Sopenharmony_ci  name: 'screen01',
1179e41f4b71Sopenharmony_ci  width: 1080,
1180e41f4b71Sopenharmony_ci  height: 2340,
1181e41f4b71Sopenharmony_ci  density: 2,
1182e41f4b71Sopenharmony_ci  surfaceId: ''
1183e41f4b71Sopenharmony_ci};
1184e41f4b71Sopenharmony_ci
1185e41f4b71Sopenharmony_ciscreen.createVirtualScreen(option).then((data: screen.Screen) => {
1186e41f4b71Sopenharmony_ci  let screenClass: screen.Screen = data;
1187e41f4b71Sopenharmony_ci  console.info('Succeeded in creating the virtual screen. Data: ' + JSON.stringify(data));
1188e41f4b71Sopenharmony_ci  let modeIndex: number = 0;
1189e41f4b71Sopenharmony_ci  screenClass.setScreenActiveMode(modeIndex, (err: BusinessError) => {
1190e41f4b71Sopenharmony_ci    const errCode: number = err.code;
1191e41f4b71Sopenharmony_ci    if (errCode) {
1192e41f4b71Sopenharmony_ci      console.error(`Failed to set screen active mode 0. Code:${err.code},message is ${err.message}`);
1193e41f4b71Sopenharmony_ci      return;
1194e41f4b71Sopenharmony_ci    }
1195e41f4b71Sopenharmony_ci    console.info('Succeeded in setting the vertical orientation.');
1196e41f4b71Sopenharmony_ci  });
1197e41f4b71Sopenharmony_ci}).catch((err: BusinessError) => {
1198e41f4b71Sopenharmony_ci  console.error(`Failed to create the virtual screen. Code:${err.code},message is ${err.message}`);
1199e41f4b71Sopenharmony_ci});
1200e41f4b71Sopenharmony_ci```
1201e41f4b71Sopenharmony_ci
1202e41f4b71Sopenharmony_ci### setScreenActiveMode
1203e41f4b71Sopenharmony_ci
1204e41f4b71Sopenharmony_cisetScreenActiveMode(modeIndex: number): Promise&lt;void&gt;
1205e41f4b71Sopenharmony_ci
1206e41f4b71Sopenharmony_ciSets the active mode of the screen. This API uses a promise to return the result.
1207e41f4b71Sopenharmony_ci
1208e41f4b71Sopenharmony_ci**System capability**: SystemCapability.WindowManager.WindowManager.Core
1209e41f4b71Sopenharmony_ci
1210e41f4b71Sopenharmony_ci| Name   | Type  | Mandatory| Description      |
1211e41f4b71Sopenharmony_ci| --------- | ------ | ---- | ---------- |
1212e41f4b71Sopenharmony_ci| modeIndex | number | Yes  | Index of the mode to set. The current value and value range of this parameter vary according to the screen resolution, refresh rate, and device hardware. The value must be an integer.|
1213e41f4b71Sopenharmony_ci
1214e41f4b71Sopenharmony_ci**Return value**
1215e41f4b71Sopenharmony_ci
1216e41f4b71Sopenharmony_ci| Type               | Description                     |
1217e41f4b71Sopenharmony_ci| ------------------- | ------------------------- |
1218e41f4b71Sopenharmony_ci| Promise&lt;void&gt; | Promise that returns no value.|
1219e41f4b71Sopenharmony_ci
1220e41f4b71Sopenharmony_ci**Error codes**
1221e41f4b71Sopenharmony_ci
1222e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Display Error Codes](errorcode-display.md).
1223e41f4b71Sopenharmony_ci
1224e41f4b71Sopenharmony_ci| ID| Error Message|
1225e41f4b71Sopenharmony_ci| ------- | -------------------------------------------- |
1226e41f4b71Sopenharmony_ci| 202     | Permission verification failed. A non-system application calls a system API.|
1227e41f4b71Sopenharmony_ci| 401     | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types.|
1228e41f4b71Sopenharmony_ci| 1400003 | This display manager service works abnormally. |
1229e41f4b71Sopenharmony_ci
1230e41f4b71Sopenharmony_ci**Example**
1231e41f4b71Sopenharmony_ci
1232e41f4b71Sopenharmony_ci```ts
1233e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
1234e41f4b71Sopenharmony_ci
1235e41f4b71Sopenharmony_ciclass VirtualScreenOption {
1236e41f4b71Sopenharmony_ci  name : string = '';
1237e41f4b71Sopenharmony_ci  width : number =  0;
1238e41f4b71Sopenharmony_ci  height : number = 0;
1239e41f4b71Sopenharmony_ci  density : number = 0;
1240e41f4b71Sopenharmony_ci  surfaceId : string = '';
1241e41f4b71Sopenharmony_ci}
1242e41f4b71Sopenharmony_ci
1243e41f4b71Sopenharmony_cilet option : VirtualScreenOption = {
1244e41f4b71Sopenharmony_ci  name: 'screen01',
1245e41f4b71Sopenharmony_ci  width: 1080,
1246e41f4b71Sopenharmony_ci  height: 2340,
1247e41f4b71Sopenharmony_ci  density: 2,
1248e41f4b71Sopenharmony_ci  surfaceId: ''
1249e41f4b71Sopenharmony_ci};
1250e41f4b71Sopenharmony_ci
1251e41f4b71Sopenharmony_ciscreen.createVirtualScreen(option).then((data: screen.Screen) => {
1252e41f4b71Sopenharmony_ci  let screenClass: screen.Screen = data;
1253e41f4b71Sopenharmony_ci  console.info('Succeeded in creating the virtual screen. Data: ' + JSON.stringify(data));
1254e41f4b71Sopenharmony_ci  let modeIndex: number = 0;
1255e41f4b71Sopenharmony_ci  let promise: Promise<void> = screenClass.setScreenActiveMode(modeIndex);
1256e41f4b71Sopenharmony_ci  promise.then(() => {
1257e41f4b71Sopenharmony_ci    console.info('Succeeded in setting screen active mode 0.');
1258e41f4b71Sopenharmony_ci  }).catch((err: BusinessError) => {
1259e41f4b71Sopenharmony_ci    console.error(`Failed to set screen active mode 0.Code:${err.code},message is ${err.message}`);
1260e41f4b71Sopenharmony_ci  });
1261e41f4b71Sopenharmony_ci}).catch((err: BusinessError) => {
1262e41f4b71Sopenharmony_ci  console.error(`Failed to create the virtual screen. Code:${err.code},message is ${err.message}`);
1263e41f4b71Sopenharmony_ci});
1264e41f4b71Sopenharmony_ci```
1265e41f4b71Sopenharmony_ci
1266e41f4b71Sopenharmony_ci### setDensityDpi
1267e41f4b71Sopenharmony_ci
1268e41f4b71Sopenharmony_cisetDensityDpi(densityDpi: number, callback: AsyncCallback&lt;void&gt;): void;
1269e41f4b71Sopenharmony_ci
1270e41f4b71Sopenharmony_ciSets the pixel density of the screen. This API uses an asynchronous callback to return the result.
1271e41f4b71Sopenharmony_ci
1272e41f4b71Sopenharmony_ci**System capability**: SystemCapability.WindowManager.WindowManager.Core
1273e41f4b71Sopenharmony_ci
1274e41f4b71Sopenharmony_ci| Name    | Type                     | Mandatory| Description                                      |
1275e41f4b71Sopenharmony_ci| ---------- | ------------------------- | ---- |------------------------------------------|
1276e41f4b71Sopenharmony_ci| densityDpi | number                    | Yes  | Pixel density. The value must be an integer in the range [80, 640].      |
1277e41f4b71Sopenharmony_ci| callback   | AsyncCallback&lt;void&gt; | Yes  | Callback used to return the result. If the pixel density is successfully set, **err** is **undefined**; otherwise, **err** is an error object.|
1278e41f4b71Sopenharmony_ci
1279e41f4b71Sopenharmony_ci**Error codes**
1280e41f4b71Sopenharmony_ci
1281e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Display Error Codes](errorcode-display.md).
1282e41f4b71Sopenharmony_ci
1283e41f4b71Sopenharmony_ci| ID| Error Message|
1284e41f4b71Sopenharmony_ci| ------- | -------------------------------------------- |
1285e41f4b71Sopenharmony_ci| 202     | Permission verification failed. A non-system application calls a system API.|
1286e41f4b71Sopenharmony_ci| 401     | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types.|
1287e41f4b71Sopenharmony_ci| 1400003 | This display manager service works abnormally. |
1288e41f4b71Sopenharmony_ci
1289e41f4b71Sopenharmony_ci**Example**
1290e41f4b71Sopenharmony_ci
1291e41f4b71Sopenharmony_ci```ts
1292e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
1293e41f4b71Sopenharmony_ci
1294e41f4b71Sopenharmony_cilet densityDpi: number = 320;
1295e41f4b71Sopenharmony_ciclass VirtualScreenOption {
1296e41f4b71Sopenharmony_ci  name : string = '';
1297e41f4b71Sopenharmony_ci  width : number =  0;
1298e41f4b71Sopenharmony_ci  height : number = 0;
1299e41f4b71Sopenharmony_ci  density : number = 0;
1300e41f4b71Sopenharmony_ci  surfaceId : string = '';
1301e41f4b71Sopenharmony_ci}
1302e41f4b71Sopenharmony_ci
1303e41f4b71Sopenharmony_cilet option : VirtualScreenOption = {
1304e41f4b71Sopenharmony_ci  name: 'screen01',
1305e41f4b71Sopenharmony_ci  width: 1080,
1306e41f4b71Sopenharmony_ci  height: 2340,
1307e41f4b71Sopenharmony_ci  density: 2,
1308e41f4b71Sopenharmony_ci  surfaceId: ''
1309e41f4b71Sopenharmony_ci};
1310e41f4b71Sopenharmony_ci
1311e41f4b71Sopenharmony_ciscreen.createVirtualScreen(option).then((data: screen.Screen) => {
1312e41f4b71Sopenharmony_ci  let screenClass: screen.Screen = data;
1313e41f4b71Sopenharmony_ci  console.info('Succeeded in creating the virtual screen. Data: ' + JSON.stringify(data));
1314e41f4b71Sopenharmony_ci  screenClass.setDensityDpi(densityDpi, (err: BusinessError) => {
1315e41f4b71Sopenharmony_ci    const errCode: number = err.code;
1316e41f4b71Sopenharmony_ci    if (errCode) {
1317e41f4b71Sopenharmony_ci      console.error(`Failed to set the pixel density of the screen to 320. Code:${err.code},message is ${err.message}`);
1318e41f4b71Sopenharmony_ci      return;
1319e41f4b71Sopenharmony_ci    }
1320e41f4b71Sopenharmony_ci    console.info('Succeeded in setting the vertical orientation.');
1321e41f4b71Sopenharmony_ci  });
1322e41f4b71Sopenharmony_ci}).catch((err: BusinessError) => {
1323e41f4b71Sopenharmony_ci  console.error(`Failed to create the virtual screen. Code:${err.code},message is ${err.message}`);
1324e41f4b71Sopenharmony_ci});
1325e41f4b71Sopenharmony_ci```
1326e41f4b71Sopenharmony_ci
1327e41f4b71Sopenharmony_ci### setDensityDpi
1328e41f4b71Sopenharmony_ci
1329e41f4b71Sopenharmony_cisetDensityDpi(densityDpi: number): Promise&lt;void&gt;
1330e41f4b71Sopenharmony_ci
1331e41f4b71Sopenharmony_ciSets the pixel density of the screen. This API uses a promise to return the result.
1332e41f4b71Sopenharmony_ci
1333e41f4b71Sopenharmony_ci**System capability**: SystemCapability.WindowManager.WindowManager.Core
1334e41f4b71Sopenharmony_ci
1335e41f4b71Sopenharmony_ci| Name    | Type  | Mandatory| Description                                |
1336e41f4b71Sopenharmony_ci| ---------- | ------ | ---- |------------------------------------|
1337e41f4b71Sopenharmony_ci| densityDpi | number | Yes  | Pixel density. The value must be an integer in the range [80, 640].|
1338e41f4b71Sopenharmony_ci
1339e41f4b71Sopenharmony_ci**Return value**
1340e41f4b71Sopenharmony_ci
1341e41f4b71Sopenharmony_ci| Type               | Description                     |
1342e41f4b71Sopenharmony_ci| ------------------- | ------------------------- |
1343e41f4b71Sopenharmony_ci| Promise&lt;void&gt; | Promise that returns no value.|
1344e41f4b71Sopenharmony_ci
1345e41f4b71Sopenharmony_ci**Error codes**
1346e41f4b71Sopenharmony_ci
1347e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Display Error Codes](errorcode-display.md).
1348e41f4b71Sopenharmony_ci
1349e41f4b71Sopenharmony_ci| ID| Error Message|
1350e41f4b71Sopenharmony_ci| ------- | -------------------------------------------- |
1351e41f4b71Sopenharmony_ci| 202     | Permission verification failed. A non-system application calls a system API.|
1352e41f4b71Sopenharmony_ci| 401     | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types.|
1353e41f4b71Sopenharmony_ci| 1400003 | This display manager service works abnormally. |
1354e41f4b71Sopenharmony_ci
1355e41f4b71Sopenharmony_ci**Example**
1356e41f4b71Sopenharmony_ci
1357e41f4b71Sopenharmony_ci```ts
1358e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
1359e41f4b71Sopenharmony_ci
1360e41f4b71Sopenharmony_cilet densityDpi: number = 320;
1361e41f4b71Sopenharmony_ciclass VirtualScreenOption {
1362e41f4b71Sopenharmony_ci  name : string = '';
1363e41f4b71Sopenharmony_ci  width : number =  0;
1364e41f4b71Sopenharmony_ci  height : number = 0;
1365e41f4b71Sopenharmony_ci  density : number = 0;
1366e41f4b71Sopenharmony_ci  surfaceId : string = '';
1367e41f4b71Sopenharmony_ci}
1368e41f4b71Sopenharmony_ci
1369e41f4b71Sopenharmony_cilet option : VirtualScreenOption = {
1370e41f4b71Sopenharmony_ci  name: 'screen01',
1371e41f4b71Sopenharmony_ci  width: 1080,
1372e41f4b71Sopenharmony_ci  height: 2340,
1373e41f4b71Sopenharmony_ci  density: 2,
1374e41f4b71Sopenharmony_ci  surfaceId: ''
1375e41f4b71Sopenharmony_ci};
1376e41f4b71Sopenharmony_ci
1377e41f4b71Sopenharmony_ciscreen.createVirtualScreen(option).then((data: screen.Screen) => {
1378e41f4b71Sopenharmony_ci  let screenClass: screen.Screen = data;
1379e41f4b71Sopenharmony_ci  let promise: Promise<void> = screenClass.setDensityDpi(densityDpi);
1380e41f4b71Sopenharmony_ci  promise.then(() => {
1381e41f4b71Sopenharmony_ci    console.info('Succeeded in setting the pixel density of the screen to 320.');
1382e41f4b71Sopenharmony_ci  }).catch((err: BusinessError) => {
1383e41f4b71Sopenharmony_ci    console.error(`Failed to set the pixel density of the screen to 320. Code:${err.code},message is ${err.message}`);
1384e41f4b71Sopenharmony_ci  });
1385e41f4b71Sopenharmony_ci}).catch((err: BusinessError) => {
1386e41f4b71Sopenharmony_ci  console.error(`Failed to create the virtual screen. Code:${err.code},message is ${err.message}`);
1387e41f4b71Sopenharmony_ci});
1388e41f4b71Sopenharmony_ci```
1389e41f4b71Sopenharmony_ci
1390e41f4b71Sopenharmony_ci## Orientation
1391e41f4b71Sopenharmony_ci
1392e41f4b71Sopenharmony_ciEnumerates the screen orientations.
1393e41f4b71Sopenharmony_ci
1394e41f4b71Sopenharmony_ci**System capability**: SystemCapability.WindowManager.WindowManager.Core
1395e41f4b71Sopenharmony_ci
1396e41f4b71Sopenharmony_ci| Name              | Value  | Description                            |
1397e41f4b71Sopenharmony_ci| ------------------ | ---- | -------------------------------- |
1398e41f4b71Sopenharmony_ci| UNSPECIFIED        | 0    | Unspecified. The screen orientation is determined by the system.|
1399e41f4b71Sopenharmony_ci| VERTICAL           | 1    | Vertical.        |
1400e41f4b71Sopenharmony_ci| HORIZONTAL         | 2    | Horizontal.        |
1401e41f4b71Sopenharmony_ci| REVERSE_VERTICAL   | 3    | Reverse vertical.    |
1402e41f4b71Sopenharmony_ci| REVERSE_HORIZONTAL | 4    | Reverse horizontal.    |
1403e41f4b71Sopenharmony_ci
1404e41f4b71Sopenharmony_ci## ScreenSourceMode<sup>10+</sup>
1405e41f4b71Sopenharmony_ci
1406e41f4b71Sopenharmony_ciEnumerates the display content source modes of the screen.
1407e41f4b71Sopenharmony_ci
1408e41f4b71Sopenharmony_ci**System capability**: SystemCapability.WindowManager.WindowManager.Core
1409e41f4b71Sopenharmony_ci
1410e41f4b71Sopenharmony_ci| Name              | Value  | Description                            |
1411e41f4b71Sopenharmony_ci| ------------------ | ---- | -------------------------------- |
1412e41f4b71Sopenharmony_ci| SCREEN_MAIN         | 0    | The primary screen is displayed (default).|
1413e41f4b71Sopenharmony_ci| SCREEN_MIRROR       | 1    | The mirror is displayed.        |
1414e41f4b71Sopenharmony_ci| SCREEN_EXTEND       | 2    | The extended screen is displayed.        |
1415e41f4b71Sopenharmony_ci| SCREEN_ALONE        | 3    | The source is unspecified.    |
1416e41f4b71Sopenharmony_ci
1417e41f4b71Sopenharmony_ci## ScreenModeInfo
1418e41f4b71Sopenharmony_ci
1419e41f4b71Sopenharmony_ciDefines the screen mode information.
1420e41f4b71Sopenharmony_ci
1421e41f4b71Sopenharmony_ci**System capability**: SystemCapability.WindowManager.WindowManager.Core
1422e41f4b71Sopenharmony_ci
1423e41f4b71Sopenharmony_ci| Name       | Type| Readable| Writable| Description                                              |
1424e41f4b71Sopenharmony_ci| ----------- | -------- | ---- | ---- | -------------------------------------------------- |
1425e41f4b71Sopenharmony_ci| id          | number   | Yes  | Yes  | Mode ID. The supported mode is determined by the device resolution and refresh rate. The value must be an integer.| 
1426e41f4b71Sopenharmony_ci| width       | number   | Yes  | Yes  | Width of the screen, in px. The value must be an integer.                               |
1427e41f4b71Sopenharmony_ci| height      | number   | Yes  | Yes  | Height of the screen, in px. The value must be an integer.                               |
1428e41f4b71Sopenharmony_ci| refreshRate | number   | Yes  | Yes  | Refresh rate of the screen, in hz. The value must be an integer.                                    |
1429