MediaSessionService: Prevent getActiveSessions() from growing infinitely
Bug: 67358262 Change-Id: I1c25a456ff4f2b16fee3098ac8f14d2899fb1ca5 Test: Run CtsMediaHostTest
This commit is contained in:
@@ -205,9 +205,8 @@ public class MediaSessionService extends SystemService implements Monitor {
|
||||
}
|
||||
|
||||
private List<MediaSessionRecord> getActiveSessionsLocked(int userId) {
|
||||
List<MediaSessionRecord> records;
|
||||
List<MediaSessionRecord> records = new ArrayList<>();
|
||||
if (userId == UserHandle.USER_ALL) {
|
||||
records = new ArrayList<>();
|
||||
int size = mUserRecords.size();
|
||||
for (int i = 0; i < size; i++) {
|
||||
records.addAll(mUserRecords.valueAt(i).mPriorityStack.getActiveSessions(userId));
|
||||
@@ -216,9 +215,9 @@ public class MediaSessionService extends SystemService implements Monitor {
|
||||
FullUserRecord user = getFullUserRecordLocked(userId);
|
||||
if (user == null) {
|
||||
Log.w(TAG, "getSessions failed. Unknown user " + userId);
|
||||
return new ArrayList<>();
|
||||
return records;
|
||||
}
|
||||
records = user.mPriorityStack.getActiveSessions(userId);
|
||||
records.addAll(user.mPriorityStack.getActiveSessions(userId));
|
||||
}
|
||||
|
||||
// Return global priority session at the first whenever it's asked.
|
||||
|
||||
Reference in New Issue
Block a user