Add warnings for leaked receivers in tests
This CL adds a way to track BroadcastReceivers that are leaking in test
cases that use SysuiTestCase (all of SystemUITests). Every receiver that
is registered with Context is recorded and those that are not
unregistered are logged as a Warning. After each test, receivers are
unregistered so they don't polute following tests.
Additionally, if a BroadcastDispatcher is instantiated, a Fake is
provided that will also track leaked receivers and log them as Info (as
BroadcastDispatcher will only keep WeakReferences).
This is a separate tracker done directly in SysuiTestableContext instead
of using LeakCheckedTest or a LeakChecker as that is usually pretty
stringent (it will fail the test).
Test: SystemUITests
Bug: 151614195
Change-Id: I11afb49ce3bbc51d98fa069ba4074c852d07bcce
4 files changed