From 669e4361d29e62b7bd7d59aa9151cf7c74280af0 Mon Sep 17 00:00:00 2001 From: shilei Date: Thu, 13 Oct 2022 21:44:45 +0800 Subject: [PATCH] add Signed-off-by: shilei Change-Id: I3e4de2cd908b75c60b75a009f1c2b6cbf940ada5 --- api/@ohos.bundle.bundleManager.d.ts | 122 +++++++++++++++++++ api/@ohos.bundle.d.ts | 2 + api/@ohos.bundle.installer.d.ts | 181 ++++++++++++++++++++++++++++ api/bundle/bundleInstaller.d.ts | 19 +++ 4 files changed, 324 insertions(+) create mode 100644 api/@ohos.bundle.bundleManager.d.ts create mode 100644 api/@ohos.bundle.installer.d.ts diff --git a/api/@ohos.bundle.bundleManager.d.ts b/api/@ohos.bundle.bundleManager.d.ts new file mode 100644 index 0000000000..754bb104fa --- /dev/null +++ b/api/@ohos.bundle.bundleManager.d.ts @@ -0,0 +1,122 @@ +/* + * 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. + */ + +import { AsyncCallback } from './basic'; + +/** + * 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 + * #ACTION_HOME and #ENTITY_HOME Want filters set in the application's config.json or module.json file. + * @permission ohos.permission.GET_BUNDLE_INFO_PRIVILEGED + * @param { string } bundleName - Indicates the bundle name of the application. + * @param { number } userId - Indicates the user ID or do not pass user ID. + * @param { AsyncCallback } callback - The callback for starting the application's main ability. + * @throws { BusinessError } 201 - Calling interface without permission 'ohos.permission.GET_BUNDLE_INFO_PRIVILEGED'. + * @throws { BusinessError } 401 - Input parameters check failed. + * @throws { BusinessError } 17700001 - The specified bundleName is not existed. + * @throws { BusinessError } 17700004 - The specified userId is not existed. + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @since 9 + */ +function getLaunchWantForBundle(bundleName: string, userId: number, callback: AsyncCallback): void; + +/** + * 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 + * #ACTION_HOME and #ENTITY_HOME Want filters set in the application's config.json or module.json file. + * @permission ohos.permission.GET_BUNDLE_INFO_PRIVILEGED + * @param { string } bundleName - Indicates the bundle name of the application. + * @param { AsyncCallback } callback - The callback for starting the application's main ability. + * @throws { BusinessError } 201 - Calling interface without permission 'ohos.permission.GET_BUNDLE_INFO_PRIVILEGED'. + * @throws { BusinessError } 401 - Input parameters check failed. + * @throws { BusinessError } 17700001 - The specified bundleName is not existed. + * @throws { BusinessError } 17700004 - The specified userId is not existed. + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @since 9 + */ +function getLaunchWantForBundle(bundleName: string, callback: AsyncCallback): void; + +/** + * 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 + * #ACTION_HOME and #ENTITY_HOME Want filters set in the application's config.json or module.json file. + * @permission ohos.permission.GET_BUNDLE_INFO_PRIVILEGED + * @param { string } bundleName - Indicates the bundle name of the application. + * @param { number } userId - Indicates the user ID or do not pass user ID. + * @returns { Promise } the Want for starting the application's main ability. + * @throws { BusinessError } 201 - Calling interface without permission 'ohos.permission.GET_BUNDLE_INFO_PRIVILEGED'. + * @throws { BusinessError } 401 - Input parameters check failed. + * @throws { BusinessError } 17700001 - The specified bundleName is not existed. + * @throws { BusinessError } 17700004 - The specified userId is not existed. + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @since 9 + */ +function getLaunchWantForBundle(bundleName: string, userId?: number): Promise; + +/** + * Obtains the profile designated by metadata name, abilityName and moduleName from the current application. + * @param { string } moduleName - Indicates the moduleName of the application. + * @param { string } abilityName - Indicates the abilityName of the application. + * @param { string } metadataName - Indicates the name of metadata in ability. + * @param { AsyncCallback } callback - The callback of returning string in json-format of the corresponding config file. + * @throws { BusinessError } 401 - Input parameters check failed. + * @throws { BusinessError } 17700003 - The specified anilityName or moduleName is not existed. + * @throws { BusinessError } 17700024 - The specified metadataName is not existed or the profile is not json-format. + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @since 9 + */ +function getProfileByAbility(moduleName: string, abilityName: string, metadataName: string, callback: AsyncCallback>): void; + +/** + * Obtains the profile designated by metadata name, abilityName and moduleName from the current application. + * @param { string } moduleName - Indicates the moduleName of the application. + * @param { string } abilityName - Indicates the abilityName of the application. + * @param { string } metadataName - Indicates the name of metadata in ability. + * @returns { Promise> } Returns string in json-format of the corresponding config file. + * @throws { BusinessError } 401 - Input parameters check failed. + * @throws { BusinessError } 17700003 - The specified anilityName or moduleName is not existed. + * @throws { BusinessError } 17700024 - The specified metadataName is not existed or the profile is not json-format. + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @since 9 + */ +function getProfileByAbility(moduleName: string, abilityName: string, metadataName?: string): Promise>; + +/** + * Obtains the profile designated by metadata name, extensionAbilityName and moduleName from the current application. + * @param { string } moduleName - Indicates the moduleName of the application. + * @param { string } extensionAbilityName - Indicates the extensionAbilityName of the application. + * @param { string } metadataName - Indicates the name of metadata in ability. + * @param { AsyncCallback } callback - The callback of returning string in json-format of the corresponding config file. + * @throws { BusinessError } 401 - Input parameters check failed. + * @throws { BusinessError } 17700003 - The specified extensionAbilityName or moduleName is not existed. + * @throws { BusinessError } 17700024 - The specified metadataName is not existed or the profile is not json-format. + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @since 9 + */ +function getProfileByExtensionAbility(moduleName: string, extensionAbilityName: string, metadataName: string, callback: AsyncCallback>): void; + +/** + * Obtains the profile designated by metadata name, extensionAbilityName and moduleName from the current application. + * @param { string } moduleName - Indicates the moduleName of the application. + * @param { string } extensionAbilityName - Indicates the extensionAbilityName of the application. + * @param { string } metadataName - Indicates the name of metadata in ability. + * @returns { Promise> } Returns string in json-format of the corresponding config file. + * @throws { BusinessError } 401 - Input parameters check failed. + * @throws { BusinessError } 17700003 - The specified extensionAbilityName or moduleName is not existed. + * @throws { BusinessError } 17700024 - The specified metadataName is not existed or the profile is not json-format. + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @since 9 + */ +function getProfileByExtensionAbility(moduleName: string, extensionAbilityName: string, metadataName?: string): Promise>; \ No newline at end of file diff --git a/api/@ohos.bundle.d.ts b/api/@ohos.bundle.d.ts index 468be9fb97..8444c2188e 100644 --- a/api/@ohos.bundle.d.ts +++ b/api/@ohos.bundle.d.ts @@ -662,6 +662,8 @@ declare namespace bundle { * @return Returns the Want for starting the application's main ability if any; returns null if * the given bundle does not exist or does not contain any main ability. * @permission ohos.permission.GET_BUNDLE_INFO_PRIVILEGED + * @deprecated since 9 + * @useinstead ohos.bundle.bundleManager#getLaunchWantForBundle */ function getLaunchWantForBundle(bundleName: string, callback: AsyncCallback): void; function getLaunchWantForBundle(bundleName: string): Promise; diff --git a/api/@ohos.bundle.installer.d.ts b/api/@ohos.bundle.installer.d.ts new file mode 100644 index 0000000000..680468fa47 --- /dev/null +++ b/api/@ohos.bundle.installer.d.ts @@ -0,0 +1,181 @@ +/* + * 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. + */ + +import { AsyncCallback } from './basic'; + +/** + * Support install, upgrade, remove and recover bundles on the devices. + * @namespace installer + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @systemapi + * @since 9 + */ +declare namespace installer { + /** + * Obtains the interface used to install bundle. + * @param { AsyncCallback } callback - The callback of BundleInstaller object. + * @throws { BusinessError } 401 - Input parameters check failed. + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @systemapi + * @since 9 + */ + function getBundleInstaller(callback: AsyncCallback): void + + /** + * Obtains the interface used to install bundle. + * @param { AsyncCallback } callback - The callback of getting a list of BundleInstaller objects. + * @returns { Promise } BundleInstaller object. + * @throws { BusinessError } 401 - Input parameters check failed. + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @systemapi + * @since 9 + */ + function getBundleInstaller(): Promise; + + /** + * Bundle installer interface, include install uninstall recover. + * @interface BundleInstaller + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @systemapi + * @since 9 + */ + interface BundleInstaller { + /** + * Install haps for an application. + * @permission ohos.permission.INSTALL_BUNDLE + * @param { Array } hapFilePaths - Indicates the path where the hap of the application is stored. + * @param { InstallParam } installParam - Indicates other parameters required for the installation. + * @param { AsyncCallback } callback - The callback of installing haps result. + * @throws { BusinessError } 201 - Calling interface without permission 'ohos.permission.INSTALL_BUNDLE'. + * @throws { BusinessError } 401 - Input parameters check failed. + * @throws { BusinessError } 17700004 - The specified userId is not existed. + * @throws { BusinessError } 17700010 - To parse file of config.json or module.json failed. + * @throws { BusinessError } 17700011 - To verify signature failed. + * @throws { BusinessError } 17700012 - Invalid hapFilePaths since being lack of file or path. + * @throws { BusinessError } 17700013 - Too large size of hap file which exceeds the size limitation. + * @throws { BusinessError } 17700014 - The suffix of the hap name is not .hap. + * @throws { BusinessError } 17700015 - Multiple haps have inconsistent configured information. + * @throws { BusinessError } 17700016 - No disk space left for installation. + * @throws { BusinessError } 17700017 - Downgrade installation is prohibited. + * @throws { BusinessError } 17700101 - The system service is excepted. + * @throws { BusinessError } 17700103 - I/O operation is failed. + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @systemapi + * @since 9 + */ + install(hapFilePaths: Array, installParam: InstallParam, callback: AsyncCallback) : void; + + /** + * Uninstall an application. + * @permission ohos.permission.INSTALL_BUNDLE + * @param { string } bundleName - Indicates the bundle name of the application to be uninstalled. + * @param { InstallParam } installParam - Indicates other parameters required for the uninstallation. + * @param { AsyncCallback } callback - The callback of uninstalling application result. + * @throws { BusinessError } 201 - Calling interface without permission 'ohos.permission.INSTALL_BUNDLE'. + * @throws { BusinessError } 401 - Input parameters check failed. + * @throws { BusinessError } 17700004 - The specified userId is not existed. + * @throws { BusinessError } 17700020 - The specified bundle is pre-installed bundle which cannot be uninstalled. + * @throws { BusinessError } 17700101 - The system service is excepted. + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @systemapi + * @since 9 + */ + uninstall(bundleName: string, installParam: InstallParam, callback : AsyncCallback) : void; + + /** + * recover an application. + * @permission ohos.permission.INSTALL_BUNDLE + * @param { string } bundleName - Indicates the bundle name of the application to be uninstalled. + * @param { InstallParam } installParam - Indicates other parameters required for the uninstallation. + * @param { AsyncCallback } callback - The callback of recoverring application result. + * @throws { BusinessError } 201 - Calling interface without permission 'ohos.permission.INSTALL_BUNDLE'. + * @throws { BusinessError } 401 - Input parameters check failed. + * @throws { BusinessError } 17700004 - The specified userId is not existed. + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @systemapi + * @since 9 + */ + recover(bundleName: string, installParam: InstallParam, callback: AsyncCallback): void; + } + + /** + * Provides parameters required for hashParam. + * @typedef HashParam + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @systemapi + * @since 9 + */ + export interface HashParam { + /** + * Indicates the moduleName + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @since 9 + */ + moduleName: string; + + /** + * Indicates the hash value + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @since 9 + */ + hashValue: string; + } + + /** + * Provides parameters required for installing or uninstalling an application. + * @typedef InstallParam + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @systemapi + * @since 9 + */ + export interface InstallParam { + /** + * Indicates the user id + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @since 9 + */ + userId: number; + + /** + * Indicates the install flag + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @since 9 + */ + installFlag: number; + + /** + * Indicates whether the param has data + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @since 9 + */ + isKeepData: boolean; + + /** + * Indicates the hash params + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @since 9 + */ + hashParams?: Array; + + /** + * Indicates the deadline of the crowdtesting bundle + * @syscap SystemCapability.BundleManager.BundleFramework.Core + * @since 9 + */ + crowdtestDeadline?: number; + } +} + +export default installer; \ No newline at end of file diff --git a/api/bundle/bundleInstaller.d.ts b/api/bundle/bundleInstaller.d.ts index a2e31165f8..3aee486769 100644 --- a/api/bundle/bundleInstaller.d.ts +++ b/api/bundle/bundleInstaller.d.ts @@ -45,12 +45,16 @@ import bundle from './../@ohos.bundle'; * @syscap SystemCapability.BundleManager.BundleFramework * @permission NA * @systemapi Hide this for inner system use + * @deprecated since 9 + * @useinstead ohos.bundle.installer#InstallParam */ export interface InstallParam { /** * @default Indicates the user id * @since 7 * @syscap SystemCapability.BundleManager.BundleFramework + * @deprecated since 9 + * @useinstead ohos.bundle.installer.InstallParam#userId */ userId: number; @@ -58,6 +62,8 @@ export interface InstallParam { * @default Indicates the install flag * @since 7 * @syscap SystemCapability.BundleManager.BundleFramework + * @deprecated since 9 + * @useinstead ohos.bundle.installer.InstallParam#installFlag */ installFlag: number; @@ -65,6 +71,8 @@ export interface InstallParam { * @default Indicates whether the param has data * @since 7 * @syscap SystemCapability.BundleManager.BundleFramework + * @deprecated since 9 + * @useinstead ohos.bundle.installer.InstallParam#isKeepData */ isKeepData: boolean; @@ -89,6 +97,7 @@ export interface InstallParam { * @syscap SystemCapability.BundleManager.BundleFramework * @permission NA * @systemapi Hide this for inner system use + * @deprecated since 9 */ export interface InstallStatus { @@ -96,6 +105,7 @@ export interface InstallStatus { * @default Indicates the install or uninstall error code * @since 7 * @syscap SystemCapability.BundleManager.BundleFramework + * @deprecated since 9 */ status: bundle.InstallErrorCode; @@ -103,6 +113,7 @@ export interface InstallStatus { * @default Indicates the install or uninstall result string message * @since 7 * @syscap SystemCapability.BundleManager.BundleFramework + * @deprecated since 9 */ statusMessage: string; } @@ -113,6 +124,8 @@ export interface InstallStatus { * @syscap SystemCapability.BundleManager.BundleFramework * @permission NA * @systemapi Hide this for inner system use + * @deprecated since 9 + * @useinstead ohos.bundle.installer#BundleInstaller */ export interface BundleInstaller { /** @@ -126,6 +139,8 @@ export interface BundleInstaller { * @param installParam Indicates other parameters required for the installation. * @return InstallStatus * @permission ohos.permission.INSTALL_BUNDLE + * @deprecated since 9 + * @useinstead ohos.bundle.installer.BundleInstaller#install */ install(bundleFilePaths: Array, param: InstallParam, callback: AsyncCallback): void; @@ -139,6 +154,8 @@ export interface BundleInstaller { * @param installParam Indicates other parameters required for the uninstallation. * @return InstallStatus * @permission ohos.permission.INSTALL_BUNDLE + * @deprecated since 9 + * @useinstead ohos.bundle.installer.BundleInstaller#uninstall */ uninstall(bundleName: string, param: InstallParam, callback: AsyncCallback): void; @@ -153,6 +170,8 @@ export interface BundleInstaller { * @return InstallStatus * @permission ohos.permission.INSTALL_BUNDLE * @systemapi Hide this for inner system use + * @deprecated since 9 + * @useinstead ohos.bundle.installer.BundleInstaller#recover */ recover(bundleName: string, param: InstallParam, callback: AsyncCallback): void; } \ No newline at end of file -- Gitee