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

Commit 68394167 authored by Pechetty Sravani (xWF)'s avatar Pechetty Sravani (xWF) Committed by Android (Google) Code Review
Browse files

Revert "Use compat framework to gate system managed media servic..."

Revert submission 31853468-stopmediafgs

Reason for revert: <Droidmonitor created revert due to b/399006472.Will be verified through ABTD for standard investigation.>

Reverted changes: /q/submissionid:31853468-stopmediafgs

Change-Id: Ib93b0383310f59fef3a898f0dda8e014021a499a
parent 32b6528e
Loading
Loading
Loading
Loading
+17 −42
Original line number Diff line number Diff line
@@ -387,15 +387,6 @@ public final class ActiveServices {
    @Overridable
    public static final long FGS_SAW_RESTRICTIONS = 319471980L;

    /**
     * Allows system to manage foreground state of service with type
     * <li>{@link android.content.pm.ServiceInfo#FOREGROUND_SERVICE_TYPE_MEDIA_PLAYBACK}</li>
     */
    @ChangeId
    @EnabledSince(targetSdkVersion = VERSION_CODES.VANILLA_ICE_CREAM)
    @Overridable
    public static final long MEDIA_FGS_STATE_TRANSITION = 281762171L;

    final ActivityManagerService mAm;

    // Maximum number of services that we allow to start in the background
@@ -9350,20 +9341,16 @@ public final class ActiveServices {
                        == ServiceInfo.FOREGROUND_SERVICE_TYPE_NONE
                        && sr.foregroundId == notificationId) {
                    // check if service is explicitly requested by app to not be in foreground.
                    if (sr.systemRequestedFgToBg && CompatChanges.isChangeEnabled(
                            MEDIA_FGS_STATE_TRANSITION, sr.appInfo.uid)) {
                        if (DEBUG_FOREGROUND_SERVICE) {
                    if (sr.systemRequestedFgToBg) {
                        Slog.d(TAG,
                                "System initiated service transition to foreground "
                                        + "for package "
                                        + packageName);
                        }
                        setServiceForegroundInnerLocked(sr, sr.foregroundId,
                                sr.foregroundNoti, /* flags */ 0,
                                ServiceInfo.FOREGROUND_SERVICE_TYPE_MEDIA_PLAYBACK,
                                /* callingUidStart */ 0, /* systemRequestedTransition */ true);
                    } else {
                        if (DEBUG_FOREGROUND_SERVICE) {
                        Slog.d(TAG,
                                "Ignoring system initiated foreground service transition for "
                                        + "package"
@@ -9373,7 +9360,6 @@ public final class ActiveServices {
            }
        }
    }
    }

    /**
     * Handles notifications from MediaSessionService about inactive media foreground services.
@@ -9402,25 +9388,14 @@ public final class ActiveServices {
                if (sr.foregroundServiceType
                        == ServiceInfo.FOREGROUND_SERVICE_TYPE_MEDIA_PLAYBACK
                        && sr.foregroundId == notificationId) {
                    if (CompatChanges.isChangeEnabled(MEDIA_FGS_STATE_TRANSITION, sr.appInfo.uid)) {
                        if (DEBUG_FOREGROUND_SERVICE) {
                    Slog.d(TAG,
                                    "System initiated transition of foreground service"
                                            + "(type:media) to"
                                            + " bg "
                            "System initiated transition of foreground service(type:media) to bg "
                                    + "for package"
                                    + packageName);
                        }
                    setServiceForegroundInnerLocked(sr, /* id */ 0,
                            /* notification */ null, /* flags */ 0,
                            /* foregroundServiceType */ 0, /* callingUidStart */ 0,
                            /* systemRequestedTransition */ true);
                    } else {
                        if (DEBUG_FOREGROUND_SERVICE) {
                            Slog.d(TAG, "Ignoring system initiated transition of foreground"
                                    + " service(type:media)to bg for package " + packageName);
                        }
                    }
                }
            }
        }