• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2021 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 *     http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16import { AsyncCallback } from './basic';
17import { StartAbilityParameter } from './ability/startAbilityParameter';
18import { DataAbilityHelper } from './ability/dataAbilityHelper';
19import { NotificationRequest } from './notification/notificationRequest';
20import { ConnectOptions } from './ability/connectOptions';
21import Want from './@ohos.app.ability.Want';
22
23/**
24 * A Particle Ability represents an ability with service.
25 * @name particleAbility
26 * @since 7
27 * @syscap SystemCapability.Ability.AbilityRuntime.FAModel
28 * @permission N/A
29 * @FAModelOnly
30 */
31declare namespace particleAbility {
32  /**
33   * Service ability uses this method to start a specific ability.
34   *
35   * @since 7
36   * @syscap SystemCapability.Ability.AbilityRuntime.FAModel
37   * @param parameter Indicates the ability to start.
38   * @returns -
39   * @FAModelOnly
40   */
41  function startAbility(parameter: StartAbilityParameter, callback: AsyncCallback<void>): void;
42  function startAbility(parameter: StartAbilityParameter): Promise<void>;
43
44  /**
45   * Destroys this service ability.
46   *
47   * @since 7
48   * @syscap SystemCapability.Ability.AbilityRuntime.FAModel
49   * @returns -
50   * @FAModelOnly
51   */
52  function terminateSelf(callback: AsyncCallback<void>): void;
53  function terminateSelf(): Promise<void>;
54
55  /**
56   * Obtains the dataAbilityHelper.
57   *
58   * @since 7
59   * @syscap SystemCapability.Ability.AbilityRuntime.FAModel
60   * @param uri Indicates the path of the file to open.
61   * @returns Returns the dataAbilityHelper.
62   * @FAModelOnly
63   */
64  function acquireDataAbilityHelper(uri: string): DataAbilityHelper;
65
66  /**
67   * Keep this Service ability in the background and display a notification bar.
68   *
69   * @since 7
70   * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask
71   * @permission ohos.permission.KEEP_BACKGROUND_RUNNING
72   * @param id Identifies the notification bar information.
73   * @param request Indicates the notificationRequest instance containing information for displaying a notification bar.
74   * @FAModelOnly
75   * @deprecated since 9
76   * @useinstead ohos.resourceschedule.backgroundTaskManager.startBackgroundRunning
77   */
78  function startBackgroundRunning(id: number, request: NotificationRequest, callback: AsyncCallback<void>): void;
79  function startBackgroundRunning(id: number, request: NotificationRequest): Promise<void>;
80
81  /**
82   * Cancel background running of this ability to free up system memory.
83   *
84   * @since 7
85   * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask
86   * @FAModelOnly
87   * @deprecated since 9
88   * @useinstead ohos.resourceschedule.backgroundTaskManager.stopBackgroundRunning
89   */
90  function cancelBackgroundRunning(callback: AsyncCallback<void>): void;
91  function cancelBackgroundRunning(): Promise<void>;
92
93  /**
94   * Connects an ability to a Service ability.
95   *
96   * @since 7
97   * @syscap SystemCapability.Ability.AbilityRuntime.FAModel
98   * @param request Indicates the Service ability to connect.
99   * @param options Callback object for the client. If this parameter is null, an exception is thrown.
100   * @returns unique identifier of the connection between the client and the service side.
101   * @FAModelOnly
102   */
103   function connectAbility(request: Want, options:ConnectOptions): number;
104
105  /**
106  * Disconnects ability to a Service ability.
107  * @since 7
108  * @syscap SystemCapability.Ability.AbilityRuntime.FAModel
109  * @param connection the connection id returned from connectAbility api.
110  * @FAModelOnly
111  */
112   function disconnectAbility(connection: number, callback:AsyncCallback<void>): void;
113   function disconnectAbility(connection: number): Promise<void>;
114
115  /**
116  * Obtain the errorCode.
117  *
118  * @since 7
119  * @syscap SystemCapability.Ability.AbilityRuntime.FAModel
120  * @FAModelOnly
121  */
122  export enum ErrorCode {
123    INVALID_PARAMETER = -1
124  }
125}
126export default particleAbility;
127