Loading cmds/statsd/src/atoms.proto +55 −0 Original line number Diff line number Diff line Loading @@ -446,6 +446,9 @@ message Atom { 277 [(module) = "settings"]; CellBroadcastMessageFiltered cb_message_filtered = 278 [(module) = "cellbroadcast"]; TvTunerDvrStatus tv_tuner_dvr_status = 279 [(module) = "framework"]; TvCasSessionOpenStatus tv_cas_session_open_status = 280 [(module) = "framework"]; // StatsdStats tracks platform atoms with ids upto 500. // Update StatsdStats::kMaxPushedAtomId when atom ids here approach that value. Loading Loading @@ -9242,6 +9245,58 @@ 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 a cas session opened through MediaCas. * This is atom ID 280. * * Logged from: * frameworks/base/media/java/android/media/MediaCas.java */ message TvCasSessionOpenStatus { enum State { UNKNOWN = 0; SUCCEEDED = 1; // indicate that the session is opened successfully. FAILED = 2; // indicate that the session isn’t opened successfully. } // The uid of the application that sent this custom atom. optional int32 uid = 1 [(is_uid) = true]; // Cas system Id optional int32 cas_system_id = 2; // State of the session optional State state = 3; } /** * Logs when an app is frozen or unfrozen. * Loading media/java/android/media/MediaCas.java +22 −1 Original line number Diff line number Diff line Loading @@ -20,6 +20,7 @@ import android.annotation.IntDef; import android.annotation.NonNull; import android.annotation.Nullable; import android.annotation.TestApi; import android.app.ActivityManager; import android.content.Context; import android.hardware.cas.V1_0.HidlCasPluginDescriptor; import android.hardware.cas.V1_0.ICas; Loading @@ -43,6 +44,8 @@ import android.os.RemoteException; import android.util.Log; import android.util.Singleton; import com.android.internal.util.FrameworkStatsLog; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.util.ArrayList; Loading Loading @@ -122,6 +125,7 @@ public final class MediaCas implements AutoCloseable { private String mTvInputServiceSessionId; private int mClientId; private int mCasSystemId; private int mUserId; private TunerResourceManager mTunerResourceManager = null; private final Map<Session, Integer> mSessionMap = new HashMap<>(); Loading Loading @@ -673,6 +677,8 @@ public final class MediaCas implements AutoCloseable { */ public MediaCas(int CA_system_id) throws UnsupportedCasException { try { mCasSystemId = CA_system_id; mUserId = ActivityManager.getCurrentUser(); IMediaCasService service = getService(); android.hardware.cas.V1_2.IMediaCasService serviceV12 = android.hardware.cas.V1_2.IMediaCasService.castFrom(service); Loading Loading @@ -721,7 +727,6 @@ public final class MediaCas implements AutoCloseable { this(casSystemId); Objects.requireNonNull(context, "context must not be null"); mCasSystemId = casSystemId; mTunerResourceManager = (TunerResourceManager) context.getSystemService(Context.TV_TUNER_RESOURCE_MGR_SERVICE); if (mTunerResourceManager != null) { Loading Loading @@ -925,10 +930,18 @@ public final class MediaCas implements AutoCloseable { mICas.openSession(cb); MediaCasException.throwExceptionIfNeeded(cb.mStatus); addSessionToResourceMap(cb.mSession, sessionResourceHandle); Log.d(TAG, "Write Stats Log for succeed to Open Session."); FrameworkStatsLog .write(FrameworkStatsLog.TV_CAS_SESSION_OPEN_STATUS, mUserId, mCasSystemId, FrameworkStatsLog.TV_CAS_SESSION_OPEN_STATUS__STATE__SUCCEEDED); return cb.mSession; } catch (RemoteException e) { cleanupAndRethrowIllegalState(); } Log.d(TAG, "Write Stats Log for fail to Open Session."); FrameworkStatsLog .write(FrameworkStatsLog.TV_CAS_SESSION_OPEN_STATUS, mUserId, mCasSystemId, FrameworkStatsLog.TV_CAS_SESSION_OPEN_STATUS__STATE__FAILED); return null; } Loading Loading @@ -964,10 +977,18 @@ public final class MediaCas implements AutoCloseable { mICasV12.openSession_1_2(sessionUsage, scramblingMode, cb); MediaCasException.throwExceptionIfNeeded(cb.mStatus); addSessionToResourceMap(cb.mSession, sessionResourceHandle); Log.d(TAG, "Write Stats Log for succeed to Open Session."); FrameworkStatsLog .write(FrameworkStatsLog.TV_CAS_SESSION_OPEN_STATUS, mUserId, mCasSystemId, FrameworkStatsLog.TV_CAS_SESSION_OPEN_STATUS__STATE__SUCCEEDED); return cb.mSession; } catch (RemoteException e) { cleanupAndRethrowIllegalState(); } Log.d(TAG, "Write Stats Log for fail to Open Session."); FrameworkStatsLog .write(FrameworkStatsLog.TV_CAS_SESSION_OPEN_STATUS, mUserId, mCasSystemId, FrameworkStatsLog.TV_CAS_SESSION_OPEN_STATUS__STATE__FAILED); return null; } Loading media/java/android/media/tv/tuner/dvr/DvrPlayback.java +28 −0 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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); Loading @@ -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 */ Loading @@ -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)); } Loading Loading @@ -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(); } Loading @@ -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(); } Loading media/java/android/media/tv/tuner/dvr/DvrRecorder.java +28 −0 Original line number Diff line number Diff line Loading @@ -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. * Loading @@ -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); Loading @@ -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 */ Loading @@ -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)); } Loading Loading @@ -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(); } Loading @@ -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(); } Loading Loading
cmds/statsd/src/atoms.proto +55 −0 Original line number Diff line number Diff line Loading @@ -446,6 +446,9 @@ message Atom { 277 [(module) = "settings"]; CellBroadcastMessageFiltered cb_message_filtered = 278 [(module) = "cellbroadcast"]; TvTunerDvrStatus tv_tuner_dvr_status = 279 [(module) = "framework"]; TvCasSessionOpenStatus tv_cas_session_open_status = 280 [(module) = "framework"]; // StatsdStats tracks platform atoms with ids upto 500. // Update StatsdStats::kMaxPushedAtomId when atom ids here approach that value. Loading Loading @@ -9242,6 +9245,58 @@ 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 a cas session opened through MediaCas. * This is atom ID 280. * * Logged from: * frameworks/base/media/java/android/media/MediaCas.java */ message TvCasSessionOpenStatus { enum State { UNKNOWN = 0; SUCCEEDED = 1; // indicate that the session is opened successfully. FAILED = 2; // indicate that the session isn’t opened successfully. } // The uid of the application that sent this custom atom. optional int32 uid = 1 [(is_uid) = true]; // Cas system Id optional int32 cas_system_id = 2; // State of the session optional State state = 3; } /** * Logs when an app is frozen or unfrozen. * Loading
media/java/android/media/MediaCas.java +22 −1 Original line number Diff line number Diff line Loading @@ -20,6 +20,7 @@ import android.annotation.IntDef; import android.annotation.NonNull; import android.annotation.Nullable; import android.annotation.TestApi; import android.app.ActivityManager; import android.content.Context; import android.hardware.cas.V1_0.HidlCasPluginDescriptor; import android.hardware.cas.V1_0.ICas; Loading @@ -43,6 +44,8 @@ import android.os.RemoteException; import android.util.Log; import android.util.Singleton; import com.android.internal.util.FrameworkStatsLog; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.util.ArrayList; Loading Loading @@ -122,6 +125,7 @@ public final class MediaCas implements AutoCloseable { private String mTvInputServiceSessionId; private int mClientId; private int mCasSystemId; private int mUserId; private TunerResourceManager mTunerResourceManager = null; private final Map<Session, Integer> mSessionMap = new HashMap<>(); Loading Loading @@ -673,6 +677,8 @@ public final class MediaCas implements AutoCloseable { */ public MediaCas(int CA_system_id) throws UnsupportedCasException { try { mCasSystemId = CA_system_id; mUserId = ActivityManager.getCurrentUser(); IMediaCasService service = getService(); android.hardware.cas.V1_2.IMediaCasService serviceV12 = android.hardware.cas.V1_2.IMediaCasService.castFrom(service); Loading Loading @@ -721,7 +727,6 @@ public final class MediaCas implements AutoCloseable { this(casSystemId); Objects.requireNonNull(context, "context must not be null"); mCasSystemId = casSystemId; mTunerResourceManager = (TunerResourceManager) context.getSystemService(Context.TV_TUNER_RESOURCE_MGR_SERVICE); if (mTunerResourceManager != null) { Loading Loading @@ -925,10 +930,18 @@ public final class MediaCas implements AutoCloseable { mICas.openSession(cb); MediaCasException.throwExceptionIfNeeded(cb.mStatus); addSessionToResourceMap(cb.mSession, sessionResourceHandle); Log.d(TAG, "Write Stats Log for succeed to Open Session."); FrameworkStatsLog .write(FrameworkStatsLog.TV_CAS_SESSION_OPEN_STATUS, mUserId, mCasSystemId, FrameworkStatsLog.TV_CAS_SESSION_OPEN_STATUS__STATE__SUCCEEDED); return cb.mSession; } catch (RemoteException e) { cleanupAndRethrowIllegalState(); } Log.d(TAG, "Write Stats Log for fail to Open Session."); FrameworkStatsLog .write(FrameworkStatsLog.TV_CAS_SESSION_OPEN_STATUS, mUserId, mCasSystemId, FrameworkStatsLog.TV_CAS_SESSION_OPEN_STATUS__STATE__FAILED); return null; } Loading Loading @@ -964,10 +977,18 @@ public final class MediaCas implements AutoCloseable { mICasV12.openSession_1_2(sessionUsage, scramblingMode, cb); MediaCasException.throwExceptionIfNeeded(cb.mStatus); addSessionToResourceMap(cb.mSession, sessionResourceHandle); Log.d(TAG, "Write Stats Log for succeed to Open Session."); FrameworkStatsLog .write(FrameworkStatsLog.TV_CAS_SESSION_OPEN_STATUS, mUserId, mCasSystemId, FrameworkStatsLog.TV_CAS_SESSION_OPEN_STATUS__STATE__SUCCEEDED); return cb.mSession; } catch (RemoteException e) { cleanupAndRethrowIllegalState(); } Log.d(TAG, "Write Stats Log for fail to Open Session."); FrameworkStatsLog .write(FrameworkStatsLog.TV_CAS_SESSION_OPEN_STATUS, mUserId, mCasSystemId, FrameworkStatsLog.TV_CAS_SESSION_OPEN_STATUS__STATE__FAILED); return null; } Loading
media/java/android/media/tv/tuner/dvr/DvrPlayback.java +28 −0 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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); Loading @@ -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 */ Loading @@ -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)); } Loading Loading @@ -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(); } Loading @@ -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(); } Loading
media/java/android/media/tv/tuner/dvr/DvrRecorder.java +28 −0 Original line number Diff line number Diff line Loading @@ -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. * Loading @@ -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); Loading @@ -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 */ Loading @@ -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)); } Loading Loading @@ -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(); } Loading @@ -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(); } Loading