diff --git a/api/@ohos.screen.d.ts b/api/@ohos.screen.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..51a5ae905ad3c60c0902abb181e65cadaeaf43bb --- /dev/null +++ b/api/@ohos.screen.d.ts @@ -0,0 +1,150 @@ +/* +* Copyright (c) 2022 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 screen manager + * @devices tv, phone, tablet, wearable + * @systemapi Hide this for inner system use. + * @since 9 + */ +declare namespace screen { + /** + * get all screen + * @devices tv, phone, tablet, wearable + * @since 9 + */ + function getAllScreen(): Promise>; + + // Screen plug-in event; Screen resolution ratio and other parameters, combination relationship changes + function on(eventType: 'connect' | 'disconnect' | 'change', callback: Callback): void; + function off(eventType: 'connect' | 'disconnect' | 'change', callback?: Callback): void; + + /** + * make screens as expand-screen + * @devices tv, phone, tablet, wearable + * @since 9 + */ + function makeExpand(options:Array): Promise; + + /** + * make screens as mirror-screen + * @devices tv, phone, tablet, wearable + * @since 9 + */ + function makeMirror(mainScreen:number, mirrorScreen:Array): Promise; + + /** + * the parameter of making expand screen + * @devices tv, phone, tablet, wearable + * @since 9 + */ + interface ExpandOption { + /** + * screen id + */ + screenId: number; + + /** + * the start coordinate X of the screen origin + */ + startX: number; + + /** + * the start coordinate Y of the screen origin + */ + startY: number; + } + + /** + * interface for screen + * @devices tv, phone, tablet, wearable + * @since 9 + */ + interface Screen { + /** + * get screen id + * @devices tv, phone, tablet, wearable + * @since 9 + */ + readonly id: number; + + // return group id + readonly parent: number; + + readonly supportedModeInfo: Array; + + readonly activeModeIndex: number; + + readonly orientation: Orientation; + + /** + * set the orientation of the screen + * @devices tv, phone, tablet, wearable + * @since 9 + */ + setOrientation(orientation: Orientation): Promise; + + setScreenActiveMode(modeIndex: number): Promise; + } + + /** + * interface for screen group + * @devices tv, phone, tablet, wearable + * @since 9 + */ + interface ScreenGroup { + /** + * get screen group id + * @devices tv, phone, tablet, wearable + * @since 9 + */ + id: number; + + combinationInfo: ExpandInfo | MirrorInfo; + } + + interface ExpandInfo { + screenId: Array; + startX: Array; + startY: Array; + } + + interface MirrorInfo { + mainScreenId: number; + mirrorScreenId: Array; + } + + enum Orientation { + UNSPECIFIED = 0, + VERTICAL = 1, + HORIZONTAL = 2, + REVERSE_VERTICAL = 3, + REVERSE_HORIZONTAL = 4, + SENSOR = 5, + SENSOR_VERTICAL = 6, + SENSOR_HORIZONTAL = 7, + } + + interface ScreenModeInfo { + id: number; + width: number; + height: number; + refreshRate: number; + } +} + +export default screen;