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

Skip to content
Commit 853f6132 authored by Hui Yu's avatar Hui Yu
Browse files

Prototyping background started FGS startForeground() restriction.

1. Add a field mAllowStartForeground in ServiceRecord, this field is set
to true if the service is started from foreground or meet the exemption
conditions (the exemption conditions is the same exemption list as
"background started FGS while-in-use permission restriction" in R.
2. Add a DeviceConfig flag "default_fgs_starts_restriction_enabled"
to enable the FGS startForeground() restriction. Default is disable.
3. if mAllowStartForeground is false and "default_fgs_starts_restriction_enabled"
is true, do not allow startForeground() on this service.
4. if mAllowStartForeground is false,  generate a WTF log message in following
format:
ActivityManager: Background started FGS [callingPackage: com.google.android.music; callingUid: 10155; uidState: FGS; intent: Intent { act=com.google.android.music.leanback.APP_IN_USE cmp=com.google.android.music/.autocache.AutoCacheSchedulingService }]

On droidfood devices, these log messages are sent to error_stats table,
so we can tell how many apps have background started FGS.

Bug: 157473819
Test: adb logcat | grep "Background started FGS"
atest cts/tests/app/src/android/app/cts/ActivityManagerFgsBgStartTest.java#testFgsStartFromBG

Change-Id: Id122fc3379a8a67287454bc1341521ef84b1c614
parent 326e3ca1
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