Add SafetyNet logging to JNI::NewStringUTF.
(cherry picked from commit 6444277041f41294d98adac4bb585183e56587f6)
Test: blueline-userdebug boots.
Bug: 172655291
Merged-In: I653db8be0c0a45302f0d1c54285c02d2d052a9f4
Merged-In: I9e9ed17377c9723d07169e7bcdbb8e36f995988e
Change-Id: I9e9ed17377c9723d07169e7bcdbb8e36f995988e
diff --git a/runtime/jni_internal.cc b/runtime/jni_internal.cc
index 37a1fe6..2805139 100644
--- a/runtime/jni_internal.cc
+++ b/runtime/jni_internal.cc
@@ -19,6 +19,7 @@
#include <dlfcn.h>
#include <cstdarg>
+#include <log/log.h>
#include <memory>
#include <utility>
#include <vector>
@@ -1768,6 +1769,7 @@
/*bad=*/ []() { return true; }); // Abort processing and return 0 for bad characters.
if (UNLIKELY(utf8_length != 0u && utf16_length == 0u)) {
// VisitModifiedUtf8Chars() aborted for a bad character.
+ android_errorWriteLog(0x534e4554, "172655291"); // Report to SafetyNet.
// Report the error to logcat but avoid too much spam.
static const uint64_t kMinDelay = UINT64_C(10000000000); // 10s
static std::atomic<uint64_t> prev_bad_input_time(UINT64_C(0));