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 9## Modules to Import 10 11```ts 12import quickFixManager from '@ohos.app.ability.quickFixManager'; 13``` 14 15## HapModuleQuickFixInfo 16 17Defines the quick fix information at the HAP file level. 18 19**System capability**: SystemCapability.Ability.AbilityRuntime.QuickFix 20 21**System API**: This is a system API and cannot be called by third-party applications. 22 23| Name | Type | Mandatory| Description | 24| ----------- | -------------------- | ---- | ------------------------------------------------------------ | 25| moduleName | string | Yes | Name of the HAP file. | 26| originHapHash | string | Yes | Hash value of the HAP file. | 27| quickFixFilePath | string | Yes | Installation path of the quick fix patch file. | 28 29## ApplicationQuickFixInfo 30 31Defines the quick fix information at the application level. 32 33**System capability**: SystemCapability.Ability.AbilityRuntime.QuickFix 34 35**System API**: This is a system API and cannot be called by third-party applications. 36 37| Name | Type | Mandatory| Description | 38| ----------- | -------------------- | ---- | ------------------------------------------------------------ | 39| bundleName | string | Yes | Bundle name. | 40| bundleVersionCode | number | Yes | Internal version number of the application. | 41| bundleVersionName | string | Yes | Version number of the application that is shown to users. | 42| quickFixVersionCode | number | Yes | Version code of the quick fix patch package. | 43| quickFixVersionName | string | Yes | Text description of the version number of the quick fix patch package. | 44| hapModuleQuickFixInfo | Array\<[HapModuleQuickFixInfo](#hapmodulequickfixinfo)> | Yes | Quick fix information at the HAP file level. | 45 46## quickFixManager.applyQuickFix 47 48applyQuickFix(hapModuleQuickFixFiles: Array\<string>, callback: AsyncCallback\<void>): void; 49 50Applies a quick fix patch. This API uses an asynchronous callback to return the result. 51 52**Required permissions**: ohos.permission.INSTALL_BUNDLE 53 54**System capability**: SystemCapability.Ability.AbilityRuntime.QuickFix 55 56**System API**: This is a system API and cannot be called by third-party applications. 57 58**Parameters** 59 60 | Parameter| Type| Mandatory| Description| 61 | -------- | -------- | -------- | -------- | 62 | hapModuleQuickFixFiles | Array\<string> | Yes| Quick fix patch files, each of which must contain a valid file path.| 63 | callback | AsyncCallback\<void> | Yes| Callback used to return the result.| 64 65**Error codes** 66 67| ID| Error Message| 68| ------- | -------- | 69| 18500002 | The specified quick fix is invalid. It may not exist or inaccessible. | 70| 18500008 | Internal error. | 71 72If an error occurs during patch installation, the error code and message are returned through the common event [COMMON_EVENT_QUICK_FIX_APPLY_RESULT](commonEventManager-definitions.md#common_event_quick_fix_apply_result-9). The table below lists the possible error codes and messages. 73 74| ID| Error Message| 75| ------- | -------- | 76| 18500003 | Deploy hqf failed. | 77| 18500004 | Switch hqf failed. | 78| 18500005 | Delete hqf failed. | 79| 18500006 | Load patch failed. | 80| 18500007 | Unload patch failed. | 81 82For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md). 83 84> **NOTE** 85> 86> 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***. 87 88**Example** 89 90```ts 91 import quickFixManager from '@ohos.app.ability.quickFixManager'; 92 93 try { 94 let hapModuleQuickFixFiles = ['/data/storage/el2/base/entry.hqf']; 95 quickFixManager.applyQuickFix(hapModuleQuickFixFiles, (error) => { 96 if (error) { 97 console.info( `applyQuickFix failed with error + ${error}`); 98 } else { 99 console.info( 'applyQuickFix success'); 100 } 101 }); 102 } catch (paramError) { 103 console.log('error: ' + paramError.code + ', ' + paramError.message); 104 } 105``` 106 107## quickFixManager.applyQuickFix 108 109applyQuickFix(hapModuleQuickFixFiles: Array\<string>): Promise\<void>; 110 111Applies a quick fix patch. This API uses a promise to return the result. 112 113**Required permissions**: ohos.permission.INSTALL_BUNDLE 114 115**System capability**: SystemCapability.Ability.AbilityRuntime.QuickFix 116 117**System API**: This is a system API and cannot be called by third-party applications. 118 119**Parameters** 120 121 | Parameter| Type| Mandatory| Description| 122 | -------- | -------- | -------- | -------- | 123 | hapModuleQuickFixFiles | Array\<string> | Yes| Quick fix patch files, each of which must contain a valid file path.| 124 125**Return value** 126 127 | Type| Description| 128 | -------- | -------- | 129 | Promise\<void> | Promise used to return the result.| 130 131**Error codes** 132 133| ID| Error Message| 134| ------- | -------- | 135| 18500002 | The specified quick fix is invalid. It may not exist or inaccessible. | 136| 18500008 | Internal error. | 137 138If an error occurs during patch installation, the error code and message are returned through the common event [COMMON_EVENT_QUICK_FIX_APPLY_RESULT](commonEventManager-definitions.md#common_event_quick_fix_apply_result-9). The table below lists the possible error codes and messages. 139 140| ID| Error Message| 141| ------- | -------- | 142| 18500003 | Deploy hqf failed. | 143| 18500004 | Switch hqf failed. | 144| 18500005 | Delete hqf failed. | 145| 18500006 | Load patch failed. | 146| 18500007 | Unload patch failed. | 147 148For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md). 149 150**Example** 151 152```ts 153 import quickFixManager from '@ohos.app.ability.quickFixManager'; 154 155 let hapModuleQuickFixFiles = ['/data/storage/el2/base/entry.hqf']; 156 try { 157 quickFixManager.applyQuickFix(hapModuleQuickFixFiles).then(() => { 158 console.info('applyQuickFix success'); 159 }).catch((error) => { 160 console.info(`applyQuickFix err: + ${error}`); 161 }); 162 } catch (paramError) { 163 console.log('error: ' + paramError.code + ', ' + paramError.message); 164 } 165``` 166 167## quickFixManager.getApplicationQuickFixInfo 168 169getApplicationQuickFixInfo(bundleName: string, callback: AsyncCallback\<ApplicationQuickFixInfo>): void; 170 171Obtains the quick fix information of the application. This API uses an asynchronous callback to return the result. 172 173**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED 174 175**System capability**: SystemCapability.Ability.AbilityRuntime.QuickFix 176 177**System API**: This is a system API and cannot be called by third-party applications. 178 179**Parameters** 180 181 | Parameter| Type| Mandatory| Description| 182 | -------- | -------- | -------- | -------- | 183 | bundleName | string | Yes|Bundle name. | 184 | callback | AsyncCallback\<[ApplicationQuickFixInfo](#applicationquickfixinfo)> | Yes| Callback used to return the quick fix information.| 185 186**Error codes** 187 188| ID| Error Message| 189| ------- | -------- | 190| 18500001 | The specified bundleName is invalid. | 191| 18500008 | Internal error. | 192 193For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md). 194 195**Example** 196 197```ts 198 import quickFixManager from '@ohos.app.ability.quickFixManager'; 199 200 try { 201 let bundleName = 'bundleName' 202 quickFixManager.getApplicationQuickFixInfo(bundleName, (error, data) => { 203 if (error) { 204 console.info(`getApplicationQuickFixInfo error: + ${error}`); 205 } else { 206 console.info(`getApplicationQuickFixInfo success: + ${data}`); 207 } 208 }); 209 } catch (paramError) { 210 console.log('error: ' + paramError.code + ', ' + paramError.message); 211 } 212``` 213 214## quickFixManager.getApplicationQuickFixInfo 215 216getApplicationQuickFixInfo(bundleName: string): Promise\<ApplicationQuickFixInfo>; 217 218Obtains the quick fix information of the application. This API uses a promise to return the result. 219 220**Required permissions**: ohos.permission.GET_BUNDLE_INFO_PRIVILEGED 221 222**System capability**: SystemCapability.Ability.AbilityRuntime.QuickFix 223 224**System API**: This is a system API and cannot be called by third-party applications. 225 226**Parameters** 227 228 | Parameter| Type| Mandatory| Description| 229 | -------- | -------- | -------- | -------- | 230 | bundleName | string | Yes| Bundle name. | 231 232**Return value** 233 234 | Type| Description| 235 | -------- | -------- | 236 | Promise\<[ApplicationQuickFixInfo](#applicationquickfixinfo)> | Promise used to return the quick fix information.| 237 238**Error codes** 239 240| ID| Error Message| 241| ------- | -------- | 242| 18500001 | The specified bundleName is invalid. | 243| 18500008 | Internal error. | 244 245For details about the error codes, see [Ability Error Codes](../errorcodes/errorcode-ability.md). 246 247**Example** 248 249 ```ts 250 import quickFixManager from '@ohos.app.ability.quickFixManager'; 251 252 try { 253 let bundleName = 'bundleName'; 254 quickFixManager.getApplicationQuickFixInfo(bundleName).then((data) => { 255 console.info(`getApplicationQuickFixInfo success: + ${data}`); 256 }).catch((error) => { 257 console.info(`getApplicationQuickFixInfo err: + ${error}`); 258 }); 259 } catch (paramError) { 260 console.log('error: ' + paramError.code + ', ' + paramError.message); 261 } 262``` 263