Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Skip to content
Commit 4b230198 authored by Matías Hernández's avatar Matías Hernández
Browse files

Lock state of NotificationComparator while sorting in RankingHelper

When the default dialer or default SMS package is changed, the NotificationComparator and NotificationMessagingUtil update their cached copy of this value, which is used to evaluate isImportantOngoing and isImportantMessaging (two of the criteria involved in the comparison). However, if this is changed _while a sort() is ongoing_, then the results of element comparison could potentially be inconsistent whenever notifications posted by the new or previous package are involved. In the worst case this could result in a system crash ("IllegalArgumentException: Comparison method violates its general contract!").

This CL introduces a lock object in NotificationComparator that should be acquired and held for the full duration of the sort. Default package changes that arrive within this time will be processed afterwards.

Fixes: 293249306
Test: atest NotificationComparatorTest -- testChangeDialerPackageWhileSorting() crashes without the synchronized block around records.sort(comparator).
Change-Id: I67251437ae827c39b135f5d45cfe682aa852d09a
parent 701e4404
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment