Fix locking issues.

* Synchronize access to unlocked user cache. The cache will be checked
for each API call. Add synchronization blocks when reading/writing to
it.
* Synchronize and remove double locking for access to static array of
AppSearchImpl instances.

Bug: 179406838
Test: atest -m -c --rebuild-module-info CtsAppSearchTestCases
FrameworksCoreTests: android.app.appsearch
FrameworksServicesTests: com.android.server.appsearch
Change-Id: Ibaf0d6ff07b4e2f15f3479ff56e143a34ce453e3
2 files changed