camera: Fix prefix length path for External Camera HAL am: b8863f6a03

Original change: https://android-review.googlesource.com/c/platform/hardware/interfaces/+/2386907

Change-Id: I1ccf1ab9bc2520801b55741219def26675f381fa
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Avichal Rakesh 2023-06-09 01:31:57 +00:00 committed by Automerger Merge Worker
commit e1390f059f
2 changed files with 14 additions and 12 deletions

View file

@ -18,15 +18,16 @@
//#define LOG_NDEBUG 0
#include <log/log.h>
#include <regex>
#include <sys/inotify.h>
#include <cutils/properties.h>
#include <errno.h>
#include <linux/videodev2.h>
#include <cutils/properties.h>
#include "ExternalCameraProviderImpl_2_4.h"
#include <sys/inotify.h>
#include <regex>
#include <string>
#include "ExternalCameraDevice_3_4.h"
#include "ExternalCameraDevice_3_5.h"
#include "ExternalCameraDevice_3_6.h"
#include "ExternalCameraProviderImpl_2_4.h"
namespace android {
namespace hardware {
@ -41,10 +42,10 @@ namespace {
// "device@<version>/external/<id>"
const std::regex kDeviceNameRE("device@([0-9]+\\.[0-9]+)/external/(.+)");
const int kMaxDevicePathLen = 256;
const char* kDevicePath = "/dev/";
constexpr char kPrefix[] = "video";
constexpr int kPrefixLen = sizeof(kPrefix) - 1;
constexpr int kDevicePrefixLen = sizeof(kDevicePath) + kPrefixLen + 1;
constexpr const char* kDevicePath = "/dev/";
constexpr const char* kPrefix = "video";
constexpr int kPrefixLen = std::char_traits<char>::length(kPrefix);
constexpr int kDevicePrefixLen = std::char_traits<char>::length(kDevicePath) + kPrefixLen;
bool matchDeviceName(int cameraIdOffset,
const hidl_string& deviceName, std::string* deviceVersion,

View file

@ -23,6 +23,7 @@
#include <linux/videodev2.h>
#include <sys/inotify.h>
#include <regex>
#include <string>
#include "ExternalCameraDevice_3_4.h"
#include "ExternalCameraDevice_3_5.h"
#include "ExternalCameraDevice_3_6.h"
@ -39,10 +40,10 @@ namespace {
// "device@<version>/external/<id>"
const std::regex kDeviceNameRE("device@([0-9]+\\.[0-9]+)/external/(.+)");
const int kMaxDevicePathLen = 256;
const char* kDevicePath = "/dev/";
constexpr char kPrefix[] = "video";
constexpr int kPrefixLen = sizeof(kPrefix) - 1;
constexpr int kDevicePrefixLen = sizeof(kDevicePath) + kPrefixLen + 1;
constexpr const char* kDevicePath = "/dev/";
constexpr const char* kPrefix = "video";
constexpr int kPrefixLen = std::char_traits<char>::length(kPrefix);
constexpr int kDevicePrefixLen = std::char_traits<char>::length(kDevicePath) + kPrefixLen;
bool matchDeviceName(int cameraIdOffset, const hidl_string& deviceName, std::string* deviceVersion,
std::string* cameraDevicePath) {