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 */ 15import { AsyncCallback } from './basic'; 16import { Want } from './ability/want'; 17import { StartAbilityParameter } from './ability/startAbilityParameter'; 18import { AbilityResult } from './ability/abilityResult'; 19import { Context } from './app/context'; 20import { DataAbilityHelper } from './ability/dataAbilityHelper'; 21import { ConnectOptions } from './ability/connectOptions'; 22 23/** 24 * A Feature Ability represents an ability with a UI and is designed to interact with users. 25 * @name featureAbility 26 * @since 6 27 * @sysCap AAFwk 28 * @devices phone, tablet 29 * @permission N/A 30 */ 31declare namespace featureAbility { 32 /** 33 * Obtain the want sended from the source ability. 34 * @devices phone, tablet 35 * @since 6 36 * @sysCap AAFwk 37 * @param parameter Indicates the ability to start. 38 * @return - 39 */ 40 function getWant(callback: AsyncCallback<Want>): void; 41 function getWant(): Promise<Want>; 42 43 /** 44 * Starts a new ability. 45 * @devices phone, tablet 46 * @since 6 47 * @sysCap AAFwk 48 * @param parameter Indicates the ability to start. 49 * @return - 50 */ 51 function startAbility(parameter: StartAbilityParameter, callback: AsyncCallback<number>): void; 52 function startAbility(parameter: StartAbilityParameter): Promise<number>; 53 54 /** 55 * Obtains the application context. 56 * 57 * @return Returns the application context. 58 * @since 6 59 */ 60 function getContext(): Context; 61 62 /** 63 * Starts an ability and returns the execution result when the ability is destroyed. 64 * @devices phone, tablet 65 * @since 7 66 * @sysCap AAFwk 67 * @param parameter Indicates the ability to start. 68 * @return - 69 */ 70 function startAbilityForResult(parameter: StartAbilityParameter, callback: AsyncCallback<AbilityResult>): void; 71 function startAbilityForResult(parameter: StartAbilityParameter): Promise<AbilityResult>; 72 73 /** 74 * Sets the result code and data to be returned by this Page ability to the caller 75 * and destroys this Page ability. 76 * @devices phone, tablet 77 * @since 7 78 * @sysCap AAFwk 79 * @param parameter Indicates the result to return. 80 * @return - 81 */ 82 function terminateSelfWithResult(parameter: AbilityResult, callback: AsyncCallback<void>): void; 83 function terminateSelfWithResult(parameter: AbilityResult): Promise<void>; 84 85 /** 86 * Destroys this Page ability. 87 * @devices phone, tablet 88 * @since 7 89 * @sysCap AAFwk 90 * @return - 91 */ 92 function terminateSelf(callback: AsyncCallback<void>): void; 93 94 /** 95 * Obtains the dataAbilityHelper. 96 * @devices phone, tablet 97 * @since 7 98 * @sysCap AAFwk 99 * @param uri Indicates the path of the file to open. 100 * @return Returns the dataAbilityHelper. 101 */ 102 function acquireDataAbilityHelper(uri: string): DataAbilityHelper; 103 104 /** 105 * Checks whether the main window of this ability has window focus. 106 * @devices phone, tablet 107 * @since 7 108 * @sysCap AAFwk 109 */ 110 function hasWindowFocus(callback: AsyncCallback<boolean>): void; 111 function hasWindowFocus(): Promise<boolean>; 112 113 /** 114 * Connects the current ability to an ability using the AbilityInfo.AbilityType.SERVICE template. 115 * @default - 116 * @devices phone, tablet 117 * @since 7 118 * @SysCap aafwk 119 * @param request The element name of the service ability 120 * @param options The remote object instance 121 * @return Returns the number of the ability connected 122 */ 123 function connectAbility(request: Want, options:ConnectOptions ): number; 124 125 /** 126 * The callback interface was connect successfully. 127 * @default - 128 * @devices phone, tablet 129 * @since 7 130 * @SysCap aafwk 131 * @param connection The number of the ability connected 132 */ 133 function disconnectAbility(connection: number, callback:AsyncCallback<void>): void; 134 function disconnectAbility(connection: number): Promise<void>; 135 136 export enum AbilityWindowConfiguration { 137 WINDOW_MODE_UNDEFINED = 0, 138 WINDOW_MODE_FULLSCREEN = 1, 139 WINDOW_MODE_SPLIT_PRIMARY = 100, 140 WINDOW_MODE_SPLIT_SECONDARY = 101, 141 WINDOW_MODE_FLOATING = 102 142 } 143 144 export enum AbilityStartSetting { 145 BOUNDS_KEY = "abilityBounds", 146 WINDOW_MODE_KEY = "windowMode", 147 DISPLAY_ID_KEY = "displayId" 148 } 149} 150export default featureAbility; 151