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

Commit d4f33bc4 authored by Christopher Tate's avatar Christopher Tate
Browse files

Teach FGS notification deferral about service types

Service type is a set, not a single type.

Bug: 179291546
Bug: 177729759
Test: atest CtsAppTestCases:ServiceTest
Test: atest CtsAppTestCases:NotificationManagerTest
Change-Id: I9c5bea609187a8521c5bc29f3df266af3bfa6dbb
parent b5cc4a53
Loading
Loading
Loading
Loading
+15 −9
Original line number Diff line number Diff line
@@ -189,6 +189,15 @@ public final class ActiveServices {
    // calling startForeground() before we ANR + stop it.
    static final int SERVICE_START_FOREGROUND_TIMEOUT = 10 * 1000 * Build.HW_TIMEOUT_MULTIPLIER;

    // Foreground service types that always get immediate notification display,
    // expressed in the same bitmask format that ServiceRecord.foregroundServiceType
    // uses.
    static final int FGS_IMMEDIATE_DISPLAY_MASK =
            ServiceInfo.FOREGROUND_SERVICE_TYPE_MEDIA_PLAYBACK
                    | ServiceInfo.FOREGROUND_SERVICE_TYPE_PHONE_CALL
                    | ServiceInfo.FOREGROUND_SERVICE_TYPE_CONNECTED_DEVICE
                    | ServiceInfo.FOREGROUND_SERVICE_TYPE_MEDIA_PROJECTION;

    final ActivityManagerService mAm;

    // Maximum number of services that we allow to start in the background
@@ -2018,10 +2027,7 @@ public final class ActiveServices {
                }
                // or is this an type of FGS that always shows immediately?
                if (!showNow) {
                    switch (r.foregroundServiceType) {
                        case ServiceInfo.FOREGROUND_SERVICE_TYPE_MEDIA_PLAYBACK:
                        case ServiceInfo.FOREGROUND_SERVICE_TYPE_PHONE_CALL:
                        case ServiceInfo.FOREGROUND_SERVICE_TYPE_MEDIA_PROJECTION:
                    if ((r.foregroundServiceType & FGS_IMMEDIATE_DISPLAY_MASK) != 0) {
                        if (DEBUG_FOREGROUND_SERVICE) {
                            Slog.d(TAG_SERVICE, "FGS " + r
                                    + " type gets immediate display");