Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5b476f04 authored by Varun Shah's avatar Varun Shah Committed by Android (Google) Code Review
Browse files

Merge "Update onTimeout api with ForegroundServiceType annotation." into main

parents dd8353a6 ff624a1a
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -1233,7 +1233,8 @@ public final class ActivityThread extends ClientTransactionHandler
        }

        @Override
        public final void scheduleTimeoutServiceForType(IBinder token, int startId, int fgsType) {
        public final void scheduleTimeoutServiceForType(IBinder token, int startId,
                @ServiceInfo.ForegroundServiceType int fgsType) {
            if (Trace.isTagEnabled(Trace.TRACE_TAG_ACTIVITY_MANAGER)) {
                Trace.instant(Trace.TRACE_TAG_ACTIVITY_MANAGER,
                        "scheduleTimeoutServiceForType. token=" + token);
@@ -5151,7 +5152,8 @@ public final class ActivityThread extends ClientTransactionHandler
        }
    }

    private void handleTimeoutServiceForType(IBinder token, int startId, int fgsType) {
    private void handleTimeoutServiceForType(IBinder token, int startId,
            @ServiceInfo.ForegroundServiceType int fgsType) {
        Service s = mServices.get(token);
        if (s != null) {
            try {
+5 −4
Original line number Diff line number Diff line
@@ -1164,7 +1164,7 @@ public abstract class Service extends ContextWrapper implements ComponentCallbac
    }

    /** @hide */
    public final void callOnTimeLimitExceeded(int startId, int fgsType) {
    public final void callOnTimeLimitExceeded(int startId, @ForegroundServiceType int fgsType) {
        // Note, because all the service callbacks (and other similar callbacks, e.g. activity
        // callbacks) are delivered using the main handler, it's possible the service is already
        // stopped when before this method is called, so we do a double check here.
@@ -1190,9 +1190,10 @@ public abstract class Service extends ContextWrapper implements ComponentCallbac
     *
     * @param startId the startId passed to {@link #onStartCommand(Intent, int, int)} when
     *                the service started.
     * @param fgsType the foreground service type which caused the timeout.
     * @param fgsType the {@link ServiceInfo.ForegroundServiceType foreground service type} which
     *                caused the timeout.
     */
    @FlaggedApi(Flags.FLAG_INTRODUCE_NEW_SERVICE_ONTIMEOUT_CALLBACK)
    public void onTimeout(int startId, int fgsType) {
    public void onTimeout(int startId, @ForegroundServiceType int fgsType) {
    }
}