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

Commit 769668e8 authored by Varun Shah's avatar Varun Shah
Browse files

Update new onTimeout to be called for SHORT_SERVICE.

Add logic to call the new onTimeout callback for short fgs. The old
callback (without the fgs type) will still be called to maintain
compatibility.

Bug: 330399444
Test: atest CtsShortFgsTest
Change-Id: I14b29d6fc9564f24aa8f7d2c64a2e454880d5d10
parent ca8aece3
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -1135,6 +1135,9 @@ public abstract class Service extends ContextWrapper implements ComponentCallbac
        } catch (RemoteException ex) {
        }
        onTimeout(startId);
        if (Flags.introduceNewServiceOntimeoutCallback()) {
            onTimeout(startId, ServiceInfo.FOREGROUND_SERVICE_TYPE_SHORT_SERVICE);
        }
    }

    /**
@@ -1146,6 +1149,12 @@ public abstract class Service extends ContextWrapper implements ComponentCallbac
     * 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>Starting from Android version {@link android.os.Build.VERSION_CODES#VANILLA_ICE_CREAM},
     * {@link #onTimeout(int, int)} will also be called when a foreground service of type
     * {@link ServiceInfo#FOREGROUND_SERVICE_TYPE_SHORT_SERVICE} times out.
     * Developers do not need to implement both of the callbacks on
     * {@link android.os.Build.VERSION_CODES#VANILLA_ICE_CREAM} and onwards.
     *
     * <p>Note, even though
     * {@link ServiceInfo#FOREGROUND_SERVICE_TYPE_SHORT_SERVICE}
     * was added