• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2020 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 *     http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16/**
17 * @file
18 * @kit BasicServicesKit
19 */
20
21/**
22 * @interface DeviceResponse
23 * @syscap SystemCapability.Startup.SystemInfo.Lite
24 * @since 3
25 */
26export interface DeviceResponse {
27  /**
28   * Brand.
29   *
30   * @type { string }
31   * @syscap SystemCapability.Startup.SystemInfo.Lite
32   * @since 3
33   */
34  brand: string;
35
36  /**
37   * Manufacturer.
38   *
39   * @type { string }
40   * @syscap SystemCapability.Startup.SystemInfo.Lite
41   * @since 3
42   */
43  manufacturer: string;
44
45  /**
46   * Model.
47   *
48   * @type { string }
49   * @syscap SystemCapability.Startup.SystemInfo.Lite
50   * @since 3
51   */
52  model: string;
53
54  /**
55   * Product number.
56   *
57   * @type { string }
58   * @syscap SystemCapability.Startup.SystemInfo.Lite
59   * @since 3
60   */
61  product: string;
62
63  /**
64   * System language.
65   *
66   * @type { string }
67   * @syscap SystemCapability.Startup.SystemInfo.Lite
68   * @since 4
69   */
70  language: string;
71
72  /**
73   * System region.
74   *
75   * @type { string }
76   * @syscap SystemCapability.Startup.SystemInfo.Lite
77   * @since 4
78   */
79  region: string;
80
81  /**
82   * Window width.
83   *
84   * @type { number }
85   * @syscap SystemCapability.Startup.SystemInfo.Lite
86   * @since 3
87   */
88  windowWidth: number;
89
90  /**
91   * Window Height.
92   *
93   * @type { number }
94   * @syscap SystemCapability.Startup.SystemInfo.Lite
95   * @since 3
96   */
97  windowHeight: number;
98
99  /**
100   * Screen density.
101   *
102   * @type { number }
103   * @syscap SystemCapability.Startup.SystemInfo.Lite
104   * @since 4
105   */
106  screenDensity: number;
107
108  /**
109   * Screen shape. The options are as follows:
110   * rect: Rectangle screen.
111   * circle: Circle screen.
112   *
113   * @type { 'rect' | 'circle' }
114   * @syscap SystemCapability.Startup.SystemInfo.Lite
115   * @since 4
116   */
117  screenShape: 'rect' | 'circle';
118
119  /**
120   * API version.
121   *
122   * @type { number }
123   * @syscap SystemCapability.Startup.SystemInfo.Lite
124   * @since 4
125   */
126  apiVersion: number;
127
128  /**
129   * Device type. The options are as follows:
130   * phone: smartphone
131   * tablet: tablet
132   * tv: smart TV
133   * wearable: wearable
134   * liteWearable: lite wearable
135   * ar: AR
136   * vr: virtual reality
137   * earphones: headset
138   * pc: personal computer
139   * speaker: speaker
140   * smartVision: smart visual device
141   * linkIoT: connection module
142   *
143   * @type { string }
144   * @syscap SystemCapability.Startup.SystemInfo.Lite
145   * @since 4
146   */
147  deviceType: string;
148}
149
150export interface GetDeviceOptions {
151  /**
152   * Called when the device information is obtained.
153   *
154   * @syscap SystemCapability.Startup.SystemInfo.Lite
155   * @since 3
156   */
157  success?: (data: DeviceResponse) => void;
158
159  /**
160   * Called when the device information fails to be obtained.
161   *
162   * @syscap SystemCapability.Startup.SystemInfo.Lite
163   * @since 3
164   */
165  fail?: (data: any, code: number) => void;
166
167  /**
168   * Called when the execution is completed.
169   *
170   * @syscap SystemCapability.Startup.SystemInfo.Lite
171   * @since 3
172   */
173  complete?: () => void;
174}
175
176/**
177 * getInfo interface
178 *
179 * @syscap SystemCapability.Startup.SystemInfo.Lite
180 * @since 3
181 */
182export default class Device {
183  /**
184   * Obtains the device information.
185   *
186   * @param { GetDeviceOptions } options - Options
187   * @syscap SystemCapability.Startup.SystemInfo.Lite
188   * @since 3
189   * @deprecated since 6
190   */
191  static getInfo(options?: GetDeviceOptions): void;
192}
193