• 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 './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   * @return -
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   * @return -
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   * @return 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
76   */
77  function startBackgroundRunning(id: number, request: NotificationRequest, callback: AsyncCallback<void>): void;
78  function startBackgroundRunning(id: number, request: NotificationRequest): Promise<void>;
79
80  /**
81   * Cancel background running of this ability to free up system memory.
82   *
83   * @since 7
84   * @syscap SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask
85   * @FAModelOnly
86   * @deprecated
87   */
88  function cancelBackgroundRunning(callback: AsyncCallback<void>): void;
89  function cancelBackgroundRunning(): Promise<void>;
90
91  /**
92   * Connects an ability to a Service ability.
93   *
94   * @since 7
95   * @syscap SystemCapability.Ability.AbilityRuntime.FAModel
96   * @param request Indicates the Service ability to connect.
97   * @param options Callback object for the client. If this parameter is null, an exception is thrown.
98   * @return unique identifier of the connection between the client and the service side.
99   * @FAModelOnly
100   */
101   function connectAbility(request: Want, options:ConnectOptions): number;
102
103  /**
104  * Disconnects ability to a Service ability.
105  * @since 7
106  * @syscap SystemCapability.Ability.AbilityRuntime.FAModel
107  * @param connection the connection id returned from connectAbility api.
108  * @FAModelOnly
109  */
110   function disconnectAbility(connection: number, callback:AsyncCallback<void>): void;
111   function disconnectAbility(connection: number): Promise<void>;
112
113  /**
114  * Obtain the errorCode.
115  *
116  * @since 7
117  * @syscap SystemCapability.Ability.AbilityRuntime.FAModel
118  * @FAModelOnly
119  */
120  export enum ErrorCode {
121    INVALID_PARAMETER = -1
122  }
123}
124export default particleAbility;
125