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

Commit a649f548 authored by Kelvin Kwan's avatar Kelvin Kwan
Browse files

Ensure user can only share documents from allowed users.

This is done by placing checking on various levels.

- On the UI level, we check in the loader (DirectoryLoader/Recents Loader).
- We also block querying document in DocumentsAccess
- And we will not return the uris if we are not allowed to access the target
user uri.

Need to follow up on some issues:
Breadcrumb bar disappeared in disabled user
(because we cannot load root document and push to the stack)
Cannot search if selected user is disabled (because of empty stack.
We cannot restart loader in loadDocumentsForCurrentStack)

Bug: 149818298
Bug: 148270816
Test: atest DocumentsUIGoogleTests
Test: manual

Change-Id: I000813d3e66a8c376dbfbd7e4085f403c2e5e0f6
parent 4505a178
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -201,6 +201,9 @@
    <!-- Toast shown when user want to share files amount over limit [CHAR LIMIT=60] -->
    <string name="toast_share_over_limit">Can\u2019t share more than <xliff:g id="count" example="1">%1$d</xliff:g> files</string>

    <!-- Toast shown when a document is not allowed to share across users. This is a last-resort toast and not expected to be shown. [CHAR LIMIT=48] -->
    <string name="toast_action_not_allowed">Action not allowed</string>

    <!-- Title of dialog when prompting user to select an app to share documents with [CHAR LIMIT=32] -->
    <string name="share_via">Share via</string>

+3 −1
Original line number Diff line number Diff line
@@ -89,6 +89,7 @@ public abstract class AbstractActionHandler<T extends FragmentActivity & CommonA
    @VisibleForTesting
    public static final int CODE_FORWARD = 42;
    public static final int CODE_AUTHENTICATION = 43;
    public static final int CODE_FORWARD_CROSS_PROFILE = 44;

    @VisibleForTesting
    static final int LOADER_ID = 42;
@@ -259,7 +260,7 @@ public abstract class AbstractActionHandler<T extends FragmentActivity & CommonA
    }

    @Override
    public void openRoot(ResolveInfo app) {
    public void openRoot(ResolveInfo app, UserId userId) {
        throw new UnsupportedOperationException("Can't open an app.");
    }

@@ -758,6 +759,7 @@ public abstract class AbstractActionHandler<T extends FragmentActivity & CommonA
    public void loadDocumentsForCurrentStack() {
        DocumentStack stack = mState.stack;
        if (!stack.isRecents() && stack.isEmpty()) {
            // TODO: we may also need to reload cross-profile supported root with empty stack
            DirectoryResult result = new DirectoryResult();

            // TODO (b/35996595): Consider plumbing through the actual exception, though it might
+1 −1
Original line number Diff line number Diff line
@@ -93,7 +93,7 @@ public interface ActionHandler {

    void openRoot(RootInfo root);

    void openRoot(ResolveInfo app);
    void openRoot(ResolveInfo app, UserId userId);

    void loadRoot(Uri uri, UserId userId);

+1 −1
Original line number Diff line number Diff line
@@ -154,7 +154,7 @@ public abstract class BaseActivity
        Metrics.logActivityLaunch(mState, intent);

        mProviders = DocumentsApplication.getProvidersCache(this);
        mDocs = DocumentsAccess.create(this);
        mDocs = DocumentsAccess.create(this, mState);

        Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
        setSupportActionBar(toolbar);
+23 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2020 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.android.documentsui;

/**
 * Represents an exception related to cross profile.
 */
public abstract class CrossProfileException extends Exception {
}
Loading