cameraservice: Pipe session identifier to the Camera HAL

For data analysis from HAL logs, it is helpful to get some higher level
information of the camera usage (such as the client's package name).
HALs are denied access to this higher level information at runtime.

To help data with data analysis, cameraservice will now pass a session
identifier when configuring streams. This identifier can be used to
correlate HAL logs with cameraservice logs at the time of log
consumption, but not at runtime. This identifier has no functional
purpose and is randomly generated, so does not contain any identifying
information about the high level client.

Bug: 271171714
Test: Manually verified that cameraservice passes the session identifier
      to the camera HAL.
Change-Id: Id980b11f9062369e5bca354a5113d6b5040de8be
diff --git a/services/camera/libcameraservice/utils/CameraServiceProxyWrapper.cpp b/services/camera/libcameraservice/utils/CameraServiceProxyWrapper.cpp
index 1b80de2..4225366 100644
--- a/services/camera/libcameraservice/utils/CameraServiceProxyWrapper.cpp
+++ b/services/camera/libcameraservice/utils/CameraServiceProxyWrapper.cpp
@@ -101,6 +101,11 @@
     mSessionStats.mStreamStats.clear();
 }
 
+int64_t CameraServiceProxyWrapper::CameraSessionStatsWrapper::getLogId() {
+    Mutex::Autolock l(mLock);
+    return mSessionStats.mLogId;
+}
+
 /**
  * CameraServiceProxyWrapper functions
  */
@@ -303,6 +308,21 @@
     return ret;
 }
 
+int64_t CameraServiceProxyWrapper::getCurrentLogIdForCamera(const String8& cameraId) {
+    std::shared_ptr<CameraSessionStatsWrapper> stats;
+    {
+        Mutex::Autolock _l(mLock);
+        if (mSessionStatsMap.count(cameraId) == 0) {
+            ALOGE("%s: SessionStatsMap should contain camera %s before asking for its logging ID.",
+                  __FUNCTION__, cameraId.c_str());
+            return 0;
+        }
+
+        stats = mSessionStatsMap[cameraId];
+    }
+    return stats->getLogId();
+}
+
 int64_t CameraServiceProxyWrapper::generateLogId(std::random_device& randomDevice) {
     int64_t ret = 0;
     do {