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/CameraExtensionSessionStats.aidl b/camera/aidl/android/hardware/CameraExtensionSessionStats.aidl
new file mode 100644
index 0000000..1c81831
--- /dev/null
+++ b/camera/aidl/android/hardware/CameraExtensionSessionStats.aidl
@@ -0,0 +1,69 @@
+/*
+ * Copyright (C) 2023 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.hardware;
+
+/**
+ * Metrics specific to Extension Sessions (see CameraExtensionSession) for logging.
+ *
+ * Each Extension Session is mapped to one camera session internally, and will be sent to
+ * CameraServiceProxy with IDLE/CLOSE calls.
+ * @hide
+ */
+parcelable CameraExtensionSessionStats {
+ /**
+ * Value should match {@code CameraExtensionCharacteristics#EXTENSION_*}
+ */
+ @Backing(type="int")
+ enum Type {
+ EXTENSION_NONE = -1,
+ EXTENSION_AUTOMATIC = 0,
+ EXTENSION_FACE_RETOUCH = 1,
+ EXTENSION_BOKEH = 2,
+ EXTENSION_HDR = 3,
+ EXTENSION_NIGHT = 4
+ }
+
+ /**
+ * Key to uniquely identify the session this stat is associated with. The first call to
+ * 'ICameraService.reportExtensionSessionStats' should set this to an empty string.
+ * 'ICameraService.reportExtensionSessionStats' will return the key which should be used with
+ * the next calls.
+ */
+ String key;
+
+ /**
+ * Camera ID for which the stats is being reported.
+ */
+ String cameraId;
+
+ /**
+ * Package name of the client using the camera
+ */
+ String clientName;
+
+
+ /**
+ * Type of extension session requested by the app. Note that EXTENSION_AUTOMATIC is reported
+ * as such.
+ */
+ Type type = Type.EXTENSION_NONE;
+
+ /**
+ * true if advanced extensions are being used, false otherwise
+ */
+ boolean isAdvanced = false;
+}
\ No newline at end of file