Iteration on findDocumentPath() API.

Rename findPath() to findDocumentPath() per comment in ag/1588156.

Bug: 30948740
Change-Id: I84ef4d9c0ed1f854e0e33f3552a1805b944c2791
This commit is contained in:
Garfield Tan
2016-11-01 14:13:38 -07:00
parent a3230467d1
commit 3f6b68a697
5 changed files with 21 additions and 21 deletions

View File

@@ -636,7 +636,7 @@ public final class DocumentsContract {
/** {@hide} */
public static final String METHOD_EJECT_ROOT = "android:ejectRoot";
/** {@hide} */
public static final String METHOD_FIND_PATH = "android:findPath";
public static final String METHOD_FIND_DOCUMENT_PATH = "android:findDocumentPath";
/** {@hide} */
public static final String EXTRA_PARENT_URI = "parentUri";
@@ -1304,22 +1304,22 @@ public final class DocumentsContract {
* from the top of the tree or the root document to the requested document,
* both inclusive.
*
* Document id should be unique across roots.
* Document ID should be unique across roots.
*
* @param treeUri treeUri of the document which path is requested.
* @return a list of documents ID starting from the top of the tree to the
* requested document, or {@code null} if failed.
* @see DocumentsProvider#findPath(String, String)
* @see DocumentsProvider#findDocumentPath(String, String)
*
* {@hide}
*/
public static List<String> findPath(ContentResolver resolver, Uri treeUri) {
public static List<String> findDocumentPath(ContentResolver resolver, Uri treeUri) {
checkArgument(isTreeUri(treeUri), treeUri + " is not a tree uri.");
final ContentProviderClient client = resolver.acquireUnstableContentProviderClient(
treeUri.getAuthority());
try {
return findPath(client, treeUri).getPath();
return findDocumentPath(client, treeUri).getPath();
} catch (Exception e) {
Log.w(TAG, "Failed to find path", e);
return null;
@@ -1339,15 +1339,15 @@ public final class DocumentsContract {
* @param uri uri of the document which path is requested. It can be either a
* plain document uri or a tree uri.
* @return the path of the document.
* @see DocumentsProvider#findPath(String, String)
* @see DocumentsProvider#findDocumentPath(String, String)
*
* {@hide}
*/
public static Path findPath(ContentProviderClient client, Uri uri) throws RemoteException {
public static Path findDocumentPath(ContentProviderClient client, Uri uri) throws RemoteException {
final Bundle in = new Bundle();
in.putParcelable(DocumentsContract.EXTRA_URI, uri);
final Bundle out = client.call(METHOD_FIND_PATH, null, in);
final Bundle out = client.call(METHOD_FIND_DOCUMENT_PATH, null, in);
return out.getParcelable(DocumentsContract.EXTRA_RESULT);
}

View File

@@ -20,7 +20,7 @@ import static android.provider.DocumentsContract.METHOD_COPY_DOCUMENT;
import static android.provider.DocumentsContract.METHOD_CREATE_DOCUMENT;
import static android.provider.DocumentsContract.METHOD_DELETE_DOCUMENT;
import static android.provider.DocumentsContract.METHOD_EJECT_ROOT;
import static android.provider.DocumentsContract.METHOD_FIND_PATH;
import static android.provider.DocumentsContract.METHOD_FIND_DOCUMENT_PATH;
import static android.provider.DocumentsContract.METHOD_IS_CHILD_DOCUMENT;
import static android.provider.DocumentsContract.METHOD_MOVE_DOCUMENT;
import static android.provider.DocumentsContract.METHOD_REMOVE_DOCUMENT;
@@ -350,17 +350,17 @@ public abstract class DocumentsProvider extends ContentProvider {
* document.
*
* @param childDocumentId the document which path is requested.
* @param parentDocumentId the document with which path starts if not null, or
* null to indicate path to root is requested.
* @param parentDocumentId the document from which the path starts if not null,
* or null to indicate a path from the root is requested.
* @return the path of the requested document. If parentDocumentId is null
* returned root ID must not be null. If parentDocumentId is not null
* returned root ID must be null.
*
* @hide
*/
public Path findPath(String childDocumentId, @Nullable String parentDocumentId)
public Path findDocumentPath(String childDocumentId, @Nullable String parentDocumentId)
throws FileNotFoundException {
throw new UnsupportedOperationException("findPath not supported.");
throw new UnsupportedOperationException("findDocumentPath not supported.");
}
/**
@@ -914,7 +914,7 @@ public abstract class DocumentsProvider extends ContentProvider {
// It's responsibility of the provider to revoke any grants, as the document may be
// still attached to another parents.
} else if (METHOD_FIND_PATH.equals(method)) {
} else if (METHOD_FIND_DOCUMENT_PATH.equals(method)) {
final boolean isTreeUri = isTreeUri(documentUri);
if (isTreeUri) {
@@ -927,7 +927,7 @@ public abstract class DocumentsProvider extends ContentProvider {
? DocumentsContract.getTreeDocumentId(documentUri)
: null;
Path path = findPath(documentId, parentDocumentId);
Path path = findDocumentPath(documentId, parentDocumentId);
// Ensure provider doesn't leak information to unprivileged callers.
if (isTreeUri) {

View File

@@ -60,7 +60,7 @@ public class DocumentsProviderTest extends ProviderTestCase2<TestDocumentsProvid
DocumentsContract.buildDocumentUri(TestDocumentsProvider.AUTHORITY, DOCUMENT_ID);
try (ContentProviderClient client =
mResolver.acquireUnstableContentProviderClient(docUri)) {
final Path actual = DocumentsContract.findPath(client, docUri);
final Path actual = DocumentsContract.findDocumentPath(client, docUri);
assertEquals(expected, actual);
}
}
@@ -73,7 +73,7 @@ public class DocumentsProviderTest extends ProviderTestCase2<TestDocumentsProvid
final Uri docUri = buildTreeDocumentUri(
TestDocumentsProvider.AUTHORITY, PARENT_DOCUMENT_ID, DOCUMENT_ID);
final List<String> actual = DocumentsContract.findPath(mResolver, docUri);
final List<String> actual = DocumentsContract.findDocumentPath(mResolver, docUri);
assertEquals(expected.getPath(), actual);
}
@@ -83,7 +83,7 @@ public class DocumentsProviderTest extends ProviderTestCase2<TestDocumentsProvid
final Uri docUri = buildTreeDocumentUri(
TestDocumentsProvider.AUTHORITY, PARENT_DOCUMENT_ID, DOCUMENT_ID);
assertNull(DocumentsContract.findPath(mResolver, docUri));
assertNull(DocumentsContract.findDocumentPath(mResolver, docUri));
}
public void testFindPath_treeUri_erasesNonNullRootId() throws Exception {
@@ -95,7 +95,7 @@ public class DocumentsProviderTest extends ProviderTestCase2<TestDocumentsProvid
TestDocumentsProvider.AUTHORITY, PARENT_DOCUMENT_ID, DOCUMENT_ID);
try (ContentProviderClient client =
mResolver.acquireUnstableContentProviderClient(docUri)) {
Path path = DocumentsContract.findPath(client, docUri);
Path path = DocumentsContract.findDocumentPath(client, docUri);
assertNull(path.getRootId());
}
}

View File

@@ -85,7 +85,7 @@ public class TestDocumentsProvider extends DocumentsProvider {
}
@Override
public Path findPath(String documentId, @Nullable String parentDocumentId) {
public Path findDocumentPath(String documentId, @Nullable String parentDocumentId) {
lastDocumentId = documentId;
lastParentDocumentId = parentDocumentId;

View File

@@ -445,7 +445,7 @@ public class ExternalStorageProvider extends DocumentsProvider {
}
@Override
public Path findPath(String childDocId, @Nullable String parentDocId)
public Path findDocumentPath(String childDocId, @Nullable String parentDocId)
throws FileNotFoundException {
LinkedList<String> path = new LinkedList<>();