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

Commit e2f18f23 authored by android-build-team Robot's avatar android-build-team Robot
Browse files

Snap for 7318334 from 2cb4dcb6 to sc-release

Change-Id: Ia2183994192255be4b73b1f95da4d8d16f95101d
parents 7c92182f 2cb4dcb6
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -97,8 +97,8 @@ public class SearchFragment extends Fragment {
    }

    @Override
    public void onActivityCreated(@Nullable Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
    public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);

        final BaseActivity activity = (BaseActivity) getActivity();
        final Injector injector = activity.getInjector();
+0 −2
Original line number Diff line number Diff line
@@ -333,8 +333,6 @@ public class SearchViewManager implements
    public boolean cancelSearch() {
        if (mSearchView != null && (isExpanded() || isSearching())) {
            cancelQueuedSearch();
            // If the query string is not empty search view won't get iconified
            mSearchView.setQuery("", false);

            if (mFullBar) {
                onClose();
+20 −13
Original line number Diff line number Diff line
@@ -62,6 +62,7 @@ import com.android.documentsui.base.UserId;

import com.google.common.collect.ArrayListMultimap;
import com.google.common.collect.Multimap;
import com.google.common.util.concurrent.MoreExecutors;

import java.util.ArrayList;
import java.util.Collection;
@@ -72,7 +73,10 @@ import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Semaphore;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import java.util.function.Function;

@@ -498,6 +502,11 @@ public class ProvidersCache implements ProvidersAccess, LookupApplicationName {
        @Nullable
        private final Runnable mCallback;

        @GuardedBy("mLock")
        private Multimap<UserAuthority, RootInfo> mLocalRoots = ArrayListMultimap.create();
        @GuardedBy("mLock")
        private HashSet<UserAuthority> mLocalStoppedAuthorities = new HashSet<>();

        /**
         * Create task to update roots cache.
         *
@@ -526,17 +535,12 @@ public class ProvidersCache implements ProvidersAccess, LookupApplicationName {
            int previousPriority = Thread.currentThread().getPriority();
            Thread.currentThread().setPriority(Thread.MAX_PRIORITY);

            synchronized (mLock) {
                mRoots.clear();
                mStoppedAuthorities.clear();
            }

            final long start = SystemClock.elapsedRealtime();

            for (UserId userId : mUserIdManager.getUserIds()) {
                final RootInfo recents = createOrGetRecentsRoot(userId);
                synchronized (mLock) {
                    mRoots.put(new UserAuthority(recents.userId, recents.authority), recents);
                    mLocalRoots.put(new UserAuthority(recents.userId, recents.authority), recents);
                }
            }

@@ -556,12 +560,14 @@ public class ProvidersCache implements ProvidersAccess, LookupApplicationName {

            if (!taskInfos.isEmpty()) {
                CountDownLatch updateTaskInternalCountDown = new CountDownLatch(taskInfos.size());
                ExecutorService executor = MoreExecutors.getExitingExecutorService(
                        (ThreadPoolExecutor) Executors.newCachedThreadPool());
                for (SingleProviderUpdateTaskInfo taskInfo: taskInfos) {
                    new Thread(() ->
                    executor.submit(() ->
                            startSingleProviderUpdateTask(
                                    taskInfo.providerInfo,
                                    taskInfo.userId,
                                    updateTaskInternalCountDown)).start();
                                    updateTaskInternalCountDown));
                }

                // Block until all SingleProviderUpdateTask threads finish executing.
@@ -578,17 +584,17 @@ public class ProvidersCache implements ProvidersAccess, LookupApplicationName {
            }

            final long delta = SystemClock.elapsedRealtime() - start;
            int rootsCount = 0;
            synchronized (mLock) {
                rootsCount = mRoots.size();
                mFirstLoadDone = true;
                if (mBootCompletedResult != null) {
                    mBootCompletedResult.finish();
                    mBootCompletedResult = null;
                }
                mRoots = mLocalRoots;
                mStoppedAuthorities = mLocalStoppedAuthorities;
            }
            if (VERBOSE) {
                Log.v(TAG, "Update found " + rootsCount + " roots in " + delta + "ms");
                Log.v(TAG, "Update found " + mLocalRoots.size() + " roots in " + delta + "ms");
            }

            mFirstLoad.countDown();
@@ -626,7 +632,7 @@ public class ProvidersCache implements ProvidersAccess, LookupApplicationName {
                    Log.v(TAG, "Ignoring stopped authority " + info.authority + ", user " + userId);
                }
                synchronized (mLock) {
                    mStoppedAuthorities.add(userAuthority);
                    mLocalStoppedAuthorities.add(userAuthority);
                }
                return;
            }
@@ -635,7 +641,8 @@ public class ProvidersCache implements ProvidersAccess, LookupApplicationName {
                    || Objects.equals(
                    new UserPackage(userId, info.packageName), mForceRefreshUserPackage);
            synchronized (mLock) {
                mRoots.putAll(userAuthority, loadRootsForAuthority(userAuthority, forceRefresh));
                mLocalRoots.putAll(userAuthority,
                        loadRootsForAuthority(userAuthority, forceRefresh));
            }
        }
    }