1/* 2 * Copyright (c) 2023-2024 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 insightIntent from './@ohos.app.ability.insightIntent'; 23 24/** 25 * Insight intent driver. 26 * 27 * @namespace insightIntentDriver 28 * @syscap SystemCapability.Ability.AbilityRuntime.Core 29 * @systemapi 30 * @StageModelOnly 31 * @since 11 32 */ 33declare namespace insightIntentDriver { 34 /** 35 * Param when execute insight intent. 36 * 37 * @typedef ExecuteParam 38 * @syscap SystemCapability.Ability.AbilityRuntime.Core 39 * @systemapi 40 * @StageModelOnly 41 * @since 11 42 */ 43 interface ExecuteParam { 44 /** 45 * Indicates the bundle name. 46 * 47 * @type { string } 48 * @syscap SystemCapability.Ability.AbilityRuntime.Core 49 * @systemapi 50 * @StageModelOnly 51 * @since 11 52 */ 53 bundleName: string; 54 55 /** 56 * Indicates the module name. 57 * 58 * @type { string } 59 * @syscap SystemCapability.Ability.AbilityRuntime.Core 60 * @systemapi 61 * @StageModelOnly 62 * @since 11 63 */ 64 moduleName: string; 65 66 /** 67 * Indicates the ability name. 68 * 69 * @type { string } 70 * @syscap SystemCapability.Ability.AbilityRuntime.Core 71 * @systemapi 72 * @StageModelOnly 73 * @since 11 74 */ 75 abilityName: string; 76 77 /** 78 * Indicates the insight intent name. 79 * 80 * @type { string } 81 * @syscap SystemCapability.Ability.AbilityRuntime.Core 82 * @systemapi 83 * @StageModelOnly 84 * @since 11 85 */ 86 insightIntentName: string; 87 88 /** 89 * Indicates the insight intent param. 90 * 91 * @type { Record<string, Object> } 92 * @syscap SystemCapability.Ability.AbilityRuntime.Core 93 * @systemapi 94 * @StageModelOnly 95 * @since 11 96 */ 97 insightIntentParam: Record<string, Object>; 98 99 /** 100 * Indicates the execute mode. 101 * 102 * @type { insightIntent.ExecuteMode } 103 * @syscap SystemCapability.Ability.AbilityRuntime.Core 104 * @systemapi 105 * @StageModelOnly 106 * @since 11 107 */ 108 executeMode: insightIntent.ExecuteMode; 109 110 /** 111 * Indicates the display Id, only works when executeMode is UIAbility foreground. 112 * 113 * @type { ?number } 114 * @syscap SystemCapability.Ability.AbilityRuntime.Core 115 * @systemapi 116 * @StageModelOnly 117 * @since 12 118 */ 119 displayId?: number; 120 } 121 122 /** 123 * Execute insight intent. 124 * If the caller application is in foreground, you can use this method to execute insight intent; 125 * If the caller application is in background, you need to apply for permission: ohos.permission.START_ABILITIES_FROM_BACKGROUND. 126 * 127 * @permission ohos.permission.EXECUTE_INSIGHT_INTENT 128 * @param { ExecuteParam } param - Execute parameter. 129 * @param { AsyncCallback<insightIntent.ExecuteResult> } callback - The callback of executeIntent. 130 * @throws { BusinessError } 201 - Permission denied. 131 * @throws { BusinessError } 202 - Not system application. 132 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 133 * 2. Incorrect parameter types. 134 * @throws { BusinessError } 16000001 - The specified ability does not exist. 135 * @throws { BusinessError } 16000002 - Incorrect ability type. 136 * @throws { BusinessError } 16000004 - Can not start invisible component. 137 * @throws { BusinessError } 16000005 - The specified process does not have the permission. 138 * @throws { BusinessError } 16000006 - Cross-user operations are not allowed. 139 * @throws { BusinessError } 16000008 - The crowdtesting application expires. 140 * @throws { BusinessError } 16000009 - An ability cannot be started or stopped in Wukong mode. 141 * @throws { BusinessError } 16000010 - The call with the continuation flag is forbidden. 142 * @throws { BusinessError } 16000011 - The context does not exist. 143 * @throws { BusinessError } 16000012 - The application is controlled. 144 * @throws { BusinessError } 16000013 - The application is controlled by EDM. 145 * @throws { BusinessError } 16000050 - Internal error. 146 * @throws { BusinessError } 16000053 - The ability is not on the top of the UI. 147 * @throws { BusinessError } 16000055 - Installation-free timed out. 148 * @syscap SystemCapability.Ability.AbilityRuntime.Core 149 * @systemapi 150 * @StageModelOnly 151 * @since 11 152 */ 153 function execute(param: ExecuteParam, callback: AsyncCallback<insightIntent.ExecuteResult>): void; 154 155 /** 156 * Execute insight intent. 157 * If the caller application is in foreground, you can use this method to execute insight intent; 158 * If the caller application is in background, you need to apply for permission: ohos.permission.START_ABILITIES_FROM_BACKGROUND. 159 * 160 * @permission ohos.permission.EXECUTE_INSIGHT_INTENT 161 * @param { ExecuteParam } param - Execute parameter. 162 * @returns { Promise<insightIntent.ExecuteResult> } Returns the execute result. 163 * @throws { BusinessError } 201 - Permission denied. 164 * @throws { BusinessError } 202 - Not system application. 165 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 166 * 2. Incorrect parameter types. 167 * @throws { BusinessError } 16000001 - The specified ability does not exist. 168 * @throws { BusinessError } 16000002 - Incorrect ability type. 169 * @throws { BusinessError } 16000004 - Can not start invisible component. 170 * @throws { BusinessError } 16000005 - The specified process does not have the permission. 171 * @throws { BusinessError } 16000006 - Cross-user operations are not allowed. 172 * @throws { BusinessError } 16000008 - The crowdtesting application expires. 173 * @throws { BusinessError } 16000009 - An ability cannot be started or stopped in Wukong mode. 174 * @throws { BusinessError } 16000010 - The call with the continuation flag is forbidden. 175 * @throws { BusinessError } 16000011 - The context does not exist. 176 * @throws { BusinessError } 16000012 - The application is controlled. 177 * @throws { BusinessError } 16000013 - The application is controlled by EDM. 178 * @throws { BusinessError } 16000050 - Internal error. 179 * @throws { BusinessError } 16000053 - The ability is not on the top of the UI. 180 * @throws { BusinessError } 16000055 - Installation-free timed out. 181 * @syscap SystemCapability.Ability.AbilityRuntime.Core 182 * @systemapi 183 * @StageModelOnly 184 * @since 11 185 */ 186 function execute(param: ExecuteParam): Promise<insightIntent.ExecuteResult>; 187} 188 189export default insightIntentDriver; 190