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