Merge "Graphics depth formats: Add confidence values" into mnc-dev
diff --git a/base/file.cpp b/base/file.cpp
index 6b19818..9a340b7 100644
--- a/base/file.cpp
+++ b/base/file.cpp
@@ -51,7 +51,7 @@
return false;
}
bool result = ReadFdToString(fd, content);
- TEMP_FAILURE_RETRY(close(fd));
+ close(fd);
return result;
}
@@ -102,7 +102,7 @@
ALOGE("android::WriteStringToFile write failed: %s", strerror(errno));
return CleanUpAfterFailedWrite(path);
}
- TEMP_FAILURE_RETRY(close(fd));
+ close(fd);
return true;
}
#endif
@@ -116,7 +116,7 @@
}
bool result = WriteStringToFd(content, fd);
- TEMP_FAILURE_RETRY(close(fd));
+ close(fd);
return result || CleanUpAfterFailedWrite(path);
}
diff --git a/include/utils/BlobCache.h b/include/utils/BlobCache.h
index 7d621e4..65dca9f 100644
--- a/include/utils/BlobCache.h
+++ b/include/utils/BlobCache.h
@@ -185,6 +185,12 @@
// mNumEntries is number of cache entries following the header in the
// data.
size_t mNumEntries;
+
+ // mBuildId is the build id of the device when the cache was created.
+ // When an update to the build happens (via an OTA or other update) this
+ // is used to invalidate the cache.
+ int mBuildIdLength;
+ char mBuildId[];
};
// An EntryHeader is the header for a serialized cache entry. No need to
diff --git a/libutils/Android.mk b/libutils/Android.mk
index f675a94..40cd31e 100644
--- a/libutils/Android.mk
+++ b/libutils/Android.mk
@@ -16,7 +16,6 @@
commonSources:= \
BasicHashtable.cpp \
- BlobCache.cpp \
CallStack.cpp \
FileMap.cpp \
JenkinsHash.cpp \
@@ -74,6 +73,7 @@
# we have the common sources, plus some device-specific stuff
LOCAL_SRC_FILES:= \
$(commonSources) \
+ BlobCache.cpp \
Looper.cpp \
Trace.cpp
@@ -83,7 +83,8 @@
LOCAL_CFLAGS += -Werror
LOCAL_STATIC_LIBRARIES := \
- libcutils
+ libcutils \
+ libc
LOCAL_SHARED_LIBRARIES := \
libbacktrace \
diff --git a/libutils/BlobCache.cpp b/libutils/BlobCache.cpp
index 0ea09cf..126995b 100644
--- a/libutils/BlobCache.cpp
+++ b/libutils/BlobCache.cpp
@@ -25,13 +25,15 @@
#include <utils/Errors.h>
#include <utils/Log.h>
+#include <cutils/properties.h>
+
namespace android {
// BlobCache::Header::mMagicNumber value
static const uint32_t blobCacheMagic = ('_' << 24) + ('B' << 16) + ('b' << 8) + '$';
// BlobCache::Header::mBlobCacheVersion value
-static const uint32_t blobCacheVersion = 2;
+static const uint32_t blobCacheVersion = 3;
// BlobCache::Header::mDeviceVersion value
static const uint32_t blobCacheDeviceVersion = 1;
@@ -165,7 +167,7 @@
}
size_t BlobCache::getFlattenedSize() const {
- size_t size = align4(sizeof(Header));
+ size_t size = align4(sizeof(Header) + PROPERTY_VALUE_MAX);
for (size_t i = 0; i < mCacheEntries.size(); i++) {
const CacheEntry& e(mCacheEntries[i]);
sp<Blob> keyBlob = e.getKey();
@@ -187,10 +189,13 @@
header->mBlobCacheVersion = blobCacheVersion;
header->mDeviceVersion = blobCacheDeviceVersion;
header->mNumEntries = mCacheEntries.size();
+ char buildId[PROPERTY_VALUE_MAX];
+ header->mBuildIdLength = property_get("ro.build.id", buildId, "");
+ memcpy(header->mBuildId, buildId, header->mBuildIdLength);
// Write cache entries
uint8_t* byteBuffer = reinterpret_cast<uint8_t*>(buffer);
- off_t byteOffset = align4(sizeof(Header));
+ off_t byteOffset = align4(sizeof(Header) + header->mBuildIdLength);
for (size_t i = 0; i < mCacheEntries.size(); i++) {
const CacheEntry& e(mCacheEntries[i]);
sp<Blob> keyBlob = e.getKey();
@@ -239,15 +244,19 @@
ALOGE("unflatten: bad magic number: %" PRIu32, header->mMagicNumber);
return BAD_VALUE;
}
+ char buildId[PROPERTY_VALUE_MAX];
+ int len = property_get("ro.build.id", buildId, "");
if (header->mBlobCacheVersion != blobCacheVersion ||
- header->mDeviceVersion != blobCacheDeviceVersion) {
+ header->mDeviceVersion != blobCacheDeviceVersion ||
+ len != header->mBuildIdLength ||
+ strncmp(buildId, header->mBuildId, len)) {
// We treat version mismatches as an empty cache.
return OK;
}
// Read cache entries
const uint8_t* byteBuffer = reinterpret_cast<const uint8_t*>(buffer);
- off_t byteOffset = align4(sizeof(Header));
+ off_t byteOffset = align4(sizeof(Header) + header->mBuildIdLength);
size_t numEntries = header->mNumEntries;
for (size_t i = 0; i < numEntries; i++) {
if (byteOffset + sizeof(EntryHeader) > size) {