1e41f4b71Sopenharmony_ci# Ability Subsystem Changelog 2e41f4b71Sopenharmony_ci 3e41f4b71Sopenharmony_ci## cl.ability.1 Deprecated the createModuleContext API 4e41f4b71Sopenharmony_ci 5e41f4b71Sopenharmony_ci**Access Level** 6e41f4b71Sopenharmony_ci 7e41f4b71Sopenharmony_ciPublic API 8e41f4b71Sopenharmony_ci 9e41f4b71Sopenharmony_ci**Reason for Change** 10e41f4b71Sopenharmony_ci 11e41f4b71Sopenharmony_ciThe context created using this API cannot obtain resources correctly. 12e41f4b71Sopenharmony_ci 13e41f4b71Sopenharmony_ci**Change Impact** 14e41f4b71Sopenharmony_ci 15e41f4b71Sopenharmony_ciThis change is a compatibility change. A new API is provided. 16e41f4b71Sopenharmony_ci 17e41f4b71Sopenharmony_ci**Start API Level** 18e41f4b71Sopenharmony_ci 19e41f4b71Sopenharmony_ci9 20e41f4b71Sopenharmony_ci 21e41f4b71Sopenharmony_ci**Change Since** 22e41f4b71Sopenharmony_ci 23e41f4b71Sopenharmony_ciOpenHarmony SDK 5.0.0.37 24e41f4b71Sopenharmony_ci 25e41f4b71Sopenharmony_ci**Deprecated APIs/Components** 26e41f4b71Sopenharmony_ci 27e41f4b71Sopenharmony_ci|Deprecated API|Description|Substitute API| 28e41f4b71Sopenharmony_ci|-------|-------|-------| 29e41f4b71Sopenharmony_ci|createModuleContext(moduleName: string): Context|The context created using this API cannot obtain resources correctly. You are advised to use the substitute API.|createModuleContext(context: Context, moduleName: string): Promise\<Context>| 30e41f4b71Sopenharmony_ci 31e41f4b71Sopenharmony_ci**Adaptation Guide** 32e41f4b71Sopenharmony_ci 33e41f4b71Sopenharmony_ciUse **createModuleContext** with the input parameter **context** in the code. 34e41f4b71Sopenharmony_ci 35e41f4b71Sopenharmony_ciCode example before deprecation: 36e41f4b71Sopenharmony_ci 37e41f4b71Sopenharmony_ci```ts 38e41f4b71Sopenharmony_ciimport { common, UIAbility } from '@kit.AbilityKit'; 39e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit'; 40e41f4b71Sopenharmony_ci 41e41f4b71Sopenharmony_ciexport default class EntryAbility extends UIAbility { 42e41f4b71Sopenharmony_ci onCreate() { 43e41f4b71Sopenharmony_ci console.log('MyAbility onCreate'); 44e41f4b71Sopenharmony_ci let moduleContext: common.Context; 45e41f4b71Sopenharmony_ci try { 46e41f4b71Sopenharmony_ci moduleContext = this.context.createModuleContext('entry'); 47e41f4b71Sopenharmony_ci } catch (error) { 48e41f4b71Sopenharmony_ci console.error(`createModuleContext failed, error.code: ${(error as BusinessError).code}, error.message: ${(error as BusinessError).message}`); 49e41f4b71Sopenharmony_ci } 50e41f4b71Sopenharmony_ci } 51e41f4b71Sopenharmony_ci} 52e41f4b71Sopenharmony_ci``` 53e41f4b71Sopenharmony_ciCode example after deprecation: 54e41f4b71Sopenharmony_ci 55e41f4b71Sopenharmony_ci```ts 56e41f4b71Sopenharmony_ciimport { common, UIAbility } from '@kit.AbilityKit'; 57e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit'; 58e41f4b71Sopenharmony_ci 59e41f4b71Sopenharmony_ciexport default class EntryAbility extends UIAbility { 60e41f4b71Sopenharmony_ci onCreate() { 61e41f4b71Sopenharmony_ci console.log('MyAbility onCreate'); 62e41f4b71Sopenharmony_ci let moduleContext: common.Context; 63e41f4b71Sopenharmony_ci try { 64e41f4b71Sopenharmony_ci common.createModuleContext(this.context,'entry').then((data: Context)=>{ 65e41f4b71Sopenharmony_ci moduleContext = data; 66e41f4b71Sopenharmony_ci }).catch((err : BusinessError)=>{ 67e41f4b71Sopenharmony_ci console.error(`createModuleContext failed, error.code: ${(error as BusinessError).code}, error.message: ${(error as BusinessError).message}`); 68e41f4b71Sopenharmony_ci }) 69e41f4b71Sopenharmony_ci } catch (error) { 70e41f4b71Sopenharmony_ci console.error(`createModuleContext failed, error.code: ${(error as BusinessError).code}, error.message: ${(error as BusinessError).message}`); 71e41f4b71Sopenharmony_ci } 72e41f4b71Sopenharmony_ci } 73e41f4b71Sopenharmony_ci} 74e41f4b71Sopenharmony_ci``` 75e41f4b71Sopenharmony_ci## cl.ability.2 Deprecated the createModuleContext API 76e41f4b71Sopenharmony_ci 77e41f4b71Sopenharmony_ci**Access Level** 78e41f4b71Sopenharmony_ci 79e41f4b71Sopenharmony_ciSystem API 80e41f4b71Sopenharmony_ci 81e41f4b71Sopenharmony_ci**Reason for Change** 82e41f4b71Sopenharmony_ci 83e41f4b71Sopenharmony_ciThe context created using this API cannot obtain resources correctly. 84e41f4b71Sopenharmony_ci 85e41f4b71Sopenharmony_ci**Change Impact** 86e41f4b71Sopenharmony_ci 87e41f4b71Sopenharmony_ciThis change is a compatibility change. A new API is provided. 88e41f4b71Sopenharmony_ci 89e41f4b71Sopenharmony_ci**Start API Level** 90e41f4b71Sopenharmony_ci 91e41f4b71Sopenharmony_ci9 92e41f4b71Sopenharmony_ci 93e41f4b71Sopenharmony_ci**Change Since** 94e41f4b71Sopenharmony_ci 95e41f4b71Sopenharmony_ciOpenHarmony SDK 5.0.0.37 96e41f4b71Sopenharmony_ci 97e41f4b71Sopenharmony_ci**Deprecated APIs/Components** 98e41f4b71Sopenharmony_ci 99e41f4b71Sopenharmony_ci|Deprecated API|Description|Substitute API| 100e41f4b71Sopenharmony_ci|-------|-------|-------| 101e41f4b71Sopenharmony_ci|createModuleContext(bundleName: string, moduleName: string): Context|The context created using this API cannot obtain resources correctly. You are advised to use the substitute API.|createModuleContext(context: Context, bundleName: string, moduleName: string): Promise\<Context>| 102e41f4b71Sopenharmony_ci 103e41f4b71Sopenharmony_ci**Adaptation Guide** 104e41f4b71Sopenharmony_ci 105e41f4b71Sopenharmony_ciUse **createModuleContext** with the input parameter **context** in the code. 106e41f4b71Sopenharmony_ci 107e41f4b71Sopenharmony_ciCode example before deprecation: 108e41f4b71Sopenharmony_ci 109e41f4b71Sopenharmony_ci```ts 110e41f4b71Sopenharmony_ciimport { common, UIAbility } from '@kit.AbilityKit'; 111e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit'; 112e41f4b71Sopenharmony_ci 113e41f4b71Sopenharmony_ciexport default class EntryAbility extends UIAbility { 114e41f4b71Sopenharmony_ci onCreate() { 115e41f4b71Sopenharmony_ci console.log('MyAbility onCreate'); 116e41f4b71Sopenharmony_ci let moduleContext: common.Context; 117e41f4b71Sopenharmony_ci try { 118e41f4b71Sopenharmony_ci moduleContext = this.context.createModuleContext('bunlename', 'entry'); 119e41f4b71Sopenharmony_ci } catch (error) { 120e41f4b71Sopenharmony_ci console.error(`createModuleContext failed, error.code: ${(error as BusinessError).code}, error.message: ${(error as BusinessError).message}`); 121e41f4b71Sopenharmony_ci } 122e41f4b71Sopenharmony_ci } 123e41f4b71Sopenharmony_ci} 124e41f4b71Sopenharmony_ci``` 125e41f4b71Sopenharmony_ciCode example after deprecation: 126e41f4b71Sopenharmony_ci 127e41f4b71Sopenharmony_ci```ts 128e41f4b71Sopenharmony_ciimport { common, UIAbility } from '@kit.AbilityKit'; 129e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit'; 130e41f4b71Sopenharmony_ci 131e41f4b71Sopenharmony_ciexport default class EntryAbility extends UIAbility { 132e41f4b71Sopenharmony_ci onCreate() { 133e41f4b71Sopenharmony_ci console.log('MyAbility onCreate'); 134e41f4b71Sopenharmony_ci let moduleContext: common.Context; 135e41f4b71Sopenharmony_ci try { 136e41f4b71Sopenharmony_ci common.createModuleContext(this.context, 'bunlename', 'entry').then((data: Context)=>{ 137e41f4b71Sopenharmony_ci moduleContext = data; 138e41f4b71Sopenharmony_ci }).catch((err : BusinessError)=>{ 139e41f4b71Sopenharmony_ci console.error(`createModuleContext failed, error.code: ${(error as BusinessError).code}, error.message: ${(error as BusinessError).message}`); 140e41f4b71Sopenharmony_ci }) 141e41f4b71Sopenharmony_ci } catch (error) { 142e41f4b71Sopenharmony_ci console.error(`createModuleContext failed, error.code: ${(error as BusinessError).code}, error.message: ${(error as BusinessError).message}`); 143e41f4b71Sopenharmony_ci } 144e41f4b71Sopenharmony_ci } 145e41f4b71Sopenharmony_ci} 146e41f4b71Sopenharmony_ci``` 147e41f4b71Sopenharmony_ci 148e41f4b71Sopenharmony_ci## cl.ability.3 Deprecated the createBundleContext API 149e41f4b71Sopenharmony_ci 150e41f4b71Sopenharmony_ci**Access Level** 151e41f4b71Sopenharmony_ci 152e41f4b71Sopenharmony_ciSystem API 153e41f4b71Sopenharmony_ci 154e41f4b71Sopenharmony_ci**Reason for Change** 155e41f4b71Sopenharmony_ci 156e41f4b71Sopenharmony_ciThe context created using this API cannot obtain resources correctly. 157e41f4b71Sopenharmony_ci 158e41f4b71Sopenharmony_ci**Change Impact** 159e41f4b71Sopenharmony_ci 160e41f4b71Sopenharmony_ciThis change is a compatibility change. A new API is provided. 161e41f4b71Sopenharmony_ci 162e41f4b71Sopenharmony_ci**Start API Level** 163e41f4b71Sopenharmony_ci 164e41f4b71Sopenharmony_ci9 165e41f4b71Sopenharmony_ci 166e41f4b71Sopenharmony_ci**Change Since** 167e41f4b71Sopenharmony_ci 168e41f4b71Sopenharmony_ciOpenHarmony SDK 5.0.0.37 169e41f4b71Sopenharmony_ci 170e41f4b71Sopenharmony_ci**Deprecated APIs/Components** 171e41f4b71Sopenharmony_ci 172e41f4b71Sopenharmony_ci|Deprecated API|Description|Substitute API| 173e41f4b71Sopenharmony_ci|-------|-------|-------| 174e41f4b71Sopenharmony_ci|createBundleContext(bundleName: string): Context|The context created using this API cannot obtain resources correctly. You are advised to use the substitute API.|createBundleContext(context: Context, bundleName: string): Promise\<Context>| 175e41f4b71Sopenharmony_ci 176e41f4b71Sopenharmony_ci**Adaptation Guide** 177e41f4b71Sopenharmony_ci 178e41f4b71Sopenharmony_ciUse **createBundleContext** with the input parameter **context** in the code. 179e41f4b71Sopenharmony_ci 180e41f4b71Sopenharmony_ciCode example before deprecation: 181e41f4b71Sopenharmony_ci 182e41f4b71Sopenharmony_ci```ts 183e41f4b71Sopenharmony_ciimport { common, UIAbility } from '@kit.AbilityKit'; 184e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit'; 185e41f4b71Sopenharmony_ci 186e41f4b71Sopenharmony_ciexport default class EntryAbility extends UIAbility { 187e41f4b71Sopenharmony_ci onCreate() { 188e41f4b71Sopenharmony_ci console.log('MyAbility onCreate'); 189e41f4b71Sopenharmony_ci let bundleContext: common.Context; 190e41f4b71Sopenharmony_ci try { 191e41f4b71Sopenharmony_ci bundleContext = this.context.createBundleContext('bundlename'); 192e41f4b71Sopenharmony_ci } catch (error) { 193e41f4b71Sopenharmony_ci console.error(`createBundleContext failed, error.code: ${(error as BusinessError).code}, error.message: ${(error as BusinessError).message}`); 194e41f4b71Sopenharmony_ci } 195e41f4b71Sopenharmony_ci } 196e41f4b71Sopenharmony_ci} 197e41f4b71Sopenharmony_ci``` 198e41f4b71Sopenharmony_ciCode example after deprecation: 199e41f4b71Sopenharmony_ci 200e41f4b71Sopenharmony_ci```ts 201e41f4b71Sopenharmony_ciimport { common, UIAbility } from '@kit.AbilityKit'; 202e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit'; 203e41f4b71Sopenharmony_ci 204e41f4b71Sopenharmony_ciexport default class EntryAbility extends UIAbility { 205e41f4b71Sopenharmony_ci onCreate() { 206e41f4b71Sopenharmony_ci console.log('MyAbility onCreate'); 207e41f4b71Sopenharmony_ci let bundleContext: common.Context; 208e41f4b71Sopenharmony_ci try { 209e41f4b71Sopenharmony_ci common.createBundleContext(this.context,'bundlename').then((data: Context)=>{ 210e41f4b71Sopenharmony_ci bundleContext = data; 211e41f4b71Sopenharmony_ci }).catch((err : BusinessError)=>{ 212e41f4b71Sopenharmony_ci console.error(`createBundleContext failed, error.code: ${(error as BusinessError).code}, error.message: ${(error as BusinessError).message}`); 213e41f4b71Sopenharmony_ci }) 214e41f4b71Sopenharmony_ci } catch (error) { 215e41f4b71Sopenharmony_ci console.error(`createBundleContext failed, error.code: ${(error as BusinessError).code}, error.message: ${(error as BusinessError).message}`); 216e41f4b71Sopenharmony_ci } 217e41f4b71Sopenharmony_ci } 218e41f4b71Sopenharmony_ci} 219e41f4b71Sopenharmony_ci``` 220