Loading services/core/java/com/android/server/am/ActiveServices.java +42 −17 Original line number Original line Diff line number Diff line Loading @@ -387,6 +387,15 @@ public final class ActiveServices { @Overridable @Overridable public static final long FGS_SAW_RESTRICTIONS = 319471980L; 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; final ActivityManagerService mAm; // Maximum number of services that we allow to start in the background // Maximum number of services that we allow to start in the background Loading Loading @@ -9341,16 +9350,20 @@ public final class ActiveServices { == ServiceInfo.FOREGROUND_SERVICE_TYPE_NONE == ServiceInfo.FOREGROUND_SERVICE_TYPE_NONE && sr.foregroundId == notificationId) { && sr.foregroundId == notificationId) { // check if service is explicitly requested by app to not be in foreground. // check if service is explicitly requested by app to not be in foreground. if (sr.systemRequestedFgToBg) { if (sr.systemRequestedFgToBg && CompatChanges.isChangeEnabled( MEDIA_FGS_STATE_TRANSITION, sr.appInfo.uid)) { if (DEBUG_FOREGROUND_SERVICE) { Slog.d(TAG, Slog.d(TAG, "System initiated service transition to foreground " "System initiated service transition to foreground " + "for package " + "for package " + packageName); + packageName); } setServiceForegroundInnerLocked(sr, sr.foregroundId, setServiceForegroundInnerLocked(sr, sr.foregroundId, sr.foregroundNoti, /* flags */ 0, sr.foregroundNoti, /* flags */ 0, ServiceInfo.FOREGROUND_SERVICE_TYPE_MEDIA_PLAYBACK, ServiceInfo.FOREGROUND_SERVICE_TYPE_MEDIA_PLAYBACK, /* callingUidStart */ 0, /* systemRequestedTransition */ true); /* callingUidStart */ 0, /* systemRequestedTransition */ true); } else { } else { if (DEBUG_FOREGROUND_SERVICE) { Slog.d(TAG, Slog.d(TAG, "Ignoring system initiated foreground service transition for " "Ignoring system initiated foreground service transition for " + "package " + "package " Loading @@ -9360,6 +9373,7 @@ public final class ActiveServices { } } } } } } } /** /** * Handles notifications from MediaSessionService about inactive media foreground services. * Handles notifications from MediaSessionService about inactive media foreground services. Loading Loading @@ -9388,14 +9402,25 @@ public final class ActiveServices { if (sr.foregroundServiceType if (sr.foregroundServiceType == ServiceInfo.FOREGROUND_SERVICE_TYPE_MEDIA_PLAYBACK == ServiceInfo.FOREGROUND_SERVICE_TYPE_MEDIA_PLAYBACK && sr.foregroundId == notificationId) { && sr.foregroundId == notificationId) { if (CompatChanges.isChangeEnabled(MEDIA_FGS_STATE_TRANSITION, sr.appInfo.uid)) { if (DEBUG_FOREGROUND_SERVICE) { Slog.d(TAG, 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 " + "for package " + packageName); + packageName); } setServiceForegroundInnerLocked(sr, /* id */ 0, setServiceForegroundInnerLocked(sr, /* id */ 0, /* notification */ null, /* flags */ 0, /* notification */ null, /* flags */ 0, /* foregroundServiceType */ 0, /* callingUidStart */ 0, /* foregroundServiceType */ 0, /* callingUidStart */ 0, /* systemRequestedTransition */ true); /* systemRequestedTransition */ true); } else { if (DEBUG_FOREGROUND_SERVICE) { Slog.d(TAG, "Ignoring system initiated transition of foreground" + " service(type:media)to bg for package " + packageName); } } } } } } } } Loading Loading
services/core/java/com/android/server/am/ActiveServices.java +42 −17 Original line number Original line Diff line number Diff line Loading @@ -387,6 +387,15 @@ public final class ActiveServices { @Overridable @Overridable public static final long FGS_SAW_RESTRICTIONS = 319471980L; 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; final ActivityManagerService mAm; // Maximum number of services that we allow to start in the background // Maximum number of services that we allow to start in the background Loading Loading @@ -9341,16 +9350,20 @@ public final class ActiveServices { == ServiceInfo.FOREGROUND_SERVICE_TYPE_NONE == ServiceInfo.FOREGROUND_SERVICE_TYPE_NONE && sr.foregroundId == notificationId) { && sr.foregroundId == notificationId) { // check if service is explicitly requested by app to not be in foreground. // check if service is explicitly requested by app to not be in foreground. if (sr.systemRequestedFgToBg) { if (sr.systemRequestedFgToBg && CompatChanges.isChangeEnabled( MEDIA_FGS_STATE_TRANSITION, sr.appInfo.uid)) { if (DEBUG_FOREGROUND_SERVICE) { Slog.d(TAG, Slog.d(TAG, "System initiated service transition to foreground " "System initiated service transition to foreground " + "for package " + "for package " + packageName); + packageName); } setServiceForegroundInnerLocked(sr, sr.foregroundId, setServiceForegroundInnerLocked(sr, sr.foregroundId, sr.foregroundNoti, /* flags */ 0, sr.foregroundNoti, /* flags */ 0, ServiceInfo.FOREGROUND_SERVICE_TYPE_MEDIA_PLAYBACK, ServiceInfo.FOREGROUND_SERVICE_TYPE_MEDIA_PLAYBACK, /* callingUidStart */ 0, /* systemRequestedTransition */ true); /* callingUidStart */ 0, /* systemRequestedTransition */ true); } else { } else { if (DEBUG_FOREGROUND_SERVICE) { Slog.d(TAG, Slog.d(TAG, "Ignoring system initiated foreground service transition for " "Ignoring system initiated foreground service transition for " + "package " + "package " Loading @@ -9360,6 +9373,7 @@ public final class ActiveServices { } } } } } } } /** /** * Handles notifications from MediaSessionService about inactive media foreground services. * Handles notifications from MediaSessionService about inactive media foreground services. Loading Loading @@ -9388,14 +9402,25 @@ public final class ActiveServices { if (sr.foregroundServiceType if (sr.foregroundServiceType == ServiceInfo.FOREGROUND_SERVICE_TYPE_MEDIA_PLAYBACK == ServiceInfo.FOREGROUND_SERVICE_TYPE_MEDIA_PLAYBACK && sr.foregroundId == notificationId) { && sr.foregroundId == notificationId) { if (CompatChanges.isChangeEnabled(MEDIA_FGS_STATE_TRANSITION, sr.appInfo.uid)) { if (DEBUG_FOREGROUND_SERVICE) { Slog.d(TAG, 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 " + "for package " + packageName); + packageName); } setServiceForegroundInnerLocked(sr, /* id */ 0, setServiceForegroundInnerLocked(sr, /* id */ 0, /* notification */ null, /* flags */ 0, /* notification */ null, /* flags */ 0, /* foregroundServiceType */ 0, /* callingUidStart */ 0, /* foregroundServiceType */ 0, /* callingUidStart */ 0, /* systemRequestedTransition */ true); /* systemRequestedTransition */ true); } else { if (DEBUG_FOREGROUND_SERVICE) { Slog.d(TAG, "Ignoring system initiated transition of foreground" + " service(type:media)to bg for package " + packageName); } } } } } } } } Loading