1# Ability Framework Changelog 2 3## cl.ability.1 API Migration 4The **requestPermissionsFromUser** API of **UIAbilityContext** is migrated from the ability subsystem to the security subsystem. 5 6Previously, the permission popup was implemented based on **UIAbility**, which used the **startAbilityForResult** API of **UIAbilityContext** to return the permission authorization result to the caller. Therefore, **requestPermissionsFromUser** was temporarily placed in **UIAbilityContext**. The permission popup is now implemented based on **ServiceExtensionAbility**, which no longer requires **startAbilityForResult** of **UIAbilityContext**. Therefore, **requestPermissionsFromUser** is migrated to the security subsystem. 7 8You need to adapt your application based on the following information. 9 10 **Change Impact** 11 12JS APIs in API version 9 are affected. Your application needs to adapt these APIs so that it can properly implement features in the SDK environment of the new version. 13 14**Key API/Component Changes** 15 16| Module | Class | Method/Attribute/Enum/Constant | Change Type| 17| ------------------------- | ------------------- | ------------------------------------------------------------ | -------- | 18| application/UIAbilityContext | UIAbilityContext | requestPermissionsFromUser(permissions: Array<string>, requestCallback: AsyncCallback<PermissionRequestResult>): void; | Deleted | 19| application/UIAbilityContext | UIAbilityContext | requestPermissionsFromUser(permissions: Array<string>): Promise<PermissionRequestResult>; | Deleted | 20| @ohos.abilityAccessCtrl | AtManager | requestPermissionsFromUser(context: Context, permissions: Array<Permissions>, requestCallback: AsyncCallback<PermissionRequestResult>) : void; | Added | 21| @ohos.abilityAccessCtrl | AtManager | requestPermissionsFromUser(context: Context, permissions: Array<Permissions>) : Promise<PermissionRequestResult>; | Added | 22 23 24**Adaptation Guide** 25 26The following illustrates how **requestPermissionsFromUser** is called to show a permission popup. 27 28Stage model: 29 30```ts 31import abilityAccessCtrl from '@ohos.abilityAccessCtrl.d.ts'; 32// onWindowStageCreate lifecycle of UIAbility. 33onWindowStageCreate() { 34 let AtManager = abilityAccessCtrl.createAtManager(); 35 // requestPermissionsFromUser determines whether to display a popup based on the permission authorization status. 36 AtManager.requestPermissionsFromUser(this.context, ["ohos.permission.MANAGE_DISPOSED_APP_STATUS"]).then((data) => { 37 console.log("data type:" + typeof(data)); 38 console.log("data:" + data); 39 console.log("data permissions:" + data.permissions); 40 console.log("data result:" + data.authResults); 41 }).catch((err) => { 42 console.error('Failed to start ability', err.code); 43 }) 44} 45``` 46 47 48 49## cl.ability.2 Deletion of Deprecated APIs in API Version 9 50 51In the [Ability Exception Rectification](../OpenHarmony_3.2.8.3/changelogs-ability.md) document, some APIs in API version 9 have been marked as deprecated. According to API specifications of OpenHarmony, these APIs should be deleted. 52 53**Change Impact** 54 55The application developed based on earlier versions needs to use new APIs to replace the deleted ones. Otherwise, the application compilation will be affected. 56 57**Key API/Component Changes** 58 59API files are deleted. 60 61| Deleted API | New API | 62| ----------------------------------------------- | ----------------------------------------------- | 63| @ohos.application.Ability.d.ts | @ohos.app.ability.UIAbility.d.ts | 64| @ohos.application.AbilityConstant.d.ts | @ohos.app.ability.AbilityConstant.d.ts | 65| @ohos.application.AbilityLifecycleCallback.d.ts | @ohos.app.ability.AbilityLifecycleCallback.d.ts | 66| @ohos.application.AbilityStage.d.ts | @ohos.app.ability.AbilityStage.d.ts | 67| @ohos.application.EnvironmentCallback.d.ts | @ohos.app.ability.EnvironmentCallback.d.ts | 68| @ohos.application.ExtensionAbility.d.ts | @ohos.app.ability.ExtensionAbility.d.ts | 69| @ohos.application.FormExtension.d.ts | @ohos.app.form.FormExtensionAbility.d.ts | 70| @ohos.application.ServiceExtensionAbility.d.ts | @ohos.app.ability.ServiceExtensionAbility.d.ts | 71| @ohos.application.StartOptions.d.ts | @ohos.app.ability.StartOptions.d.ts | 72| @ohos.application.context.d.ts | @ohos.app.ability.common.d.ts | 73| @ohos.application.errorManager.d.ts | @ohos.app.ability.errorManager.d.ts | 74 75APIs or attributes are deleted: 76 77- @ohos.application.Configuration.d.ts 78 - **direction**, **screenDensity**, **displayId**, and **hasPointerDevice** of **Configuration** are deleted. Use **Configuration** of **@ohos.app.ability.Configuration.d.ts**. 79- @ohos.application.ConfigurationConstant.d.ts 80 - **Direction** and **ScreenDensity** are deleted. Use **Direction** and **ScreenDensity** of **@ohos.app.ability.ConfigurationConstant.d.ts**. 81- @ohos.application.abilityManager.d.ts 82 - **getExtensionRunningInfos** and **getTopAbility** are deleted. Use the APIs with the same name in **@ohos.app.ability.abilityManager.d.ts**. 83- @ohos.application.appManager.d.ts 84 - **ApplicationState** and **ProcessState** are deleted. Use **ApplicationState** and **ProcessState** of **@ohos.app.ability.appManager.d.ts**. 85 - **registerApplicationStateObserver** and **getProcessRunningInformation** are deleted. Use the APIs with the same name in **@ohos.app.ability.appManager.d.ts**. 86- @ohos.application.formHost.d.ts 87 - **shareForm** and **notifyFormsPrivacyProtected** are deleted. Use the APIs with the same name in **@ohos.app.form.formHost.d.ts**. 88- @ohos.application.formInfo.d.ts 89 - **eTS** of **FormType** is deleted. Use **eTS** of **FormType** in **@ohos.app.form.formInfo.d.ts**. 90 - **IDENTITY_KEY**, **BUNDLE_NAME_KEY**, **ABILITY_NAME_KEY**, and **DEVICE_ID_KEY** of **FormParam** are deleted. Use the enums with the same name in **@ohos.app.form.formInfo.d.ts**. 91 - **FormInfoFilter** is deleted. Use **FormInfoFilter** of **@ohos.app.form.formInfo.d.ts**. 92 - **FormDimension** is deleted. Use **FormDimension** of **@ohos.app.form.formInfo.d.ts**. 93 - **VisibilityType** is deleted. Use **VisibilityType** of **@ohos.app.form.formInfo.d.ts**. 94- @ohos.wantAgent.d.ts 95 - **trigger** and **getOperationType** are deleted. Use the APIs with the same name in **@ohos.app.ability.wantAgent.d.ts**. 96- application/ApplicationContext.d.ts 97 - **registerAbilityLifecycleCallback**, **unregisterAbilityLifecycleCallback**, **registerEnvironmentCallback**, and **unregisterEnvironmentCallback** are deleted. Use **on** and **off**. 98- application/ServiceExtensionContext.d.ts 99 - **connectAbility**, **connectAbilityWithAccount**, and **disconnectAbility** are deleted. Use **connectServiceExtensionAbility**, **connectServiceExtensionAbilityWithAccount**, and **disconnectServiceExtensionAbility**. 100- @ohos.application.FormExtension.d.ts 101 - **onCreate**, **onCastToNormal**, **onUpdate**, **onVisibilityChange**, **onEvent**, **onDestroy**, **onAcquireFormState**, and **onShare** are deleted. Use the following lifecycle methods of **@ohos.app.form.FormExtensionAbility.d.ts**: **onAddForm**, **onCastToNormalForm**, **onUpdateForm**, **onChangeFormVisibility**, **onFormEvent**, **onRemoveForm**, **onAcquireFormState**, and **onShareForm**. 102- @ohos.application.abilityDelegatorRegistry.d.ts 103 - **AbilityDelegator**, **AbilityDelegatorArgs**, **AbilityMonitor**, and **ShellCmdResult** are deleted. Use the classes with the same name in **@ohos.app.ability.abilityDelegatorRegistry.d.ts**. 104- @ohos.application.abilityManager.d.ts 105 - **AbilityRunningInfo** and **ExtensionRunningInfo** are deleted. Use the classes with the same name in **@ohos.app.ability.abilityManager.d.ts**. 106- @ohos.application.appManager.d.ts 107 - **AbilityStateData**, **AppStateData**, **ApplicationStateObserver**, **ProcessRunningInfo**, and **ProcessRunningInformation** are deleted. Use the classes with the same name in **@ohos.app.ability.appManager.d.ts**. 108- @ohos.application.missionManager.d.ts 109 - **MissionInfo**, **MissionListener**, and **MissionSnapshot** are deleted. Use the classes with the same name in **@ohos.app.ability.missionManager.d.ts**. 110- @ohos.wantAgent.d.ts 111 - **TriggerInfo** and **WantAgentInfo** are deleted. Use the classes with the same name in **@ohos.app.ability.wantAgent.d.ts**. 112 113**Adaptation Guide** 114 115As mentioned above, only several APIs have their names changed in terms of, for example, the registration callbacks (**registerAbilityLifecycleCallback**, **unregisterAbilityLifecycleCallback**, **registerEnvironmentCallback**, and **unregisterEnvironmentCallback**) and connection and disconnection **ServiceExtensionAbility** (**connectAbility**, **connectAbilityWithAccount**, and **disconnectAbility**). For such APIs, replace their names with those of their corresponding new APIs in the lifecycle callbacks. 116 117Most APIs are moved to the new namespace. Therefore, you can modify **import** for adaptation. 118 119For example, the original API uses **@ohos.application.Ability**: 120 121```js 122import Ability from '@ohos.application.Ability'; 123``` 124 125You can directly modify **import** to switch to the new namespace: 126 127```js 128import Ability from '@ohos.app.ability.UIAbility'; 129``` 130 131In addition, exception handling is needed. For details, see the API reference for the new APIs. 132 133## cl.ability.2 RestartFlag Attribute Names Changed and Unsupported Attribute Deleted in appRecovery 134 135In the **appRecovery** API, the enum names of **RestartFlag** are changed from **NO_RESTART** upon a specific fault to **RESTART** upon a specific fault. 136The **CPP_CRASH_NO_RESTART** enum is deleted. 137 138**Change Impact** 139 140If your application uses the **CPP_CRASH_NO_RESTART**, **JS_CRASH_NO_RESTART**, or **APP_FREEZE_NO_RESTART** attribute in versions earlier than 3.2.10.6, its behavior will change after an upgrade to 3.2.10.6. 141 142**Key API/Component Changes** 143 144**RestartFlag** <sup>9+</sup> 145 146Before change 147 148| Name | Value | Description | 149| --------------------- | ------ | -------------------------------- | 150| ALWAYS_RESTART | 0 | The application is restarted in all cases. | 151| CPP_CRASH_NO_RESTART | 0x0001 | The application is **not restarted** in the case of CPP_CRASH. | 152| JS_CRASH_NO_RESTART | 0x0002 | The application is **not restarted** in the case of JS_CRASH. | 153| APP_FREEZE_NO_RESTART | 0x0004 | The application is **not restarted** in the case of APP_FREEZE.| 154| NO_RESTART | 0xFFFF | The application is not restarted in any case. | 155 156After change 157 158| Name | Value | Description | 159| ----------------------- | ------ | ------------------------------ | 160| ALWAYS_RESTART | 0 | The application is restarted in all cases. | 161| CPP_CRASH_NO_RESTART | NA | **Deleted.** The restart in this scenario is not supported.| 162| RESTART_WHEN_JS_CRASH | 0x0001 | The application is **restarted** in the case of JS_CRASH. | 163| RESTART_WHEN_APP_FREEZE | 0x0002 | The application is **restarted** in the case of APP_FREEZE.| 164| NO_RESTART | 0xFFFF | The application is not restarted in any case. | 165 166**Adaptation Guide** 167 168Perform adaptation based on the new semantics. 169