1# @system.device (设备信息)
2
3本模块提供当前设备的信息。
4
5> **说明:**
6>
7> - 从API Version 6开始,该接口不再维护,推荐使用新接口[`@ohos.deviceInfo`](js-apis-device-info.md)进行设备信息查询。
8>
9> - 本模块首批接口从API version 3开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
10
11## 导入模块
12
13```typescript
14import device from '@system.device';
15```
16
17## device.getInfo<sup>(deprecated)</sup>
18
19getInfo(options?: GetDeviceOptions): void
20
21获取当前设备的信息。
22
23> **说明:**<br>
24> 在首页的onShow生命周期之前不建议调用device.getInfo接口。
25
26**系统能力:** SystemCapability.Startup.SystemInfo.Lite
27
28**参数:**
29
30| 参数名 | 类型 | 必填 | 说明 |
31| -------- | -------- | -------- | -------- |
32| options | [GetDeviceOptions](#getdeviceoptionsdeprecated) | 否 | 定义设备信息获取的参数选项。 |
33
34## GetDeviceOptions<sup>(deprecated)</sup>
35
36定义设备信息获取的参数选项。
37
38**系统能力:** SystemCapability.Startup.SystemInfo.Lite
39
40| 名称 | 类型 | 必填 | 说明 |
41| -------- | -------- | -------- | -------- |
42| success | (data:DeviceResponse)=> void | 否 | 接口调用成功的回调函数。 data为成功返回的设备信息,具体参考[DeviceResponse](#deviceresponsedeprecated)。|
43| fail | (data:any,code:number)=> void | 否 | 接口调用失败的回调函数。 code为失败返回的错误码。<br>code:200,表示返回结果中存在无法获得的信息。|
44| complete | ()=> void | 否 | 接口调用结束的回调函数。 |
45
46## DeviceResponse<sup>(deprecated)</sup>
47
48设备信息。
49
50**系统能力:** SystemCapability.Startup.SystemInfo.Lite
51
52| 名称 | 类型 | 说明 |
53| -------- | -------- | -------- |
54| brand | string | 品牌。 |
55| manufacturer | string | 生产商。 |
56| model | string | 型号。 |
57| product | string | 代号。 |
58| language<sup>4+</sup> | string | 系统语言。 |
59| region<sup>4+</sup> | string | 系统地区。 |
60| windowWidth | number | 可使用的窗口宽度。 |
61| windowHeight | number | 可使用的窗口高度。 |
62| screenDensity<sup>4+</sup> | number | 屏幕密度。 |
63| screenShape<sup>4+</sup> | string | 屏幕形状。可取值:<br/>-&nbsp;rect:方形屏;<br/>-&nbsp;circle:圆形屏。 |
64| apiVersion<sup>4+</sup> | number | 系统API版本号。 |
65| deviceType<sup>4+</sup> | string | 设备类型。 |
66
67
68**示例:**
69
70```typescript
71export default {
72  getInfo() {
73    device.getInfo({
74      success: function(data) {
75        console.log('Device information obtained successfully. Device brand:' + data.brand);
76      },
77      fail: function(data, code) {
78        console.log('Failed to obtain device information. Error code:'+ code + '; Error information: ' + data);
79      },
80    });
81  },
82}
83```