Skip to content

Commit

Permalink
Merge branch 'cm-11.0' of git://github.com/CyanogenMod/android_framew…
Browse files Browse the repository at this point in the history
…orks_native into cm-11.0
  • Loading branch information
GDsouza committed Jun 24, 2014
2 parents 25caf2d + f4ba36a commit 35ba537
Show file tree
Hide file tree
Showing 7 changed files with 47 additions and 27 deletions.
3 changes: 3 additions & 0 deletions cmds/flatland/Android.mk
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
local_target_dir := $(TARGET_OUT_DATA)/local/tmp
LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)

Expand All @@ -11,6 +12,8 @@ LOCAL_MODULE:= flatland

LOCAL_MODULE_TAGS := tests

LOCAL_MODULE_PATH := $(local_target_dir)

LOCAL_SHARED_LIBRARIES := \
libEGL \
libGLESv2 \
Expand Down
1 change: 1 addition & 0 deletions include/binder/Parcel.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ class Parcel {
status_t writeStrongBinder(const sp<IBinder>& val);
status_t writeWeakBinder(const wp<IBinder>& val);
status_t writeInt32Array(size_t len, const int32_t *val);
status_t writeByteArray(size_t len, const uint8_t *val);

template<typename T>
status_t write(const Flattenable<T>& val);
Expand Down
28 changes: 26 additions & 2 deletions libs/binder/Parcel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@

#include <private/binder/binder_module.h>

#include <inttypes.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
Expand Down Expand Up @@ -627,6 +628,16 @@ status_t Parcel::writeInt32Array(size_t len, const int32_t *val) {
}
return ret;
}
status_t Parcel::writeByteArray(size_t len, const uint8_t *val) {
if (!val) {
return writeAligned(-1);
}
status_t ret = writeAligned(len);
if (ret == NO_ERROR) {
ret = write(val, len * sizeof(*val));
}
return ret;
}

status_t Parcel::writeInt64(int64_t val)
{
Expand Down Expand Up @@ -897,7 +908,8 @@ void Parcel::remove(size_t start, size_t amt)

status_t Parcel::read(void* outData, size_t len) const
{
if ((mDataPos+PAD_SIZE(len)) >= mDataPos && (mDataPos+PAD_SIZE(len)) <= mDataSize) {
if ((mDataPos+PAD_SIZE(len)) >= mDataPos && (mDataPos+PAD_SIZE(len)) <= mDataSize
&& len <= PAD_SIZE(len)) {
memcpy(outData, mData+mDataPos, len);
mDataPos += PAD_SIZE(len);
ALOGV("read Setting data pos of %p to %d\n", this, mDataPos);
Expand All @@ -908,7 +920,8 @@ status_t Parcel::read(void* outData, size_t len) const

const void* Parcel::readInplace(size_t len) const
{
if ((mDataPos+PAD_SIZE(len)) >= mDataPos && (mDataPos+PAD_SIZE(len)) <= mDataSize) {
if ((mDataPos+PAD_SIZE(len)) >= mDataPos && (mDataPos+PAD_SIZE(len)) <= mDataSize
&& len <= PAD_SIZE(len)) {
const void* data = mData+mDataPos;
mDataPos += PAD_SIZE(len);
ALOGV("readInplace Setting data pos of %p to %d\n", this, mDataPos);
Expand Down Expand Up @@ -1317,6 +1330,7 @@ size_t Parcel::ipcObjectsCount() const
void Parcel::ipcSetDataReference(const uint8_t* data, size_t dataSize,
const size_t* objects, size_t objectsCount, release_func relFunc, void* relCookie)
{
size_t minOffset = 0;
freeDataNoInit();
mError = NO_ERROR;
mData = const_cast<uint8_t*>(data);
Expand All @@ -1329,6 +1343,16 @@ void Parcel::ipcSetDataReference(const uint8_t* data, size_t dataSize,
mNextObjectHint = 0;
mOwner = relFunc;
mOwnerCookie = relCookie;
for (size_t i = 0; i < mObjectsSize; i++) {
size_t offset = mObjects[i];
if (offset < minOffset) {
ALOGE("%s: bad object offset %zu < %zu\n",
__func__, offset, minOffset);
mObjectsSize = 0;
break;
}
minOffset = offset + sizeof(flat_binder_object);
}
scanForFds();
}

Expand Down
16 changes: 4 additions & 12 deletions services/sensorservice/SensorFusion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,15 +102,6 @@ status_t SensorFusion::activate(void* ident, bool enabled) {
}
}

if (enabled) {
ALOGD_IF(DEBUG_CONNECTIONS, "SensorFusion calling batch ident=%p ", ident);
// Activating a sensor in continuous mode is equivalent to calling batch with the default
// period and timeout equal to ZERO, followed by a call to activate.
mSensorDevice.batch(ident, mAcc.getHandle(), 0, DEFAULT_EVENTS_PERIOD, 0);
mSensorDevice.batch(ident, mMag.getHandle(), 0, DEFAULT_EVENTS_PERIOD, 0);
mSensorDevice.batch(ident, mGyro.getHandle(), 0, DEFAULT_EVENTS_PERIOD, 0);
}

mSensorDevice.activate(ident, mAcc.getHandle(), enabled);
mSensorDevice.activate(ident, mMag.getHandle(), enabled);
mSensorDevice.activate(ident, mGyro.getHandle(), enabled);
Expand All @@ -127,9 +118,10 @@ status_t SensorFusion::activate(void* ident, bool enabled) {
}

status_t SensorFusion::setDelay(void* ident, int64_t ns) {
mSensorDevice.setDelay(ident, mAcc.getHandle(), ns);
mSensorDevice.setDelay(ident, mMag.getHandle(), ms2ns(20));
mSensorDevice.setDelay(ident, mGyro.getHandle(), mTargetDelayNs);
// Call batch with timeout zero instead of setDelay().
mSensorDevice.batch(ident, mAcc.getHandle(), 0, ns, 0);
mSensorDevice.batch(ident, mMag.getHandle(), 0, ms2ns(20), 0);
mSensorDevice.batch(ident, mGyro.getHandle(), 0, mTargetDelayNs, 0);
return NO_ERROR;
}

Expand Down
1 change: 0 additions & 1 deletion services/sensorservice/SensorFusion.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ class SensorDevice;

class SensorFusion : public Singleton<SensorFusion> {
friend class Singleton<SensorFusion>;
static const nsecs_t DEFAULT_EVENTS_PERIOD = 200000000; // 5 Hz

SensorDevice& mSensorDevice;
Sensor mAcc;
Expand Down
23 changes: 12 additions & 11 deletions services/sensorservice/SensorService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -426,20 +426,21 @@ bool SensorService::threadLoop()
}

void SensorService::recordLastValue(
sensors_event_t const * buffer, size_t count)
{
const sensors_event_t* buffer, size_t count) {
Mutex::Autolock _l(mLock);
// record the last event for each sensor
int32_t prev = buffer[0].sensor;
for (size_t i=1 ; i<count ; i++) {
// record the last event of each sensor type in this buffer
int32_t curr = buffer[i].sensor;
if (curr != prev) {
mLastEventSeen.editValueFor(prev) = buffer[i-1];
prev = curr;
const sensors_event_t* last = NULL;
for (size_t i = 0; i < count; i++) {
const sensors_event_t* event = &buffer[i];
if (event->type != SENSOR_TYPE_META_DATA) {
if (last && event->sensor != last->sensor) {
mLastEventSeen.editValueFor(last->sensor) = *last;
}
last = event;
}
}
mLastEventSeen.editValueFor(prev) = buffer[count-1];
if (last) {
mLastEventSeen.editValueFor(last->sensor) = *last;
}
}

void SensorService::sortEventBuffer(sensors_event_t* buffer, size_t count)
Expand Down
2 changes: 1 addition & 1 deletion services/sensorservice/SensorService.h
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ class SensorService :

String8 getSensorName(int handle) const;
bool isVirtualSensor(int handle) const;
void recordLastValue(sensors_event_t const * buffer, size_t count);
void recordLastValue(const sensors_event_t* buffer, size_t count);
static void sortEventBuffer(sensors_event_t* buffer, size_t count);
Sensor registerSensor(SensorInterface* sensor);
Sensor registerVirtualSensor(SensorInterface* sensor);
Expand Down

0 comments on commit 35ba537

Please sign in to comment.