From c7b0034069b9375faf3e299b733fed578226e117 Mon Sep 17 00:00:00 2001 From: xpeng Date: Fri, 24 Jun 2022 14:32:13 +0800 Subject: [PATCH] Add interfaces to set orientation for window and set&get screen rotation lock status respectively Signed-off-by: xpeng Change-Id: I019bb870c507842fdf2612d6a73949869eb618f6 --- api/@ohos.screen.d.ts | 15 +++++++++++++++ api/@ohos.window.d.ts | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+) diff --git a/api/@ohos.screen.d.ts b/api/@ohos.screen.d.ts index 606ab803df..cb4b192512 100644 --- a/api/@ohos.screen.d.ts +++ b/api/@ohos.screen.d.ts @@ -83,6 +83,21 @@ declare namespace screen { function setVirtualScreenSurface(screenId:number, surfaceId: string, callback: AsyncCallback): void; function setVirtualScreenSurface(screenId:number, surfaceId: string): Promise; + /** + * Get screen rotation lock status. + * @since 9 + */ + function isScreenRotationLocked(callback: AsyncCallback): void; + function isScreenRotationLocked(): Promise; + + /** + * Set screen rotation lock status. + * @param isLocked Indicates whether the screen rotation switch is locked. + * @since 9 + */ + function setScreenRotationLocked(isLocked:boolean, callback: AsyncCallback): void; + function setScreenRotationLocked(isLocked:boolean): Promise; + /** * the parameter of making expand screen * @syscap SystemCapability.WindowManager.WindowManager.Core diff --git a/api/@ohos.window.d.ts b/api/@ohos.window.d.ts index 659499edb6..da97685ea6 100644 --- a/api/@ohos.window.d.ts +++ b/api/@ohos.window.d.ts @@ -567,6 +567,26 @@ declare namespace window { */ function off(type: 'systemBarTintChange', callback?: Callback): void; + /** + * display orientation + * @syscap SystemCapability.WindowManager.WindowManager.Core + * @since 9 + */ + enum Orientation { + UNSPECIFIED = 0, + PORTRAIT = 1, + LANDSCAPE = 2, + PORTRAIT_INVERTED = 3, + LANDSCAPE_INVERTED = 4, + AUTO_ROTATION = 5, + AUTO_ROTATION_PORTRAIT = 6, + AUTO_ROTATION_LANDSCAPE = 7, + AUTO_ROTATION_RESTRICTED = 8, + AUTO_ROTATION_PORTRAIT_RESTRICTED = 9, + AUTO_ROTATION_LANDSCAPE_RESTRICTED = 10, + LOCKED = 11, + } + interface Window { /** * hide window. @@ -752,6 +772,22 @@ declare namespace window { */ setSystemBarProperties(systemBarProperties: SystemBarProperties): Promise; + /** + * Set the requested orientation config of the window + * @param orientation the orientation config of the window + * @syscap SystemCapability.WindowManager.WindowManager.Core + * @since 9 + */ + setRequestedOrientation(orientation: Orientation): Promise; + + /** + * Set the requested orientation config of the window + * @param orientation the orientation config of the window + * @syscap SystemCapability.WindowManager.WindowManager.Core + * @since 9 + */ + setRequestedOrientation(orientation: Orientation, callback: AsyncCallback): void; + /** * Loads content * @param path path Path of the page to which the content will be loaded -- Gitee