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
This commit is contained in:
Henry Fang
2020-06-01 14:59:17 -07:00
parent 1ae85bb287
commit fd40c07abe
2 changed files with 46 additions and 1 deletions

View File

@@ -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.
*

View File

@@ -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;
}