1/* 2 * Copyright (c) 2023 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 16/** 17 * @file 18 * @kit AbilityKit 19 */ 20 21import type { AsyncCallback } from './@ohos.base'; 22import type Want from './@ohos.app.ability.Want'; 23import type { MultiAppMode } from './bundleManager/ApplicationInfo'; 24 25/** 26 * This module provides the capability to manage dialog session. 27 * 28 * @namespace dialogSession 29 * @syscap SystemCapability.Ability.AbilityRuntime.Core 30 * @systemapi 31 * @stagemodelonly 32 * @since 11 33 */ 34declare namespace dialogSession { 35 36 /** 37 * Indicates the ability information displayed in the picker dialog, including bundleName, moduleName, and abilityName. 38 * 39 * @typedef DialogAbilityInfo 40 * @syscap SystemCapability.Ability.AbilityRuntime.Core 41 * @systemapi 42 * @stagemodelonly 43 * @since 11 44 */ 45 export interface DialogAbilityInfo { 46 47 /** 48 * Bundle name 49 * 50 * @type { string } 51 * @syscap SystemCapability.Ability.AbilityRuntime.Core 52 * @systemapi 53 * @stagemodelonly 54 * @since 11 55 */ 56 bundleName: string; 57 58 /** 59 * Module name 60 * 61 * @type { string } 62 * @syscap SystemCapability.Ability.AbilityRuntime.Core 63 * @systemapi 64 * @stagemodelonly 65 * @since 11 66 */ 67 moduleName: string; 68 69 /** 70 * Ability name 71 * 72 * @type { string } 73 * @syscap SystemCapability.Ability.AbilityRuntime.Core 74 * @systemapi 75 * @stagemodelonly 76 * @since 11 77 */ 78 abilityName: string; 79 80 /** 81 * The icon id of ability 82 * 83 * @type { number } 84 * @syscap SystemCapability.Ability.AbilityRuntime.Core 85 * @systemapi 86 * @stagemodelonly 87 * @since 11 88 */ 89 abilityIconId: number; 90 91 /** 92 * The label id of ability 93 * 94 * @type { number } 95 * @syscap SystemCapability.Ability.AbilityRuntime.Core 96 * @systemapi 97 * @stagemodelonly 98 * @since 11 99 */ 100 abilityLabelId: number; 101 102 /** 103 * The icon id of bundle 104 * 105 * @type { number } 106 * @syscap SystemCapability.Ability.AbilityRuntime.Core 107 * @systemapi 108 * @stagemodelonly 109 * @since 11 110 */ 111 bundleIconId: number; 112 113 /** 114 * The label id of bundle 115 * 116 * @type { number } 117 * @syscap SystemCapability.Ability.AbilityRuntime.Core 118 * @systemapi 119 * @stagemodelonly 120 * @since 11 121 */ 122 bundleLabelId: number; 123 124 /** 125 * The ability is visible 126 * 127 * @type { boolean } 128 * @syscap SystemCapability.Ability.AbilityRuntime.Core 129 * @systemapi 130 * @stagemodelonly 131 * @since 12 132 */ 133 visible: boolean; 134 135 /** 136 * Index of an application clone. It takes effect only for cloned applications. 137 * 138 * @type { number } 139 * @syscap SystemCapability.Ability.AbilityRuntime.Core 140 * @systemapi 141 * @stagemodelonly 142 * @since 12 143 */ 144 appIndex: number; 145 146 /** 147 * The mode of the multi-application. 148 * 149 * @type { MultiAppMode } 150 * @syscap SystemCapability.Ability.AbilityRuntime.Core 151 * @systemapi 152 * @stagemodelonly 153 * @since 12 154 */ 155 multiAppMode: MultiAppMode; 156 } 157 158 /** 159 * Dialog session info 160 * 161 * @typedef DialogSessionInfo 162 * @syscap SystemCapability.Ability.AbilityRuntime.Core 163 * @systemapi 164 * @stagemodelonly 165 * @since 11 166 */ 167 export interface DialogSessionInfo { 168 169 /** 170 * The dialog info of caller ability 171 * 172 * @type { DialogAbilityInfo } 173 * @syscap SystemCapability.Ability.AbilityRuntime.Core 174 * @systemapi 175 * @stagemodelonly 176 * @since 11 177 */ 178 callerAbilityInfo: DialogAbilityInfo; 179 180 /** 181 * The dialog infos of target ability to select 182 * 183 * @type { Array<DialogAbilityInfo> } 184 * @syscap SystemCapability.Ability.AbilityRuntime.Core 185 * @systemapi 186 * @stagemodelonly 187 * @since 11 188 */ 189 targetAbilityInfos: Array<DialogAbilityInfo>; 190 191 /** 192 * The description of the params object in dialog session info 193 * 194 * @type { ?Record<string, Object> } 195 * @syscap SystemCapability.Ability.AbilityRuntime.Core 196 * @systemapi 197 * @stagemodelonly 198 * @since 11 199 */ 200 parameters?: Record<string, Object>; 201 } 202 203 /** 204 * Query the session info of dialog. 205 * 206 * @param { string } dialogSessionId - Query information by dialog session id. 207 * @returns { DialogSessionInfo } Returns the session info. 208 * @throws { BusinessError } 202 - The application is not system-app, can not use system-api. 209 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 210 * 2. Incorrect parameter types; 3. Parameter verification failed. 211 * @throws { BusinessError } 16000005 - The specified process does not have the permission. 212 * @throws { BusinessError } 16000006 - Cross-user operations are not allowed. 213 * @throws { BusinessError } 16000050 - Internal error. 214 * @syscap SystemCapability.Ability.AbilityRuntime.Core 215 * @systemapi 216 * @stagemodelonly 217 * @since 11 218 */ 219 function getDialogSessionInfo(dialogSessionId: string): DialogSessionInfo; 220 221 /** 222 * Send the selection result of dialog. 223 * 224 * @param { string } dialogSessionId - Send Result by dialog session id. 225 * @param { Want } targetWant - The selection target ability to start. 226 * @param { boolean } isAllowed - allowed or disallowed to start target ability. 227 * @returns { Promise<void> } The promise returned by the sendDialogResult. 228 * @throws { BusinessError } 202 - The application is not system-app, can not use system-api. 229 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 230 * 2. Incorrect parameter types; 3. Parameter verification failed. 231 * @throws { BusinessError } 16000005 - The specified process does not have the permission. 232 * @throws { BusinessError } 16000006 - Cross-user operations are not allowed. 233 * @throws { BusinessError } 16000050 - Internal error. 234 * @syscap SystemCapability.Ability.AbilityRuntime.Core 235 * @systemapi 236 * @stagemodelonly 237 * @since 11 238 */ 239 function sendDialogResult(dialogSessionId: string, targetWant: Want, isAllowed: boolean): Promise<void>; 240 241 /** 242 * Send the selection result of dialog. 243 * 244 * @param { string } dialogSessionId - Send Result by dialog session id. 245 * @param { Want } targetWant - The selection target ability to start. 246 * @param { boolean } isAllowed - allowed or disallowed to start target ability. 247 * @param { AsyncCallback<void> } callback - The callback of sendDialogResult. 248 * @throws { BusinessError } 202 - The application is not system-app, can not use system-api. 249 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 250 * 2. Incorrect parameter types; 3. Parameter verification failed. 251 * @throws { BusinessError } 16000005 - The specified process does not have the permission. 252 * @throws { BusinessError } 16000006 - Cross-user operations are not allowed. 253 * @throws { BusinessError } 16000050 - Internal error. 254 * @syscap SystemCapability.Ability.AbilityRuntime.Core 255 * @systemapi 256 * @stagemodelonly 257 * @since 11 258 */ 259 function sendDialogResult(dialogSessionId: string, targetWant: Want, isAllowed: boolean, callback: AsyncCallback<void>): void; 260} 261 262export default dialogSession;