mirror of
https://gitee.com/openharmony/interface_sdk-js
synced 2024-11-27 09:22:53 +00:00
add startUIExtensionAbilityByType
Signed-off-by: x30043723 <xieqiongyang@huawei.com> Change-Id: I692e116a6b5216de31b34a04e6a1123346dbaa5d
This commit is contained in:
parent
f99bd82f10
commit
8c7b224dc9
@ -14,6 +14,7 @@
|
||||
*/
|
||||
|
||||
import type { AbilityResult } from './ability/abilityResult';
|
||||
import type { AbilityStartCallback } from './application/AbilityStartCallback';
|
||||
import type { AsyncCallback } from './@ohos.base';
|
||||
import type { LocalStorage } from 'StateManagement';
|
||||
import type Want from './@ohos.app.ability.Want';
|
||||
@ -357,4 +358,50 @@ export default class UIExtensionContentSession {
|
||||
* @since 10
|
||||
*/
|
||||
setWindowPrivacyMode(isPrivacyMode: boolean, callback: AsyncCallback<void>): void;
|
||||
|
||||
/**
|
||||
* Starts the UIAbility or 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 target ability.
|
||||
* @param { Record<string, Object> } wantParam - Indicates the want parameter.
|
||||
* @param { AbilityStartCallback } abilityStartCallback - Indicates the abilityStartCallback.
|
||||
* @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 } 16000050 - Internal error.
|
||||
* @throws { BusinessError } 16200001 - The caller has been released.
|
||||
* @syscap SystemCapability.Ability.AbilityRuntime.Core
|
||||
* @StageModelOnly
|
||||
* @since 11
|
||||
*/
|
||||
startAbilityByType(type: string, wantParam: Record<string, Object>,
|
||||
abilityStartCallback: AbilityStartCallback, callback: AsyncCallback<void>): void;
|
||||
|
||||
/**
|
||||
* Starts the UIAbility or 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 target ability.
|
||||
* @param { Record<string, Object> } wantParam - Indicates the want parameter.
|
||||
* @param { AbilityStartCallback } abilityStartCallback - Indicates the abilityStartCallback.
|
||||
* @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
|
||||
*/
|
||||
startAbilityByType(type: string, wantParam: Record<string, Object>,
|
||||
abilityStartCallback: AbilityStartCallback): Promise<void>;
|
||||
}
|
||||
|
10
api/@ohos.app.ability.common.d.ts
vendored
10
api/@ohos.app.ability.common.d.ts
vendored
@ -25,6 +25,7 @@ import * as _ServiceExtensionContext from './application/ServiceExtensionContext
|
||||
import * as _EventHub from './application/EventHub';
|
||||
import { PacMap as _PacMap } from './ability/dataAbilityHelper';
|
||||
import { AbilityResult as _AbilityResult } from './ability/abilityResult';
|
||||
import type { AbilityStartCallback as _AbilityStartCallback } from './application/AbilityStartCallback';
|
||||
import { ConnectOptions as _ConnectOptions } from './ability/connectOptions';
|
||||
|
||||
/**
|
||||
@ -207,6 +208,15 @@ declare namespace common {
|
||||
* @since 10
|
||||
*/
|
||||
export type UIExtensionContext = _UIExtensionContext.default;
|
||||
|
||||
/**
|
||||
* The function Called when some error occurred except disconnected from UIAbility or UIExtensionAbility
|
||||
*
|
||||
* @syscap SystemCapability.Ability.AbilityRuntime.Core
|
||||
* @StageModelOnly
|
||||
* @since 11
|
||||
*/
|
||||
export type AbilityStartCallback = _AbilityStartCallback;
|
||||
}
|
||||
|
||||
export default common;
|
||||
|
78
api/ability/uiExtensionCallback.d.ts
vendored
78
api/ability/uiExtensionCallback.d.ts
vendored
@ -1,78 +0,0 @@
|
||||
/*
|
||||
* 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;
|
||||
}
|
35
api/application/AbilityStartCallback.d.ts
vendored
Normal file
35
api/application/AbilityStartCallback.d.ts
vendored
Normal file
@ -0,0 +1,35 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* The callback of UIAbility or UIExtensionAbility.
|
||||
* @syscap SystemCapability.Ability.AbilityRuntime.Core
|
||||
* @StageModelOnly
|
||||
* @since 11
|
||||
*/
|
||||
export default class AbilityStartCallback {
|
||||
|
||||
/**
|
||||
* Called when some error occurred except disconnected from UIAbility or UIExtensionAbility.
|
||||
*
|
||||
* @param { number } code - The code returned if the UIAbility or UIExtensionAbility failed to start.
|
||||
* @param { string } name - The name returned if the UIAbility or UIExtensionAbility failed to start.
|
||||
* @param { string } message - The message returned if the UIAbility or UIExtensionAbility failed to start.
|
||||
* @syscap SystemCapability.Ability.AbilityRuntime.Core
|
||||
* @StageModelOnly
|
||||
* @since 11
|
||||
*/
|
||||
onError(code: number, name: string, message: string): void;
|
||||
}
|
28
api/application/UIAbilityContext.d.ts
vendored
28
api/application/UIAbilityContext.d.ts
vendored
@ -29,7 +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';
|
||||
import type { AbilityStartCallback } from './AbilityStartCallback';
|
||||
|
||||
/**
|
||||
* The context of an ability. It allows access to ability-specific resources.
|
||||
@ -2089,14 +2089,14 @@ export default class UIAbilityContext extends Context {
|
||||
reportDrawnCompleted(callback: AsyncCallback<void>): void;
|
||||
|
||||
/**
|
||||
* Starts the uiExtensionability by type.
|
||||
* Starts the UIAbility or 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.
|
||||
* @param { string } type - The type of target ability.
|
||||
* @param { Record<string, Object> } wantParam - Indicates the want parameter.
|
||||
* @param { AbilityStartCallback } abilityStartCallback - Indicates the abilityStartCallback.
|
||||
* @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.
|
||||
@ -2108,17 +2108,17 @@ export default class UIAbilityContext extends Context {
|
||||
* @StageModelOnly
|
||||
* @since 11
|
||||
*/
|
||||
startUIExtensionAbilityByType(type: string, wantParam: { [key: string]: Object },
|
||||
uiExtensioncallback: UIExtensionCallback, callback: AsyncCallback<void>): void;
|
||||
startAbilityByType(type: string, wantParam: Record<string, Object>,
|
||||
abilityStartCallback: AbilityStartCallback, callback: AsyncCallback<void>): void;
|
||||
|
||||
/**
|
||||
* Starts the uiExtensionability by type.
|
||||
* Starts the UIAbility or 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 { string } type - The type of target ability.
|
||||
* @param { Record<string, Object> } wantParam - Indicates the want parameter.
|
||||
* @param { AbilityStartCallback } abilityStartCallback - Indicates the abilityStartCallback.
|
||||
* @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.
|
||||
@ -2131,6 +2131,6 @@ export default class UIAbilityContext extends Context {
|
||||
* @StageModelOnly
|
||||
* @since 11
|
||||
*/
|
||||
startUIExtensionAbilityByType(type: string, wantParam: { [key: string]: Object },
|
||||
uiExtensioncallback: UIExtensionCallback): Promise<void>;
|
||||
startAbilityByType(type: string, wantParam: Record<string, Object>,
|
||||
abilityStartCallback: AbilityStartCallback): Promise<void>;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user