Add interfaces to set orientation for window and set&get screen rotation lock status respectively

Signed-off-by: xpeng <pengxin33@huawei.com>
Change-Id: I019bb870c507842fdf2612d6a73949869eb618f6
This commit is contained in:
xpeng 2022-06-24 14:32:13 +08:00
parent 88fae6d472
commit c7b0034069
2 changed files with 51 additions and 0 deletions

15
api/@ohos.screen.d.ts vendored
View File

@ -83,6 +83,21 @@ declare namespace screen {
function setVirtualScreenSurface(screenId:number, surfaceId: string, callback: AsyncCallback<void>): void;
function setVirtualScreenSurface(screenId:number, surfaceId: string): Promise<void>;
/**
* Get screen rotation lock status.
* @since 9
*/
function isScreenRotationLocked(callback: AsyncCallback<boolean>): void;
function isScreenRotationLocked(): Promise<boolean>;
/**
* Set screen rotation lock status.
* @param isLocked Indicates whether the screen rotation switch is locked.
* @since 9
*/
function setScreenRotationLocked(isLocked:boolean, callback: AsyncCallback<void>): void;
function setScreenRotationLocked(isLocked:boolean): Promise<void>;
/**
* the parameter of making expand screen
* @syscap SystemCapability.WindowManager.WindowManager.Core

36
api/@ohos.window.d.ts vendored
View File

@ -567,6 +567,26 @@ declare namespace window {
*/
function off(type: 'systemBarTintChange', callback?: Callback<SystemBarTintState>): 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<void>;
/**
* 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<void>;
/**
* 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>): void;
/**
* Loads content
* @param path path Path of the page to which the content will be loaded