Commit 3e261e9b authored by Eric Stevenson's avatar Eric Stevenson Committed by Commit Bot

Android: Add extra fields related to resources to crash reports.

This CL adds two fields to Android crash reports. Specifically:
1. custom_themes: Whether or not the user has apps installed for using
custom themes. This should help debug obscure resources related
crashes.
2. resources_version: The product version as stored in resources.arsc.
This should help us detect if we tried to load resources from the old
apk during an update.

Bug: 820591
Change-Id: I1e2b36ec5640bb1376f83452851eaa5319d0f32f
Reviewed-on: https://chromium-review.googlesource.com/969597
Commit-Queue: Eric Stevenson <estevenson@chromium.org>
Reviewed-by: default avatarLei Zhang <thestig@chromium.org>
Reviewed-by: default avataragrieve <agrieve@chromium.org>
Reviewed-by: default avatarYaron Friedman <yfriedman@chromium.org>
Cr-Commit-Position: refs/heads/master@{#545798}
parent 5b4e8c54
......@@ -2678,6 +2678,7 @@ if (is_android) {
]
deps = [
":base_java_resources",
"//third_party/android_tools:android_support_annotations_java",
"//third_party/android_tools:android_support_multidex_java",
"//third_party/jsr-305:jsr_305_javalib",
......@@ -2770,6 +2771,11 @@ if (is_android) {
]
}
android_resources("base_java_resources") {
resource_dirs = [ "android/java/res" ]
custom_package = "org.chromium.base"
}
android_aidl("base_java_aidl") {
import_include = [ "android/java/src" ]
sources = [
......
......@@ -73,7 +73,9 @@ BuildInfo::BuildInfo(const std::vector<std::string>& params)
installer_package_name_(StrDupParam(params, 16)),
abi_name_(StrDupParam(params, 17)),
firebase_app_id_(StrDupParam(params, 18)),
extracted_file_suffix_(params[19]),
custom_themes_(StrDupParam(params, 19)),
resources_version_(StrDupParam(params, 20)),
extracted_file_suffix_(params[21]),
java_exception_info_(NULL) {}
// static
......
......@@ -103,6 +103,10 @@ class BASE_EXPORT BuildInfo {
// Will be empty string if no app id is assigned.
const char* firebase_app_id() const { return firebase_app_id_; }
const char* custom_themes() const { return custom_themes_; }
const char* resources_version() const { return resources_version_; }
const char* build_type() const {
return build_type_;
}
......@@ -155,6 +159,8 @@ class BASE_EXPORT BuildInfo {
const char* const installer_package_name_;
const char* const abi_name_;
const char* const firebase_app_id_;
const char* const custom_themes_;
const char* const resources_version_;
// Not needed by breakpad.
const std::string extracted_file_suffix_;
// This is set via set_java_exception_info, not at constructor time.
......
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright 2018 The Chromium Authors. All rights reserved.
Use of this source code is governed by a BSD-style license that can be
found in the LICENSE file.
-->
<resources xmlns:android="http://schemas.android.com/apk/res/android">
<!-- Overridden by apk targets. -->
<string name="product_version" translatable="false">Developer Build</string>
</resources>
......@@ -45,6 +45,10 @@ public class BuildInfo {
public final String androidBuildFingerprint;
/** A string that is different each time the apk changes. */
public final String extractedFileSuffix;
/** Whether or not the device has apps installed for using custom themes. */
public final String customThemes;
/** Product version as stored in Android resources. */
public final String resourcesVersion;
private static class Holder { private static BuildInfo sInstance = new BuildInfo(); }
......@@ -59,7 +63,7 @@ public class BuildInfo {
buildInfo.packageName, String.valueOf(buildInfo.versionCode), buildInfo.versionName,
buildInfo.androidBuildFingerprint, buildInfo.gmsVersionCode,
buildInfo.installerPackageName, buildInfo.abiString, BuildConfig.FIREBASE_APP_ID,
buildInfo.extractedFileSuffix,
buildInfo.customThemes, buildInfo.resourcesVersion, buildInfo.extractedFileSuffix,
};
}
......@@ -110,6 +114,31 @@ public class BuildInfo {
gmsVersionCode = gmsPackageInfo != null ? String.valueOf(gmsPackageInfo.versionCode)
: "gms versionCode not available.";
String hasCustomThemes = "true";
try {
// Substratum is a theme engine that enables users to use custom themes provided
// by theme apps. Sometimes these can cause crashs if not installed correctly.
// These crashes can be difficult to debug, so knowing if the theme manager is
// present on the device is useful (http://crbug.com/820591).
pm.getPackageInfo("projekt.substratum", 0);
} catch (NameNotFoundException e) {
hasCustomThemes = "false";
}
customThemes = hasCustomThemes;
String currentResourcesVersion;
try {
// This value can be compared with the actual product version to determine if
// corrupted resources were the cause of a crash. This can happen if the app
// loads resources from the outdated package during an update
// (http://crbug.com/820591).
currentResourcesVersion =
ContextUtils.getApplicationContext().getString(R.string.product_version);
} catch (Exception e) {
currentResourcesVersion = "Not found";
}
resourcesVersion = currentResourcesVersion;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
abiString = TextUtils.join(", ", Build.SUPPORTED_ABIS);
} else {
......
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright 2018 The Chromium Authors. All rights reserved.
Use of this source code is governed by a BSD-style license that can be
found in the LICENSE file.
-->
<resources xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
<string name="product_version" translatable="false" tools:ignore="UnusedResources">{{product_version}}</string>
</resources>
......@@ -2161,6 +2161,14 @@ if (enable_java_templates) {
_srcjar_deps += [ ":${_template_name}__build_config_java" ]
}
_version_resources_target = "${_template_name}__version_resources"
jinja_template_resources(_version_resources_target) {
res_dir = "//build/android/res_templates"
resources = [ "//build/android/res_templates/values/version_strings.xml" ]
variables = [ "product_version=$_version_name" ]
}
_deps += [ ":$_version_resources_target" ]
_java_target = "${_template_name}__java"
java_library_impl(_java_target) {
forward_variables_from(invoker,
......
......@@ -49,6 +49,8 @@ public class PureJavaExceptionReporter {
public static final String EXCEPTION_INFO = "exception_info";
public static final String PROCESS_TYPE = "ptype";
public static final String EARLY_JAVA_EXCEPTION = "early_java_exception";
public static final String CUSTOM_THEMES = "custom_themes";
public static final String RESOURCES_VERSION = "resources_version";
private static final String CRASH_DUMP_DIR = "Crash Reports";
private static final String FILE_PREFIX = "chromium-browser-minidump-";
......@@ -137,6 +139,8 @@ public class PureJavaExceptionReporter {
addPairedString(PACKAGE,
String.format("%s v%s (%s)", BuildConfig.FIREBASE_APP_ID, buildInfo.versionCode,
buildInfo.versionName));
addPairedString(CUSTOM_THEMES, buildInfo.customThemes);
addPairedString(RESOURCES_VERSION, buildInfo.resourcesVersion);
addString(mBoundary);
}
......
......@@ -1712,6 +1712,8 @@ void HandleCrashDump(const BreakpadInfo& info) {
static const char brand[] = "brand";
static const char board[] = "board";
static const char exception_info[] = "exception_info";
static const char custom_themes[] = "custom_themes";
static const char resources_version[] = "resources_version";
base::android::BuildInfo* android_build_info =
base::android::BuildInfo::GetInstance();
......@@ -1737,6 +1739,11 @@ void HandleCrashDump(const BreakpadInfo& info) {
writer.AddBoundary();
writer.AddPairString(abi_name, android_build_info->abi_name());
writer.AddBoundary();
writer.AddPairString(custom_themes, android_build_info->custom_themes());
writer.AddBoundary();
writer.AddPairString(resources_version,
android_build_info->resources_version());
writer.AddBoundary();
WriteAndroidPackage(writer, android_build_info);
writer.AddBoundary();
if (android_build_info->java_exception_info() != nullptr) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment