BroadcastQueue: add support for priority tranches.
Both manifest and registered receivers can specify a "priority" in which they'd like to be delivered. This can be used to ensure that system components receieve a broadcast (and can update their internal state) before third-party apps receive that broadcast. The "default" stack handled this by dispatching all receivers in the order defined by ActivityManagerService, but the "modern" stack now needs to carefully only allow parallel dispatch within a specific tranche of consistent priority. (That is, we must finish dispatching all receivers with priority "10" before moving on to priority "9".) This change repurposes the logic we built for ordered broadcasts, where a process queue is "blocked" while waiting on a certain number of prior broadcasts to reach a terminal state. To avoid priority inversions (where a lower priority receiver would be blocked behind a higher priority receiver in a frozen state), we currently promote all receivers waiting on a "prioritized" broadcast to be immediately runnable. Bug: 245771249 Test: atest FrameworksMockingServicesTests:BroadcastQueueTest Test: atest FrameworksMockingServicesTests:BroadcastQueueModernImplTest Change-Id: Ic6ff9a959a262bd73ecd3d7977f400d10b81535d
Loading
Please register or sign in to comment