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

Commit 78f0ec4b authored by Steve McKay's avatar Steve McKay
Browse files

Don't sort pre-sorted results.

BUG: 30927484
Test: Run unittests
Change-Id: Ia64d50e3805d3c907eb780501b649bca9ed36e49
parent 991f3882
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 {