161847f8eSopenharmony_ci/*
261847f8eSopenharmony_ci * Copyright (c) 2023 Huawei Device Co., Ltd.
361847f8eSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"),
461847f8eSopenharmony_ci * you may not use this file except in compliance with the License.
561847f8eSopenharmony_ci * You may obtain a copy of the License at
661847f8eSopenharmony_ci *
761847f8eSopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
861847f8eSopenharmony_ci *
961847f8eSopenharmony_ci * Unless required by applicable law or agreed to in writing, software
1061847f8eSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
1161847f8eSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1261847f8eSopenharmony_ci * See the License for the specific language governing permissions and
1361847f8eSopenharmony_ci * limitations under the License.
1461847f8eSopenharmony_ci */
1561847f8eSopenharmony_ci
1661847f8eSopenharmony_ci/**
1761847f8eSopenharmony_ci * @file
1861847f8eSopenharmony_ci * @kit AbilityKit
1961847f8eSopenharmony_ci */
2061847f8eSopenharmony_ci
2161847f8eSopenharmony_ciimport type { AsyncCallback } from './@ohos.base';
2261847f8eSopenharmony_ciimport type Want from './@ohos.app.ability.Want';
2361847f8eSopenharmony_ciimport type { MultiAppMode } from './bundleManager/ApplicationInfo';
2461847f8eSopenharmony_ci
2561847f8eSopenharmony_ci/**
2661847f8eSopenharmony_ci * This module provides the capability to manage dialog session.
2761847f8eSopenharmony_ci *
2861847f8eSopenharmony_ci * @namespace dialogSession
2961847f8eSopenharmony_ci * @syscap SystemCapability.Ability.AbilityRuntime.Core
3061847f8eSopenharmony_ci * @systemapi
3161847f8eSopenharmony_ci * @stagemodelonly
3261847f8eSopenharmony_ci * @since 11
3361847f8eSopenharmony_ci */
3461847f8eSopenharmony_cideclare namespace dialogSession {
3561847f8eSopenharmony_ci
3661847f8eSopenharmony_ci  /**
3761847f8eSopenharmony_ci   * Indicates the ability information displayed in the picker dialog, including bundleName, moduleName, and abilityName.
3861847f8eSopenharmony_ci   *
3961847f8eSopenharmony_ci   * @typedef DialogAbilityInfo
4061847f8eSopenharmony_ci   * @syscap SystemCapability.Ability.AbilityRuntime.Core
4161847f8eSopenharmony_ci   * @systemapi
4261847f8eSopenharmony_ci   * @stagemodelonly
4361847f8eSopenharmony_ci   * @since 11
4461847f8eSopenharmony_ci   */
4561847f8eSopenharmony_ci  export interface DialogAbilityInfo {
4661847f8eSopenharmony_ci
4761847f8eSopenharmony_ci    /**
4861847f8eSopenharmony_ci     * Bundle name
4961847f8eSopenharmony_ci     *
5061847f8eSopenharmony_ci     * @type { string }
5161847f8eSopenharmony_ci     * @syscap SystemCapability.Ability.AbilityRuntime.Core
5261847f8eSopenharmony_ci     * @systemapi
5361847f8eSopenharmony_ci     * @stagemodelonly
5461847f8eSopenharmony_ci     * @since 11
5561847f8eSopenharmony_ci     */
5661847f8eSopenharmony_ci    bundleName: string;
5761847f8eSopenharmony_ci
5861847f8eSopenharmony_ci    /**
5961847f8eSopenharmony_ci     * Module name
6061847f8eSopenharmony_ci     *
6161847f8eSopenharmony_ci     * @type { string }
6261847f8eSopenharmony_ci     * @syscap SystemCapability.Ability.AbilityRuntime.Core
6361847f8eSopenharmony_ci     * @systemapi
6461847f8eSopenharmony_ci     * @stagemodelonly
6561847f8eSopenharmony_ci     * @since 11
6661847f8eSopenharmony_ci     */
6761847f8eSopenharmony_ci    moduleName: string;
6861847f8eSopenharmony_ci
6961847f8eSopenharmony_ci    /**
7061847f8eSopenharmony_ci     * Ability name
7161847f8eSopenharmony_ci     *
7261847f8eSopenharmony_ci     * @type { string }
7361847f8eSopenharmony_ci     * @syscap SystemCapability.Ability.AbilityRuntime.Core
7461847f8eSopenharmony_ci     * @systemapi
7561847f8eSopenharmony_ci     * @stagemodelonly
7661847f8eSopenharmony_ci     * @since 11
7761847f8eSopenharmony_ci     */
7861847f8eSopenharmony_ci    abilityName: string;
7961847f8eSopenharmony_ci
8061847f8eSopenharmony_ci    /**
8161847f8eSopenharmony_ci     * The icon id of ability
8261847f8eSopenharmony_ci     *
8361847f8eSopenharmony_ci     * @type { number }
8461847f8eSopenharmony_ci     * @syscap SystemCapability.Ability.AbilityRuntime.Core
8561847f8eSopenharmony_ci     * @systemapi
8661847f8eSopenharmony_ci     * @stagemodelonly
8761847f8eSopenharmony_ci     * @since 11
8861847f8eSopenharmony_ci     */
8961847f8eSopenharmony_ci    abilityIconId: number;
9061847f8eSopenharmony_ci
9161847f8eSopenharmony_ci    /**
9261847f8eSopenharmony_ci     * The label id of ability
9361847f8eSopenharmony_ci     *
9461847f8eSopenharmony_ci     * @type { number }
9561847f8eSopenharmony_ci     * @syscap SystemCapability.Ability.AbilityRuntime.Core
9661847f8eSopenharmony_ci     * @systemapi
9761847f8eSopenharmony_ci     * @stagemodelonly
9861847f8eSopenharmony_ci     * @since 11
9961847f8eSopenharmony_ci     */
10061847f8eSopenharmony_ci    abilityLabelId: number;
10161847f8eSopenharmony_ci
10261847f8eSopenharmony_ci    /**
10361847f8eSopenharmony_ci     * The icon id of bundle
10461847f8eSopenharmony_ci     *
10561847f8eSopenharmony_ci     * @type { number }
10661847f8eSopenharmony_ci     * @syscap SystemCapability.Ability.AbilityRuntime.Core
10761847f8eSopenharmony_ci     * @systemapi
10861847f8eSopenharmony_ci     * @stagemodelonly
10961847f8eSopenharmony_ci     * @since 11
11061847f8eSopenharmony_ci     */
11161847f8eSopenharmony_ci    bundleIconId: number;
11261847f8eSopenharmony_ci
11361847f8eSopenharmony_ci    /**
11461847f8eSopenharmony_ci     * The label id of bundle
11561847f8eSopenharmony_ci     *
11661847f8eSopenharmony_ci     * @type { number }
11761847f8eSopenharmony_ci     * @syscap SystemCapability.Ability.AbilityRuntime.Core
11861847f8eSopenharmony_ci     * @systemapi
11961847f8eSopenharmony_ci     * @stagemodelonly
12061847f8eSopenharmony_ci     * @since 11
12161847f8eSopenharmony_ci     */
12261847f8eSopenharmony_ci    bundleLabelId: number;
12361847f8eSopenharmony_ci
12461847f8eSopenharmony_ci    /**
12561847f8eSopenharmony_ci     * The ability is visible
12661847f8eSopenharmony_ci     *
12761847f8eSopenharmony_ci     * @type { boolean }
12861847f8eSopenharmony_ci     * @syscap SystemCapability.Ability.AbilityRuntime.Core
12961847f8eSopenharmony_ci     * @systemapi
13061847f8eSopenharmony_ci     * @stagemodelonly
13161847f8eSopenharmony_ci     * @since 12
13261847f8eSopenharmony_ci     */
13361847f8eSopenharmony_ci    visible: boolean;
13461847f8eSopenharmony_ci
13561847f8eSopenharmony_ci    /**
13661847f8eSopenharmony_ci     * Index of an application clone. It takes effect only for cloned applications.
13761847f8eSopenharmony_ci     *
13861847f8eSopenharmony_ci     * @type { number }
13961847f8eSopenharmony_ci     * @syscap SystemCapability.Ability.AbilityRuntime.Core
14061847f8eSopenharmony_ci     * @systemapi
14161847f8eSopenharmony_ci     * @stagemodelonly
14261847f8eSopenharmony_ci     * @since 12
14361847f8eSopenharmony_ci     */
14461847f8eSopenharmony_ci    appIndex: number;
14561847f8eSopenharmony_ci
14661847f8eSopenharmony_ci    /**
14761847f8eSopenharmony_ci      * The mode of the multi-application.
14861847f8eSopenharmony_ci      *
14961847f8eSopenharmony_ci      * @type { MultiAppMode }
15061847f8eSopenharmony_ci      * @syscap SystemCapability.Ability.AbilityRuntime.Core
15161847f8eSopenharmony_ci      * @systemapi
15261847f8eSopenharmony_ci      * @stagemodelonly
15361847f8eSopenharmony_ci      * @since 12
15461847f8eSopenharmony_ci      */
15561847f8eSopenharmony_ci    multiAppMode: MultiAppMode;
15661847f8eSopenharmony_ci  }
15761847f8eSopenharmony_ci
15861847f8eSopenharmony_ci  /**
15961847f8eSopenharmony_ci   * Dialog session info
16061847f8eSopenharmony_ci   *
16161847f8eSopenharmony_ci   * @typedef DialogSessionInfo
16261847f8eSopenharmony_ci   * @syscap SystemCapability.Ability.AbilityRuntime.Core
16361847f8eSopenharmony_ci   * @systemapi
16461847f8eSopenharmony_ci   * @stagemodelonly
16561847f8eSopenharmony_ci   * @since 11
16661847f8eSopenharmony_ci   */
16761847f8eSopenharmony_ci  export interface DialogSessionInfo {
16861847f8eSopenharmony_ci
16961847f8eSopenharmony_ci    /**
17061847f8eSopenharmony_ci     * The dialog info of caller ability
17161847f8eSopenharmony_ci     *
17261847f8eSopenharmony_ci     * @type { DialogAbilityInfo }
17361847f8eSopenharmony_ci     * @syscap SystemCapability.Ability.AbilityRuntime.Core
17461847f8eSopenharmony_ci     * @systemapi
17561847f8eSopenharmony_ci     * @stagemodelonly
17661847f8eSopenharmony_ci     * @since 11
17761847f8eSopenharmony_ci     */
17861847f8eSopenharmony_ci    callerAbilityInfo: DialogAbilityInfo;
17961847f8eSopenharmony_ci
18061847f8eSopenharmony_ci    /**
18161847f8eSopenharmony_ci     * The dialog infos of target ability to select
18261847f8eSopenharmony_ci     *
18361847f8eSopenharmony_ci     * @type { Array<DialogAbilityInfo> }
18461847f8eSopenharmony_ci     * @syscap SystemCapability.Ability.AbilityRuntime.Core
18561847f8eSopenharmony_ci     * @systemapi
18661847f8eSopenharmony_ci     * @stagemodelonly
18761847f8eSopenharmony_ci     * @since 11
18861847f8eSopenharmony_ci     */
18961847f8eSopenharmony_ci    targetAbilityInfos: Array<DialogAbilityInfo>;
19061847f8eSopenharmony_ci
19161847f8eSopenharmony_ci    /**
19261847f8eSopenharmony_ci     * The description of the params object in dialog session info
19361847f8eSopenharmony_ci     *
19461847f8eSopenharmony_ci     * @type { ?Record<string, Object> }
19561847f8eSopenharmony_ci     * @syscap SystemCapability.Ability.AbilityRuntime.Core
19661847f8eSopenharmony_ci     * @systemapi
19761847f8eSopenharmony_ci     * @stagemodelonly
19861847f8eSopenharmony_ci     * @since 11
19961847f8eSopenharmony_ci     */
20061847f8eSopenharmony_ci    parameters?: Record<string, Object>;
20161847f8eSopenharmony_ci  }
20261847f8eSopenharmony_ci
20361847f8eSopenharmony_ci  /**
20461847f8eSopenharmony_ci   * Query the session info of dialog.
20561847f8eSopenharmony_ci   *
20661847f8eSopenharmony_ci   * @param { string } dialogSessionId - Query information by dialog session id.
20761847f8eSopenharmony_ci   * @returns { DialogSessionInfo } Returns the session info.
20861847f8eSopenharmony_ci   * @throws { BusinessError } 202 - The application is not system-app, can not use system-api.
20961847f8eSopenharmony_ci   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
21061847f8eSopenharmony_ci   * 2. Incorrect parameter types; 3. Parameter verification failed.
21161847f8eSopenharmony_ci   * @throws { BusinessError } 16000005 - The specified process does not have the permission.
21261847f8eSopenharmony_ci   * @throws { BusinessError } 16000006 - Cross-user operations are not allowed.
21361847f8eSopenharmony_ci   * @throws { BusinessError } 16000050 - Internal error.
21461847f8eSopenharmony_ci   * @syscap SystemCapability.Ability.AbilityRuntime.Core
21561847f8eSopenharmony_ci   * @systemapi
21661847f8eSopenharmony_ci   * @stagemodelonly
21761847f8eSopenharmony_ci   * @since 11
21861847f8eSopenharmony_ci   */
21961847f8eSopenharmony_ci  function getDialogSessionInfo(dialogSessionId: string): DialogSessionInfo;
22061847f8eSopenharmony_ci
22161847f8eSopenharmony_ci  /**
22261847f8eSopenharmony_ci   * Send the selection result of dialog.
22361847f8eSopenharmony_ci   *
22461847f8eSopenharmony_ci   * @param { string } dialogSessionId - Send Result by dialog session id.
22561847f8eSopenharmony_ci   * @param { Want } targetWant - The selection target ability to start.
22661847f8eSopenharmony_ci   * @param { boolean } isAllowed - allowed or disallowed to start target ability.
22761847f8eSopenharmony_ci   * @returns { Promise<void> } The promise returned by the sendDialogResult.
22861847f8eSopenharmony_ci   * @throws { BusinessError } 202 - The application is not system-app, can not use system-api.
22961847f8eSopenharmony_ci   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
23061847f8eSopenharmony_ci   * 2. Incorrect parameter types; 3. Parameter verification failed.
23161847f8eSopenharmony_ci   * @throws { BusinessError } 16000005 - The specified process does not have the permission.
23261847f8eSopenharmony_ci   * @throws { BusinessError } 16000006 - Cross-user operations are not allowed.
23361847f8eSopenharmony_ci   * @throws { BusinessError } 16000050 - Internal error.
23461847f8eSopenharmony_ci   * @syscap SystemCapability.Ability.AbilityRuntime.Core
23561847f8eSopenharmony_ci   * @systemapi
23661847f8eSopenharmony_ci   * @stagemodelonly
23761847f8eSopenharmony_ci   * @since 11
23861847f8eSopenharmony_ci   */
23961847f8eSopenharmony_ci  function sendDialogResult(dialogSessionId: string, targetWant: Want, isAllowed: boolean): Promise<void>;
24061847f8eSopenharmony_ci
24161847f8eSopenharmony_ci  /**
24261847f8eSopenharmony_ci   * Send the selection result of dialog.
24361847f8eSopenharmony_ci   *
24461847f8eSopenharmony_ci   * @param { string } dialogSessionId - Send Result by dialog session id.
24561847f8eSopenharmony_ci   * @param { Want } targetWant - The selection target ability to start.
24661847f8eSopenharmony_ci   * @param { boolean } isAllowed - allowed or disallowed to start target ability.
24761847f8eSopenharmony_ci   * @param { AsyncCallback<void> } callback - The callback of sendDialogResult.
24861847f8eSopenharmony_ci   * @throws { BusinessError } 202 - The application is not system-app, can not use system-api.
24961847f8eSopenharmony_ci   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
25061847f8eSopenharmony_ci   * 2. Incorrect parameter types; 3. Parameter verification failed.
25161847f8eSopenharmony_ci   * @throws { BusinessError } 16000005 - The specified process does not have the permission.
25261847f8eSopenharmony_ci   * @throws { BusinessError } 16000006 - Cross-user operations are not allowed.
25361847f8eSopenharmony_ci   * @throws { BusinessError } 16000050 - Internal error.
25461847f8eSopenharmony_ci   * @syscap SystemCapability.Ability.AbilityRuntime.Core
25561847f8eSopenharmony_ci   * @systemapi
25661847f8eSopenharmony_ci   * @stagemodelonly
25761847f8eSopenharmony_ci   * @since 11
25861847f8eSopenharmony_ci   */
25961847f8eSopenharmony_ci  function sendDialogResult(dialogSessionId: string, targetWant: Want, isAllowed: boolean, callback: AsyncCallback<void>): void;
26061847f8eSopenharmony_ci}
26161847f8eSopenharmony_ci
26261847f8eSopenharmony_ciexport default dialogSession;