add startUIExtensionAbilityByType

Signed-off-by: x30043723 <xieqiongyang@huawei.com>

Change-Id: I692e116a6b5216de31b34a04e6a1123346dbaa5d
This commit is contained in:
x30043723 2023-09-21 08:11:58 +00:00
parent 7e95ca534e
commit f99bd82f10
2 changed files with 125 additions and 0 deletions

78
api/ability/uiExtensionCallback.d.ts vendored Normal file
View 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 Want from '../@ohos.app.ability.Want';
/**
* @interface UIExtensionCallback
* @syscap SystemCapability.Ability.AbilityRuntime.Core
* @StageModelOnly
* @since 11
*/
export interface UIExtensionCallback {
/**
* Called when remote UIExtensionAbility object is ready for receive data.
*
* @param { UIExtensionProxy } proxy
* @syscap SystemCapability.Ability.AbilityRuntime.Core
* @StageModelOnly
* @since 11
*/
onRemoteReady(proxy: UIExtensionProxy): void;
/**
* Called when data received from UIExtensionAbility.
*
* @param { object } parameters
* @syscap SystemCapability.Ability.AbilityRuntime.Core
* @StageModelOnly
* @since 11
*/
onReceive(parameters: { [key: string]: Object }): void;
/**
* Called when the UIExtensionAbility is terminated with result data.
*
* @param { number } code
* @param { Want } want
* @syscap SystemCapability.Ability.AbilityRuntime.Core
* @StageModelOnly
* @since 11
*/
onResult(code: number, want?: Want): void;
/**
* Returned number if disconnected from UIExtensionAbility, 0 means the
* UIExtensionAbility is terminate by itself, otherwise the connect is broken abnormal.
*
* @param { number } code
* @syscap SystemCapability.Ability.AbilityRuntime.Core
* @StageModelOnly
* @since 11
*/
onRelease(code: number): void;
/**
* Called when some error occurred except disconnected from UIExtensionAbility.
*
* @param { number } code
* @param { string } name
* @param { string } message
* @syscap SystemCapability.Ability.AbilityRuntime.Core
* @StageModelOnly
* @since 11
*/
onError(code: number, name: string, message: string): void;
}

View File

@ -29,6 +29,7 @@ import { LocalStorage } from 'StateManagement';
import image from '../@ohos.multimedia.image';
import dialogRequest from '../@ohos.app.ability.dialogRequest';
import AbilityConstant from '../@ohos.app.ability.AbilityConstant';
import { UIExtensionCallback } from '../ability/uiExtensionCallback';
/**
* The context of an ability. It allows access to ability-specific resources.
@ -2086,4 +2087,50 @@ export default class UIAbilityContext extends Context {
* @since 10
*/
reportDrawnCompleted(callback: AsyncCallback<void>): void;
/**
* Starts the uiExtensionability by type.
* 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.
*
* @param { string } type - The type of UIExtensionAbilitys.
* @param { object } wantParam - Indicates the want parameter.
* @param { UIExtensionCallback } uiExtensioncallback - Indicates the uiExtensioncallback.
* @param { AsyncCallback<void> } callback - The callback of startUIExtensionAbilityByType.
* @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 } 16000050 - Internal error.
* @throws { BusinessError } 16200001 - The caller has been released.
* @syscap SystemCapability.Ability.AbilityRuntime.Core
* @StageModelOnly
* @since 11
*/
startUIExtensionAbilityByType(type: string, wantParam: { [key: string]: Object },
uiExtensioncallback: UIExtensionCallback, callback: AsyncCallback<void>): void;
/**
* Starts the uiExtensionability by type.
* 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.
*
* @param { string } type - The type of UIExtensionAbilitys.
* @param { object } wantParam - Indicates the want parameter.
* @param { UIExtensionCallback } uiExtensioncallback - Indicates the uiExtensioncallback.
* @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 } 16000050 - Internal error.
* @throws { BusinessError } 16200001 - The caller has been released.
* @syscap SystemCapability.Ability.AbilityRuntime.Core
* @StageModelOnly
* @since 11
*/
startUIExtensionAbilityByType(type: string, wantParam: { [key: string]: Object },
uiExtensioncallback: UIExtensionCallback): Promise<void>;
}