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

Commit e0507534 authored by Takamasa Kuramitsu's avatar Takamasa Kuramitsu
Browse files

Fix duplicated roots are shown

Symptom:
Duplicated roots are shown in the drawer of DocumentsUI

Root cause:
ArrayListMultimap that allows duplicate key-value pairs is used for
mRoots. If the specific roots info are re-loaded with getRootOneshot(),
the duplicate roots info are put in mRoots and results in duplicated
roots are shown.

Solution:
Use replaceValues() instead of putAll() when re-loading roots for the
specific authority.

Bug: 73470276
Test: Manual
Test: Run instrumentation tests from com.android.documentsui.tests
Change-Id: Ia3f53fe2e5c36aa13f2cd6e0d5e39cec05aa4b28
parent 960a2186
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -210,7 +210,7 @@ public class ProvidersCache implements ProvidersAccess {
        final ContentResolver resolver = mContext.getContentResolver();
        synchronized (mLock) {
            for (String authority : mStoppedAuthorities) {
                mRoots.putAll(authority, loadRootsForAuthority(resolver, authority, true));
                mRoots.replaceValues(authority, loadRootsForAuthority(resolver, authority, true));
            }
            mStoppedAuthorities.clear();
        }
@@ -227,7 +227,7 @@ public class ProvidersCache implements ProvidersAccess {
                return;
            }
            if (DEBUG) Log.d(TAG, "Loading stopped authority " + authority);
            mRoots.putAll(authority, loadRootsForAuthority(resolver, authority, true));
            mRoots.replaceValues(authority, loadRootsForAuthority(resolver, authority, true));
            mStoppedAuthorities.remove(authority);
        }
    }
@@ -334,7 +334,7 @@ public class ProvidersCache implements ProvidersAccess {
        synchronized (mLock) {
            RootInfo root = forceRefresh ? null : getRootLocked(authority, rootId);
            if (root == null) {
                mRoots.putAll(authority, loadRootsForAuthority(
                mRoots.replaceValues(authority, loadRootsForAuthority(
                                mContext.getContentResolver(), authority, forceRefresh));
                root = getRootLocked(authority, rootId);
            }