diff options
author | 2024-02-20 15:53:41 +0000 | |
---|---|---|
committer | 2024-02-20 15:53:41 +0000 | |
commit | f17902765f6d34d0e07d0836e8676358605d868f (patch) | |
tree | c4df28e27451a5d85da3417125c83ca308898dc5 | |
parent | 53c8e3a78556fce4a6871fa34d35bb77c2c8d1a0 (diff) | |
parent | 30ab48c3074d299197efe78f9d03337d18232bee (diff) |
Merge "Decouple Fgs logic from UsageStats reporting logic" into main
-rw-r--r-- | services/core/java/com/android/server/media/MediaSessionService.java | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/services/core/java/com/android/server/media/MediaSessionService.java b/services/core/java/com/android/server/media/MediaSessionService.java index 3e8af27d2584..e7e8096a1965 100644 --- a/services/core/java/com/android/server/media/MediaSessionService.java +++ b/services/core/java/com/android/server/media/MediaSessionService.java @@ -312,14 +312,15 @@ public class MediaSessionService extends SystemService implements Monitor { } user.mPriorityStack.onSessionActiveStateChanged(record); } - boolean allowRunningInForeground = record.isActive() - && (playbackState == null || playbackState.isActive()); + boolean isUserEngaged = + record.isActive() && (playbackState == null || playbackState.isActive()); Log.d(TAG, "onSessionActiveStateChanged: " + "record=" + record + "playbackState=" + playbackState - + "allowRunningInForeground=" + allowRunningInForeground); - setForegroundServiceAllowance(record, allowRunningInForeground); + + "allowRunningInForeground=" + isUserEngaged); + setForegroundServiceAllowance(record, /* allowRunningInForeground= */ isUserEngaged); + reportMediaInteractionEvent(record, isUserEngaged); mHandler.postSessionsChanged(record); } } @@ -417,12 +418,14 @@ public class MediaSessionService extends SystemService implements Monitor { } user.mPriorityStack.onPlaybackStateChanged(record, shouldUpdatePriority); if (playbackState != null) { - boolean allowRunningInForeground = playbackState.isActive() && record.isActive(); + boolean isUserEngaged = playbackState.isActive() && record.isActive(); Log.d(TAG, "onSessionPlaybackStateChanged: " + "record=" + record + "playbackState=" + playbackState - + "allowRunningInForeground=" + allowRunningInForeground); - setForegroundServiceAllowance(record, allowRunningInForeground); + + "allowRunningInForeground=" + isUserEngaged); + setForegroundServiceAllowance( + record, /* allowRunningInForeground= */ isUserEngaged); + reportMediaInteractionEvent(record, isUserEngaged); } } } @@ -590,6 +593,7 @@ public class MediaSessionService extends SystemService implements Monitor { Log.d(TAG, "destroySessionLocked: record=" + session); setForegroundServiceAllowance(session, /* allowRunningInForeground= */ false); + reportMediaInteractionEvent(session, /* userEngaged= */ false); mHandler.postSessionsChanged(session); } @@ -608,11 +612,9 @@ public class MediaSessionService extends SystemService implements Monitor { if (allowRunningInForeground) { mActivityManagerInternal.startForegroundServiceDelegate( foregroundServiceDelegationOptions, /* connection= */ null); - reportMediaInteractionEvent(record, /* userEngaged= */ true); } else { mActivityManagerInternal.stopForegroundServiceDelegate( foregroundServiceDelegationOptions); - reportMediaInteractionEvent(record, /* userEngaged= */ false); } } |