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

Commit 863b66e9 authored by Aditya's avatar Aditya Committed by Automerger Merge Worker
Browse files

Fixing bugs related to pausing of private space. am: e8cc1dbb

parents 9db7cc59 e8cc1dbb
Loading
Loading
Loading
Loading
+27 −10
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) {
@@ -345,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);
            }
        });

@@ -397,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);
@@ -902,10 +923,6 @@ public abstract class BaseActivity
        }
    }

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

    @Override
    public DocumentInfo getCurrentDirectory() {
        return mState.stack.peek();
+4 −2
Original line number Diff line number Diff line
@@ -262,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.
                // 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