From 022acfa803e7f1fba6b4e306b1bc6ff0994f73da Mon Sep 17 00:00:00 2001 From: youqijing Date: Thu, 17 Feb 2022 17:03:47 +0800 Subject: [PATCH] Add dispaly interface Signed-off-by: youqijing Change-Id: I88e24ca8f96ef7f12c653a332b1b001d0a29e450 --- api/@ohos.display.d.ts | 171 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 171 insertions(+) create mode 100644 api/@ohos.display.d.ts diff --git a/api/@ohos.display.d.ts b/api/@ohos.display.d.ts new file mode 100644 index 0000000000..024a10daef --- /dev/null +++ b/api/@ohos.display.d.ts @@ -0,0 +1,171 @@ +/* +* Copyright (c) 2021 Huawei Device Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +import { AsyncCallback, Callback } from './basic'; + +/** + * interface of display manager + * @syscap SystemCapability.WindowManager.WindowManager.Core + * @since 7 + */ +declare namespace display { + /** + * get the default display + * @since 7 + */ + function getDefaultDisplay(callback: AsyncCallback): void; + + /** + * get the default display + * @since 7 + */ + function getDefaultDisplay(): Promise; + + /** + * get all displays + * @since 7 + */ + function getAllDisplay(callback: AsyncCallback>): void; + + /** + * get all displays + * @since 7 + */ + function getAllDisplay(): Promise>; + + /** + * register the callback of display change + * @param type: type of callback + * @since 7 + */ + function on(type: 'add' | 'remove' | 'change', callback: Callback): void; + + /** + * unregister the callback of display change + * @param type: type of callback + * @since 7 + */ + function off(type: 'add' | 'remove' | 'change', callback?: Callback): void; + + /** + * the state of display + * @syscap SystemCapability.WindowManager.WindowManager.Core + * @since 7 + */ + enum DisplayState { + /** + * unknown + */ + STATE_UNKNOWN = 0, + /** + * screen off + */ + STATE_OFF, + /** + * screen on + */ + STATE_ON, + /** + * doze, but it will update for some important system messages + */ + STATE_DOZE, + /** + * doze and not update + */ + STATE_DOZE_SUSPEND, + /** + * VR node + */ + STATE_VR, + /** + * screen on and not update + */ + STATE_ON_SUSPEND, + } + + /** + * Properties of display, it couldn't update automatically + * @syscap SystemCapability.WindowManager.WindowManager.Core + * @since 7 + */ + interface Display { + /** + * display id + */ + id: number; + + /** + * display name + */ + name: string; + + /** + * the display is alive + */ + alive: boolean; + + /** + * the state of display + */ + state: DisplayState; + + /** + * refresh rate, unit: Hz + */ + refreshRate: number; + + /** + * the rotation degrees of the display + */ + rotation: number; + + /** + * the width of display, unit: pixel + */ + width: number; + + /** + * the height of display, unit: pixel + */ + height: number; + + /** + * indicates the display resolution. + */ + densityDPI: number; + + /** + * indicates the display density in pixels. The value of a low-resolution display is 1.0 + */ + densityPixels: number; + + /** + * indicates the text scale density of a display. + */ + scaledDensity: number; + + /** + * the DPI on X-axis. + */ + xDPI: number; + + /** + * the DPI on Y-axis. + */ + yDPI: number; + } +} + +export default display; \ No newline at end of file -- Gitee