1/* 2 * Copyright (c) 2022 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 16import { AsyncCallback } from './basic'; 17 18/** 19 * Support install, upgrade, remove and recover bundles on the devices. 20 * @namespace installer 21 * @syscap SystemCapability.BundleManager.BundleFramework.Core 22 * @systemapi 23 * @since 9 24 */ 25declare namespace installer { 26 /** 27 * Obtains the interface used to install bundle. 28 * @param { AsyncCallback } callback - The callback of BundleInstaller object. 29 * @throws { BusinessError } 202 - Permission denied, non-system app called system api. 30 * @throws { BusinessError } 401 - Input parameters check failed. 31 * @syscap SystemCapability.BundleManager.BundleFramework.Core 32 * @systemapi 33 * @since 9 34 */ 35 function getBundleInstaller(callback: AsyncCallback<BundleInstaller>): void 36 37 /** 38 * Obtains the interface used to install bundle. 39 * @param { AsyncCallback } callback - The callback of getting a list of BundleInstaller objects. 40 * @throws { BusinessError } 202 - Permission denied, non-system app called system api. 41 * @returns { Promise<BundleInstaller> } BundleInstaller object. 42 * @syscap SystemCapability.BundleManager.BundleFramework.Core 43 * @systemapi 44 * @since 9 45 */ 46 function getBundleInstaller(): Promise<BundleInstaller>; 47 48 /** 49 * Bundle installer interface, include install uninstall recover. 50 * @interface BundleInstaller 51 * @syscap SystemCapability.BundleManager.BundleFramework.Core 52 * @systemapi 53 * @since 9 54 */ 55 interface BundleInstaller { 56 /** 57 * Install haps for an application. 58 * @permission ohos.permission.INSTALL_BUNDLE 59 * @param { Array<string> } hapFilePaths - Indicates the path where the hap of the application is stored. 60 * @param { InstallParam } installParam - Indicates other parameters required for the installation. 61 * @param { AsyncCallback } callback - The callback of installing haps result. 62 * @throws { BusinessError } 201 - Calling interface without permission 'ohos.permission.INSTALL_BUNDLE'. 63 * @throws { BusinessError } 202 - Permission denied, non-system app called system api. 64 * @throws { BusinessError } 401 - Input parameters check failed. 65 * @throws { BusinessError } 17700004 - The specified user ID is not found. 66 * @throws { BusinessError } 17700010 - Failed to install the HAP because the HAP fails to be parsed. 67 * @throws { BusinessError } 17700011 - Failed to install the HAP because the HAP signature fails to be verified. 68 * @throws { BusinessError } 17700012 - Failed to install the HAP because the HAP path is invalid or the HAP is too large. 69 * @throws { BusinessError } 17700015 - Failed to install the HAPs because they have different configuration information. 70 * @throws { BusinessError } 17700016 - Failed to install the HAP because of insufficient system disk space. 71 * @throws { BusinessError } 17700017 - Failed to install the HAP since the version of the HAP to install is too early. 72 * @throws { BusinessError } 17700018 - Failed to install because the dependent module does not exist. 73 * @syscap SystemCapability.BundleManager.BundleFramework.Core 74 * @systemapi 75 * @since 9 76 */ 77 install(hapFilePaths: Array<string>, installParam: InstallParam, callback: AsyncCallback<void>) : void; 78 install(hapFilePaths: Array<string>, callback: AsyncCallback<void>) : void; 79 80 /** 81 * Install haps for an application. 82 * @permission ohos.permission.INSTALL_BUNDLE 83 * @param { Array<string> } hapFilePaths - Indicates the path where the hap of the application is stored. 84 * @param { InstallParam } installParam - Indicates other parameters required for the installation. 85 * @param { AsyncCallback } callback - The callback of installing haps result. 86 * @throws { BusinessError } 201 - Calling interface without permission 'ohos.permission.INSTALL_BUNDLE'. 87 * @throws { BusinessError } 202 - Permission denied, non-system app called system api. 88 * @throws { BusinessError } 401 - Input parameters check failed. 89 * @throws { BusinessError } 17700004 - The specified user ID is not found. 90 * @throws { BusinessError } 17700010 - Failed to install the HAP because the HAP fails to be parsed. 91 * @throws { BusinessError } 17700011 - Failed to install the HAP because the HAP signature fails to be verified. 92 * @throws { BusinessError } 17700012 - Failed to install the HAP because the HAP path is invalid or the HAP is too large. 93 * @throws { BusinessError } 17700015 - Failed to install the HAPs because they have different configuration information. 94 * @throws { BusinessError } 17700016 - Failed to install the HAP because of insufficient system disk space. 95 * @throws { BusinessError } 17700017 - Failed to install the HAP since the version of the HAP to install is too early. 96 * @throws { BusinessError } 17700018 - Failed to install because the dependent module does not exist. 97 * @syscap SystemCapability.BundleManager.BundleFramework.Core 98 * @systemapi 99 * @since 9 100 */ 101 install(hapFilePaths: Array<string>, installParam?: InstallParam) : Promise<void>; 102 103 /** 104 * Uninstall an application. 105 * @permission ohos.permission.INSTALL_BUNDLE 106 * @param { string } bundleName - Indicates the bundle name of the application to be uninstalled. 107 * @param { InstallParam } installParam - Indicates other parameters required for the uninstall. 108 * @param { AsyncCallback } callback - The callback of uninstalling application result. 109 * @throws { BusinessError } 201 - Calling interface without permission 'ohos.permission.INSTALL_BUNDLE'. 110 * @throws { BusinessError } 202 - Permission denied, non-system app called system api. 111 * @throws { BusinessError } 401 - Input parameters check failed. 112 * @throws { BusinessError } 17700004 - The specified user ID is not found. 113 * @throws { BusinessError } 17700020 - The specified bundle is pre-installed bundle which cannot be uninstalled. 114 * @syscap SystemCapability.BundleManager.BundleFramework.Core 115 * @systemapi 116 * @since 9 117 */ 118 uninstall(bundleName: string, installParam: InstallParam, callback : AsyncCallback<void>) : void; 119 uninstall(bundleName: string, callback : AsyncCallback<void>) : void; 120 121 /** 122 * Uninstall an application. 123 * @permission ohos.permission.INSTALL_BUNDLE 124 * @param { string } bundleName - Indicates the bundle name of the application to be uninstalled. 125 * @param { InstallParam } installParam - Indicates other parameters required for the uninstall. 126 * @param { AsyncCallback } callback - The callback of uninstalling application result. 127 * @throws { BusinessError } 201 - Calling interface without permission 'ohos.permission.INSTALL_BUNDLE'. 128 * @throws { BusinessError } 202 - Permission denied, non-system app called system api. 129 * @throws { BusinessError } 401 - Input parameters check failed. 130 * @throws { BusinessError } 17700004 - The specified userId is not existed. 131 * @throws { BusinessError } 17700020 - The specified bundle is pre-installed bundle which cannot be uninstalled. 132 * @syscap SystemCapability.BundleManager.BundleFramework.Core 133 * @systemapi 134 * @since 9 135 */ 136 uninstall(bundleName: string, installParam?: InstallParam) : Promise<void>; 137 138 /** 139 * Recover an application. 140 * @permission ohos.permission.INSTALL_BUNDLE 141 * @param { string } bundleName - Indicates the bundle name of the application to be recovered. 142 * @param { InstallParam } installParam - Indicates other parameters required for the recover. 143 * @param { AsyncCallback } callback - The callback of recovering application result. 144 * @throws { BusinessError } 201 - Calling interface without permission 'ohos.permission.INSTALL_BUNDLE'. 145 * @throws { BusinessError } 202 - Permission denied, non-system app called system api. 146 * @throws { BusinessError } 401 - Input parameters check failed. 147 * @throws { BusinessError } 17700004 - The specified user ID is not found. 148 * @syscap SystemCapability.BundleManager.BundleFramework.Core 149 * @systemapi 150 * @since 9 151 */ 152 recover(bundleName: string, installParam: InstallParam, callback: AsyncCallback<void>): void; 153 recover(bundleName: string, callback: AsyncCallback<void>): void; 154 155 /** 156 * Recover an application. 157 * @permission ohos.permission.INSTALL_BUNDLE 158 * @param { string } bundleName - Indicates the bundle name of the application to be recovered. 159 * @param { InstallParam } installParam - Indicates other parameters required for the recover. 160 * @param { AsyncCallback } callback - The callback of recovering application result. 161 * @throws { BusinessError } 201 - Calling interface without permission 'ohos.permission.INSTALL_BUNDLE'. 162 * @throws { BusinessError } 202 - Permission denied, non-system app called system api. 163 * @throws { BusinessError } 401 - Input parameters check failed. 164 * @throws { BusinessError } 17700004 - The specified user ID is not found. 165 * @syscap SystemCapability.BundleManager.BundleFramework.Core 166 * @systemapi 167 * @since 9 168 */ 169 recover(bundleName: string, installParam?: InstallParam) : Promise<void>; 170 } 171 172 /** 173 * Provides parameters required for hashParam. 174 * @typedef HashParam 175 * @syscap SystemCapability.BundleManager.BundleFramework.Core 176 * @systemapi 177 * @since 9 178 */ 179 export interface HashParam { 180 /** 181 * Indicates the moduleName 182 * @syscap SystemCapability.BundleManager.BundleFramework.Core 183 * @since 9 184 */ 185 moduleName: string; 186 187 /** 188 * Indicates the hash value 189 * @syscap SystemCapability.BundleManager.BundleFramework.Core 190 * @since 9 191 */ 192 hashValue: string; 193 } 194 195 /** 196 * Provides parameters required for installing or uninstalling an application. 197 * @typedef InstallParam 198 * @syscap SystemCapability.BundleManager.BundleFramework.Core 199 * @systemapi 200 * @since 9 201 */ 202 export interface InstallParam { 203 /** 204 * Indicates the user id 205 * @syscap SystemCapability.BundleManager.BundleFramework.Core 206 * @since 9 207 */ 208 userId?: number; 209 210 /** 211 * Indicates the install flag, which 0x00 for normal, 0x10 for freeInstall 212 * @syscap SystemCapability.BundleManager.BundleFramework.Core 213 * @since 9 214 */ 215 installFlag?: number; 216 217 /** 218 * Indicates whether the param has data 219 * @syscap SystemCapability.BundleManager.BundleFramework.Core 220 * @since 9 221 */ 222 isKeepData?: boolean; 223 224 /** 225 * Indicates the hash params 226 * @syscap SystemCapability.BundleManager.BundleFramework.Core 227 * @since 9 228 */ 229 hashParams?: Array<HashParam>; 230 231 /** 232 * Indicates the deadline of the crowdtesting bundle 233 * @syscap SystemCapability.BundleManager.BundleFramework.Core 234 * @since 9 235 */ 236 crowdtestDeadline?: number; 237 } 238} 239 240export default installer;