mirror of
https://github.com/Anything-at-25-00/android_device_tecno_LG8n.git
synced 2024-11-29 00:46:26 -08:00
LG8n: Add libcamera_metadata shim for stripping out system camera cap
Change-Id: I8f7772fc9ec15a00c4b630866aa7fc162a52c1aa Signed-off-by: SamarV-121 <samarvispute121@pm.me>
This commit is contained in:
parent
e4967e0c5a
commit
0c2da1b00a
|
@ -97,8 +97,7 @@ PRODUCT_PACKAGES += \
|
||||||
android.hardware.camera.provider@2.6.vendor
|
android.hardware.camera.provider@2.6.vendor
|
||||||
|
|
||||||
PRODUCT_PACKAGES += \
|
PRODUCT_PACKAGES += \
|
||||||
libcamera_metadata.vendor \
|
libshim_camera_metadata \
|
||||||
libcamera_metadata_shim \
|
|
||||||
libdng_sdk.vendor \
|
libdng_sdk.vendor \
|
||||||
libexpat.vendor \
|
libexpat.vendor \
|
||||||
libpng.vendor
|
libpng.vendor
|
||||||
|
|
|
@ -16,3 +16,10 @@ cc_library_shared {
|
||||||
"libmedia_headers",
|
"libmedia_headers",
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cc_library {
|
||||||
|
name: "libshim_camera_metadata",
|
||||||
|
shared_libs: ["libcamera_metadata"],
|
||||||
|
srcs: ["libshim_camera_metadata.cpp"],
|
||||||
|
vendor: true
|
||||||
|
}
|
||||||
|
|
57
libshims/libshim_camera_metadata.cpp
Normal file
57
libshims/libshim_camera_metadata.cpp
Normal file
|
@ -0,0 +1,57 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2022 The LineageOS Project
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <dlfcn.h>
|
||||||
|
#include <system/camera_metadata.h>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
extern "C" int add_camera_metadata_entry(camera_metadata_t* dst, uint32_t tag, const void* data,
|
||||||
|
size_t data_count) {
|
||||||
|
static auto add_camera_metadata_entry_orig =
|
||||||
|
reinterpret_cast<typeof(add_camera_metadata_entry)*>(
|
||||||
|
dlsym(RTLD_NEXT, "add_camera_metadata_entry"));
|
||||||
|
|
||||||
|
if (tag == ANDROID_REQUEST_AVAILABLE_CAPABILITIES) {
|
||||||
|
std::vector<uint8_t> caps;
|
||||||
|
auto u8 = reinterpret_cast<const uint8_t*>(data);
|
||||||
|
|
||||||
|
for (size_t i = 0; i < data_count; i++) {
|
||||||
|
if (u8[i] != ANDROID_REQUEST_AVAILABLE_CAPABILITIES_SYSTEM_CAMERA) {
|
||||||
|
caps.emplace_back(u8[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return add_camera_metadata_entry_orig(dst, tag, caps.data(), caps.size());
|
||||||
|
}
|
||||||
|
|
||||||
|
return add_camera_metadata_entry_orig(dst, tag, data, data_count);
|
||||||
|
}
|
||||||
|
|
||||||
|
extern "C" int update_camera_metadata_entry(camera_metadata_t* dst, size_t index, const void* data,
|
||||||
|
size_t data_count,
|
||||||
|
camera_metadata_entry_t* updated_entry) {
|
||||||
|
static auto update_camera_metadata_entry_orig =
|
||||||
|
reinterpret_cast<typeof(update_camera_metadata_entry)*>(
|
||||||
|
dlsym(RTLD_NEXT, "update_camera_metadata_entry"));
|
||||||
|
|
||||||
|
if (camera_metadata_entry_t entry;
|
||||||
|
find_camera_metadata_entry(dst, ANDROID_REQUEST_AVAILABLE_CAPABILITIES, &entry) == 0 &&
|
||||||
|
entry.index == index) {
|
||||||
|
std::vector<uint8_t> caps;
|
||||||
|
auto u8 = reinterpret_cast<const uint8_t*>(data);
|
||||||
|
|
||||||
|
for (size_t i = 0; i < data_count; i++) {
|
||||||
|
if (u8[i] != ANDROID_REQUEST_AVAILABLE_CAPABILITIES_SYSTEM_CAMERA) {
|
||||||
|
caps.emplace_back(u8[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return update_camera_metadata_entry_orig(dst, index, caps.data(), caps.size(),
|
||||||
|
updated_entry);
|
||||||
|
}
|
||||||
|
|
||||||
|
return update_camera_metadata_entry_orig(dst, index, data, data_count, updated_entry);
|
||||||
|
}
|
Loading…
Reference in a new issue