• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2021-2022 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 { Callback } from './basic';
18import Want from './@ohos.app.ability.Want';
19import { StartAbilityParameter } from './ability/startAbilityParameter';
20import { AbilityResult } from './ability/abilityResult';
21import { AppVersionInfo as _AppVersionInfo } from './app/appVersionInfo';
22import { Context as _Context } from './app/context';
23import { DataAbilityHelper } from './ability/dataAbilityHelper';
24import { ConnectOptions } from './ability/connectOptions';
25import { ProcessInfo as _ProcessInfo } from './app/processInfo';
26import window from './@ohos.window';
27
28/**
29 * A Feature Ability represents an ability with a UI and is designed to interact with users.
30 * @name featureAbility
31 * @since 6
32 * @syscap SystemCapability.Ability.AbilityRuntime.FAModel
33 * @permission N/A
34 * @FAModelOnly
35 */
36declare namespace featureAbility {
37  /**
38   * Obtain the want sent from the source ability.
39   *
40   * @since 6
41   * @syscap SystemCapability.Ability.AbilityRuntime.FAModel
42   * @param parameter Indicates the ability to start.
43   * @returns -
44   * @FAModelOnly
45   */
46  function getWant(callback: AsyncCallback<Want>): void;
47  function getWant(): Promise<Want>;
48
49  /**
50   * Starts a new ability.
51   *
52   * @since 6
53   * @syscap SystemCapability.Ability.AbilityRuntime.FAModel
54   * @param parameter Indicates the ability to start.
55   * @returns -
56   * @FAModelOnly
57   */
58  function startAbility(parameter: StartAbilityParameter, callback: AsyncCallback<number>): void;
59  function startAbility(parameter: StartAbilityParameter): Promise<number>;
60
61  /**
62   * Obtains the application context.
63   *
64   * @syscap SystemCapability.Ability.AbilityRuntime.FAModel
65   * @returns Returns the application context.
66   * @since 6
67   * @FAModelOnly
68   */
69  function getContext(): Context;
70
71  /**
72   * Starts an ability and returns the execution result when the ability is destroyed.
73   *
74   * @since 7
75   * @syscap SystemCapability.Ability.AbilityRuntime.FAModel
76   * @param parameter Indicates the ability to start.
77   * @returns Returns the {@link AbilityResult}.
78   * @FAModelOnly
79   */
80  function startAbilityForResult(parameter: StartAbilityParameter, callback: AsyncCallback<AbilityResult>): void;
81  function startAbilityForResult(parameter: StartAbilityParameter): Promise<AbilityResult>;
82
83  /**
84   * Sets the result code and data to be returned by this Page ability to the caller
85   * and destroys this Page ability.
86   *
87   * @since 7
88   * @syscap SystemCapability.Ability.AbilityRuntime.FAModel
89   * @param parameter Indicates the result to return.
90   * @returns -
91   * @FAModelOnly
92   */
93  function terminateSelfWithResult(parameter: AbilityResult, callback: AsyncCallback<void>): void;
94  function terminateSelfWithResult(parameter: AbilityResult): Promise<void>;
95
96  /**
97   * Destroys this Page ability.
98   *
99   * @since 7
100   * @syscap SystemCapability.Ability.AbilityRuntime.FAModel
101   * @returns -
102   * @FAModelOnly
103   */
104  function terminateSelf(callback: AsyncCallback<void>): void;
105  function terminateSelf(): Promise<void>;
106
107  /**
108   * Obtains the dataAbilityHelper.
109   *
110   * @since 7
111   * @syscap SystemCapability.Ability.AbilityRuntime.FAModel
112   * @param uri Indicates the path of the file to open.
113   * @returns Returns the dataAbilityHelper.
114   * @FAModelOnly
115   */
116  function acquireDataAbilityHelper(uri: string): DataAbilityHelper;
117
118   /**
119   * Checks whether the main window of this ability has window focus.
120   *
121   * @since 7
122   * @syscap SystemCapability.Ability.AbilityRuntime.FAModel
123   * @returns Returns {@code true} if this ability currently has window focus; returns {@code false} otherwise.
124   * @FAModelOnly
125   */
126  function hasWindowFocus(callback: AsyncCallback<boolean>): void;
127  function hasWindowFocus(): Promise<boolean>;
128
129  /**
130   * Connects the current ability to an ability using the AbilityInfo.AbilityType.SERVICE template.
131   * @default -
132   * @since 7
133   * @syscap SystemCapability.Ability.AbilityRuntime.FAModel
134   * @param request The element name of the service ability
135   * @param options The remote object instance
136   * @returns Returns the number code of the ability connected
137   * @FAModelOnly
138   */
139  function connectAbility(request: Want, options:ConnectOptions ): number;
140
141  /**
142  * The callback interface was connect successfully.
143  * @default -
144  * @since 7
145  * @syscap SystemCapability.Ability.AbilityRuntime.FAModel
146  * @param connection The number code of the ability connected
147  * @FAModelOnly
148  */
149  function disconnectAbility(connection: number, callback:AsyncCallback<void>): void;
150  function disconnectAbility(connection: number): Promise<void>;
151
152  /**
153   * Obtains the window corresponding to the current ability.
154   *
155   * @since 7
156   * @syscap SystemCapability.Ability.AbilityRuntime.FAModel
157   * @returns Returns the window corresponding to the current ability.
158   * @FAModelOnly
159   */
160  function getWindow(callback: AsyncCallback<window.Window>): void;
161  function getWindow(): Promise<window.Window>;
162
163  /**
164   * Obtain the window configuration.
165   *
166   * @since 7
167   * @syscap SystemCapability.Ability.AbilityRuntime.FAModel
168   * @FAModelOnly
169   */
170  export enum AbilityWindowConfiguration {
171    WINDOW_MODE_UNDEFINED = 0,
172    WINDOW_MODE_FULLSCREEN = 1,
173    WINDOW_MODE_SPLIT_PRIMARY = 100,
174    WINDOW_MODE_SPLIT_SECONDARY = 101,
175    WINDOW_MODE_FLOATING = 102
176  }
177
178  /**
179   * Obtain the window properties.
180   *
181   * @since 7
182   * @syscap SystemCapability.Ability.AbilityRuntime.FAModel
183   * @FAModelOnly
184   */
185  export enum AbilityStartSetting {
186    BOUNDS_KEY = "abilityBounds",
187    WINDOW_MODE_KEY = "windowMode",
188    DISPLAY_ID_KEY = "displayId"
189  }
190
191  /**
192   * Obtain the errorCode.
193   *
194   * @since 7
195   * @syscap SystemCapability.Ability.AbilityRuntime.FAModel
196   * @FAModelOnly
197   */
198  export enum ErrorCode {
199    NO_ERROR = 0,
200    INVALID_PARAMETER = -1,
201    ABILITY_NOT_FOUND = -2,
202    PERMISSION_DENY = -3
203  }
204
205  /**
206   * Indicates the operation type of data.
207   *
208   * @since 7
209   * @syscap SystemCapability.Ability.AbilityRuntime.FAModel
210   * @FAModelOnly
211   */
212  export enum DataAbilityOperationType {
213    TYPE_INSERT = 1,
214    TYPE_UPDATE = 2,
215    TYPE_DELETE = 3,
216    TYPE_ASSERT = 4,
217  }
218
219  /**
220   * The context of an ability or an application.  It allows access to
221   * application-specific resources, request and verification permissions.
222   * Can only be obtained through the ability.
223   *
224   * @since 9
225   * @syscap SystemCapability.Ability.AbilityRuntime.Core
226   * @FAModelOnly
227   */
228  export type Context = _Context
229
230  /**
231   * Defines an AppVersionInfo object.
232   * @since 9
233   * @syscap SystemCapability.Ability.AbilityRuntime.Core
234   */
235  export type AppVersionInfo = _AppVersionInfo
236
237  /**
238   * @name This class saves process information about an application
239   * @since 9
240   * @syscap SystemCapability.Ability.AbilityRuntime.Core
241   */
242  export type ProcessInfo = _ProcessInfo
243}
244export default featureAbility;
245