Merge changes I9f8ce2e5,I3142b073 into rvc-dev am: 084e7473fb
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/11689890 Change-Id: Ie8ca43aa9f3e33bb235e3796daabc17514754433
This commit is contained in:
@@ -446,6 +446,9 @@ message Atom {
|
|||||||
277 [(module) = "settings"];
|
277 [(module) = "settings"];
|
||||||
CellBroadcastMessageFiltered cb_message_filtered =
|
CellBroadcastMessageFiltered cb_message_filtered =
|
||||||
278 [(module) = "cellbroadcast"];
|
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.
|
// StatsdStats tracks platform atoms with ids upto 500.
|
||||||
// Update StatsdStats::kMaxPushedAtomId when atom ids here approach that value.
|
// Update StatsdStats::kMaxPushedAtomId when atom ids here approach that value.
|
||||||
@@ -9242,6 +9245,58 @@ message TvTunerStateChanged {
|
|||||||
// new state
|
// new state
|
||||||
optional State state = 2;
|
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.
|
* Logs when an app is frozen or unfrozen.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ import android.annotation.IntDef;
|
|||||||
import android.annotation.NonNull;
|
import android.annotation.NonNull;
|
||||||
import android.annotation.Nullable;
|
import android.annotation.Nullable;
|
||||||
import android.annotation.TestApi;
|
import android.annotation.TestApi;
|
||||||
|
import android.app.ActivityManager;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.hardware.cas.V1_0.HidlCasPluginDescriptor;
|
import android.hardware.cas.V1_0.HidlCasPluginDescriptor;
|
||||||
import android.hardware.cas.V1_0.ICas;
|
import android.hardware.cas.V1_0.ICas;
|
||||||
@@ -43,6 +44,8 @@ import android.os.RemoteException;
|
|||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.util.Singleton;
|
import android.util.Singleton;
|
||||||
|
|
||||||
|
import com.android.internal.util.FrameworkStatsLog;
|
||||||
|
|
||||||
import java.lang.annotation.Retention;
|
import java.lang.annotation.Retention;
|
||||||
import java.lang.annotation.RetentionPolicy;
|
import java.lang.annotation.RetentionPolicy;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@@ -122,6 +125,7 @@ public final class MediaCas implements AutoCloseable {
|
|||||||
private String mTvInputServiceSessionId;
|
private String mTvInputServiceSessionId;
|
||||||
private int mClientId;
|
private int mClientId;
|
||||||
private int mCasSystemId;
|
private int mCasSystemId;
|
||||||
|
private int mUserId;
|
||||||
private TunerResourceManager mTunerResourceManager = null;
|
private TunerResourceManager mTunerResourceManager = null;
|
||||||
private final Map<Session, Integer> mSessionMap = new HashMap<>();
|
private final Map<Session, Integer> mSessionMap = new HashMap<>();
|
||||||
|
|
||||||
@@ -673,6 +677,8 @@ public final class MediaCas implements AutoCloseable {
|
|||||||
*/
|
*/
|
||||||
public MediaCas(int CA_system_id) throws UnsupportedCasException {
|
public MediaCas(int CA_system_id) throws UnsupportedCasException {
|
||||||
try {
|
try {
|
||||||
|
mCasSystemId = CA_system_id;
|
||||||
|
mUserId = ActivityManager.getCurrentUser();
|
||||||
IMediaCasService service = getService();
|
IMediaCasService service = getService();
|
||||||
android.hardware.cas.V1_2.IMediaCasService serviceV12 =
|
android.hardware.cas.V1_2.IMediaCasService serviceV12 =
|
||||||
android.hardware.cas.V1_2.IMediaCasService.castFrom(service);
|
android.hardware.cas.V1_2.IMediaCasService.castFrom(service);
|
||||||
@@ -721,7 +727,6 @@ public final class MediaCas implements AutoCloseable {
|
|||||||
this(casSystemId);
|
this(casSystemId);
|
||||||
|
|
||||||
Objects.requireNonNull(context, "context must not be null");
|
Objects.requireNonNull(context, "context must not be null");
|
||||||
mCasSystemId = casSystemId;
|
|
||||||
mTunerResourceManager = (TunerResourceManager)
|
mTunerResourceManager = (TunerResourceManager)
|
||||||
context.getSystemService(Context.TV_TUNER_RESOURCE_MGR_SERVICE);
|
context.getSystemService(Context.TV_TUNER_RESOURCE_MGR_SERVICE);
|
||||||
if (mTunerResourceManager != null) {
|
if (mTunerResourceManager != null) {
|
||||||
@@ -925,10 +930,18 @@ public final class MediaCas implements AutoCloseable {
|
|||||||
mICas.openSession(cb);
|
mICas.openSession(cb);
|
||||||
MediaCasException.throwExceptionIfNeeded(cb.mStatus);
|
MediaCasException.throwExceptionIfNeeded(cb.mStatus);
|
||||||
addSessionToResourceMap(cb.mSession, sessionResourceHandle);
|
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;
|
return cb.mSession;
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
cleanupAndRethrowIllegalState();
|
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;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -964,10 +977,18 @@ public final class MediaCas implements AutoCloseable {
|
|||||||
mICasV12.openSession_1_2(sessionUsage, scramblingMode, cb);
|
mICasV12.openSession_1_2(sessionUsage, scramblingMode, cb);
|
||||||
MediaCasException.throwExceptionIfNeeded(cb.mStatus);
|
MediaCasException.throwExceptionIfNeeded(cb.mStatus);
|
||||||
addSessionToResourceMap(cb.mSession, sessionResourceHandle);
|
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;
|
return cb.mSession;
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
cleanupAndRethrowIllegalState();
|
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;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -20,12 +20,16 @@ import android.annotation.BytesLong;
|
|||||||
import android.annotation.IntDef;
|
import android.annotation.IntDef;
|
||||||
import android.annotation.NonNull;
|
import android.annotation.NonNull;
|
||||||
import android.annotation.SystemApi;
|
import android.annotation.SystemApi;
|
||||||
|
import android.app.ActivityManager;
|
||||||
import android.hardware.tv.tuner.V1_0.Constants;
|
import android.hardware.tv.tuner.V1_0.Constants;
|
||||||
import android.media.tv.tuner.Tuner;
|
import android.media.tv.tuner.Tuner;
|
||||||
import android.media.tv.tuner.Tuner.Result;
|
import android.media.tv.tuner.Tuner.Result;
|
||||||
import android.media.tv.tuner.TunerUtils;
|
import android.media.tv.tuner.TunerUtils;
|
||||||
import android.media.tv.tuner.filter.Filter;
|
import android.media.tv.tuner.filter.Filter;
|
||||||
import android.os.ParcelFileDescriptor;
|
import android.os.ParcelFileDescriptor;
|
||||||
|
import android.util.Log;
|
||||||
|
|
||||||
|
import com.android.internal.util.FrameworkStatsLog;
|
||||||
|
|
||||||
import java.lang.annotation.Retention;
|
import java.lang.annotation.Retention;
|
||||||
import java.lang.annotation.RetentionPolicy;
|
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;
|
public static final int PLAYBACK_STATUS_FULL = Constants.PlaybackStatus.SPACE_FULL;
|
||||||
|
|
||||||
|
private static final String TAG = "TvTunerPlayback";
|
||||||
|
|
||||||
private long mNativeContext;
|
private long mNativeContext;
|
||||||
private OnPlaybackStatusChangedListener mListener;
|
private OnPlaybackStatusChangedListener mListener;
|
||||||
private Executor mExecutor;
|
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 nativeAttachFilter(Filter filter);
|
||||||
private native int nativeDetachFilter(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 native long nativeRead(byte[] bytes, long offset, long size);
|
||||||
|
|
||||||
private DvrPlayback() {
|
private DvrPlayback() {
|
||||||
|
mUserId = ActivityManager.getCurrentUser();
|
||||||
|
mSegmentId = (sInstantId & 0x0000ffff) << 16;
|
||||||
|
sInstantId++;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @hide */
|
/** @hide */
|
||||||
@@ -98,6 +111,9 @@ public class DvrPlayback implements AutoCloseable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void onPlaybackStatusChanged(int status) {
|
private void onPlaybackStatusChanged(int status) {
|
||||||
|
if (status == PLAYBACK_STATUS_EMPTY) {
|
||||||
|
mUnderflow++;
|
||||||
|
}
|
||||||
if (mExecutor != null && mListener != null) {
|
if (mExecutor != null && mListener != null) {
|
||||||
mExecutor.execute(() -> mListener.onPlaybackStatusChanged(status));
|
mExecutor.execute(() -> mListener.onPlaybackStatusChanged(status));
|
||||||
}
|
}
|
||||||
@@ -154,6 +170,13 @@ public class DvrPlayback implements AutoCloseable {
|
|||||||
*/
|
*/
|
||||||
@Result
|
@Result
|
||||||
public int start() {
|
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();
|
return nativeStartDvr();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -167,6 +190,11 @@ public class DvrPlayback implements AutoCloseable {
|
|||||||
*/
|
*/
|
||||||
@Result
|
@Result
|
||||||
public int stop() {
|
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();
|
return nativeStopDvr();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -19,14 +19,19 @@ package android.media.tv.tuner.dvr;
|
|||||||
import android.annotation.BytesLong;
|
import android.annotation.BytesLong;
|
||||||
import android.annotation.NonNull;
|
import android.annotation.NonNull;
|
||||||
import android.annotation.SystemApi;
|
import android.annotation.SystemApi;
|
||||||
|
import android.app.ActivityManager;
|
||||||
import android.media.tv.tuner.Tuner;
|
import android.media.tv.tuner.Tuner;
|
||||||
import android.media.tv.tuner.Tuner.Result;
|
import android.media.tv.tuner.Tuner.Result;
|
||||||
import android.media.tv.tuner.TunerUtils;
|
import android.media.tv.tuner.TunerUtils;
|
||||||
import android.media.tv.tuner.filter.Filter;
|
import android.media.tv.tuner.filter.Filter;
|
||||||
import android.os.ParcelFileDescriptor;
|
import android.os.ParcelFileDescriptor;
|
||||||
|
import android.util.Log;
|
||||||
|
|
||||||
|
import com.android.internal.util.FrameworkStatsLog;
|
||||||
|
|
||||||
import java.util.concurrent.Executor;
|
import java.util.concurrent.Executor;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Digital Video Record (DVR) recorder class which provides record control on Demux's output buffer.
|
* 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
|
@SystemApi
|
||||||
public class DvrRecorder implements AutoCloseable {
|
public class DvrRecorder implements AutoCloseable {
|
||||||
|
private static final String TAG = "TvTunerRecord";
|
||||||
private long mNativeContext;
|
private long mNativeContext;
|
||||||
private OnRecordStatusChangedListener mListener;
|
private OnRecordStatusChangedListener mListener;
|
||||||
private Executor mExecutor;
|
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 nativeAttachFilter(Filter filter);
|
||||||
private native int nativeDetachFilter(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 native long nativeWrite(byte[] bytes, long offset, long size);
|
||||||
|
|
||||||
private DvrRecorder() {
|
private DvrRecorder() {
|
||||||
|
mUserId = ActivityManager.getCurrentUser();
|
||||||
|
mSegmentId = (sInstantId & 0x0000ffff) << 16;
|
||||||
|
sInstantId++;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @hide */
|
/** @hide */
|
||||||
@@ -60,6 +73,9 @@ public class DvrRecorder implements AutoCloseable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void onRecordStatusChanged(int status) {
|
private void onRecordStatusChanged(int status) {
|
||||||
|
if (status == Filter.STATUS_OVERFLOW) {
|
||||||
|
mOverflow++;
|
||||||
|
}
|
||||||
if (mExecutor != null && mListener != null) {
|
if (mExecutor != null && mListener != null) {
|
||||||
mExecutor.execute(() -> mListener.onRecordStatusChanged(status));
|
mExecutor.execute(() -> mListener.onRecordStatusChanged(status));
|
||||||
}
|
}
|
||||||
@@ -112,6 +128,13 @@ public class DvrRecorder implements AutoCloseable {
|
|||||||
*/
|
*/
|
||||||
@Result
|
@Result
|
||||||
public int start() {
|
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();
|
return nativeStartDvr();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -124,6 +147,11 @@ public class DvrRecorder implements AutoCloseable {
|
|||||||
*/
|
*/
|
||||||
@Result
|
@Result
|
||||||
public int stop() {
|
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();
|
return nativeStopDvr();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user