1/* 2 * Copyright (c) 2022 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 { AsyncCallback } from './@ohos.base'; 22import type { ElementName } from './bundleManager/ElementName'; 23import Want from './@ohos.app.ability.Want'; 24 25/** 26 * Used for application interception control 27 * 28 * @namespace appControl 29 * @syscap SystemCapability.BundleManager.BundleFramework.AppControl 30 * @systemapi 31 * @since 9 32 */ 33declare namespace appControl { 34 /** 35 * Indicates the ability component type. 36 * 37 * @enum { number } 38 * @syscap SystemCapability.BundleManager.BundleFramework.AppControl 39 * @systemapi 40 * @since 11 41 */ 42 export enum ComponentType { 43 /** 44 * Indicates the UI ability type. 45 * 46 * @syscap SystemCapability.BundleManager.BundleFramework.AppControl 47 * @systemapi 48 * @since 11 49 */ 50 UI_ABILITY = 1, 51 52 /** 53 * Indicates the extension ability type. 54 * 55 * @syscap SystemCapability.BundleManager.BundleFramework.AppControl 56 * @systemapi 57 * @since 11 58 */ 59 UI_EXTENSION = 2 60 } 61 62 /** 63 * Indicates when to intercept the specified application. 64 * 65 * @enum { number } 66 * @syscap SystemCapability.BundleManager.BundleFramework.AppControl 67 * @systemapi 68 * @since 11 69 */ 70 export enum DisposedType { 71 /** 72 * All abilities will be blocked. 73 * 74 * @syscap SystemCapability.BundleManager.BundleFramework.AppControl 75 * @systemapi 76 * @since 11 77 */ 78 BLOCK_APPLICATION = 1, 79 /** 80 * Only the specified abilities will be blocked. 81 * 82 * @syscap SystemCapability.BundleManager.BundleFramework.AppControl 83 * @systemapi 84 * @since 11 85 */ 86 BLOCK_ABILITY = 2, 87 /** 88 * All abilities will not be blocked. 89 * 90 * @syscap SystemCapability.BundleManager.BundleFramework.AppControl 91 * @systemapi 92 * @since 11 93 */ 94 NON_BLOCK = 3 95 } 96 97 /** 98 * Indicates the strategy to intercept the specified application. 99 * 100 * @enum { number } 101 * @syscap SystemCapability.BundleManager.BundleFramework.AppControl 102 * @systemapi 103 * @since 11 104 */ 105 export enum ControlType { 106 /** 107 * Only the specified abilities are allowed to run. 108 * 109 * @syscap SystemCapability.BundleManager.BundleFramework.AppControl 110 * @systemapi 111 * @since 11 112 */ 113 ALLOWED_LIST = 1, 114 /** 115 * The specified abilities are not allowed to run. 116 * 117 * @syscap SystemCapability.BundleManager.BundleFramework.AppControl 118 * @systemapi 119 * @since 11 120 */ 121 DISALLOWED_LIST = 2 122 } 123 124 /** 125 * Indicates the rule for interception. 126 * 127 * @typedef DisposedRule 128 * @syscap SystemCapability.BundleManager.BundleFramework.AppControl 129 * @systemapi 130 * @since 11 131 */ 132 export interface DisposedRule { 133 /** 134 * Indicates the ability that will be pulled up when interception occurs. 135 * 136 * @type { Want } 137 * @syscap SystemCapability.BundleManager.BundleFramework.AppControl 138 * @systemapi 139 * @since 11 140 */ 141 want: Want; 142 143 /** 144 * Indicates the type of the ability that will be pulled up when interception occurs. 145 * 146 * @type { ComponentType } 147 * @syscap SystemCapability.BundleManager.BundleFramework.AppControl 148 * @systemapi 149 * @since 11 150 */ 151 componentType: ComponentType; 152 153 /** 154 * Indicates when to intercept the specified application. 155 * 156 * @type { DisposedType } 157 * @syscap SystemCapability.BundleManager.BundleFramework.AppControl 158 * @systemapi 159 * @since 11 160 */ 161 disposedType: DisposedType; 162 163 /** 164 * Indicates the interception policy. 165 * 166 * @type { ControlType } 167 * @syscap SystemCapability.BundleManager.BundleFramework.AppControl 168 * @systemapi 169 * @since 11 170 */ 171 controlType: ControlType; 172 173 /** 174 * Indicates the abilities to be disposed of the specified application. 175 * 176 * @type { Array<ElementName> } 177 * @syscap SystemCapability.BundleManager.BundleFramework.AppControl 178 * @systemapi 179 * @since 11 180 */ 181 elementList: Array<ElementName> ; 182 183 /** 184 * Indicates priority of the rule. 185 * 186 * @type { number } 187 * @syscap SystemCapability.BundleManager.BundleFramework.AppControl 188 * @systemapi 189 * @since 11 190 */ 191 priority: number; 192 } 193 194 /** 195 * Set the disposed status of a specified bundle. 196 * 197 * @permission ohos.permission.MANAGE_DISPOSED_APP_STATUS 198 * @param { string } appId - Indicates the app ID of the application. 199 * @param { Want } disposedWant - Indicates the disposed want. 200 * @param { AsyncCallback<void> } callback - The callback of setting the disposed status result. 201 * @throws { BusinessError } 201 - Permission denied. 202 * @throws { BusinessError } 202 - Permission denied, non-system app called system api. 203 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. 204 * @throws { BusinessError } 801 - Capability not supported. 205 * @throws { BusinessError } 17700005 - The specified app ID is empty string. 206 * @syscap SystemCapability.BundleManager.BundleFramework.AppControl 207 * @systemapi 208 * @since 9 209 */ 210 function setDisposedStatus(appId: string, disposedWant: Want, callback: AsyncCallback<void>): void; 211 212 /** 213 * Set the disposed status of a specified bundle. 214 * 215 * @permission ohos.permission.MANAGE_DISPOSED_APP_STATUS 216 * @param { string } appId - Indicates the app ID of the application. 217 * @param { Want } disposedWant - Indicates the disposed want. 218 * @returns { Promise<void> } The result of setting the disposed status of a specified bundle. 219 * @throws { BusinessError } 201 - Permission denied. 220 * @throws { BusinessError } 202 - Permission denied, non-system app called system api. 221 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. 222 * @throws { BusinessError } 801 - Capability not supported. 223 * @throws { BusinessError } 17700005 - The specified app ID is empty string. 224 * @syscap SystemCapability.BundleManager.BundleFramework.AppControl 225 * @systemapi 226 * @since 9 227 */ 228 function setDisposedStatus(appId: string, disposedWant: Want): Promise<void>; 229 230 /** 231 * Set the disposed status of a specified bundle. 232 * 233 * @permission ohos.permission.MANAGE_DISPOSED_APP_STATUS 234 * @param { string } appId - Indicates the app ID of the application. 235 * @param { Want } disposedWant - Indicates the disposed want. 236 * @throws { BusinessError } 201 - Permission denied. 237 * @throws { BusinessError } 202 - Permission denied, non-system app called system api. 238 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. 239 * @throws { BusinessError } 801 - Capability not supported. 240 * @throws { BusinessError } 17700005 - The specified app ID is empty string. 241 * @syscap SystemCapability.BundleManager.BundleFramework.AppControl 242 * @systemapi 243 * @since 10 244 */ 245 function setDisposedStatusSync(appId: string, disposedWant: Want): void; 246 247 /** 248 * Obtains the disposed status of a specified bundle. 249 * 250 * @permission ohos.permission.MANAGE_DISPOSED_APP_STATUS 251 * @param { string } appId - Indicates the app ID of the application. 252 * @param { AsyncCallback<Want> } callback - The callback of getting the disposed status of a specified bundle result. 253 * @throws { BusinessError } 201 - Permission denied. 254 * @throws { BusinessError } 202 - Permission denied, non-system app called system api. 255 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. 256 * @throws { BusinessError } 801 - Capability not supported. 257 * @throws { BusinessError } 17700005 - The specified app ID is empty string. 258 * @syscap SystemCapability.BundleManager.BundleFramework.AppControl 259 * @systemapi 260 * @since 9 261 */ 262 function getDisposedStatus(appId: string, callback: AsyncCallback<Want>): void; 263 264 /** 265 * Obtains the disposed status of a specified bundle. 266 * 267 * @permission ohos.permission.MANAGE_DISPOSED_APP_STATUS 268 * @param { string } appId - Indicates the app ID of the application. 269 * @returns { Promise<Want> } Returns the disposed status of a specified bundle. 270 * @throws { BusinessError } 201 - Permission denied. 271 * @throws { BusinessError } 202 - Permission denied, non-system app called system api. 272 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. 273 * @throws { BusinessError } 801 - Capability not supported. 274 * @throws { BusinessError } 17700005 - The specified app ID is empty string. 275 * @syscap SystemCapability.BundleManager.BundleFramework.AppControl 276 * @systemapi 277 * @since 9 278 */ 279 function getDisposedStatus(appId: string): Promise<Want>; 280 281 /** 282 * Obtains the disposed status of a specified bundle. 283 * 284 * @permission ohos.permission.MANAGE_DISPOSED_APP_STATUS 285 * @param { string } appId - Indicates the app ID of the application. 286 * @returns { Want } Returns the disposed status of a specified bundle. 287 * @throws { BusinessError } 201 - Permission denied. 288 * @throws { BusinessError } 202 - Permission denied, non-system app called system api. 289 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. 290 * @throws { BusinessError } 801 - Capability not supported. 291 * @throws { BusinessError } 17700005 - The specified app ID is empty string. 292 * @syscap SystemCapability.BundleManager.BundleFramework.AppControl 293 * @systemapi 294 * @since 10 295 */ 296 function getDisposedStatusSync(appId: string): Want; 297 298 /** 299 * Delete the disposed status of a specified bundle. 300 * 301 * @permission ohos.permission.MANAGE_DISPOSED_APP_STATUS 302 * @param { string } appId - Indicates the app ID of the application. 303 * @param { AsyncCallback<void> } callback - the callback of deleting the disposed status of a specified bundle result. 304 * @throws { BusinessError } 201 - Permission denied. 305 * @throws { BusinessError } 202 - Permission denied, non-system app called system api. 306 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. 307 * @throws { BusinessError } 801 - Capability not supported. 308 * @throws { BusinessError } 17700005 - The specified app ID is empty string. 309 * @syscap SystemCapability.BundleManager.BundleFramework.AppControl 310 * @systemapi 311 * @since 9 312 */ 313 function deleteDisposedStatus(appId: string, callback: AsyncCallback<void>): void; 314 315 /** 316 * Delete the disposed status of a specified bundle. 317 * 318 * @permission ohos.permission.MANAGE_DISPOSED_APP_STATUS 319 * @param { string } appId - Indicates the app ID of the application. 320 * @returns { Promise<void> } Returns the result of deleting the disposed status of a specified bundle. 321 * @throws { BusinessError } 201 - Permission denied. 322 * @throws { BusinessError } 202 - Permission denied, non-system app called system api. 323 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. 324 * @throws { BusinessError } 801 - Capability not supported. 325 * @throws { BusinessError } 17700005 - The specified app ID is empty string. 326 * @syscap SystemCapability.BundleManager.BundleFramework.AppControl 327 * @systemapi 328 * @since 9 329 */ 330 function deleteDisposedStatus(appId: string): Promise<void>; 331 332 /** 333 * Delete the disposed status of a specified bundle. 334 * 335 * @permission ohos.permission.MANAGE_DISPOSED_APP_STATUS 336 * @param { string } appId - Indicates the app ID of the application. 337 * @throws { BusinessError } 201 - Permission denied. 338 * @throws { BusinessError } 202 - Permission denied, non-system app called system api. 339 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. 340 * @throws { BusinessError } 801 - Capability not supported. 341 * @throws { BusinessError } 17700005 - The specified app ID is empty string. 342 * @syscap SystemCapability.BundleManager.BundleFramework.AppControl 343 * @systemapi 344 * @since 10 345 */ 346 /** 347 * Delete the disposed status of a specified bundle. 348 * 349 * @permission ohos.permission.MANAGE_DISPOSED_APP_STATUS 350 * @param { string } appId - Indicates the app ID of the application. 351 * @param { number } [appIndex] Indicates the index of clone app. 352 * @throws { BusinessError } 201 - Permission denied. 353 * @throws { BusinessError } 202 - Permission denied. A non-system application is not allowed to call a system API. 354 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. 355 * @throws { BusinessError } 801 - Capability not supported. 356 * @throws { BusinessError } 17700005 - The specified app ID is invalid. 357 * @throws { BusinessError } 17700061 - AppIndex is not in the valid range. 358 * @syscap SystemCapability.BundleManager.BundleFramework.AppControl 359 * @systemapi 360 * @since 12 361 */ 362 function deleteDisposedStatusSync(appId: string, appIndex?: number): void; 363 364 /** 365 * Obtains the disposed rule of a specified bundle. 366 * 367 * @permission ohos.permission.MANAGE_DISPOSED_APP_STATUS 368 * @param { string } appId - Indicates the app ID of the application. 369 * @returns { DisposedRule } Returns the disposed rule of a specified bundle. 370 * @throws { BusinessError } 201 - Permission denied. 371 * @throws { BusinessError } 202 - Permission denied. A non-system application is not allowed to call a system API. 372 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. 373 * @throws { BusinessError } 801 - Capability not supported. 374 * @throws { BusinessError } 17700005 - The specified app ID is an empty string. 375 * @syscap SystemCapability.BundleManager.BundleFramework.AppControl 376 * @systemapi 377 * @since 11 378 */ 379 /** 380 * Obtains the disposed rule of a specified bundle. 381 * 382 * @permission ohos.permission.MANAGE_DISPOSED_APP_STATUS 383 * @param { string } appId - Indicates the app ID of the application. 384 * @param { number } [appIndex] Indicates the index of clone app. 385 * @returns { DisposedRule } Returns the disposed rule of a specified bundle. 386 * @throws { BusinessError } 201 - Permission denied. 387 * @throws { BusinessError } 202 - Permission denied. A non-system application is not allowed to call a system API. 388 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. 389 * @throws { BusinessError } 801 - Capability not supported. 390 * @throws { BusinessError } 17700005 - The specified app ID is invalid. 391 * @throws { BusinessError } 17700061 - AppIndex is not in the valid range. 392 * @syscap SystemCapability.BundleManager.BundleFramework.AppControl 393 * @systemapi 394 * @since 12 395 */ 396 function getDisposedRule(appId: string, appIndex?: number): DisposedRule; 397 398 /** 399 * Sets the disposed rule of a specified bundle. 400 * 401 * @permission ohos.permission.MANAGE_DISPOSED_APP_STATUS 402 * @param { string } appId - Indicates the app ID of the application. 403 * @param { DisposedRule } rule - Indicates the disposed rule of a specified bundle. 404 * @throws { BusinessError } 201 - Permission denied. 405 * @throws { BusinessError } 202 - Permission denied. A non-system application is not allowed to call a system API. 406 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. 407 * @throws { BusinessError } 801 - Capability not supported. 408 * @throws { BusinessError } 17700005 - The specified app ID is an empty string. 409 * @syscap SystemCapability.BundleManager.BundleFramework.AppControl 410 * @systemapi 411 * @since 11 412 */ 413 /** 414 * Sets the disposed rule of a specified bundle. 415 * 416 * @permission ohos.permission.MANAGE_DISPOSED_APP_STATUS 417 * @param { string } appId - Indicates the app ID of the application. 418 * @param { DisposedRule } rule - Indicates the disposed rule of a specified bundle. 419 * @param { number } [appIndex] Indicates the index of clone app. 420 * @throws { BusinessError } 201 - Permission denied. 421 * @throws { BusinessError } 202 - Permission denied. A non-system application is not allowed to call a system API. 422 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. 423 * @throws { BusinessError } 801 - Capability not supported. 424 * @throws { BusinessError } 17700005 - The specified app ID is invalid. 425 * @throws { BusinessError } 17700061 - AppIndex is not in the valid range. 426 * @syscap SystemCapability.BundleManager.BundleFramework.AppControl 427 * @systemapi 428 * @since 12 429 */ 430 function setDisposedRule(appId: string, rule: DisposedRule, appIndex?: number): void; 431} 432 433export default appControl; 434