Closes file descriptor after loading ranking map

Closes file descriptor after loading ranking map from SharedMemory
object.

Bug: 249848655
Test: atest NotificationRankingUpdateTest, manual
flash+NotificationShellCmd to issue 500 notifications with reranking.

Change-Id: I66779f4eae5ff93cc6a90d3fd00b829ab3670cff
This commit is contained in:
Alexander Roederer
2023-08-17 13:59:51 +00:00
parent 23b05cd28b
commit a254049856
2 changed files with 6 additions and 1 deletions

View File

@@ -92,6 +92,7 @@ public class NotificationRankingUpdate implements Parcelable {
mapParcel.recycle();
if (buffer != null) {
mRankingMapFd.unmap(buffer);
mRankingMapFd.close();
}
}
} else {

View File

@@ -136,7 +136,11 @@ public class NotificationRankingUpdateTest {
NotificationListenerService.RankingMap retrievedRankings =
retrievedRankingUpdate.getRankingMap();
assertNotNull(retrievedRankings);
assertTrue(retrievedRankingUpdate.isFdNotNullAndClosed());
// The rankingUpdate file descriptor is only non-null in the new path.
if (SystemUiSystemPropertiesFlags.getResolver().isEnabled(
SystemUiSystemPropertiesFlags.NotificationFlags.RANKING_UPDATE_ASHMEM)) {
assertTrue(retrievedRankingUpdate.isFdNotNullAndClosed());
}
NotificationListenerService.Ranking retrievedRanking =
new NotificationListenerService.Ranking();
assertTrue(retrievedRankings.getRanking(TEST_KEY, retrievedRanking));