mirror of
https://gitee.com/openharmony/interface_sdk-js
synced 2024-12-14 11:09:00 +00:00
Add UIExtension and UIExtensionContext interface.
Signed-off-by: dy_study <dingyao5@huawei.com> Change-Id: I98e0c8b4149cf6dd9512e710bdc31e7eacdd3d9c
This commit is contained in:
parent
1a2011c5c8
commit
6d393829d5
78
api/@ohos.app.ability.UIExtensionAbility.d.ts
vendored
Executable file
78
api/@ohos.app.ability.UIExtensionAbility.d.ts
vendored
Executable file
@ -0,0 +1,78 @@
|
||||
/*
|
||||
* Copyright (c) 2023 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 ExtensionAbility from './@ohos.app.ability.ExtensionAbility';
|
||||
import { LocalStorage } from 'StateManagement';
|
||||
import Want from './@ohos.app.ability.Want';
|
||||
|
||||
/**
|
||||
* The class of UI extension ability.
|
||||
*
|
||||
* @extends ExtensionAbility
|
||||
* @syscap SystemCapability.Ability.AbilityRuntime.Core
|
||||
* @StageModelOnly
|
||||
* @since 10
|
||||
*/
|
||||
export default class UIExtensionAbility extends ExtensionAbility {
|
||||
/**
|
||||
* Called back when an UI extension is started for initialization.
|
||||
*
|
||||
* @param { Want } want - Indicates the want info of the created UI extension.
|
||||
* @syscap SystemCapability.Ability.AbilityRuntime.Core
|
||||
* @StageModelOnly
|
||||
* @since 10
|
||||
*/
|
||||
onCreate(want: Want): void;
|
||||
|
||||
/**
|
||||
* Called back when an UI extension need load content.
|
||||
*
|
||||
* @param { string } path - Path of the page to which the content will be loaded
|
||||
* @param { LocalStorage } storage - The data object shared within the content instance loaded by the window
|
||||
* @syscap SystemCapability.Ability.AbilityRuntime.Core
|
||||
* @StageModelOnly
|
||||
* @since 10
|
||||
*/
|
||||
onLoadContent(path: string, storage: LocalStorage): void;
|
||||
|
||||
/**
|
||||
* Called back when the state of an UI extension changes to foreground.
|
||||
*
|
||||
* @param { Want } want - Indicates the want info of the UI extension.
|
||||
* @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore
|
||||
* @StageModelOnly
|
||||
* @since 10
|
||||
*/
|
||||
onForeground(want: Want): void;
|
||||
|
||||
/**
|
||||
* Called back when the state of an UI extension changes to background.
|
||||
*
|
||||
* @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore
|
||||
* @StageModelOnly
|
||||
* @since 10
|
||||
*/
|
||||
onBackground(): void;
|
||||
|
||||
/**
|
||||
* Called back before an UI extension is destroyed.
|
||||
*
|
||||
* @returns { void | Promise<void> } the promise returned by the function.
|
||||
* @syscap SystemCapability.Ability.AbilityRuntime.Core
|
||||
* @StageModelOnly
|
||||
* @since 10
|
||||
*/
|
||||
onDestroy(): void | Promise<void>;
|
||||
}
|
292
api/application/UIExtensionContext.d.ts
vendored
Executable file
292
api/application/UIExtensionContext.d.ts
vendored
Executable file
@ -0,0 +1,292 @@
|
||||
/*
|
||||
* Copyright (c) 2023 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 { AbilityResult } from '../ability/abilityResult';
|
||||
import { AsyncCallback } from '../@ohos.base';
|
||||
import ExtensionContext from './ExtensionContext';
|
||||
import { LocalStorage } from 'StateManagement';
|
||||
import Want from '../@ohos.app.ability.Want';
|
||||
import StartOptions from '../@ohos.app.ability.StartOptions';
|
||||
|
||||
/**
|
||||
* The context of UI extension. It allows access to UIExtension-specific resources.
|
||||
*
|
||||
* @extends ExtensionContext
|
||||
* @syscap SystemCapability.Ability.AbilityRuntime.Core
|
||||
* @StageModelOnly
|
||||
* @since 10
|
||||
*/
|
||||
export default class UIExtensionContext extends ExtensionContext {
|
||||
/**
|
||||
* UI extension uses this method to start a specific ability.If the caller application is in foreground,
|
||||
* you can use this method to start ability; If the caller application is in the background,
|
||||
* you need to apply for permission:ohos.permission.START_ABILITIES_FROM_BACKGROUND.
|
||||
* If the target ability is visible, you can start the target ability; If the target ability is invisible,
|
||||
* you need to apply for permission:ohos.permission.START_INVISIBLE_ABILITY to start target invisible ability.
|
||||
* If the target ability is in cross-device, you need to apply for permission:ohos.permission.DISTRIBUTED_DATASYNC.
|
||||
*
|
||||
* @param { Want } want - Indicates the ability to start.
|
||||
* @param { AsyncCallback<void> } callback - The callback of startAbility.
|
||||
* @throws { BusinessError } 201 - The application does not have permission to call the interface.
|
||||
* @throws { BusinessError } 401 - If the input parameter is not valid parameter.
|
||||
* @throws { BusinessError } 16000001 - The specified ability does not exist.
|
||||
* @throws { BusinessError } 16000002 - Incorrect ability type.
|
||||
* @throws { BusinessError } 16000004 - Can not start invisible component.
|
||||
* @throws { BusinessError } 16000005 - The specified process does not have the permission.
|
||||
* @throws { BusinessError } 16000006 - Cross-user operations are not allowed.
|
||||
* @throws { BusinessError } 16000008 - The crowdtesting application expires.
|
||||
* @throws { BusinessError } 16000009 - An ability cannot be started or stopped in Wukong mode.
|
||||
* @throws { BusinessError } 16000010 - The call with the continuation flag is forbidden.
|
||||
* @throws { BusinessError } 16000011 - The context does not exist.
|
||||
* @throws { BusinessError } 16000012 - The application is controlled.
|
||||
* @throws { BusinessError } 16000013 - The application is controlled by EDM.
|
||||
* @throws { BusinessError } 16000050 - Internal error.
|
||||
* @throws { BusinessError } 16000053 - The ability is not on the top of the UI.
|
||||
* @throws { BusinessError } 16000055 - Installation-free timed out.
|
||||
* @throws { BusinessError } 16200001 - The caller has been released.
|
||||
* @syscap SystemCapability.Ability.AbilityRuntime.Core
|
||||
* @StageModelOnly
|
||||
* @since 10
|
||||
*/
|
||||
startAbility(want: Want, callback: AsyncCallback<void>): void;
|
||||
|
||||
/**
|
||||
* UI extension uses this method to start a specific ability.If the caller application is in foreground,
|
||||
* you can use this method to start ability; If the caller application is in the background,
|
||||
* you need to apply for permission:ohos.permission.START_ABILITIES_FROM_BACKGROUND.
|
||||
* If the target ability is visible, you can start the target ability; If the target ability is invisible,
|
||||
* you need to apply for permission:ohos.permission.START_INVISIBLE_ABILITY to start target invisible ability.
|
||||
* If the target ability is in cross-device, you need to apply for permission:ohos.permission.DISTRIBUTED_DATASYNC.
|
||||
*
|
||||
* @param { Want } want - Indicates the ability to start.
|
||||
* @param { StartOptions } options - Indicates the start options.
|
||||
* @param { AsyncCallback<void> } callback - The callback of startAbility.
|
||||
* @throws { BusinessError } 201 - The application does not have permission to call the interface.
|
||||
* @throws { BusinessError } 401 - If the input parameter is not valid parameter.
|
||||
* @throws { BusinessError } 16000001 - The specified ability does not exist.
|
||||
* @throws { BusinessError } 16000004 - Can not start invisible component.
|
||||
* @throws { BusinessError } 16000005 - The specified process does not have the permission.
|
||||
* @throws { BusinessError } 16000006 - Cross-user operations are not allowed.
|
||||
* @throws { BusinessError } 16000008 - The crowdtesting application expires.
|
||||
* @throws { BusinessError } 16000009 - An ability cannot be started or stopped in Wukong mode.
|
||||
* @throws { BusinessError } 16000011 - The context does not exist.
|
||||
* @throws { BusinessError } 16000012 - The application is controlled.
|
||||
* @throws { BusinessError } 16000013 - The application is controlled by EDM.
|
||||
* @throws { BusinessError } 16000050 - Internal error.
|
||||
* @throws { BusinessError } 16000053 - The ability is not on the top of the UI.
|
||||
* @throws { BusinessError } 16000055 - Installation-free timed out.
|
||||
* @throws { BusinessError } 16200001 - The caller has been released.
|
||||
* @syscap SystemCapability.Ability.AbilityRuntime.Core
|
||||
* @StageModelOnly
|
||||
* @since 10
|
||||
*/
|
||||
startAbility(want: Want, options: StartOptions, callback: AsyncCallback<void>): void;
|
||||
|
||||
/**
|
||||
* UI extension uses this method to start a specific ability.If the caller application is in foreground,
|
||||
* you can use this method to start ability; If the caller application is in the background,
|
||||
* you need to apply for permission:ohos.permission.START_ABILITIES_FROM_BACKGROUND.
|
||||
* If the target ability is visible, you can start the target ability; If the target ability is invisible,
|
||||
* you need to apply for permission:ohos.permission.START_INVISIBLE_ABILITY to start target invisible ability.
|
||||
* If the target ability is in cross-device, you need to apply for permission:ohos.permission.DISTRIBUTED_DATASYNC.
|
||||
*
|
||||
* @param { Want } want - Indicates the ability to start.
|
||||
* @param { StartOptions } [options] - Indicates the start options.
|
||||
* @returns { Promise<void> } The promise returned by the function.
|
||||
* @throws { BusinessError } 201 - The application does not have permission to call the interface.
|
||||
* @throws { BusinessError } 401 - If the input parameter is not valid parameter.
|
||||
* @throws { BusinessError } 16000001 - The specified ability does not exist.
|
||||
* @throws { BusinessError } 16000002 - Incorrect ability type.
|
||||
* @throws { BusinessError } 16000004 - Can not start invisible component.
|
||||
* @throws { BusinessError } 16000005 - The specified process does not have the permission.
|
||||
* @throws { BusinessError } 16000006 - Cross-user operations are not allowed.
|
||||
* @throws { BusinessError } 16000008 - The crowdtesting application expires.
|
||||
* @throws { BusinessError } 16000009 - An ability cannot be started or stopped in Wukong mode.
|
||||
* @throws { BusinessError } 16000010 - The call with the continuation flag is forbidden.
|
||||
* @throws { BusinessError } 16000011 - The context does not exist.
|
||||
* @throws { BusinessError } 16000012 - The application is controlled.
|
||||
* @throws { BusinessError } 16000013 - The application is controlled by EDM.
|
||||
* @throws { BusinessError } 16000050 - Internal error.
|
||||
* @throws { BusinessError } 16000053 - The ability is not on the top of the UI.
|
||||
* @throws { BusinessError } 16000055 - Installation-free timed out.
|
||||
* @throws { BusinessError } 16200001 - The caller has been released.
|
||||
* @syscap SystemCapability.Ability.AbilityRuntime.Core
|
||||
* @StageModelOnly
|
||||
* @since 10
|
||||
*/
|
||||
startAbility(want: Want, options?: StartOptions): Promise<void>;
|
||||
|
||||
/**
|
||||
* Starts an ability and returns the execution result when the ability is destroyed.
|
||||
* If the caller application is in foreground, you can use this method to start ability; If the caller application
|
||||
* is in the background, you need to apply for permission:ohos.permission.START_ABILITIES_FROM_BACKGROUND.
|
||||
* If the target ability is visible, you can start the target ability; If the target ability is invisible,
|
||||
* you need to apply for permission:ohos.permission.START_INVISIBLE_ABILITY to start target invisible ability.
|
||||
* If the target ability is in cross-device, you need to apply for permission:ohos.permission.DISTRIBUTED_DATASYNC.
|
||||
*
|
||||
* @param { Want } want - Indicates the ability to start.
|
||||
* @param { AsyncCallback<AbilityResult> } callback - The callback is used to return the result of startAbility.
|
||||
* @throws { BusinessError } 201 - The application does not have permission to call the interface.
|
||||
* @throws { BusinessError } 401 - If the input parameter is not valid parameter.
|
||||
* @throws { BusinessError } 16000001 - The specified ability does not exist.
|
||||
* @throws { BusinessError } 16000002 - Incorrect ability type.
|
||||
* @throws { BusinessError } 16000004 - Can not start invisible component.
|
||||
* @throws { BusinessError } 16000005 - The specified process does not have the permission.
|
||||
* @throws { BusinessError } 16000006 - Cross-user operations are not allowed.
|
||||
* @throws { BusinessError } 16000008 - The crowdtesting application expires.
|
||||
* @throws { BusinessError } 16000009 - An ability cannot be started or stopped in Wukong mode.
|
||||
* @throws { BusinessError } 16000010 - The call with the continuation flag is forbidden.
|
||||
* @throws { BusinessError } 16000011 - The context does not exist.
|
||||
* @throws { BusinessError } 16000012 - The application is controlled.
|
||||
* @throws { BusinessError } 16000013 - The application is controlled by EDM.
|
||||
* @throws { BusinessError } 16000050 - Internal error.
|
||||
* @throws { BusinessError } 16000053 - The ability is not on the top of the UI.
|
||||
* @throws { BusinessError } 16000055 - Installation-free timed out.
|
||||
* @throws { BusinessError } 16200001 - The caller has been released.
|
||||
* @syscap SystemCapability.Ability.AbilityRuntime.Core
|
||||
* @StageModelOnly
|
||||
* @since 10
|
||||
*/
|
||||
startAbilityForResult(want: Want, callback: AsyncCallback<AbilityResult>): void;
|
||||
|
||||
/**
|
||||
* Starts an ability and returns the execution result when the ability is destroyed.
|
||||
* If the caller application is in foreground, you can use this method to start ability; If the caller application
|
||||
* is in the background, you need to apply for permission:ohos.permission.START_ABILITIES_FROM_BACKGROUND.
|
||||
* If the target ability is visible, you can start the target ability; If the target ability is invisible,
|
||||
* you need to apply for permission:ohos.permission.START_INVISIBLE_ABILITY to start target invisible ability.
|
||||
* If the target ability is in cross-device, you need to apply for permission:ohos.permission.DISTRIBUTED_DATASYNC.
|
||||
*
|
||||
* @param { Want } want - Indicates the ability to start.
|
||||
* @param { StartOptions } options - Indicates the start options.
|
||||
* @param { AsyncCallback<AbilityResult> } callback - The callback is used to return the result of startAbility.
|
||||
* @throws { BusinessError } 201 - The application does not have permission to call the interface.
|
||||
* @throws { BusinessError } 401 - If the input parameter is not valid parameter.
|
||||
* @throws { BusinessError } 16000001 - The specified ability does not exist.
|
||||
* @throws { BusinessError } 16000004 - Can not start invisible component.
|
||||
* @throws { BusinessError } 16000005 - The specified process does not have the permission.
|
||||
* @throws { BusinessError } 16000006 - Cross-user operations are not allowed.
|
||||
* @throws { BusinessError } 16000008 - The crowdtesting application expires.
|
||||
* @throws { BusinessError } 16000009 - An ability cannot be started or stopped in Wukong mode.
|
||||
* @throws { BusinessError } 16000011 - The context does not exist.
|
||||
* @throws { BusinessError } 16000012 - The application is controlled.
|
||||
* @throws { BusinessError } 16000013 - The application is controlled by EDM.
|
||||
* @throws { BusinessError } 16000050 - Internal error.
|
||||
* @throws { BusinessError } 16000053 - The ability is not on the top of the UI.
|
||||
* @throws { BusinessError } 16000055 - Installation-free timed out.
|
||||
* @throws { BusinessError } 16200001 - The caller has been released.
|
||||
* @syscap SystemCapability.Ability.AbilityRuntime.Core
|
||||
* @StageModelOnly
|
||||
* @since 10
|
||||
*/
|
||||
startAbilityForResult(want: Want, options: StartOptions, callback: AsyncCallback<AbilityResult>): void;
|
||||
|
||||
/**
|
||||
* Starts an ability and returns the execution result when the ability is destroyed.
|
||||
* If the caller application is in foreground, you can use this method to start ability; If the caller application
|
||||
* is in the background, you need to apply for permission:ohos.permission.START_ABILITIES_FROM_BACKGROUND.
|
||||
* If the target ability is visible, you can start the target ability; If the target ability is invisible,
|
||||
* you need to apply for permission:ohos.permission.START_INVISIBLE_ABILITY to start target invisible ability.
|
||||
* If the target ability is in cross-device, you need to apply for permission:ohos.permission.DISTRIBUTED_DATASYNC.
|
||||
*
|
||||
* @param { Want } want - Indicates the ability to start.
|
||||
* @param { StartOptions } [options] - Indicates the start options.
|
||||
* @returns { Promise<AbilityResult> } Returns the result of startAbility.
|
||||
* @throws { BusinessError } 201 - The application does not have permission to call the interface.
|
||||
* @throws { BusinessError } 401 - If the input parameter is not valid parameter.
|
||||
* @throws { BusinessError } 16000001 - The specified ability does not exist.
|
||||
* @throws { BusinessError } 16000002 - Incorrect ability type.
|
||||
* @throws { BusinessError } 16000004 - Can not start invisible component.
|
||||
* @throws { BusinessError } 16000005 - The specified process does not have the permission.
|
||||
* @throws { BusinessError } 16000006 - Cross-user operations are not allowed.
|
||||
* @throws { BusinessError } 16000008 - The crowdtesting application expires.
|
||||
* @throws { BusinessError } 16000009 - An ability cannot be started or stopped in Wukong mode.
|
||||
* @throws { BusinessError } 16000010 - The call with the continuation flag is forbidden.
|
||||
* @throws { BusinessError } 16000011 - The context does not exist.
|
||||
* @throws { BusinessError } 16000012 - The application is controlled.
|
||||
* @throws { BusinessError } 16000013 - The application is controlled by EDM.
|
||||
* @throws { BusinessError } 16000050 - Internal error.
|
||||
* @throws { BusinessError } 16000053 - The ability is not on the top of the UI.
|
||||
* @throws { BusinessError } 16000055 - Installation-free timed out.
|
||||
* @throws { BusinessError } 16200001 - The caller has been released.
|
||||
* @syscap SystemCapability.Ability.AbilityRuntime.Core
|
||||
* @StageModelOnly
|
||||
* @since 10
|
||||
*/
|
||||
startAbilityForResult(want: Want, options?: StartOptions): Promise<AbilityResult>;
|
||||
|
||||
/**
|
||||
* Destroys the UI extension.
|
||||
*
|
||||
* @param { number } sessionId - Session ID of the window.
|
||||
* @param { AsyncCallback<void> } callback - The callback of terminateSelf.
|
||||
* @throws { BusinessError } 401 - If the input parameter is not valid parameter.
|
||||
* @throws { BusinessError } 16000009 - An ability cannot be started or stopped in Wukong mode.
|
||||
* @throws { BusinessError } 16000011 - The context does not exist.
|
||||
* @throws { BusinessError } 16000050 - Internal error.
|
||||
* @syscap SystemCapability.Ability.AbilityRuntime.Core
|
||||
* @StageModelOnly
|
||||
* @since 10
|
||||
*/
|
||||
terminateSelf(sessionId: number, callback: AsyncCallback<void>): void;
|
||||
|
||||
/**
|
||||
* Destroys the UI extension.
|
||||
*
|
||||
* @param { number } sessionId - Session ID of the window.
|
||||
* @returns { Promise<void> } The promise returned by the function.
|
||||
* @throws { BusinessError } 16000009 - An ability cannot be started or stopped in Wukong mode.
|
||||
* @throws { BusinessError } 16000011 - The context does not exist.
|
||||
* @throws { BusinessError } 16000050 - Internal error.
|
||||
* @syscap SystemCapability.Ability.AbilityRuntime.Core
|
||||
* @StageModelOnly
|
||||
* @since 10
|
||||
*/
|
||||
terminateSelf(sessionId: number): Promise<void>;
|
||||
|
||||
/**
|
||||
* Sets the result code and data to be returned by the UI extension to the caller
|
||||
* and destroys the UI extension.
|
||||
*
|
||||
* @param { number } sessionId - Session ID of the window.
|
||||
* @param { AbilityResult } parameter - Indicates the result to return.
|
||||
* @param { AsyncCallback<void> } callback - The callback of terminateSelfWithResult.
|
||||
* @throws { BusinessError } 401 - If the input parameter is not valid parameter.
|
||||
* @throws { BusinessError } 16000009 - An ability cannot be started or stopped in Wukong mode.
|
||||
* @throws { BusinessError } 16000011 - The context does not exist.
|
||||
* @throws { BusinessError } 16000050 - Internal error.
|
||||
* @syscap SystemCapability.Ability.AbilityRuntime.Core
|
||||
* @StageModelOnly
|
||||
* @since 10
|
||||
*/
|
||||
terminateSelfWithResult(sessionId: number, parameter: AbilityResult, callback: AsyncCallback<void>): void;
|
||||
|
||||
/**
|
||||
* Sets the result code and data to be returned by the UI extension to the caller
|
||||
* and destroys the UI extension.
|
||||
*
|
||||
* @param { number } sessionId - Session ID of the window.
|
||||
* @param { AbilityResult } parameter - Indicates the result to return.
|
||||
* @returns { Promise<void> } The promise returned by the function.
|
||||
* @throws { BusinessError } 401 - If the input parameter is not valid parameter.
|
||||
* @throws { BusinessError } 16000009 - An ability cannot be started or stopped in Wukong mode.
|
||||
* @throws { BusinessError } 16000011 - The context does not exist.
|
||||
* @throws { BusinessError } 16000050 - Internal error.
|
||||
* @syscap SystemCapability.Ability.AbilityRuntime.Core
|
||||
* @StageModelOnly
|
||||
* @since 10
|
||||
*/
|
||||
terminateSelfWithResult(sessionId: number, parameter: AbilityResult): Promise<void>;
|
||||
}
|
Loading…
Reference in New Issue
Block a user