161847f8eSopenharmony_ci/* 261847f8eSopenharmony_ci * Copyright (c) 2021-2023 Huawei Device Co., Ltd. 361847f8eSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 461847f8eSopenharmony_ci * you may not use this file except in compliance with the License. 561847f8eSopenharmony_ci * You may obtain a copy of the License at 661847f8eSopenharmony_ci * 761847f8eSopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 861847f8eSopenharmony_ci * 961847f8eSopenharmony_ci * Unless required by applicable law or agreed to in writing, software 1061847f8eSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 1161847f8eSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1261847f8eSopenharmony_ci * See the License for the specific language governing permissions and 1361847f8eSopenharmony_ci * limitations under the License. 1461847f8eSopenharmony_ci */ 1561847f8eSopenharmony_ci 1661847f8eSopenharmony_ci/** 1761847f8eSopenharmony_ci * @file 1861847f8eSopenharmony_ci * @kit AbilityKit 1961847f8eSopenharmony_ci */ 2061847f8eSopenharmony_ci 2161847f8eSopenharmony_ciimport { AsyncCallback } from './@ohos.base'; 2261847f8eSopenharmony_ciimport { StartAbilityParameter } from './ability/startAbilityParameter'; 2361847f8eSopenharmony_ciimport { DataAbilityHelper } from './ability/dataAbilityHelper'; 2461847f8eSopenharmony_ciimport { NotificationRequest } from './notification/notificationRequest'; 2561847f8eSopenharmony_ciimport { ConnectOptions } from './ability/connectOptions'; 2661847f8eSopenharmony_ciimport Want from './@ohos.app.ability.Want'; 2761847f8eSopenharmony_ci 2861847f8eSopenharmony_ci/** 2961847f8eSopenharmony_ci * A Particle Ability represents an ability with service. 3061847f8eSopenharmony_ci * 3161847f8eSopenharmony_ci * @namespace particleAbility 3261847f8eSopenharmony_ci * @syscap SystemCapability.Ability.AbilityRuntime.FAModel 3361847f8eSopenharmony_ci * @FAModelOnly 3461847f8eSopenharmony_ci * @since 7 3561847f8eSopenharmony_ci */ 3661847f8eSopenharmony_cideclare namespace particleAbility { 3761847f8eSopenharmony_ci /** 3861847f8eSopenharmony_ci * Service ability uses this method to start a specific ability. 3961847f8eSopenharmony_ci * 4061847f8eSopenharmony_ci * @param { StartAbilityParameter } parameter - Indicates the ability to start. 4161847f8eSopenharmony_ci * @param { AsyncCallback<void> } callback - Returns the result of starting Ability in the form of callback. 4261847f8eSopenharmony_ci * @syscap SystemCapability.Ability.AbilityRuntime.FAModel 4361847f8eSopenharmony_ci * @FAModelOnly 4461847f8eSopenharmony_ci * @since 7 4561847f8eSopenharmony_ci */ 4661847f8eSopenharmony_ci function startAbility(parameter: StartAbilityParameter, callback: AsyncCallback<void>): void; 4761847f8eSopenharmony_ci 4861847f8eSopenharmony_ci /** 4961847f8eSopenharmony_ci * Service ability uses this method to start a specific ability. 5061847f8eSopenharmony_ci * 5161847f8eSopenharmony_ci * @param { StartAbilityParameter } parameter - Indicates the ability to start. 5261847f8eSopenharmony_ci * @returns { Promise<void> } the promise returned by the function. 5361847f8eSopenharmony_ci * @syscap SystemCapability.Ability.AbilityRuntime.FAModel 5461847f8eSopenharmony_ci * @FAModelOnly 5561847f8eSopenharmony_ci * @since 7 5661847f8eSopenharmony_ci */ 5761847f8eSopenharmony_ci function startAbility(parameter: StartAbilityParameter): Promise<void>; 5861847f8eSopenharmony_ci 5961847f8eSopenharmony_ci /** 6061847f8eSopenharmony_ci * Destroys this service ability. 6161847f8eSopenharmony_ci * 6261847f8eSopenharmony_ci * @param { AsyncCallback<void> } callback - Return the result of stopping Ability in the form of callback. 6361847f8eSopenharmony_ci * @syscap SystemCapability.Ability.AbilityRuntime.FAModel 6461847f8eSopenharmony_ci * @FAModelOnly 6561847f8eSopenharmony_ci * @since 7 6661847f8eSopenharmony_ci */ 6761847f8eSopenharmony_ci function terminateSelf(callback: AsyncCallback<void>): void; 6861847f8eSopenharmony_ci 6961847f8eSopenharmony_ci /** 7061847f8eSopenharmony_ci * Destroys this service ability. 7161847f8eSopenharmony_ci * 7261847f8eSopenharmony_ci * @returns { Promise<void> } the promise returned by the function. 7361847f8eSopenharmony_ci * @syscap SystemCapability.Ability.AbilityRuntime.FAModel 7461847f8eSopenharmony_ci * @FAModelOnly 7561847f8eSopenharmony_ci * @since 7 7661847f8eSopenharmony_ci */ 7761847f8eSopenharmony_ci function terminateSelf(): Promise<void>; 7861847f8eSopenharmony_ci 7961847f8eSopenharmony_ci /** 8061847f8eSopenharmony_ci * Obtains the dataAbilityHelper. 8161847f8eSopenharmony_ci * 8261847f8eSopenharmony_ci * @param { string } uri - Indicates the path of the file to open. 8361847f8eSopenharmony_ci * @returns { DataAbilityHelper } Returns the dataAbilityHelper. 8461847f8eSopenharmony_ci * @syscap SystemCapability.Ability.AbilityRuntime.FAModel 8561847f8eSopenharmony_ci * @FAModelOnly 8661847f8eSopenharmony_ci * @since 7 8761847f8eSopenharmony_ci */ 8861847f8eSopenharmony_ci function acquireDataAbilityHelper(uri: string): DataAbilityHelper; 8961847f8eSopenharmony_ci 9061847f8eSopenharmony_ci /** 9161847f8eSopenharmony_ci * Keep this Service ability in the background and display a notification bar. 9261847f8eSopenharmony_ci * 9361847f8eSopenharmony_ci * @permission ohos.permission.KEEP_BACKGROUND_RUNNING 9461847f8eSopenharmony_ci * @param { number } id - Identifies the notification bar information. 9561847f8eSopenharmony_ci * @param { NotificationRequest } request - Indicates the notificationRequest instance containing information 9661847f8eSopenharmony_ci * for displaying a notification bar. 9761847f8eSopenharmony_ci * @param { AsyncCallback<void> } callback - returns the result of starting a long-term task in the form of callback. 9861847f8eSopenharmony_ci * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask 9961847f8eSopenharmony_ci * @FAModelOnly 10061847f8eSopenharmony_ci * @since 7 10161847f8eSopenharmony_ci * @deprecated since 9 10261847f8eSopenharmony_ci * @useinstead ohos.resourceschedule.backgroundTaskManager/backgroundTaskManager#startBackgroundRunning 10361847f8eSopenharmony_ci */ 10461847f8eSopenharmony_ci function startBackgroundRunning(id: number, request: NotificationRequest, callback: AsyncCallback<void>): void; 10561847f8eSopenharmony_ci 10661847f8eSopenharmony_ci /** 10761847f8eSopenharmony_ci * Keep this Service ability in the background and display a notification bar. 10861847f8eSopenharmony_ci * 10961847f8eSopenharmony_ci * @permission ohos.permission.KEEP_BACKGROUND_RUNNING 11061847f8eSopenharmony_ci * @param { number } id - Identifies the notification bar information. 11161847f8eSopenharmony_ci * @param { NotificationRequest } request - Indicates the notificationRequest instance containing information 11261847f8eSopenharmony_ci * for displaying a notification bar. 11361847f8eSopenharmony_ci * @returns { Promise<void> } the promise returned by the function. 11461847f8eSopenharmony_ci * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask 11561847f8eSopenharmony_ci * @FAModelOnly 11661847f8eSopenharmony_ci * @since 7 11761847f8eSopenharmony_ci * @deprecated since 9 11861847f8eSopenharmony_ci * @useinstead ohos.resourceschedule.backgroundTaskManager/backgroundTaskManager#startBackgroundRunning 11961847f8eSopenharmony_ci */ 12061847f8eSopenharmony_ci function startBackgroundRunning(id: number, request: NotificationRequest): Promise<void>; 12161847f8eSopenharmony_ci 12261847f8eSopenharmony_ci /** 12361847f8eSopenharmony_ci * Cancel background running of this ability to free up system memory. 12461847f8eSopenharmony_ci * 12561847f8eSopenharmony_ci * @param { AsyncCallback<void> } callback - Returns the result of canceling a long-term task in the form of callback. 12661847f8eSopenharmony_ci * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask 12761847f8eSopenharmony_ci * @FAModelOnly 12861847f8eSopenharmony_ci * @since 7 12961847f8eSopenharmony_ci * @deprecated since 9 13061847f8eSopenharmony_ci * @useinstead ohos.resourceschedule.backgroundTaskManager/backgroundTaskManager#stopBackgroundRunning 13161847f8eSopenharmony_ci */ 13261847f8eSopenharmony_ci function cancelBackgroundRunning(callback: AsyncCallback<void>): void; 13361847f8eSopenharmony_ci 13461847f8eSopenharmony_ci /** 13561847f8eSopenharmony_ci * Cancel background running of this ability to free up system memory. 13661847f8eSopenharmony_ci * 13761847f8eSopenharmony_ci * @returns { Promise<void> } the promise returned by the function. 13861847f8eSopenharmony_ci * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask 13961847f8eSopenharmony_ci * @FAModelOnly 14061847f8eSopenharmony_ci * @since 7 14161847f8eSopenharmony_ci * @deprecated since 9 14261847f8eSopenharmony_ci * @useinstead ohos.resourceschedule.backgroundTaskManager/backgroundTaskManager#stopBackgroundRunning 14361847f8eSopenharmony_ci */ 14461847f8eSopenharmony_ci function cancelBackgroundRunning(): Promise<void>; 14561847f8eSopenharmony_ci 14661847f8eSopenharmony_ci /** 14761847f8eSopenharmony_ci * Connects an ability to a Service ability. 14861847f8eSopenharmony_ci * 14961847f8eSopenharmony_ci * @param { Want } request - Indicates the Service ability to connect. 15061847f8eSopenharmony_ci * @param { ConnectOptions } options - Callback object for the client. If this parameter is null, 15161847f8eSopenharmony_ci * an exception is thrown. 15261847f8eSopenharmony_ci * @returns { number } unique identifier of the connection between the client and the service side. 15361847f8eSopenharmony_ci * @syscap SystemCapability.Ability.AbilityRuntime.FAModel 15461847f8eSopenharmony_ci * @FAModelOnly 15561847f8eSopenharmony_ci * @since 7 15661847f8eSopenharmony_ci */ 15761847f8eSopenharmony_ci function connectAbility(request: Want, options: ConnectOptions): number; 15861847f8eSopenharmony_ci 15961847f8eSopenharmony_ci /** 16061847f8eSopenharmony_ci * Disconnects ability to a Service ability. 16161847f8eSopenharmony_ci * 16261847f8eSopenharmony_ci * @param { number } connection - the connection id returned from connectAbility api. 16361847f8eSopenharmony_ci * @param { AsyncCallback<void> } callback - Returns the disconnection result in the form of callback. 16461847f8eSopenharmony_ci * @syscap SystemCapability.Ability.AbilityRuntime.FAModel 16561847f8eSopenharmony_ci * @FAModelOnly 16661847f8eSopenharmony_ci * @since 7 16761847f8eSopenharmony_ci */ 16861847f8eSopenharmony_ci function disconnectAbility(connection: number, callback: AsyncCallback<void>): void; 16961847f8eSopenharmony_ci 17061847f8eSopenharmony_ci /** 17161847f8eSopenharmony_ci * Disconnects ability to a Service ability. 17261847f8eSopenharmony_ci * 17361847f8eSopenharmony_ci * @param { number } connection - the connection id returned from connectAbility api. 17461847f8eSopenharmony_ci * @returns { Promise<void> } the promise returned by the function. 17561847f8eSopenharmony_ci * @syscap SystemCapability.Ability.AbilityRuntime.FAModel 17661847f8eSopenharmony_ci * @FAModelOnly 17761847f8eSopenharmony_ci * @since 7 17861847f8eSopenharmony_ci */ 17961847f8eSopenharmony_ci function disconnectAbility(connection: number): Promise<void>; 18061847f8eSopenharmony_ci 18161847f8eSopenharmony_ci /** 18261847f8eSopenharmony_ci * Obtain the errorCode. 18361847f8eSopenharmony_ci * 18461847f8eSopenharmony_ci * @enum { number } 18561847f8eSopenharmony_ci * @syscap SystemCapability.Ability.AbilityRuntime.FAModel 18661847f8eSopenharmony_ci * @FAModelOnly 18761847f8eSopenharmony_ci * @since 7 18861847f8eSopenharmony_ci */ 18961847f8eSopenharmony_ci export enum ErrorCode { 19061847f8eSopenharmony_ci /** 19161847f8eSopenharmony_ci * Invalid parameter. 19261847f8eSopenharmony_ci * 19361847f8eSopenharmony_ci * @syscap SystemCapability.Ability.AbilityRuntime.FAModel 19461847f8eSopenharmony_ci * @FAModelOnly 19561847f8eSopenharmony_ci * @since 7 19661847f8eSopenharmony_ci */ 19761847f8eSopenharmony_ci INVALID_PARAMETER = -1 19861847f8eSopenharmony_ci } 19961847f8eSopenharmony_ci} 20061847f8eSopenharmony_ciexport default particleAbility; 201