summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Treehugger Robot <android-test-infra-autosubmit@system.gserviceaccount.com> 2024-04-30 20:09:35 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2024-04-30 20:09:35 +0000
commit8c0f3860e1f40f16abac74b78412c81aebdd6e42 (patch)
treeb538a0634af736cd0bf8370014eff52e21929015
parent98128316507d549b989f853c4a8f72159763c017 (diff)
parent3e8e3c4904662a4de8bb359cd8035b876b381332 (diff)
Merge "Update the Service#onTimeout() javadoc." into main
-rw-r--r--core/java/android/app/Service.java18
1 files changed, 18 insertions, 0 deletions
diff --git a/core/java/android/app/Service.java b/core/java/android/app/Service.java
index f092945a5d28..9b3fb5c73415 100644
--- a/core/java/android/app/Service.java
+++ b/core/java/android/app/Service.java
@@ -1197,6 +1197,24 @@ public abstract class Service extends ContextWrapper implements ComponentCallbac
/**
* Callback called when a particular foreground service type has timed out.
*
+ * <p>This callback is meant to give the app a small grace period of a few seconds to finish
+ * the foreground service of the offending type - if it fails to do so, the app will be
+ * declared an ANR.
+ *
+ * <p>The foreground service of the offending type can be stopped within the time limit by
+ * {@link android.app.Service#stopSelf()},
+ * {@link android.content.Context#stopService(android.content.Intent)} or their overloads.
+ * {@link android.app.Service#stopForeground(int)} can be used as well, which demotes the
+ * service to a "background" service, which will soon be stopped by the system.
+ *
+ * <p>The specific time limit for each type (if one exists) is mentioned in the documentation
+ * for that foreground service type.
+ *
+ * <p>Note: time limits are restricted to a rolling 24-hour window - for example, if a
+ * foreground service type has a time limit of 6 hours, that time counter begins as soon as the
+ * foreground service starts. This time limit will only be reset once every 24 hours or if the
+ * app comes into the foreground state.
+ *
* @param startId the startId passed to {@link #onStartCommand(Intent, int, int)} when
* the service started.
* @param fgsType the {@link ServiceInfo.ForegroundServiceType foreground service type} which