OSDN Git Service

Suppress all background-state services in user-forced app standby
authorChristopher Tate <ctate@google.com>
Tue, 13 Mar 2018 00:57:09 +0000 (17:57 -0700)
committerChristopher Tate <ctate@google.com>
Wed, 21 Mar 2018 00:21:39 +0000 (17:21 -0700)
commitc7933acad1e6a66f7858bc92b057f6fd6d72c803
treefee1a3c9ab1793ba66dc75bffd96c68973ec6f68
parent3912a7f54466f258c5b2597eebdb54cfe0f8281c
Suppress all background-state services in user-forced app standby

Foreground services are treated as normal services when the user has
placed the app under FAS restrictions.  The API contract for the app
is unchanged -- for example, if the app calls startForegroundService()
in this state it will still ANR if it fails to call startForeground()
as promised.  All service starts are quietly suppressed unless the app
is showing foreground UI.

If an app is already running a foreground service when FAS is applied,
that service is taken out of the fg state and thereafter treated like an
ordinary background service in a background state:  after 1 minute, the
service is summarily stopped by the OS.

Bug: 73559697
Test: ApiDemos fg service suite
Test: atest CtsAppTestCases
Change-Id: Icc5fb180b90cb5d902e96aeb92a93f6daf00bd9b
services/core/java/com/android/server/AppStateTracker.java
services/core/java/com/android/server/am/ActiveServices.java
services/core/java/com/android/server/am/ActivityManagerService.java
services/core/java/com/android/server/am/BroadcastQueue.java