Make onMediaStoreReady() return early when already called

MediaDocumentsProvider.onMediaStoreReady() can be called multiple times
on boot, and currently it always calls notifyRootsChanged().

In ARC, DocumentsUI's ProvidersCache is already observing
DocumentsProvider root changes when onMediaStoreReady() is called, as
DocumentsUI is started on BOOT_COMPLETED. Hence, ProvidersCache calls
MediaDocumentsProvider.queryRoots() multiple times on ARC boot, which
seems to be causing ANRs in some cases. To avoid it, this CL makes
onMediaStoreReady() not to call notifyRootsChanged() if
onMediaStoreReady() has been called already.

This CL also removes an unnecessary import caught by pre-upload check.

Bug: 342068340
Test: On ARC, check that MediaDocumentsProvider.queryRoots() with
  sMediaStoreReady=true is called only once on boot.

Change-Id: If3eb0bfc16ef4bbd3287c23a826175df834e48f7
1 file changed