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 * @syscap SystemCapability.Startup.SystemInfo 18 */ 19export interface DeviceResponse { 20 /** 21 * Brand. 22 * @syscap SystemCapability.Startup.SystemInfo 23 * @since 3 24 */ 25 brand: string; 26 27 /** 28 * Manufacturer. 29 * @syscap SystemCapability.Startup.SystemInfo 30 * @since 3 31 */ 32 manufacturer: string; 33 34 /** 35 * Model. 36 * @syscap SystemCapability.Startup.SystemInfo 37 * @since 3 38 */ 39 model: string; 40 41 /** 42 * Product number. 43 * @syscap SystemCapability.Startup.SystemInfo 44 * @since 3 45 */ 46 product: string; 47 48 /** 49 * System language. 50 * @syscap SystemCapability.Startup.SystemInfo 51 * @since 4 52 */ 53 language: string; 54 55 /** 56 * System region. 57 * @syscap SystemCapability.Startup.SystemInfo 58 * @since 4 59 */ 60 region: string; 61 62 /** 63 * Window width. 64 * @syscap SystemCapability.Startup.SystemInfo 65 * @since 3 66 */ 67 windowWidth: number; 68 69 /** 70 * Window Height. 71 * @syscap SystemCapability.Startup.SystemInfo 72 * @since 3 73 */ 74 windowHeight: number; 75 76 /** 77 * Screen density. 78 * @syscap SystemCapability.Startup.SystemInfo 79 * @since 4 80 */ 81 screenDensity: number; 82 83 /** 84 * Screen shape. The options are as follows: 85 * rect: Rectangle screen. 86 * circle: Circle screen. 87 * @syscap SystemCapability.Startup.SystemInfo 88 * @since 4 89 */ 90 screenShape: "rect" | "circle"; 91 92 /** 93 * API version. 94 * @syscap SystemCapability.Startup.SystemInfo 95 * @since 4 96 */ 97 apiVersion: number; 98 99 /** 100 * Device type. The options are as follows: 101 * phone: smartphone 102 * tablet: tablet 103 * tv: smart TV 104 * wearable: wearable 105 * liteWearable: lite wearable 106 * ar: AR 107 * vr: virtual reality 108 * earphones: headset 109 * pc: personal computer 110 * speaker: speaker 111 * smartVision: smart visual device 112 * linkIoT: connection module 113 * @syscap SystemCapability.Startup.SystemInfo 114 * @since 4 115 */ 116 deviceType: string; 117} 118 119export interface GetDeviceOptions { 120 /** 121 * Called when the device information is obtained. 122 * @syscap SystemCapability.Startup.SystemInfo 123 * @since 3 124 */ 125 success?: (data: DeviceResponse) => void; 126 127 /** 128 * Called when the device information fails to be obtained. 129 * @syscap SystemCapability.Startup.SystemInfo 130 * @since 3 131 */ 132 fail?: (data: any, code: number) => void; 133 134 /** 135 * Called when the execution is completed. 136 * @syscap SystemCapability.Startup.SystemInfo 137 * @since 3 138 */ 139 complete?: () => void; 140} 141 142/** 143 * getInfo interface 144 */ 145export default class Device { 146 /** 147 * Obtains the device information. 148 * @syscap SystemCapability.Startup.SystemInfo 149 * @param options Options. 150 * @deprecated since 6 151 */ 152 static getInfo(options?: GetDeviceOptions): void; 153} 154