summaryrefslogtreecommitdiff
path: root/test-mock/src
diff options
context:
space:
mode:
authorDmitri Plotnikov <dplotnikov@google.com>2020-02-14 17:04:13 -0800
committerDmitri Plotnikov <dplotnikov@google.com>2020-02-19 11:58:26 -0800
commit7a223fbcf1a56a67931afb13eaf2445fb71dec43 (patch)
tree808d7b7ad9f6ceef0e140ad574b082c36b03da39 /test-mock/src
parent80fedffc34d7e7acd545abad11b9c898f2e2e000 (diff)
Add async version of "canonicalize"
Fixes: b/147699082 Test: atest FrameworksCoreTests:android.content.ContentResolverTest Change-Id: I2e851839a454ad5eabc981c76774d03b57a1aa09
Diffstat (limited to 'test-mock/src')
-rw-r--r--test-mock/src/android/test/mock/MockContentProvider.java18
-rw-r--r--test-mock/src/android/test/mock/MockIContentProvider.java15
2 files changed, 31 insertions, 2 deletions
diff --git a/test-mock/src/android/test/mock/MockContentProvider.java b/test-mock/src/android/test/mock/MockContentProvider.java
index f7ec11c79476..d1d64d39b688 100644
--- a/test-mock/src/android/test/mock/MockContentProvider.java
+++ b/test-mock/src/android/test/mock/MockContentProvider.java
@@ -156,6 +156,12 @@ public class MockContentProvider extends ContentProvider {
}
@Override
+ public void canonicalizeAsync(String callingPkg, String featureId, Uri uri,
+ RemoteCallback callback) {
+ MockContentProvider.this.canonicalizeAsync(uri, callback);
+ }
+
+ @Override
public Uri uncanonicalize(String callingPkg, @Nullable String featureId, Uri uri)
throws RemoteException {
return MockContentProvider.this.uncanonicalize(uri);
@@ -292,6 +298,18 @@ public class MockContentProvider extends ContentProvider {
/**
* @hide
*/
+ @SuppressWarnings("deprecation")
+ public void canonicalizeAsync(Uri uri, RemoteCallback callback) {
+ AsyncTask.SERIAL_EXECUTOR.execute(() -> {
+ final Bundle bundle = new Bundle();
+ bundle.putParcelable(ContentResolver.REMOTE_CALLBACK_RESULT, canonicalize(uri));
+ callback.sendResult(bundle);
+ });
+ }
+
+ /**
+ * @hide
+ */
public boolean refresh(Uri url, Bundle args) {
throw new UnsupportedOperationException("unimplemented mock method call");
}
diff --git a/test-mock/src/android/test/mock/MockIContentProvider.java b/test-mock/src/android/test/mock/MockIContentProvider.java
index 1831bcdf9df7..223bcc59039d 100644
--- a/test-mock/src/android/test/mock/MockIContentProvider.java
+++ b/test-mock/src/android/test/mock/MockIContentProvider.java
@@ -145,12 +145,23 @@ public class MockIContentProvider implements IContentProvider {
}
@Override
- public Uri canonicalize(String callingPkg, @Nullable String featureId, Uri uri)
- throws RemoteException {
+ public Uri canonicalize(String callingPkg, @Nullable String featureId, Uri uri) {
throw new UnsupportedOperationException("unimplemented mock method");
}
@Override
+ @SuppressWarnings("deprecation")
+ public void canonicalizeAsync(String callingPkg, String featureId, Uri uri,
+ RemoteCallback remoteCallback) {
+ AsyncTask.SERIAL_EXECUTOR.execute(() -> {
+ final Bundle bundle = new Bundle();
+ bundle.putParcelable(ContentResolver.REMOTE_CALLBACK_RESULT,
+ canonicalize(callingPkg, featureId, uri));
+ remoteCallback.sendResult(bundle);
+ });
+ }
+
+ @Override
public Uri uncanonicalize(String callingPkg, @Nullable String featureId, Uri uri)
throws RemoteException {
throw new UnsupportedOperationException("unimplemented mock method");