1/* 2 * Copyright (c) 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 Context from './application/Context'; 22 23/** 24 * This module provides application basic functions. 25 * 26 * @namespace application 27 * @syscap SystemCapability.Ability.AbilityRuntime.Core 28 * @stagemodelonly 29 * @atomicservice 30 * @since 12 31 */ 32declare namespace application { 33 /** 34 * Create a module context 35 * 36 * @param { Context } context - Indicates current context. 37 * @param { string } moduleName - Indicates the module name. 38 * @returns { Promise<Context> } Returns the application context. 39 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. 40 * @syscap SystemCapability.Ability.AbilityRuntime.Core 41 * @stagemodelonly 42 * @atomicservice 43 * @since 12 44 */ 45 export function createModuleContext(context: Context, moduleName: string): Promise<Context>; 46 47 /** 48 * Create a module context 49 * 50 * @permission ohos.permission.GET_BUNDLE_INFO_PRIVILEGED 51 * @param { Context } context - Indicates current context. 52 * @param { string } bundleName - Indicates the bundle name. 53 * @param { string } moduleName - Indicates the module name. 54 * @returns { Promise<Context> } Returns the application context. 55 * @throws { BusinessError } 201 - Permission denied. 56 * @throws { BusinessError } 202 - Permission denied, non-system app called system api. 57 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. 58 * @syscap SystemCapability.Ability.AbilityRuntime.Core 59 * @systemapi 60 * @stagemodelonly 61 * @since 12 62 */ 63 export function createModuleContext(context: Context, bundleName: string, moduleName: string): Promise<Context>; 64 65 /** 66 * Create a bundle context 67 * 68 * @permission ohos.permission.GET_BUNDLE_INFO_PRIVILEGED 69 * @param { Context } context - Indicates current context. 70 * @param { string } bundleName - Indicates the bundle name. 71 * @returns { Promise<Context> } Returns the application context. 72 * @throws { BusinessError } 201 - Permission denied. 73 * @throws { BusinessError } 202 - Permission denied, non-system app called system api. 74 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. 75 * @syscap SystemCapability.Ability.AbilityRuntime.Core 76 * @systemapi 77 * @stagemodelonly 78 * @since 12 79 */ 80 export function createBundleContext(context: Context, bundleName: string): Promise<Context>; 81} 82 83export default application;