summaryrefslogtreecommitdiffstats
path: root/test-runner/src
diff options
context:
space:
mode:
authorDianne Hackborn <hackbod@google.com>2010-08-06 12:16:55 -0700
committerDianne Hackborn <hackbod@google.com>2010-08-08 18:49:31 -0700
commit23fdaf6fb62a9b5154b2508916a21c678462c5d0 (patch)
tree14b794a1f76f738576bbaa8295141914f5b2b123 /test-runner/src
parent163935113919a184122b8b3bd672ef08c8df65dc (diff)
downloadframeworks_base-23fdaf6fb62a9b5154b2508916a21c678462c5d0.zip
frameworks_base-23fdaf6fb62a9b5154b2508916a21c678462c5d0.tar.gz
frameworks_base-23fdaf6fb62a9b5154b2508916a21c678462c5d0.tar.bz2
Add new ContentProvider for doing conversions to data streams.
This introduces basic infrastructure that should allow content providers holding complex data to perform on-demand conversion of their data to streams of various types. It is achieved through two new content provider APIs, one to interrogate the possible stream MIME types the provider can return, and the other to request a stream of data in a particular MIME type. Because implementations of this will often need to do on-demand data conversion, there is also a utility intoduced in ContentProvider for subclasses to easily run a function to write data into a pipe that is read by the client. This feature is mostly intended for cut and paste and drag and drop, as the complex data interchange allowing the source and destination to negotiate data types and copy (possible large) data between them. However because it is fundamental facility of ContentProvider, it can be used in other places, such as for more advanced GET_CONTENT data exchanges. An example implementation of this would be in ContactsProvider, which can now provider a data stream when a client opens certain pieces of it data, to return data as flat text, a vcard, or other format. Change-Id: I58627ea4ed359aa7cf2c66274adb18306c209cb2
Diffstat (limited to 'test-runner/src')
-rw-r--r--test-runner/src/android/test/mock/MockContentProvider.java18
-rw-r--r--test-runner/src/android/test/mock/MockIContentProvider.java10
2 files changed, 28 insertions, 0 deletions
diff --git a/test-runner/src/android/test/mock/MockContentProvider.java b/test-runner/src/android/test/mock/MockContentProvider.java
index 3fd71c8..b63ff3d 100644
--- a/test-runner/src/android/test/mock/MockContentProvider.java
+++ b/test-runner/src/android/test/mock/MockContentProvider.java
@@ -127,6 +127,16 @@ public class MockContentProvider extends ContentProvider {
throw new UnsupportedOperationException();
}
+ @SuppressWarnings("unused")
+ public String[] getStreamTypes(Uri url, String mimeTypeFilter) throws RemoteException {
+ return MockContentProvider.this.getStreamTypes(url, mimeTypeFilter);
+ }
+
+ @SuppressWarnings("unused")
+ public AssetFileDescriptor openTypedAssetFile(Uri url, String mimeType, Bundle opts)
+ throws RemoteException, FileNotFoundException {
+ return MockContentProvider.this.openTypedAssetFile(url, mimeType, opts);
+ }
}
private final InversionIContentProvider mIContentProvider = new InversionIContentProvider();
@@ -222,6 +232,14 @@ public class MockContentProvider extends ContentProvider {
throw new UnsupportedOperationException("unimplemented mock method call");
}
+ public String[] getStreamTypes(Uri url, String mimeTypeFilter) {
+ throw new UnsupportedOperationException("unimplemented mock method call");
+ }
+
+ public AssetFileDescriptor openTypedAssetFile(Uri url, String mimeType, Bundle opts) {
+ throw new UnsupportedOperationException("unimplemented mock method call");
+ }
+
/**
* Returns IContentProvider which calls back same methods in this class.
* By overriding this class, we avoid the mechanism hidden behind ContentProvider
diff --git a/test-runner/src/android/test/mock/MockIContentProvider.java b/test-runner/src/android/test/mock/MockIContentProvider.java
index 0be5bea..183be41 100644
--- a/test-runner/src/android/test/mock/MockIContentProvider.java
+++ b/test-runner/src/android/test/mock/MockIContentProvider.java
@@ -32,6 +32,7 @@ import android.os.IBinder;
import android.os.ParcelFileDescriptor;
import android.os.RemoteException;
+import java.io.FileNotFoundException;
import java.util.ArrayList;
/**
@@ -102,4 +103,13 @@ public class MockIContentProvider implements IContentProvider {
public IBinder asBinder() {
throw new UnsupportedOperationException("unimplemented mock method");
}
+
+ public String[] getStreamTypes(Uri url, String mimeTypeFilter) throws RemoteException {
+ throw new UnsupportedOperationException("unimplemented mock method");
+ }
+
+ public AssetFileDescriptor openTypedAssetFile(Uri url, String mimeType, Bundle opts)
+ throws RemoteException, FileNotFoundException {
+ throw new UnsupportedOperationException("unimplemented mock method");
+ }
}