diff options
| author | 2020-06-01 14:59:17 -0700 | |
|---|---|---|
| committer | 2020-06-03 12:38:03 -0700 | |
| commit | fd40c07abe25e96fed4f5abfa5d525efed68a36c (patch) | |
| tree | 4c35450e3b5621a99291e8aaf49586a40ac0a984 | |
| parent | 1ae85bb2871839b7109c3271b89c7293ad83859d (diff) | |
Add the metrics for status of open cas session
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: I9f8ce2e52289130f9fb39a368240676c1792c154
| -rw-r--r-- | cmds/statsd/src/atoms.proto | 24 | ||||
| -rw-r--r-- | media/java/android/media/MediaCas.java | 23 |
2 files changed, 46 insertions, 1 deletions
diff --git a/cmds/statsd/src/atoms.proto b/cmds/statsd/src/atoms.proto index 4635a2b14bb4..81d059ed84d9 100644 --- a/cmds/statsd/src/atoms.proto +++ b/cmds/statsd/src/atoms.proto @@ -447,6 +447,8 @@ message Atom { 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. @@ -9273,6 +9275,28 @@ message TvTunerDvrStatus { // 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. * diff --git a/media/java/android/media/MediaCas.java b/media/java/android/media/MediaCas.java index c652628eb425..590def4d4ced 100644 --- a/media/java/android/media/MediaCas.java +++ b/media/java/android/media/MediaCas.java @@ -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; @@ -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; @@ -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<>(); @@ -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); @@ -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) { @@ -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; } @@ -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; } |