Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9db7cc59 authored by Aditya's avatar Aditya Committed by Automerger Merge Worker
Browse files

Fixing time delay on launch on flag change. am: c0699895

parents 7a26faa3 c0699895
Loading
Loading
Loading
Loading
+2 −20
Original line number Diff line number Diff line
@@ -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);

+5 −27
Original line number Diff line number Diff line
@@ -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();
    }
}