diff options
author | Sami Kyostila <skyostil@google.com> | 2018-01-12 18:28:13 +0000 |
---|---|---|
committer | Sami Kyostila <skyostil@google.com> | 2018-01-12 19:04:02 +0000 |
commit | 52c866eea41549d0efc4d09f95f0c6d401b78b82 (patch) | |
tree | d786c2fa47853888c11d0984133ae8315022cdff /libs/services | |
parent | 200cd63fb3ff5b4354773e9994f4340f18b39cbc (diff) |
DropBoxManager: Allow adding a file using an fd
This patch adds an overload to DropBoxManager::addFile() which accepts
an already-opened file as a file descriptor. This avoids the need for
clients to create a filesystem-visible file when uploading data to
DropBox.
Test: Tested with perfetto using https://android-review.googlesource.com/c/platform/external/perfetto/+/587674
Change-Id: I076bfd3180fb9b4baff7e1bae2e611419061b2a7
Diffstat (limited to 'libs/services')
-rw-r--r-- | libs/services/include/android/os/DropBoxManager.h | 4 | ||||
-rw-r--r-- | libs/services/src/os/DropBoxManager.cpp | 5 |
2 files changed, 9 insertions, 0 deletions
diff --git a/libs/services/include/android/os/DropBoxManager.h b/libs/services/include/android/os/DropBoxManager.h index 2ed203d9f865..75b26c626d14 100644 --- a/libs/services/include/android/os/DropBoxManager.h +++ b/libs/services/include/android/os/DropBoxManager.h @@ -58,6 +58,10 @@ public: // are required from the system process. Returns NULL if the file can't be opened. Status addFile(const String16& tag, const string& filename, int flags); + // Create a new Entry from an already opened file. Takes ownership of the + // file descriptor. + Status addFile(const String16& tag, int fd, int flags); + class Entry : public virtual RefBase, public Parcelable { public: Entry(); diff --git a/libs/services/src/os/DropBoxManager.cpp b/libs/services/src/os/DropBoxManager.cpp index 1c760e850e4f..f5685d9ca753 100644 --- a/libs/services/src/os/DropBoxManager.cpp +++ b/libs/services/src/os/DropBoxManager.cpp @@ -202,7 +202,12 @@ DropBoxManager::addFile(const String16& tag, const string& filename, int flags) ALOGW("DropboxManager: %s", message.c_str()); return Status::fromExceptionCode(Status::EX_ILLEGAL_STATE, message.c_str()); } + return addFile(tag, fd, flags); +} +Status +DropBoxManager::addFile(const String16& tag, int fd, int flags) +{ Entry entry(tag, flags, fd); return add(entry); } |