From 229653a59ba635b1649590aa119a4354989314a8 Mon Sep 17 00:00:00 2001 From: Paul Elder Date: Thu, 21 Jan 2021 17:44:14 +0900 Subject: android: camera_device: Load make and model from platform settings In ChromeOS the camera make and model is saved in /var/cache/camera/camera.prop. Load and save these values at construction time, if available. Signed-off-by: Paul Elder Reviewed-by: Laurent Pinchart Reviewed-by: Jacopo Mondi --- src/android/camera_device.cpp | 23 +++++++++++++++++++++++ src/android/camera_device.h | 5 +++++ 2 files changed, 28 insertions(+) diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp index 1a384460..7929877c 100644 --- a/src/android/camera_device.cpp +++ b/src/android/camera_device.cpp @@ -9,6 +9,7 @@ #include "camera_ops.h" #include "post_processor.h" +#include #include #include #include @@ -351,6 +352,28 @@ CameraDevice::CameraDevice(unsigned int id, const std::shared_ptr &camer * streamConfiguration. */ maxJpegBufferSize_ = 13 << 20; /* 13631488 from USB HAL */ + + maker_ = "libcamera"; + model_ = "cameraModel"; + + /* \todo Support getting properties on Android */ + std::ifstream fstream("/var/cache/camera/camera.prop"); + if (!fstream.is_open()) + return; + + std::string line; + while (std::getline(fstream, line)) { + std::string::size_type delimPos = line.find("="); + if (delimPos == std::string::npos) + continue; + std::string key = line.substr(0, delimPos); + std::string val = line.substr(delimPos + 1); + + if (!key.compare("ro.product.model")) + model_ = val; + else if (!key.compare("ro.product.manufacturer")) + maker_ = val; + } } CameraDevice::~CameraDevice() diff --git a/src/android/camera_device.h b/src/android/camera_device.h index 597d11fc..4b0d8575 100644 --- a/src/android/camera_device.h +++ b/src/android/camera_device.h @@ -55,6 +55,8 @@ public: return config_.get(); } + const std::string &maker() const { return maker_; } + const std::string &model() const { return model_; } int facing() const { return facing_; } int orientation() const { return orientation_; } unsigned int maxJpegBufferSize() const { return maxJpegBufferSize_; } @@ -125,6 +127,9 @@ private: std::map formatsMap_; std::vector streams_; + std::string maker_; + std::string model_; + int facing_; int orientation_; -- cgit v1.2.1