diff --git a/core/java/android/provider/DocumentsContract.java b/core/java/android/provider/DocumentsContract.java index 20c7073873acf..59a8fdab043bd 100644 --- a/core/java/android/provider/DocumentsContract.java +++ b/core/java/android/provider/DocumentsContract.java @@ -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 findPath(ContentResolver resolver, Uri treeUri) { + public static List 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); } diff --git a/core/java/android/provider/DocumentsProvider.java b/core/java/android/provider/DocumentsProvider.java index 4256484b74c25..1df4dbd7c4c59 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_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) { diff --git a/core/tests/coretests/src/android/provider/DocumentsProviderTest.java b/core/tests/coretests/src/android/provider/DocumentsProviderTest.java index 71546e4b323b8..d1c68a92b6e76 100644 --- a/core/tests/coretests/src/android/provider/DocumentsProviderTest.java +++ b/core/tests/coretests/src/android/provider/DocumentsProviderTest.java @@ -60,7 +60,7 @@ public class DocumentsProviderTest extends ProviderTestCase2 actual = DocumentsContract.findPath(mResolver, docUri); + final List actual = DocumentsContract.findDocumentPath(mResolver, docUri); assertEquals(expected.getPath(), actual); } @@ -83,7 +83,7 @@ public class DocumentsProviderTest extends ProviderTestCase2 path = new LinkedList<>();