1# @ohos.app.ability.quickFixManager (quickFixManager) 2 3The **quickFixManager** module provides APIs for quick fix. With quick fix, you can fix bugs in your application by applying patches, which is more efficient than by updating the entire application. 4 5> **NOTE** 6> 7> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version. 8> The APIs of this module are system APIs and cannot be called by third-party applications. 9 10## Modules to Import 11 12```ts 13import quickFixManager from '@ohos.app.ability.quickFixManager'; 14``` 15 16## HapModuleQuickFixInfo 17 18Defines the quick fix information at the HAP file level. 19 20**System capability**: SystemCapability.Ability.AbilityRuntime.QuickFix 21 22**System API**: This is a system API and cannot be called by third-party applications. 23 24| Name | Type | Read-only| Mandatory| Description | 25| ----------- | -------------------- | ---- | ---- | ------------------------------------------------------------ | 26| moduleName | string | Yes| Yes | Name of the HAP file. | 27| originHapHash | string | Yes| Yes | Hash value of the HAP file. | 28| quickFixFilePath | string | Yes| Yes | Installation path of the quick fix patch file. | 29 30## ApplicationQuickFixInfo 31 32Defines the quick fix information at the application level. 33 34**System capability**: SystemCapability.Ability.AbilityRuntime.QuickFix 35 36**System API**: This is a system API and cannot be called by third-party applications. 37 38| Name | Type | Read-only| Mandatory| Description | 39| ----------- | -------------------- | ---- | ---- | ------------------------------------------------------------ | 40| bundleName | string | Yes| Yes | Bundle name. | 41| bundleVersionCode | number | Yes| Yes | Internal version number of the application. | 42| bundleVersionName | string | Yes| Yes | Version number of the application that is shown to users. | 43| quickFixVersionCode | number | Yes| Yes | Version code of the quick fix patch package. | 44| quickFixVersionName | string | Yes| Yes | Text description of the version number of the quick fix patch package. | 45| hapModuleQuickFixInfo | Array\<[HapModuleQuickFixInfo](#hapmodulequickfixinfo)> | Yes| Yes | Quick fix information at the HAP file level. | 46 47## quickFixManager.applyQuickFix 48 49applyQuickFix(hapModuleQuickFixFiles: Array\<string>, callback: AsyncCallback\<void>): void; 50 51Applies a quick fix patch. This API uses an asynchronous callback to return the result. 52 53**Required permissions**: ohos.permission.INSTALL_BUNDLE 54 55**System capability**: SystemCapability.Ability.AbilityRuntime.QuickFix 56 57**System API**: This is a system API and cannot be called by third-party applications. 58 59**Parameters** 60 61 | Parameter| Type| Mandatory| Description| 62 | -------- | -------- | -------- | -------- | 63 | hapModuleQuickFixFiles | Array\<string> | Yes| Quick fix patch files, each of which must contain a valid file path.| 64 | callback | AsyncCallback\<void> | Yes| Callback used to return the result. If the quick fix patch is installed, **err** is **undefined**. Otherwise, **err** is an error object.| 65 66**Error codes** 67 68If an error occurs during patch installation, the error code and message are returned through the common event [COMMON_EVENT_QUICK_FIX_APPLY_RESULT](commonEvent-definitions.md#common_event_quick_fix_apply_result9). 69 70| ID| Error Message| 71| ------- | -------- | 72| 18500002 | The specified quick fix is invalid. It may not exist or inaccessible. | 73| 18500008 | Internal error. | 74 75For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md). 76 77> **NOTE** 78> 79> The file path passed in the API must be an application sandbox path. For details about how to obtain the sandbox path, see [Obtaining the Sandbox Path](js-apis-bundle-BundleInstaller.md#obtaining-the-sandbox-path). The path mapped to the device is **/proc/<*applicationProcessId*>/root/*sandboxPath***. 80 81**Example** 82 83```ts 84import quickFixManager from '@ohos.app.ability.quickFixManager'; 85 86 try { 87 let hapModuleQuickFixFiles = ['/data/storage/el2/base/entry.hqf']; 88 quickFixManager.applyQuickFix(hapModuleQuickFixFiles, (error) => { 89 if (error) { 90 console.error( `applyQuickFix failed with error: ${error}`); 91 } else { 92 console.info( 'applyQuickFix success'); 93 } 94 }); 95 } catch (paramError) { 96 console.error(`error.code: ${paramError.code}, error.message: ${paramError.message}`); 97 } 98``` 99 100## quickFixManager.applyQuickFix 101 102applyQuickFix(hapModuleQuickFixFiles: Array\<string>): Promise\<void>; 103 104Applies a quick fix patch. This API uses a promise to return the result. 105 106**Required permissions**: ohos.permission.INSTALL_BUNDLE 107 108**System capability**: SystemCapability.Ability.AbilityRuntime.QuickFix 109 110**System API**: This is a system API and cannot be called by third-party applications. 111 112**Parameters** 113 114 | Parameter| Type| Mandatory| Description| 115 | -------- | -------- | -------- | -------- | 116 | hapModuleQuickFixFiles | Array\<string> | Yes| Quick fix patch files, each of which must contain a valid file path.| 117 118**Return value** 119 120 | Type| Description| 121 | -------- | -------- | 122 | Promise\<void> | Promise that returns no value.| 123 124**Error codes** 125 126If an error occurs during patch installation, the error code and message are returned through the common event [COMMON_EVENT_QUICK_FIX_APPLY_RESULT](commonEvent-definitions.md#common_event_quick_fix_apply_result9). 127 128| ID| Error Message| 129| ------- | -------- | 130| 18500002 | The specified quick fix is invalid. It may not exist or inaccessible. | 131| 18500008 | Internal error. | 132 133For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md). 134 135**Example** 136 137```ts 138import quickFixManager from '@ohos.app.ability.quickFixManager'; 139import { BusinessError } from '@ohos.base'; 140 141 let hapModuleQuickFixFiles = ['/data/storage/el2/base/entry.hqf']; 142 try { 143 quickFixManager.applyQuickFix(hapModuleQuickFixFiles).then(() => { 144 console.info('applyQuickFix success'); 145 }).catch((error: BusinessError) => { 146 console.error(`applyQuickFix err: ${error}`); 147 }); 148 } catch (paramError) { 149 console.error(`error: ${paramError.code}, ${paramError.message}`); 150 } 151``` 152 153## quickFixManager.getApplicationQuickFixInfo 154 155getApplicationQuickFixInfo(bundleName: string, callback: AsyncCallback\<ApplicationQuickFixInfo>): void; 156 157Obtains the quick fix information of the application. This API uses an asynchronous callback to return the result. 158 159**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED 160 161**System capability**: SystemCapability.Ability.AbilityRuntime.QuickFix 162 163**System API**: This is a system API and cannot be called by third-party applications. 164 165**Parameters** 166 167| Parameter| Type| Mandatory| Description| 168| -------- | -------- | -------- | -------- | 169| bundleName | string | Yes|Bundle name. | 170| callback | AsyncCallback\<[ApplicationQuickFixInfo](#applicationquickfixinfo)> | Yes| Callback used to return the quick fix information.| 171 172**Error codes** 173 174| ID| Error Message| 175| ------- | -------- | 176| 18500001 | The specified bundleName is invalid. | 177| 18500008 | Internal error. | 178 179For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md). 180 181**Example** 182 183```ts 184import quickFixManager from '@ohos.app.ability.quickFixManager'; 185 186 try { 187 let bundleName = 'bundleName'; 188 quickFixManager.getApplicationQuickFixInfo(bundleName, (error, data) => { 189 if (error) { 190 console.error(`getApplicationQuickFixInfo error: ${error}`); 191 } else { 192 console.info(`getApplicationQuickFixInfo success: ${data}`); 193 } 194 }); 195 } catch (paramError) { 196 console.error(`error: ${paramError.code}, ${paramError.message}`); 197 } 198``` 199 200## quickFixManager.getApplicationQuickFixInfo 201 202getApplicationQuickFixInfo(bundleName: string): Promise\<ApplicationQuickFixInfo>; 203 204Obtains the quick fix information of the application. This API uses a promise to return the result. 205 206**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED 207 208**System capability**: SystemCapability.Ability.AbilityRuntime.QuickFix 209 210**System API**: This is a system API and cannot be called by third-party applications. 211 212**Parameters** 213 214| Parameter| Type| Mandatory| Description| 215| -------- | -------- | -------- | -------- | 216| bundleName | string | Yes| Bundle name.| 217 218**Return value** 219 220 | Type| Description| 221 | -------- | -------- | 222 | Promise\<[ApplicationQuickFixInfo](#applicationquickfixinfo)> | Promise used to return the quick fix information.| 223 224**Error codes** 225 226| ID| Error Message| 227| ------- | -------- | 228| 18500001 | The specified bundleName is invalid. | 229| 18500008 | Internal error. | 230 231For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md). 232 233**Example** 234 235 ```ts 236import quickFixManager from '@ohos.app.ability.quickFixManager'; 237import { BusinessError } from '@ohos.base'; 238 239 try { 240 let bundleName = 'bundleName'; 241 quickFixManager.getApplicationQuickFixInfo(bundleName).then((data) => { 242 console.info(`getApplicationQuickFixInfo success: ${data}`); 243 }).catch((error: BusinessError) => { 244 console.error(`getApplicationQuickFixInfo err: ${error}`); 245 }); 246 } catch (paramError) { 247 console.error(`error: ${paramError.code}, ${paramError.message}`); 248 } 249 ``` 250 251## quickFixManager.revokeQuickFix<sup>10+<sup> 252 253revokeQuickFix(bundleName: string, callback: AsyncCallback\<void>): void; 254 255Revokes quick fix. This API uses an asynchronous callback to return the result. 256 257**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED and ohos.permission.INSTALL_BUNDLE 258 259**System capability**: SystemCapability.Ability.AbilityRuntime.QuickFix 260 261**System API**: This is a system API and cannot be called by third-party applications. 262 263**Parameters** 264 265 | Parameter| Type| Mandatory| Description| 266 | -------- | -------- | -------- | -------- | 267 | bundleName | string | Yes| Name of the bundle for which the patch needs to be revoked.| 268 | callback | AsyncCallback\<void> | Yes| Callback used to return the result. If quick fix is revoked, **err** is **undefined**. Otherwise, **err** is an error object.| 269 270**Error codes** 271 272| ID| Error Message| 273| ------- | -------- | 274| 18500001 | The bundle is not exist or no patch has applied. | 275| 18500009 | The application has a apply quick fix task that is being processed. | 276 277If an error occurs during patch installation, the error code and message are returned through the common event [COMMON_EVENT_QUICK_FIX_REVOKE_RESULT](./common_event/commonEvent-ability.md#common_event_quick_fix_revoke_result10). 278 279 280 281**Example** 282 283```ts 284import quickFixManager from '@ohos.app.ability.quickFixManager'; 285 286 let bundleName = "com.example.myapplication"; 287 quickFixManager.revokeQuickFix(bundleName, (err) => { 288 console.info("revokeQuickFix " + bundleName + " " + JSON.stringify(err)); 289 }); 290``` 291 292## quickFixManager.revokeQuickFix<sup>10+<sup> 293 294revokeQuickFix(bundleName: string): Promise\<void>; 295 296Revokes quick fix. This API uses a promise to return the result. 297 298**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED and ohos.permission.INSTALL_BUNDLE 299 300**System capability**: SystemCapability.Ability.AbilityRuntime.QuickFix 301 302**System API**: This is a system API and cannot be called by third-party applications. 303 304**Parameters** 305 306 | Parameter| Type| Mandatory| Description| 307 | -------- | -------- | -------- | -------- | 308 | bundleName | string | Yes| Name of the bundle for which the patch needs to be revoked.| 309 310**Return value** 311 312 | Type| Description| 313 | -------- | -------- | 314 | Promise\<void> | Promise that returns no value.| 315 316**Error codes** 317 318For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md). 319 320| ID| Error Message| 321| ------- | -------- | 322| 18500001 | The bundle is not exist or no patch has applied. | 323| 18500009 | The application has a apply quick fix task that is being processed. | 324 325If an error occurs during patch installation, the error code and message are returned through the common event [COMMON_EVENT_QUICK_FIX_REVOKE_RESULT](./common_event/commonEvent-ability.md#common_event_quick_fix_revoke_result10). The table below lists the possible error codes and messages. 326 327**Example** 328 329```ts 330import quickFixManager from '@ohos.app.ability.quickFixManager'; 331import { BusinessError } from '@ohos.base'; 332 333 let bundleName = "com.example.myapplication"; 334 quickFixManager.revokeQuickFix(bundleName).then(() => { 335 console.info("revokeQuickFix " + bundleName +" ok"); 336 }).catch((err: BusinessError) => { 337 console.info("revokeQuickFix " + bundleName +" failed, error code is ", JSON.stringify((err))); 338 }); 339``` 340