xref: /interface/sdk-js/api/app/context.d.ts (revision 61847f8e)
161847f8eSopenharmony_ci/*
261847f8eSopenharmony_ci * Copyright (c) 2021-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 { AsyncCallback } from '../@ohos.base';
2261847f8eSopenharmony_ciimport { ApplicationInfo } from '../bundle/applicationInfo';
2361847f8eSopenharmony_ciimport { ProcessInfo } from './processInfo';
2461847f8eSopenharmony_ciimport { ElementName } from '../bundle/elementName';
2561847f8eSopenharmony_ciimport BaseContext from '../application/BaseContext';
2661847f8eSopenharmony_ciimport { HapModuleInfo } from '../bundle/hapModuleInfo';
2761847f8eSopenharmony_ciimport { AppVersionInfo } from './appVersionInfo';
2861847f8eSopenharmony_ciimport { AbilityInfo } from '../bundle/abilityInfo';
2961847f8eSopenharmony_ciimport bundle from '../@ohos.bundle';
3061847f8eSopenharmony_ci
3161847f8eSopenharmony_ci/**
3261847f8eSopenharmony_ci * The context of an ability or an application.  It allows access to
3361847f8eSopenharmony_ci * application-specific resources, request and verification permissions.
3461847f8eSopenharmony_ci * Can only be obtained through the ability.
3561847f8eSopenharmony_ci *
3661847f8eSopenharmony_ci * @interface Context
3761847f8eSopenharmony_ci * @syscap SystemCapability.Ability.AbilityRuntime.Core
3861847f8eSopenharmony_ci * @FAModelOnly
3961847f8eSopenharmony_ci * @since 6
4061847f8eSopenharmony_ci */
4161847f8eSopenharmony_ciexport interface Context extends BaseContext {
4261847f8eSopenharmony_ci  /**
4361847f8eSopenharmony_ci   * Get the local root dir of an app. If it is the first call, the dir
4461847f8eSopenharmony_ci   * will be created.
4561847f8eSopenharmony_ci   * If in the context of the ability, return the root dir of
4661847f8eSopenharmony_ci   * the ability; if in the context of the application, return the
4761847f8eSopenharmony_ci   * root dir of the application.
4861847f8eSopenharmony_ci   *
4961847f8eSopenharmony_ci   * @returns { Promise<string> } the root dir
5061847f8eSopenharmony_ci   * @syscap SystemCapability.Ability.AbilityRuntime.Core
5161847f8eSopenharmony_ci   * @FAModelOnly
5261847f8eSopenharmony_ci   * @since 7
5361847f8eSopenharmony_ci   */
5461847f8eSopenharmony_ci  getOrCreateLocalDir(): Promise<string>;
5561847f8eSopenharmony_ci
5661847f8eSopenharmony_ci  /**
5761847f8eSopenharmony_ci   * Get the local root dir of an app. If it is the first call, the dir
5861847f8eSopenharmony_ci   * will be created.
5961847f8eSopenharmony_ci   * If in the context of the ability, return the root dir of
6061847f8eSopenharmony_ci   * the ability; if in the context of the application, return the
6161847f8eSopenharmony_ci   * root dir of the application.
6261847f8eSopenharmony_ci   *
6361847f8eSopenharmony_ci   * @param { AsyncCallback<string> } callback - Returns the local root directory of the application.
6461847f8eSopenharmony_ci   * @syscap SystemCapability.Ability.AbilityRuntime.Core
6561847f8eSopenharmony_ci   * @FAModelOnly
6661847f8eSopenharmony_ci   * @since 7
6761847f8eSopenharmony_ci   */
6861847f8eSopenharmony_ci  getOrCreateLocalDir(callback: AsyncCallback<string>): void;
6961847f8eSopenharmony_ci
7061847f8eSopenharmony_ci  /**
7161847f8eSopenharmony_ci   * Verify whether the specified permission is allowed for a particular
7261847f8eSopenharmony_ci   * pid and uid running in the system.
7361847f8eSopenharmony_ci   * Pid and uid are optional. If you do not pass in pid and uid,
7461847f8eSopenharmony_ci   * it will check your own permission.
7561847f8eSopenharmony_ci   *
7661847f8eSopenharmony_ci   * @param { string } permission - The name of the specified permission.
7761847f8eSopenharmony_ci   * @param { PermissionOptions } [options] - Permission Options.
7861847f8eSopenharmony_ci   * @returns { Promise<number> } asynchronous callback with {@code 0} if the PID
7961847f8eSopenharmony_ci   *                              and UID have the permission; callback with {@code -1} otherwise.
8061847f8eSopenharmony_ci   * @syscap SystemCapability.Ability.AbilityRuntime.Core
8161847f8eSopenharmony_ci   * @FAModelOnly
8261847f8eSopenharmony_ci   * @since 7
8361847f8eSopenharmony_ci   */
8461847f8eSopenharmony_ci  verifyPermission(permission: string, options?: PermissionOptions): Promise<number>;
8561847f8eSopenharmony_ci
8661847f8eSopenharmony_ci  /**
8761847f8eSopenharmony_ci   * Verify whether the specified permission is allowed for a particular
8861847f8eSopenharmony_ci   * pid and uid running in the system.
8961847f8eSopenharmony_ci   * Pid and uid are optional. If you do not pass in pid and uid,
9061847f8eSopenharmony_ci   * it will check your own permission.
9161847f8eSopenharmony_ci   *
9261847f8eSopenharmony_ci   * @param { string } permission - The name of the specified permission
9361847f8eSopenharmony_ci   * @param { PermissionOptions } options - Permission Options
9461847f8eSopenharmony_ci   * @param { AsyncCallback<number> } callback - Return permission verification result, 0 has permission,
9561847f8eSopenharmony_ci   *                                           -1 has no permission.
9661847f8eSopenharmony_ci   * @syscap SystemCapability.Ability.AbilityRuntime.Core
9761847f8eSopenharmony_ci   * @FAModelOnly
9861847f8eSopenharmony_ci   * @since 7
9961847f8eSopenharmony_ci   */
10061847f8eSopenharmony_ci  verifyPermission(permission: string, options: PermissionOptions, callback: AsyncCallback<number>): void;
10161847f8eSopenharmony_ci
10261847f8eSopenharmony_ci  /**
10361847f8eSopenharmony_ci   * Verify whether the specified permission is allowed for a particular
10461847f8eSopenharmony_ci   * pid and uid running in the system.
10561847f8eSopenharmony_ci   * Pid and uid are optional. If you do not pass in pid and uid,
10661847f8eSopenharmony_ci   * it will check your own permission.
10761847f8eSopenharmony_ci   *
10861847f8eSopenharmony_ci   * @param { string } permission - The name of the specified permission
10961847f8eSopenharmony_ci   * @param { AsyncCallback<number> } callback - Return permission verification result, 0 has permission,
11061847f8eSopenharmony_ci   *                                           -1 has no permission.
11161847f8eSopenharmony_ci   * @syscap SystemCapability.Ability.AbilityRuntime.Core
11261847f8eSopenharmony_ci   * @FAModelOnly
11361847f8eSopenharmony_ci   * @since 7
11461847f8eSopenharmony_ci   */
11561847f8eSopenharmony_ci  verifyPermission(permission: string, callback: AsyncCallback<number>): void;
11661847f8eSopenharmony_ci
11761847f8eSopenharmony_ci  /**
11861847f8eSopenharmony_ci   * Requests certain permissions from the system.
11961847f8eSopenharmony_ci   *
12061847f8eSopenharmony_ci   * @param { Array<string> } permissions - Indicates the list of permissions to be requested.parameter cannot be null.
12161847f8eSopenharmony_ci   * @param { number } requestCode - Indicates the request code to be passed to the PermissionRequestResult
12261847f8eSopenharmony_ci   * @param { AsyncCallback<PermissionRequestResult> } resultCallback - Return authorization result information.
12361847f8eSopenharmony_ci   * @syscap SystemCapability.Ability.AbilityRuntime.Core
12461847f8eSopenharmony_ci   * @FAModelOnly
12561847f8eSopenharmony_ci   * @since 7
12661847f8eSopenharmony_ci   */
12761847f8eSopenharmony_ci  requestPermissionsFromUser(
12861847f8eSopenharmony_ci    permissions: Array<string>,
12961847f8eSopenharmony_ci    requestCode: number,
13061847f8eSopenharmony_ci    resultCallback: AsyncCallback<PermissionRequestResult>
13161847f8eSopenharmony_ci  ): void;
13261847f8eSopenharmony_ci
13361847f8eSopenharmony_ci  /**
13461847f8eSopenharmony_ci   * Requests certain permissions from the system.
13561847f8eSopenharmony_ci   *
13661847f8eSopenharmony_ci   * @param { Array<string> } permissions - Indicates the list of permissions to be requested.Parameter cannot be null.
13761847f8eSopenharmony_ci   * @param { number } requestCode - Indicates the request code to be passed to the PermissionRequestResult
13861847f8eSopenharmony_ci   * @returns { Promise<PermissionRequestResult> } Indicates the request code to be passed to PermissionRequestResult.
13961847f8eSopenharmony_ci   * @syscap SystemCapability.Ability.AbilityRuntime.Core
14061847f8eSopenharmony_ci   * @FAModelOnly
14161847f8eSopenharmony_ci   * @since 7
14261847f8eSopenharmony_ci   */
14361847f8eSopenharmony_ci  requestPermissionsFromUser(permissions: Array<string>, requestCode: number): Promise<PermissionRequestResult>;
14461847f8eSopenharmony_ci
14561847f8eSopenharmony_ci  /**
14661847f8eSopenharmony_ci   * Obtains information about the current application.
14761847f8eSopenharmony_ci   *
14861847f8eSopenharmony_ci   * @param { AsyncCallback<ApplicationInfo> } callback - Returns information about the current application.
14961847f8eSopenharmony_ci   * @syscap SystemCapability.Ability.AbilityRuntime.Core
15061847f8eSopenharmony_ci   * @FAModelOnly
15161847f8eSopenharmony_ci   * @since 7
15261847f8eSopenharmony_ci   */
15361847f8eSopenharmony_ci  getApplicationInfo(callback: AsyncCallback<ApplicationInfo>): void;
15461847f8eSopenharmony_ci
15561847f8eSopenharmony_ci  /**
15661847f8eSopenharmony_ci   * Obtains information about the current application.
15761847f8eSopenharmony_ci   *
15861847f8eSopenharmony_ci   * @returns { Promise<ApplicationInfo> } Information about the current application.
15961847f8eSopenharmony_ci   * @syscap SystemCapability.Ability.AbilityRuntime.Core
16061847f8eSopenharmony_ci   * @FAModelOnly
16161847f8eSopenharmony_ci   * @since 7
16261847f8eSopenharmony_ci   */
16361847f8eSopenharmony_ci  getApplicationInfo(): Promise<ApplicationInfo>;
16461847f8eSopenharmony_ci
16561847f8eSopenharmony_ci  /**
16661847f8eSopenharmony_ci   * Obtains the bundle name of the current ability.
16761847f8eSopenharmony_ci   *
16861847f8eSopenharmony_ci   * @param { AsyncCallback<string> } callback - Returns the Bundle name of the current capability.
16961847f8eSopenharmony_ci   * @syscap SystemCapability.Ability.AbilityRuntime.Core
17061847f8eSopenharmony_ci   * @FAModelOnly
17161847f8eSopenharmony_ci   * @since 7
17261847f8eSopenharmony_ci   */
17361847f8eSopenharmony_ci  getBundleName(callback: AsyncCallback<string>): void;
17461847f8eSopenharmony_ci
17561847f8eSopenharmony_ci  /**
17661847f8eSopenharmony_ci   * Obtains the bundle name of the current ability.
17761847f8eSopenharmony_ci   *
17861847f8eSopenharmony_ci   * @returns { Promise<string> } The Bundle name of the current capability.
17961847f8eSopenharmony_ci   * @syscap SystemCapability.Ability.AbilityRuntime.Core
18061847f8eSopenharmony_ci   * @FAModelOnly
18161847f8eSopenharmony_ci   * @since 7
18261847f8eSopenharmony_ci   */
18361847f8eSopenharmony_ci  getBundleName(): Promise<string>;
18461847f8eSopenharmony_ci
18561847f8eSopenharmony_ci  /**
18661847f8eSopenharmony_ci   * Obtains the current display orientation of this ability.
18761847f8eSopenharmony_ci   *
18861847f8eSopenharmony_ci   * @param { AsyncCallback<bundle.DisplayOrientation> } callback - Indicates the realistic direction of the screen.
18961847f8eSopenharmony_ci   * @syscap SystemCapability.Ability.AbilityRuntime.Core
19061847f8eSopenharmony_ci   * @FAModelOnly
19161847f8eSopenharmony_ci   * @since 7
19261847f8eSopenharmony_ci   */
19361847f8eSopenharmony_ci  getDisplayOrientation(callback: AsyncCallback<bundle.DisplayOrientation>): void;
19461847f8eSopenharmony_ci
19561847f8eSopenharmony_ci  /**
19661847f8eSopenharmony_ci   * Obtains the current display orientation of this ability.
19761847f8eSopenharmony_ci   *
19861847f8eSopenharmony_ci   * @returns { Promise<bundle.DisplayOrientation> } Indicates the screen display direction.
19961847f8eSopenharmony_ci   * @syscap SystemCapability.Ability.AbilityRuntime.Core
20061847f8eSopenharmony_ci   * @FAModelOnly
20161847f8eSopenharmony_ci   * @since 7
20261847f8eSopenharmony_ci   */
20361847f8eSopenharmony_ci  getDisplayOrientation(): Promise<bundle.DisplayOrientation>;
20461847f8eSopenharmony_ci
20561847f8eSopenharmony_ci  /**
20661847f8eSopenharmony_ci   * Obtains the absolute path to the application-specific cache directory
20761847f8eSopenharmony_ci   *
20861847f8eSopenharmony_ci   * @param { AsyncCallback<string> } callback - Returns the absolute path of the application's cache directory.
20961847f8eSopenharmony_ci   * @syscap SystemCapability.Ability.AbilityRuntime.Core
21061847f8eSopenharmony_ci   * @FAModelOnly
21161847f8eSopenharmony_ci   * @since 6
21261847f8eSopenharmony_ci   * @deprecated since 7
21361847f8eSopenharmony_ci   */
21461847f8eSopenharmony_ci  getExternalCacheDir(callback: AsyncCallback<string>): void;
21561847f8eSopenharmony_ci
21661847f8eSopenharmony_ci  /**
21761847f8eSopenharmony_ci   * Obtains the absolute path to the application-specific cache directory
21861847f8eSopenharmony_ci   *
21961847f8eSopenharmony_ci   * @returns { Promise<string> } Return the cache directory of the application.
22061847f8eSopenharmony_ci   * @syscap SystemCapability.Ability.AbilityRuntime.Core
22161847f8eSopenharmony_ci   * @FAModelOnly
22261847f8eSopenharmony_ci   * @since 6
22361847f8eSopenharmony_ci   * @deprecated since 7
22461847f8eSopenharmony_ci   */
22561847f8eSopenharmony_ci  getExternalCacheDir(): Promise<string>;
22661847f8eSopenharmony_ci
22761847f8eSopenharmony_ci  /**
22861847f8eSopenharmony_ci   * Sets the display orientation of the current ability.
22961847f8eSopenharmony_ci   *
23061847f8eSopenharmony_ci   * @param { bundle.DisplayOrientation } orientation - Indicates the new orientation for the current ability.
23161847f8eSopenharmony_ci   * @param { AsyncCallback<void> } callback - Indicates the realistic direction of the screen.
23261847f8eSopenharmony_ci   * @syscap SystemCapability.Ability.AbilityRuntime.Core
23361847f8eSopenharmony_ci   * @FAModelOnly
23461847f8eSopenharmony_ci   * @since 7
23561847f8eSopenharmony_ci   */
23661847f8eSopenharmony_ci  setDisplayOrientation(orientation: bundle.DisplayOrientation, callback: AsyncCallback<void>): void;
23761847f8eSopenharmony_ci
23861847f8eSopenharmony_ci  /**
23961847f8eSopenharmony_ci   * Sets the display orientation of the current ability.
24061847f8eSopenharmony_ci   *
24161847f8eSopenharmony_ci   * @param { bundle.DisplayOrientation } orientation - Indicates the new orientation for the current ability.
24261847f8eSopenharmony_ci   * @returns { Promise<void> } the promise returned by the function.
24361847f8eSopenharmony_ci   * @syscap SystemCapability.Ability.AbilityRuntime.Core
24461847f8eSopenharmony_ci   * @FAModelOnly
24561847f8eSopenharmony_ci   * @since 7
24661847f8eSopenharmony_ci   */
24761847f8eSopenharmony_ci  setDisplayOrientation(orientation: bundle.DisplayOrientation): Promise<void>;
24861847f8eSopenharmony_ci
24961847f8eSopenharmony_ci  /**
25061847f8eSopenharmony_ci   * Sets whether to show this ability on top of the lock screen whenever the lock screen is displayed, keeping the
25161847f8eSopenharmony_ci   * ability in the ACTIVE state.
25261847f8eSopenharmony_ci   * The interface can only take effect in API8 and below versions.
25361847f8eSopenharmony_ci   *
25461847f8eSopenharmony_ci   * @param { boolean } show - Specifies whether to show this ability on top of the lock screen. The value true means
25561847f8eSopenharmony_ci   *                           to show it on the lock screen, and the value false means not.
25661847f8eSopenharmony_ci   * @param { AsyncCallback<void> } callback - Returns the callback result.
25761847f8eSopenharmony_ci   * @syscap SystemCapability.Ability.AbilityRuntime.Core
25861847f8eSopenharmony_ci   * @FAModelOnly
25961847f8eSopenharmony_ci   * @since 7
26061847f8eSopenharmony_ci   * @deprecated since 9
26161847f8eSopenharmony_ci   * @useinstead ohos.window/window.WindowStage#setShowOnLockScreen
26261847f8eSopenharmony_ci   */
26361847f8eSopenharmony_ci  setShowOnLockScreen(show: boolean, callback: AsyncCallback<void>): void;
26461847f8eSopenharmony_ci
26561847f8eSopenharmony_ci  /**
26661847f8eSopenharmony_ci   * Sets whether to show this ability on top of the lock screen whenever the lock screen is displayed, keeping the
26761847f8eSopenharmony_ci   * ability in the ACTIVE state.
26861847f8eSopenharmony_ci   * The interface can only take effect in API8 and below versions.
26961847f8eSopenharmony_ci   *
27061847f8eSopenharmony_ci   * @param { boolean } show - Specifies whether to show this ability on top of the lock screen. The value true means to
27161847f8eSopenharmony_ci   *                           show it on the lock screen, and the value false means not.
27261847f8eSopenharmony_ci   * @returns { Promise<void> } the promise returned by the function.
27361847f8eSopenharmony_ci   * @syscap SystemCapability.Ability.AbilityRuntime.Core
27461847f8eSopenharmony_ci   * @FAModelOnly
27561847f8eSopenharmony_ci   * @since 7
27661847f8eSopenharmony_ci   * @deprecated since 9
27761847f8eSopenharmony_ci   * @useinstead ohos.window/window.WindowStage#setShowOnLockScreen
27861847f8eSopenharmony_ci   */
27961847f8eSopenharmony_ci  setShowOnLockScreen(show: boolean): Promise<void>;
28061847f8eSopenharmony_ci
28161847f8eSopenharmony_ci  /**
28261847f8eSopenharmony_ci   * Sets whether to wake up the screen when this ability is restored.
28361847f8eSopenharmony_ci   *
28461847f8eSopenharmony_ci   * @param { boolean } wakeUp - Specifies whether to wake up the screen. The value true means to wake it up,
28561847f8eSopenharmony_ci   *                             and the value false means not.
28661847f8eSopenharmony_ci   * @param { AsyncCallback<void> } callback - Returns the callback result.
28761847f8eSopenharmony_ci   * @syscap SystemCapability.Ability.AbilityRuntime.Core
28861847f8eSopenharmony_ci   * @FAModelOnly
28961847f8eSopenharmony_ci   * @since 7
29061847f8eSopenharmony_ci   * @deprecated since 12
29161847f8eSopenharmony_ci   * @useinstead ohos.window.Window#setWakeUpScreen
29261847f8eSopenharmony_ci   */
29361847f8eSopenharmony_ci  setWakeUpScreen(wakeUp: boolean, callback: AsyncCallback<void>): void;
29461847f8eSopenharmony_ci
29561847f8eSopenharmony_ci  /**
29661847f8eSopenharmony_ci   * Sets whether to wake up the screen when this ability is restored.
29761847f8eSopenharmony_ci   *
29861847f8eSopenharmony_ci   * @param { boolean } wakeUp - Specifies whether to wake up the screen. The value true means to wake it up, and the
29961847f8eSopenharmony_ci   *                             value false means not.
30061847f8eSopenharmony_ci   * @returns { Promise<void> } the promise returned by the function.
30161847f8eSopenharmony_ci   * @syscap SystemCapability.Ability.AbilityRuntime.Core
30261847f8eSopenharmony_ci   * @FAModelOnly
30361847f8eSopenharmony_ci   * @since 7
30461847f8eSopenharmony_ci   * @deprecated since 12
30561847f8eSopenharmony_ci   * @useinstead ohos.window.Window#setWakeUpScreen
30661847f8eSopenharmony_ci   */
30761847f8eSopenharmony_ci  setWakeUpScreen(wakeUp: boolean): Promise<void>;
30861847f8eSopenharmony_ci
30961847f8eSopenharmony_ci  /**
31061847f8eSopenharmony_ci   * Obtains information about the current process, including the process ID and name.
31161847f8eSopenharmony_ci   *
31261847f8eSopenharmony_ci   * @param { AsyncCallback<ProcessInfo> } callback - Return current process information.
31361847f8eSopenharmony_ci   * @syscap SystemCapability.Ability.AbilityRuntime.Core
31461847f8eSopenharmony_ci   * @FAModelOnly
31561847f8eSopenharmony_ci   * @since 7
31661847f8eSopenharmony_ci   */
31761847f8eSopenharmony_ci  getProcessInfo(callback: AsyncCallback<ProcessInfo>): void;
31861847f8eSopenharmony_ci
31961847f8eSopenharmony_ci  /**
32061847f8eSopenharmony_ci   * Obtains information about the current process, including the process ID and name.
32161847f8eSopenharmony_ci   *
32261847f8eSopenharmony_ci   * @returns { Promise<ProcessInfo> } Information about the current process.
32361847f8eSopenharmony_ci   * @syscap SystemCapability.Ability.AbilityRuntime.Core
32461847f8eSopenharmony_ci   * @FAModelOnly
32561847f8eSopenharmony_ci   * @since 7
32661847f8eSopenharmony_ci   */
32761847f8eSopenharmony_ci  getProcessInfo(): Promise<ProcessInfo>;
32861847f8eSopenharmony_ci
32961847f8eSopenharmony_ci  /**
33061847f8eSopenharmony_ci   * Obtains the ohos.bundle.ElementName object of the current ability.This method is available only to Page abilities.
33161847f8eSopenharmony_ci   *
33261847f8eSopenharmony_ci   * @param { AsyncCallback<ElementName> } callback - Returns the ohos.bundle.ElementName of the current capability.
33361847f8eSopenharmony_ci   * @syscap SystemCapability.Ability.AbilityRuntime.Core
33461847f8eSopenharmony_ci   * @FAModelOnly
33561847f8eSopenharmony_ci   * @since 7
33661847f8eSopenharmony_ci   */
33761847f8eSopenharmony_ci  getElementName(callback: AsyncCallback<ElementName>): void;
33861847f8eSopenharmony_ci
33961847f8eSopenharmony_ci  /**
34061847f8eSopenharmony_ci   * Obtains the ohos.bundle.ElementName object of the current ability.This method is available only to Page abilities.
34161847f8eSopenharmony_ci   *
34261847f8eSopenharmony_ci   * @returns { Promise<ElementName> } The ohos.bundle.ElementName object of the current capability.
34361847f8eSopenharmony_ci   * @syscap SystemCapability.Ability.AbilityRuntime.Core
34461847f8eSopenharmony_ci   * @FAModelOnly
34561847f8eSopenharmony_ci   * @since 7
34661847f8eSopenharmony_ci   */
34761847f8eSopenharmony_ci  getElementName(): Promise<ElementName>;
34861847f8eSopenharmony_ci
34961847f8eSopenharmony_ci  /**
35061847f8eSopenharmony_ci   * Obtains the name of the current process.
35161847f8eSopenharmony_ci   *
35261847f8eSopenharmony_ci   * @param { AsyncCallback<string> } callback - Return current process name.
35361847f8eSopenharmony_ci   * @syscap SystemCapability.Ability.AbilityRuntime.Core
35461847f8eSopenharmony_ci   * @FAModelOnly
35561847f8eSopenharmony_ci   * @since 7
35661847f8eSopenharmony_ci   */
35761847f8eSopenharmony_ci  getProcessName(callback: AsyncCallback<string>): void;
35861847f8eSopenharmony_ci
35961847f8eSopenharmony_ci  /**
36061847f8eSopenharmony_ci   * Obtains the name of the current process.
36161847f8eSopenharmony_ci   *
36261847f8eSopenharmony_ci   * @returns { Promise<string> } Returns the name of the current process.
36361847f8eSopenharmony_ci   * @syscap SystemCapability.Ability.AbilityRuntime.Core
36461847f8eSopenharmony_ci   * @FAModelOnly
36561847f8eSopenharmony_ci   * @since 7
36661847f8eSopenharmony_ci   */
36761847f8eSopenharmony_ci  getProcessName(): Promise<string>;
36861847f8eSopenharmony_ci
36961847f8eSopenharmony_ci  /**
37061847f8eSopenharmony_ci   * Obtains the bundle name of the ability that called the current ability.
37161847f8eSopenharmony_ci   *
37261847f8eSopenharmony_ci   * @param { AsyncCallback<string> } callback - Returns the Bundle name of the ability caller.
37361847f8eSopenharmony_ci   * @syscap SystemCapability.Ability.AbilityRuntime.Core
37461847f8eSopenharmony_ci   * @FAModelOnly
37561847f8eSopenharmony_ci   * @since 7
37661847f8eSopenharmony_ci   */
37761847f8eSopenharmony_ci  getCallingBundle(callback: AsyncCallback<string>): void;
37861847f8eSopenharmony_ci
37961847f8eSopenharmony_ci  /**
38061847f8eSopenharmony_ci   * Obtains the bundle name of the ability that called the current ability.
38161847f8eSopenharmony_ci   *
38261847f8eSopenharmony_ci   * @returns { Promise<string> } Returns the Bundle name of the ability caller.
38361847f8eSopenharmony_ci   * @syscap SystemCapability.Ability.AbilityRuntime.Core
38461847f8eSopenharmony_ci   * @FAModelOnly
38561847f8eSopenharmony_ci   * @since 7
38661847f8eSopenharmony_ci   */
38761847f8eSopenharmony_ci  getCallingBundle(): Promise<string>;
38861847f8eSopenharmony_ci
38961847f8eSopenharmony_ci  /**
39061847f8eSopenharmony_ci   * Obtains the file directory of this application on the internal storage.
39161847f8eSopenharmony_ci   *
39261847f8eSopenharmony_ci   * @param { AsyncCallback<string> } callback - Return the file directory of this application on internal storage.
39361847f8eSopenharmony_ci   * @syscap SystemCapability.Ability.AbilityRuntime.Core
39461847f8eSopenharmony_ci   * @FAModelOnly
39561847f8eSopenharmony_ci   * @since 6
39661847f8eSopenharmony_ci   */
39761847f8eSopenharmony_ci  getFilesDir(callback: AsyncCallback<string>): void;
39861847f8eSopenharmony_ci
39961847f8eSopenharmony_ci  /**
40061847f8eSopenharmony_ci   * Obtains the file directory of this application on the internal storage.
40161847f8eSopenharmony_ci   *
40261847f8eSopenharmony_ci   * @returns { Promise<string> } Return the file directory of this application on internal storage.
40361847f8eSopenharmony_ci   * @syscap SystemCapability.Ability.AbilityRuntime.Core
40461847f8eSopenharmony_ci   * @FAModelOnly
40561847f8eSopenharmony_ci   * @since 6
40661847f8eSopenharmony_ci   */
40761847f8eSopenharmony_ci  getFilesDir(): Promise<string>;
40861847f8eSopenharmony_ci
40961847f8eSopenharmony_ci  /**
41061847f8eSopenharmony_ci   * Obtains the cache directory of this application on the internal storage.
41161847f8eSopenharmony_ci   *
41261847f8eSopenharmony_ci   * @param { AsyncCallback<string> } callback - Returns the internal storage directory of the application.
41361847f8eSopenharmony_ci   * @syscap SystemCapability.Ability.AbilityRuntime.Core
41461847f8eSopenharmony_ci   * @FAModelOnly
41561847f8eSopenharmony_ci   * @since 6
41661847f8eSopenharmony_ci   */
41761847f8eSopenharmony_ci  getCacheDir(callback: AsyncCallback<string>): void;
41861847f8eSopenharmony_ci
41961847f8eSopenharmony_ci  /**
42061847f8eSopenharmony_ci   * Obtains the cache directory of this application on the internal storage.
42161847f8eSopenharmony_ci   *
42261847f8eSopenharmony_ci   * @returns { Promise<string> } Returns the internal storage directory of the application.
42361847f8eSopenharmony_ci   * @syscap SystemCapability.Ability.AbilityRuntime.Core
42461847f8eSopenharmony_ci   * @FAModelOnly
42561847f8eSopenharmony_ci   * @since 6
42661847f8eSopenharmony_ci   */
42761847f8eSopenharmony_ci  getCacheDir(): Promise<string>;
42861847f8eSopenharmony_ci
42961847f8eSopenharmony_ci  /**
43061847f8eSopenharmony_ci   * Obtains the distributed file path for storing ability or application data files.
43161847f8eSopenharmony_ci   * If the distributed file path does not exist, the system will create a path and return the created path.
43261847f8eSopenharmony_ci   *
43361847f8eSopenharmony_ci   * @returns { Promise<string> } Returns the distributed file path of the Ability or application. If it is the first
43461847f8eSopenharmony_ci   *                              call, a directory will be created.
43561847f8eSopenharmony_ci   * @syscap SystemCapability.Ability.AbilityRuntime.Core
43661847f8eSopenharmony_ci   * @FAModelOnly
43761847f8eSopenharmony_ci   * @since 7
43861847f8eSopenharmony_ci   */
43961847f8eSopenharmony_ci  getOrCreateDistributedDir(): Promise<string>;
44061847f8eSopenharmony_ci
44161847f8eSopenharmony_ci  /**
44261847f8eSopenharmony_ci   * Obtains the distributed file path for storing ability or application data files.
44361847f8eSopenharmony_ci   * If the distributed file path does not exist, the system will create a path and return the created path.
44461847f8eSopenharmony_ci   *
44561847f8eSopenharmony_ci   * @param { AsyncCallback<string> } callback - Returns the distributed file path of Ability or application.
44661847f8eSopenharmony_ci   *                                  If the path does not exist,the system will create a path and return the created path.
44761847f8eSopenharmony_ci   * @syscap SystemCapability.Ability.AbilityRuntime.Core
44861847f8eSopenharmony_ci   * @FAModelOnly
44961847f8eSopenharmony_ci   * @since 7
45061847f8eSopenharmony_ci   */
45161847f8eSopenharmony_ci  getOrCreateDistributedDir(callback: AsyncCallback<string>): void;
45261847f8eSopenharmony_ci
45361847f8eSopenharmony_ci  /**
45461847f8eSopenharmony_ci   * Obtains the application type.
45561847f8eSopenharmony_ci   *
45661847f8eSopenharmony_ci   * @param { AsyncCallback<string> } callback - Returns the type of the current application.
45761847f8eSopenharmony_ci   * @syscap SystemCapability.Ability.AbilityRuntime.Core
45861847f8eSopenharmony_ci   * @FAModelOnly
45961847f8eSopenharmony_ci   * @since 7
46061847f8eSopenharmony_ci   */
46161847f8eSopenharmony_ci  getAppType(callback: AsyncCallback<string>): void;
46261847f8eSopenharmony_ci
46361847f8eSopenharmony_ci  /**
46461847f8eSopenharmony_ci   * Obtains the application type.
46561847f8eSopenharmony_ci   *
46661847f8eSopenharmony_ci   * @returns { Promise<string> } Returns the type of this app.
46761847f8eSopenharmony_ci   * @syscap SystemCapability.Ability.AbilityRuntime.Core
46861847f8eSopenharmony_ci   * @FAModelOnly
46961847f8eSopenharmony_ci   * @since 7
47061847f8eSopenharmony_ci   */
47161847f8eSopenharmony_ci  getAppType(): Promise<string>;
47261847f8eSopenharmony_ci
47361847f8eSopenharmony_ci  /**
47461847f8eSopenharmony_ci   * Obtains the ModuleInfo object for this application.
47561847f8eSopenharmony_ci   *
47661847f8eSopenharmony_ci   * @param { AsyncCallback<HapModuleInfo> } callback - Returns the ModuleInfo object of the application.
47761847f8eSopenharmony_ci   * @syscap SystemCapability.Ability.AbilityRuntime.Core
47861847f8eSopenharmony_ci   * @FAModelOnly
47961847f8eSopenharmony_ci   * @since 7
48061847f8eSopenharmony_ci   */
48161847f8eSopenharmony_ci  getHapModuleInfo(callback: AsyncCallback<HapModuleInfo>): void;
48261847f8eSopenharmony_ci
48361847f8eSopenharmony_ci  /**
48461847f8eSopenharmony_ci   * Obtains the ModuleInfo object for this application.
48561847f8eSopenharmony_ci   *
48661847f8eSopenharmony_ci   * @returns { Promise<HapModuleInfo> } Return to the ModuleInfo of the application and enjoy it.
48761847f8eSopenharmony_ci   * @syscap SystemCapability.Ability.AbilityRuntime.Core
48861847f8eSopenharmony_ci   * @FAModelOnly
48961847f8eSopenharmony_ci   * @since 7
49061847f8eSopenharmony_ci   */
49161847f8eSopenharmony_ci  getHapModuleInfo(): Promise<HapModuleInfo>;
49261847f8eSopenharmony_ci
49361847f8eSopenharmony_ci  /**
49461847f8eSopenharmony_ci   * Obtains the application version information.
49561847f8eSopenharmony_ci   *
49661847f8eSopenharmony_ci   * @param { AsyncCallback<AppVersionInfo> } callback - Return application version information.
49761847f8eSopenharmony_ci   * @syscap SystemCapability.Ability.AbilityRuntime.Core
49861847f8eSopenharmony_ci   * @FAModelOnly
49961847f8eSopenharmony_ci   * @since 7
50061847f8eSopenharmony_ci   */
50161847f8eSopenharmony_ci  getAppVersionInfo(callback: AsyncCallback<AppVersionInfo>): void;
50261847f8eSopenharmony_ci
50361847f8eSopenharmony_ci  /**
50461847f8eSopenharmony_ci   * Obtains the application version information.
50561847f8eSopenharmony_ci   *
50661847f8eSopenharmony_ci   * @returns { Promise<AppVersionInfo> } Return application version information.
50761847f8eSopenharmony_ci   * @syscap SystemCapability.Ability.AbilityRuntime.Core
50861847f8eSopenharmony_ci   * @FAModelOnly
50961847f8eSopenharmony_ci   * @since 7
51061847f8eSopenharmony_ci   */
51161847f8eSopenharmony_ci  getAppVersionInfo(): Promise<AppVersionInfo>;
51261847f8eSopenharmony_ci
51361847f8eSopenharmony_ci  /**
51461847f8eSopenharmony_ci   * Obtains the context of this application.
51561847f8eSopenharmony_ci   *
51661847f8eSopenharmony_ci   * @returns { Context } Return application context information.
51761847f8eSopenharmony_ci   * @syscap SystemCapability.Ability.AbilityRuntime.Core
51861847f8eSopenharmony_ci   * @FAModelOnly
51961847f8eSopenharmony_ci   * @since 7
52061847f8eSopenharmony_ci   */
52161847f8eSopenharmony_ci  getApplicationContext(): Context;
52261847f8eSopenharmony_ci
52361847f8eSopenharmony_ci  /**
52461847f8eSopenharmony_ci   * Checks the detailed information of this ability.
52561847f8eSopenharmony_ci   *
52661847f8eSopenharmony_ci   * @param { AsyncCallback<AbilityInfo> } callback - Return the detailed information of the current belonging Ability.
52761847f8eSopenharmony_ci   * @syscap SystemCapability.Ability.AbilityRuntime.Core
52861847f8eSopenharmony_ci   * @FAModelOnly
52961847f8eSopenharmony_ci   * @since 7
53061847f8eSopenharmony_ci   */
53161847f8eSopenharmony_ci  getAbilityInfo(callback: AsyncCallback<AbilityInfo>): void;
53261847f8eSopenharmony_ci
53361847f8eSopenharmony_ci  /**
53461847f8eSopenharmony_ci   * Checks the detailed information of this ability.
53561847f8eSopenharmony_ci   *
53661847f8eSopenharmony_ci   * @returns { Promise<AbilityInfo> } Return the detailed information of the current belonging Ability.
53761847f8eSopenharmony_ci   * @syscap SystemCapability.Ability.AbilityRuntime.Core
53861847f8eSopenharmony_ci   * @FAModelOnly
53961847f8eSopenharmony_ci   * @since 7
54061847f8eSopenharmony_ci   */
54161847f8eSopenharmony_ci  getAbilityInfo(): Promise<AbilityInfo>;
54261847f8eSopenharmony_ci
54361847f8eSopenharmony_ci  /**
54461847f8eSopenharmony_ci   * Checks whether the configuration of this ability is changing.
54561847f8eSopenharmony_ci   *
54661847f8eSopenharmony_ci   * @param { AsyncCallback<boolean> } callback - True if the configuration of the capability is being changed, otherwise false.
54761847f8eSopenharmony_ci   * @syscap SystemCapability.Ability.AbilityRuntime.Core
54861847f8eSopenharmony_ci   * @FAModelOnly
54961847f8eSopenharmony_ci   * @since 7
55061847f8eSopenharmony_ci   */
55161847f8eSopenharmony_ci  isUpdatingConfigurations(callback: AsyncCallback<boolean>): void;
55261847f8eSopenharmony_ci
55361847f8eSopenharmony_ci  /**
55461847f8eSopenharmony_ci   * Checks whether the configuration of this ability is changing.
55561847f8eSopenharmony_ci   *
55661847f8eSopenharmony_ci   * @returns { Promise<boolean> } true if the configuration of this ability is changing and false otherwise.
55761847f8eSopenharmony_ci   * @syscap SystemCapability.Ability.AbilityRuntime.Core
55861847f8eSopenharmony_ci   * @FAModelOnly
55961847f8eSopenharmony_ci   * @since 7
56061847f8eSopenharmony_ci   */
56161847f8eSopenharmony_ci  isUpdatingConfigurations(): Promise<boolean>;
56261847f8eSopenharmony_ci
56361847f8eSopenharmony_ci  /**
56461847f8eSopenharmony_ci   * Inform the system of the time required for drawing this Page ability.
56561847f8eSopenharmony_ci   *
56661847f8eSopenharmony_ci   * @param { AsyncCallback<void> } callback - Represents the specified callback method.
56761847f8eSopenharmony_ci   * @syscap SystemCapability.Ability.AbilityRuntime.Core
56861847f8eSopenharmony_ci   * @FAModelOnly
56961847f8eSopenharmony_ci   * @since 7
57061847f8eSopenharmony_ci   */
57161847f8eSopenharmony_ci  printDrawnCompleted(callback: AsyncCallback<void>): void;
57261847f8eSopenharmony_ci
57361847f8eSopenharmony_ci  /**
57461847f8eSopenharmony_ci   * Inform the system of the time required for drawing this Page ability.
57561847f8eSopenharmony_ci   *
57661847f8eSopenharmony_ci   * @returns { Promise<void> } The promise form returns the result.
57761847f8eSopenharmony_ci   * @syscap SystemCapability.Ability.AbilityRuntime.Core
57861847f8eSopenharmony_ci   * @FAModelOnly
57961847f8eSopenharmony_ci   * @since 7
58061847f8eSopenharmony_ci   */
58161847f8eSopenharmony_ci  printDrawnCompleted(): Promise<void>;
58261847f8eSopenharmony_ci}
58361847f8eSopenharmony_ci/**
58461847f8eSopenharmony_ci * @typedef PermissionRequestResult
58561847f8eSopenharmony_ci * @syscap SystemCapability.Ability.AbilityRuntime.Core
58661847f8eSopenharmony_ci * @FAModelOnly
58761847f8eSopenharmony_ci * @since 7
58861847f8eSopenharmony_ci */
58961847f8eSopenharmony_ciinterface PermissionRequestResult {
59061847f8eSopenharmony_ci  /**
59161847f8eSopenharmony_ci   * @type { number }
59261847f8eSopenharmony_ci   * @default The request code passed in by the user
59361847f8eSopenharmony_ci   * @syscap SystemCapability.Ability.AbilityRuntime.Core
59461847f8eSopenharmony_ci   * @FAModelOnly
59561847f8eSopenharmony_ci   * @since 7
59661847f8eSopenharmony_ci   */
59761847f8eSopenharmony_ci  requestCode: number;
59861847f8eSopenharmony_ci
59961847f8eSopenharmony_ci  /**
60061847f8eSopenharmony_ci   * @type { Array<string> }
60161847f8eSopenharmony_ci   * @default The permissions passed in by the user
60261847f8eSopenharmony_ci   * @syscap SystemCapability.Ability.AbilityRuntime.Core
60361847f8eSopenharmony_ci   * @FAModelOnly
60461847f8eSopenharmony_ci   * @since 7
60561847f8eSopenharmony_ci   */
60661847f8eSopenharmony_ci  permissions: Array<string>;
60761847f8eSopenharmony_ci
60861847f8eSopenharmony_ci  /**
60961847f8eSopenharmony_ci   * @type { Array<number> }
61061847f8eSopenharmony_ci   * @default The results for the corresponding request permissions
61161847f8eSopenharmony_ci   * @syscap SystemCapability.Ability.AbilityRuntime.Core
61261847f8eSopenharmony_ci   * @FAModelOnly
61361847f8eSopenharmony_ci   * @since 7
61461847f8eSopenharmony_ci   */
61561847f8eSopenharmony_ci  authResults: Array<number>;
61661847f8eSopenharmony_ci}
61761847f8eSopenharmony_ci
61861847f8eSopenharmony_ci/**
61961847f8eSopenharmony_ci * @typedef PermissionOptions
62061847f8eSopenharmony_ci * @syscap SystemCapability.Ability.AbilityRuntime.Core
62161847f8eSopenharmony_ci * @FAModelOnly
62261847f8eSopenharmony_ci * @since 7
62361847f8eSopenharmony_ci */
62461847f8eSopenharmony_ciinterface PermissionOptions {
62561847f8eSopenharmony_ci  /**
62661847f8eSopenharmony_ci   * @type { ?number }
62761847f8eSopenharmony_ci   * @default The process id
62861847f8eSopenharmony_ci   * @syscap SystemCapability.Ability.AbilityRuntime.Core
62961847f8eSopenharmony_ci   * @FAModelOnly
63061847f8eSopenharmony_ci   * @since 7
63161847f8eSopenharmony_ci   */
63261847f8eSopenharmony_ci  pid?: number;
63361847f8eSopenharmony_ci
63461847f8eSopenharmony_ci  /**
63561847f8eSopenharmony_ci   * @type { ?number }
63661847f8eSopenharmony_ci   * @default The user id
63761847f8eSopenharmony_ci   * @syscap SystemCapability.Ability.AbilityRuntime.Core
63861847f8eSopenharmony_ci   * @FAModelOnly
63961847f8eSopenharmony_ci   * @since 7
64061847f8eSopenharmony_ci   */
64161847f8eSopenharmony_ci  uid?: number;
64261847f8eSopenharmony_ci}
643