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