diff --git a/libs/services/include/android/os/DropBoxManager.h b/libs/services/include/android/os/DropBoxManager.h index 8717178bb7d64..3449a7b722835 100644 --- a/libs/services/include/android/os/DropBoxManager.h +++ b/libs/services/include/android/os/DropBoxManager.h @@ -57,7 +57,11 @@ public: // and a handle will be passed to the system process, so no additional permissions // 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 bbb45f022a870..e8e34d7c4cb3a 100644 --- a/libs/services/src/os/DropBoxManager.cpp +++ b/libs/services/src/os/DropBoxManager.cpp @@ -179,7 +179,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); }