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

Commit 416c788b authored by Android Build Coastguard Worker's avatar Android Build Coastguard Worker
Browse files

Snap for 13097162 from 3fd4aa0e to 25Q2-release

Change-Id: I6984e4d163265be105c008fa466edfc6d35b9399
parents b7ff0d5e 3fd4aa0e
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -40,6 +40,7 @@
            <FrameLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:paddingBottom="@dimen/file_area_padding_bottom"
                app:layout_behavior="@string/scrolling_behavior">

                <FrameLayout
+4 −0
Original line number Diff line number Diff line
@@ -23,6 +23,10 @@
    <dimen name="profile_tab_padding">0dp</dimen>
    <dimen name="grid_container_padding">20dp</dimen>
    <dimen name="list_container_padding">@dimen/space_extra_small_4</dimen>
    <!-- For compact screen, file area occupies the whole screen height, in M3 we show breadcrumb
         at the bottom, so we need to add padding (breadcrumb height) at the bottom to make sure
         breadcrumb won't over-shadow the file area. -->
    <dimen name="file_area_padding_bottom">48dp</dimen>
    <dimen name="icon_size">40dp</dimen>
    <dimen name="button_touch_size">48dp</dimen>
    <dimen name="root_icon_size">24dp</dimen>
+18 −16
Original line number Diff line number Diff line
@@ -137,30 +137,32 @@ class TrampolineActivity : AppCompatActivity() {
}

fun shouldForwardIntentToPhotopicker(intent: Intent): Boolean {
    if (intent.action != ACTION_GET_CONTENT || !isMediaMimeType(intent.type)) {
    // Photopicker can only handle `ACTION_GET_CONTENT` intents.
    if (intent.action != ACTION_GET_CONTENT) {
        return false
    }

    // Intent has type ACTION_GET_CONTENT and is either image/* or video/* with no
    // additional mime types.
    if (!intent.hasExtra(Intent.EXTRA_MIME_TYPES)) {
        return true
    // Photopicker only handles media mime types (i.e. image/* or video/*), however, it also handles
    // requests that have type */* with EXTRA_MIME_TYPES that are media mime types. In that scenario
    // it provides an escape hatch to the user to go back to DocumentsUI.
    val intentTypeIsMedia = isMediaMimeType(intent.type)
    if (!intentTypeIsMedia && intent.type != "*/*") {
        return false
    }

    val extraMimeTypes = intent.getStringArrayExtra(Intent.EXTRA_MIME_TYPES)
    extraMimeTypes?.let {
        if (it.size == 0) {
            return false
        }

        for (mimeType in it) {
            if (!isMediaMimeType(mimeType)) {
    // In the event there were no `EXTRA_MIME_TYPES` this should exclusively be handled by
    // DocumentsUI and not Photopicker.
    if (intent.type == "*/*" && extraMimeTypes == null) {
        return false
    }

    if (extraMimeTypes == null) {
        return intentTypeIsMedia
    }
    } ?: return false

    return true
    return extraMimeTypes.isNotEmpty() && extraMimeTypes.none { !isMediaMimeType(it) }
}

fun isMediaMimeType(mimeType: String?): Boolean {
+15 −3
Original line number Diff line number Diff line
@@ -47,11 +47,16 @@ import java.util.Objects
abstract class ActivityTestJunit4<T : Activity?> {
    @JvmField
    var bots: Bots? = null

    @JvmField
    var device: UiDevice? = null

    @JvmField
    var context: Context? = null
    var userId: UserId? = null
    var automation: UiAutomation? = null

    @JvmField
    var features: Features? = null

    /**
@@ -60,7 +65,12 @@ abstract class ActivityTestJunit4<T : Activity?> {
     * Override the method if you want to open different root on start.
     * @return Root that will be opened. Return null if you want to open activity's default root.
     */
    protected var initialRoot: RootInfo? = null
    protected open var initialRoot: RootInfo? = null

    @JvmField
    var rootDir0: RootInfo? = null

    @JvmField
    var rootDir1: RootInfo? = null
    protected var mResolver: ContentResolver? = null

@@ -83,8 +93,9 @@ abstract class ActivityTestJunit4<T : Activity?> {
     */
    @Throws(RemoteException::class)
    protected fun setupTestingRoots() {
        this.initialRoot = mDocsHelper!!.getRoot(StubProvider.ROOT_0_ID)
        rootDir0 = mDocsHelper!!.getRoot(StubProvider.ROOT_0_ID)
        rootDir1 = mDocsHelper!!.getRoot(StubProvider.ROOT_1_ID)
        this.initialRoot = rootDir0
    }

    @Throws(Exception::class)
@@ -154,7 +165,7 @@ abstract class ActivityTestJunit4<T : Activity?> {
    }

    @Throws(RemoteException::class)
    protected fun initTestFiles() {
    protected open fun initTestFiles() {
        mDocsHelper!!.createFolder(this.initialRoot, dirName1)
        mDocsHelper!!.createDocument(this.initialRoot, "text/plain", fileName1)
        mDocsHelper!!.createDocument(this.initialRoot, "image/png", fileName2)
@@ -201,6 +212,7 @@ abstract class ActivityTestJunit4<T : Activity?> {
    companion object {
        // Testing files. For custom ones, override initTestFiles().
        const val dirName1 = "Dir1"
        const val childDir1 = "ChildDir1"
        const val fileName1 = "file1.log"
        const val fileName2 = "file12.png"
        const val fileName3 = "anotherFile0.log"
+56 −6
Original line number Diff line number Diff line
@@ -18,24 +18,46 @@ package com.android.documentsui;

import static com.android.documentsui.StubProvider.ROOT_0_ID;
import static com.android.documentsui.StubProvider.ROOT_1_ID;
import static com.android.documentsui.flags.Flags.FLAG_HIDE_ROOTS_ON_DESKTOP;

import android.os.RemoteException;
import android.content.pm.PackageManager;
import android.platform.test.annotations.RequiresFlagsDisabled;
import android.platform.test.annotations.RequiresFlagsEnabled;
import android.platform.test.flag.junit.CheckFlagsRule;
import android.platform.test.flag.junit.DeviceFlagsValueProvider;

import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.filters.LargeTest;

import com.android.documentsui.base.RootInfo;
import com.android.documentsui.files.FilesActivity;
import com.android.documentsui.filters.HugeLongTest;

import org.junit.After;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;

@LargeTest
public class FilesActivityDefaultsUiTest extends ActivityTest<FilesActivity> {
@RunWith(AndroidJUnit4.class)
public class FilesActivityDefaultsUiTest extends ActivityTestJunit4<FilesActivity> {

    @Rule
    public final CheckFlagsRule mCheckFlagsRule = DeviceFlagsValueProvider.createCheckFlagsRule();

    public FilesActivityDefaultsUiTest() {
        super(FilesActivity.class);
    @Before
    public void setUp() throws Exception {
        super.setUp();
    }

    @After
    public void tearDown() throws Exception {
        super.tearDown();
    }

    @Override
    protected void initTestFiles() throws RemoteException {
    protected void initTestFiles() {
        // Overriding to init with no items in test roots
    }

@@ -44,6 +66,7 @@ public class FilesActivityDefaultsUiTest extends ActivityTest<FilesActivity> {
        return null;  // test the default, unaffected state of the app.
    }

    @Test
    @HugeLongTest
    public void testNavigate_FromEmptyDirectory() throws Exception {
        device.waitForIdle();
@@ -57,8 +80,10 @@ public class FilesActivityDefaultsUiTest extends ActivityTest<FilesActivity> {
        device.pressBack();
    }

    @Test
    @HugeLongTest
    public void testDefaultRoots() throws Exception {
    @RequiresFlagsDisabled(FLAG_HIDE_ROOTS_ON_DESKTOP)
    public void testDefaultRoots_hideRootsOnDesktopFlagDisabled() throws Exception {
        device.waitForIdle();

        // Should also have Drive, but that requires pre-configuration of devices
@@ -71,4 +96,29 @@ public class FilesActivityDefaultsUiTest extends ActivityTest<FilesActivity> {
                ROOT_0_ID,
                ROOT_1_ID);
    }

    @Test
    @HugeLongTest
    @RequiresFlagsEnabled(FLAG_HIDE_ROOTS_ON_DESKTOP)
    public void testDefaultRoots_hideRootsOnDesktopFlagEnabled() throws Exception {
        device.waitForIdle();

        String[] expectedRoots;
        if (context.getPackageManager().hasSystemFeature(PackageManager.FEATURE_PC)) {
            expectedRoots = new String[]{"Downloads",
                    ROOT_0_ID,
                    ROOT_1_ID};
        } else {
            expectedRoots = new String[]{
                    "Images",
                    "Videos",
                    "Audio",
                    "Downloads",
                    ROOT_0_ID,
                    ROOT_1_ID};
        }
        // Should also have Drive, but that requires pre-configuration of devices
        // We omit for now.
        bots.roots.assertRootsPresent(expectedRoots);
    }
}
Loading