1/* 2 * Copyright (c) 2025-2025 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 */ 15declare namespace display { 16 17export class BusinessError extends Error { 18 public code: number; 19 public message: string; 20} 21 22export interface Rect { 23 left: number; 24 25 top: number; 26 27 width: number; 28 29 height: number; 30} 31 32export interface WaterfallDisplayAreaRects { 33 readonly left: Rect; 34 35 readonly right: Rect; 36 37 readonly top: Rect; 38 39 readonly bottom: Rect; 40} 41 42export interface CutoutInfo { 43 readonly boundingRects: Array<Rect>; 44 45 readonly waterfallDisplayAreaRects: WaterfallDisplayAreaRects; 46} 47 48export interface FoldCreaseRegion { 49 readonly displayId: number; 50 51 readonly creaseRects: Array<Rect>; 52} 53 54export enum FoldDisplayMode { 55 56 FOLD_DISPLAY_MODE_UNKNOWN = 0, 57 58 FOLD_DISPLAY_MODE_FULL, 59 60 FOLD_DISPLAY_MODE_MAIN, 61 62 FOLD_DISPLAY_MODE_SUB, 63 64 FOLD_DISPLAY_MODE_COORDINATION 65} 66 67export enum Orientation { 68 69 PORTRAIT = 0, 70 71 LANDSCAPE = 1, 72 73 PORTRAIT_INVERTED = 2, 74 75 LANDSCAPE_INVERTED = 3 76 } 77 78export enum FoldStatus { 79 80 FOLD_STATUS_UNKNOWN = 0, 81 82 FOLD_STATUS_EXPANDED, 83 84 FOLD_STATUS_FOLDED, 85 86 FOLD_STATUS_HALF_FOLDED 87} 88 89export enum DisplayState { 90 91 STATE_UNKNOWN = 0, 92 93 STATE_OFF, 94 95 STATE_ON, 96 97 STATE_DOZE, 98 99 STATE_DOZE_SUSPEND, 100 101 STATE_VR, 102 103 STATE_ON_SUSPEND 104} 105 106export enum ColorSpace { 107 108 UNKNOWN = 0, 109 110 ADOBE_RGB_1998 = 1, 111 112 DCI_P3 = 2, 113 114 DISPLAY_P3 = 3, 115 116 SRGB = 4, 117 118 BT709 = 6, 119 120 BT601_EBU = 7, 121 122 BT601_SMPTE_C = 8, 123 124 BT2020_HLG = 9, 125 126 BT2020_PQ = 10, 127 128 P3_HLG = 11, 129 130 P3_PQ = 12, 131 132 ADOBE_RGB_1998_LIMIT = 13, 133 134 DISPLAY_P3_LIMIT = 14, 135 136 SRGB_LIMIT = 15, 137 138 BT709_LIMIT = 16, 139 140 BT601_EBU_LIMIT = 17, 141 142 BT601_SMPTE_C_LIMIT = 18, 143 144 BT2020_HLG_LIMIT = 19, 145 146 BT2020_PQ_LIMIT = 20, 147 148 P3_HLG_LIMIT = 21, 149 150 P3_PQ_LIMIT = 22, 151 152 LINEAR_P3 = 23, 153 154 LINEAR_SRGB = 24, 155 156 LINEAR_BT709 = 24, 157 158 LINEAR_BT2020 = 25, 159 160 DISPLAY_SRGB = 4, 161 162 DISPLAY_P3_SRGB = 3, 163 164 DISPLAY_P3_HLG = 11, 165 166 DISPLAY_P3_PQ = 12, 167 168 CUSTOM = 5, 169} 170 171export enum HDRFormat { 172 NONE = 0, 173 174 VIDEO_HLG = 1, 175 176 VIDEO_HDR10 = 2, 177 178 VIDEO_HDR_VIVID = 3, 179 180 IMAGE_HDR_VIVID_DUAL = 4, 181 182 IMAGE_HDR_VIVID_SINGLE = 5, 183 184 IMAGE_HDR_ISO_DUAL = 6, 185 186 IMAGE_HDR_ISO_SINGLE = 7, 187} 188 189export interface Display { 190 id: number; 191 192 name: string; 193 194 alive: boolean; 195 196 state: DisplayState; 197 198 refreshRate: number; 199 200 rotation: number; 201 202 width: number; 203 204 height: number; 205 206 availableHeight: number; 207 208 availableWidth: number; 209 210 densityDPI: number; 211 212 orientation: Orientation; 213 214 densityPixels: number; 215 216 scaledDensity: number; 217 218 xDPI: number; 219 220 yDPI: number; 221 222 colorSpaces: Array<ColorSpace>; 223 224 hdrFormats: Array<HDRFormat>; 225 226 getCutoutInfo(callback: AsyncCallback<CutoutInfo>): void; 227 228 getCutoutInfo(): Promise<CutoutInfo>; 229} 230 231export type Callback<T> = (data: T) => void; 232 233export type AsyncCallback<T> = (err: BusinessError, data: T) => void; 234 235export function isFoldable(): boolean; 236 237export function getFoldDisplayMode(): FoldDisplayMode; 238 239export function getFoldStatus(): FoldStatus; 240 241export function getCurrentFoldCreaseRegion(): FoldCreaseRegion; 242 243export function getDisplayByIdSync(displayId: int): Display; 244 245export function getDefaultDisplaySync(): Display; 246 247export function getAllDisplaysSyncNative(): Array<Display>; 248 249export function getAllDisplays(callback: AsyncCallback<Array<Display>>): void; 250 251export function getAllDisplays(): Promise<Array<Display>> 252 253export function on(type: 'add' | 'remove' | 'change', callback: Callback<number>): void; 254 255export function off(type: 'foldDisplayModeChange' | 'foldStatusChange', callback?: Callback<int>): void; 256 257} 258 259export default display;