Fix config store in media application in test process
A couple of tests in MediaProviderTest.java are creating instances of
MediaProvider without overriding its provideConfigStore method. Due to
this, these tests were setting onConfigChange listeners in various
classes for ConfigStoreImpl. These listeners were retained even after
these tests since these new MediaProvider instances were attached to a
static Isolated Context in this test class and never cleared.
This was an old change but the tests were passing until now because no
tests were changing the device config and hence the onConfigChange
listeners were never invoked. The newly added SettingsUiTest makes a
config change hence invoking the listeners and crashing the process due
to a Security exception in the listener executor methods.
With this change, we have ensured that ConfigStoreImpl never gets
constructed in the Test process. We have also ensured that the isolated
context is reset before each test in MediaProviderTest.
Test: atest MediaProviderTests
Bug: 337091524
Change-Id: Id0c2fb5202abee3ca7558cb563c140de71d07a76
3 files changed