Index: components/crash/content/app/breakpad_linux.cc |
diff --git a/components/crash/content/app/breakpad_linux.cc b/components/crash/content/app/breakpad_linux.cc |
index 16c1e5b5c0c715f378e3b58a3401df02de8f0cef..61932b817db0bd4b6b289af57b3e30497df8f017 100644 |
--- a/components/crash/content/app/breakpad_linux.cc |
+++ b/components/crash/content/app/breakpad_linux.cc |
@@ -561,6 +561,30 @@ void CrashReporterWriter::AddFileContents(const char* filename_msg, |
} |
#endif // defined(OS_CHROMEOS) |
+#if defined(OS_ANDROID) |
+// Writes the "package" field, which is in the format: |
+// $PACKAGE_NAME v$VERSION_CODE ($VERSION_NAME) |
+void WriteAndroidPackage(MimeWriter& writer, |
+ base::android::BuildInfo* android_build_info) { |
+ static const char package[] = "package"; |
+ // The actual size limits on packageId and versionName are quite generous. |
+ // Limit to a reasonable size rather than allocating theoretical limits. |
+ const int kMaxSize = 1024; |
+ char buf[kMaxSize]; |
+ |
+ my_strlcpy(buf, android_build_info->package_name(), kMaxSize); |
scottmg
2017/01/11 02:47:41
Comment here why it's not just using sprintf.
agrieve
2017/01/12 02:13:09
Done.
|
+ my_strlcat(buf, " v", kMaxSize - my_strlen(buf)); |
scottmg
2017/01/11 02:47:41
I believe strlcat and strlcpy normally take the fu
agrieve
2017/01/12 02:13:09
Aha, that's much nicer :)
|
+ my_strlcat(buf, android_build_info->package_version_code(), |
+ kMaxSize - my_strlen(buf)); |
+ my_strlcat(buf, " (", kMaxSize - my_strlen(buf)); |
+ my_strlcat(buf, android_build_info->package_version_name(), |
+ kMaxSize - my_strlen(buf)); |
+ my_strlcat(buf, ")", kMaxSize - my_strlen(buf)); |
+ |
+ writer.AddPairString(package, buf); |
+} |
+#endif // defined(OS_ANDROID) |
+ |
void DumpProcess() { |
if (g_breakpad) |
g_breakpad->WriteMinidump(); |
@@ -1657,6 +1681,8 @@ void HandleCrashDump(const BreakpadInfo& info) { |
writer.AddPairString(gms_core_version, |
android_build_info->gms_version_code()); |
writer.AddBoundary(); |
+ WriteAndroidPackage(writer, android_build_info); |
+ writer.AddBoundary(); |
if (android_build_info->java_exception_info() != nullptr) { |
writer.AddPairString(exception_info, |
android_build_info->java_exception_info()); |