/* * Copyright (c) 2021-2022 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 { AbilityInfo } from "../bundleManager/AbilityInfo"; import { AbilityResult } from "../ability/abilityResult"; import { AsyncCallback } from "../basic"; import { ConnectOptions } from "../ability/connectOptions"; import { HapModuleInfo } from "../bundleManager/HapModuleInfo"; import Context from "./Context"; import Want from "../@ohos.app.ability.Want"; import StartOptions from "../@ohos.app.ability.StartOptions"; import { Configuration } from '../@ohos.app.ability.Configuration'; import { Caller } from '../@ohos.app.ability.UIAbility'; import { LocalStorage } from 'StateManagement'; import image from '../@ohos.multimedia.image'; import dialogRequest from "../@ohos.app.ability.dialogRequest"; /** * The context of an ability. It allows access to ability-specific resources. * @syscap SystemCapability.Ability.AbilityRuntime.Core * @StageModelOnly * @since 9 */ export default class UIAbilityContext extends Context { /** * Indicates configuration information about an ability. * @type { AbilityInfo } * @syscap SystemCapability.Ability.AbilityRuntime.Core * @StageModelOnly * @since 9 */ abilityInfo: AbilityInfo; /** * Indicates configuration information about the module. * @type { HapModuleInfo } * @syscap SystemCapability.Ability.AbilityRuntime.Core * @StageModelOnly * @since 9 */ currentHapModuleInfo: HapModuleInfo; /** * Indicates configuration information. * @type { Configuration } * @syscap SystemCapability.Ability.AbilityRuntime.Core * @StageModelOnly * @since 9 */ config: Configuration; /** * Starts a new ability. * @param want { Want } - Indicates the ability to start. * @param { AsyncCallback } callback - The callback of startAbility. * @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 } 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 9 */ startAbility(want: Want, callback: AsyncCallback): void; /** * Starts a new ability. * @param { Want } want - Indicates the ability to start. * @param { StartOptions } options - Indicates the start options. * @param { AsyncCallback } callback - The callback of startAbility. * @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 } 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 9 */ startAbility(want: Want, options: StartOptions, callback: AsyncCallback): void; /** * Starts a new ability. * @param { Want } want - Indicates the ability to start. * @param { StartOptions } options - Indicates the start options. * @returns { Promise } The promise returned by the function. * @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 } 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 9 */ startAbility(want: Want, options?: StartOptions): Promise; /** * Get the caller object of the startup capability * @permission ohos.permission.ABILITY_BACKGROUND_COMMUNICATION * @param { Want } want - Indicates the ability to start. * @returns { Promise } Returns the Caller interface. * @throws { BusinessError } 201 - The application does not have permission to call the interface. * @throws { BusinessError } 202 - The application is not system-app, can not use system-api. * @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 } 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 9 */ startAbilityByCall(want: Want): Promise; /** * Starts a new ability with account. * @permission ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS * @param { Want } want - Indicates the want info to start. * @param { number } accountId - Indicates the account to start. * @param { AsyncCallback } callback - The callback of startAbilityWithAccount. * @throws { BusinessError } 201 - The application does not have permission to call the interface. * @throws { BusinessError } 202 - The application is not system-app, can not use system-api. * @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 } 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 * @systemapi * @StageModelOnly * @since 9 */ startAbilityWithAccount(want: Want, accountId: number, callback: AsyncCallback): void; /** * Starts a new ability with account. * @permission ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS * @param { Want } want - Indicates the want info to start. * @param { number } accountId - Indicates the account to start. * @param { StartOptions } options - Indicates the start options. * @param { AsyncCallback } callback - The callback of startAbilityWithAccount. * @throws { BusinessError } 201 - The application does not have permission to call the interface. * @throws { BusinessError } 202 - The application is not system-app, can not use system-api. * @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 } 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 * @systemapi * @StageModelOnly * @since 9 */ startAbilityWithAccount(want: Want, accountId: number, options: StartOptions, callback: AsyncCallback): void; /** * Starts a new ability with account. * @permission ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS * @param { Want } want - Indicates the want info to start. * @param { number } accountId - Indicates the account to start. * @param { StartOptions } options - Indicates the start options. * @returns { Promise } The promise returned by the function. * @throws { BusinessError } 201 - The application does not have permission to call the interface. * @throws { BusinessError } 202 - The application is not system-app, can not use system-api. * @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 } 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 * @systemapi * @StageModelOnly * @since 9 */ startAbilityWithAccount(want: Want, accountId: number, options?: StartOptions): Promise; /** * Starts an ability and returns the execution result when the ability is destroyed. * @param { Want } want - Indicates the ability to start. * @param { AsyncCallback } callback - The callback is used to return the result of startAbility. * @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 } 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 9 */ startAbilityForResult(want: Want, callback: AsyncCallback): void; /** * Starts an ability and returns the execution result when the ability is destroyed. * @param { Want } want - Indicates the ability to start. * @param { StartOptions } options - Indicates the start options. * @param { AsyncCallback } callback - The callback is used to return the result of startAbility. * @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 } 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 9 */ startAbilityForResult(want: Want, options: StartOptions, callback: AsyncCallback): void; /** * Starts an ability and returns the execution result when the ability is destroyed. * @param { Want } want - Indicates the ability to start. * @param { StartOptions } options - Indicates the start options. * @returns { Promise } Returns the result of startAbility. * @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 } 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 9 */ startAbilityForResult(want: Want, options?: StartOptions): Promise; /** * Starts an ability and returns the execution result when the ability is destroyed with account. * @permission ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS * @param { Want } want - Indicates the want info to start. * @param { number } accountId - Indicates the account to start. * @param { AsyncCallback } 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 } 202 - The application is not system-app, can not use system-api. * @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 } 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 * @systemapi * @StageModelOnly * @since 9 */ startAbilityForResultWithAccount(want: Want, accountId: number, callback: AsyncCallback): void; /** * Starts an ability and returns the execution result when the ability is destroyed with account. * @permission ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS * @param { Want } want - Indicates the want info to start. * @param { number } accountId - Indicates the account to start. * @param { StartOptions } options - Indicates the start options. * @param { AsyncCallback } 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 } 202 - The application is not system-app, can not use system-api. * @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 } 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 * @systemapi * @StageModelOnly * @since 9 */ startAbilityForResultWithAccount(want: Want, accountId: number, options: StartOptions, callback: AsyncCallback): void; /** * Starts an ability and returns the execution result when the ability is destroyed with account. * @permission ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS * @param { Want } want - Indicates the want info to start. * @param { number } accountId - Indicates the account to start. * @param { StartOptions } options - Indicates the start options. * @returns { Promise } Returns the result of startAbility. * @throws { BusinessError } 201 - The application does not have permission to call the interface. * @throws { BusinessError } 202 - The application is not system-app, can not use system-api. * @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 } 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 * @systemapi * @StageModelOnly * @since 9 */ startAbilityForResultWithAccount(want: Want, accountId: number, options?: StartOptions): Promise; /** * Starts a new service extension ability. * @param { Want } want - Indicates the want info to start. * @param { AsyncCallback } callback - The callback of startServiceExtensionAbility. * @throws { BusinessError } 202 - The application is not system-app, can not use system-api. * @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 } 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 } 16000011 - The context does not exist. * @throws { BusinessError } 16000050 - Internal error. * @throws { BusinessError } 16200001 - The caller has been released. * @syscap SystemCapability.Ability.AbilityRuntime.Core * @systemapi * @StageModelOnly * @since 9 */ startServiceExtensionAbility(want: Want, callback: AsyncCallback): void; /** * Starts a new service extension ability. * @param { Want } want - Indicates the want info to start. * @returns { Promise } The promise returned by the function. * @throws { BusinessError } 202 - The application is not system-app, can not use system-api. * @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 } 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 } 16000011 - The context does not exist. * @throws { BusinessError } 16000050 - Internal error. * @throws { BusinessError } 16200001 - The caller has been released. * @syscap SystemCapability.Ability.AbilityRuntime.Core * @systemapi * @StageModelOnly * @since 9 */ startServiceExtensionAbility(want: Want): Promise; /** * Starts a new service extension ability with account. * @permission ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS * @param { Want } want - Indicates the want info to start. * @param { number } accountId - Indicates the account to start. * @param { AsyncCallback } callback - The callback of startServiceExtensionAbilityWithAccount. * @throws { BusinessError } 201 - The application does not have permission to call the interface. * @throws { BusinessError } 202 - The application is not system-app, can not use system-api. * @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 } 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 } 16000011 - The context does not exist. * @throws { BusinessError } 16000050 - Internal error. * @throws { BusinessError } 16200001 - The caller has been released. * @syscap SystemCapability.Ability.AbilityRuntime.Core * @systemapi * @StageModelOnly * @since 9 */ startServiceExtensionAbilityWithAccount(want: Want, accountId: number, callback: AsyncCallback): void; /** * Starts a new service extension ability with account. * @permission ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS * @param { Want } want - Indicates the want info to start. * @param { number } accountId - Indicates the account to start. * @returns { Promise } The promise returned by the function. * @throws { BusinessError } 201 - The application does not have permission to call the interface. * @throws { BusinessError } 202 - The application is not system-app, can not use system-api. * @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 } 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 } 16000011 - The context does not exist. * @throws { BusinessError } 16000050 - Internal error. * @throws { BusinessError } 16200001 - The caller has been released. * @syscap SystemCapability.Ability.AbilityRuntime.Core * @systemapi * @StageModelOnly * @since 9 */ startServiceExtensionAbilityWithAccount(want: Want, accountId: number): Promise; /** * Stops a service within the same application. * @param { Want } want - Indicates the want info to start. * @param { AsyncCallback } callback - The callback of stopServiceExtensionAbility. * @throws { BusinessError } 202 - The application is not system-app, can not use system-api. * @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 } 16000005 - The specified process does not have the permission. * @throws { BusinessError } 16000006 - Cross-user operations are not allowed. * @throws { BusinessError } 16000011 - The context does not exist. * @throws { BusinessError } 16000050 - Internal error. * @throws { BusinessError } 16200001 - The caller has been released. * @syscap SystemCapability.Ability.AbilityRuntime.Core * @systemapi * @StageModelOnly * @since 9 */ stopServiceExtensionAbility(want: Want, callback: AsyncCallback): void; /** * Stops a service within the same application. * @param { Want } want - Indicates the want info to start. * @returns { Promise } The promise returned by the function. * @throws { BusinessError } 202 - The application is not system-app, can not use system-api. * @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 } 16000005 - The specified process does not have the permission. * @throws { BusinessError } 16000006 - Cross-user operations are not allowed. * @throws { BusinessError } 16000011 - The context does not exist. * @throws { BusinessError } 16000050 - Internal error. * @throws { BusinessError } 16200001 - The caller has been released. * @syscap SystemCapability.Ability.AbilityRuntime.Core * @systemapi * @StageModelOnly * @since 9 */ stopServiceExtensionAbility(want: Want): Promise; /** * Stops a service within the same application with account. * @permission ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS * @param { Want } want - Indicates the want info to start. * @param { number } accountId - Indicates the accountId to start. * @param { AsyncCallback } callback - The callback of stopServiceExtensionAbilityWithAccount. * @throws { BusinessError } 201 - The application does not have permission to call the interface. * @throws { BusinessError } 202 - The application is not system-app, can not use system-api. * @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 } 16000005 - The specified process does not have the permission. * @throws { BusinessError } 16000006 - Cross-user operations are not allowed. * @throws { BusinessError } 16000011 - The context does not exist. * @throws { BusinessError } 16000050 - Internal error. * @throws { BusinessError } 16200001 - The caller has been released. * @syscap SystemCapability.Ability.AbilityRuntime.Core * @systemapi * @StageModelOnly * @since 9 */ stopServiceExtensionAbilityWithAccount(want: Want, accountId: number, callback: AsyncCallback): void; /** * Stops a service within the same application with account. * @permission ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS * @param { Want } want - Indicates the want info to start. * @param { number } accountId - Indicates the accountId to start. * @returns { Promise } The promise returned by the function. * @throws { BusinessError } 201 - The application does not have permission to call the interface. * @throws { BusinessError } 202 - The application is not system-app, can not use system-api. * @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 } 16000005 - The specified process does not have the permission. * @throws { BusinessError } 16000006 - Cross-user operations are not allowed. * @throws { BusinessError } 16000011 - The context does not exist. * @throws { BusinessError } 16000050 - Internal error. * @throws { BusinessError } 16200001 - The caller has been released. * @syscap SystemCapability.Ability.AbilityRuntime.Core * @systemapi * @StageModelOnly * @since 9 */ stopServiceExtensionAbilityWithAccount(want: Want, accountId: number): Promise; /** * Destroys this Page ability. * @param { AsyncCallback } callback - The callback of terminateSelf. * @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 } 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 9 */ terminateSelf(callback: AsyncCallback): void; /** * Destroys this Page ability. * @returns { Promise } The promise returned by the function. * @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 } 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 9 */ terminateSelf(): Promise; /** * Sets the result code and data to be returned by this Page ability to the caller * and destroys this Page ability. * @param { AbilityResult } parameter - Indicates the result to return. * @param { AsyncCallback } callback - The callback of terminateSelfWithResult. * @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 } 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 9 */ terminateSelfWithResult(parameter: AbilityResult, callback: AsyncCallback): void; /** * Sets the result code and data to be returned by this Page ability to the caller * and destroys this Page ability. * @param { AbilityResult } parameter - Indicates the result to return. * @returns { Promise } The promise returned by the function. * @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 } 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 9 */ terminateSelfWithResult(parameter: AbilityResult): Promise; /** * Connects the current ability to an ability using the AbilityInfo.AbilityType.SERVICE template. * @param { Want } want - The element name of the service ability * @param { ConnectOptions } options - The remote object instance * @returns { number } Returns the number code of the ability connected * @throws { BusinessError } 401 - If the input parameter is not valid parameter. * @throws { BusinessError } 16000001 - The specified ability does not exist. * @throws { BusinessError } 16000005 - The specified process does not have the permission. * @throws { BusinessError } 16000011 - The context does not exist. * @throws { BusinessError } 16000050 - Internal error. * @syscap SystemCapability.Ability.AbilityRuntime.Core * @StageModelOnly * @since 9 */ connectServiceExtensionAbility(want: Want, options: ConnectOptions): number; /** * Connects the current ability to an ability using the AbilityInfo.AbilityType.SERVICE template with account. * @permission ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS * @param { Want } want - The element name of the service ability * @param { number } accountId - The account to connect * @param { ConnectOptions } options - The remote object instance * @returns { number } Returns the number code of the ability connected * @throws { BusinessError } 201 - The application does not have permission to call the interface. * @throws { BusinessError } 202 - The application is not system-app, can not use system-api. * @throws { BusinessError } 401 - If the input parameter is not valid parameter. * @throws { BusinessError } 16000001 - The specified ability does not exist. * @throws { BusinessError } 16000005 - The specified process does not have the permission. * @throws { BusinessError } 16000011 - The context does not exist. * @throws { BusinessError } 16000050 - Internal error. * @syscap SystemCapability.Ability.AbilityRuntime.Core * @systemapi * @StageModelOnly * @since 9 */ connectServiceExtensionAbilityWithAccount(want: Want, accountId: number, options: ConnectOptions): number; /** * The callback interface is connected successfully. * @param { number } connection - The number code of the ability connected * @param { AsyncCallback } callback - The callback of disconnectAbility. * @throws { BusinessError } 401 - If the input parameter is not valid parameter. * @throws { BusinessError } 16000001 - The specified ability does not exist. * @throws { BusinessError } 16000005 - The specified process does not have the permission. * @throws { BusinessError } 16000011 - The context does not exist. * @throws { BusinessError } 16000050 - Internal error. * @syscap SystemCapability.Ability.AbilityRuntime.Core * @StageModelOnly * @since 9 */ disconnectServiceExtensionAbility(connection: number, callback: AsyncCallback): void; /** * The callback interface is connected successfully. * @param { number } connection - The number code of the ability connected * @returns { Promise } The promise returned by the function. * @throws { BusinessError } 401 - If the input parameter is not valid parameter. * @throws { BusinessError } 16000001 - The specified ability does not exist. * @throws { BusinessError } 16000005 - The specified process does not have the permission. * @throws { BusinessError } 16000011 - The context does not exist. * @throws { BusinessError } 16000050 - Internal error. * @syscap SystemCapability.Ability.AbilityRuntime.Core * @StageModelOnly * @since 9 */ disconnectServiceExtensionAbility(connection: number): Promise; /** * Set mission label of current ability. * @param { string } label - The label of ability that showed in recent missions. * @param { AsyncCallback } callback - The callback of setMissionLabel. * @throws { BusinessError } 401 - If the input parameter is not valid parameter. * @throws { BusinessError } 16000011 - The context does not exist. * @throws { BusinessError } 16000050 - Internal error. * @syscap SystemCapability.Ability.AbilityRuntime.Core * @StageModelOnly * @since 9 */ setMissionLabel(label: string, callback: AsyncCallback): void; /** * Set mission label of current ability. * @param { string } label - The label of ability that showed in recent missions. * @returns { Promise } The promise returned by the function. * @throws { BusinessError } 401 - If the input parameter is not valid parameter. * @throws { BusinessError } 16000011 - The context does not exist. * @throws { BusinessError } 16000050 - Internal error. * @syscap SystemCapability.Ability.AbilityRuntime.Core * @StageModelOnly * @since 9 */ setMissionLabel(label: string): Promise; /** * Set mission icon of current ability. * @param { image.PixelMap } icon - The icon of ability that showed in recent missions. * @param { AsyncCallback } callback - The callback of setMissionIcon. * @throws { BusinessError } 401 - If the input parameter is not valid parameter. * @throws { BusinessError } 16000011 - The context does not exist. * @throws { BusinessError } 16000050 - Internal error. * @syscap SystemCapability.Ability.AbilityRuntime.Core * @systemapi * @StageModelOnly * @since 9 */ setMissionIcon(icon: image.PixelMap, callback: AsyncCallback): void; /** * Set mission icon of current ability. * @param { image.PixelMap } icon - The icon of ability that showed in recent missions. * @returns { Promise } The promise returned by the function. * @throws { BusinessError } 401 - If the input parameter is not valid parameter. * @throws { BusinessError } 16000011 - The context does not exist. * @throws { BusinessError } 16000050 - Internal error. * @syscap SystemCapability.Ability.AbilityRuntime.Core * @systemapi * @StageModelOnly * @since 9 */ setMissionIcon(icon: image.PixelMap): Promise; /** * Restore window stage data in ability continuation * @param { LocalStorage } localStorage - the storage data used to restore window stage * @throws { BusinessError } 401 - If the input parameter is not valid parameter. * @syscap SystemCapability.Ability.AbilityRuntime.Core * @StageModelOnly * @since 9 */ restoreWindowStage(localStorage: LocalStorage): void; /** * Check to see ability is in terminating state. * @returns { boolean } Returns true when ability is in terminating state, else returns false. * @syscap SystemCapability.Ability.AbilityRuntime.Core * @StageModelOnly * @since 9 */ isTerminating(): boolean; /** * Service extension uses this method to start a specific ability, * if ability is multi instance, will start a recent instance. * @param { Want } want - Indicates the ability to start. * @param { AsyncCallback } callback - The callback of startAbility. * @throws { BusinessError } 401 - If the input parameter is not valid parameter. * @syscap SystemCapability.Ability.AbilityRuntime.Core * @systemapi * @StageModelOnly * @since 9 */ startRecentAbility(want: Want, callback: AsyncCallback): void; /** * Service extension uses this method to start a specific ability, * if ability is multi instance, will start a recent instance. * @param { Want } want - Indicates the ability to start. * @param { StartOptions } options - Indicates the start options. * @param { AsyncCallback } callback - The callback of startAbility. * @throws { BusinessError } 401 - If the input parameter is not valid parameter. * @throws { BusinessError } 16000011 - The context does not exist. * @throws { BusinessError } 16000050 - Internal error. * @syscap SystemCapability.Ability.AbilityRuntime.Core * @systemapi * @StageModelOnly * @since 9 */ startRecentAbility(want: Want, options: StartOptions, callback: AsyncCallback): void; /** * Service extension uses this method to start a specific ability, * if ability is multi instance, will start a recent instance. * @param { Want } want - Indicates the ability to start. * @param { StartOptions } options - Indicates the start options. * @returns { Promise } The promise returned by the function. * @throws { BusinessError } 401 - If the input parameter is not valid parameter. * @syscap SystemCapability.Ability.AbilityRuntime.Core * @systemapi * @throws { BusinessError } 16000011 - The context does not exist. * @throws { BusinessError } 16000050 - Internal error. * @StageModelOnly * @since 9 */ startRecentAbility(want: Want, options?: StartOptions): Promise; /** * Requests certain permissions from the system. * @param want { Want } - Indicates the dialog service to start. * @param { AsyncCallback } result - The callback is used to return the request result. * @throws { BusinessError } 401 - If the input parameter is not valid parameter. * @syscap SystemCapability.Ability.AbilityRuntime.Core * @StageModelOnly * @since 9 */ requestDialogService(want: Want, result: AsyncCallback): void; /** * Requests certain permissions from the system. * @param want { Want } - Indicates the dialog service to start. * @returns { Promise } Returns the request result. * @throws { BusinessError } 401 - If the input parameter is not valid parameter. * @syscap SystemCapability.Ability.AbilityRuntime.Core * @StageModelOnly * @since 9 */ requestDialogService(want: Want): Promise; }