Refactored to ensure thread safety

clearServiceWatcher() called on the main thread but resetStaticState()
called on the instrumentation thread. Refactored the code to ensure
thread safety.

Fixes: 166685544
Test: atest ContentCapturePerfTests
Change-Id: I9adced9e068112c43554b495bd6dc591f8775945
1 file changed