Add the metrics for DVR status
Metrics review request: b/155199791 Metrics design review is updated at https://eldar.corp.google.com/assessments/937523088/drafts/927800491 bug: 154661158 Test: Manual Change-Id: I3142b0737f7469a79a526281b75a06d3dbf97483
This commit is contained in:
@@ -446,6 +446,7 @@ message Atom {
|
||||
277 [(module) = "settings"];
|
||||
CellBroadcastMessageFiltered cb_message_filtered =
|
||||
278 [(module) = "cellbroadcast"];
|
||||
TvTunerDvrStatus tv_tuner_dvr_status = 279 [(module) = "framework"];
|
||||
|
||||
// StatsdStats tracks platform atoms with ids upto 500.
|
||||
// Update StatsdStats::kMaxPushedAtomId when atom ids here approach that value.
|
||||
@@ -9242,6 +9243,36 @@ message TvTunerStateChanged {
|
||||
// new state
|
||||
optional State state = 2;
|
||||
}
|
||||
|
||||
/**
|
||||
* Logs the status of a dvr playback or record.
|
||||
* This is atom ID 279.
|
||||
*
|
||||
* Logged from:
|
||||
* frameworks/base/media/java/android/media/tv/tuner/dvr
|
||||
*/
|
||||
message TvTunerDvrStatus {
|
||||
enum Type {
|
||||
UNKNOWN_TYPE = 0;
|
||||
PLAYBACK = 1; // is a playback
|
||||
RECORD = 2; // is a record
|
||||
}
|
||||
enum State {
|
||||
UNKNOWN_STATE = 0;
|
||||
STARTED = 1; // DVR is started
|
||||
STOPPED = 2; // DVR is stopped
|
||||
}
|
||||
// The uid of the application that sent this custom atom.
|
||||
optional int32 uid = 1 [(is_uid) = true];
|
||||
// DVR type
|
||||
optional Type type = 2;
|
||||
// DVR state
|
||||
optional State state = 3;
|
||||
// Identify the segment of a record or playback
|
||||
optional int32 segment_id = 4;
|
||||
// indicate how many overflow or underflow happened between started to stopped
|
||||
optional int32 overflow_underflow_count = 5;
|
||||
}
|
||||
/**
|
||||
* Logs when an app is frozen or unfrozen.
|
||||
*
|
||||
|
||||
@@ -20,12 +20,16 @@ import android.annotation.BytesLong;
|
||||
import android.annotation.IntDef;
|
||||
import android.annotation.NonNull;
|
||||
import android.annotation.SystemApi;
|
||||
import android.app.ActivityManager;
|
||||
import android.hardware.tv.tuner.V1_0.Constants;
|
||||
import android.media.tv.tuner.Tuner;
|
||||
import android.media.tv.tuner.Tuner.Result;
|
||||
import android.media.tv.tuner.TunerUtils;
|
||||
import android.media.tv.tuner.filter.Filter;
|
||||
import android.os.ParcelFileDescriptor;
|
||||
import android.util.Log;
|
||||
|
||||
import com.android.internal.util.FrameworkStatsLog;
|
||||
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
@@ -72,9 +76,15 @@ public class DvrPlayback implements AutoCloseable {
|
||||
*/
|
||||
public static final int PLAYBACK_STATUS_FULL = Constants.PlaybackStatus.SPACE_FULL;
|
||||
|
||||
private static final String TAG = "TvTunerPlayback";
|
||||
|
||||
private long mNativeContext;
|
||||
private OnPlaybackStatusChangedListener mListener;
|
||||
private Executor mExecutor;
|
||||
private int mUserId;
|
||||
private static int sInstantId = 0;
|
||||
private int mSegmentId = 0;
|
||||
private int mUnderflow;
|
||||
|
||||
private native int nativeAttachFilter(Filter filter);
|
||||
private native int nativeDetachFilter(Filter filter);
|
||||
@@ -88,6 +98,9 @@ public class DvrPlayback implements AutoCloseable {
|
||||
private native long nativeRead(byte[] bytes, long offset, long size);
|
||||
|
||||
private DvrPlayback() {
|
||||
mUserId = ActivityManager.getCurrentUser();
|
||||
mSegmentId = (sInstantId & 0x0000ffff) << 16;
|
||||
sInstantId++;
|
||||
}
|
||||
|
||||
/** @hide */
|
||||
@@ -98,6 +111,9 @@ public class DvrPlayback implements AutoCloseable {
|
||||
}
|
||||
|
||||
private void onPlaybackStatusChanged(int status) {
|
||||
if (status == PLAYBACK_STATUS_EMPTY) {
|
||||
mUnderflow++;
|
||||
}
|
||||
if (mExecutor != null && mListener != null) {
|
||||
mExecutor.execute(() -> mListener.onPlaybackStatusChanged(status));
|
||||
}
|
||||
@@ -154,6 +170,13 @@ public class DvrPlayback implements AutoCloseable {
|
||||
*/
|
||||
@Result
|
||||
public int start() {
|
||||
mSegmentId = (mSegmentId & 0xffff0000) | (((mSegmentId & 0x0000ffff) + 1) & 0x0000ffff);
|
||||
mUnderflow = 0;
|
||||
Log.d(TAG, "Write Stats Log for Playback.");
|
||||
FrameworkStatsLog
|
||||
.write(FrameworkStatsLog.TV_TUNER_DVR_STATUS, mUserId,
|
||||
FrameworkStatsLog.TV_TUNER_DVR_STATUS__TYPE__PLAYBACK,
|
||||
FrameworkStatsLog.TV_TUNER_DVR_STATUS__STATE__STARTED, mSegmentId, 0);
|
||||
return nativeStartDvr();
|
||||
}
|
||||
|
||||
@@ -167,6 +190,11 @@ public class DvrPlayback implements AutoCloseable {
|
||||
*/
|
||||
@Result
|
||||
public int stop() {
|
||||
Log.d(TAG, "Write Stats Log for Playback.");
|
||||
FrameworkStatsLog
|
||||
.write(FrameworkStatsLog.TV_TUNER_DVR_STATUS, mUserId,
|
||||
FrameworkStatsLog.TV_TUNER_DVR_STATUS__TYPE__PLAYBACK,
|
||||
FrameworkStatsLog.TV_TUNER_DVR_STATUS__STATE__STOPPED, mSegmentId, mUnderflow);
|
||||
return nativeStopDvr();
|
||||
}
|
||||
|
||||
|
||||
@@ -19,14 +19,19 @@ package android.media.tv.tuner.dvr;
|
||||
import android.annotation.BytesLong;
|
||||
import android.annotation.NonNull;
|
||||
import android.annotation.SystemApi;
|
||||
import android.app.ActivityManager;
|
||||
import android.media.tv.tuner.Tuner;
|
||||
import android.media.tv.tuner.Tuner.Result;
|
||||
import android.media.tv.tuner.TunerUtils;
|
||||
import android.media.tv.tuner.filter.Filter;
|
||||
import android.os.ParcelFileDescriptor;
|
||||
import android.util.Log;
|
||||
|
||||
import com.android.internal.util.FrameworkStatsLog;
|
||||
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
|
||||
/**
|
||||
* Digital Video Record (DVR) recorder class which provides record control on Demux's output buffer.
|
||||
*
|
||||
@@ -34,9 +39,14 @@ import java.util.concurrent.Executor;
|
||||
*/
|
||||
@SystemApi
|
||||
public class DvrRecorder implements AutoCloseable {
|
||||
private static final String TAG = "TvTunerRecord";
|
||||
private long mNativeContext;
|
||||
private OnRecordStatusChangedListener mListener;
|
||||
private Executor mExecutor;
|
||||
private int mUserId;
|
||||
private static int sInstantId = 0;
|
||||
private int mSegmentId = 0;
|
||||
private int mOverflow;
|
||||
|
||||
private native int nativeAttachFilter(Filter filter);
|
||||
private native int nativeDetachFilter(Filter filter);
|
||||
@@ -50,6 +60,9 @@ public class DvrRecorder implements AutoCloseable {
|
||||
private native long nativeWrite(byte[] bytes, long offset, long size);
|
||||
|
||||
private DvrRecorder() {
|
||||
mUserId = ActivityManager.getCurrentUser();
|
||||
mSegmentId = (sInstantId & 0x0000ffff) << 16;
|
||||
sInstantId++;
|
||||
}
|
||||
|
||||
/** @hide */
|
||||
@@ -60,6 +73,9 @@ public class DvrRecorder implements AutoCloseable {
|
||||
}
|
||||
|
||||
private void onRecordStatusChanged(int status) {
|
||||
if (status == Filter.STATUS_OVERFLOW) {
|
||||
mOverflow++;
|
||||
}
|
||||
if (mExecutor != null && mListener != null) {
|
||||
mExecutor.execute(() -> mListener.onRecordStatusChanged(status));
|
||||
}
|
||||
@@ -112,6 +128,13 @@ public class DvrRecorder implements AutoCloseable {
|
||||
*/
|
||||
@Result
|
||||
public int start() {
|
||||
mSegmentId = (mSegmentId & 0xffff0000) | (((mSegmentId & 0x0000ffff) + 1) & 0x0000ffff);
|
||||
mOverflow = 0;
|
||||
Log.d(TAG, "Write Stats Log for Record.");
|
||||
FrameworkStatsLog
|
||||
.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();
|
||||
}
|
||||
|
||||
@@ -124,6 +147,11 @@ public class DvrRecorder implements AutoCloseable {
|
||||
*/
|
||||
@Result
|
||||
public int stop() {
|
||||
Log.d(TAG, "Write Stats Log for Playback.");
|
||||
FrameworkStatsLog
|
||||
.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();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user