Make unregister receiver "sync".

Before this CL, unregistering a receiver was done asynchronously in
BroadcastDispatcher. This meant that after a call to unregisterReceiver,
there was a period of time in which broadcasts may still be dispatched
for that receiver.

After this change, we mark receivers as pending removal, blocking any
received broadcast to be dispatched while its being removed.

Also, remove the double posting to the same handler thread. Instead, we
use the fact that we know that UserBroadcastDispatcher will only be
called from BroadcastDispatcher in the background thread to prevent
re-posting.

Fixes: 193941146
Test: atest SystemUITests
Test: everything seems to be working fine
Change-Id: I345f4d7ad918381188d553bd2b89643d11ae3d6c
9 files changed