Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Skip to content
Commit dcd7201b authored by Achim Thesmann's avatar Achim Thesmann
Browse files

Refine Background Activity Launch (BAL) Modes

This CL refines the `BackgroundActivityStartMode` constants in `ActivityOptions` to provide clearer and more secure control over background activity launches.

Key changes include:

* Introduce `MODE_BACKGROUND_ACTIVITY_START_ALLOW_ALWAYS`: This new constant explicitly grants all BAL privileges, including those associated with the `START_ACTIVITIES_FROM_BACKGROUND` permission. It mirrors the behavior of the deprecated `MODE_BACKGROUND_ACTIVITY_START_ALLOWED` when used with the (now obsolete) `setPendingIntentBackgroundActivityLaunchAllowedByPermission` API. This ensures apps don't inadvertently gain broader BAL privileges when upgrading to SDK 35 or higher.

* Introduce `MODE_BACKGROUND_ACTIVITY_START_ALLOW_IF_VISIBLE`: This new constant offers a safer alternative by granting BAL privileges only when the app is visible to the user. This aligns with the common use case where activities are started in response to user interaction with a visible UI element.

* Deprecate `MODE_BACKGROUND_ACTIVITY_START_ALLOWED`: The existing `MODE_BACKGROUND_ACTIVITY_START_ALLOWED` constant is deprecated to encourage the use of the more explicit and secure new constants.

* Naming Convention: The new constants use "ALLOW" instead of "ALLOWED" to indicate an instruction rather than a result. This distinction clarifies the purpose of these constants and aligns with the intended usage.  With `MODE_BACKGROUND_ACTIVITY_START_ALLOWED` being deprecated and `MODE_BACKGROUND_ACTIVITY_START_DENIED` rarely being used because it is the default when targeting SDK 35+, this naming inconsistency with  is less of a concern.

These changes improve the clarity and security of background activity launch controls, guiding developers towards best practices and minimizing the risk of unintended behavior.

Test: atest BackgroundActivityLaunchTests
Flag: com.android.window.flags.bal_additional_start_modes
Bug: 352182359
Change-Id: Id82d8a3260fd04b477739803441f16d2f0c6bac3
parent 276222e0
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment