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

Commit edee6de3 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Don't sort pre-sorted results."

parents 187283d4 78f0ec4b
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -17,9 +17,12 @@
package com.android.documentsui.sorting;

import static com.android.documentsui.base.Shared.DEBUG;
import static com.android.documentsui.base.Shared.ENABLE_OMC_API_FEATURES;
import static com.android.documentsui.base.Shared.VERBOSE;

import android.annotation.IntDef;
import android.annotation.Nullable;
import android.content.ContentResolver;
import android.database.Cursor;
import android.os.Parcel;
import android.os.Parcelable;
@@ -220,6 +223,15 @@ public class SortModel implements Parcelable {
    }

    public Cursor sortCursor(Cursor cursor) {
        if (ENABLE_OMC_API_FEATURES
                && cursor.getExtras().containsKey(ContentResolver.QUERY_ARG_SORT_COLUMNS)) {
            if (VERBOSE) Log.i(TAG, "Cursor is pre-sorted by provider. Skipping sort. Booya!");

            // TODO: assert that the contents of QUERY_ARG_SORT_COLUMNS
            // matches the sort dimension...once we're returning any pre-sorted results.
            return cursor;
        }

        if (mSortedDimension != null) {
            return new SortingCursorWrapper(cursor, mSortedDimension);
        } else {