diff --git a/core/java/android/app/Service.java b/core/java/android/app/Service.java index 01e4b150fd7c6..6eabd994a6086 100644 --- a/core/java/android/app/Service.java +++ b/core/java/android/app/Service.java @@ -1053,4 +1053,16 @@ public abstract class Service extends ContextWrapper implements ComponentCallbac return sStartForegroundServiceStackTraces.get(className); } } + + /** + * Callback called on timeout for {@link ServiceInfo#FOREGROUND_SERVICE_TYPE_SHORT_SERVICE}. + * + * TODO Implement it + * TODO Javadoc + * + * @param startId + * @hide + */ + public void onTimeout(int startId) { + } } diff --git a/core/java/android/content/pm/ServiceInfo.java b/core/java/android/content/pm/ServiceInfo.java index ab20b6f7f9ccb..14f03eae8bf15 100644 --- a/core/java/android/content/pm/ServiceInfo.java +++ b/core/java/android/content/pm/ServiceInfo.java @@ -363,6 +363,28 @@ public class ServiceInfo extends ComponentInfo ) public static final int FOREGROUND_SERVICE_TYPE_SYSTEM_EXEMPTED = 1 << 10; + /** + * Foreground service type corresponding to {@code shortService} in + * the {@link android.R.attr#foregroundServiceType} attribute. + * + * TODO Implement it + * + * TODO Expand the javadoc + * + * This type is not associated with specific use cases unlike other types, but this has + * unique restrictions. + * + * + * @see Service#onTimeout + * + * @hide + */ + public static final int FOREGROUND_SERVICE_TYPE_SHORT_SERVICE = 1 << 11; + /** * Constant corresponding to {@code specialUse} in * the {@link android.R.attr#foregroundServiceType} attribute. @@ -446,6 +468,7 @@ public class ServiceInfo extends ComponentInfo FOREGROUND_SERVICE_TYPE_HEALTH, FOREGROUND_SERVICE_TYPE_REMOTE_MESSAGING, FOREGROUND_SERVICE_TYPE_SYSTEM_EXEMPTED, + FOREGROUND_SERVICE_TYPE_SHORT_SERVICE, FOREGROUND_SERVICE_TYPE_SPECIAL_USE }) @Retention(RetentionPolicy.SOURCE) @@ -528,6 +551,8 @@ public class ServiceInfo extends ComponentInfo return "remoteMessaging"; case FOREGROUND_SERVICE_TYPE_SYSTEM_EXEMPTED: return "systemExempted"; + case FOREGROUND_SERVICE_TYPE_SHORT_SERVICE: + return "shortService"; case FOREGROUND_SERVICE_TYPE_SPECIAL_USE: return "specialUse"; default: diff --git a/core/res/res/values/attrs_manifest.xml b/core/res/res/values/attrs_manifest.xml index 607467abe24f0..a5c0827230463 100644 --- a/core/res/res/values/attrs_manifest.xml +++ b/core/res/res/values/attrs_manifest.xml @@ -1704,6 +1704,12 @@ {@link android.content.pm.ServiceInfo#FOREGROUND_SERVICE_TYPE_SYSTEM_EXEMPTED}. --> + +