cameraservice: Add metrics for extension sessions
We want to log camera extension usage in cameraservice. This CL adds
the scaffolding for it. Specifically, it does the following:
- Adds CameraExtensionSessionStats.aidl: This is used as the interface
that CameraExtensionSession, CameraService, and CameraServiceProxy
use to parcel extension metrics around.
- Adds 'reportExtensionStats' to ICameraService: To keep the details
of extensions away from cameraservice, CameraExtensionSession is
responsible for collecting and reporting the stats. CameraService
simply maps the reported stats to the current camera session and
passes it to CameraServiceProxy when the session is closed.
Some additional safeguards are added for this function because
CameraExtensionSession can potentially report stats after the
session has already been closed from cameraservice.
Bug: 261470491
Test: No functional change.
`atest CtsCameraTestCases` passes.
`statsd_testdrive 227` confirms that extension metrics are logged
correctly.
Change-Id: I4a9897fc2b09cabb7618e94f8484757735c5e1f3
diff --git a/camera/aidl/android/hardware/ICameraService.aidl b/camera/aidl/android/hardware/ICameraService.aidl
index 9f32595..f8e1631 100644
--- a/camera/aidl/android/hardware/ICameraService.aidl
+++ b/camera/aidl/android/hardware/ICameraService.aidl
@@ -30,6 +30,7 @@
import android.hardware.ICameraServiceListener;
import android.hardware.CameraInfo;
import android.hardware.CameraStatus;
+import android.hardware.CameraExtensionSessionStats;
/**
* Binder interface for the native camera service running in mediaserver.
@@ -214,6 +215,26 @@
*/
oneway void notifyDeviceStateChange(long newState);
+ /**
+ * Report Extension specific metrics to camera service for logging. This should only be called
+ * by CameraExtensionSession to log extension metrics. All calls after the first must set
+ * CameraExtensionSessionStats.key to the value returned by this function.
+ *
+ * Each subsequent call fully overwrites the existing CameraExtensionSessionStats for the
+ * current session, so the caller is responsible for keeping the stats complete.
+ *
+ * Due to cameraservice and cameraservice_proxy architecture, there is no guarantee that
+ * {@code stats} will be logged immediately (or at all). CameraService will log whatever
+ * extension stats it has at the time of camera session closing which may be before the app
+ * process receives a session/device closed callback; so CameraExtensionSession
+ * should send metrics to the cameraservice preriodically, and cameraservice must handle calls
+ * to this function from sessions that have not been logged yet and from sessions that have
+ * already been closed.
+ *
+ * @return the key that must be used to report updates to previously reported stats.
+ */
+ String reportExtensionSessionStats(in CameraExtensionSessionStats stats);
+
// Bitfield constants for notifyDeviceStateChange
// All bits >= 32 are for custom vendor states
// Written as ints since AIDL does not support long constants.