Commit 3cb9bc59 authored by Andrew Grieve's avatar Andrew Grieve Committed by Commit Bot

Android: Guard against null versionName in BuildInfo

This regressed in be35cd67

Bug: 824141
Change-Id: I7975bc8dffbfafeec7f0a50bad4d75dfeefff0ee
Reviewed-on: https://chromium-review.googlesource.com/973383
Commit-Queue: agrieve <agrieve@chromium.org>
Reviewed-by: default avatarPaul Jensen <pauljensen@chromium.org>
Cr-Commit-Position: refs/heads/master@{#544711}
parent 73aa9d5e
...@@ -63,6 +63,10 @@ public class BuildInfo { ...@@ -63,6 +63,10 @@ public class BuildInfo {
}; };
} }
private static String nullToEmpty(CharSequence seq) {
return seq == null ? "" : seq.toString();
}
/** /**
* @param packageInfo Package for Chrome/WebView (as opposed to host app). * @param packageInfo Package for Chrome/WebView (as opposed to host app).
*/ */
...@@ -86,19 +90,16 @@ public class BuildInfo { ...@@ -86,19 +90,16 @@ public class BuildInfo {
if (sBrowserPackageInfo != null) { if (sBrowserPackageInfo != null) {
packageName = sBrowserPackageInfo.packageName; packageName = sBrowserPackageInfo.packageName;
versionCode = sBrowserPackageInfo.versionCode; versionCode = sBrowserPackageInfo.versionCode;
versionName = sBrowserPackageInfo.versionName; versionName = nullToEmpty(sBrowserPackageInfo.versionName);
sBrowserPackageInfo = null; sBrowserPackageInfo = null;
} else { } else {
packageName = hostPackageName; packageName = hostPackageName;
versionCode = hostVersionCode; versionCode = hostVersionCode;
versionName = pi.versionName; versionName = nullToEmpty(pi.versionName);
} }
CharSequence label = pm.getApplicationLabel(pi.applicationInfo); hostPackageLabel = nullToEmpty(pm.getApplicationLabel(pi.applicationInfo));
hostPackageLabel = label == null ? "" : label.toString(); installerPackageName = nullToEmpty(pm.getInstallerPackageName(packageName));
String value = pm.getInstallerPackageName(packageName);
installerPackageName = value == null ? "" : value;
PackageInfo gmsPackageInfo = null; PackageInfo gmsPackageInfo = null;
try { try {
......
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