cameraservice: Add logId to correlate CameraActionEvents
Cameraservice currently triggers logging of CameraActionEvents (through
CameraServiceProxy) which are logged as independent event. For data
analysis purposes, it would be helpful to have one set of
OPEN-n*SESSION-CLOSE events correlate with each other.
To help with that, an mLogId field was added in CameraSessionStats which
will hold a string identifier. This identifier will be randomly
generated for OPEN events and reused for corresponding
ACTIVE, IDLE, and CLOSE events.
Bug: 271297241
Test: Manually tested that statsd gets the expected logId for camera
sessions.
Change-Id: Ia26f2cd5d75bdeb15737e85d7df1a46b75993712
diff --git a/camera/CameraSessionStats.cpp b/camera/CameraSessionStats.cpp
index 0706ac1..26c612a 100644
--- a/camera/CameraSessionStats.cpp
+++ b/camera/CameraSessionStats.cpp
@@ -271,6 +271,7 @@
mApiLevel(0),
mIsNdk(false),
mLatencyMs(-1),
+ mLogId(0),
mMaxPreviewFps(0),
mSessionType(0),
mInternalReconfigure(0),
@@ -281,7 +282,7 @@
CameraSessionStats::CameraSessionStats(const String16& cameraId,
int facing, int newCameraState, const String16& clientName,
- int apiLevel, bool isNdk, int32_t latencyMs) :
+ int apiLevel, bool isNdk, int32_t latencyMs, int64_t logId) :
mCameraId(cameraId),
mFacing(facing),
mNewCameraState(newCameraState),
@@ -289,6 +290,7 @@
mApiLevel(apiLevel),
mIsNdk(isNdk),
mLatencyMs(latencyMs),
+ mLogId(logId),
mMaxPreviewFps(0),
mSessionType(0),
mInternalReconfigure(0),
@@ -347,6 +349,12 @@
return err;
}
+ int64_t logId;
+ if ((err = parcel->readInt64(&logId)) != OK) {
+ ALOGE("%s: Failed to read log ID from parcel", __FUNCTION__);
+ return err;
+ }
+
float maxPreviewFps;
if ((err = parcel->readFloat(&maxPreviewFps)) != OK) {
ALOGE("%s: Failed to read maxPreviewFps from parcel", __FUNCTION__);
@@ -408,6 +416,7 @@
mApiLevel = apiLevel;
mIsNdk = isNdk;
mLatencyMs = latencyMs;
+ mLogId = logId;
mMaxPreviewFps = maxPreviewFps;
mSessionType = sessionType;
mInternalReconfigure = internalReconfigure;
@@ -464,6 +473,11 @@
return err;
}
+ if ((err = parcel->writeInt64(mLogId)) != OK) {
+ ALOGE("%s: Failed to write log ID!", __FUNCTION__);
+ return err;
+ }
+
if ((err = parcel->writeFloat(mMaxPreviewFps)) != OK) {
ALOGE("%s: Failed to write maxPreviewFps!", __FUNCTION__);
return err;
@@ -508,6 +522,7 @@
ALOGE("%s: Failed to write video stabilization mode!", __FUNCTION__);
return err;
}
+
return OK;
}