bugfixes for los 14.1X

This commit is contained in:
PythonLimited 2018-01-07 15:18:14 +01:00
parent 4bb7629c42
commit 55e680dc5f
8 changed files with 119 additions and 151 deletions

View file

@ -1,31 +0,0 @@
/*
* Copyright (C) 2012 The Android Open Source Project
* Copyright (C) 2016 The CyanogenMod Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef _BDROID_BUILDCFG_H
#define _BDROID_BUILDCFG_H
#define BTM_DEF_LOCAL_NAME "Moto G"
#define BLUETOOTH_QTI_SW TRUE
// Disables read remote device feature
#define BTA_SKIP_BLE_READ_REMOTE_FEAT FALSE
#define MAX_L2CAP_CHANNELS 16
// skips conn update at conn completion
#define BTA_BLE_SKIP_CONN_UPD FALSE
/* Defined if the kernel does not have support for CLOCK_BOOTTIME_ALARM */
#define KERNEL_MISSING_CLOCK_BOOTTIME_ALARM TRUE
#endif

View file

@ -1,5 +1,5 @@
/*
* Copyright (C) 2016, The CyanogenMod Project
* Copyright (C) 2018, The LineageOS Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -22,36 +22,18 @@
*/
#define LOG_NDEBUG 0
#define LOG_TAG "CameraWrapper"
#include <cutils/log.h>
#include <cutils/properties.h>
#include <utils/threads.h>
#include <utils/String8.h>
#include <hardware/hardware.h>
#include <hardware/camera.h>
#include <camera/Camera.h>
#include <camera/CameraParameters.h>
#include <camera/CameraParameters2.h>
#define BACK_CAMERA 0
#define FRONT_CAMERA 1
#define OPEN_RETRIES 10
#define OPEN_RETRY_MSEC 40
using namespace android;
enum {
UNKNOWN = -1,
FALCON,
PEREGRINE,
TITAN,
THEA,
};
static int product_device = UNKNOWN;
static Mutex gCameraWrapperLock;
static android::Mutex gCameraWrapperLock;
static camera_module_t *gVendorModule = 0;
static char **fixed_set_params = NULL;
@ -60,8 +42,8 @@ static int camera_device_open(const hw_module_t *module, const char *name,
hw_device_t **device);
static int camera_get_number_of_cameras(void);
static int camera_get_camera_info(int camera_id, struct camera_info *info);
static char videoHfr[4] = "off";
static int camera_send_command(struct camera_device *device, int32_t cmd,
int32_t arg1, int32_t arg2);
static struct hw_module_methods_t camera_module_methods = {
.open = camera_device_open
@ -69,15 +51,15 @@ static struct hw_module_methods_t camera_module_methods = {
camera_module_t HAL_MODULE_INFO_SYM = {
.common = {
.tag = HARDWARE_MODULE_TAG,
.version_major = 3,
.version_minor = 0,
.id = CAMERA_HARDWARE_MODULE_ID,
.name = "msm8226 Camera Wrapper",
.author = "The CyanogenMod Project",
.methods = &camera_module_methods,
.dso = NULL, /* remove compilation warnings */
.reserved = {0}, /* remove compilation warnings */
.tag = HARDWARE_MODULE_TAG,
.module_api_version = CAMERA_MODULE_API_VERSION_1_0,
.hal_api_version = HARDWARE_HAL_API_VERSION,
.id = CAMERA_HARDWARE_MODULE_ID,
.name = "Samsung MSM8226 Camera Wrapper",
.author = "The NeoHomies Project",
.methods = &camera_module_methods,
.dso = NULL, /* remove compilation warnings */
.reserved = {0}, /* remove compilation warnings */
},
.get_number_of_cameras = camera_get_number_of_cameras,
.get_camera_info = camera_get_camera_info,
@ -89,11 +71,6 @@ camera_module_t HAL_MODULE_INFO_SYM = {
.reserved = {0}, /* remove compilation warnings */
};
static int get_product_device()
{
return FALCON;
}
typedef struct wrapper_camera_device {
camera_device_t base;
int id;
@ -116,105 +93,107 @@ static int check_vendor_module()
return 0;
rv = hw_get_module_by_class("camera", "vendor",
(const hw_module_t**)&gVendorModule);
(const hw_module_t **)&gVendorModule);
if (rv)
ALOGE("failed to open vendor camera module");
return rv;
}
#define KEY_VIDEO_HFR_VALUES "video-hfr-values"
const static char * iso_values[] = {"auto,ISO_HJR,ISO100,ISO200,ISO400,ISO800,ISO1600,auto"};
static char *camera_fixup_getparams(int id, const char *settings)
{
CameraParameters params;
params.unflatten(String8(settings));
android::CameraParameters params;
params.unflatten(android::String8(settings));
#if !LOG_NDEBUG
ALOGV("%s: original parameters:", __FUNCTION__);
params.dump();
#endif
if (id == BACK_CAMERA) {
params.set(CameraParameters::KEY_SUPPORTED_FLASH_MODES, "auto,on,off,torch");
// fix params here
params.set(android::CameraParameters::KEY_SUPPORTED_ISO_MODES, iso_values[id]);
params.set(android::CameraParameters::KEY_EXPOSURE_COMPENSATION_STEP, "0.5");
params.set(android::CameraParameters::KEY_MIN_EXPOSURE_COMPENSATION, "-4");
params.set(android::CameraParameters::KEY_MAX_EXPOSURE_COMPENSATION, "4");
/* If the vendor has HFR values but doesn't also expose that
* this can be turned off, fixup the params to tell the Camera
* that it really is okay to turn it off.
*/
const char *hfrValues = params.get(KEY_VIDEO_HFR_VALUES);
if (hfrValues && *hfrValues && ! strstr(hfrValues, "off")) {
char tmp[strlen(hfrValues) + 4 + 1];
sprintf(tmp, "%s,off", hfrValues);
params.set(KEY_VIDEO_HFR_VALUES, tmp);
}
params.set(CameraParameters::KEY_SUPPORTED_DENOISE, "denoise-on,denoise-off");
params.set(CameraParameters::KEY_SUPPORTED_FACE_DETECTION, "on,off");
params.set(CameraParameters::KEY_SUPPORTED_REDEYE_REDUCTION, "enable,disable");
/* Enforce video-snapshot-supported to true */
params.set(android::CameraParameters::KEY_VIDEO_SNAPSHOT_SUPPORTED, "true");
if (get_product_device() == FALCON || get_product_device() == PEREGRINE) {
if (id == BACK_CAMERA) {
params.set(CameraParameters::KEY_SUPPORTED_HFR_SIZES, "1296x728");
params.set(CameraParameters::KEY_SUPPORTED_VIDEO_HIGH_FRAME_RATE_MODES, "60,off");
}
} else {
params.set(CameraParameters::KEY_SUPPORTED_HFR_SIZES, "1296x728,1296x728,720x480");
params.set(CameraParameters::KEY_SUPPORTED_VIDEO_HIGH_FRAME_RATE_MODES, "60,90,120,off");
params.set(CameraParameters::KEY_SUPPORTED_ZSL_MODES, "on,off");
}
if (!(get_product_device() == FALCON || get_product_device() == PEREGRINE) ||
id == BACK_CAMERA) {
params.set(CameraParameters::KEY_SUPPORTED_TOUCH_AF_AEC, "touch-on,touch-off");
params.set(CameraParameters::KEY_SUPPORTED_SCENE_MODES,
"auto,action,portrait,landscape,night,night-portrait,theatre"
"candlelight,beach,snow,sunset,steadyphoto,fireworks,sports,party,"
"auto_hdr,hdr,asd,backlight,flowers,AR");
}
/* HFR video recording workaround */
const char *recordingHint = params.get(CameraParameters::KEY_RECORDING_HINT);
if (recordingHint && !strcmp(recordingHint, "true")) {
params.set(CameraParameters::KEY_VIDEO_HIGH_FRAME_RATE, videoHfr);
}
android::String8 strParams = params.flatten();
char *ret = strdup(strParams.string());
#if !LOG_NDEBUG
ALOGV("%s: fixed parameters:", __FUNCTION__);
params.dump();
#endif
String8 strParams = params.flatten();
char *ret = strdup(strParams.string());
return ret;
}
static char *camera_fixup_setparams(int id, const char *settings)
static char *camera_fixup_setparams(struct camera_device *device, const char *settings)
{
CameraParameters params;
params.unflatten(String8(settings));
int id = CAMERA_ID(device);
android::CameraParameters params;
params.unflatten(android::String8(settings));
#if !LOG_NDEBUG
ALOGV("%s: original parameters:", __FUNCTION__);
params.dump();
#endif
/*
* The video-hfr parameter gets removed from the parameters list by the
* vendor call, unless the Motorola camera app is used. Save the value
* so that we can later return it.
*/
const char *hfr = params.get(CameraParameters::KEY_VIDEO_HIGH_FRAME_RATE);
snprintf(videoHfr, sizeof(videoHfr), "%s", hfr ? hfr : "off");
const char *recordingHint = params.get(android::CameraParameters::KEY_RECORDING_HINT);
bool isVideo = recordingHint && !strcmp(recordingHint, "true");
if (get_product_device() == TITAN || get_product_device() == THEA) {
const char *sceneMode = params.get(CameraParameters::KEY_SCENE_MODE);
if (sceneMode != NULL) {
if (!strcmp(sceneMode, CameraParameters::SCENE_MODE_HDR)) {
params.remove(CameraParameters::KEY_ZSL);
}
}
if (isVideo) {
params.set(android::CameraParameters::KEY_DIS, android::CameraParameters::DIS_DISABLE);
params.set(android::CameraParameters::KEY_ZSL, android::CameraParameters::ZSL_OFF);
} else {
params.set(android::CameraParameters::KEY_ZSL, android::CameraParameters::ZSL_ON);
}
// fix params here
// No need to fix-up ISO_HJR, it is the same for userspace and the camera lib
if (params.get("iso")) {
const char *isoMode = params.get(android::CameraParameters::KEY_ISO_MODE);
if (strcmp(isoMode, "ISO100") == 0)
params.set(android::CameraParameters::KEY_ISO_MODE, "100");
else if (strcmp(isoMode, "ISO200") == 0)
params.set(android::CameraParameters::KEY_ISO_MODE, "200");
else if (strcmp(isoMode, "ISO400") == 0)
params.set(android::CameraParameters::KEY_ISO_MODE, "400");
else if (strcmp(isoMode, "ISO800") == 0)
params.set(android::CameraParameters::KEY_ISO_MODE, "800");
else if (strcmp(isoMode, "ISO1600") == 0)
params.set(android::CameraParameters::KEY_ISO_MODE, "1600");
}
android::String8 strParams = params.flatten();
if (fixed_set_params[id])
free(fixed_set_params[id]);
fixed_set_params[id] = strdup(strParams.string());
char *ret = fixed_set_params[id];
#if !LOG_NDEBUG
ALOGV("%s: fixed parameters:", __FUNCTION__);
params.dump();
#endif
String8 strParams = params.flatten();
if (fixed_set_params[id])
free(fixed_set_params[id]);
fixed_set_params[id] = strdup(strParams.string());
char *ret = fixed_set_params[id];
return ret;
}
@ -247,8 +226,7 @@ static void camera_set_callbacks(struct camera_device *device,
if (!device)
return;
VENDOR_CALL(device, set_callbacks, notify_cb, data_cb, data_cb_timestamp,
get_memory, user);
VENDOR_CALL(device, set_callbacks, notify_cb, data_cb, data_cb_timestamp, get_memory, user);
}
static void camera_enable_msg_type(struct camera_device *device,
@ -421,8 +399,7 @@ static int camera_cancel_picture(struct camera_device *device)
return VENDOR_CALL(device, cancel_picture);
}
static int camera_set_parameters(struct camera_device *device,
const char *params)
static int camera_set_parameters(struct camera_device *device, const char *params)
{
ALOGV("%s->%08X->%08X", __FUNCTION__, (uintptr_t)device,
(uintptr_t)(((wrapper_camera_device_t*)device)->vendor));
@ -431,7 +408,7 @@ static int camera_set_parameters(struct camera_device *device,
return -EINVAL;
char *tmp = NULL;
tmp = camera_fixup_setparams(CAMERA_ID(device), params);
tmp = camera_fixup_setparams(device, params);
int ret = VENDOR_CALL(device, set_parameters, tmp);
return ret;
@ -450,6 +427,7 @@ static char *camera_get_parameters(struct camera_device *device)
char *tmp = camera_fixup_getparams(CAMERA_ID(device), params);
VENDOR_CALL(device, put_parameters, params);
params = tmp;
return params;
}
@ -505,7 +483,7 @@ static int camera_device_close(hw_device_t *device)
ALOGV("%s", __FUNCTION__);
Mutex::Autolock lock(gCameraWrapperLock);
android::Mutex::Autolock lock(gCameraWrapperLock);
if (!device) {
ret = -EINVAL;
@ -549,7 +527,7 @@ static int camera_device_open(const hw_module_t *module, const char *name,
wrapper_camera_device_t *camera_device = NULL;
camera_device_ops_t *camera_ops = NULL;
Mutex::Autolock lock(gCameraWrapperLock);
android::Mutex::Autolock lock(gCameraWrapperLock);
ALOGV("%s", __FUNCTION__);
@ -585,16 +563,9 @@ static int camera_device_open(const hw_module_t *module, const char *name,
memset(camera_device, 0, sizeof(*camera_device));
camera_device->id = cameraid;
int retries = OPEN_RETRIES;
bool retry;
do {
rv = gVendorModule->common.methods->open(
(const hw_module_t*)gVendorModule, name,
(hw_device_t**)&(camera_device->vendor));
retry = --retries > 0 && rv;
if (retry)
usleep(OPEN_RETRY_MSEC * 1000);
} while (retry);
rv = gVendorModule->common.methods->open(
(const hw_module_t*)gVendorModule, name,
(hw_device_t**)&(camera_device->vendor));
if (rv) {
ALOGE("vendor camera open fail");
goto fail;
@ -612,7 +583,7 @@ static int camera_device_open(const hw_module_t *module, const char *name,
memset(camera_ops, 0, sizeof(*camera_ops));
camera_device->base.common.tag = HARDWARE_DEVICE_TAG;
camera_device->base.common.version = 3;
camera_device->base.common.version = HARDWARE_DEVICE_API_VERSION(1, 0);
camera_device->base.common.module = (hw_module_t *)(module);
camera_device->base.common.close = camera_device_close;
camera_device->base.ops = camera_ops;

2
sepolicy/cameraserver.te Normal file
View file

@ -0,0 +1,2 @@
allow cameraserver system_data_file:sock_file write;
allow cameraserver camera_socket:sock_file write;

View file

@ -1 +1,3 @@
allow init tmpfs:lnk_file create_file_perms;
allow init debugfs:dir mounton;
allow init wcnss_device:chr_file write;

View file

@ -4,10 +4,11 @@ allow mm-qcamerad sysfs_camera:file rw_file_perms;
allow mm-qcamerad system_data_file:dir w_dir_perms;
allow mm-qcamerad system_data_file:file open;
#allow mm-qcamerad system_file:file execmod;
#type_transition mm-qcamerad system_data_file:sock_file camera_socket "cam_socket3";
#type_transition mm-qcamerad system_data_file:sock_file camera_socket "cam_socket2";
allow mm-qcamerad system_data_file:sock_file rw_file_perms;
allow mm-qcamerad system_data_file:sock_file rw_file_perms;
allow mm-qcamerad system_server:unix_stream_socket rw_socket_perms;
allow mm-qcamerad system_data_file:sock_file { create unlink };
binder_call(mm-qcamerad, servicemanager)
binder_call(mm-qcamerad, system_server)

1
sepolicy/mpdecision.te Normal file
View file

@ -0,0 +1 @@
allow mpdecision socket_device:dir write;

View file

@ -0,0 +1,2 @@
allow untrusted_app fuse:lnk_file read;
allow untrusted_app sysfs:file { getattr open read };

View file

@ -17,11 +17,31 @@
#include <stdlib.h>
#include <stdint.h>
#include <media/IMediaSource.h>
#include <cutils/log.h>
#include <string.h>
#include <media/stagefright/MediaBufferGroup.h>
#include <media/stagefright/MediaSource.h>
/* MediaBufferGroup::MediaBufferGroup */
extern "C" int _ZN7android16MediaBufferGroupC1Ej(unsigned int);
extern "C" int _ZN7android16MediaBufferGroupC1Ev() {
return _ZN7android16MediaBufferGroupC1Ej(0);
//extern "C" int _ZN7android16MediaBufferGroupC1Ej(unsigned int);
//extern "C" int _ZN7android16MediaBufferGroupC1Ev() {
// return _ZN7android16MediaBufferGroupC1Ej(0);
//}
extern android::MediaBufferGroup* _ZN7android16MediaBufferGroupC1Ev() {
#ifdef AOSP
return new android::MediaBufferGroup();
#else
return new android::MediaBufferGroup(0);
#endif
}
extern int _ZN7android16MediaBufferGroup14acquire_bufferEPPNS_11MediaBufferEb(void *obj,android::MediaBuffer **out,
bool nonBlocking, size_t requestedSize) {
android::MediaBufferGroup *mbg = static_cast<android::MediaBufferGroup *>(obj);
return mbg->acquire_buffer(out,nonBlocking,requestedSize);
}
extern "C" {