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