summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDevin Moore <devinmoore@google.com>2021-05-10 22:33:24 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2021-05-10 22:33:24 +0000
commitbef6e9f73b15ed83233edeecf7a5e59f075aa095 (patch)
tree6352b1dce6dcb82c918e9423d1a13b9d7c6538d2
parent8d85d9ed08d025e1ae631f4d66eefbcf2e7d6262 (diff)
parent2741a815bcfc91396b115cd3018cd26501ac8f1d (diff)
downloadlibfmq-bef6e9f73b15ed83233edeecf7a5e59f075aa095.tar.gz
Merge "Add SafetyNet logging for b/184963385 fix" into sc-dev
-rw-r--r--FmqInternal.cpp5
-rw-r--r--base/fmq/MQDescriptorBase.h1
-rw-r--r--include/fmq/MessageQueueBase.h4
3 files changed, 10 insertions, 0 deletions
diff --git a/FmqInternal.cpp b/FmqInternal.cpp
index 6b95def..886d155 100644
--- a/FmqInternal.cpp
+++ b/FmqInternal.cpp
@@ -16,6 +16,7 @@
#define LOG_TAG "FMQ"
#include <android-base/logging.h>
+#include <utils/Log.h>
namespace android {
namespace hardware {
@@ -29,6 +30,10 @@ void logError(const std::string &message) {
LOG(ERROR) << message;
}
+void errorWriteLog(int tag, const char* info) {
+ android_errorWriteLog(tag, info);
+}
+
} // namespace details
} // namespace hardware
} // namespace android
diff --git a/base/fmq/MQDescriptorBase.h b/base/fmq/MQDescriptorBase.h
index 21b8e21..0d18d4c 100644
--- a/base/fmq/MQDescriptorBase.h
+++ b/base/fmq/MQDescriptorBase.h
@@ -54,6 +54,7 @@ static_assert(__alignof(GrantorDescriptor) == 8, "wrong alignment");
namespace details {
void logError(const std::string& message);
+void errorWriteLog(int tag, const char* message);
typedef uint64_t RingBufferPosition;
enum GrantorType : int { READPTRPOS = 0, WRITEPTRPOS, DATAPTRPOS, EVFLAGWORDPOS };
diff --git a/include/fmq/MessageQueueBase.h b/include/fmq/MessageQueueBase.h
index 9bf20e4..b932317 100644
--- a/include/fmq/MessageQueueBase.h
+++ b/include/fmq/MessageQueueBase.h
@@ -589,7 +589,9 @@ void MessageQueueBase<MQDescriptorType, T, flavor>::initMemory(bool resetPointer
const auto& grantors = mDesc->grantors();
for (const auto& grantor : grantors) {
if (hardware::details::isAlignedToWordBoundary(grantor.offset) == false) {
+#ifdef __BIONIC__
__assert(__FILE__, __LINE__, "Grantor offsets need to be aligned");
+#endif
}
}
@@ -1073,6 +1075,7 @@ bool MessageQueueBase<MQDescriptorType, T, flavor>::beginWrite(size_t nMessages,
hardware::details::logError(
"The write pointer has become misaligned. Writing to the queue is no longer "
"possible.");
+ hardware::details::errorWriteLog(0x534e4554, "184963385");
return false;
}
size_t writeOffset = writePtr % mDesc->getSize();
@@ -1164,6 +1167,7 @@ MessageQueueBase<MQDescriptorType, T, flavor>::beginRead(size_t nMessages,
hardware::details::logError(
"The write or read pointer has become misaligned. Reading from the queue is no "
"longer possible.");
+ hardware::details::errorWriteLog(0x534e4554, "184963385");
return false;
}