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

Commit 5f863bee authored by Tony Huang's avatar Tony Huang
Browse files

Only restrict scope storage if caller target sdk is above R

Bug: 144816835
Test: manaul
Test: atest DocumentsUIGoogleTests
Change-Id: Ida19109d335f449b547ed74b869e45237dd8cc48
parent d43fb2b9
Loading
Loading
Loading
Loading
+1 −0
Original line number Original line Diff line number Diff line
@@ -364,6 +364,7 @@ public abstract class BaseActivity
        state.sortModel = SortModel.createModel();
        state.sortModel = SortModel.createModel();
        state.localOnly = intent.getBooleanExtra(Intent.EXTRA_LOCAL_ONLY, false);
        state.localOnly = intent.getBooleanExtra(Intent.EXTRA_LOCAL_ONLY, false);
        state.excludedAuthorities = getExcludedAuthorities();
        state.excludedAuthorities = getExcludedAuthorities();
        state.restrictScopeStorage = Shared.shouldRestrictStorageAccessFramework(this);


        includeState(state);
        includeState(state);


+4 −0
Original line number Original line Diff line number Diff line
@@ -83,6 +83,7 @@ public class State implements android.os.Parcelable {
    public boolean localOnly;
    public boolean localOnly;


    public boolean openableOnly;
    public boolean openableOnly;
    public boolean restrictScopeStorage;


    /**
    /**
     * Represents whether the intent is a cross-profile intent
     * Represents whether the intent is a cross-profile intent
@@ -171,6 +172,7 @@ public class State implements android.os.Parcelable {
        out.writeMap(dirConfigs);
        out.writeMap(dirConfigs);
        out.writeList(excludedAuthorities);
        out.writeList(excludedAuthorities);
        out.writeInt(openableOnly ? 1 : 0);
        out.writeInt(openableOnly ? 1 : 0);
        out.writeInt(restrictScopeStorage ? 1 : 0);
        out.writeParcelable(sortModel, 0);
        out.writeParcelable(sortModel, 0);
    }
    }


@@ -185,6 +187,7 @@ public class State implements android.os.Parcelable {
                + ", dirConfigs=" + dirConfigs
                + ", dirConfigs=" + dirConfigs
                + ", excludedAuthorities=" + excludedAuthorities
                + ", excludedAuthorities=" + excludedAuthorities
                + ", openableOnly=" + openableOnly
                + ", openableOnly=" + openableOnly
                + ", restrictScopeStorage=" + restrictScopeStorage
                + ", sortModel=" + sortModel
                + ", sortModel=" + sortModel
                + "}";
                + "}";
    }
    }
@@ -206,6 +209,7 @@ public class State implements android.os.Parcelable {
            in.readMap(state.dirConfigs, loader);
            in.readMap(state.dirConfigs, loader);
            in.readList(state.excludedAuthorities, loader);
            in.readList(state.excludedAuthorities, loader);
            state.openableOnly = in.readInt() != 0;
            state.openableOnly = in.readInt() != 0;
            state.restrictScopeStorage = in.readInt() != 0;
            state.sortModel = in.readParcelable(loader);
            state.sortModel = in.readParcelable(loader);
            return state;
            return state;
        }
        }
+2 −1
Original line number Original line Diff line number Diff line
@@ -130,7 +130,8 @@ abstract class Message {
                update(null, mEnv.getModel().info, null,
                update(null, mEnv.getModel().info, null,
                        mEnv.getContext().getDrawable(R.drawable.ic_dialog_info));
                        mEnv.getContext().getDrawable(R.drawable.ic_dialog_info));
            } else if (mEnv.getDisplayState().action == State.ACTION_OPEN_TREE
            } else if (mEnv.getDisplayState().action == State.ACTION_OPEN_TREE
                    && mEnv.getDisplayState().stack.peek().isBlockedFromTree()) {
                    && mEnv.getDisplayState().stack.peek().isBlockedFromTree()
                    && mEnv.getDisplayState().restrictScopeStorage) {
                updateBlockFromTreeMessage();
                updateBlockFromTreeMessage();
            }
            }
        }
        }
+2 −1
Original line number Original line Diff line number Diff line
@@ -355,7 +355,8 @@ public class PickActivity extends BaseActivity implements ActionHandler.Addons {
            mState.action == ACTION_PICK_COPY_DESTINATION) {
            mState.action == ACTION_PICK_COPY_DESTINATION) {
            final PickFragment pick = PickFragment.get(fm);
            final PickFragment pick = PickFragment.get(fm);
            if (pick != null) {
            if (pick != null) {
                pick.setPickTarget(mState.action, mState.copyOperationSubType, cwd);
                pick.setPickTarget(mState.action,
                        mState.copyOperationSubType, mState.restrictScopeStorage, cwd);
            }
            }
        }
        }
    }
    }
+5 −3
Original line number Original line Diff line number Diff line
@@ -71,6 +71,7 @@ public class PickFragment extends Fragment {


    private Injector<ActionHandler<PickActivity>> mInjector;
    private Injector<ActionHandler<PickActivity>> mInjector;
    private int mAction;
    private int mAction;
    private boolean mRestrictScopeStorage;
    // Only legal values are OPERATION_COPY, OPERATION_COMPRESS, OPERATION_EXTRACT,
    // Only legal values are OPERATION_COPY, OPERATION_COMPRESS, OPERATION_EXTRACT,
    // OPERATION_MOVE, and unset (OPERATION_UNKNOWN).
    // OPERATION_MOVE, and unset (OPERATION_UNKNOWN).
    private @OpType int mCopyOperationSubType = OPERATION_UNKNOWN;
    private @OpType int mCopyOperationSubType = OPERATION_UNKNOWN;
@@ -136,12 +137,13 @@ public class PickFragment extends Fragment {
    /**
    /**
     * @param action Which action defined in State is the picker shown for.
     * @param action Which action defined in State is the picker shown for.
     */
     */
    public void setPickTarget(
    public void setPickTarget(int action, @OpType int copyOperationSubType,
            int action, @OpType int copyOperationSubType, DocumentInfo pickTarget) {
            boolean restrictScopeStorage, DocumentInfo pickTarget) {
        assert(copyOperationSubType != OPERATION_DELETE);
        assert(copyOperationSubType != OPERATION_DELETE);


        mAction = action;
        mAction = action;
        mCopyOperationSubType = copyOperationSubType;
        mCopyOperationSubType = copyOperationSubType;
        mRestrictScopeStorage = restrictScopeStorage;
        mPickTarget = pickTarget;
        mPickTarget = pickTarget;
        if (mContainer != null) {
        if (mContainer != null) {
            updateView();
            updateView();
@@ -166,7 +168,7 @@ public class PickFragment extends Fragment {
                mPick.setText(getString(R.string.open_tree_button));
                mPick.setText(getString(R.string.open_tree_button));
                mPick.setWidth(Integer.MAX_VALUE);
                mPick.setWidth(Integer.MAX_VALUE);
                mCancel.setVisibility(View.GONE);
                mCancel.setVisibility(View.GONE);
                mPick.setEnabled(!mPickTarget.isBlockedFromTree());
                mPick.setEnabled(!(mPickTarget.isBlockedFromTree() && mRestrictScopeStorage));
                break;
                break;
            case State.ACTION_PICK_COPY_DESTINATION:
            case State.ACTION_PICK_COPY_DESTINATION:
                int titleId;
                int titleId;
Loading