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 Want from './@ohos.app.ability.Want'; 22import wantConstant from './@ohos.app.ability.wantConstant'; 23import type { AsyncCallback } from './@ohos.base'; 24import type insightIntent from './@ohos.app.ability.insightIntent'; 25 26/** 27 * Insight intent driver. 28 * 29 * @namespace insightIntentDriver 30 * @syscap SystemCapability.Ability.AbilityRuntime.Core 31 * @systemapi 32 * @StageModelOnly 33 * @since 11 34 */ 35declare namespace insightIntentDriver { 36 /** 37 * Param when execute insight intent. 38 * 39 * @typedef ExecuteParam 40 * @syscap SystemCapability.Ability.AbilityRuntime.Core 41 * @systemapi 42 * @StageModelOnly 43 * @since 11 44 */ 45 interface ExecuteParam { 46 /** 47 * Indicates the 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 * Indicates the 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 * Indicates the 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 * Indicates the insight intent name. 81 * 82 * @type { string } 83 * @syscap SystemCapability.Ability.AbilityRuntime.Core 84 * @systemapi 85 * @StageModelOnly 86 * @since 11 87 */ 88 insightIntentName: string; 89 90 /** 91 * Indicates the insight intent param. 92 * 93 * @type { Record<string, Object> } 94 * @syscap SystemCapability.Ability.AbilityRuntime.Core 95 * @systemapi 96 * @StageModelOnly 97 * @since 11 98 */ 99 insightIntentParam: Record<string, Object>; 100 101 /** 102 * Indicates the execute mode. 103 * 104 * @type { insightIntent.ExecuteMode } 105 * @syscap SystemCapability.Ability.AbilityRuntime.Core 106 * @systemapi 107 * @StageModelOnly 108 * @since 11 109 */ 110 executeMode: insightIntent.ExecuteMode; 111 112 /** 113 * Indicates the display Id, only works when executeMode is UIAbility foreground. 114 * 115 * @type { ?number } 116 * @syscap SystemCapability.Ability.AbilityRuntime.Core 117 * @systemapi 118 * @StageModelOnly 119 * @since 12 120 */ 121 displayId?: number; 122 123 /** 124 * Indicates the URIs will be authorized to the insight intent executor. 125 * 126 * @type { ?Array<string> } 127 * @syscap SystemCapability.Ability.AbilityRuntime.Core 128 * @systemapi 129 * @stagemodelonly 130 * @since 18 131 */ 132 uris?: Array<string>; 133 134 /** 135 * Indicates the URIs read and write permissions which consistent with {@link Want#flags}, 136 * flags must be one of {@link wantConstant#Flags#FLAG_AUTH_READ_URI_PERMISSION}, 137 * {@link wantConstant#Flags#FLAG_AUTH_WRITE_URI_PERMISSION}, 138 * {@link wantConstant#Flags#FLAG_AUTH_READ_URI_PERMISSION}| 139 * {@link wantConstant#Flags#FLAG_AUTH_WRITE_URI_PERMISSION}. 140 * 141 * @type { ?number } 142 * @syscap SystemCapability.Ability.AbilityRuntime.Core 143 * @systemapi 144 * @stagemodelonly 145 * @since 18 146 */ 147 flags?: number; 148 } 149 150 /** 151 * Execute insight intent. 152 * If the caller application is in foreground, you can use this method to execute insight intent; 153 * If the caller application is in background, you need to apply for permission: ohos.permission.START_ABILITIES_FROM_BACKGROUND; 154 * If the execute mode is UI_ABILITY_BACKGROUND, you need to apply for permission: ohos.permission.ABILITY_BACKGROUND_COMMUNICATION. 155 * 156 * @permission ohos.permission.EXECUTE_INSIGHT_INTENT 157 * @param { ExecuteParam } param - Execute parameter. 158 * @param { AsyncCallback<insightIntent.ExecuteResult> } callback - The callback of executeIntent. 159 * @throws { BusinessError } 201 - Permission denied. 160 * @throws { BusinessError } 202 - Not system application. 161 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 162 * 2. Incorrect parameter types. 163 * @throws { BusinessError } 16000001 - The specified ability does not exist. 164 * @throws { BusinessError } 16000002 - Incorrect ability type. 165 * @throws { BusinessError } 16000004 - Failed to start the invisible ability. 166 * @throws { BusinessError } 16000005 - The specified process does not have the permission. 167 * @throws { BusinessError } 16000006 - Cross-user operations are not allowed. 168 * @throws { BusinessError } 16000008 - The crowdtesting application expires. 169 * @throws { BusinessError } 16000009 - An ability cannot be started or stopped in Wukong mode. 170 * @throws { BusinessError } 16000010 - The call with the continuation flag is forbidden. 171 * @throws { BusinessError } 16000011 - The context does not exist. 172 * @throws { BusinessError } 16000012 - The application is controlled. 173 * @throws { BusinessError } 16000013 - The application is controlled by EDM. 174 * @throws { BusinessError } 16000050 - Internal error. 175 * @throws { BusinessError } 16000053 - The ability is not on the top of the UI. 176 * @throws { BusinessError } 16000055 - Installation-free timed out. 177 * @syscap SystemCapability.Ability.AbilityRuntime.Core 178 * @systemapi 179 * @StageModelOnly 180 * @since 11 181 */ 182 function execute(param: ExecuteParam, callback: AsyncCallback<insightIntent.ExecuteResult>): void; 183 184 /** 185 * Execute insight intent. 186 * If the caller application is in foreground, you can use this method to execute insight intent; 187 * If the caller application is in background, you need to apply for permission: ohos.permission.START_ABILITIES_FROM_BACKGROUND; 188 * If the execute mode is UI_ABILITY_BACKGROUND, you need to apply for permission: ohos.permission.ABILITY_BACKGROUND_COMMUNICATION. 189 * 190 * @permission ohos.permission.EXECUTE_INSIGHT_INTENT 191 * @param { ExecuteParam } param - Execute parameter. 192 * @returns { Promise<insightIntent.ExecuteResult> } Returns the execute result. 193 * @throws { BusinessError } 201 - Permission denied. 194 * @throws { BusinessError } 202 - Not system application. 195 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 196 * 2. Incorrect parameter types. 197 * @throws { BusinessError } 16000001 - The specified ability does not exist. 198 * @throws { BusinessError } 16000002 - Incorrect ability type. 199 * @throws { BusinessError } 16000004 - Failed to start the invisible ability. 200 * @throws { BusinessError } 16000005 - The specified process does not have the permission. 201 * @throws { BusinessError } 16000006 - Cross-user operations are not allowed. 202 * @throws { BusinessError } 16000008 - The crowdtesting application expires. 203 * @throws { BusinessError } 16000009 - An ability cannot be started or stopped in Wukong mode. 204 * @throws { BusinessError } 16000010 - The call with the continuation flag is forbidden. 205 * @throws { BusinessError } 16000011 - The context does not exist. 206 * @throws { BusinessError } 16000012 - The application is controlled. 207 * @throws { BusinessError } 16000013 - The application is controlled by EDM. 208 * @throws { BusinessError } 16000050 - Internal error. 209 * @throws { BusinessError } 16000053 - The ability is not on the top of the UI. 210 * @throws { BusinessError } 16000055 - Installation-free timed out. 211 * @syscap SystemCapability.Ability.AbilityRuntime.Core 212 * @systemapi 213 * @StageModelOnly 214 * @since 11 215 */ 216 function execute(param: ExecuteParam): Promise<insightIntent.ExecuteResult>; 217} 218 219export default insightIntentDriver; 220