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 window from './@ohos.window'; 22import type insightIntent from './@ohos.app.ability.insightIntent'; 23import type InsightIntentContext from './@ohos.app.ability.InsightIntentContext'; 24import type UIExtensionContentSession from './@ohos.app.ability.UIExtensionContentSession'; 25 26/** 27 * The class of insight intent executor. 28 * 29 * @syscap SystemCapability.Ability.AbilityRuntime.Core 30 * @StageModelOnly 31 * @atomicservice 32 * @since 11 33 */ 34export default class InsightIntentExecutor { 35 /** 36 * Indicates context of insight intent. 37 * 38 * @type { InsightIntentContext } 39 * @syscap SystemCapability.Ability.AbilityRuntime.Core 40 * @StageModelOnly 41 * @atomicservice 42 * @since 11 43 */ 44 context: InsightIntentContext; 45 46 /** 47 * Called when a UIAbility executes the insight intent in the foreground. 48 * 49 * @param { string } name - Indicates the insight intent name. 50 * @param { Record<string, Object> } param - Indicates the insight intent parameters. 51 * @param { window.WindowStage } pageLoader - Indicates the page loader. 52 * @returns { insightIntent.ExecuteResult | Promise<insightIntent.ExecuteResult> } The result of insight intent execution, support promise. 53 * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore 54 * @StageModelOnly 55 * @atomicservice 56 * @since 11 57 */ 58 onExecuteInUIAbilityForegroundMode(name: string, param: Record<string, Object>, pageLoader: window.WindowStage): 59 insightIntent.ExecuteResult | Promise<insightIntent.ExecuteResult>; 60 61 /** 62 * Called when a UIAbility executes the insight intent in the background. 63 * 64 * @param { string } name - Indicates the insight intent name. 65 * @param { Record<string, Object> } param - Indicates the insight intent parameters. 66 * @returns { insightIntent.ExecuteResult | Promise<insightIntent.ExecuteResult> } The result of insight intent execution, support promise. 67 * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore 68 * @StageModelOnly 69 * @atomicservice 70 * @since 11 71 */ 72 onExecuteInUIAbilityBackgroundMode(name: string, param: Record<string, Object>): 73 insightIntent.ExecuteResult | Promise<insightIntent.ExecuteResult>; 74 75 /** 76 * Called when a UIExtensionAbility executes the insight intent. 77 * 78 * @param { string } name - Indicates the insight intent name. 79 * @param { Record<string, Object> } param - Indicates the insight intent parameters. 80 * @param { UIExtensionContentSession } pageLoader - Indicates the page loader. 81 * @returns { insightIntent.ExecuteResult | Promise<insightIntent.ExecuteResult> } The result of insight intent execution, support promise. 82 * @syscap SystemCapability.Ability.AbilityRuntime.Core 83 * @StageModelOnly 84 * @since 11 85 */ 86 onExecuteInUIExtensionAbility(name: string, param: Record<string, Object>, pageLoader: UIExtensionContentSession): 87 insightIntent.ExecuteResult | Promise<insightIntent.ExecuteResult>; 88 89 /** 90 * Called when a ServiceExtensionAbility executes the insight intent. 91 * 92 * @param { string } name - Indicates the insight intent name. 93 * @param { Record<string, Object> } param - Indicates the insight intent parameters. 94 * @returns { insightIntent.ExecuteResult | Promise<insightIntent.ExecuteResult> } The result of insight intent execution, support promise. 95 * @syscap SystemCapability.Ability.AbilityRuntime.Core 96 * @StageModelOnly 97 * @since 11 98 */ 99 onExecuteInServiceExtensionAbility(name: string, param: Record<string, Object>): 100 insightIntent.ExecuteResult | Promise<insightIntent.ExecuteResult>; 101} 102