From f61a9d76e16f2e4084ba905e0730b045913f3228 Mon Sep 17 00:00:00 2001 From: Makoto Onuki Date: Wed, 20 Oct 2021 11:01:59 -0700 Subject: [PATCH] Fix javadoc on Context.startForegroundService Bug: 203664384 Bug: 142968927 Test: treehugger Change-Id: Ie3ba7d9fd5cda034f2ef8fab79630cfb15d6bb13 --- core/java/android/content/Context.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/core/java/android/content/Context.java b/core/java/android/content/Context.java index c3ec09466de62..7f2a740d3228b 100644 --- a/core/java/android/content/Context.java +++ b/core/java/android/content/Context.java @@ -3246,7 +3246,11 @@ public abstract class Context { * Service will call {@link android.app.Service#startForeground(int, android.app.Notification) * startForeground(int, android.app.Notification)} once it begins running. The service is given * an amount of time comparable to the ANR interval to do this, otherwise the system - * will automatically stop the service and declare the app ANR. + * will automatically crash the process, in which case an internal exception + * {@code ForegroundServiceDidNotStartInTimeException} is logged on logcat on devices + * running SDK Version {@link android.os.Build.VERSION_CODES#S} or later. On older Android + * versions, an internal exception {@code RemoteServiceException} is logged instead, with + * a corresponding message. * *

Unlike the ordinary {@link #startService(Intent)}, this method can be used * at any time, regardless of whether the app hosting the service is in a foreground