diff options
| author | Dan Egnor <egnor@google.com> | 2009-11-25 12:38:00 -0800 |
|---|---|---|
| committer | Dan Egnor <egnor@google.com> | 2009-11-25 12:38:00 -0800 |
| commit | eb7a7d57ca50f85b054edadab766b51ff22a2dfd (patch) | |
| tree | 556e05254f66359607699f4dcca123143052e0c4 /core/java | |
| parent | a85a0ac1072c7653fdafa791416658154b76ac0d (diff) | |
Change the DropBoxManager API slightly (this is public, but not yet released) --
take a File instead of a ParcelFileDescriptor (gets opened internally) --
that way the caller doesn't have to worry about closing their PFD and so on.
(Pretty much 100% of the time the caller will be uploading a file, anyway.)
Diffstat (limited to 'core/java')
| -rw-r--r-- | core/java/android/os/DropBoxManager.java | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/core/java/android/os/DropBoxManager.java b/core/java/android/os/DropBoxManager.java index 782767686a91..7889a92286c1 100644 --- a/core/java/android/os/DropBoxManager.java +++ b/core/java/android/os/DropBoxManager.java @@ -230,17 +230,24 @@ public class DropBoxManager { } /** - * Stores data read from a file descriptor. The data may be ignored or - * discarded as with {@link #addText}. You must close your - * ParcelFileDescriptor object after calling this method! + * Stores the contents of a file, which may be ignored or discarded as with + * {@link #addText}. * * @param tag describing the type of entry being stored - * @param fd file descriptor to read from + * @param file to read from * @param flags describing the data + * @throws IOException if the file can't be opened */ - public void addFile(String tag, ParcelFileDescriptor fd, int flags) { - if (fd == null) throw new NullPointerException(); - try { mService.add(new Entry(tag, 0, fd, flags)); } catch (RemoteException e) {} + public void addFile(String tag, File file, int flags) throws IOException { + if (file == null) throw new NullPointerException(); + Entry entry = new Entry(tag, 0, file, flags); + try { + mService.add(new Entry(tag, 0, file, flags)); + } catch (RemoteException e) { + // ignore + } finally { + entry.close(); + } } /** |
