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 wantConstant from './@ohos.app.ability.wantConstant'; 2361847f8eSopenharmony_ci 2461847f8eSopenharmony_ci/** 2561847f8eSopenharmony_ci * This module provides the capability to authorize URI. 2661847f8eSopenharmony_ci * 2761847f8eSopenharmony_ci * @namespace uriPermissionManager 2861847f8eSopenharmony_ci * @syscap SystemCapability.Ability.AbilityRuntime.Core 2961847f8eSopenharmony_ci * @since 10 3061847f8eSopenharmony_ci */ 3161847f8eSopenharmony_cideclare namespace uriPermissionManager { 3261847f8eSopenharmony_ci /** 3361847f8eSopenharmony_ci * Grant URI to another application 3461847f8eSopenharmony_ci * 3561847f8eSopenharmony_ci * @permission ohos.permission.PROXY_AUTHORIZATION_URI 3661847f8eSopenharmony_ci * @param { string } uri - File URI. 3761847f8eSopenharmony_ci * @param { wantConstant.Flags } flag - wantConstant.Flags.FLAG_AUTH_READ_URI_PERMISSION, 3861847f8eSopenharmony_ci * wantConstant.Flags.FLAG_AUTH_WRITE_URI_PERMISSION or 3961847f8eSopenharmony_ci * wantConstant.Flags.FLAG_AUTH_PERSISTABLE_URI_PERMISSION. 4061847f8eSopenharmony_ci * @param { string } targetBundleName - Indicates the bundle name of authorization target. 4161847f8eSopenharmony_ci * @param { AsyncCallback<number> } callback - the callback of grantUriPermission. 4261847f8eSopenharmony_ci * @throws { BusinessError } 201 - Permission denied. 4361847f8eSopenharmony_ci * @throws { BusinessError } 202 - Not System App. Interface caller is not a system app. 4461847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. Possible causes: 4561847f8eSopenharmony_ci * 1. Mandatory parameters are left unspecified; 4661847f8eSopenharmony_ci * 2. Incorrect parameter types. 4761847f8eSopenharmony_ci * @throws { BusinessError } 16000050 - Internal error. 4861847f8eSopenharmony_ci * @throws { BusinessError } 16000058 - Invalid URI flag. 4961847f8eSopenharmony_ci * @throws { BusinessError } 16000059 - Invalid URI type. 5061847f8eSopenharmony_ci * @throws { BusinessError } 16000060 - A sandbox application cannot grant URI permission. 5161847f8eSopenharmony_ci * @syscap SystemCapability.Ability.AbilityRuntime.Core 5261847f8eSopenharmony_ci * @systemapi hide this for inner system use. 5361847f8eSopenharmony_ci * @since 10 5461847f8eSopenharmony_ci */ 5561847f8eSopenharmony_ci function grantUriPermission( 5661847f8eSopenharmony_ci uri: string, 5761847f8eSopenharmony_ci flag: wantConstant.Flags, 5861847f8eSopenharmony_ci targetBundleName: string, 5961847f8eSopenharmony_ci callback: AsyncCallback<number> 6061847f8eSopenharmony_ci ): void; 6161847f8eSopenharmony_ci 6261847f8eSopenharmony_ci /** 6361847f8eSopenharmony_ci * Grant URI to another application 6461847f8eSopenharmony_ci * 6561847f8eSopenharmony_ci * @permission ohos.permission.PROXY_AUTHORIZATION_URI 6661847f8eSopenharmony_ci * @param { string } uri - File URI. 6761847f8eSopenharmony_ci * @param { wantConstant.Flags } flag - wantConstant.Flags.FLAG_AUTH_READ_URI_PERMISSION, 6861847f8eSopenharmony_ci * wantConstant.Flags.FLAG_AUTH_WRITE_URI_PERMISSION or 6961847f8eSopenharmony_ci * wantConstant.Flags.FLAG_AUTH_PERSISTABLE_URI_PERMISSION. 7061847f8eSopenharmony_ci * @param { string } targetBundleName - Indicates the bundle name of authorization target. 7161847f8eSopenharmony_ci * @returns { Promise<number> } - the promise returned by the function. 7261847f8eSopenharmony_ci * @throws { BusinessError } 201 - Permission denied. 7361847f8eSopenharmony_ci * @throws { BusinessError } 202 - Not System App. Interface caller is not a system app. 7461847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. Possible causes: 7561847f8eSopenharmony_ci * 1. Mandatory parameters are left unspecified; 7661847f8eSopenharmony_ci * 2. Incorrect parameter types. 7761847f8eSopenharmony_ci * @throws { BusinessError } 16000050 - Internal error. 7861847f8eSopenharmony_ci * @throws { BusinessError } 16000058 - Invalid URI flag. 7961847f8eSopenharmony_ci * @throws { BusinessError } 16000059 - Invalid URI type. 8061847f8eSopenharmony_ci * @throws { BusinessError } 16000060 - A sandbox application cannot grant URI permission. 8161847f8eSopenharmony_ci * @syscap SystemCapability.Ability.AbilityRuntime.Core 8261847f8eSopenharmony_ci * @systemapi hide this for inner system use. 8361847f8eSopenharmony_ci * @since 10 8461847f8eSopenharmony_ci */ 8561847f8eSopenharmony_ci function grantUriPermission(uri: string, flag: wantConstant.Flags, targetBundleName: string): Promise<number>; 8661847f8eSopenharmony_ci 8761847f8eSopenharmony_ci /** 8861847f8eSopenharmony_ci * Revoke URI from one application 8961847f8eSopenharmony_ci * 9061847f8eSopenharmony_ci * @permission ohos.permission.PROXY_AUTHORIZATION_URI 9161847f8eSopenharmony_ci * @param { string } uri - File URI. 9261847f8eSopenharmony_ci * @param { string } targetBundleName - Indicates the bundle name of authorization target. 9361847f8eSopenharmony_ci * @param { AsyncCallback<number> } callback - the callback of revokeUriPermission. 9461847f8eSopenharmony_ci * @throws { BusinessError } 201 - Permission denied. 9561847f8eSopenharmony_ci * @throws { BusinessError } 202 - Not System App. Interface caller is not a system app. 9661847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. Possible causes: 9761847f8eSopenharmony_ci * 1. Mandatory parameters are left unspecified; 9861847f8eSopenharmony_ci * 2. Incorrect parameter types. 9961847f8eSopenharmony_ci * @throws { BusinessError } 16000050 - Internal error. 10061847f8eSopenharmony_ci * @throws { BusinessError } 16000059 - Invalid URI type. 10161847f8eSopenharmony_ci * @syscap SystemCapability.Ability.AbilityRuntime.Core 10261847f8eSopenharmony_ci * @systemapi hide this for inner system use 10361847f8eSopenharmony_ci * @since 10 10461847f8eSopenharmony_ci */ 10561847f8eSopenharmony_ci /** 10661847f8eSopenharmony_ci * Revoke URI from one application 10761847f8eSopenharmony_ci * 10861847f8eSopenharmony_ci * @param { string } uri - File URI. 10961847f8eSopenharmony_ci * @param { string } targetBundleName - Indicates the bundle name of authorization target. 11061847f8eSopenharmony_ci * @param { AsyncCallback<number> } callback - the callback of revokeUriPermission. 11161847f8eSopenharmony_ci * @throws { BusinessError } 202 - Not System App. Interface caller is not a system app. 11261847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. Possible causes: 11361847f8eSopenharmony_ci * 1. Mandatory parameters are left unspecified; 11461847f8eSopenharmony_ci * 2. Incorrect parameter types. 11561847f8eSopenharmony_ci * @throws { BusinessError } 16000050 - Internal error. 11661847f8eSopenharmony_ci * @throws { BusinessError } 16000059 - Invalid URI type. 11761847f8eSopenharmony_ci * @syscap SystemCapability.Ability.AbilityRuntime.Core 11861847f8eSopenharmony_ci * @systemapi hide this for inner system use 11961847f8eSopenharmony_ci * @since 12 12061847f8eSopenharmony_ci */ 12161847f8eSopenharmony_ci function revokeUriPermission(uri: string, targetBundleName: string, callback: AsyncCallback<number>): void; 12261847f8eSopenharmony_ci 12361847f8eSopenharmony_ci /** 12461847f8eSopenharmony_ci * Revoke URI from one application 12561847f8eSopenharmony_ci * 12661847f8eSopenharmony_ci * @permission ohos.permission.PROXY_AUTHORIZATION_URI 12761847f8eSopenharmony_ci * @param { string } uri - File URI. 12861847f8eSopenharmony_ci * @param { string } targetBundleName - Indicates the bundle name of authorization target. 12961847f8eSopenharmony_ci * @returns { Promise<number> } - the promise returned by the function. 13061847f8eSopenharmony_ci * @throws { BusinessError } 201 - Permission denied. 13161847f8eSopenharmony_ci * @throws { BusinessError } 202 - Not System App. Interface caller is not a system app. 13261847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. Possible causes: 13361847f8eSopenharmony_ci * 1. Mandatory parameters are left unspecified; 13461847f8eSopenharmony_ci * 2. Incorrect parameter types. 13561847f8eSopenharmony_ci * @throws { BusinessError } 16000050 - Internal error. 13661847f8eSopenharmony_ci * @throws { BusinessError } 16000059 - Invalid URI type. 13761847f8eSopenharmony_ci * @syscap SystemCapability.Ability.AbilityRuntime.Core 13861847f8eSopenharmony_ci * @systemapi hide this for inner system use 13961847f8eSopenharmony_ci * @since 10 14061847f8eSopenharmony_ci */ 14161847f8eSopenharmony_ci /** 14261847f8eSopenharmony_ci * Revoke URI from one application 14361847f8eSopenharmony_ci * 14461847f8eSopenharmony_ci * @param { string } uri - File URI. 14561847f8eSopenharmony_ci * @param { string } targetBundleName - Indicates the bundle name of authorization target. 14661847f8eSopenharmony_ci * @returns { Promise<number> } - the promise returned by the function. 14761847f8eSopenharmony_ci * @throws { BusinessError } 202 - Not System App. Interface caller is not a system app. 14861847f8eSopenharmony_ci * @throws { BusinessError } 401 - Parameter error. Possible causes: 14961847f8eSopenharmony_ci * 1. Mandatory parameters are left unspecified; 15061847f8eSopenharmony_ci * 2. Incorrect parameter types. 15161847f8eSopenharmony_ci * @throws { BusinessError } 16000050 - Internal error. 15261847f8eSopenharmony_ci * @throws { BusinessError } 16000059 - Invalid URI type. 15361847f8eSopenharmony_ci * @syscap SystemCapability.Ability.AbilityRuntime.Core 15461847f8eSopenharmony_ci * @systemapi hide this for inner system use 15561847f8eSopenharmony_ci * @since 12 15661847f8eSopenharmony_ci */ 15761847f8eSopenharmony_ci function revokeUriPermission(uri: string, targetBundleName: string): Promise<number>; 15861847f8eSopenharmony_ci} 15961847f8eSopenharmony_ci 16061847f8eSopenharmony_ciexport default uriPermissionManager;