use of android.database.MatrixCursor.RowBuilder in project android_frameworks_base by crdroidandroid.
the class StubProvider method queryRoots.
@Override
public Cursor queryRoots(String[] projection) throws FileNotFoundException {
final MatrixCursor result = new MatrixCursor(projection != null ? projection : DEFAULT_ROOT_PROJECTION);
for (Map.Entry<String, RootInfo> entry : mRoots.entrySet()) {
final String id = entry.getKey();
final RootInfo info = entry.getValue();
final RowBuilder row = result.newRow();
row.add(Root.COLUMN_ROOT_ID, id);
row.add(Root.COLUMN_FLAGS, info.flags);
row.add(Root.COLUMN_TITLE, id);
row.add(Root.COLUMN_DOCUMENT_ID, info.document.documentId);
row.add(Root.COLUMN_AVAILABLE_BYTES, info.getRemainingCapacity());
}
return result;
}
use of android.database.MatrixCursor.RowBuilder in project android_frameworks_base by crdroidandroid.
the class StressProvider method includeRoot.
private void includeRoot(MatrixCursor result, StubRoot root) {
final RowBuilder row = result.newRow();
row.add(Root.COLUMN_ROOT_ID, root.id);
row.add(Root.COLUMN_FLAGS, 0);
row.add(Root.COLUMN_TITLE, root.id);
row.add(Root.COLUMN_DOCUMENT_ID, root.documentId);
}
use of android.database.MatrixCursor.RowBuilder in project android_frameworks_base by crdroidandroid.
the class BugreportStorageProvider method queryDocument.
@Override
public Cursor queryDocument(String documentId, String[] projection) throws FileNotFoundException {
if (mArchiveHelper.isArchivedDocument(documentId)) {
return mArchiveHelper.queryDocument(documentId, projection);
}
final MatrixCursor result = new MatrixCursor(resolveDocumentProjection(projection));
if (DOC_ID_ROOT.equals(documentId)) {
final RowBuilder row = result.newRow();
row.add(Document.COLUMN_DOCUMENT_ID, documentId);
row.add(Document.COLUMN_MIME_TYPE, Document.MIME_TYPE_DIR);
row.add(Document.COLUMN_DISPLAY_NAME, mRoot.getName());
row.add(Document.COLUMN_LAST_MODIFIED, mRoot.lastModified());
row.add(Document.COLUMN_FLAGS, Document.FLAG_DIR_PREFERS_LAST_MODIFIED);
} else {
addFileRow(result, getFileForDocId(documentId));
}
return result;
}
use of android.database.MatrixCursor.RowBuilder in project android_frameworks_base by crdroidandroid.
the class ExternalStorageProvider method includeFile.
private void includeFile(MatrixCursor result, String docId, File file) throws FileNotFoundException {
if (docId == null) {
docId = getDocIdForFile(file);
} else {
file = getFileForDocId(docId);
}
int flags = 0;
if (file.canWrite()) {
if (file.isDirectory()) {
flags |= Document.FLAG_DIR_SUPPORTS_CREATE;
flags |= Document.FLAG_SUPPORTS_DELETE;
flags |= Document.FLAG_SUPPORTS_RENAME;
flags |= Document.FLAG_SUPPORTS_MOVE;
} else {
flags |= Document.FLAG_SUPPORTS_WRITE;
flags |= Document.FLAG_SUPPORTS_DELETE;
flags |= Document.FLAG_SUPPORTS_RENAME;
flags |= Document.FLAG_SUPPORTS_MOVE;
}
}
final String mimeType = getTypeForFile(file);
if (mArchiveHelper.isSupportedArchiveType(mimeType)) {
flags |= Document.FLAG_ARCHIVE;
}
final String displayName = file.getName();
if (mimeType.startsWith("image/")) {
flags |= Document.FLAG_SUPPORTS_THUMBNAIL;
}
final RowBuilder row = result.newRow();
row.add(Document.COLUMN_DOCUMENT_ID, docId);
row.add(Document.COLUMN_DISPLAY_NAME, displayName);
row.add(Document.COLUMN_SIZE, file.length());
row.add(Document.COLUMN_MIME_TYPE, mimeType);
row.add(Document.COLUMN_FLAGS, flags);
row.add(DocumentArchiveHelper.COLUMN_LOCAL_FILE_PATH, file.getPath());
// Only publish dates reasonably after epoch
long lastModified = file.lastModified();
if (lastModified > 31536000000L) {
row.add(Document.COLUMN_LAST_MODIFIED, lastModified);
}
}
use of android.database.MatrixCursor.RowBuilder in project android_frameworks_base by crdroidandroid.
the class TestDocumentsProvider method queryRoots.
@Override
public Cursor queryRoots(String[] projection) throws FileNotFoundException {
Log.d(TAG, "Someone asked for our roots!");
if (LAG)
lagUntilCanceled(null);
if (ROOTS_WEDGE)
wedgeUntilCanceled(null);
if (ROOTS_CRASH)
System.exit(12);
if (ROOTS_REFRESH) {
new AsyncTask<Void, Void, Void>() {
@Override
protected Void doInBackground(Void... params) {
SystemClock.sleep(3000);
Log.d(TAG, "Notifying that something changed!!");
final Uri uri = DocumentsContract.buildRootsUri(mAuthority);
getContext().getContentResolver().notifyChange(uri, null, false);
return null;
}
}.execute();
}
final MatrixCursor result = new MatrixCursor(resolveRootProjection(projection));
final RowBuilder row = result.newRow();
row.add(Root.COLUMN_ROOT_ID, MY_ROOT_ID);
row.add(Root.COLUMN_FLAGS, Root.FLAG_SUPPORTS_RECENTS | Root.FLAG_SUPPORTS_CREATE);
row.add(Root.COLUMN_TITLE, "_Test title which is really long");
row.add(Root.COLUMN_SUMMARY, SystemClock.elapsedRealtime() + " summary which is also super long text");
row.add(Root.COLUMN_DOCUMENT_ID, MY_DOC_ID);
row.add(Root.COLUMN_AVAILABLE_BYTES, 1024);
return result;
}
Aggregations