Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(202)

Unified Diff: components/crash/content/app/breakpad_linux.cc

Issue 2556523002: Add package field to Android crash reports (Closed)
Patch Set: inline "package Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 9ebc33f4f01ce975604b921303e43c3af59a04cb..e840ff7f66ed9eeb644e731ee0c2ffebb64046d8 100644
--- a/components/crash/content/app/breakpad_linux.cc
+++ b/components/crash/content/app/breakpad_linux.cc
@@ -553,6 +553,28 @@ 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) {
+ // 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];
+
+ // Not using sprintf to ensure no heap allocations.
+ my_strlcpy(buf, android_build_info->package_name(), kMaxSize);
+ my_strlcat(buf, " v", kMaxSize);
+ my_strlcat(buf, android_build_info->package_version_code(), kMaxSize);
+ my_strlcat(buf, " (", kMaxSize);
+ my_strlcat(buf, android_build_info->package_version_name(), kMaxSize);
+ my_strlcat(buf, ")", kMaxSize);
+
+ writer.AddPairString("package", buf);
+}
+#endif // defined(OS_ANDROID)
+
void DumpProcess() {
if (g_breakpad)
g_breakpad->WriteMinidump();
@@ -1628,6 +1650,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());
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698