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

Commit 3694f83b authored by Android Build Coastguard Worker's avatar Android Build Coastguard Worker
Browse files

Snap for 11522042 from 863b66e9 to 24Q2-release

Change-Id: I6ad9e4e9e720a678a9e2abc344bb7bc7f35f071c
parents 610e31c3 863b66e9
Loading
Loading
Loading
Loading
+34 −11
Original line number Diff line number Diff line
@@ -54,6 +54,7 @@ import com.android.documentsui.AbstractActionHandler.CommonAddons;
import com.android.documentsui.Injector.Injected;
import com.android.documentsui.NavigationViewManager.Breadcrumb;
import com.android.documentsui.base.DocumentInfo;
import com.android.documentsui.base.DocumentStack;
import com.android.documentsui.base.EventHandler;
import com.android.documentsui.base.RootInfo;
import com.android.documentsui.base.Shared;
@@ -87,6 +88,7 @@ public abstract class BaseActivity
        extends AppCompatActivity implements CommonAddons, NavigationViewManager.Environment {

    private static final String BENCHMARK_TESTING_PACKAGE = "com.android.documentsui.appperftests";
    private static final String TAG = "BaseActivity";

    protected SearchViewManager mSearchManager;
    protected AppsRowManager mAppsRowManager;
@@ -118,10 +120,25 @@ public abstract class BaseActivity

    private PreferencesMonitor mPreferencesMonitor;

    private boolean mHasProfileBecomeUnavailable = false;
    private final DocumentStack mInitialStack = new DocumentStack();
    private UserId mLastSelectedUser = null;

    public void setHasProfileBecomeUnavailable(boolean hasProfileBecomeUnavailable) {
        mHasProfileBecomeUnavailable = hasProfileBecomeUnavailable;
    protected void setInitialStack(DocumentStack stack) {
        if (mInitialStack.isInitialized()) {
            if (DEBUG) {
                Log.d(TAG, "Initial stack already initialised. " + mInitialStack.isInitialized());
            }
            return;
        }
        mInitialStack.reset(stack);
    }

    public DocumentStack getInitialStack() {
        return mInitialStack;
    }

    public UserId getLastSelectedUser() {
        return mLastSelectedUser;
    }

    public BaseActivity(@LayoutRes int layoutId, String tag) {
@@ -140,7 +157,7 @@ public abstract class BaseActivity

    @VisibleForTesting
    protected void initConfigStore() {
        mConfigStore = DocumentsApplication.getConfigStore(this);
        mConfigStore = DocumentsApplication.getConfigStore();
    }

    @VisibleForTesting
@@ -287,6 +304,12 @@ public abstract class BaseActivity

        mUserIdManager = DocumentsApplication.getUserIdManager(this);
        mUserManagerState = DocumentsApplication.getUserManagerState(this);
        // If private space feature flag is enabled, we should store the intent that launched docsUi
        // so that we can use this intent to get CrossProfileResolveInfo when ever we want to,
        // for example when ACTION_PROFILE_AVAILABLE intent is received
        if (mUserManagerState != null) {
            mUserManagerState.setCurrentStateIntent(intent);
        }
        mSearchManager = new SearchViewManager(searchListener, queryInterceptor,
                chipGroup, savedInstanceState);
        // initialize the chip sets by accept mime types
@@ -339,9 +362,7 @@ public abstract class BaseActivity
                // When a profile with user property SHOW_IN_QUIET_MODE_HIDDEN is currently
                // selected, and it becomes unavailable, we reset the roots to recents.
                // We do not reset it to recents when pick activity is due to ACTION_CREATE_DOCUMENT
                mInjector.actions.loadCrossProfileRoot(
                        (mHasProfileBecomeUnavailable && mState.action != State.ACTION_CREATE)
                                ? getRecentsRoot() : getCurrentRoot(), userId);
                mInjector.actions.loadCrossProfileRoot(getCurrentRoot(), userId);
            }
        });

@@ -391,6 +412,12 @@ public abstract class BaseActivity
        mRootsMonitor.start();
    }

    @Override
    protected void onPause() {
        super.onPause();
        mLastSelectedUser = getSelectedUser();
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        boolean showMenu = super.onCreateOptionsMenu(menu);
@@ -896,10 +923,6 @@ public abstract class BaseActivity
        }
    }

    public RootInfo getRecentsRoot() {
        return mProviders.generateRecentsRoot(getSelectedUser());
    }

    @Override
    public DocumentInfo getCurrentDirectory() {
        return mState.stack.peek();
+10 −34
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(context);
        // 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) {
@@ -140,7 +127,7 @@ public class DocumentsApplication extends Application {
    public static UserManagerState getUserManagerState(Context context) {
        UserManagerState userManagerState =
                ((DocumentsApplication) context.getApplicationContext()).mUserManagerState;
        if (userManagerState == null && getConfigStore(context).isPrivateSpaceInDocsUIEnabled()) {
        if (userManagerState == null && getConfigStore().isPrivateSpaceInDocsUIEnabled()) {
            userManagerState = UserManagerState.create(context);
            ((DocumentsApplication) context.getApplicationContext()).mUserManagerState =
                    userManagerState;
@@ -159,21 +146,13 @@ public class DocumentsApplication extends Application {
    /**
     * Retrieve {@link ConfigStore} instance to access feature flags in production code.
     */
    public static synchronized ConfigStore getConfigStore(Context context) {
    public static synchronized ConfigStore getConfigStore() {
        if (sConfigStore == null) {
            sConfigStore = new ConfigStore.ConfigStoreImpl();
        }
        return sConfigStore;
    }

    /**
     * Set {@link #mProviders} as null onDestroy of BaseActivity so that new session uses new
     * instance of {@link #mProviders}
     */
    public static void invalidateProvidersCache(Context context) {
        ((DocumentsApplication) context.getApplicationContext()).mProviders = null;
    }

    /**
     * Set {@link #mUserManagerState} as null onDestroy of BaseActivity so that new session uses new
     * instance of {@link #mUserManagerState}
@@ -217,19 +196,14 @@ public class DocumentsApplication extends Application {
            Log.w(TAG, "Can't obtain OverlayManager from System Service!");
        }

        if (getConfigStore(this).isPrivateSpaceInDocsUIEnabled()) {
        if (getConfigStore().isPrivateSpaceInDocsUIEnabled()) {
            mUserManagerState = UserManagerState.create(this);
            mUserIdManager = null;
            synchronized (DocumentsApplication.class) {
                mProviders = new ProvidersCache(this, mUserManagerState, getConfigStore(this));
            }
        } else {
            mUserManagerState = null;
            mUserIdManager = UserIdManager.create(this);
            synchronized (DocumentsApplication.class) {
                mProviders = new ProvidersCache(this, mUserIdManager, getConfigStore(this));
            }
        }
        mProviders = new ProvidersCache(this);

        mProviders.updateAsync(/* forceRefreshAll= */ false, /* callback= */  null);

@@ -288,13 +262,15 @@ public class DocumentsApplication extends Application {
                final String packageName = data.getSchemeSpecificPart();
                mProviders.updatePackageAsync(UserId.DEFAULT_USER, packageName);
            } else if (PROFILE_FILTER_ACTIONS.contains(action)) {
                // After we have reloaded roots. Resend the broadcast locally so the other
                // components can reload properly after roots are updated.
                if (getConfigStore(context).isPrivateSpaceInDocsUIEnabled()) {
                // Make the changes to UserManagerState object before calling providers updateAsync
                // so that providers for all the users are loaded
                if (getConfigStore().isPrivateSpaceInDocsUIEnabled()) {
                    UserHandle userHandle = intent.getParcelableExtra(Intent.EXTRA_USER);
                    UserId userId = UserId.of(userHandle);
                    getUserManagerState(context).onProfileActionStatusChange(action, userId);
                }
                // After we have reloaded roots. Resend the broadcast locally so the other
                // components can reload properly after roots are updated.
                mProviders.updateAsync(/* forceRefreshAll= */ true,
                        () -> LocalBroadcastManager.getInstance(context).sendBroadcast(intent));
            } else {
+3 −3
Original line number Diff line number Diff line
@@ -59,7 +59,7 @@ import java.util.concurrent.Executor;
import java.util.concurrent.Semaphore;
import java.util.concurrent.TimeUnit;

/*
/**
 * The abstract class to query multiple roots from {@link android.provider.DocumentsProvider}
 * and return the combined result.
 */
@@ -88,7 +88,7 @@ public abstract class MultiRootDocumentsLoader extends AsyncTaskLoader<Directory
    private LockingContentObserver mObserver;

    @GuardedBy("mTasks")
    /** A authority -> QueryTask map */
    /* A authority -> QueryTask map */
    private final Map<String, QueryTask> mTasks = new HashMap<>();

    private CountDownLatch mFirstPassLatch;
@@ -96,7 +96,7 @@ public abstract class MultiRootDocumentsLoader extends AsyncTaskLoader<Directory

    private DirectoryResult mResult;

    /*
    /**
     * Create the loader to query roots from {@link android.provider.DocumentsProvider}.
     *
     * @param context the context
+2 −1
Original line number Diff line number Diff line
@@ -71,7 +71,8 @@ public class NavigationViewManager implements AppBarLayout.OnOffsetChangedListen
    private final ConfigStore mConfigStore;

    private boolean mIsActionModeActivated = false;
    private @ColorRes int mDefaultStatusBarColorResId;
    @ColorRes
    private int mDefaultStatusBarColorResId;

    public NavigationViewManager(
            BaseActivity activity,
+2 −7
Original line number Diff line number Diff line
@@ -128,14 +128,9 @@ public class ProfileTabs implements ProfileTabsAddons {
            // Update the layout according to the current root if necessary.
            // Make sure we do not invoke callback. Otherwise, it is likely to cause infinite loop.
            mTabs.removeOnTabSelectedListener(mOnTabSelectedListener);
            if (!mUserIds.contains(currentRoot.userId)) {
                mTabs.addOnTabSelectedListener(mOnTabSelectedListener);
                mTabs.selectTab(mTabs.getTabAt(mUserIds.indexOf(UserId.CURRENT_USER)));
            } else {
            mTabs.selectTab(mTabs.getTabAt(mUserIds.indexOf(currentRoot.userId)));
            mTabs.addOnTabSelectedListener(mOnTabSelectedListener);
        }
        }
        mTabsContainer.setVisibility(shouldShow() ? View.VISIBLE : View.GONE);

        // Material next changes apply only for version S or greater
Loading