Iteration on findDocumentPath() API.
Rename findPath() to findDocumentPath() per comment in ag/1588156.
Bug: 30948740
Change-Id: I84ef4d9c0ed1f854e0e33f3552a1805b944c2791
diff --git a/core/java/android/provider/DocumentsContract.java b/core/java/android/provider/DocumentsContract.java
index 20c7073..59a8fda 100644
--- a/core/java/android/provider/DocumentsContract.java
+++ b/core/java/android/provider/DocumentsContract.java
@@ -636,7 +636,7 @@
/** {@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 @@
* 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 @@
* @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);
}
diff --git a/core/java/android/provider/DocumentsProvider.java b/core/java/android/provider/DocumentsProvider.java
index 4256484..1df4dbd 100644
--- a/core/java/android/provider/DocumentsProvider.java
+++ b/core/java/android/provider/DocumentsProvider.java
@@ -20,7 +20,7 @@
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 @@
* 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 @@
// 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 @@
? 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) {
diff --git a/core/tests/coretests/src/android/provider/DocumentsProviderTest.java b/core/tests/coretests/src/android/provider/DocumentsProviderTest.java
index 71546e4..d1c68a9 100644
--- a/core/tests/coretests/src/android/provider/DocumentsProviderTest.java
+++ b/core/tests/coretests/src/android/provider/DocumentsProviderTest.java
@@ -60,7 +60,7 @@
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 @@
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 @@
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 @@
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());
}
}
diff --git a/core/tests/coretests/src/android/provider/TestDocumentsProvider.java b/core/tests/coretests/src/android/provider/TestDocumentsProvider.java
index 8dcf566..d61049d 100644
--- a/core/tests/coretests/src/android/provider/TestDocumentsProvider.java
+++ b/core/tests/coretests/src/android/provider/TestDocumentsProvider.java
@@ -85,7 +85,7 @@
}
@Override
- public Path findPath(String documentId, @Nullable String parentDocumentId) {
+ public Path findDocumentPath(String documentId, @Nullable String parentDocumentId) {
lastDocumentId = documentId;
lastParentDocumentId = parentDocumentId;
diff --git a/packages/ExternalStorageProvider/src/com/android/externalstorage/ExternalStorageProvider.java b/packages/ExternalStorageProvider/src/com/android/externalstorage/ExternalStorageProvider.java
index 4e6f3d0..9af20d0 100644
--- a/packages/ExternalStorageProvider/src/com/android/externalstorage/ExternalStorageProvider.java
+++ b/packages/ExternalStorageProvider/src/com/android/externalstorage/ExternalStorageProvider.java
@@ -445,7 +445,7 @@
}
@Override
- public Path findPath(String childDocId, @Nullable String parentDocId)
+ public Path findDocumentPath(String childDocId, @Nullable String parentDocId)
throws FileNotFoundException {
LinkedList<String> path = new LinkedList<>();