问题记录
SOC:RK3568
system:Android12
流行应用 一些APP通过打开板载摄像头出现画面裁剪 画面比例不正常或者是预览方向旋转,但是使用相机APP打开却不会
修改:
hardware\interfaces\camera\device\3.4\default\RgaCropScale.cpp
int RgaCropScale::rga_scale_crop(
int src_width, int src_height,
unsigned long src_fd, int src_format,unsigned long dst_fd,
int dst_width, int dst_height,
int zoom_val, int mirror,bool flipH, bool flipV, bool isNeedCrop,
bool isDstNV21, bool is16Align, bool isYuyvFormat)
{
...
src.rotation = 0;
if (mirror == 90)
src.rotation = HAL_TRANSFORM_ROT_90;
else if(mirror == 180)
src.rotation = HAL_TRANSFORM_ROT_180;
else if(mirror == 270)
src.rotation = HAL_TRANSFORM_ROT_270;
...
}
修改src.rotation赋值:
旋转:
HAL_TRANSFORM_ROT_90;
HAL_TRANSFORM_ROT_180;
HAL_TRANSFORM_ROT_270
镜像:
HAL_TRANSFORM_FLIP_H
HAL_TRANSFORM_FLIP_V
上面修改会影响系统相机画面,添加判断哪个app打开摄像头
frameworks/av/services/camera/libcameraservice/common/Camera2ClientBase.cpp
template <typename TClientBase>
Camera2ClientBase<TClientBase>::Camera2ClientBase(
const sp<CameraService>& cameraService,
const sp<TCamCallbacks>& remoteCallback,
const String16& clientPackageName,
const std::optional<String16>& clientFeatureId,
const String8& cameraId,
int api1CameraId,
int cameraFacing,
int sensorOrientation,
int clientPid,
uid_t clientUid,
int servicePid,
bool overrideForPerfClass,
bool legacyClient):
TClientBase(cameraService, remoteCallback, clientPackageName, clientFeatureId,
cameraId, api1CameraId, cameraFacing, sensorOrientation, clientPid, clientUid,
servicePid),
mSharedCameraCallbacks(remoteCallback),
mDeviceVersion(cameraService->getDeviceVersion(TClientBase::mCameraIdStr)),
mDevice(new Camera3Device(cameraId, overrideForPerfClass, legacyClient)),
mDeviceActive(false), mApi1CameraId(api1CameraId)
{
ALOGI("Camera %s: Opened. Client: %s (PID %d, UID %d)", cameraId.string(),
String8(clientPackageName).string(), clientPid, clientUid);
++ int iCameraIDatoi = atoi(cameraId.string());
++ if(iCameraIDatoi == 0 || iCameraIDatoi == 1){
++__system_property_set("persist.camera.openCameraAPP",String8(clientPackageName).string());
++ }
mInitialClientPid = clientPid;
LOG_ALWAYS_FATAL_IF(mDevice == 0, "Device should never be NULL here.");
}
hardware\interfaces\camera\device\3.4\default\RgaCropScale.cpp
++#include <cutils/properties.h>
int RgaCropScale::rga_scale_crop(
int src_width, int src_height,
unsigned long src_fd, int src_format,unsigned long dst_fd,
int dst_width, int dst_height,
int zoom_val, int mirror,bool flipH, bool flipV, bool isNeedCrop,
bool isDstNV21, bool is16Align, bool isYuyvFormat)
{
...
-- src.rotation = 0;
-- if (mirror == 90)
-- src.rotation = HAL_TRANSFORM_ROT_90;
-- else if(mirror == 180)
-- src.rotation = HAL_TRANSFORM_ROT_180;
-- else if(mirror == 270)
-- src.rotation = HAL_TRANSFORM_ROT_270;
++ char CameraAPP[128];
++ __system_property_get("persist.camera.openCameraAPP",CameraAPP);
++ if(strcmp(CameraAPP,"tv.danmaku.bili") == 0 ){
++ src.rotation = HAL_TRANSFORM_ROT_90;
++ }
...
}