From 550655e852788c3bf2f5f9c365d941f4268a9082 Mon Sep 17 00:00:00 2001 From: dy_study Date: Wed, 2 Mar 2022 02:37:39 +0000 Subject: [PATCH] fixed a3c4480 from https://gitee.com/test-chamber/interface_sdk-js/pulls/841 IssueNo:api7 ts Description:commit applicationFramework api7 interface ts files Sig:SIG_ApplicationFramework Feature or Bugfix: Feature Binary Source: No Signed-off-by: dy_study Change-Id: Id5077cb0282c46fb0e5c93265055434ea8eee6b1 --- api/@ohos.ability.errorCode.d.ts | 49 +++++++++++++ api/@ohos.ability.featureAbility.d.ts | 1 + api/@ohos.ability.particleAbility.d.ts | 24 +++++++ api/@ohos.app.abilityManager.d.ts | 18 +++++ api/@ohos.bundle.d.ts | 74 ++++++++++++++++++-- api/ability/dataAbilityHelper.d.ts | 40 +++++++++++ api/app/appVersionInfo.d.ts | 46 ++++++++++++ api/app/context.d.ts | 97 +++++++++++++++++++++++++- api/app/processInfo.d.ts | 2 +- 9 files changed, 343 insertions(+), 8 deletions(-) create mode 100644 api/@ohos.ability.errorCode.d.ts create mode 100644 api/app/appVersionInfo.d.ts diff --git a/api/@ohos.ability.errorCode.d.ts b/api/@ohos.ability.errorCode.d.ts new file mode 100644 index 0000000000..155f039766 --- /dev/null +++ b/api/@ohos.ability.errorCode.d.ts @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + /** + * Defines error codes used when starting an ability, for example, featureAbility.ErrorCode.NO_ERROR. + * @since 6 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + */ +export enum ErrorCode { + /** + * Permission denied. + * @since 6 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + */ + PERMISSION_DENY = -3, + + /** + * Ability not found. + * @since 6 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + */ + ABILITY_NOT_FOUND = -2, + + /** + * Invalid parameter. + * @since 6 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + */ + INVALID_PARAMETER = -1, + + /** + * No error. + * @since 6 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + */ + NO_ERROR = 0 +} diff --git a/api/@ohos.ability.featureAbility.d.ts b/api/@ohos.ability.featureAbility.d.ts index 0aebda140e..44de8063d5 100644 --- a/api/@ohos.ability.featureAbility.d.ts +++ b/api/@ohos.ability.featureAbility.d.ts @@ -13,6 +13,7 @@ * limitations under the License. */ import { AsyncCallback } from './basic'; +import { Callback } from './basic'; import { Want } from './ability/want'; import { StartAbilityParameter } from './ability/startAbilityParameter'; import { AbilityResult } from './ability/abilityResult'; diff --git a/api/@ohos.ability.particleAbility.d.ts b/api/@ohos.ability.particleAbility.d.ts index 968b176d9c..f6d62b65b4 100644 --- a/api/@ohos.ability.particleAbility.d.ts +++ b/api/@ohos.ability.particleAbility.d.ts @@ -17,6 +17,8 @@ import { AsyncCallback } from './basic'; import { StartAbilityParameter } from './ability/startAbilityParameter'; import { DataAbilityHelper } from './ability/dataAbilityHelper'; import { NotificationRequest } from './notification/notificationRequest'; +import { ConnectOptions } from './ability/connectOptions'; +import { Want } from './ability/want'; /** * A Particle Ability represents an ability with service. @@ -85,5 +87,27 @@ declare namespace particleAbility { */ function cancelBackgroundRunning(callback: AsyncCallback): void; function cancelBackgroundRunning(): Promise; + + /** + * Connects an ability to a Service ability. + * + * @since 7 + * @syscap SystemCapability.Ability.AbilityRuntime.FAModel + * @param request Indicates the Service ability to connect. + * @param options Callback object for the client. If this parameter is null, an exception is thrown. + * @return unique identifier of the connection between the client and the service side. + * @FAModelOnly + */ + function connectAbility(request: Want, options:ConnectOptions ): number; + + /** + * Disconnects ability to a Service ability. + * @since 7 + * @syscap SystemCapability.Ability.AbilityRuntime.FAModel + * @param connection the connection id returned from connectAbility api. + * @FAModelOnly + */ + function disconnectAbility(connection: number, callback:AsyncCallback): void; + function disconnectAbility(connection: number): Promise; } export default particleAbility; diff --git a/api/@ohos.app.abilityManager.d.ts b/api/@ohos.app.abilityManager.d.ts index cc24a83c7b..8dc9575ac0 100644 --- a/api/@ohos.app.abilityManager.d.ts +++ b/api/@ohos.app.abilityManager.d.ts @@ -80,6 +80,24 @@ declare namespace abilityManager { */ function deleteMissions(missionIds: Array): Promise; function deleteMissions(missionIds: Array, callback: AsyncCallback): void; + + /** + * Is it a ram-constrained device + * @since 7 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @return whether a ram-constrained device. + */ + function isRamConstrainedDevice(): Promise; + function isRamConstrainedDevice(callback: AsyncCallback): void; + + /** + * Get the memory size of the application + * @since 7 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @return application memory size. + */ + function getAppMemorySize(): Promise; + function getAppMemorySize(callback: AsyncCallback): void; } export default abilityManager; diff --git a/api/@ohos.bundle.d.ts b/api/@ohos.bundle.d.ts index 8d2be229f4..fc8040c3f8 100644 --- a/api/@ohos.bundle.d.ts +++ b/api/@ohos.bundle.d.ts @@ -23,6 +23,7 @@ import { BundleInstaller } from './bundle/bundleInstaller'; import { ShortcutInfo } from './bundle/shortcutInfo'; import { ModuleUsageRecord } from './bundle/moduleUsageRecord'; import { PermissionDef } from './bundle/PermissionDef'; +import image from './@ohos.multimedia.image'; /** * bundle. @@ -384,6 +385,19 @@ declare namespace bundle { */ function getBundleInstaller(callback: AsyncCallback): void; function getBundleInstaller(): Promise; + + /** + * Obtains information about the current ability. + * + * @since 7 + * @syscap SystemCapability.BundleManager.BundleFramework + * @param bundleName Indicates the application bundle name to be queried. + * @param abilityName Indicates the ability name. + * @return Returns the AbilityInfo object for the current ability. + * @permission ohos.permission.GET_BUNDLE_INFO_PRIVILEGED, ohos.permission.GET_BUNDLE_INFO + */ + function getAbilityInfo(bundleName: string, abilityName: string, callback: AsyncCallback): void; + function getAbilityInfo(bundleName: string, abilityName: string): Promise; /** * Obtains based on a given bundle name. @@ -393,12 +407,13 @@ declare namespace bundle { * @param bundleName Indicates the application bundle name to be queried. * @param bundleFlags Indicates the flag used to specify information contained in the ApplicationInfo object * that will be returned. - * @param userId Indicates the user ID. + * @param userId Indicates the user ID or do not pass user ID. * @return Returns the ApplicationInfo object. * @permission ohos.permission.GET_BUNDLE_INFO_PRIVILEGED, ohos.permission.GET_BUNDLE_INFO */ function getApplicationInfo(bundleName: string, bundleFlags: number, userId: number, callback: AsyncCallback) : void; - function getApplicationInfo(bundleName: string, bundleFlags: number, userId: number) : Promise; + function getApplicationInfo(bundleName: string, bundleFlags: number, callback: AsyncCallback) : void; + function getApplicationInfo(bundleName: string, bundleFlags: number, userId?: number) : Promise; /** * Query the AbilityInfo by the given Want. @@ -439,12 +454,13 @@ declare namespace bundle { * @syscap SystemCapability.BundleManager.BundleFramework * @param bundleFlags Indicates the flag used to specify information contained in the ApplicationInfo objects * that will be returned. - * @param userId Indicates the user ID. + * @param userId Indicates the user ID or do not pass user ID. * @return Returns a list of ApplicationInfo objects. * @permission ohos.permission.GET_BUNDLE_INFO_PRIVILEGED */ function getAllApplicationInfo(bundleFlags: number, userId: number, callback: AsyncCallback>) : void; - function getAllApplicationInfo(bundleFlags: number, userId: number) : Promise>; + function getAllApplicationInfo(bundleFlags: number, callback: AsyncCallback>) : void; + function getAllApplicationInfo(bundleFlags: number, userId?: number) : Promise>; /** * Obtains bundle name by the given uid. @@ -471,8 +487,6 @@ declare namespace bundle { function getBundleArchiveInfo(hapFilePath: string, bundleFlags: number, callback: AsyncCallback) : void function getBundleArchiveInfo(hapFilePath: string, bundleFlags: number) : Promise; - /** - /** * Obtains the Want for starting the main ability of an application based on the * given bundle name. The main ability of an application is the ability that has the @@ -582,6 +596,54 @@ declare namespace bundle { */ function getPermissionDef(permissionName: string, callback: AsyncCallback): void; function getPermissionDef(permissionName: string): Promise; + + /** + * Obtains the label of a specified ability. + * + * @since 8 + * @syscap SystemCapability.BundleManager.BundleFramework + * @param bundleName Indicates the bundle name of the application to which the ability belongs. + * @param abilityName Indicates the ability name. + * @permission ohos.permission.GET_BUNDLE_INFO_PRIVILEGED + * @return Returns the label representing the label of the specified ability. + */ + function getAbilityLabel(bundleName: string, abilityName: string, callback: AsyncCallback): void; + function getAbilityLabel(bundleName: string, abilityName: string): Promise; + + /** + * Obtains the icon of a specified ability. + * + * @since 8 + * @syscap SystemCapability.BundleManager.BundleFramework + * @param bundleName Indicates the bundle name of the application to which the ability belongs. + * @param abilityName Indicates the ability name. + * @return Returns the PixelMap object representing the icon of the specified ability. + * @permission ohos.permission.GET_BUNDLE_INFO_PRIVILEGED + */ + function getAbilityIcon(bundleName: string, abilityName: string, callback: AsyncCallback): void; + function getAbilityIcon(bundleName: string, abilityName: string): Promise; + + /** + * Checks whether a specified ability is enabled. + * + * @since 8 + * @syscap SystemCapability.BundleManager.BundleFramework + * @param info Indicates information about the ability to check. + * @returns Returns true if the ability is enabled; returns false otherwise. + */ + function isAbilityEnabled(info: AbilityInfo, callback: AsyncCallback): void; + function isAbilityEnabled(info: AbilityInfo): Promise; + + /** + * Checks whether a specified application is enabled. + * + * @since 8 + * @syscap SystemCapability.BundleManager.BundleFramework + * @param bundleName Indicates the bundle name of the application. + * @returns Returns true if the application is enabled; returns false otherwise. + */ + function isApplicationEnabled(bundleName: string, callback: AsyncCallback): void; + function isApplicationEnabled(bundleName: string): Promise; } export default bundle; diff --git a/api/ability/dataAbilityHelper.d.ts b/api/ability/dataAbilityHelper.d.ts index f1bf139a73..1fd91039bf 100644 --- a/api/ability/dataAbilityHelper.d.ts +++ b/api/ability/dataAbilityHelper.d.ts @@ -198,4 +198,44 @@ export interface DataAbilityHelper { */ query(uri: string, columns: Array, predicates: dataAbility.DataAbilityPredicates, callback: AsyncCallback): void; query(uri: string, columns: Array, predicates: dataAbility.DataAbilityPredicates): Promise; + + /** + * Calls the extended API of the DataAbility. This method uses a promise to return the result. + * + * @since 7 + * @syscap SystemCapability.Ability.AbilityRuntime.FAModel + * @param uri URI of the Data ability. Example: "dataability:///com.example.xxx.xxxx" + * @param method Indicates the method to call. + * @param arg Indicates the parameter of the String type. + * @param extras Indicates the parameter of the PacMap type. + * If a custom Sequenceable object is put in the PacMap object and will be transferred across processes, + * you must call BasePacMap.setClassLoader(ClassLoader) to set a class loader for the custom object. + * If the PacMap object is to be transferred to a non-OHOS process, + * values of primitive types are supported, but not custom Sequenceable objects. + * @return Returns the query result {@link PacMap}. + * @FAModelOnly + */ + call(uri: string, method: string, arg: string, extras: PacMap, callback: AsyncCallback): void; + call(uri: string, method: string, arg: string, extras: PacMap): Promise; +} + +/** + * Defines a PacMap object for storing a series of values. + * @since 7 + * @syscap SystemCapability.Ability.AbilityRuntime.FAModel + * @FAModelOnly + */ + export interface PacMap { + + /** + * Indicates the parameter of the PacMap type. + * If a custom Sequenceable object is put in the PacMap object and will be transferred across processes, + * you must call BasePacMap.setClassLoader(ClassLoader) to set a class loader for the custom object. + * If the PacMap object is to be transferred to a non-OHOS process, + * values of primitive types are supported, but not custom Sequenceable objects. + * @since 7 + * @syscap SystemCapability.Ability.AbilityRuntime.FAModel + * @FAModelOnly + */ + [key: string]: number | string | boolean | Array | null; } diff --git a/api/app/appVersionInfo.d.ts b/api/app/appVersionInfo.d.ts new file mode 100644 index 0000000000..9aa63fc268 --- /dev/null +++ b/api/app/appVersionInfo.d.ts @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * Defines an AppVersionInfo object. + * @since 7 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + */ +export interface AppVersionInfo { + + /** + * Application name. + * @default appName + * @since 7 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + */ + readonly appName: string; + + /** + * Application version number. + * @default versionCode + * @since 7 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + */ + readonly versionCode: number; + + /** + * Application version name. + * @default versionName + * @since 7 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + */ + readonly versionName: string; +} diff --git a/api/app/context.d.ts b/api/app/context.d.ts index 06097c18c9..048c033f5d 100644 --- a/api/app/context.d.ts +++ b/api/app/context.d.ts @@ -18,6 +18,10 @@ import { ApplicationInfo } from '../bundle/applicationInfo'; import { ProcessInfo } from './processInfo'; import { ElementName } from '../bundle/elementName'; import BaseContext from '../application/BaseContext'; +import { HapModuleInfo } from '../bundle/hapModuleInfo'; +import { AppVersionInfo } from './appVersionInfo'; +import { AbilityInfo } from '../bundle/abilityInfo'; + /** * The context of an ability or an application. It allows access to @@ -126,6 +130,97 @@ export interface Context extends BaseContext { */ getCallingBundle(callback: AsyncCallback): void getCallingBundle(): Promise; + + /** + * Obtains the file directory of this application on the internal storage. + * @since 7 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @FAModelOnly + */ + getFilesDir(callback: AsyncCallback): void; + getFilesDir(): Promise; + + /** + * Obtains the cache directory of this application on the internal storage. + * @since 7 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @FAModelOnly + */ + getCacheDir(callback: AsyncCallback): void; + getCacheDir(): Promise; + + /** + * Obtains the distributed file path for storing ability or application data files. + * If the distributed file path does not exist, the system will create a path and return the created path. + * @since 7 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @FAModelOnly + */ + getOrCreateDistributedDir(): Promise; + getOrCreateDistributedDir(callback: AsyncCallback): void; + + /** + * Obtains the application type. + * @since 7 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @FAModelOnly + */ + getAppType(callback: AsyncCallback): void + getAppType(): Promise; + + /** + * Obtains the ModuleInfo object for this application. + * @since 7 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @FAModelOnly + */ + getHapModuleInfo(callback: AsyncCallback): void + getHapModuleInfo(): Promise; + + /** + * Obtains the application version information. + * @since 7 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @FAModelOnly + */ + getAppVersionInfo(callback: AsyncCallback): void + getAppVersionInfo(): Promise; + + /** + * Obtains the context of this application. + * @since 7 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @FAModelOnly + */ + getApplicationContext(): Context; + + /** + * Checks the detailed information of this ability. + * @since 7 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @FAModelOnly + */ + getAbilityInfo(callback: AsyncCallback): void + getAbilityInfo(): Promise; + + /** + * Checks whether the configuration of this ability is changing. + * @since 7 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @return true if the configuration of this ability is changing and false otherwise. + * @FAModelOnly + */ + isUpdatingConfigurations(): Promise; + isUpdatingConfigurations(callback: AsyncCallback): void; + + /** + * Informs the system of the time required for drawing this Page ability. + * @since 7 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @FAModelOnly + */ + printDrawnCompleted(): Promise; + printDrawnCompleted(callback: AsyncCallback): void; } /** @@ -184,4 +279,4 @@ interface PermissionOptions { * @FAModelOnly */ uid?: number; -} \ No newline at end of file +} diff --git a/api/app/processInfo.d.ts b/api/app/processInfo.d.ts index 1074141503..5f3c2a825d 100644 --- a/api/app/processInfo.d.ts +++ b/api/app/processInfo.d.ts @@ -37,5 +37,5 @@ export interface ProcessInfo { * @since 7 * @syscap SystemCapability.Ability.AbilityRuntime.Core */ - processName: string; + processName: string; } \ No newline at end of file -- Gitee