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

Commit d7ae0b85 authored by Hangyu Kuang's avatar Hangyu Kuang
Browse files

media: Relax the filedescriptor check to allow write-only mode.

Test: Use the MMS app to record video.
Bug: 34594319
Change-Id: Id89dd1e6fa83e1a126ff8cced065600ce4e0e663
parent efbd36c8
Loading
Loading
Loading
Loading
+12 −6
Original line number Diff line number Diff line
@@ -290,9 +290,12 @@ status_t MediaRecorder::setOutputFile(int fd)
    // this issue by checking the file descriptor first before passing
    // it through binder call.
    int flags = fcntl(fd, F_GETFL);
    // fd must be in read-write mode.
    if (flags == -1 || (flags & O_RDWR) == 0) {
        ALOGE("Invalid file descriptor: %d err: %s", fd, strerror(errno));
    if (flags == -1) {
        ALOGE("Fail to get File Status Flags err: %s", strerror(errno));
    }
    // fd must be in read-write mode or write-only mode.
    if ((flags & (O_RDWR | O_WRONLY)) == 0) {
        ALOGE("File descriptor is not in read-write mode or write-only mode");
        return BAD_VALUE;
    }

@@ -321,9 +324,12 @@ status_t MediaRecorder::setNextOutputFile(int fd)
    // this issue by checking the file descriptor first before passing
    // it through binder call.
    int flags = fcntl(fd, F_GETFL);
    // fd must be in read-write mode.
    if (flags == -1 || (flags & O_RDWR) == 0) {
        ALOGE("Invalid file descriptor: %d err: %s", fd, strerror(errno));
    if (flags == -1) {
        ALOGE("Fail to get File Status Flags err: %s", strerror(errno));
    }
    // fd must be in read-write mode or write-only mode.
    if ((flags & (O_RDWR | O_WRONLY)) == 0) {
        ALOGE("File descriptor is not in read-write mode or write-only mode");
        return BAD_VALUE;
    }