cameraservice: Correlate various CameraActionEvents

CameraActionEvent logged by cameraservice has a new logId field
associated with it which lets the CameraActionEvents generated in one
OPEN-n*SESSION-CLOSE sequence be correlated to each other when consuming
the logs for data analysis. This CL updates CameraServiceProxy.java to
accept the new field.

Bug: 271297241
Test: Manually verified that statsd captures the correct logId field.
Change-Id: I94ac7c7e36d23a9ec360c0bd3f4230a6932cb908
This commit is contained in:
Avichal Rakesh
2023-03-03 15:29:04 -08:00
parent efde968c40
commit 6fa3a81c25
2 changed files with 21 additions and 7 deletions

View File

@@ -54,6 +54,7 @@ public class CameraSessionStats implements Parcelable {
private int mApiLevel;
private boolean mIsNdk;
private int mLatencyMs;
private long mLogId;
private int mSessionType;
private int mInternalReconfigure;
private long mRequestCount;
@@ -70,6 +71,7 @@ public class CameraSessionStats implements Parcelable {
mApiLevel = -1;
mIsNdk = false;
mLatencyMs = -1;
mLogId = 0;
mMaxPreviewFps = 0;
mSessionType = -1;
mInternalReconfigure = -1;
@@ -82,7 +84,7 @@ public class CameraSessionStats implements Parcelable {
public CameraSessionStats(String cameraId, int facing, int newCameraState,
String clientName, int apiLevel, boolean isNdk, int creationDuration,
float maxPreviewFps, int sessionType, int internalReconfigure) {
float maxPreviewFps, int sessionType, int internalReconfigure, long logId) {
mCameraId = cameraId;
mFacing = facing;
mNewCameraState = newCameraState;
@@ -90,6 +92,7 @@ public class CameraSessionStats implements Parcelable {
mApiLevel = apiLevel;
mIsNdk = isNdk;
mLatencyMs = creationDuration;
mLogId = logId;
mMaxPreviewFps = maxPreviewFps;
mSessionType = sessionType;
mInternalReconfigure = internalReconfigure;
@@ -127,6 +130,7 @@ public class CameraSessionStats implements Parcelable {
dest.writeInt(mApiLevel);
dest.writeBoolean(mIsNdk);
dest.writeInt(mLatencyMs);
dest.writeLong(mLogId);
dest.writeFloat(mMaxPreviewFps);
dest.writeInt(mSessionType);
dest.writeInt(mInternalReconfigure);
@@ -146,6 +150,7 @@ public class CameraSessionStats implements Parcelable {
mApiLevel = in.readInt();
mIsNdk = in.readBoolean();
mLatencyMs = in.readInt();
mLogId = in.readLong();
mMaxPreviewFps = in.readFloat();
mSessionType = in.readInt();
mInternalReconfigure = in.readInt();
@@ -189,6 +194,10 @@ public class CameraSessionStats implements Parcelable {
return mLatencyMs;
}
public long getLogId() {
return mLogId;
}
public float getMaxPreviewFps() {
return mMaxPreviewFps;
}

View File

@@ -243,11 +243,13 @@ public class CameraServiceProxy extends SystemService
public List<CameraStreamStats> mStreamStats;
public String mUserTag;
public int mVideoStabilizationMode;
public final long mLogId;
private long mDurationOrStartTimeMs; // Either start time, or duration once completed
CameraUsageEvent(String cameraId, int facing, String clientName, int apiLevel,
boolean isNdk, int action, int latencyMs, int operatingMode, boolean deviceError) {
boolean isNdk, int action, int latencyMs, int operatingMode, boolean deviceError,
long logId) {
mCameraId = cameraId;
mCameraFacing = facing;
mClientName = clientName;
@@ -259,6 +261,7 @@ public class CameraServiceProxy extends SystemService
mLatencyMs = latencyMs;
mOperatingMode = operatingMode;
mDeviceError = deviceError;
mLogId = logId;
}
public void markCompleted(int internalReconfigure, long requestCount,
@@ -840,7 +843,8 @@ public class CameraServiceProxy extends SystemService
+ ", deviceError " + e.mDeviceError
+ ", streamCount is " + streamCount
+ ", userTag is " + e.mUserTag
+ ", videoStabilizationMode " + e.mVideoStabilizationMode);
+ ", videoStabilizationMode " + e.mVideoStabilizationMode
+ ", logId " + e.mLogId);
}
// Convert from CameraStreamStats to CameraStreamProto
CameraStreamProto[] streamProtos = new CameraStreamProto[MAX_STREAM_STATISTICS];
@@ -900,7 +904,7 @@ public class CameraServiceProxy extends SystemService
MessageNano.toByteArray(streamProtos[2]),
MessageNano.toByteArray(streamProtos[3]),
MessageNano.toByteArray(streamProtos[4]),
e.mUserTag, e.mVideoStabilizationMode);
e.mUserTag, e.mVideoStabilizationMode, e.mLogId);
}
}
@@ -1089,6 +1093,7 @@ public class CameraServiceProxy extends SystemService
List<CameraStreamStats> streamStats = cameraState.getStreamStats();
String userTag = cameraState.getUserTag();
int videoStabilizationMode = cameraState.getVideoStabilizationMode();
long logId = cameraState.getLogId();
synchronized(mLock) {
// Update active camera list and notify NFC if necessary
boolean wasEmpty = mActiveCameraUsage.isEmpty();
@@ -1110,7 +1115,7 @@ public class CameraServiceProxy extends SystemService
CameraUsageEvent openEvent = new CameraUsageEvent(
cameraId, facing, clientName, apiLevel, isNdk,
FrameworkStatsLog.CAMERA_ACTION_EVENT__ACTION__OPEN,
latencyMs, sessionType, deviceError);
latencyMs, sessionType, deviceError, logId);
mCameraUsageHistory.add(openEvent);
break;
case CameraSessionStats.CAMERA_STATE_ACTIVE:
@@ -1137,7 +1142,7 @@ public class CameraServiceProxy extends SystemService
CameraUsageEvent newEvent = new CameraUsageEvent(
cameraId, facing, clientName, apiLevel, isNdk,
FrameworkStatsLog.CAMERA_ACTION_EVENT__ACTION__SESSION,
latencyMs, sessionType, deviceError);
latencyMs, sessionType, deviceError, logId);
CameraUsageEvent oldEvent = mActiveCameraUsage.put(cameraId, newEvent);
if (oldEvent != null) {
Slog.w(TAG, "Camera " + cameraId + " was already marked as active");
@@ -1181,7 +1186,7 @@ public class CameraServiceProxy extends SystemService
CameraUsageEvent closeEvent = new CameraUsageEvent(
cameraId, facing, clientName, apiLevel, isNdk,
FrameworkStatsLog.CAMERA_ACTION_EVENT__ACTION__CLOSE,
latencyMs, sessionType, deviceError);
latencyMs, sessionType, deviceError, logId);
mCameraUsageHistory.add(closeEvent);
}