Search in sources :

Example 66 with DocumentInfo

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);
}
Also used : DocumentInfo(com.android.documentsui.model.DocumentInfo)

Example 67 with DocumentInfo

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);
}
Also used : DocumentInfo(com.android.documentsui.model.DocumentInfo)

Example 68 with DocumentInfo

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;
}
Also used : ArrayList(java.util.ArrayList) Cursor(android.database.Cursor) Uri(android.net.Uri) DocumentsContract.buildDocumentUri(android.provider.DocumentsContract.buildDocumentUri) DocumentsContract.buildChildDocumentsUri(android.provider.DocumentsContract.buildChildDocumentsUri) DocumentsContract.buildRootsUri(android.provider.DocumentsContract.buildRootsUri) DocumentInfo(com.android.documentsui.model.DocumentInfo)

Example 69 with DocumentInfo

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);
}
Also used : DocumentInfo(com.android.documentsui.model.DocumentInfo)

Example 70 with DocumentInfo

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);
}
Also used : DocumentInfo(com.android.documentsui.model.DocumentInfo)

Aggregations

DocumentInfo (com.android.documentsui.model.DocumentInfo)150 Uri (android.net.Uri)40 Cursor (android.database.Cursor)30 DocumentInfo.getCursorString (com.android.documentsui.model.DocumentInfo.getCursorString)30 FragmentManager (android.app.FragmentManager)20 Point (android.graphics.Point)20 RootInfo (com.android.documentsui.model.RootInfo)20 ArrayList (java.util.ArrayList)20 Intent (android.content.Intent)15 DocumentsContract.buildChildDocumentsUri (android.provider.DocumentsContract.buildChildDocumentsUri)15 DocumentsContract.buildDocumentUri (android.provider.DocumentsContract.buildDocumentUri)15 ClipData (android.content.ClipData)10 ContentResolver (android.content.ContentResolver)10 DialogInterface (android.content.DialogInterface)10 RemoteException (android.os.RemoteException)10 BaseActivity (com.android.documentsui.BaseActivity)10 DocumentStack (com.android.documentsui.model.DocumentStack)10 Activity (android.app.Activity)5 AlertDialog (android.app.AlertDialog)5 ContentProviderClient (android.content.ContentProviderClient)5