Fixing time delay on launch on flag change. am: c069989503
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/DocumentsUI/+/26391392
Change-Id: Iff60142daf36c00ebc8c32c9b37ba20b164a2781
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
diff --git a/src/com/android/documentsui/DocumentsApplication.java b/src/com/android/documentsui/DocumentsApplication.java
index 60fbdaf..c5be414 100644
--- a/src/com/android/documentsui/DocumentsApplication.java
+++ b/src/com/android/documentsui/DocumentsApplication.java
@@ -83,20 +83,7 @@
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 @@
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 080b729..6750584 100644
--- a/src/com/android/documentsui/roots/ProvidersCache.java
+++ b/src/com/android/documentsui/roots/ProvidersCache.java
@@ -49,11 +49,8 @@
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 @@
@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) {
+ public ProvidersCache(Context context) {
mContext = context;
- mUserIdManager = userIdManager;
- mUserManagerState = null;
- mConfigStore = configStore;
- }
-
- public ProvidersCache(Context context, UserManagerState userManagerState,
- ConfigStore configStore) {
- mContext = context;
- mUserIdManager = null;
- mUserManagerState = userManagerState;
- mConfigStore = configStore;
- }
-
- public boolean isProvidersCacheUsingUserManagerState() {
- return mUserManagerState != null;
}
/**
@@ -220,7 +198,7 @@
// 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 @@
}
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();
}
}