Search in sources :

Example 61 with MatrixCursor

use of android.database.MatrixCursor in project android_frameworks_base by ResurrectionRemix.

the class TestDocumentsProvider method queryDocument.

@Override
public Cursor queryDocument(String documentId, String[] projection) throws FileNotFoundException {
    if (LAG)
        lagUntilCanceled(null);
    if (DOCUMENT_CRASH)
        System.exit(12);
    final MatrixCursor result = new MatrixCursor(resolveDocumentProjection(projection));
    includeFile(result, documentId, 0);
    return result;
}
Also used : MatrixCursor(android.database.MatrixCursor)

Example 62 with MatrixCursor

use of android.database.MatrixCursor in project android_frameworks_base by ResurrectionRemix.

the class SectionBreakDocumentsAdapterWrapperTest method testItemCount_mixed.

// Tests that the item count is correct for a directory containing files and subdirs.
public void testItemCount_mixed() {
    MatrixCursor c = new MatrixCursor(TestModel.COLUMNS);
    for (int i = 0; i < 5; ++i) {
        MatrixCursor.RowBuilder row = c.newRow();
        row.add(RootCursorWrapper.COLUMN_AUTHORITY, AUTHORITY);
        row.add(Document.COLUMN_DOCUMENT_ID, Integer.toString(i));
        row.add(Document.COLUMN_SIZE, i);
        String mimeType = (i < 2) ? Document.MIME_TYPE_DIR : "text/*";
        row.add(Document.COLUMN_MIME_TYPE, mimeType);
    }
    DirectoryResult r = new DirectoryResult();
    r.cursor = c;
    r.sortOrder = State.SORT_ORDER_SIZE;
    mModel.update(r);
    assertEquals(mModel.getItemCount() + 1, mAdapter.getItemCount());
}
Also used : DirectoryResult(com.android.documentsui.DirectoryResult) MatrixCursor(android.database.MatrixCursor)

Example 63 with MatrixCursor

use of android.database.MatrixCursor in project android_frameworks_base by ResurrectionRemix.

the class ModelTest method setUp.

public void setUp() {
    setupTestContext();
    Random rand = new Random();
    MatrixCursor c = new MatrixCursor(COLUMNS);
    for (int i = 0; i < ITEM_COUNT; ++i) {
        MatrixCursor.RowBuilder row = c.newRow();
        row.add(RootCursorWrapper.COLUMN_AUTHORITY, AUTHORITY);
        row.add(Document.COLUMN_DOCUMENT_ID, Integer.toString(i));
        row.add(Document.COLUMN_FLAGS, Document.FLAG_SUPPORTS_DELETE);
        // Generate random document names and sizes. This forces the model's internal sort code
        // to actually do something.
        row.add(Document.COLUMN_DISPLAY_NAME, NAMES[i]);
        row.add(Document.COLUMN_SIZE, rand.nextInt());
    }
    cursor = c;
    DirectoryResult r = new DirectoryResult();
    r.cursor = cursor;
    // Instantiate the model with a dummy view adapter and listener that (for now) do nothing.
    model = new Model();
    model.addUpdateListener(new DummyListener());
    model.update(r);
}
Also used : Random(java.util.Random) DirectoryResult(com.android.documentsui.DirectoryResult) MatrixCursor(android.database.MatrixCursor)

Example 64 with MatrixCursor

use of android.database.MatrixCursor in project android_frameworks_base by ResurrectionRemix.

the class ModelTest method testModelIdIsUnique.

// Tests multiple authorities with clashing document IDs.
public void testModelIdIsUnique() {
    MatrixCursor cIn1 = new MatrixCursor(COLUMNS);
    MatrixCursor cIn2 = new MatrixCursor(COLUMNS);
    // Make two sets of items with the same IDs, under different authorities.
    final String AUTHORITY0 = "auth0";
    final String AUTHORITY1 = "auth1";
    for (int i = 0; i < ITEM_COUNT; ++i) {
        MatrixCursor.RowBuilder row0 = cIn1.newRow();
        row0.add(RootCursorWrapper.COLUMN_AUTHORITY, AUTHORITY0);
        row0.add(Document.COLUMN_DOCUMENT_ID, Integer.toString(i));
        MatrixCursor.RowBuilder row1 = cIn2.newRow();
        row1.add(RootCursorWrapper.COLUMN_AUTHORITY, AUTHORITY1);
        row1.add(Document.COLUMN_DOCUMENT_ID, Integer.toString(i));
    }
    Cursor cIn = new MergeCursor(new Cursor[] { cIn1, cIn2 });
    // Update the model, then make sure it contains all the expected items.
    DirectoryResult r = new DirectoryResult();
    r.cursor = cIn;
    model.update(r);
    assertEquals(ITEM_COUNT * 2, model.getItemCount());
    BitSet b0 = new BitSet(ITEM_COUNT);
    BitSet b1 = new BitSet(ITEM_COUNT);
    for (String id : model.getModelIds()) {
        Cursor cOut = model.getItem(id);
        String authority = DocumentInfo.getCursorString(cOut, RootCursorWrapper.COLUMN_AUTHORITY);
        String docId = DocumentInfo.getCursorString(cOut, Document.COLUMN_DOCUMENT_ID);
        switch(authority) {
            case AUTHORITY0:
                b0.set(Integer.parseInt(docId));
                break;
            case AUTHORITY1:
                b1.set(Integer.parseInt(docId));
                break;
            default:
                fail("Unrecognized authority string");
        }
    }
    assertEquals(ITEM_COUNT, b0.cardinality());
    assertEquals(ITEM_COUNT, b1.cardinality());
}
Also used : DirectoryResult(com.android.documentsui.DirectoryResult) MergeCursor(android.database.MergeCursor) BitSet(java.util.BitSet) MergeCursor(android.database.MergeCursor) MatrixCursor(android.database.MatrixCursor) Cursor(android.database.Cursor) MatrixCursor(android.database.MatrixCursor)

Example 65 with MatrixCursor

use of android.database.MatrixCursor in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class SettingsSearchIndexablesProvider method queryXmlResources.

@Override
public Cursor queryXmlResources(String[] projection) {
    MatrixCursor cursor = new MatrixCursor(INDEXABLES_XML_RES_COLUMNS);
    Collection<SearchIndexableResource> values = SearchIndexableResources.values();
    for (SearchIndexableResource val : values) {
        Object[] ref = new Object[7];
        ref[COLUMN_INDEX_XML_RES_RANK] = val.rank;
        ref[COLUMN_INDEX_XML_RES_RESID] = val.xmlResId;
        ref[COLUMN_INDEX_XML_RES_CLASS_NAME] = val.className;
        ref[COLUMN_INDEX_XML_RES_ICON_RESID] = val.iconResId;
        // intent action
        ref[COLUMN_INDEX_XML_RES_INTENT_ACTION] = null;
        // intent target package
        ref[COLUMN_INDEX_XML_RES_INTENT_TARGET_PACKAGE] = null;
        // intent target class
        ref[COLUMN_INDEX_XML_RES_INTENT_TARGET_CLASS] = null;
        cursor.addRow(ref);
    }
    return cursor;
}
Also used : SearchIndexableResource(android.provider.SearchIndexableResource) MatrixCursor(android.database.MatrixCursor)

Aggregations

MatrixCursor (android.database.MatrixCursor)259 Cursor (android.database.Cursor)37 DirectoryResult (com.android.documentsui.DirectoryResult)35 RowBuilder (android.database.MatrixCursor.RowBuilder)30 File (java.io.File)30 MergeCursor (android.database.MergeCursor)18 Uri (android.net.Uri)18 Test (org.junit.Test)17 Setting (com.android.providers.settings.SettingsState.Setting)15 FileNotFoundException (java.io.FileNotFoundException)15 ArrayList (java.util.ArrayList)13 Bundle (android.os.Bundle)10 BitSet (java.util.BitSet)10 Random (java.util.Random)10 IOException (java.io.IOException)7 LinkedList (java.util.LinkedList)7 ContentValues (android.content.ContentValues)6 HashSet (java.util.HashSet)6 Map (java.util.Map)6 SQLiteQueryBuilder (android.database.sqlite.SQLiteQueryBuilder)5