diff options
-rw-r--r-- | src/com/android/documentsui/DocumentsApplication.java | 22 | ||||
-rw-r--r-- | src/com/android/documentsui/roots/ProvidersCache.java | 32 |
2 files changed, 7 insertions, 47 deletions
diff --git a/src/com/android/documentsui/DocumentsApplication.java b/src/com/android/documentsui/DocumentsApplication.java index 60fbdaf7c..c5be4149b 100644 --- a/src/com/android/documentsui/DocumentsApplication.java +++ b/src/com/android/documentsui/DocumentsApplication.java @@ -83,20 +83,7 @@ public class DocumentsApplication extends Application { private Lookup<String, String> mFileTypeLookup; public static ProvidersCache getProvidersCache(Context context) { - ProvidersCache providers = - ((DocumentsApplication) context.getApplicationContext()).mProviders; - final ConfigStore configStore = getConfigStore(); - // When private space in DocsUI is enabled then ProvidersCache should use UserManagerState - // else it should use UserIdManager. The following if-check will ensure the construction of - // a new ProvidersCache instance whenever there is a mismatch in this. - if (configStore.isPrivateSpaceInDocsUIEnabled() - != providers.isProvidersCacheUsingUserManagerState()) { - providers = configStore.isPrivateSpaceInDocsUIEnabled() - ? new ProvidersCache(context, getUserManagerState(context), configStore) - : new ProvidersCache(context, getUserIdManager(context), configStore); - ((DocumentsApplication) context.getApplicationContext()).mProviders = providers; - } - return providers; + return ((DocumentsApplication) context.getApplicationContext()).mProviders; } public static ThumbnailCache getThumbnailCache(Context context) { @@ -212,16 +199,11 @@ public class DocumentsApplication extends Application { if (getConfigStore().isPrivateSpaceInDocsUIEnabled()) { mUserManagerState = UserManagerState.create(this); mUserIdManager = null; - synchronized (DocumentsApplication.class) { - mProviders = new ProvidersCache(this, mUserManagerState, getConfigStore()); - } } else { mUserManagerState = null; mUserIdManager = UserIdManager.create(this); - synchronized (DocumentsApplication.class) { - mProviders = new ProvidersCache(this, mUserIdManager, getConfigStore()); - } } + mProviders = new ProvidersCache(this); mProviders.updateAsync(/* forceRefreshAll= */ false, /* callback= */ null); diff --git a/src/com/android/documentsui/roots/ProvidersCache.java b/src/com/android/documentsui/roots/ProvidersCache.java index 080b729c5..675058451 100644 --- a/src/com/android/documentsui/roots/ProvidersCache.java +++ b/src/com/android/documentsui/roots/ProvidersCache.java @@ -49,11 +49,8 @@ import androidx.annotation.GuardedBy; import androidx.annotation.Nullable; import androidx.localbroadcastmanager.content.LocalBroadcastManager; -import com.android.documentsui.ConfigStore; import com.android.documentsui.DocumentsApplication; import com.android.documentsui.R; -import com.android.documentsui.UserIdManager; -import com.android.documentsui.UserManagerState; import com.android.documentsui.UserPackage; import com.android.documentsui.archives.ArchivesProvider; import com.android.documentsui.base.LookupApplicationName; @@ -123,27 +120,8 @@ public class ProvidersCache implements ProvidersAccess, LookupApplicationName { @GuardedBy("mObservedAuthoritiesDetails") private final Map<UserAuthority, PackageDetails> mObservedAuthoritiesDetails = new HashMap<>(); - private final UserIdManager mUserIdManager; - private final UserManagerState mUserManagerState; - private final ConfigStore mConfigStore; - - public ProvidersCache(Context context, UserIdManager userIdManager, ConfigStore configStore) { - mContext = context; - mUserIdManager = userIdManager; - mUserManagerState = null; - mConfigStore = configStore; - } - - public ProvidersCache(Context context, UserManagerState userManagerState, - ConfigStore configStore) { + public ProvidersCache(Context context) { mContext = context; - mUserIdManager = null; - mUserManagerState = userManagerState; - mConfigStore = configStore; - } - - public boolean isProvidersCacheUsingUserManagerState() { - return mUserManagerState != null; } /** @@ -220,7 +198,7 @@ public class ProvidersCache implements ProvidersAccess, LookupApplicationName { // For that reason we update our RecentsRoot to reflect // the current language. final String title = mContext.getString(R.string.root_recent); - List<UserId> userIds = getUserIds(); + List<UserId> userIds = new ArrayList<>(getUserIds()); for (UserId userId : userIds) { RootInfo recentRoot = createOrGetRecentsRoot(userId); recentRoot.title = title; @@ -727,9 +705,9 @@ public class ProvidersCache implements ProvidersAccess, LookupApplicationName { } private List<UserId> getUserIds() { - if (mConfigStore.isPrivateSpaceInDocsUIEnabled()) { - return mUserManagerState.getUserIds(); + if (DocumentsApplication.getConfigStore().isPrivateSpaceInDocsUIEnabled()) { + return DocumentsApplication.getUserManagerState(mContext).getUserIds(); } - return mUserIdManager.getUserIds(); + return DocumentsApplication.getUserIdManager(mContext).getUserIds(); } } |