update new sdk
This commit is contained in:
parent
f33907443a
commit
744c72c133
1643 changed files with 83006 additions and 28021 deletions
44
android/hardware/aw/sensors/aw_sensors/AccelSensor.cpp
Normal file → Executable file
44
android/hardware/aw/sensors/aw_sensors/AccelSensor.cpp
Normal file → Executable file
|
@ -262,13 +262,18 @@ int AccelSensor::readEvents(sensors_event_t* data, int count) {
|
|||
return -EINVAL;
|
||||
|
||||
ssize_t n = mInputReader.fill(data_fd);
|
||||
if (n < 0)
|
||||
return n;
|
||||
|
||||
if (n < 0) {
|
||||
ALOGE(" sensor AceelSensor readEvents fill buffer failed\n");
|
||||
return n;
|
||||
}
|
||||
int numEventReceived = 0;
|
||||
input_event const* event;
|
||||
ssize_t dataAvailable = 0;
|
||||
dataAvailable = mInputReader.readEvent(&event);
|
||||
if (dataAvailable <= 0)
|
||||
ALOGE("sensor no sensor data available\n");
|
||||
|
||||
while (count && mInputReader.readEvent(&event)) {
|
||||
while (count && dataAvailable) {
|
||||
int type = event->type;
|
||||
|
||||
if ((type == EV_ABS) || (type == EV_REL) || (type == EV_KEY)) {
|
||||
|
@ -276,28 +281,26 @@ int AccelSensor::readEvents(sensors_event_t* data, int count) {
|
|||
mInputReader.next();
|
||||
} else if (type == EV_SYN) {
|
||||
int64_t time = timevalToNano(event->time);
|
||||
|
||||
if (mPendingMask) {
|
||||
mPendingMask = 0;
|
||||
mPendingEvent.timestamp = time;
|
||||
|
||||
if (mEnabled) {
|
||||
*data++ = mPendingEvent;
|
||||
mAccData = mPendingEvent;
|
||||
count--;
|
||||
numEventReceived++;
|
||||
}
|
||||
}
|
||||
if (mPendingMask) {
|
||||
mPendingMask = 0;
|
||||
mPendingEvent.timestamp = time;
|
||||
*data++ = mPendingEvent;
|
||||
mAccData = mPendingEvent;
|
||||
count--;
|
||||
numEventReceived++;
|
||||
} else
|
||||
ALOGE("AccelSensor error no data but sync event\n");
|
||||
|
||||
if (!mPendingMask) {
|
||||
mInputReader.next();
|
||||
}
|
||||
|
||||
} else {
|
||||
ALOGE("AccelSensor: unknown event (type=%d, code=%d)",
|
||||
type, event->code);
|
||||
mInputReader.next();
|
||||
}
|
||||
}
|
||||
|
||||
dataAvailable = mInputReader.readEvent(&event);
|
||||
}
|
||||
|
||||
return numEventReceived;
|
||||
|
@ -332,6 +335,11 @@ void AccelSensor::processEvent(int code, int value) {
|
|||
mPendingMask = 1;
|
||||
mPendingEvent.acceleration.z = value * direct_z ;
|
||||
break;
|
||||
|
||||
default:
|
||||
ALOGE("AccelSensor: unknown code (value=%d, code=%d)\n",
|
||||
value, code);
|
||||
break;
|
||||
}
|
||||
|
||||
#ifdef DEBUG_SENSOR
|
||||
|
|
11
android/hardware/aw/sensors/aw_sensors/InputEventReader.cpp
Normal file → Executable file
11
android/hardware/aw/sensors/aw_sensors/InputEventReader.cpp
Normal file → Executable file
|
@ -50,11 +50,12 @@ InputEventCircularReader::~InputEventCircularReader()
|
|||
ssize_t InputEventCircularReader::fill(int fd)
|
||||
{
|
||||
size_t numEventsRead = 0;
|
||||
if (mFreeSpace) {
|
||||
if (mFreeSpace > 0) {
|
||||
const ssize_t nread = read(fd, mHead, mFreeSpace * sizeof(input_event));
|
||||
if (nread<0 || nread % sizeof(input_event)) {
|
||||
if (nread <= 0 || nread % sizeof(input_event)) {
|
||||
// we got a partial event!!
|
||||
return nread<0 ? -errno : -EINVAL;
|
||||
ALOGE("sensor InputEventCircular read data frome fd fail\n");
|
||||
return nread < 0 ? -errno : -EINVAL;
|
||||
}
|
||||
|
||||
numEventsRead = nread / sizeof(input_event);
|
||||
|
@ -68,7 +69,9 @@ ssize_t InputEventCircularReader::fill(int fd)
|
|||
mHead = mBuffer + s;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
ALOGE("sensor InputEventCircular no free space for data\n");
|
||||
}
|
||||
|
||||
return numEventsRead;
|
||||
}
|
||||
|
|
24
android/hardware/aw/sensors/aw_sensors/ProximitySensor.cpp
Normal file → Executable file
24
android/hardware/aw/sensors/aw_sensors/ProximitySensor.cpp
Normal file → Executable file
|
@ -126,25 +126,23 @@ int ProximitySensor::readEvents(sensors_event_t* data, int count)
|
|||
processEvent(event->code, event->value);
|
||||
mInputReader.next();
|
||||
} else if (type == EV_SYN) {
|
||||
int64_t time = timevalToNano(event->time);
|
||||
int64_t time = timevalToNano(event->time);
|
||||
if (mPendingMask) {
|
||||
mPendingMask = 0;
|
||||
mPendingEvent.timestamp = time;
|
||||
|
||||
if (mPendingMask) {
|
||||
mPendingMask = 0;
|
||||
mPendingEvent.timestamp = time;
|
||||
*data++ = mPendingEvent;
|
||||
count--;
|
||||
numEventReceived++;
|
||||
} else
|
||||
ALOGE("ProximitySensor sensor error no data but sync event\n");
|
||||
|
||||
if (mEnabled) {
|
||||
*data++ = mPendingEvent;
|
||||
count--;
|
||||
numEventReceived++;
|
||||
}
|
||||
}
|
||||
|
||||
if (!mPendingMask) {
|
||||
if (!mPendingMask) {
|
||||
mInputReader.next();
|
||||
}
|
||||
|
||||
} else {
|
||||
ALOGE("AccelSensor: unknown event (type=%d, code=%d)",
|
||||
ALOGE("ProximitySensor: unknown event (type=%d, code=%d)",
|
||||
type, event->code);
|
||||
mInputReader.next();
|
||||
}
|
||||
|
|
10
android/hardware/aw/sensors/aw_sensors/sensorDetect.cpp
Normal file → Executable file
10
android/hardware/aw/sensors/aw_sensors/sensorDetect.cpp
Normal file → Executable file
|
@ -119,9 +119,9 @@ struct sensor_extend_t proSensorList[] = {
|
|||
SENSORS_PROXIMITY_HANDLE,
|
||||
SENSOR_TYPE_PROXIMITY,
|
||||
1.0f, 0.1f,
|
||||
0.873f, 0,
|
||||
0.873f, 50000,
|
||||
0,0,SENSOR_STRING_TYPE_PROXIMITY,
|
||||
0,0,SENSOR_FLAG_WAKE_UP,
|
||||
0,1000000,(SENSOR_FLAG_WAKE_UP | SENSOR_FLAG_ON_CHANGE_MODE),
|
||||
{ },
|
||||
},
|
||||
}
|
||||
|
@ -154,9 +154,9 @@ struct sensor_extend_t ligSensorList[] = {
|
|||
SENSORS_LIGHT_HANDLE,
|
||||
SENSOR_TYPE_LIGHT,
|
||||
4096.0f, 1.0f,
|
||||
0.09f, 0,
|
||||
0.09f, 50000,
|
||||
0,0,SENSOR_STRING_TYPE_LIGHT,
|
||||
0,0,SENSOR_FLAG_ON_CHANGE_MODE,
|
||||
0,1000000,SENSOR_FLAG_ON_CHANGE_MODE,
|
||||
{ },
|
||||
},
|
||||
},
|
||||
|
@ -243,7 +243,7 @@ struct sensor_extend_t gsensorList[] = {
|
|||
SENSOR_TYPE_ACCELEROMETER,
|
||||
4.0f*9.81f,
|
||||
(4.0f*9.81f)/1024.0f,
|
||||
0.2f, 8100,
|
||||
0.2f, 10000,
|
||||
0,0,SENSOR_STRING_TYPE_ACCELEROMETER,
|
||||
0,1000000,SENSOR_FLAG_CONTINUOUS_MODE,
|
||||
{ },
|
||||
|
|
11
android/hardware/aw/sensors/aw_sensors/sensors.cpp
Normal file → Executable file
11
android/hardware/aw/sensors/aw_sensors/sensors.cpp
Normal file → Executable file
|
@ -285,6 +285,7 @@ int sensors_poll_context_t::pollEvents(sensors_event_t* data, int count)
|
|||
{
|
||||
int nbEvents = 0;
|
||||
int n = 0;
|
||||
int noInCnt = 0;
|
||||
// check flush pending
|
||||
for (int i = 0; i < 10; i++) {
|
||||
if(getFlushPending(i)) {
|
||||
|
@ -301,7 +302,7 @@ int sensors_poll_context_t::pollEvents(sensors_event_t* data, int count)
|
|||
|
||||
n = poll(mPollFds, sNumber, -1);
|
||||
if (n<0) {
|
||||
ALOGE(" AW poll() failed (%s)", strerror(errno));
|
||||
ALOGE(" AW sensor poll() failed (%s)", strerror(errno));
|
||||
return 0;
|
||||
}
|
||||
if (mPollFds[wake].revents & POLLIN) {
|
||||
|
@ -314,7 +315,6 @@ int sensors_poll_context_t::pollEvents(sensors_event_t* data, int count)
|
|||
// read sensor event
|
||||
for (int i = 0 ; (count >= 0) && (i < sNumber) ; i++) {
|
||||
SensorBase* const sensor(mSensors[i]);
|
||||
|
||||
#ifdef DEBUG_SENSOR
|
||||
ALOGE("AW count:%d, mPollFds[%d].revents:%d, hasPendingEvents():%d,sNumber:%d\n",
|
||||
count, i, mPollFds[i].revents, sensor->hasPendingEvents(),sNumber);
|
||||
|
@ -324,10 +324,15 @@ int sensors_poll_context_t::pollEvents(sensors_event_t* data, int count)
|
|||
if (nb < count) {
|
||||
mPollFds[i].revents = 0;
|
||||
}
|
||||
if (nb <= 0)
|
||||
ALOGE("AW sensor: %d error readEvents return %d\n", i, nb);
|
||||
count -= nb;
|
||||
nbEvents += nb;
|
||||
data += nb;
|
||||
}
|
||||
} else
|
||||
noInCnt++;
|
||||
if (noInCnt == sNumber)
|
||||
ALOGE("AW sensor error no data pollin\n");
|
||||
}
|
||||
return nbEvents;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue