Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 52c866ee authored by Sami Kyostila's avatar Sami Kyostila
Browse files

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
parent 200cd63f
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -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();
+5 −0
Original line number Diff line number Diff line
@@ -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);
}