title: Android 11 (API level 30) onTaskRemoved fired in Foreground service when app go to background
body: <p>I tried to test app that I work with on android 11 (got it on Pixel 3 XL). I receive strange behaviour when app goes to background:
  onTaskRemoved fired on Foreground service and looks like app killed and restarted.</p>
  <p>Info about Foreground service:
  in Manifest:</p>
  <pre><code>&lt;service
      android:name=&quot;.MyFS&quot;
      android:foregroundServiceType=&quot;mediaProjection&quot;
      android:enabled=&quot;true&quot;
      android:exported=&quot;false&quot;/&gt;
  </code></pre>
  <p>in FS class onStartCommand -&gt; return START_STICKY;</p>
  <p>Additional info: App using &quot;camera&quot; &amp; &quot;microphone&quot; and I tried to add this two to android:foregroundServiceType=&quot;mediaProjection|camera|microphone&quot; but it didn't help.</p>
  <p><strong>Also interesting that onTaskRemoved fired just on first time that app goes to Background, if I back to app and click &quot;home&quot; second time onTaskRemoved not called.</strong></p>
  <p>Please help me to understand from were it comes. Thanks</p>
  <p>PS:
  Is it related?
  Before onTaskRemoved I can see in the full logcat this:</p>
  <pre><code>2020-10-05 09:33:19.866 1463-1524/? D/EventSequenceValidator: onIntentFailed during UNKNOWN.
      java.lang.Throwable: EventSequenceValidator#getStackTrace
          at com.google.android.startop.iorap.EventSequenceValidator.logWarningWithStackTrace(EventSequenceValidator.java:260)
          at com.google.android.startop.iorap.EventSequenceValidator.onIntentFailed(EventSequenceValidator.java:130)
          at com.android.server.wm.LaunchObserverRegistryImpl.handleOnIntentFailed(LaunchObserverRegistryImpl.java:147)
          at com.android.server.wm.LaunchObserverRegistryImpl.lambda$KukKmVpn5W_1xSV6Dnp8wW2H2Ks(Unknown Source:0)
          at com.android.server.wm.-$$Lambda$LaunchObserverRegistryImpl$KukKmVpn5W_1xSV6Dnp8wW2H2Ks.accept(Unknown Source:2)
          at com.android.internal.util.function.pooled.PooledLambdaImpl.doInvoke(PooledLambdaImpl.java:264)
          at com.android.internal.util.function.pooled.PooledLambdaImpl.invoke(PooledLambdaImpl.java:201)
          at com.android.internal.util.function.pooled.OmniFunction.run(OmniFunction.java:97)
          at android.os.Handler.handleCallback(Handler.java:938)
          at android.os.Handler.dispatchMessage(Handler.java:99)
          at android.os.Looper.loop(Looper.java:223)
          at android.os.HandlerThread.run(HandlerThread.java:67)
          at com.android.server.ServiceThread.run(ServiceThread.java:44)
  2020-10-05 09:33:19.866 1463-1524/? D/EventSequenceValidator: dec AccIntentStartedEvents to 2
  2020-10-05 09:33:19.870 27662-27662/: t:main onTaskRemoved here.
  </code></pre>