X-Git-Url: http://git.osdn.net/view?a=blobdiff_plain;f=libs%2Fgui%2FSensor.cpp;h=9d0aa248c7ad83aa3aed32a603e33f69f76ef3c2;hb=18c874df483a61cffd59cbce2ceee88c87f10e3f;hp=cc865d16dd47228b47aa4da4404eedbbacc21c3c;hpb=8335fa3f500addd8804869388fd91d776aa56188;p=android-x86%2Fframeworks-native.git diff --git a/libs/gui/Sensor.cpp b/libs/gui/Sensor.cpp index cc865d16dd..9d0aa248c7 100644 --- a/libs/gui/Sensor.cpp +++ b/libs/gui/Sensor.cpp @@ -297,6 +297,7 @@ Sensor::Sensor(struct sensor_t const& hwSensor, const uuid_t& uuid, int halVersi mFlags |= (hwSensor.flags & DATA_INJECTION_MASK); } +#ifndef NO_SENSOR_PERMISSION_CHECK if (mRequiredPermission.length() > 0) { // If the sensor is protected by a permission we need to know if it is // a runtime one to determine whether we can use the permission cache. @@ -307,6 +308,7 @@ Sensor::Sensor(struct sensor_t const& hwSensor, const uuid_t& uuid, int halVersi String16(mRequiredPermission)); } } +#endif } Sensor::~Sensor() { @@ -408,6 +410,15 @@ const Sensor::uuid_t& Sensor::getUuid() const { return mUuid; } +void Sensor::setId(int32_t id) { + mUuid.i64[0] = id; + mUuid.i64[1] = 0; +} + +int32_t Sensor::getId() const { + return int32_t(mUuid.i64[0]); +} + size_t Sensor::getFlattenedSize() const { size_t fixedSize = sizeof(mVersion) + sizeof(mHandle) + sizeof(mType) + @@ -448,7 +459,18 @@ status_t Sensor::flatten(void* buffer, size_t size) const { FlattenableUtils::write(buffer, size, mRequiredAppOp); FlattenableUtils::write(buffer, size, mMaxDelay); FlattenableUtils::write(buffer, size, mFlags); - FlattenableUtils::write(buffer, size, mUuid); + if (mUuid.i64[1] != 0) { + // We should never hit this case with our current API, but we + // could via a careless API change. If that happens, + // this code will keep us from leaking our UUID (while probably + // breaking dynamic sensors). See b/29547335. + ALOGW("Sensor with UUID being flattened; sending 0. Expect " + "bad dynamic sensor behavior"); + uuid_t tmpUuid; // default constructor makes this 0. + FlattenableUtils::write(buffer, size, tmpUuid); + } else { + FlattenableUtils::write(buffer, size, mUuid); + } return NO_ERROR; }