Add constants "short service" foreground service

Aslo add the timeout callback.

All APIs are still hidden.

Bug: 257270313
Test: Build
Change-Id: I9868de22a343e97c83cc2524cf81aec159aa62ab
This commit is contained in:
Makoto Onuki
2022-11-16 11:08:01 -08:00
parent 890e92f419
commit f36f22de3e
3 changed files with 43 additions and 0 deletions

View File

@@ -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) {
}
}

View File

@@ -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.
* <ul>
* <li>Has a timeout
* <li>Cannot start other foreground services from this
* <li>
* </ul>
*
* @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:

View File

@@ -1704,6 +1704,12 @@
{@link android.content.pm.ServiceInfo#FOREGROUND_SERVICE_TYPE_SYSTEM_EXEMPTED}.
-->
<flag name="systemExempted" value="0x400" />
<!-- "Short service" foreground service type. See
TODO: Change it to a real link
{@code android.content.pm.ServiceInfo#FOREGROUND_SERVICE_TYPE_SHORT_SERVICE}.
for more details.
-->
<flag name="shortService" value="0x800" />
<!-- Use cases that can't be categorized into any other foreground service types, but also
can't use @link android.app.job.JobInfo.Builder} APIs.
See {@link android.content.pm.ServiceInfo#FOREGROUND_SERVICE_TYPE_SPECIAL_USE} for the