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

Commit 588598ee authored by Android Build Coastguard Worker's avatar Android Build Coastguard Worker
Browse files

Snap for 13599671 from 250d3bb4 to 25Q3-release

Change-Id: I4bd0b9ddb9d21aac7ab0cf815f28937a74bfd896
parents 256b3418 250d3bb4
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -1026,8 +1026,9 @@ public abstract class AbstractActionHandler<T extends FragmentActivity & CommonA
            int maxResults = (root == null || root.isRecents())
                    ? RecentsLoader.MAX_DOCS_FROM_ROOT : MAX_RESULTS;
            QueryOptions options = new QueryOptions(
                    maxResults, lastModifiedDelta, Duration.ofMillis(MAX_SEARCH_TIME_MS),
                    mState.showHiddenFiles, mState.acceptMimes, mSearchMgr.buildQueryArgs());
                    maxResults, maxResults, lastModifiedDelta,
                    Duration.ofMillis(MAX_SEARCH_TIME_MS), mState.showHiddenFiles,
                    mState.acceptMimes, mSearchMgr.buildQueryArgs());

            if (stack.isRecents() || mSearchMgr.isSearching()) {
                Log.d(TAG, "Creating search loader V2");
+1 −18
Original line number Diff line number Diff line
@@ -19,11 +19,10 @@ package com.android.documentsui;
import static com.android.documentsui.base.Shared.EXTRA_BENCHMARK;
import static com.android.documentsui.base.SharedMinimal.DEBUG;
import static com.android.documentsui.base.State.MODE_GRID;
import static com.android.documentsui.util.FlagUtils.isSearchV2Enabled;
import static com.android.documentsui.util.FlagUtils.isUseMaterial3FlagEnabled;
import static com.android.documentsui.util.FlagUtils.isUsePeekPreviewFlagEnabled;
import static com.android.documentsui.util.FlagUtils.isVisualSignalsFlagEnabled;
import static com.android.documentsui.util.Material3Config.getRes;
import static com.android.documentsui.util.FlagUtils.isSearchV2Enabled;

import android.content.Context;
import android.content.Intent;
@@ -54,7 +53,6 @@ import androidx.appcompat.widget.ActionMenuView;
import androidx.appcompat.widget.Toolbar;
import androidx.core.view.WindowInsetsCompat;
import androidx.fragment.app.Fragment;
import androidx.lifecycle.ViewModelProvider;

import com.android.documentsui.AbstractActionHandler.CommonAddons;
import com.android.documentsui.Injector.Injected;
@@ -70,8 +68,6 @@ import com.android.documentsui.base.UserId;
import com.android.documentsui.dirlist.AnimationView;
import com.android.documentsui.dirlist.AppsRowManager;
import com.android.documentsui.dirlist.DirectoryFragment;
import com.android.documentsui.peek.PeekViewManager;
import com.android.documentsui.peek.PeekViewModel;
import com.android.documentsui.prefs.LocalPreferences;
import com.android.documentsui.prefs.PreferencesMonitor;
import com.android.documentsui.queries.CommandInterceptor;
@@ -103,7 +99,6 @@ public abstract class BaseActivity

    protected SearchViewManager mSearchManager;
    protected AppsRowManager mAppsRowManager;
    protected @Nullable PeekViewManager mPeekViewManager;
    protected UserIdManager mUserIdManager;
    protected UserManagerState mUserManagerState;
    protected State mState;
@@ -438,18 +433,6 @@ public abstract class BaseActivity
        // Base classes must update result in their onCreate.
        setResult(AppCompatActivity.RESULT_CANCELED);
        updateRecentsSetting();

        if (isUsePeekPreviewFlagEnabled()) {
            ViewModelProvider viewModelProvider = new ViewModelProvider(this);
            PeekViewModel viewModel = viewModelProvider.get(PeekViewModel.class);
            mPeekViewManager = new PeekViewManager(
                    viewModel,
                    findViewById(getRes(R.id.peek_overlay)),
                    getSupportFragmentManager());
            viewModel.getOverlayActive().observe(
                    this,
                    mPeekViewManager);
        }
    }

    private NavigationViewManager getNavigationViewManager(Breadcrumb breadcrumb,
+65 −9
Original line number Diff line number Diff line
@@ -16,12 +16,16 @@

package com.android.documentsui.archives;

import static com.android.documentsui.util.FlagUtils.isZipNgFlagEnabled;

import android.text.TextUtils;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import org.apache.commons.compress.archivers.ArchiveEntry;
import org.apache.commons.compress.archivers.ArchiveInputStream;
import org.apache.commons.compress.archivers.sevenz.SevenZArchiveEntry;
import org.apache.commons.compress.archivers.sevenz.SevenZFile;
import org.apache.commons.compress.archivers.zip.ZipArchiveEntry;
import org.apache.commons.compress.archivers.zip.ZipFile;
@@ -29,17 +33,34 @@ import org.apache.commons.compress.archivers.zip.ZipFile;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.util.zip.CRC32;
import java.util.zip.Checksum;

/**
 * To simulate the input stream by using ZipFile, SevenZFile, or ArchiveInputStream.
 */
abstract class ArchiveEntryInputStream extends InputStream {
    private final long mSize;
    private final ReadSource mReadSource;

    private ArchiveEntryInputStream(ReadSource readSource, @NonNull ArchiveEntry archiveEntry) {
    private final @NonNull ReadSource mReadSource;
    /** Expected number of bytes if the data being extracted. */
    private final long mExpectedSize;
    /** Number of bytes having been extracted so far. */
    private long mAccumulatedSize = 0;
    /** Expected CRC when all the data has been extracted, or -1 if no CRC needs to be checked. */
    private long mExpectedCrc = -1;
    /** CRC accumulator, or null if no CRC needs to be checked. */
    private @Nullable Checksum mCrcComputer = null;

    private ArchiveEntryInputStream(@NonNull ReadSource readSource, @NonNull ArchiveEntry entry) {
        mReadSource = readSource;
        mSize = archiveEntry.getSize();
        mExpectedSize = entry.getSize();
        if (isZipNgFlagEnabled()) {
            if (entry instanceof ZipArchiveEntry) {
                mExpectedCrc = ((ZipArchiveEntry) entry).getCrc();
            } else if (entry instanceof SevenZArchiveEntry) {
                mExpectedCrc = ((SevenZArchiveEntry) entry).getCrcValue();
            }
            if (mExpectedCrc >= 0) mCrcComputer = new CRC32();
        }
    }

    @Override
@@ -49,16 +70,51 @@ abstract class ArchiveEntryInputStream extends InputStream {

    @Override
    public int read(byte[] b, int off, int len) throws IOException {
        if (mReadSource != null) {
            return mReadSource.read(b, off, len);
        if (mReadSource == null) return -1;

        final int n = mReadSource.read(b, off, len);

        if (n >= 0) {
            if (isZipNgFlagEnabled()) {
                mAccumulatedSize += n;
                if (mAccumulatedSize > mExpectedSize) {
                    throw new IOException(
                            "Extracted file is too long: Already extracted " + mAccumulatedSize
                                    + " bytes when only " + mExpectedSize + " bytes are expected");
                }

                if (mCrcComputer != null) mCrcComputer.update(b, off, n);
            }

            return n;
        }

        // End of stream.
        if (isZipNgFlagEnabled()) {
            // Check file size.
            if (mAccumulatedSize != mExpectedSize) {
                throw new IOException(
                        "Extracted file is too short: Only extracted " + mAccumulatedSize
                                + " bytes when " + mExpectedSize + " bytes are expected");
            }

            // Check CRC.
            if (mCrcComputer != null) {
                final long crc = mCrcComputer.getValue();
                mCrcComputer = null;
                if (crc != mExpectedCrc) {
                    throw new IOException(
                            String.format("Bad CRC: got %08X, want %08X", crc, mExpectedCrc));
                }
            }
        }

        return -1; /* end of input stream */
        return -1;
    }

    @Override
    public int available() throws IOException {
        return mReadSource == null ? 0 : StrictMath.toIntExact(mSize);
        return mReadSource == null ? 0 : StrictMath.toIntExact(mExpectedSize);
    }

    /**
+22 −3
Original line number Diff line number Diff line
@@ -22,7 +22,26 @@ package com.android.documentsui.base
 * interchangeably. Additionally the "folderId" is rootId for the RootInfo, but documentId for
 * DocumentInfo.
 */
data class FolderInfo(val folderId: String, val authority: String) {
    constructor(folder: DocumentInfo) : this(folder.documentId, folder.authority)
    constructor(rootInfo: RootInfo) : this(rootInfo.rootId, rootInfo.authority)
data class FolderInfo(
    val folderId: String,
    val authority: String,
    // Specifies whether the Root this folder exists on supports search result limiting: this can
    // help to find more search results (increasing the limit) or improve performance (decreasing
    // the limit). We could just send the limit regardless of whether the root says it supports this
    // but this allows SearchLoader to be judicious and not starting sending new parameters that
    // it hasn't done in the past.
    //
    // TODO(b:419704219) remove this property when RootInfo/DocumentInfo have a shared interface.
    val supportsSearchResultLimiting: Boolean
) {
    constructor(rootInfo: RootInfo) : this(
        rootInfo.rootId,
        rootInfo.authority,
        rootInfo.supportsSearchResultLimit()
    )
    constructor(folder: DocumentInfo, folderRoot: RootInfo) : this(
        folder.documentId,
        folder.authority,
        folderRoot.supportsSearchResultLimit()
    )
}
+9 −0
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@ import static com.android.documentsui.base.Shared.compareToIgnoreCaseNullable;
import static com.android.documentsui.base.SharedMinimal.VERBOSE;
import static com.android.documentsui.util.Material3Config.getRes;

import android.content.ContentResolver;
import android.content.Context;
import android.database.Cursor;
import android.graphics.drawable.Drawable;
@@ -390,6 +391,14 @@ public class RootInfo implements Durable, Parcelable, Comparable<RootInfo> {
        return queryArgs != null && queryArgs.contains(QUERY_ARG_MIME_TYPES);
    }

    /**
     * Returns true if the DocumentsProvider hosting this root supports us specifying a limit for
     * the maximum number of search results it should return.
     */
    public boolean supportsSearchResultLimit() {
        return queryArgs != null && queryArgs.contains(ContentResolver.QUERY_ARG_LIMIT);
    }

    public boolean supportsEject() {
        return (flags & Root.FLAG_SUPPORTS_EJECT) != 0;
    }
Loading