From ec2bc8d99fe9fad5f6e829b259b78a2bd58c4a76 Mon Sep 17 00:00:00 2001 From: Dmitri Plotnikov Date: Fri, 23 Oct 2020 15:47:19 -0700 Subject: Add async version of "uncanonicalize" This CL is basically identical to http://ag/10353234, which did the same with the sister method, "canonicalize". Fixes: b/147705670 Test: atest FrameworksCoreTests:android.content.ContentResolverTest Change-Id: Ide93850f225cdd61779a62fc2c4666efe438b536 --- .../src/android/test/mock/MockContentProvider.java | 18 ++++++++++++++++++ .../src/android/test/mock/MockIContentProvider.java | 15 +++++++++++++-- 2 files changed, 31 insertions(+), 2 deletions(-) (limited to 'test-mock/src') diff --git a/test-mock/src/android/test/mock/MockContentProvider.java b/test-mock/src/android/test/mock/MockContentProvider.java index a5c254f1aca2..5b9f67efd95d 100644 --- a/test-mock/src/android/test/mock/MockContentProvider.java +++ b/test-mock/src/android/test/mock/MockContentProvider.java @@ -168,6 +168,12 @@ public class MockContentProvider extends ContentProvider { return MockContentProvider.this.uncanonicalize(uri); } + @Override + public void uncanonicalizeAsync(String callingPkg, String featureId, Uri uri, + RemoteCallback callback) { + MockContentProvider.this.uncanonicalizeAsync(uri, callback); + } + @Override public boolean refresh(String callingPkg, @Nullable String featureId, Uri url, Bundle args, ICancellationSignal cancellationSignal) throws RemoteException { @@ -308,6 +314,18 @@ public class MockContentProvider extends ContentProvider { }); } + /** + * @hide + */ + @SuppressWarnings("deprecation") + public void uncanonicalizeAsync(Uri uri, RemoteCallback callback) { + AsyncTask.SERIAL_EXECUTOR.execute(() -> { + final Bundle bundle = new Bundle(); + bundle.putParcelable(ContentResolver.REMOTE_CALLBACK_RESULT, uncanonicalize(uri)); + callback.sendResult(bundle); + }); + } + /** * @hide */ diff --git a/test-mock/src/android/test/mock/MockIContentProvider.java b/test-mock/src/android/test/mock/MockIContentProvider.java index 223bcc59039d..82a1cf7d1796 100644 --- a/test-mock/src/android/test/mock/MockIContentProvider.java +++ b/test-mock/src/android/test/mock/MockIContentProvider.java @@ -162,11 +162,22 @@ public class MockIContentProvider implements IContentProvider { } @Override - public Uri uncanonicalize(String callingPkg, @Nullable String featureId, Uri uri) - throws RemoteException { + public Uri uncanonicalize(String callingPkg, @Nullable String featureId, Uri uri) { throw new UnsupportedOperationException("unimplemented mock method"); } + @Override + @SuppressWarnings("deprecation") + public void uncanonicalizeAsync(String callingPkg, String featureId, Uri uri, + RemoteCallback remoteCallback) { + AsyncTask.SERIAL_EXECUTOR.execute(() -> { + final Bundle bundle = new Bundle(); + bundle.putParcelable(ContentResolver.REMOTE_CALLBACK_RESULT, + uncanonicalize(callingPkg, featureId, uri)); + remoteCallback.sendResult(bundle); + }); + } + @Override public boolean refresh(String callingPkg, @Nullable String featureId, Uri url, Bundle args, ICancellationSignal cancellationSignal) throws RemoteException { -- cgit v1.2.3-59-g8ed1b