Skip to content
Commit 1536cc27 authored by Christopher Tate's avatar Christopher Tate
Browse files

Mark uid as non-idle/FG-entitled when launching for fg service

During app launch the app is considered background unless there's an
established reason for it to be otherwise, but the two-stage "start
foreground service" sequence means that there was now a race condition
between giving the app the opportunity to make the service launch in
the foreground and the "hey this uid isn't foreground, we should shut
things down.

Now, during service launch we explicitly mark the uid as foreground-
equivalent when the startForegroundService() sequence is underway.

The install-then-launch sequence isn't strictly essential to demonstrate
the race; but it happened to wind up inducing some broadcast traffic
(and therefore an OOM-adjust sequence) at a conveniently inopportune time
very early during process bringup for the fg service.

Fixes: 65706471
Test: adb install -r ~/Downloads/sampleForegroundService.apk &&
  adb shell am startforegroundservice -a myActionName android.support.mediacompat.foregroundservice

Change-Id: I6f3b6f8fb808e9d830fe108c577047b1938452fc
parent 9b1a9b4f
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment