Loading services/java/com/android/server/PowerManagerService.java +1 −0 Original line number Diff line number Diff line Loading @@ -2803,6 +2803,7 @@ class PowerManagerService extends IPowerManager.Stub boolean enabled = (mode == SCREEN_BRIGHTNESS_MODE_AUTOMATIC); if (mUseSoftwareAutoBrightness && mAutoBrightessEnabled != enabled) { mAutoBrightessEnabled = enabled; enableLightSensor(mAutoBrightessEnabled); if (isScreenOn()) { // force recompute of backlight values if (mLightSensorValue >= 0) { Loading services/sensorservice/Android.mk +4 −0 Original line number Diff line number Diff line Loading @@ -24,6 +24,10 @@ ifeq ($(TARGET_HAS_FOXCONN_SENSORS),true) LOCAL_CFLAGS += -DFOXCONN_SENSORS endif ifneq ($(filter p990 p999, $(TARGET_BOOTLOADER_BOARD_NAME)),) LOCAL_CFLAGS += -DUSE_LGE_ALS_DUMMY endif # need "-lrt" on Linux simulator to pick up clock_gettime ifeq ($(TARGET_SIMULATOR),true) ifeq ($(HOST_OS),linux) Loading services/sensorservice/SensorDevice.cpp +69 −6 Original line number Diff line number Diff line Loading @@ -30,6 +30,10 @@ #include "SensorDevice.h" #ifdef USE_LGE_ALS_DUMMY #include <fcntl.h> #endif namespace android { // --------------------------------------------------------------------------- class BatteryService : public Singleton<BatteryService> { Loading Loading @@ -97,6 +101,27 @@ ANDROID_SINGLETON_STATIC_INSTANCE(BatteryService) ANDROID_SINGLETON_STATIC_INSTANCE(SensorDevice) #ifdef USE_LGE_ALS_DUMMY static ssize_t addDummyLGESensor(sensor_t const **list, ssize_t count) { struct sensor_t dummy_light = { name : "Dummy LGE-Star light sensor", vendor : "CyanogenMod", version : 1, handle : SENSOR_TYPE_LIGHT, type : SENSOR_TYPE_LIGHT, maxRange : 20, resolution : 0.1, power : 20, }; void * new_list = malloc((count+1)*sizeof(sensor_t)); new_list = memcpy(new_list, *list, count*sizeof(sensor_t)); ((sensor_t *)new_list)[count] = dummy_light; *list = (sensor_t const *)new_list; count++; return count; } #endif SensorDevice::SensorDevice() : mSensorDevice(0), mOldSensorsEnabled(0), Loading Loading @@ -139,15 +164,23 @@ SensorDevice::SensorDevice() if (mSensorDevice || mOldSensorsCompatMode) { sensor_t const* list; ssize_t count = mSensorModule->get_sensors_list(mSensorModule, &list); mActivationCount.setCapacity(count); Info model; for (size_t i=0 ; i<size_t(count) ; i++) { mActivationCount.add(list[i].handle, model); #ifdef USE_LGE_ALS_DUMMY count = addDummyLGESensor(&list, count); #endif if (mOldSensorsCompatMode) { mOldSensorsList = list; mOldSensorsCount = count; mSensorDataDevice->data_open(mSensorDataDevice, mSensorControlDevice->open_data_source(mSensorControlDevice)); } mActivationCount.setCapacity(count); Info model; for (size_t i=0 ; i<size_t(count) ; i++) { mActivationCount.add(list[i].handle, model); if (mOldSensorsCompatMode) { mSensorControlDevice->activate(mSensorControlDevice, list[i].handle, 0); } else { mSensorDevice->activate(mSensorDevice, list[i].handle, 0); Loading Loading @@ -178,6 +211,10 @@ void SensorDevice::dump(String8& result, char* buffer, size_t SIZE) ssize_t SensorDevice::getSensorList(sensor_t const** list) { if (!mSensorModule) return NO_INIT; ssize_t count = mSensorModule->get_sensors_list(mSensorModule, list); #ifdef USE_LGE_ALS_DUMMY return addDummyLGESensor(list, count); #endif return count; } Loading Loading @@ -258,6 +295,32 @@ status_t SensorDevice::activate(void* ident, int handle, int enabled) status_t err(NO_ERROR); bool actuateHardware = false; #ifdef USE_LGE_ALS_DUMMY if (handle == SENSOR_TYPE_LIGHT) { int nwr, ret, fd; char value[2]; fd = open("/sys/devices/platform/star_aat2870.0/lsensor_onoff", O_RDWR); if(fd < 0) return -ENODEV; nwr = sprintf(value, "%s\n", enabled ? "1" : "0"); write(fd, value, nwr); close(fd); fd = open("/sys/devices/platform/star_aat2870.0/alc", O_RDWR); if(fd < 0) return -ENODEV; nwr = sprintf(value, "%s\n", enabled ? "2" : "0"); write(fd, value, nwr); close(fd); return 0; } #endif Info& info( mActivationCount.editValueFor(handle) ); if (enabled) { Mutex::Autolock _l(mLock); Loading Loading
services/java/com/android/server/PowerManagerService.java +1 −0 Original line number Diff line number Diff line Loading @@ -2803,6 +2803,7 @@ class PowerManagerService extends IPowerManager.Stub boolean enabled = (mode == SCREEN_BRIGHTNESS_MODE_AUTOMATIC); if (mUseSoftwareAutoBrightness && mAutoBrightessEnabled != enabled) { mAutoBrightessEnabled = enabled; enableLightSensor(mAutoBrightessEnabled); if (isScreenOn()) { // force recompute of backlight values if (mLightSensorValue >= 0) { Loading
services/sensorservice/Android.mk +4 −0 Original line number Diff line number Diff line Loading @@ -24,6 +24,10 @@ ifeq ($(TARGET_HAS_FOXCONN_SENSORS),true) LOCAL_CFLAGS += -DFOXCONN_SENSORS endif ifneq ($(filter p990 p999, $(TARGET_BOOTLOADER_BOARD_NAME)),) LOCAL_CFLAGS += -DUSE_LGE_ALS_DUMMY endif # need "-lrt" on Linux simulator to pick up clock_gettime ifeq ($(TARGET_SIMULATOR),true) ifeq ($(HOST_OS),linux) Loading
services/sensorservice/SensorDevice.cpp +69 −6 Original line number Diff line number Diff line Loading @@ -30,6 +30,10 @@ #include "SensorDevice.h" #ifdef USE_LGE_ALS_DUMMY #include <fcntl.h> #endif namespace android { // --------------------------------------------------------------------------- class BatteryService : public Singleton<BatteryService> { Loading Loading @@ -97,6 +101,27 @@ ANDROID_SINGLETON_STATIC_INSTANCE(BatteryService) ANDROID_SINGLETON_STATIC_INSTANCE(SensorDevice) #ifdef USE_LGE_ALS_DUMMY static ssize_t addDummyLGESensor(sensor_t const **list, ssize_t count) { struct sensor_t dummy_light = { name : "Dummy LGE-Star light sensor", vendor : "CyanogenMod", version : 1, handle : SENSOR_TYPE_LIGHT, type : SENSOR_TYPE_LIGHT, maxRange : 20, resolution : 0.1, power : 20, }; void * new_list = malloc((count+1)*sizeof(sensor_t)); new_list = memcpy(new_list, *list, count*sizeof(sensor_t)); ((sensor_t *)new_list)[count] = dummy_light; *list = (sensor_t const *)new_list; count++; return count; } #endif SensorDevice::SensorDevice() : mSensorDevice(0), mOldSensorsEnabled(0), Loading Loading @@ -139,15 +164,23 @@ SensorDevice::SensorDevice() if (mSensorDevice || mOldSensorsCompatMode) { sensor_t const* list; ssize_t count = mSensorModule->get_sensors_list(mSensorModule, &list); mActivationCount.setCapacity(count); Info model; for (size_t i=0 ; i<size_t(count) ; i++) { mActivationCount.add(list[i].handle, model); #ifdef USE_LGE_ALS_DUMMY count = addDummyLGESensor(&list, count); #endif if (mOldSensorsCompatMode) { mOldSensorsList = list; mOldSensorsCount = count; mSensorDataDevice->data_open(mSensorDataDevice, mSensorControlDevice->open_data_source(mSensorControlDevice)); } mActivationCount.setCapacity(count); Info model; for (size_t i=0 ; i<size_t(count) ; i++) { mActivationCount.add(list[i].handle, model); if (mOldSensorsCompatMode) { mSensorControlDevice->activate(mSensorControlDevice, list[i].handle, 0); } else { mSensorDevice->activate(mSensorDevice, list[i].handle, 0); Loading Loading @@ -178,6 +211,10 @@ void SensorDevice::dump(String8& result, char* buffer, size_t SIZE) ssize_t SensorDevice::getSensorList(sensor_t const** list) { if (!mSensorModule) return NO_INIT; ssize_t count = mSensorModule->get_sensors_list(mSensorModule, list); #ifdef USE_LGE_ALS_DUMMY return addDummyLGESensor(list, count); #endif return count; } Loading Loading @@ -258,6 +295,32 @@ status_t SensorDevice::activate(void* ident, int handle, int enabled) status_t err(NO_ERROR); bool actuateHardware = false; #ifdef USE_LGE_ALS_DUMMY if (handle == SENSOR_TYPE_LIGHT) { int nwr, ret, fd; char value[2]; fd = open("/sys/devices/platform/star_aat2870.0/lsensor_onoff", O_RDWR); if(fd < 0) return -ENODEV; nwr = sprintf(value, "%s\n", enabled ? "1" : "0"); write(fd, value, nwr); close(fd); fd = open("/sys/devices/platform/star_aat2870.0/alc", O_RDWR); if(fd < 0) return -ENODEV; nwr = sprintf(value, "%s\n", enabled ? "2" : "0"); write(fd, value, nwr); close(fd); return 0; } #endif Info& info( mActivationCount.editValueFor(handle) ); if (enabled) { Mutex::Autolock _l(mLock); Loading