Loading media/java/android/media/session/PlaybackState.java +0 −22 Original line number Diff line number Diff line Loading @@ -524,28 +524,6 @@ public final class PlaybackState implements Parcelable { return false; } /** * Returns whether the service holding the media session should run in the foreground when the * media session has this playback state or not. * * @hide */ public boolean shouldAllowServiceToRunInForeground() { switch (mState) { case PlaybackState.STATE_PLAYING: case PlaybackState.STATE_FAST_FORWARDING: case PlaybackState.STATE_REWINDING: case PlaybackState.STATE_BUFFERING: case PlaybackState.STATE_CONNECTING: case PlaybackState.STATE_SKIPPING_TO_PREVIOUS: case PlaybackState.STATE_SKIPPING_TO_NEXT: case PlaybackState.STATE_SKIPPING_TO_QUEUE_ITEM: return true; default: return false; } } public static final @android.annotation.NonNull Parcelable.Creator<PlaybackState> CREATOR = new Parcelable.Creator<PlaybackState>() { @Override Loading services/core/java/com/android/server/media/MediaSession2Record.java +6 −1 Original line number Diff line number Diff line Loading @@ -198,7 +198,12 @@ public class MediaSession2Record implements MediaSessionRecordImpl { mIsConnected = true; service = mService; } service.onSessionActiveStateChanged(MediaSession2Record.this); // TODO (b/318745416): Add support for FGS in MediaSession2. Passing a // null playback state means the owning process will not be allowed to // run in the foreground. service.onSessionActiveStateChanged(MediaSession2Record.this, /* playbackState= */ null); } @Override Loading services/core/java/com/android/server/media/MediaSessionRecord.java +1 −1 Original line number Diff line number Diff line Loading @@ -1144,7 +1144,7 @@ public class MediaSessionRecord implements IBinder.DeathRecipient, MediaSessionR mIsActive = active; long token = Binder.clearCallingIdentity(); try { mService.onSessionActiveStateChanged(MediaSessionRecord.this); mService.onSessionActiveStateChanged(MediaSessionRecord.this, mPlaybackState); } finally { Binder.restoreCallingIdentity(token); } Loading services/core/java/com/android/server/media/MediaSessionService.java +8 −3 Original line number Diff line number Diff line Loading @@ -260,7 +260,8 @@ public class MediaSessionService extends SystemService implements Monitor { return mGlobalPrioritySession != null && mGlobalPrioritySession.isActive(); } void onSessionActiveStateChanged(MediaSessionRecordImpl record) { void onSessionActiveStateChanged( MediaSessionRecordImpl record, @Nullable PlaybackState playbackState) { synchronized (mLock) { FullUserRecord user = getFullUserRecordLocked(record.getUserId()); if (user == null) { Loading @@ -287,7 +288,9 @@ public class MediaSessionService extends SystemService implements Monitor { user.mPriorityStack.onSessionActiveStateChanged(record); } setForegroundServiceAllowance( record, /* allowRunningInForeground= */ record.isActive()); record, /* allowRunningInForeground= */ record.isActive() && (playbackState == null || playbackState.isActive())); mHandler.postSessionsChanged(record); } } Loading Loading @@ -386,7 +389,9 @@ public class MediaSessionService extends SystemService implements Monitor { user.mPriorityStack.onPlaybackStateChanged(record, shouldUpdatePriority); if (playbackState != null) { setForegroundServiceAllowance( record, playbackState.shouldAllowServiceToRunInForeground()); record, /* allowRunningInForeground= */ playbackState.isActive() && record.isActive()); } } } Loading Loading
media/java/android/media/session/PlaybackState.java +0 −22 Original line number Diff line number Diff line Loading @@ -524,28 +524,6 @@ public final class PlaybackState implements Parcelable { return false; } /** * Returns whether the service holding the media session should run in the foreground when the * media session has this playback state or not. * * @hide */ public boolean shouldAllowServiceToRunInForeground() { switch (mState) { case PlaybackState.STATE_PLAYING: case PlaybackState.STATE_FAST_FORWARDING: case PlaybackState.STATE_REWINDING: case PlaybackState.STATE_BUFFERING: case PlaybackState.STATE_CONNECTING: case PlaybackState.STATE_SKIPPING_TO_PREVIOUS: case PlaybackState.STATE_SKIPPING_TO_NEXT: case PlaybackState.STATE_SKIPPING_TO_QUEUE_ITEM: return true; default: return false; } } public static final @android.annotation.NonNull Parcelable.Creator<PlaybackState> CREATOR = new Parcelable.Creator<PlaybackState>() { @Override Loading
services/core/java/com/android/server/media/MediaSession2Record.java +6 −1 Original line number Diff line number Diff line Loading @@ -198,7 +198,12 @@ public class MediaSession2Record implements MediaSessionRecordImpl { mIsConnected = true; service = mService; } service.onSessionActiveStateChanged(MediaSession2Record.this); // TODO (b/318745416): Add support for FGS in MediaSession2. Passing a // null playback state means the owning process will not be allowed to // run in the foreground. service.onSessionActiveStateChanged(MediaSession2Record.this, /* playbackState= */ null); } @Override Loading
services/core/java/com/android/server/media/MediaSessionRecord.java +1 −1 Original line number Diff line number Diff line Loading @@ -1144,7 +1144,7 @@ public class MediaSessionRecord implements IBinder.DeathRecipient, MediaSessionR mIsActive = active; long token = Binder.clearCallingIdentity(); try { mService.onSessionActiveStateChanged(MediaSessionRecord.this); mService.onSessionActiveStateChanged(MediaSessionRecord.this, mPlaybackState); } finally { Binder.restoreCallingIdentity(token); } Loading
services/core/java/com/android/server/media/MediaSessionService.java +8 −3 Original line number Diff line number Diff line Loading @@ -260,7 +260,8 @@ public class MediaSessionService extends SystemService implements Monitor { return mGlobalPrioritySession != null && mGlobalPrioritySession.isActive(); } void onSessionActiveStateChanged(MediaSessionRecordImpl record) { void onSessionActiveStateChanged( MediaSessionRecordImpl record, @Nullable PlaybackState playbackState) { synchronized (mLock) { FullUserRecord user = getFullUserRecordLocked(record.getUserId()); if (user == null) { Loading @@ -287,7 +288,9 @@ public class MediaSessionService extends SystemService implements Monitor { user.mPriorityStack.onSessionActiveStateChanged(record); } setForegroundServiceAllowance( record, /* allowRunningInForeground= */ record.isActive()); record, /* allowRunningInForeground= */ record.isActive() && (playbackState == null || playbackState.isActive())); mHandler.postSessionsChanged(record); } } Loading Loading @@ -386,7 +389,9 @@ public class MediaSessionService extends SystemService implements Monitor { user.mPriorityStack.onPlaybackStateChanged(record, shouldUpdatePriority); if (playbackState != null) { setForegroundServiceAllowance( record, playbackState.shouldAllowServiceToRunInForeground()); record, /* allowRunningInForeground= */ playbackState.isActive() && record.isActive()); } } } Loading