remove cdma references from supersonic, stupid me on accidently mergin the 2 folders and use Passion lib sensors cuz leo akmd isnt working
This commit is contained in:
parent
4451d92d32
commit
0bbb7ccecb
22
Android.mk
Executable file
22
Android.mk
Executable file
@ -0,0 +1,22 @@
|
||||
# Copyright (C) 2009 The Android Open Source 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.
|
||||
|
||||
LOCAL_PATH := $(my-dir)
|
||||
subdir_makefiles := \
|
||||
$(LOCAL_PATH)/libreference-ril/Android.mk \
|
||||
$(LOCAL_PATH)/libgps/Android.mk \
|
||||
$(LOCAL_PATH)/libsensors/Android.mk \
|
||||
$(LOCAL_PATH)/liblights/Android.mk
|
||||
|
||||
include $(subdir_makefiles)
|
@ -1,27 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Copyright (C) 2008 The Android Open Source 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.
|
||||
-->
|
||||
|
||||
<!-- This file contains fake APNs that are necessary for the emulator
|
||||
to talk to the network. It should only be installed for SDK builds.
|
||||
|
||||
This file is not installed by the local Android.mk, it's installed using
|
||||
a PRODUCT_COPY_FILES line in the sdk section of the toplevel Makefile.
|
||||
-->
|
||||
<apns version="6">
|
||||
<!-- use empty string to specify no proxy or port -->
|
||||
<apn carrier="CDMA" mcc="310" mnc="120" apn="0" port="" mmsproxy="" mmsport="" mmsc="" type="*"/>
|
||||
<apn carrier="CDMA" mcc="310" mnc="120" apn="1" port="" mmsproxy="" mmsport="" mmsc="http://mms.sprintpcs.com" />
|
||||
</apns>
|
23
leo.mk
23
leo.mk
@ -28,15 +28,22 @@ PRODUCT_COPY_FILES += \
|
||||
PRODUCT_COPY_FILES += \
|
||||
device/htc/leo/init.leo.rc:root/init.leo.rc \
|
||||
|
||||
PRODUCT_PROPERTY_OVERRIDES := \
|
||||
PRODUCT_PROPERTY_OVERRIDES += \
|
||||
ro.sf.lcd_density=240 \
|
||||
rild.libpath=/system/lib/libhtc_ril.so \
|
||||
wifi.interface=eth0 \
|
||||
wifi.supplicant_scan_interval=15 \
|
||||
ro.ril.ecc.HTC-ELL=92,93,94 \
|
||||
ro.ril.ecc.HTC-WWE=999 \
|
||||
ro.ril.enable.a52.HTC-ITA=1 \
|
||||
ro.ril.enable.a53.HTC-ITA=1 \
|
||||
ro.ril.enable.a52=0 \
|
||||
ro.ril.enable.a53=1 \
|
||||
ro.ril.enable.dtm = 1 \
|
||||
ro.ril.gprsclass = 12 \
|
||||
ro.ril.hsdpa.category=8 \
|
||||
ro.ril.hsupa.category=5 \
|
||||
ro.ril.hsxpa=2 \
|
||||
ro.ril.gprsclass=10
|
||||
|
||||
|
||||
wifi.interface=eth0 \
|
||||
wifi.supplicant_scan_interval=15
|
||||
|
||||
# Default network type.
|
||||
# 0 => WCDMA preferred.
|
||||
@ -47,6 +54,10 @@ PRODUCT_PROPERTY_OVERRIDES += \
|
||||
PRODUCT_PROPERTY_OVERRIDES += \
|
||||
ro.ril.disable.power.collapse = 1
|
||||
|
||||
# AGPS otpions
|
||||
PRODUCT_PROPERTY_OVERRIDES += \
|
||||
ro.ril.def.agps.mode=2
|
||||
|
||||
# The OpenGL ES API level that is natively supported by this device.
|
||||
# This is a 16.16 fixed point number
|
||||
PRODUCT_PROPERTY_OVERRIDES += \
|
||||
|
295
libsensors/AkmSensor.cpp
Normal file
295
libsensors/AkmSensor.cpp
Normal file
@ -0,0 +1,295 @@
|
||||
/*
|
||||
* Copyright (C) 2008 The Android Open Source 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.
|
||||
*/
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <errno.h>
|
||||
#include <math.h>
|
||||
#include <poll.h>
|
||||
#include <unistd.h>
|
||||
#include <dirent.h>
|
||||
#include <sys/select.h>
|
||||
|
||||
#include <linux/akm8973.h>
|
||||
|
||||
#include <cutils/log.h>
|
||||
|
||||
#include "AkmSensor.h"
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
AkmSensor::AkmSensor()
|
||||
: SensorBase(AKM_DEVICE_NAME, "compass"),
|
||||
mEnabled(0),
|
||||
mPendingMask(0),
|
||||
mInputReader(32)
|
||||
{
|
||||
memset(mPendingEvents, 0, sizeof(mPendingEvents));
|
||||
|
||||
mPendingEvents[Accelerometer].version = sizeof(sensors_event_t);
|
||||
mPendingEvents[Accelerometer].sensor = ID_A;
|
||||
mPendingEvents[Accelerometer].type = SENSOR_TYPE_ACCELEROMETER;
|
||||
mPendingEvents[Accelerometer].acceleration.status = SENSOR_STATUS_ACCURACY_HIGH;
|
||||
|
||||
mPendingEvents[MagneticField].version = sizeof(sensors_event_t);
|
||||
mPendingEvents[MagneticField].sensor = ID_M;
|
||||
mPendingEvents[MagneticField].type = SENSOR_TYPE_MAGNETIC_FIELD;
|
||||
mPendingEvents[MagneticField].magnetic.status = SENSOR_STATUS_ACCURACY_HIGH;
|
||||
|
||||
mPendingEvents[Orientation ].version = sizeof(sensors_event_t);
|
||||
mPendingEvents[Orientation ].sensor = ID_O;
|
||||
mPendingEvents[Orientation ].type = SENSOR_TYPE_ORIENTATION;
|
||||
mPendingEvents[Orientation ].orientation.status = SENSOR_STATUS_ACCURACY_HIGH;
|
||||
|
||||
for (int i=0 ; i<numSensors ; i++)
|
||||
mDelays[i] = 200000000; // 200 ms by default
|
||||
|
||||
// read the actual value of all sensors if they're enabled already
|
||||
struct input_absinfo absinfo;
|
||||
short flags = 0;
|
||||
|
||||
open_device();
|
||||
|
||||
if (!ioctl(dev_fd, ECS_IOCTL_APP_GET_AFLAG, &flags)) {
|
||||
if (flags) {
|
||||
mEnabled |= 1<<Accelerometer;
|
||||
if (!ioctl(data_fd, EVIOCGABS(EVENT_TYPE_ACCEL_X), &absinfo)) {
|
||||
mPendingEvents[Accelerometer].acceleration.x = absinfo.value * CONVERT_A_X;
|
||||
}
|
||||
if (!ioctl(data_fd, EVIOCGABS(EVENT_TYPE_ACCEL_Y), &absinfo)) {
|
||||
mPendingEvents[Accelerometer].acceleration.y = absinfo.value * CONVERT_A_Y;
|
||||
}
|
||||
if (!ioctl(data_fd, EVIOCGABS(EVENT_TYPE_ACCEL_Z), &absinfo)) {
|
||||
mPendingEvents[Accelerometer].acceleration.z = absinfo.value * CONVERT_A_Z;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!ioctl(dev_fd, ECS_IOCTL_APP_GET_MVFLAG, &flags)) {
|
||||
if (flags) {
|
||||
mEnabled |= 1<<MagneticField;
|
||||
if (!ioctl(data_fd, EVIOCGABS(EVENT_TYPE_MAGV_X), &absinfo)) {
|
||||
mPendingEvents[MagneticField].magnetic.x = absinfo.value * CONVERT_M_X;
|
||||
}
|
||||
if (!ioctl(data_fd, EVIOCGABS(EVENT_TYPE_MAGV_Y), &absinfo)) {
|
||||
mPendingEvents[MagneticField].magnetic.y = absinfo.value * CONVERT_M_Y;
|
||||
}
|
||||
if (!ioctl(data_fd, EVIOCGABS(EVENT_TYPE_MAGV_Z), &absinfo)) {
|
||||
mPendingEvents[MagneticField].magnetic.z = absinfo.value * CONVERT_M_Z;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!ioctl(dev_fd, ECS_IOCTL_APP_GET_MFLAG, &flags)) {
|
||||
if (flags) {
|
||||
mEnabled |= 1<<Orientation;
|
||||
if (!ioctl(data_fd, EVIOCGABS(EVENT_TYPE_YAW), &absinfo)) {
|
||||
mPendingEvents[Orientation].orientation.azimuth = absinfo.value;
|
||||
}
|
||||
if (!ioctl(data_fd, EVIOCGABS(EVENT_TYPE_PITCH), &absinfo)) {
|
||||
mPendingEvents[Orientation].orientation.pitch = absinfo.value;
|
||||
}
|
||||
if (!ioctl(data_fd, EVIOCGABS(EVENT_TYPE_ROLL), &absinfo)) {
|
||||
mPendingEvents[Orientation].orientation.roll = -absinfo.value;
|
||||
}
|
||||
if (!ioctl(data_fd, EVIOCGABS(EVENT_TYPE_ORIENT_STATUS), &absinfo)) {
|
||||
mPendingEvents[Orientation].orientation.status = uint8_t(absinfo.value & SENSOR_STATE_MASK);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// disable temperature sensor, since it is not reported
|
||||
flags = 0;
|
||||
ioctl(dev_fd, ECS_IOCTL_APP_SET_TFLAG, &flags);
|
||||
|
||||
if (!mEnabled) {
|
||||
close_device();
|
||||
}
|
||||
}
|
||||
|
||||
AkmSensor::~AkmSensor() {
|
||||
}
|
||||
|
||||
int AkmSensor::enable(int32_t handle, int en)
|
||||
{
|
||||
int what = -1;
|
||||
switch (handle) {
|
||||
case ID_A: what = Accelerometer; break;
|
||||
case ID_M: what = MagneticField; break;
|
||||
case ID_O: what = Orientation; break;
|
||||
}
|
||||
|
||||
if (uint32_t(what) >= numSensors)
|
||||
return -EINVAL;
|
||||
|
||||
int newState = en ? 1 : 0;
|
||||
int err = 0;
|
||||
|
||||
if ((uint32_t(newState)<<what) != (mEnabled & (1<<what))) {
|
||||
if (!mEnabled) {
|
||||
open_device();
|
||||
}
|
||||
int cmd;
|
||||
switch (what) {
|
||||
case Accelerometer: cmd = ECS_IOCTL_APP_SET_AFLAG; break;
|
||||
case MagneticField: cmd = ECS_IOCTL_APP_SET_MVFLAG; break;
|
||||
case Orientation: cmd = ECS_IOCTL_APP_SET_MFLAG; break;
|
||||
}
|
||||
short flags = newState;
|
||||
err = ioctl(dev_fd, cmd, &flags);
|
||||
err = err<0 ? -errno : 0;
|
||||
LOGE_IF(err, "ECS_IOCTL_APP_SET_XXX failed (%s)", strerror(-err));
|
||||
if (!err) {
|
||||
mEnabled &= ~(1<<what);
|
||||
mEnabled |= (uint32_t(flags)<<what);
|
||||
update_delay();
|
||||
}
|
||||
if (!mEnabled) {
|
||||
close_device();
|
||||
}
|
||||
}
|
||||
return err;
|
||||
}
|
||||
|
||||
int AkmSensor::setDelay(int32_t handle, int64_t ns)
|
||||
{
|
||||
#ifdef ECS_IOCTL_APP_SET_DELAY
|
||||
int what = -1;
|
||||
switch (handle) {
|
||||
case ID_A: what = Accelerometer; break;
|
||||
case ID_M: what = MagneticField; break;
|
||||
case ID_O: what = Orientation; break;
|
||||
}
|
||||
|
||||
if (uint32_t(what) >= numSensors)
|
||||
return -EINVAL;
|
||||
|
||||
if (ns < 0)
|
||||
return -EINVAL;
|
||||
|
||||
mDelays[what] = ns;
|
||||
return update_delay();
|
||||
#else
|
||||
return -1;
|
||||
#endif
|
||||
}
|
||||
|
||||
int AkmSensor::update_delay()
|
||||
{
|
||||
if (mEnabled) {
|
||||
uint64_t wanted = -1LLU;
|
||||
for (int i=0 ; i<numSensors ; i++) {
|
||||
if (mEnabled & (1<<i)) {
|
||||
uint64_t ns = mDelays[i];
|
||||
wanted = wanted < ns ? wanted : ns;
|
||||
}
|
||||
}
|
||||
short delay = int64_t(wanted) / 1000000;
|
||||
if (ioctl(dev_fd, ECS_IOCTL_APP_SET_DELAY, &delay)) {
|
||||
return -errno;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int AkmSensor::readEvents(sensors_event_t* data, int count)
|
||||
{
|
||||
if (count < 1)
|
||||
return -EINVAL;
|
||||
|
||||
ssize_t n = mInputReader.fill(data_fd);
|
||||
if (n < 0)
|
||||
return n;
|
||||
|
||||
int numEventReceived = 0;
|
||||
input_event const* event;
|
||||
|
||||
while (count && mInputReader.readEvent(&event)) {
|
||||
int type = event->type;
|
||||
if (type == EV_ABS) {
|
||||
processEvent(event->code, event->value);
|
||||
mInputReader.next();
|
||||
} else if (type == EV_SYN) {
|
||||
int64_t time = timevalToNano(event->time);
|
||||
for (int j=0 ; count && mPendingMask && j<numSensors ; j++) {
|
||||
if (mPendingMask & (1<<j)) {
|
||||
mPendingMask &= ~(1<<j);
|
||||
mPendingEvents[j].timestamp = time;
|
||||
if (mEnabled & (1<<j)) {
|
||||
*data++ = mPendingEvents[j];
|
||||
count--;
|
||||
numEventReceived++;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!mPendingMask) {
|
||||
mInputReader.next();
|
||||
}
|
||||
} else {
|
||||
LOGE("AkmSensor: unknown event (type=%d, code=%d)",
|
||||
type, event->code);
|
||||
mInputReader.next();
|
||||
}
|
||||
}
|
||||
|
||||
return numEventReceived;
|
||||
}
|
||||
|
||||
void AkmSensor::processEvent(int code, int value)
|
||||
{
|
||||
switch (code) {
|
||||
case EVENT_TYPE_ACCEL_X:
|
||||
mPendingMask |= 1<<Accelerometer;
|
||||
mPendingEvents[Accelerometer].acceleration.x = value * CONVERT_A_X;
|
||||
break;
|
||||
case EVENT_TYPE_ACCEL_Y:
|
||||
mPendingMask |= 1<<Accelerometer;
|
||||
mPendingEvents[Accelerometer].acceleration.y = value * CONVERT_A_Y;
|
||||
break;
|
||||
case EVENT_TYPE_ACCEL_Z:
|
||||
mPendingMask |= 1<<Accelerometer;
|
||||
mPendingEvents[Accelerometer].acceleration.z = value * CONVERT_A_Z;
|
||||
break;
|
||||
|
||||
case EVENT_TYPE_MAGV_X:
|
||||
mPendingMask |= 1<<MagneticField;
|
||||
mPendingEvents[MagneticField].magnetic.x = value * CONVERT_M_X;
|
||||
break;
|
||||
case EVENT_TYPE_MAGV_Y:
|
||||
mPendingMask |= 1<<MagneticField;
|
||||
mPendingEvents[MagneticField].magnetic.y = value * CONVERT_M_Y;
|
||||
break;
|
||||
case EVENT_TYPE_MAGV_Z:
|
||||
mPendingMask |= 1<<MagneticField;
|
||||
mPendingEvents[MagneticField].magnetic.z = value * CONVERT_M_Z;
|
||||
break;
|
||||
|
||||
case EVENT_TYPE_YAW:
|
||||
mPendingMask |= 1<<Orientation;
|
||||
mPendingEvents[Orientation].orientation.azimuth = value * CONVERT_O_Y;
|
||||
break;
|
||||
case EVENT_TYPE_PITCH:
|
||||
mPendingMask |= 1<<Orientation;
|
||||
mPendingEvents[Orientation].orientation.pitch = value * CONVERT_O_P;
|
||||
break;
|
||||
case EVENT_TYPE_ROLL:
|
||||
mPendingMask |= 1<<Orientation;
|
||||
mPendingEvents[Orientation].orientation.roll = value * CONVERT_O_R;
|
||||
break;
|
||||
case EVENT_TYPE_ORIENT_STATUS:
|
||||
mPendingMask |= 1<<Orientation;
|
||||
mPendingEvents[Orientation].orientation.status =
|
||||
uint8_t(value & SENSOR_STATE_MASK);
|
||||
break;
|
||||
}
|
||||
}
|
62
libsensors/AkmSensor.h
Normal file
62
libsensors/AkmSensor.h
Normal file
@ -0,0 +1,62 @@
|
||||
/*
|
||||
* Copyright (C) 2008 The Android Open Source 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 ANDROID_AKM_SENSOR_H
|
||||
#define ANDROID_AKM_SENSOR_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <errno.h>
|
||||
#include <sys/cdefs.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
|
||||
#include "nusensors.h"
|
||||
#include "SensorBase.h"
|
||||
#include "InputEventReader.h"
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
struct input_event;
|
||||
|
||||
class AkmSensor : public SensorBase {
|
||||
public:
|
||||
AkmSensor();
|
||||
virtual ~AkmSensor();
|
||||
|
||||
enum {
|
||||
Accelerometer = 0,
|
||||
MagneticField = 1,
|
||||
Orientation = 2,
|
||||
numSensors
|
||||
};
|
||||
|
||||
virtual int setDelay(int32_t handle, int64_t ns);
|
||||
virtual int enable(int32_t handle, int enabled);
|
||||
virtual int readEvents(sensors_event_t* data, int count);
|
||||
void processEvent(int code, int value);
|
||||
|
||||
private:
|
||||
int update_delay();
|
||||
uint32_t mEnabled;
|
||||
uint32_t mPendingMask;
|
||||
InputEventCircularReader mInputReader;
|
||||
sensors_event_t mPendingEvents[numSensors];
|
||||
uint64_t mDelays[numSensors];
|
||||
};
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
#endif // ANDROID_AKM_SENSOR_H
|
@ -27,7 +27,16 @@ LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)/hw
|
||||
|
||||
LOCAL_MODULE_TAGS := optional
|
||||
|
||||
LOCAL_SRC_FILES := leosensors.c
|
||||
LOCAL_CFLAGS := -DLOG_TAG=\"Sensors\"
|
||||
LOCAL_SRC_FILES := \
|
||||
sensors.c \
|
||||
nusensors.cpp \
|
||||
InputEventReader.cpp \
|
||||
SensorBase.cpp \
|
||||
LightSensor.cpp \
|
||||
ProximitySensor.cpp \
|
||||
AkmSensor.cpp
|
||||
|
||||
LOCAL_SHARED_LIBRARIES := liblog libcutils
|
||||
LOCAL_PRELINK_MODULE := false
|
||||
|
||||
|
88
libsensors/InputEventReader.cpp
Normal file
88
libsensors/InputEventReader.cpp
Normal file
@ -0,0 +1,88 @@
|
||||
/*
|
||||
* Copyright (C) 2008 The Android Open Source 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.
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include <errno.h>
|
||||
#include <unistd.h>
|
||||
#include <poll.h>
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <linux/input.h>
|
||||
|
||||
#include <cutils/log.h>
|
||||
|
||||
#include "InputEventReader.h"
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
struct input_event;
|
||||
|
||||
InputEventCircularReader::InputEventCircularReader(size_t numEvents)
|
||||
: mBuffer(new input_event[numEvents * 2]),
|
||||
mBufferEnd(mBuffer + numEvents),
|
||||
mHead(mBuffer),
|
||||
mCurr(mBuffer),
|
||||
mFreeSpace(numEvents)
|
||||
{
|
||||
}
|
||||
|
||||
InputEventCircularReader::~InputEventCircularReader()
|
||||
{
|
||||
delete [] mBuffer;
|
||||
}
|
||||
|
||||
ssize_t InputEventCircularReader::fill(int fd)
|
||||
{
|
||||
size_t numEventsRead = 0;
|
||||
if (mFreeSpace) {
|
||||
const ssize_t nread = read(fd, mHead, mFreeSpace * sizeof(input_event));
|
||||
if (nread<0 || nread % sizeof(input_event)) {
|
||||
// we got a partial event!!
|
||||
return nread<0 ? -errno : -EINVAL;
|
||||
}
|
||||
|
||||
numEventsRead = nread / sizeof(input_event);
|
||||
if (numEventsRead) {
|
||||
mHead += numEventsRead;
|
||||
mFreeSpace -= numEventsRead;
|
||||
if (mHead > mBufferEnd) {
|
||||
size_t s = mHead - mBufferEnd;
|
||||
memcpy(mBuffer, mBufferEnd, s * sizeof(input_event));
|
||||
mHead = mBuffer + s;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return numEventsRead;
|
||||
}
|
||||
|
||||
ssize_t InputEventCircularReader::readEvent(input_event const** events)
|
||||
{
|
||||
*events = mCurr;
|
||||
ssize_t available = (mBufferEnd - mBuffer) - mFreeSpace;
|
||||
return available ? 1 : 0;
|
||||
}
|
||||
|
||||
void InputEventCircularReader::next()
|
||||
{
|
||||
mCurr++;
|
||||
mFreeSpace++;
|
||||
if (mCurr >= mBufferEnd) {
|
||||
mCurr = mBuffer;
|
||||
}
|
||||
}
|
47
libsensors/InputEventReader.h
Normal file
47
libsensors/InputEventReader.h
Normal file
@ -0,0 +1,47 @@
|
||||
/*
|
||||
* Copyright (C) 2008 The Android Open Source 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 ANDROID_INPUT_EVENT_READER_H
|
||||
#define ANDROID_INPUT_EVENT_READER_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <errno.h>
|
||||
#include <sys/cdefs.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
struct input_event;
|
||||
|
||||
class InputEventCircularReader
|
||||
{
|
||||
struct input_event* const mBuffer;
|
||||
struct input_event* const mBufferEnd;
|
||||
struct input_event* mHead;
|
||||
struct input_event* mCurr;
|
||||
ssize_t mFreeSpace;
|
||||
|
||||
public:
|
||||
InputEventCircularReader(size_t numEvents);
|
||||
~InputEventCircularReader();
|
||||
ssize_t fill(int fd);
|
||||
ssize_t readEvent(input_event const** events);
|
||||
void next();
|
||||
};
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
#endif // ANDROID_INPUT_EVENT_READER_H
|
154
libsensors/LightSensor.cpp
Normal file
154
libsensors/LightSensor.cpp
Normal file
@ -0,0 +1,154 @@
|
||||
/*
|
||||
* Copyright (C) 2008 The Android Open Source 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.
|
||||
*/
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <errno.h>
|
||||
#include <math.h>
|
||||
#include <poll.h>
|
||||
#include <unistd.h>
|
||||
#include <dirent.h>
|
||||
#include <sys/select.h>
|
||||
|
||||
#include <linux/lightsensor.h>
|
||||
|
||||
#include <cutils/log.h>
|
||||
|
||||
#include "LightSensor.h"
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
LightSensor::LightSensor()
|
||||
: SensorBase(LS_DEVICE_NAME, "lightsensor-level"),
|
||||
mEnabled(0),
|
||||
mInputReader(4),
|
||||
mHasPendingEvent(false)
|
||||
{
|
||||
mPendingEvent.version = sizeof(sensors_event_t);
|
||||
mPendingEvent.sensor = ID_L;
|
||||
mPendingEvent.type = SENSOR_TYPE_LIGHT;
|
||||
memset(mPendingEvent.data, 0, sizeof(mPendingEvent.data));
|
||||
|
||||
open_device();
|
||||
|
||||
int flags = 0;
|
||||
if (!ioctl(dev_fd, LIGHTSENSOR_IOCTL_GET_ENABLED, &flags)) {
|
||||
if (flags) {
|
||||
mEnabled = 1;
|
||||
setInitialState();
|
||||
}
|
||||
}
|
||||
|
||||
if (!mEnabled) {
|
||||
close_device();
|
||||
}
|
||||
}
|
||||
|
||||
LightSensor::~LightSensor() {
|
||||
}
|
||||
|
||||
int LightSensor::setInitialState() {
|
||||
struct input_absinfo absinfo;
|
||||
if (!ioctl(data_fd, EVIOCGABS(EVENT_TYPE_LIGHT), &absinfo)) {
|
||||
mPendingEvent.light = indexToValue(absinfo.value);
|
||||
mHasPendingEvent = true;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int LightSensor::enable(int32_t, int en) {
|
||||
int flags = en ? 1 : 0;
|
||||
int err = 0;
|
||||
if (flags != mEnabled) {
|
||||
if (!mEnabled) {
|
||||
open_device();
|
||||
}
|
||||
err = ioctl(dev_fd, LIGHTSENSOR_IOCTL_ENABLE, &flags);
|
||||
err = err<0 ? -errno : 0;
|
||||
LOGE_IF(err, "LIGHTSENSOR_IOCTL_ENABLE failed (%s)", strerror(-err));
|
||||
if (!err) {
|
||||
mEnabled = en ? 1 : 0;
|
||||
if (en) {
|
||||
setInitialState();
|
||||
}
|
||||
}
|
||||
if (!mEnabled) {
|
||||
close_device();
|
||||
}
|
||||
}
|
||||
return err;
|
||||
}
|
||||
|
||||
bool LightSensor::hasPendingEvents() const {
|
||||
return mHasPendingEvent;
|
||||
}
|
||||
|
||||
int LightSensor::readEvents(sensors_event_t* data, int count)
|
||||
{
|
||||
if (count < 1)
|
||||
return -EINVAL;
|
||||
|
||||
if (mHasPendingEvent) {
|
||||
mHasPendingEvent = false;
|
||||
mPendingEvent.timestamp = getTimestamp();
|
||||
*data = mPendingEvent;
|
||||
return mEnabled ? 1 : 0;
|
||||
}
|
||||
|
||||
ssize_t n = mInputReader.fill(data_fd);
|
||||
if (n < 0)
|
||||
return n;
|
||||
|
||||
int numEventReceived = 0;
|
||||
input_event const* event;
|
||||
|
||||
while (count && mInputReader.readEvent(&event)) {
|
||||
int type = event->type;
|
||||
if (type == EV_ABS) {
|
||||
if (event->code == EVENT_TYPE_LIGHT) {
|
||||
if (event->value != -1) {
|
||||
// FIXME: not sure why we're getting -1 sometimes
|
||||
mPendingEvent.light = indexToValue(event->value);
|
||||
}
|
||||
}
|
||||
} else if (type == EV_SYN) {
|
||||
mPendingEvent.timestamp = timevalToNano(event->time);
|
||||
if (mEnabled) {
|
||||
*data++ = mPendingEvent;
|
||||
count--;
|
||||
numEventReceived++;
|
||||
}
|
||||
} else {
|
||||
LOGE("LightSensor: unknown event (type=%d, code=%d)",
|
||||
type, event->code);
|
||||
}
|
||||
mInputReader.next();
|
||||
}
|
||||
|
||||
return numEventReceived;
|
||||
}
|
||||
|
||||
float LightSensor::indexToValue(size_t index) const
|
||||
{
|
||||
static const float luxValues[10] = {
|
||||
10.0, 160.0, 225.0, 320.0, 640.0,
|
||||
1280.0, 2600.0, 5800.0, 8000.0, 10240.0
|
||||
};
|
||||
|
||||
const size_t maxIndex = sizeof(luxValues)/sizeof(*luxValues) - 1;
|
||||
if (index > maxIndex)
|
||||
index = maxIndex;
|
||||
return luxValues[index];
|
||||
}
|
52
libsensors/LightSensor.h
Normal file
52
libsensors/LightSensor.h
Normal file
@ -0,0 +1,52 @@
|
||||
/*
|
||||
* Copyright (C) 2008 The Android Open Source 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 ANDROID_LIGHT_SENSOR_H
|
||||
#define ANDROID_LIGHT_SENSOR_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <errno.h>
|
||||
#include <sys/cdefs.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#include "nusensors.h"
|
||||
#include "SensorBase.h"
|
||||
#include "InputEventReader.h"
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
struct input_event;
|
||||
|
||||
class LightSensor : public SensorBase {
|
||||
int mEnabled;
|
||||
InputEventCircularReader mInputReader;
|
||||
sensors_event_t mPendingEvent;
|
||||
bool mHasPendingEvent;
|
||||
|
||||
float indexToValue(size_t index) const;
|
||||
int setInitialState();
|
||||
|
||||
public:
|
||||
LightSensor();
|
||||
virtual ~LightSensor();
|
||||
virtual int readEvents(sensors_event_t* data, int count);
|
||||
virtual bool hasPendingEvents() const;
|
||||
virtual int enable(int32_t handle, int enabled);
|
||||
};
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
#endif // ANDROID_LIGHT_SENSOR_H
|
144
libsensors/ProximitySensor.cpp
Normal file
144
libsensors/ProximitySensor.cpp
Normal file
@ -0,0 +1,144 @@
|
||||
/*
|
||||
* Copyright (C) 2008 The Android Open Source 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.
|
||||
*/
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <errno.h>
|
||||
#include <math.h>
|
||||
#include <poll.h>
|
||||
#include <unistd.h>
|
||||
#include <dirent.h>
|
||||
#include <sys/select.h>
|
||||
|
||||
#include <linux/capella_cm3602.h>
|
||||
|
||||
#include <cutils/log.h>
|
||||
|
||||
#include "ProximitySensor.h"
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
ProximitySensor::ProximitySensor()
|
||||
: SensorBase(CM_DEVICE_NAME, "proximity"),
|
||||
mEnabled(0),
|
||||
mInputReader(4),
|
||||
mHasPendingEvent(false)
|
||||
{
|
||||
mPendingEvent.version = sizeof(sensors_event_t);
|
||||
mPendingEvent.sensor = ID_P;
|
||||
mPendingEvent.type = SENSOR_TYPE_PROXIMITY;
|
||||
memset(mPendingEvent.data, 0, sizeof(mPendingEvent.data));
|
||||
|
||||
open_device();
|
||||
|
||||
int flags = 0;
|
||||
if (!ioctl(dev_fd, CAPELLA_CM3602_IOCTL_GET_ENABLED, &flags)) {
|
||||
mEnabled = 1;
|
||||
if (flags) {
|
||||
setInitialState();
|
||||
}
|
||||
}
|
||||
if (!mEnabled) {
|
||||
close_device();
|
||||
}
|
||||
}
|
||||
|
||||
ProximitySensor::~ProximitySensor() {
|
||||
}
|
||||
|
||||
int ProximitySensor::setInitialState() {
|
||||
struct input_absinfo absinfo;
|
||||
if (!ioctl(data_fd, EVIOCGABS(EVENT_TYPE_PROXIMITY), &absinfo)) {
|
||||
// make sure to report an event immediately
|
||||
mHasPendingEvent = true;
|
||||
mPendingEvent.distance = indexToValue(absinfo.value);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ProximitySensor::enable(int32_t, int en) {
|
||||
int newState = en ? 1 : 0;
|
||||
int err = 0;
|
||||
if (newState != mEnabled) {
|
||||
if (!mEnabled) {
|
||||
open_device();
|
||||
}
|
||||
int flags = newState;
|
||||
err = ioctl(dev_fd, CAPELLA_CM3602_IOCTL_ENABLE, &flags);
|
||||
err = err<0 ? -errno : 0;
|
||||
LOGE_IF(err, "CAPELLA_CM3602_IOCTL_ENABLE failed (%s)", strerror(-err));
|
||||
if (!err) {
|
||||
mEnabled = newState;
|
||||
if (en) {
|
||||
setInitialState();
|
||||
}
|
||||
}
|
||||
if (!mEnabled) {
|
||||
close_device();
|
||||
}
|
||||
}
|
||||
return err;
|
||||
}
|
||||
|
||||
bool ProximitySensor::hasPendingEvents() const {
|
||||
return mHasPendingEvent;
|
||||
}
|
||||
|
||||
int ProximitySensor::readEvents(sensors_event_t* data, int count)
|
||||
{
|
||||
if (count < 1)
|
||||
return -EINVAL;
|
||||
|
||||
if (mHasPendingEvent) {
|
||||
mHasPendingEvent = false;
|
||||
mPendingEvent.timestamp = getTimestamp();
|
||||
*data = mPendingEvent;
|
||||
return mEnabled ? 1 : 0;
|
||||
}
|
||||
|
||||
ssize_t n = mInputReader.fill(data_fd);
|
||||
if (n < 0)
|
||||
return n;
|
||||
|
||||
int numEventReceived = 0;
|
||||
input_event const* event;
|
||||
|
||||
while (count && mInputReader.readEvent(&event)) {
|
||||
int type = event->type;
|
||||
if (type == EV_ABS) {
|
||||
if (event->code == EVENT_TYPE_PROXIMITY) {
|
||||
mPendingEvent.distance = indexToValue(event->value);
|
||||
}
|
||||
} else if (type == EV_SYN) {
|
||||
mPendingEvent.timestamp = timevalToNano(event->time);
|
||||
if (mEnabled) {
|
||||
*data++ = mPendingEvent;
|
||||
count--;
|
||||
numEventReceived++;
|
||||
}
|
||||
} else {
|
||||
LOGE("ProximitySensor: unknown event (type=%d, code=%d)",
|
||||
type, event->code);
|
||||
}
|
||||
mInputReader.next();
|
||||
}
|
||||
|
||||
return numEventReceived;
|
||||
}
|
||||
|
||||
float ProximitySensor::indexToValue(size_t index) const
|
||||
{
|
||||
return index * PROXIMITY_THRESHOLD_CM;
|
||||
}
|
52
libsensors/ProximitySensor.h
Normal file
52
libsensors/ProximitySensor.h
Normal file
@ -0,0 +1,52 @@
|
||||
/*
|
||||
* Copyright (C) 2008 The Android Open Source 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 ANDROID_PROXIMITY_SENSOR_H
|
||||
#define ANDROID_PROXIMITY_SENSOR_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <errno.h>
|
||||
#include <sys/cdefs.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#include "nusensors.h"
|
||||
#include "SensorBase.h"
|
||||
#include "InputEventReader.h"
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
struct input_event;
|
||||
|
||||
class ProximitySensor : public SensorBase {
|
||||
int mEnabled;
|
||||
InputEventCircularReader mInputReader;
|
||||
sensors_event_t mPendingEvent;
|
||||
bool mHasPendingEvent;
|
||||
|
||||
int setInitialState();
|
||||
float indexToValue(size_t index) const;
|
||||
|
||||
public:
|
||||
ProximitySensor();
|
||||
virtual ~ProximitySensor();
|
||||
virtual int readEvents(sensors_event_t* data, int count);
|
||||
virtual bool hasPendingEvents() const;
|
||||
virtual int enable(int32_t handle, int enabled);
|
||||
};
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
#endif // ANDROID_PROXIMITY_SENSOR_H
|
122
libsensors/SensorBase.cpp
Normal file
122
libsensors/SensorBase.cpp
Normal file
@ -0,0 +1,122 @@
|
||||
/*
|
||||
* Copyright (C) 2008 The Android Open Source 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.
|
||||
*/
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <errno.h>
|
||||
#include <math.h>
|
||||
#include <poll.h>
|
||||
#include <unistd.h>
|
||||
#include <dirent.h>
|
||||
#include <sys/select.h>
|
||||
|
||||
#include <cutils/log.h>
|
||||
|
||||
#include <linux/input.h>
|
||||
|
||||
#include "SensorBase.h"
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
SensorBase::SensorBase(
|
||||
const char* dev_name,
|
||||
const char* data_name)
|
||||
: dev_name(dev_name), data_name(data_name),
|
||||
dev_fd(-1), data_fd(-1)
|
||||
{
|
||||
data_fd = openInput(data_name);
|
||||
}
|
||||
|
||||
SensorBase::~SensorBase() {
|
||||
if (data_fd >= 0) {
|
||||
close(data_fd);
|
||||
}
|
||||
if (dev_fd >= 0) {
|
||||
close(dev_fd);
|
||||
}
|
||||
}
|
||||
|
||||
int SensorBase::open_device() {
|
||||
if (dev_fd<0 && dev_name) {
|
||||
dev_fd = open(dev_name, O_RDONLY);
|
||||
LOGE_IF(dev_fd<0, "Couldn't open %s (%s)", dev_name, strerror(errno));
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int SensorBase::close_device() {
|
||||
if (dev_fd >= 0) {
|
||||
close(dev_fd);
|
||||
dev_fd = -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int SensorBase::getFd() const {
|
||||
return data_fd;
|
||||
}
|
||||
|
||||
int SensorBase::setDelay(int32_t handle, int64_t ns) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool SensorBase::hasPendingEvents() const {
|
||||
return false;
|
||||
}
|
||||
|
||||
int64_t SensorBase::getTimestamp() {
|
||||
struct timespec t;
|
||||
t.tv_sec = t.tv_nsec = 0;
|
||||
clock_gettime(CLOCK_MONOTONIC, &t);
|
||||
return int64_t(t.tv_sec)*1000000000LL + t.tv_nsec;
|
||||
}
|
||||
|
||||
int SensorBase::openInput(const char* inputName) {
|
||||
int fd = -1;
|
||||
const char *dirname = "/dev/input";
|
||||
char devname[PATH_MAX];
|
||||
char *filename;
|
||||
DIR *dir;
|
||||
struct dirent *de;
|
||||
dir = opendir(dirname);
|
||||
if(dir == NULL)
|
||||
return -1;
|
||||
strcpy(devname, dirname);
|
||||
filename = devname + strlen(devname);
|
||||
*filename++ = '/';
|
||||
while((de = readdir(dir))) {
|
||||
if(de->d_name[0] == '.' &&
|
||||
(de->d_name[1] == '\0' ||
|
||||
(de->d_name[1] == '.' && de->d_name[2] == '\0')))
|
||||
continue;
|
||||
strcpy(filename, de->d_name);
|
||||
fd = open(devname, O_RDONLY);
|
||||
if (fd>=0) {
|
||||
char name[80];
|
||||
if (ioctl(fd, EVIOCGNAME(sizeof(name) - 1), &name) < 1) {
|
||||
name[0] = '\0';
|
||||
}
|
||||
if (!strcmp(name, inputName)) {
|
||||
break;
|
||||
} else {
|
||||
close(fd);
|
||||
fd = -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
closedir(dir);
|
||||
LOGE_IF(fd<0, "couldn't find '%s' input device", inputName);
|
||||
return fd;
|
||||
}
|
64
libsensors/SensorBase.h
Normal file
64
libsensors/SensorBase.h
Normal file
@ -0,0 +1,64 @@
|
||||
/*
|
||||
* Copyright (C) 2008 The Android Open Source 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 ANDROID_SENSOR_BASE_H
|
||||
#define ANDROID_SENSOR_BASE_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <errno.h>
|
||||
#include <sys/cdefs.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
struct sensors_event_t;
|
||||
|
||||
class SensorBase {
|
||||
protected:
|
||||
const char* dev_name;
|
||||
const char* data_name;
|
||||
int dev_fd;
|
||||
int data_fd;
|
||||
|
||||
static int openInput(const char* inputName);
|
||||
static int64_t getTimestamp();
|
||||
|
||||
|
||||
static int64_t timevalToNano(timeval const& t) {
|
||||
return t.tv_sec*1000000000LL + t.tv_usec*1000;
|
||||
}
|
||||
|
||||
int open_device();
|
||||
int close_device();
|
||||
|
||||
public:
|
||||
SensorBase(
|
||||
const char* dev_name,
|
||||
const char* data_name);
|
||||
|
||||
virtual ~SensorBase();
|
||||
|
||||
virtual int readEvents(sensors_event_t* data, int count) = 0;
|
||||
virtual bool hasPendingEvents() const;
|
||||
virtual int getFd() const;
|
||||
virtual int setDelay(int32_t handle, int64_t ns);
|
||||
virtual int enable(int32_t handle, int enabled) = 0;
|
||||
};
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
#endif // ANDROID_SENSOR_BASE_H
|
228
libsensors/nusensors.cpp
Normal file
228
libsensors/nusensors.cpp
Normal file
@ -0,0 +1,228 @@
|
||||
/*
|
||||
* Copyright (C) 2008 The Android Open Source 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.
|
||||
*/
|
||||
|
||||
#include <hardware/sensors.h>
|
||||
#include <fcntl.h>
|
||||
#include <errno.h>
|
||||
#include <dirent.h>
|
||||
#include <math.h>
|
||||
|
||||
#include <poll.h>
|
||||
#include <pthread.h>
|
||||
|
||||
#include <linux/input.h>
|
||||
|
||||
#include <cutils/atomic.h>
|
||||
#include <cutils/log.h>
|
||||
|
||||
#include "nusensors.h"
|
||||
#include "LightSensor.h"
|
||||
#include "ProximitySensor.h"
|
||||
#include "AkmSensor.h"
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
struct sensors_poll_context_t {
|
||||
struct sensors_poll_device_t device; // must be first
|
||||
|
||||
sensors_poll_context_t();
|
||||
~sensors_poll_context_t();
|
||||
int activate(int handle, int enabled);
|
||||
int setDelay(int handle, int64_t ns);
|
||||
int pollEvents(sensors_event_t* data, int count);
|
||||
|
||||
private:
|
||||
enum {
|
||||
light = 0,
|
||||
proximity = 1,
|
||||
akm = 2,
|
||||
numSensorDrivers,
|
||||
numFds,
|
||||
};
|
||||
|
||||
static const size_t wake = numFds - 1;
|
||||
static const char WAKE_MESSAGE = 'W';
|
||||
struct pollfd mPollFds[numFds];
|
||||
int mWritePipeFd;
|
||||
SensorBase* mSensors[numSensorDrivers];
|
||||
|
||||
int handleToDriver(int handle) const {
|
||||
switch (handle) {
|
||||
case ID_A:
|
||||
case ID_M:
|
||||
case ID_O:
|
||||
return akm;
|
||||
case ID_P:
|
||||
return proximity;
|
||||
case ID_L:
|
||||
return light;
|
||||
}
|
||||
return -EINVAL;
|
||||
}
|
||||
};
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
sensors_poll_context_t::sensors_poll_context_t()
|
||||
{
|
||||
mSensors[light] = new LightSensor();
|
||||
mPollFds[light].fd = mSensors[light]->getFd();
|
||||
mPollFds[light].events = POLLIN;
|
||||
mPollFds[light].revents = 0;
|
||||
|
||||
mSensors[proximity] = new ProximitySensor();
|
||||
mPollFds[proximity].fd = mSensors[proximity]->getFd();
|
||||
mPollFds[proximity].events = POLLIN;
|
||||
mPollFds[proximity].revents = 0;
|
||||
|
||||
mSensors[akm] = new AkmSensor();
|
||||
mPollFds[akm].fd = mSensors[akm]->getFd();
|
||||
mPollFds[akm].events = POLLIN;
|
||||
mPollFds[akm].revents = 0;
|
||||
|
||||
int wakeFds[2];
|
||||
int result = pipe(wakeFds);
|
||||
LOGE_IF(result<0, "error creating wake pipe (%s)", strerror(errno));
|
||||
fcntl(wakeFds[0], F_SETFL, O_NONBLOCK);
|
||||
fcntl(wakeFds[1], F_SETFL, O_NONBLOCK);
|
||||
mWritePipeFd = wakeFds[1];
|
||||
|
||||
mPollFds[wake].fd = wakeFds[0];
|
||||
mPollFds[wake].events = POLLIN;
|
||||
mPollFds[wake].revents = 0;
|
||||
}
|
||||
|
||||
sensors_poll_context_t::~sensors_poll_context_t() {
|
||||
for (int i=0 ; i<numSensorDrivers ; i++) {
|
||||
delete mSensors[i];
|
||||
}
|
||||
close(mPollFds[wake].fd);
|
||||
close(mWritePipeFd);
|
||||
}
|
||||
|
||||
int sensors_poll_context_t::activate(int handle, int enabled) {
|
||||
int index = handleToDriver(handle);
|
||||
if (index < 0) return index;
|
||||
int err = mSensors[index]->enable(handle, enabled);
|
||||
if (enabled && !err) {
|
||||
const char wakeMessage(WAKE_MESSAGE);
|
||||
int result = write(mWritePipeFd, &wakeMessage, 1);
|
||||
LOGE_IF(result<0, "error sending wake message (%s)", strerror(errno));
|
||||
}
|
||||
return err;
|
||||
}
|
||||
|
||||
int sensors_poll_context_t::setDelay(int handle, int64_t ns) {
|
||||
|
||||
int index = handleToDriver(handle);
|
||||
if (index < 0) return index;
|
||||
return mSensors[index]->setDelay(handle, ns);
|
||||
}
|
||||
|
||||
int sensors_poll_context_t::pollEvents(sensors_event_t* data, int count)
|
||||
{
|
||||
int nbEvents = 0;
|
||||
int n = 0;
|
||||
|
||||
do {
|
||||
// see if we have some leftover from the last poll()
|
||||
for (int i=0 ; count && i<numSensorDrivers ; i++) {
|
||||
SensorBase* const sensor(mSensors[i]);
|
||||
if ((mPollFds[i].revents & POLLIN) || (sensor->hasPendingEvents())) {
|
||||
int nb = sensor->readEvents(data, count);
|
||||
if (nb < count) {
|
||||
// no more data for this sensor
|
||||
mPollFds[i].revents = 0;
|
||||
}
|
||||
count -= nb;
|
||||
nbEvents += nb;
|
||||
data += nb;
|
||||
}
|
||||
}
|
||||
|
||||
if (count) {
|
||||
// we still have some room, so try to see if we can get
|
||||
// some events immediately or just wait if we don't have
|
||||
// anything to return
|
||||
n = poll(mPollFds, numFds, nbEvents ? 0 : -1);
|
||||
if (n<0) {
|
||||
LOGE("poll() failed (%s)", strerror(errno));
|
||||
return -errno;
|
||||
}
|
||||
if (mPollFds[wake].revents & POLLIN) {
|
||||
char msg;
|
||||
int result = read(mPollFds[wake].fd, &msg, 1);
|
||||
LOGE_IF(result<0, "error reading from wake pipe (%s)", strerror(errno));
|
||||
LOGE_IF(msg != WAKE_MESSAGE, "unknown message on wake queue (0x%02x)", int(msg));
|
||||
mPollFds[wake].revents = 0;
|
||||
}
|
||||
}
|
||||
// if we have events and space, go read them
|
||||
} while (n && count);
|
||||
|
||||
return nbEvents;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
static int poll__close(struct hw_device_t *dev)
|
||||
{
|
||||
sensors_poll_context_t *ctx = (sensors_poll_context_t *)dev;
|
||||
if (ctx) {
|
||||
delete ctx;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int poll__activate(struct sensors_poll_device_t *dev,
|
||||
int handle, int enabled) {
|
||||
sensors_poll_context_t *ctx = (sensors_poll_context_t *)dev;
|
||||
return ctx->activate(handle, enabled);
|
||||
}
|
||||
|
||||
static int poll__setDelay(struct sensors_poll_device_t *dev,
|
||||
int handle, int64_t ns) {
|
||||
sensors_poll_context_t *ctx = (sensors_poll_context_t *)dev;
|
||||
return ctx->setDelay(handle, ns);
|
||||
}
|
||||
|
||||
static int poll__poll(struct sensors_poll_device_t *dev,
|
||||
sensors_event_t* data, int count) {
|
||||
sensors_poll_context_t *ctx = (sensors_poll_context_t *)dev;
|
||||
return ctx->pollEvents(data, count);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
int init_nusensors(hw_module_t const* module, hw_device_t** device)
|
||||
{
|
||||
int status = -EINVAL;
|
||||
|
||||
sensors_poll_context_t *dev = new sensors_poll_context_t();
|
||||
memset(&dev->device, 0, sizeof(sensors_poll_device_t));
|
||||
|
||||
dev->device.common.tag = HARDWARE_DEVICE_TAG;
|
||||
dev->device.common.version = 0;
|
||||
dev->device.common.module = const_cast<hw_module_t*>(module);
|
||||
dev->device.common.close = poll__close;
|
||||
dev->device.activate = poll__activate;
|
||||
dev->device.setDelay = poll__setDelay;
|
||||
dev->device.poll = poll__poll;
|
||||
|
||||
*device = &dev->device.common;
|
||||
status = 0;
|
||||
return status;
|
||||
}
|
108
libsensors/nusensors.h
Normal file
108
libsensors/nusensors.h
Normal file
@ -0,0 +1,108 @@
|
||||
/*
|
||||
* Copyright (C) 2008 The Android Open Source 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 ANDROID_SENSORS_H
|
||||
#define ANDROID_SENSORS_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <errno.h>
|
||||
#include <sys/cdefs.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <linux/input.h>
|
||||
|
||||
#include <hardware/hardware.h>
|
||||
#include <hardware/sensors.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
int init_nusensors(hw_module_t const* module, hw_device_t** device);
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
#define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0]))
|
||||
|
||||
#define ID_A (0)
|
||||
#define ID_M (1)
|
||||
#define ID_O (2)
|
||||
#define ID_P (3)
|
||||
#define ID_L (4)
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
/*
|
||||
* The SENSORS Module
|
||||
*/
|
||||
|
||||
/* the CM3602 is a binary proximity sensor that triggers around 9 cm on
|
||||
* this hardware */
|
||||
#define PROXIMITY_THRESHOLD_CM 9.0f
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
#define AKM_DEVICE_NAME "/dev/akm8973_aot"
|
||||
#define CM_DEVICE_NAME "/dev/cm3602"
|
||||
#define LS_DEVICE_NAME "/dev/lightsensor"
|
||||
|
||||
#define EVENT_TYPE_ACCEL_X ABS_X
|
||||
#define EVENT_TYPE_ACCEL_Y ABS_Z
|
||||
#define EVENT_TYPE_ACCEL_Z ABS_Y
|
||||
#define EVENT_TYPE_ACCEL_STATUS ABS_WHEEL
|
||||
|
||||
#define EVENT_TYPE_YAW ABS_RX
|
||||
#define EVENT_TYPE_PITCH ABS_RY
|
||||
#define EVENT_TYPE_ROLL ABS_RZ
|
||||
#define EVENT_TYPE_ORIENT_STATUS ABS_RUDDER
|
||||
|
||||
#define EVENT_TYPE_MAGV_X ABS_HAT0X
|
||||
#define EVENT_TYPE_MAGV_Y ABS_HAT0Y
|
||||
#define EVENT_TYPE_MAGV_Z ABS_BRAKE
|
||||
|
||||
#define EVENT_TYPE_TEMPERATURE ABS_THROTTLE
|
||||
#define EVENT_TYPE_STEP_COUNT ABS_GAS
|
||||
#define EVENT_TYPE_PROXIMITY ABS_DISTANCE
|
||||
#define EVENT_TYPE_LIGHT ABS_MISC
|
||||
|
||||
// 720 LSG = 1G
|
||||
#define LSG (720.0f)
|
||||
|
||||
|
||||
// conversion of acceleration data to SI units (m/s^2)
|
||||
#define CONVERT_A (GRAVITY_EARTH / LSG)
|
||||
#define CONVERT_A_X (-CONVERT_A)
|
||||
#define CONVERT_A_Y (CONVERT_A)
|
||||
#define CONVERT_A_Z (-CONVERT_A)
|
||||
|
||||
// conversion of magnetic data to uT units
|
||||
#define CONVERT_M (1.0f/16.0f)
|
||||
#define CONVERT_M_X (-CONVERT_M)
|
||||
#define CONVERT_M_Y (-CONVERT_M)
|
||||
#define CONVERT_M_Z (CONVERT_M)
|
||||
|
||||
#define CONVERT_O (1.0f)
|
||||
#define CONVERT_O_Y (CONVERT_O)
|
||||
#define CONVERT_O_P (CONVERT_O)
|
||||
#define CONVERT_O_R (-CONVERT_O)
|
||||
|
||||
#define SENSOR_STATE_MASK (0x7FFF)
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif // ANDROID_SENSORS_H
|
91
libsensors/sensors.c
Normal file
91
libsensors/sensors.c
Normal file
@ -0,0 +1,91 @@
|
||||
/*
|
||||
* Copyright (C) 2008 The Android Open Source 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.
|
||||
*/
|
||||
|
||||
#include <hardware/sensors.h>
|
||||
|
||||
#include "nusensors.h"
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
/*
|
||||
* The SENSORS Module
|
||||
*/
|
||||
|
||||
/*
|
||||
* the AK8973 has a 8-bit ADC but the firmware seems to average 16 samples,
|
||||
* or at least makes its calibration on 12-bits values. This increases the
|
||||
* resolution by 4 bits.
|
||||
*/
|
||||
|
||||
static const struct sensor_t sSensorList[] = {
|
||||
{ "BMA150 3-axis Accelerometer",
|
||||
"Bosh",
|
||||
1, SENSORS_HANDLE_BASE+ID_A,
|
||||
SENSOR_TYPE_ACCELEROMETER, 4.0f*9.81f, (4.0f*9.81f)/256.0f, 0.2f, 0, { } },
|
||||
{ "AK8973 3-axis Magnetic field sensor",
|
||||
"Asahi Kasei",
|
||||
1, SENSORS_HANDLE_BASE+ID_M,
|
||||
SENSOR_TYPE_MAGNETIC_FIELD, 2000.0f, 1.0f/16.0f, 6.8f, 0, { } },
|
||||
{ "AK8973 Orientation sensor",
|
||||
"Asahi Kasei",
|
||||
1, SENSORS_HANDLE_BASE+ID_O,
|
||||
SENSOR_TYPE_ORIENTATION, 360.0f, 1.0f, 7.0f, 0, { } },
|
||||
{ "CM3602 Proximity sensor",
|
||||
"Capella Microsystems",
|
||||
1, SENSORS_HANDLE_BASE+ID_P,
|
||||
SENSOR_TYPE_PROXIMITY,
|
||||
PROXIMITY_THRESHOLD_CM, PROXIMITY_THRESHOLD_CM,
|
||||
0.5f, 0, { } },
|
||||
{ "CM3602 Light sensor",
|
||||
"Capella Microsystems",
|
||||
1, SENSORS_HANDLE_BASE+ID_L,
|
||||
SENSOR_TYPE_LIGHT, 10240.0f, 1.0f, 0.5f, 0, { } },
|
||||
};
|
||||
|
||||
static int open_sensors(const struct hw_module_t* module, const char* name,
|
||||
struct hw_device_t** device);
|
||||
|
||||
static int sensors__get_sensors_list(struct sensors_module_t* module,
|
||||
struct sensor_t const** list)
|
||||
{
|
||||
*list = sSensorList;
|
||||
return ARRAY_SIZE(sSensorList);
|
||||
}
|
||||
|
||||
static struct hw_module_methods_t sensors_module_methods = {
|
||||
.open = open_sensors
|
||||
};
|
||||
|
||||
const struct sensors_module_t HAL_MODULE_INFO_SYM = {
|
||||
.common = {
|
||||
.tag = HARDWARE_MODULE_TAG,
|
||||
.version_major = 1,
|
||||
.version_minor = 0,
|
||||
.id = SENSORS_HARDWARE_MODULE_ID,
|
||||
.name = "AK8973A & CM3602 Sensors Module",
|
||||
.author = "The Android Open Source Project",
|
||||
.methods = &sensors_module_methods,
|
||||
},
|
||||
.get_sensors_list = sensors__get_sensors_list
|
||||
};
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
static int open_sensors(const struct hw_module_t* module, const char* name,
|
||||
struct hw_device_t** device)
|
||||
{
|
||||
return init_nusensors(module, device);
|
||||
}
|
@ -20,17 +20,13 @@
|
||||
<!-- These resources are around just to allow their values to be customized
|
||||
for different hardware and product builds. -->
|
||||
<resources>
|
||||
|
||||
<!-- Flag indicating whether the surface flinger has limited
|
||||
alpha compositing functionality in hardware. If set, the window
|
||||
manager will disable alpha trasformation in animations where not
|
||||
strictly needed. -->
|
||||
<bool name="config_sf_limitedAlpha">true</bool>
|
||||
|
||||
<!-- Flag indicating whether we should enable the automatic brightness in Settings.
|
||||
config_hardware_automatic_brightness_available is not set, so we will use software implementation -->
|
||||
<bool name="config_automatic_brightness_available">true</bool>
|
||||
|
||||
|
||||
<bool name="config_animateScreenLights">true</bool>
|
||||
|
||||
<!-- disable menu hard key on Passion in non-pattern lockscreen -->
|
||||
<bool name="config_disableMenuKeyInLockScreen">true</bool>
|
||||
|
||||
@ -45,15 +41,10 @@
|
||||
|
||||
Must be overridden in platform specific overlays -->
|
||||
<integer-array name="config_autoBrightnessLevels">
|
||||
<item>11</item>
|
||||
<item>41</item>
|
||||
<item>91</item>
|
||||
<item>161</item>
|
||||
<item>226</item>
|
||||
<item>321</item>
|
||||
<item>641</item>
|
||||
<item>1281</item>
|
||||
<item>2601</item>
|
||||
<item>200</item>
|
||||
<item>400</item>
|
||||
<item>1000</item>
|
||||
<item>3000</item>
|
||||
</integer-array>
|
||||
|
||||
<!-- Array of output values for LCD backlight corresponding to the LUX values
|
||||
@ -61,16 +52,11 @@
|
||||
than the size of the config_autoBrightnessLevels array.
|
||||
-->
|
||||
<integer-array name="config_autoBrightnessLcdBacklightValues">
|
||||
<item>89</item>
|
||||
<item>89</item>
|
||||
<item>126</item>
|
||||
<item>164</item>
|
||||
<item>164</item>
|
||||
<item>164</item>
|
||||
<item>187</item>
|
||||
<item>210</item>
|
||||
<item>233</item>
|
||||
<item>255</item>
|
||||
<item>35</item>
|
||||
<item>55</item>
|
||||
<item>70</item>
|
||||
<item>70</item>
|
||||
<item>250</item>
|
||||
</integer-array>
|
||||
|
||||
<!-- Array of output values for button backlight corresponding to the LUX values
|
||||
@ -80,11 +66,6 @@
|
||||
<integer-array name="config_autoBrightnessButtonBacklightValues">
|
||||
<item>255</item>
|
||||
<item>255</item>
|
||||
<item>255</item>
|
||||
<item>255</item>
|
||||
<item>0</item>
|
||||
<item>0</item>
|
||||
<item>0</item>
|
||||
<item>0</item>
|
||||
<item>0</item>
|
||||
<item>0</item>
|
||||
@ -101,11 +82,6 @@
|
||||
<item>0</item>
|
||||
<item>0</item>
|
||||
<item>0</item>
|
||||
<item>0</item>
|
||||
<item>0</item>
|
||||
<item>0</item>
|
||||
<item>0</item>
|
||||
<item>0</item>
|
||||
</integer-array>
|
||||
|
||||
<!-- Component name of the default wallpaper. This will be ImageWallpaper if not
|
||||
@ -138,7 +114,6 @@
|
||||
[associated radio-type],[priority] -->
|
||||
<string-array translatable="false" name="networkAttributes">
|
||||
<item>"wifi,1,1,1"</item>
|
||||
<item>"wimax,6,2,0"</item>
|
||||
<item>"mobile,0,0,0"</item>
|
||||
<item>"mobile_mms,2,0,2"</item>
|
||||
<item>"mobile_supl,3,0,2"</item>
|
||||
@ -146,17 +121,6 @@
|
||||
<item>"mobile_hipri,5,0,3"</item>
|
||||
</string-array>
|
||||
|
||||
<!-- This string array should be overridden by the device to present a list of radio
|
||||
attributes. This is used by the connectivity manager to decide which networks can coexist
|
||||
based on the hardware -->
|
||||
<!-- An Array of "[ConnectivityManager connectionType],
|
||||
[# simultaneous connection types]" -->
|
||||
<string-array translatable="false" name="radioAttributes">
|
||||
<item>"2,1"</item>
|
||||
<item>"1,1"</item>
|
||||
<item>"0,1"</item>
|
||||
</string-array>
|
||||
|
||||
<!-- List of regexpressions describing the interface (if any) that represent tetherable
|
||||
USB interfaces. If the device doesn't want to support tething over USB this should
|
||||
be empty. An example would be "usb.*" -->
|
||||
@ -187,11 +151,4 @@
|
||||
<item>30</item>
|
||||
</integer-array>
|
||||
|
||||
<!-- Component name of the default wallpaper. This will be ImageWallpaper if not
|
||||
specified -->
|
||||
<string name="default_wallpaper_component">com.android.wallpaper/.nexus.NexusWallpaper</string>
|
||||
|
||||
<!-- Enable use of power animations -->
|
||||
<bool name="config_animateScreenLights">false</bool>
|
||||
|
||||
</resources>
|
||||
|
@ -1,125 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
/*
|
||||
** 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.
|
||||
*/
|
||||
-->
|
||||
|
||||
<!-- Note that IconMode can be only 0, ON or 1, FLASHING
|
||||
The icon is turned OFF if then IconIndex = 1 -->
|
||||
|
||||
<EriFile VersionNumber="1357"
|
||||
NumberOfEriEntries="12"
|
||||
EriFileType="1">
|
||||
|
||||
<CallPromptId Id="0"
|
||||
CallPromptText="CallPromptId0"/>
|
||||
|
||||
<CallPromptId Id="1"
|
||||
CallPromptText="CallPromptId1"/>
|
||||
|
||||
<CallPromptId Id="2"
|
||||
CallPromptText="CallPromptId2"/>
|
||||
|
||||
<EriInfo RoamingIndicator="64"
|
||||
IconIndex="1"
|
||||
IconMode="0"
|
||||
EriText="T-CDMA 64"
|
||||
CallPromptId="0"
|
||||
AlertId="0"/>
|
||||
|
||||
<EriInfo RoamingIndicator="65"
|
||||
IconIndex="65"
|
||||
IconMode="0"
|
||||
EriText="T-CDMA 65"
|
||||
CallPromptId="0"
|
||||
AlertId="0"/>
|
||||
|
||||
<EriInfo RoamingIndicator="66"
|
||||
IconIndex="1"
|
||||
IconMode="0"
|
||||
EriText="T-CDMA Ext 66"
|
||||
CallPromptId="0"
|
||||
AlertId="0"/>
|
||||
|
||||
<EriInfo RoamingIndicator="67"
|
||||
IconIndex="67"
|
||||
IconMode="0"
|
||||
EriText="T-CDMA Ext 67"
|
||||
CallPromptId="0"
|
||||
AlertId="0"/>
|
||||
|
||||
<EriInfo RoamingIndicator="68"
|
||||
IconIndex="68"
|
||||
IconMode="0"
|
||||
EriText="T-CDMA Roam 68"
|
||||
CallPromptId="0"
|
||||
AlertId="0"/>
|
||||
|
||||
<EriInfo RoamingIndicator="69"
|
||||
IconIndex="69"
|
||||
IconMode="1"
|
||||
EriText="T-CDMA Ext 69"
|
||||
CallPromptId="0"
|
||||
AlertId="0"/>
|
||||
|
||||
<EriInfo RoamingIndicator="70"
|
||||
IconIndex="70"
|
||||
IconMode="1"
|
||||
EriText="T-CDMA Roam 70"
|
||||
CallPromptId="0"
|
||||
AlertId="0"/>
|
||||
|
||||
<EriInfo RoamingIndicator="71"
|
||||
IconIndex="1"
|
||||
IconMode="0"
|
||||
EriText="T-CDMA Ext 71"
|
||||
CallPromptId="0"
|
||||
AlertId="0"/>
|
||||
|
||||
<EriInfo RoamingIndicator="72"
|
||||
IconIndex="72"
|
||||
IconMode="0"
|
||||
EriText="T-CDMA Ext 72"
|
||||
CallPromptId="0"
|
||||
AlertId="0"/>
|
||||
|
||||
<EriInfo RoamingIndicator="73"
|
||||
IconIndex="73"
|
||||
IconMode="0"
|
||||
EriText="T-CDMA Roam 73"
|
||||
CallPromptId="0"
|
||||
AlertId="0"/>
|
||||
|
||||
<EriInfo RoamingIndicator="74"
|
||||
IconIndex="74"
|
||||
IconMode="1"
|
||||
EriText="T-CDMA Ext 74"
|
||||
CallPromptId="0"
|
||||
AlertId="0"/>
|
||||
|
||||
<EriInfo RoamingIndicator="75"
|
||||
IconIndex="75"
|
||||
IconMode="1"
|
||||
EriText="T-CDMA Roam 75"
|
||||
CallPromptId="0"
|
||||
AlertId="0"/>
|
||||
|
||||
<EriInfo RoamingIndicator="128"
|
||||
IconIndex="1"
|
||||
IconMode="0"
|
||||
EriText="Sprint"
|
||||
CallPromptId="0"
|
||||
AlertId="0"/>
|
||||
|
||||
</EriFile>
|
72
overlay/frameworks/base/core/res/res/xml/power_profile.xml
Normal file
72
overlay/frameworks/base/core/res/res/xml/power_profile.xml
Normal file
@ -0,0 +1,72 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
**
|
||||
** Copyright 2009, The Android Open Source 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.
|
||||
*/
|
||||
-->
|
||||
|
||||
<device name="Android">
|
||||
<item name="none">0</item>
|
||||
<item name="screen.on">100</item>
|
||||
<item name="bluetooth.active">142</item> <!-- In call -->
|
||||
<item name="bluetooth.on">0.3</item>
|
||||
<!-- CPU wakelock held for 830ms on bluetooth headset at command. 43mA * 830 -->
|
||||
<item name="bluetooth.at">35690</item>
|
||||
<item name="screen.full">160</item>
|
||||
<item name="wifi.on">4</item>
|
||||
<item name="wifi.active">120</item>
|
||||
<item name="wifi.scan">220</item>
|
||||
<item name="dsp.audio">88</item>
|
||||
<item name="dsp.video">88</item>
|
||||
<item name="radio.active">300</item>
|
||||
<item name="gps.on">170</item>
|
||||
<item name="battery.capacity">1390</item>
|
||||
<item name="radio.scanning">70</item>
|
||||
<array name="radio.on"> <!-- Strength 0 to BINS-1 -->
|
||||
<value>3</value>
|
||||
<value>3</value>
|
||||
</array>
|
||||
<array name="cpu.speeds">
|
||||
<value>245000</value>
|
||||
<value>384000</value>
|
||||
<value>460800</value>
|
||||
<value>499200</value>
|
||||
<value>576000</value>
|
||||
<value>614400</value>
|
||||
<value>652800</value>
|
||||
<value>691200</value>
|
||||
<value>768000</value>
|
||||
<value>806400</value>
|
||||
<value>844800</value>
|
||||
<value>998400</value>
|
||||
</array>
|
||||
<!-- Power consumption in suspend -->
|
||||
<item name="cpu.idle">2.8</item>
|
||||
<!-- Power consumption at different speeds -->
|
||||
<array name="cpu.active">
|
||||
<value>66.6</value>
|
||||
<value>84</value>
|
||||
<value>90.8</value>
|
||||
<value>96</value>
|
||||
<value>105</value>
|
||||
<value>111.5</value>
|
||||
<value>117.3</value>
|
||||
<value>123.6</value>
|
||||
<value>134.5</value>
|
||||
<value>141.8</value>
|
||||
<value>148.5</value>
|
||||
<value>168.4</value>
|
||||
</array>
|
||||
</device>
|
@ -1,5 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<!-- Whether or not to display the trackball settings -->
|
||||
<bool name="has_trackball">false</bool>
|
||||
</resources>
|
@ -22,18 +22,18 @@
|
||||
|
||||
<mms_config version="3">
|
||||
<!-- Maximum message size in bytes for a MMS message -->
|
||||
<int name="maxMessageSize">307200</int>
|
||||
<int name="maxMessageSize">1048576</int>
|
||||
|
||||
<!-- Maximum height for an attached image -->
|
||||
<int name="maxImageHeight">1000</int>
|
||||
<int name="maxImageHeight">1944</int>
|
||||
|
||||
<!-- Maximum width for an attached image -->
|
||||
<int name="maxImageWidth">1296</int>
|
||||
<int name="maxImageWidth">2592</int>
|
||||
|
||||
<!-- User-Agent parameter used in MMS http request -->
|
||||
<string name="userAgent">Sprint APA9292KT</string>
|
||||
<string name="userAgent">Passion</string>
|
||||
|
||||
<!-- UAProf URL -->
|
||||
<string name="uaProfUrl">http://device.sprintpcs.com/HTC/APA9292KT/1326511.rdf</string>
|
||||
<string name="uaProfUrl">http://www.htcmms.com.tw/Android/Common/nexusone/ua-profile.xml</string>
|
||||
|
||||
</mms_config>
|
||||
|
@ -17,7 +17,7 @@
|
||||
<resources>
|
||||
<!-- Whether or not there is a notification led that is too intrusive to be pulsing
|
||||
constantly -->
|
||||
<bool name="has_intrusive_led">false</bool>
|
||||
<bool name="has_intrusive_led">true</bool>
|
||||
<!-- Whether or not the dock settings are to be displayed for this device when docked -->
|
||||
<bool name="has_dock_settings">true</bool>
|
||||
</resources>
|
||||
|
40
system.prop
40
system.prop
@ -1,40 +0,0 @@
|
||||
#
|
||||
# system.prop for device
|
||||
#
|
||||
|
||||
rild.libpath=/system/lib/libhtc_ril.so
|
||||
ro.ril.def.preferred.network = 4
|
||||
ro.telephony.default_network = 4
|
||||
wifi.interface = eth0
|
||||
wifi.supplicant_scan_interval=15
|
||||
ro.com.google.locationfeatures = 1
|
||||
# density in DPI of the LCD of this board. This is used to scale the UI
|
||||
# appropriately. If this property is not defined, the default value is 160 dpi.
|
||||
ro.sf.lcd_density = 240
|
||||
# ro.sf.lcd_density = 160
|
||||
|
||||
# For SD storage insert notification sound
|
||||
persist.service.mount.playsnd = 0
|
||||
|
||||
# For the agps default value
|
||||
ro.ril.def.agps.mode = 2
|
||||
|
||||
# For auto backlight default value
|
||||
settings.display.autobacklight=1
|
||||
|
||||
# default value of brightness
|
||||
settings.display.brightness=143
|
||||
|
||||
# For emmc phone storage
|
||||
ro.phone_storage = 1
|
||||
|
||||
# This is a high density device with more memory, so larger vm heaps for it.
|
||||
dalvik.vm.heapsize=32m
|
||||
|
||||
gsm.sim.operator.numeric = 0
|
||||
gsm.sim.operator.alpha = 0
|
||||
gsm.sim.operator.iso-country = 0
|
||||
|
||||
#Modify MTU from 1500 to 1472 on 3G network
|
||||
ro.ril.set.mtu1472 = 1
|
||||
|
Loading…
Reference in New Issue
Block a user