use of com.android.documentsui.model.DocumentInfo in project android_frameworks_base by AOSPA.
the class DocumentsProviderHelper method assertHasFile.
public void assertHasFile(Uri parentUri, String name) throws Exception {
List<DocumentInfo> children = listChildren(parentUri);
for (DocumentInfo child : children) {
if (name.equals(child.displayName) && !child.isDirectory()) {
return;
}
}
fail("Could not find file named=" + name + " in children " + children);
}
use of com.android.documentsui.model.DocumentInfo in project android_frameworks_base by AOSPA.
the class DocumentsProviderHelper method assertFileContents.
public void assertFileContents(String parentId, String fileName, byte[] expected) throws Exception {
DocumentInfo file = findFile(parentId, fileName);
assertNotNull(file);
assertFileContents(file.derivedUri, expected);
}
use of com.android.documentsui.model.DocumentInfo in project android_frameworks_base by AOSPA.
the class DocumentsProviderHelper method listChildren.
public List<DocumentInfo> listChildren(String documentId) throws Exception {
Uri uri = buildChildDocumentsUri(mAuthority, documentId);
List<DocumentInfo> children = new ArrayList<>();
try (Cursor cursor = mClient.query(uri, null, null, null, null, null)) {
Cursor wrapper = new RootCursorWrapper(mAuthority, "totally-fake", cursor, 100);
while (wrapper.moveToNext()) {
children.add(DocumentInfo.fromDirectoryCursor(wrapper));
}
}
return children;
}
use of com.android.documentsui.model.DocumentInfo in project android_frameworks_base by AOSPA.
the class DocumentsProviderHelper method assertHasDirectory.
public void assertHasDirectory(Uri parentUri, String name) throws Exception {
List<DocumentInfo> children = listChildren(parentUri);
for (DocumentInfo child : children) {
if (name.equals(child.displayName) && child.isDirectory()) {
return;
}
}
fail("Could not find name=" + name + " in children " + children);
}
use of com.android.documentsui.model.DocumentInfo in project android_frameworks_base by AOSPA.
the class CopyJob method start.
@Override
void start() {
mStartTime = elapsedRealtime();
try {
mBatchSize = calculateSize(mSrcs);
} catch (ResourceException e) {
Log.w(TAG, "Failed to calculate total size. Copying without progress.", e);
mBatchSize = -1;
}
DocumentInfo srcInfo;
DocumentInfo dstInfo = stack.peek();
for (int i = 0; i < mSrcs.size() && !isCanceled(); ++i) {
srcInfo = mSrcs.get(i);
if (DEBUG)
Log.d(TAG, "Copying " + srcInfo.displayName + " (" + srcInfo.derivedUri + ")" + " to " + dstInfo.displayName + " (" + dstInfo.derivedUri + ")");
try {
if (dstInfo.equals(srcInfo) || isDescendentOf(srcInfo, dstInfo)) {
Log.e(TAG, "Skipping recursive copy of " + srcInfo.derivedUri);
onFileFailed(srcInfo);
} else {
processDocument(srcInfo, null, dstInfo);
}
} catch (ResourceException e) {
Log.e(TAG, "Failed to copy " + srcInfo.derivedUri, e);
onFileFailed(srcInfo);
}
}
Metrics.logFileOperation(service, operationType, mSrcs, dstInfo);
}
Aggregations