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

Commit ff5d180d authored by Amy Zhang's avatar Amy Zhang Committed by Automerger Merge Worker
Browse files

Merge "Only allow RecordDVR to flush buffer when the DVR is stopped" am: 30e3efaa am: 6c28ea88

Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1554520

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: I84ee8ce707bb48ec12bb453200eaeec1c5244ed4
parents 396957ac 6c28ea88
Loading
Loading
Loading
Loading
+22 −3
Original line number Diff line number Diff line
@@ -47,6 +47,7 @@ public class DvrRecorder implements AutoCloseable {
    private static int sInstantId = 0;
    private int mSegmentId = 0;
    private int mOverflow;
    private Boolean mIsStopped = null;

    private native int nativeAttachFilter(Filter filter);
    private native int nativeDetachFilter(Filter filter);
@@ -135,7 +136,13 @@ public class DvrRecorder implements AutoCloseable {
                .write(FrameworkStatsLog.TV_TUNER_DVR_STATUS, mUserId,
                    FrameworkStatsLog.TV_TUNER_DVR_STATUS__TYPE__RECORD,
                    FrameworkStatsLog.TV_TUNER_DVR_STATUS__STATE__STARTED, mSegmentId, 0);
        return nativeStartDvr();
        synchronized (mIsStopped) {
            int result = nativeStartDvr();
            if (result == Tuner.RESULT_SUCCESS) {
                mIsStopped = false;
            }
            return result;
        }
    }

    /**
@@ -152,7 +159,13 @@ public class DvrRecorder implements AutoCloseable {
                .write(FrameworkStatsLog.TV_TUNER_DVR_STATUS, mUserId,
                    FrameworkStatsLog.TV_TUNER_DVR_STATUS__TYPE__RECORD,
                    FrameworkStatsLog.TV_TUNER_DVR_STATUS__STATE__STOPPED, mSegmentId, mOverflow);
        return nativeStopDvr();
        synchronized (mIsStopped) {
            int result = nativeStopDvr();
            if (result == Tuner.RESULT_SUCCESS) {
                mIsStopped = true;
            }
            return result;
        }
    }

    /**
@@ -164,8 +177,14 @@ public class DvrRecorder implements AutoCloseable {
     */
    @Result
    public int flush() {
        synchronized (mIsStopped) {
            if (mIsStopped) {
                return nativeFlushDvr();
            }
            Log.w(TAG, "Cannot flush non-stopped Record DVR.");
            return Tuner.RESULT_INVALID_STATE;
        }
    }

    /**
     * Closes the DVR instance to release resources.