Search in sources :

Example 56 with MatrixCursor

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

the class ExternalStorageProvider method queryRoots.

@Override
public Cursor queryRoots(String[] projection) throws FileNotFoundException {
    final MatrixCursor result = new MatrixCursor(resolveRootProjection(projection));
    synchronized (mRootsLock) {
        for (RootInfo root : mRoots.values()) {
            final RowBuilder row = result.newRow();
            row.add(Root.COLUMN_ROOT_ID, root.rootId);
            row.add(Root.COLUMN_FLAGS, root.flags);
            row.add(Root.COLUMN_TITLE, root.title);
            row.add(Root.COLUMN_DOCUMENT_ID, root.docId);
            row.add(Root.COLUMN_AVAILABLE_BYTES, root.reportAvailableBytes ? root.path.getFreeSpace() : -1);
        }
    }
    return result;
}
Also used : RowBuilder(android.database.MatrixCursor.RowBuilder) MatrixCursor(android.database.MatrixCursor)

Example 57 with MatrixCursor

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

the class SettingsProvider method getAllGlobalSettings.

private Cursor getAllGlobalSettings(String[] projection) {
    if (DEBUG) {
        Slog.v(LOG_TAG, "getAllGlobalSettings()");
    }
    synchronized (mLock) {
        // Get the settings.
        SettingsState settingsState = mSettingsRegistry.getSettingsLocked(SETTINGS_TYPE_GLOBAL, UserHandle.USER_SYSTEM);
        List<String> names = settingsState.getSettingNamesLocked();
        final int nameCount = names.size();
        String[] normalizedProjection = normalizeProjection(projection);
        MatrixCursor result = new MatrixCursor(normalizedProjection, nameCount);
        // Anyone can get the global settings, so no security checks.
        for (int i = 0; i < nameCount; i++) {
            String name = names.get(i);
            Setting setting = settingsState.getSettingLocked(name);
            appendSettingToCursor(result, setting);
        }
        return result;
    }
}
Also used : Setting(com.android.providers.settings.SettingsState.Setting) MatrixCursor(android.database.MatrixCursor)

Example 58 with MatrixCursor

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

the class SettingsProvider method getAllSecureSettings.

private Cursor getAllSecureSettings(int userId, String[] projection) {
    if (DEBUG) {
        Slog.v(LOG_TAG, "getAllSecureSettings(" + userId + ")");
    }
    // Resolve the userId on whose behalf the call is made.
    final int callingUserId = resolveCallingUserIdEnforcingPermissionsLocked(userId);
    synchronized (mLock) {
        List<String> names = mSettingsRegistry.getSettingsNamesLocked(SETTINGS_TYPE_SECURE, callingUserId);
        final int nameCount = names.size();
        String[] normalizedProjection = normalizeProjection(projection);
        MatrixCursor result = new MatrixCursor(normalizedProjection, nameCount);
        for (int i = 0; i < nameCount; i++) {
            String name = names.get(i);
            // Determine the owning user as some profile settings are cloned from the parent.
            final int owningUserId = resolveOwningUserIdForSecureSettingLocked(callingUserId, name);
            // Special case for location (sigh).
            if (isLocationProvidersAllowedRestricted(name, callingUserId, owningUserId)) {
                continue;
            }
            Setting setting = mSettingsRegistry.getSettingLocked(SETTINGS_TYPE_SECURE, owningUserId, name);
            appendSettingToCursor(result, setting);
        }
        return result;
    }
}
Also used : Setting(com.android.providers.settings.SettingsState.Setting) MatrixCursor(android.database.MatrixCursor)

Example 59 with MatrixCursor

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

the class MusicProvider method getRootContainerCurser.

public MatrixCursor getRootContainerCurser() {
    MatrixCursor matrixCursor = new MatrixCursor(BrowserService.MEDIA_CONTAINER_PROJECTION);
    Uri.Builder pianoBuilder = new Uri.Builder();
    pianoBuilder.authority(BrowserService.AUTHORITY);
    pianoBuilder.appendPath(BrowserService.PIANO_BASE_PATH);
    matrixCursor.addRow(new Object[] { pianoBuilder.build(), BrowserService.PIANO_BASE_PATH, "subtitle", null, 0 });
    Uri.Builder voiceBuilder = new Uri.Builder();
    voiceBuilder.authority(BrowserService.AUTHORITY);
    voiceBuilder.appendPath(BrowserService.VOICE_BASE_PATH);
    matrixCursor.addRow(new Object[] { voiceBuilder.build(), BrowserService.VOICE_BASE_PATH, "subtitle", null, 0 });
    return matrixCursor;
}
Also used : Uri(android.net.Uri) MatrixCursor(android.database.MatrixCursor)

Example 60 with MatrixCursor

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

the class TestDocumentsProvider method queryRecentDocuments.

@Override
public Cursor queryRecentDocuments(String rootId, String[] projection) throws FileNotFoundException {
    if (LAG)
        lagUntilCanceled(null);
    if (RECENT_WEDGE)
        wedgeUntilCanceled(null);
    // Pretend to take a super long time to respond
    SystemClock.sleep(3000);
    final MatrixCursor result = new MatrixCursor(resolveDocumentProjection(projection));
    includeFile(result, "It was /worth/ the_wait for?the file:with the&incredibly long name", 0);
    return result;
}
Also used : 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