• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Device Information
2
3> **NOTE**
4> - The APIs of this module are no longer maintained since API version 6. It is recommended that you use [`@ohos.deviceInfo`](js-apis-device-info.md) instead.
5>
6> - The initial APIs of this module are supported since API version 3. Newly added APIs will be marked with a superscript to indicate their earliest API version.
7
8
9## Modules to Import
10
11
12```
13import device from '@system.device';
14```
15
16
17## device.getInfo
18
19getInfo(Object): void
20
21Obtains the device information.
22
23> ![icon-note.gif](public_sys-resources/icon-note.gif) **Note:**
24> Do not call **device.getInfo** before the **onShow** event of the home page.
25
26**System capability**: SystemCapability.Startup.SysInfo
27
28**Parameters**
29
30| Name | Type | Mandatory | Description |
31| -------- | -------- | -------- | -------- |
32| success | Function | No | Called when the device information is obtained |
33| fail | Function | No | Called when the device information fails to be obtained |
34| complete | Function | No | Called when the execution is complete |
35
36The following values will be returned when the device information is obtained.
37
38| Name | Type | Description |
39| -------- | -------- | -------- |
40| brand | string | Brand |
41| manufacturer | string | Manufacturer |
42| model | string | Model |
43| product | string | Product number |
44| language<sup>4+</sup> | string | System&nbsp;language |
45| region<sup>4+</sup> | string | System&nbsp;region |
46| windowWidth | number | Window&nbsp;width |
47| windowHeight | number | Window&nbsp;height |
48| screenDensity<sup>4+</sup> | number | Screen&nbsp;density |
49| screenShape<sup>4+</sup> | string | Screen&nbsp;shape.&nbsp;The&nbsp;options&nbsp;are&nbsp;as&nbsp;follows:<br/>-&nbsp;rect:&nbsp;rectangle&nbsp;screen<br/>-&nbsp;circle:&nbsp;circle&nbsp;screen |
50| apiVersion<sup>4+</sup> | number | API&nbsp;version |
51| releaseType<sup>4+</sup> | string | Release&nbsp;type.&nbsp;The&nbsp;value&nbsp;includes&nbsp;both&nbsp;the&nbsp;release&nbsp;type&nbsp;and&nbsp;the&nbsp;API&nbsp;version,&nbsp;for&nbsp;example,&nbsp;Beta1.<br/>Available&nbsp;release&nbsp;types&nbsp;are&nbsp;as&nbsp;follows:<br/>-&nbsp;**Canary**:&nbsp;For&nbsp;the&nbsp;same&nbsp;API&nbsp;version,&nbsp;different&nbsp;canary&nbsp;releases&nbsp;are&nbsp;compatible&nbsp;with&nbsp;each&nbsp;other,&nbsp;but&nbsp;not&nbsp;compatible&nbsp;with&nbsp;those&nbsp;of&nbsp;the&nbsp;**beta**&nbsp;and&nbsp;**release**&nbsp;type.<br/>-&nbsp;**Beta**:&nbsp;For&nbsp;the&nbsp;same&nbsp;API&nbsp;version,&nbsp;different&nbsp;beta&nbsp;releases&nbsp;are&nbsp;compatible&nbsp;with&nbsp;each&nbsp;other,&nbsp;but&nbsp;not&nbsp;compatible&nbsp;with&nbsp;those&nbsp;of&nbsp;the&nbsp;**release**&nbsp;type.<br/>-&nbsp;**Release**:&nbsp;Releases&nbsp;of&nbsp;this&nbsp;type&nbsp;are&nbsp;compatible&nbsp;with&nbsp;the&nbsp;latest&nbsp;five&nbsp;API&nbsp;versions. |
52| deviceType<sup>4+</sup> | string | Device type |
53
54The following error code will be returned if the device information fails to be obtained.
55
56| Error&nbsp;Code | Description |
57| -------- | -------- |
58| 200 | The&nbsp;returned&nbsp;result&nbsp;contains&nbsp;information&nbsp;that&nbsp;cannot&nbsp;be&nbsp;obtained. |
59
60**Example**
61
62```
63export default {
64  getInfo() {
65    device.getInfo({
66      success: function(data) {
67        console.log('Device information obtained successfully. Device brand:' + data.brand);
68      },
69      fail: function(data, code) {
70        console.log('Failed to obtain device information. Error code:'+ code + '; Error information: ' + data);
71      },
72    });
73  },
74}
75```