diff options
| author | 2023-01-31 16:34:06 -0800 | |
|---|---|---|
| committer | 2023-01-31 17:05:33 -0800 | |
| commit | c93d310dc9b91ea8c2943cbd64fa470475886db0 (patch) | |
| tree | b48c67fd705ac89274cbdeef1905a4ef508ef2cf | |
| parent | b69c202024f6a5494cc162a4df6114d247d6bb1b (diff) | |
Update the javadoc on SHORT_SERVICE fgs type
Test: presubmit (javadoc change only)
Fix: 261607168
Change-Id: I1651a175fb40ce1477ef74b487b696db7effa501
| -rw-r--r-- | core/java/android/app/Service.java | 16 | ||||
| -rw-r--r-- | core/java/android/content/pm/ServiceInfo.java | 16 |
2 files changed, 30 insertions, 2 deletions
diff --git a/core/java/android/app/Service.java b/core/java/android/app/Service.java index e48539791cc1..a1554572c7df 100644 --- a/core/java/android/app/Service.java +++ b/core/java/android/app/Service.java @@ -1140,6 +1140,22 @@ public abstract class Service extends ContextWrapper implements ComponentCallbac * Callback called on timeout for {@link ServiceInfo#FOREGROUND_SERVICE_TYPE_SHORT_SERVICE}. * See {@link ServiceInfo#FOREGROUND_SERVICE_TYPE_SHORT_SERVICE} for more details. * + * <p>If the foreground service of type + * {@link ServiceInfo#FOREGROUND_SERVICE_TYPE_SHORT_SERVICE} + * doesn't finish even after it's timed out, + * the app will be declared an ANR after a short grace period of several seconds. + * + * <p>Note, even though + * {@link ServiceInfo#FOREGROUND_SERVICE_TYPE_SHORT_SERVICE} + * was added + * on Android version {@link android.os.Build.VERSION_CODES#UPSIDE_DOWN_CAKE}, + * it can be also used on + * on prior android versions (just like other new foreground service types can be used). + * However, because {@link android.app.Service#onTimeout(int)} did not exist on prior versions, + * it will never called on such versions. + * Because of this, developers must make sure to stop the foreground service even if + * {@link android.app.Service#onTimeout(int)} is not called on such versions. + * * @param startId the startId passed to {@link #onStartCommand(Intent, int, int)} when * the service started. */ diff --git a/core/java/android/content/pm/ServiceInfo.java b/core/java/android/content/pm/ServiceInfo.java index f3209f9c7ea6..49d21dafbd5d 100644 --- a/core/java/android/content/pm/ServiceInfo.java +++ b/core/java/android/content/pm/ServiceInfo.java @@ -401,8 +401,9 @@ public class ServiceInfo extends ComponentInfo * * <p>If the service isn't stopped within the timeout, * {@link android.app.Service#onTimeout(int)} will be called. - * If the service is still not stopped after the callback, - * the app will be declared an ANR. + * + * <p>If the service is still not stopped after the callback, + * the app will be declared an ANR after a short grace period of several seconds. * * <li> * A foreground service of this type cannot be made "sticky" @@ -419,6 +420,17 @@ public class ServiceInfo extends ComponentInfo * </a> * </ul> * + * <p>Note, even though + * {@link ServiceInfo#FOREGROUND_SERVICE_TYPE_SHORT_SERVICE} + * was added + * on Android version {@link android.os.Build.VERSION_CODES#UPSIDE_DOWN_CAKE}, + * it can be also used on + * on prior android versions (just like other new foreground service types can be used). + * However, because {@link android.app.Service#onTimeout(int)} did not exist on prior versions, + * it will never called on such versions. + * Because of this, developers must make sure to stop the foreground service even if + * {@link android.app.Service#onTimeout(int)} is not called on such versions. + * * @see android.app.Service#onTimeout(int) */ public static final int FOREGROUND_SERVICE_TYPE_SHORT_SERVICE = 1 << 11; |