Commit be35cd67 authored by Andrew Grieve's avatar Andrew Grieve Committed by Commit Bot

Android: Refactor BuildInfo to correct the "package" field of WebView minidumps

This adds the concept of "hostPackage" vs "package", which for webview
will contain different values.

TBR=agrieve  # trivial rename in devtools_http_handler.cc
Bug: 620323

Change-Id: I4a3c3376d3793eb3ddb90afe3359e320d6255edc
Reviewed-on: https://chromium-review.googlesource.com/939715
Commit-Queue: agrieve <agrieve@chromium.org>
Reviewed-by: default avatarMaria Khomenko <mariakhomenko@chromium.org>
Reviewed-by: default avatarTobias Sargeant <tobiasjs@chromium.org>
Cr-Commit-Position: refs/heads/master@{#541114}
parent fe6b786e
...@@ -53,7 +53,7 @@ int AwNetworkDelegate::OnBeforeStartTransaction( ...@@ -53,7 +53,7 @@ int AwNetworkDelegate::OnBeforeStartTransaction(
DCHECK(headers); DCHECK(headers);
headers->SetHeaderIfMissing( headers->SetHeaderIfMissing(
"X-Requested-With", "X-Requested-With",
base::android::BuildInfo::GetInstance()->package_name()); base::android::BuildInfo::GetInstance()->host_package_name());
return net::OK; return net::OK;
} }
......
...@@ -36,6 +36,7 @@ import org.chromium.android_webview.AwBrowserProcess; ...@@ -36,6 +36,7 @@ import org.chromium.android_webview.AwBrowserProcess;
import org.chromium.android_webview.ResourcesContextWrapperFactory; import org.chromium.android_webview.ResourcesContextWrapperFactory;
import org.chromium.android_webview.WebViewChromiumRunQueue; import org.chromium.android_webview.WebViewChromiumRunQueue;
import org.chromium.android_webview.command_line.CommandLineUtil; import org.chromium.android_webview.command_line.CommandLineUtil;
import org.chromium.base.BuildInfo;
import org.chromium.base.CommandLine; import org.chromium.base.CommandLine;
import org.chromium.base.ContextUtils; import org.chromium.base.ContextUtils;
import org.chromium.base.PackageUtils; import org.chromium.base.PackageUtils;
...@@ -202,11 +203,12 @@ public class WebViewChromiumFactoryProvider implements WebViewFactoryProvider { ...@@ -202,11 +203,12 @@ public class WebViewChromiumFactoryProvider implements WebViewFactoryProvider {
} }
ThreadUtils.setWillOverrideUiThread(); ThreadUtils.setWillOverrideUiThread();
final PackageInfo packageInfo = WebViewFactory.getLoadedPackageInfo();
BuildInfo.setBrowserPackageInfo(packageInfo);
// Load chromium library. // Load chromium library.
AwBrowserProcess.loadLibrary(mWebViewDelegate.getDataDirectorySuffix()); AwBrowserProcess.loadLibrary(mWebViewDelegate.getDataDirectorySuffix());
final PackageInfo packageInfo = WebViewFactory.getLoadedPackageInfo();
StrictMode.ThreadPolicy oldPolicy = StrictMode.allowThreadDiskWrites(); StrictMode.ThreadPolicy oldPolicy = StrictMode.allowThreadDiskWrites();
try { try {
// Load glue-layer support library. // Load glue-layer support library.
......
...@@ -241,11 +241,11 @@ void AwMainDelegate::PreSandboxStartup() { ...@@ -241,11 +241,11 @@ void AwMainDelegate::PreSandboxStartup() {
static ::crash_reporter::CrashKeyString<64> app_name_key( static ::crash_reporter::CrashKeyString<64> app_name_key(
crash_keys::kAppPackageName); crash_keys::kAppPackageName);
app_name_key.Set(android_build_info->package_name()); app_name_key.Set(android_build_info->host_package_name());
static ::crash_reporter::CrashKeyString<64> app_version_key( static ::crash_reporter::CrashKeyString<64> app_version_key(
crash_keys::kAppPackageVersionCode); crash_keys::kAppPackageVersionCode);
app_version_key.Set(android_build_info->package_version_code()); app_version_key.Set(android_build_info->host_version_code());
static ::crash_reporter::CrashKeyString<8> sdk_int_key( static ::crash_reporter::CrashKeyString<8> sdk_int_key(
crash_keys::kAndroidSdkInt); crash_keys::kAndroidSdkInt);
......
...@@ -61,16 +61,18 @@ BuildInfo::BuildInfo(const std::vector<std::string>& params) ...@@ -61,16 +61,18 @@ BuildInfo::BuildInfo(const std::vector<std::string>& params)
model_(StrDupParam(params, 4)), model_(StrDupParam(params, 4)),
sdk_int_(SdkIntParam(params, 5)), sdk_int_(SdkIntParam(params, 5)),
build_type_(StrDupParam(params, 6)), build_type_(StrDupParam(params, 6)),
package_label_(StrDupParam(params, 7)), host_package_name_(StrDupParam(params, 7)),
package_name_(StrDupParam(params, 8)), host_version_code_(StrDupParam(params, 8)),
package_version_code_(StrDupParam(params, 9)), host_package_label_(StrDupParam(params, 9)),
package_version_name_(StrDupParam(params, 10)), package_name_(StrDupParam(params, 10)),
android_build_fp_(StrDupParam(params, 11)), package_version_code_(StrDupParam(params, 11)),
gms_version_code_(StrDupParam(params, 12)), package_version_name_(StrDupParam(params, 12)),
installer_package_name_(StrDupParam(params, 13)), android_build_fp_(StrDupParam(params, 13)),
abi_name_(StrDupParam(params, 14)), gms_version_code_(StrDupParam(params, 14)),
firebase_app_id_(StrDupParam(params, 15)), installer_package_name_(StrDupParam(params, 15)),
extracted_file_suffix_(params[16]), abi_name_(StrDupParam(params, 16)),
firebase_app_id_(StrDupParam(params, 17)),
extracted_file_suffix_(params[18]),
java_exception_info_(NULL) {} java_exception_info_(NULL) {}
// static // static
......
...@@ -82,6 +82,12 @@ class BASE_EXPORT BuildInfo { ...@@ -82,6 +82,12 @@ class BASE_EXPORT BuildInfo {
return gms_version_code_; return gms_version_code_;
} }
const char* host_package_name() const { return host_package_name_; }
const char* host_version_code() const { return host_version_code_; }
const char* host_package_label() const { return host_package_label_; }
const char* package_version_code() const { const char* package_version_code() const {
return package_version_code_; return package_version_code_;
} }
...@@ -90,10 +96,6 @@ class BASE_EXPORT BuildInfo { ...@@ -90,10 +96,6 @@ class BASE_EXPORT BuildInfo {
return package_version_name_; return package_version_name_;
} }
const char* package_label() const {
return package_label_;
}
const char* package_name() const { const char* package_name() const {
return package_name_; return package_name_;
} }
...@@ -139,7 +141,9 @@ class BASE_EXPORT BuildInfo { ...@@ -139,7 +141,9 @@ class BASE_EXPORT BuildInfo {
const char* const model_; const char* const model_;
const int sdk_int_; const int sdk_int_;
const char* const build_type_; const char* const build_type_;
const char* const package_label_; const char* const host_package_name_;
const char* const host_version_code_;
const char* const host_package_label_;
const char* const package_name_; const char* const package_name_;
const char* const package_version_code_; const char* const package_version_code_;
const char* const package_version_name_; const char* const package_version_name_;
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
package org.chromium.base; package org.chromium.base;
import android.content.Context;
import android.content.pm.PackageInfo; import android.content.pm.PackageInfo;
import android.content.pm.PackageManager; import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException; import android.content.pm.PackageManager.NameNotFoundException;
...@@ -18,109 +19,113 @@ import org.chromium.base.annotations.CalledByNative; ...@@ -18,109 +19,113 @@ import org.chromium.base.annotations.CalledByNative;
* primarily of use for accessing package information from native code. * primarily of use for accessing package information from native code.
*/ */
public class BuildInfo { public class BuildInfo {
/**
* Array index to access field in {@link BuildInfo#getAll()}.
*/
public static final int BRAND_INDEX = 0;
public static final int DEVICE_INDEX = 1;
public static final int ANDROID_BUILD_ID_INDEX = 2;
public static final int MODEL_INDEX = 4;
public static final int ANDROID_BUILD_FP_INDEX = 11;
public static final int GMS_CORE_VERSION_INDEX = 12;
public static final int INSTALLER_PACKAGE_NAME_INDEX = 13;
public static final int ABI_NAME_INDEX = 14;
private static final String TAG = "BuildInfo"; private static final String TAG = "BuildInfo";
private static final int MAX_FINGERPRINT_LENGTH = 128; private static final int MAX_FINGERPRINT_LENGTH = 128;
/** private static PackageInfo sBrowserPackageInfo;
* BuildInfo is a static utility class and therefore shouldn't be instantiated. private static boolean sInitialized;
*/
private BuildInfo() {} /** The application name (e.g. "Chrome"). For WebView, this is name of the embedding app. */
public final String hostPackageLabel;
/** By default: same as versionCode. For WebView: versionCode of the embedding app. */
public final int hostVersionCode;
/** The packageName of Chrome/WebView. Use application context for host app packageName. */
public final String packageName;
/** The versionCode of the apk. */
public final int versionCode;
/** The versionName of Chrome/WebView. Use application context for host app versionName. */
public final String versionName;
/** Result of PackageManager.getInstallerPackageName(). Never null, but may be "". */
public final String installerPackageName;
/** The versionCode of Play Services (for crash reporting). */
public final String gmsVersionCode;
/** Formatted ABI string (for crash reporting). */
public final String abiString;
/** Truncated version of Build.FINGERPRINT (for crash reporting). */
public final String androidBuildFingerprint;
/** A string that is different each time the apk changes. */
public final String extractedFileSuffix;
private static class Holder { private static BuildInfo sInstance = new BuildInfo(); }
@SuppressWarnings("deprecation")
@CalledByNative @CalledByNative
public static String[] getAll() { private static String[] getAll() {
try { BuildInfo buildInfo = getInstance();
String packageName = ContextUtils.getApplicationContext().getPackageName(); String hostPackageName = ContextUtils.getApplicationContext().getPackageName();
PackageManager pm = ContextUtils.getApplicationContext().getPackageManager();
PackageInfo pi = pm.getPackageInfo(packageName, 0);
String versionCode = pi.versionCode <= 0 ? "" : Integer.toString(pi.versionCode);
String versionName = pi.versionName == null ? "" : pi.versionName;
CharSequence label = pm.getApplicationLabel(pi.applicationInfo);
String packageLabel = label == null ? "" : label.toString();
String installerPackageName = pm.getInstallerPackageName(packageName);
if (installerPackageName == null) {
installerPackageName = "";
}
String abiString = null;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
abiString = TextUtils.join(", ", Build.SUPPORTED_ABIS);
} else {
abiString = "ABI1: " + Build.CPU_ABI + ", ABI2: " + Build.CPU_ABI2;
}
// Use lastUpdateTime when developing locally, since versionCode does not normally
// change in this case.
long version = pi.versionCode > 10 ? pi.versionCode : pi.lastUpdateTime;
String extractedFileSuffix = String.format("@%s", Long.toHexString(version));
// Do not alter this list without updating callers of it.
return new String[] { return new String[] {
Build.BRAND, Build.DEVICE, Build.ID, Build.MANUFACTURER, Build.MODEL, Build.BRAND, Build.DEVICE, Build.ID, Build.MANUFACTURER, Build.MODEL,
String.valueOf(Build.VERSION.SDK_INT), Build.TYPE, packageLabel, packageName, String.valueOf(Build.VERSION.SDK_INT), Build.TYPE, hostPackageName,
versionCode, versionName, getAndroidBuildFingerprint(), getGMSVersionCode(pm), String.valueOf(buildInfo.hostVersionCode), buildInfo.hostPackageLabel,
installerPackageName, abiString, BuildConfig.FIREBASE_APP_ID, buildInfo.packageName, String.valueOf(buildInfo.versionCode), buildInfo.versionName,
extractedFileSuffix, buildInfo.androidBuildFingerprint, buildInfo.gmsVersionCode,
buildInfo.installerPackageName, buildInfo.abiString, BuildConfig.FIREBASE_APP_ID,
buildInfo.extractedFileSuffix,
}; };
} catch (NameNotFoundException e) {
throw new RuntimeException(e);
}
} }
/** /**
* @return The build fingerprint for the current Android install. The value is truncated to a * @param packageInfo Package for Chrome/WebView (as opposed to host app).
* 128 characters as this is used for crash and UMA reporting, which should avoid huge
* strings.
*/ */
private static String getAndroidBuildFingerprint() { public static void setBrowserPackageInfo(PackageInfo packageInfo) {
return Build.FINGERPRINT.substring( assert !sInitialized;
0, Math.min(Build.FINGERPRINT.length(), MAX_FINGERPRINT_LENGTH)); sBrowserPackageInfo = packageInfo;
} }
private static String getGMSVersionCode(PackageManager packageManager) { public static BuildInfo getInstance() {
String msg = "gms versionCode not available."; return Holder.sInstance;
try {
PackageInfo packageInfo = packageManager.getPackageInfo("com.google.android.gms", 0);
msg = Integer.toString(packageInfo.versionCode);
} catch (NameNotFoundException e) {
Log.d(TAG, "GMS package is not found.", e);
}
return msg;
} }
public static String getPackageVersionCode() { private BuildInfo() {
return getAll()[9]; sInitialized = true;
try {
Context appContext = ContextUtils.getApplicationContext();
String hostPackageName = appContext.getPackageName();
PackageManager pm = appContext.getPackageManager();
PackageInfo pi = pm.getPackageInfo(hostPackageName, 0);
hostVersionCode = pi.versionCode;
if (sBrowserPackageInfo != null) {
packageName = sBrowserPackageInfo.packageName;
versionCode = sBrowserPackageInfo.versionCode;
versionName = sBrowserPackageInfo.versionName;
sBrowserPackageInfo = null;
} else {
packageName = hostPackageName;
versionCode = hostVersionCode;
versionName = pi.versionName;
} }
public static String getPackageVersionName() { CharSequence label = pm.getApplicationLabel(pi.applicationInfo);
return getAll()[10]; hostPackageLabel = label == null ? "" : label.toString();
}
String value = pm.getInstallerPackageName(packageName);
installerPackageName = value == null ? "" : value;
/** Returns a string that is different each time the apk changes. */ PackageInfo gmsPackageInfo = null;
public static String getExtractedFileSuffix() { try {
return getAll()[16]; gmsPackageInfo = pm.getPackageInfo("com.google.android.gms", 0);
} catch (NameNotFoundException e) {
Log.d(TAG, "GMS package is not found.", e);
} }
gmsVersionCode = gmsPackageInfo != null ? String.valueOf(gmsPackageInfo.versionCode)
: "gms versionCode not available.";
public static String getPackageLabel() { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
return getAll()[7]; abiString = TextUtils.join(", ", Build.SUPPORTED_ABIS);
} else {
abiString = String.format("ABI1: %s, ABI2: %s", Build.CPU_ABI, Build.CPU_ABI2);
} }
public static String getPackageName() { // Use lastUpdateTime when developing locally, since versionCode does not normally
return ContextUtils.getApplicationContext().getPackageName(); // change in this case.
long version = versionCode > 10 ? versionCode : pi.lastUpdateTime;
extractedFileSuffix = String.format("@%x", version);
// The value is truncated, as this is used for crash and UMA reporting.
androidBuildFingerprint = Build.FINGERPRINT.substring(
0, Math.min(Build.FINGERPRINT.length(), MAX_FINGERPRINT_LENGTH));
} catch (NameNotFoundException e) {
throw new RuntimeException(e);
}
} }
/** /**
......
...@@ -64,7 +64,7 @@ public class ResourceExtractor { ...@@ -64,7 +64,7 @@ public class ResourceExtractor {
// Use a suffix for extracted files in order to guarantee that the version of the file // Use a suffix for extracted files in order to guarantee that the version of the file
// on disk matches up with the version of the APK. // on disk matches up with the version of the APK.
String extractSuffix = BuildInfo.getExtractedFileSuffix(); String extractSuffix = BuildInfo.getInstance().extractedFileSuffix;
String[] existingFileNames = outputDir.list(); String[] existingFileNames = outputDir.list();
boolean allFilesExist = existingFileNames != null; boolean allFilesExist = existingFileNames != null;
if (allFilesExist) { if (allFilesExist) {
......
...@@ -92,8 +92,8 @@ public final class DefaultBrowserInfo { ...@@ -92,8 +92,8 @@ public final class DefaultBrowserInfo {
Context context = ContextUtils.getApplicationContext(); Context context = ContextUtils.getApplicationContext();
ArrayList<String> menuTitles = new ArrayList<String>(2); ArrayList<String> menuTitles = new ArrayList<String>(2);
// Store the package label of current application. // Store the package label of current application.
menuTitles.add( menuTitles.add(getTitleFromPackageLabel(
getTitleFromPackageLabel(context, BuildInfo.getPackageLabel())); context, BuildInfo.getInstance().hostPackageLabel));
PackageManager pm = context.getPackageManager(); PackageManager pm = context.getPackageManager();
ResolveInfo info = getResolveInfoForViewIntent(pm); ResolveInfo info = getResolveInfoForViewIntent(pm);
......
...@@ -95,7 +95,7 @@ public class BookmarkUtils { ...@@ -95,7 +95,7 @@ public class BookmarkUtils {
createSnackbarControllerForEditButton(activity, bookmarkId); createSnackbarControllerForEditButton(activity, bookmarkId);
if (getLastUsedParent(activity) == null) { if (getLastUsedParent(activity) == null) {
if (fromCustomTab) { if (fromCustomTab) {
String packageLabel = BuildInfo.getPackageLabel(); String packageLabel = BuildInfo.getInstance().hostPackageLabel;
snackbar = Snackbar.make( snackbar = Snackbar.make(
activity.getString(R.string.bookmark_page_saved, packageLabel), activity.getString(R.string.bookmark_page_saved, packageLabel),
snackbarController, Snackbar.TYPE_ACTION, Snackbar.UMA_BOOKMARK_ADDED); snackbarController, Snackbar.TYPE_ACTION, Snackbar.UMA_BOOKMARK_ADDED);
......
...@@ -7,6 +7,7 @@ package org.chromium.chrome.browser.crash; ...@@ -7,6 +7,7 @@ package org.chromium.chrome.browser.crash;
import android.app.ActivityManager; import android.app.ActivityManager;
import android.app.ActivityManager.RunningAppProcessInfo; import android.app.ActivityManager.RunningAppProcessInfo;
import android.content.Context; import android.content.Context;
import android.os.Build;
import android.util.Log; import android.util.Log;
import org.chromium.base.ApiCompatibilityUtils; import org.chromium.base.ApiCompatibilityUtils;
...@@ -116,24 +117,24 @@ public class PureJavaExceptionReporter { ...@@ -116,24 +117,24 @@ public class PureJavaExceptionReporter {
processName = "browser"; processName = "browser";
} }
String[] allInfo = BuildInfo.getAll(); BuildInfo buildInfo = BuildInfo.getInstance();
addPairedString(PRODUCT, "Chrome_Android"); addPairedString(PRODUCT, "Chrome_Android");
addPairedString(PROCESS_TYPE, processName); addPairedString(PROCESS_TYPE, processName);
addPairedString(DEVICE, allInfo[BuildInfo.DEVICE_INDEX]); addPairedString(DEVICE, Build.DEVICE);
addPairedString(VERSION, ChromeVersionInfo.getProductVersion()); addPairedString(VERSION, ChromeVersionInfo.getProductVersion());
addPairedString(CHANNEL, getChannel()); addPairedString(CHANNEL, getChannel());
addPairedString(ANDROID_BUILD_ID, allInfo[BuildInfo.ANDROID_BUILD_ID_INDEX]); addPairedString(ANDROID_BUILD_ID, Build.ID);
addPairedString(MODEL, allInfo[BuildInfo.MODEL_INDEX]); addPairedString(MODEL, Build.MODEL);
addPairedString(BRAND, allInfo[BuildInfo.BRAND_INDEX]); addPairedString(BRAND, Build.BRAND);
addPairedString(ANDROID_BUILD_FP, allInfo[BuildInfo.ANDROID_BUILD_FP_INDEX]); addPairedString(ANDROID_BUILD_FP, buildInfo.androidBuildFingerprint);
addPairedString(GMS_CORE_VERSION, allInfo[BuildInfo.GMS_CORE_VERSION_INDEX]); addPairedString(GMS_CORE_VERSION, buildInfo.gmsVersionCode);
addPairedString(INSTALLER_PACKAGE_NAME, allInfo[BuildInfo.INSTALLER_PACKAGE_NAME_INDEX]); addPairedString(INSTALLER_PACKAGE_NAME, buildInfo.installerPackageName);
addPairedString(ABI_NAME, allInfo[BuildInfo.ABI_NAME_INDEX]); addPairedString(ABI_NAME, buildInfo.abiString);
addPairedString(EXCEPTION_INFO, Log.getStackTraceString(javaException)); addPairedString(EXCEPTION_INFO, Log.getStackTraceString(javaException));
addPairedString(EARLY_JAVA_EXCEPTION, "true"); addPairedString(EARLY_JAVA_EXCEPTION, "true");
addPairedString(PACKAGE, addPairedString(PACKAGE,
BuildConfig.FIREBASE_APP_ID + " v" + BuildInfo.getPackageVersionCode() + " (" String.format("%s v%s (%s)", BuildConfig.FIREBASE_APP_ID, buildInfo.versionCode,
+ BuildInfo.getPackageVersionName() + ")"); buildInfo.versionName));
addString(mBoundary); addString(mBoundary);
} }
......
...@@ -94,7 +94,7 @@ public class DownloadSnackbarController implements SnackbarManager.SnackbarContr ...@@ -94,7 +94,7 @@ public class DownloadSnackbarController implements SnackbarManager.SnackbarContr
if (getSnackbarManager() == null) return; if (getSnackbarManager() == null) return;
Snackbar snackbar; Snackbar snackbar;
if (getActivity() instanceof CustomTabActivity) { if (getActivity() instanceof CustomTabActivity) {
String packageLabel = BuildInfo.getPackageLabel(); String packageLabel = BuildInfo.getInstance().hostPackageLabel;
snackbar = Snackbar.make(mContext.getString(R.string.download_succeeded_message, snackbar = Snackbar.make(mContext.getString(R.string.download_succeeded_message,
downloadInfo.getFileName(), packageLabel), downloadInfo.getFileName(), packageLabel),
this, Snackbar.TYPE_NOTIFICATION, Snackbar.UMA_DOWNLOAD_SUCCEEDED); this, Snackbar.TYPE_NOTIFICATION, Snackbar.UMA_DOWNLOAD_SUCCEEDED);
......
...@@ -180,7 +180,8 @@ public abstract class RequestGenerator { ...@@ -180,7 +180,8 @@ public abstract class RequestGenerator {
* these strings when building their own custom Android ROMs. * these strings when building their own custom Android ROMs.
*/ */
public String getAdditionalParameters() { public String getAdditionalParameters() {
String applicationLabel = StringSanitizer.sanitize(BuildInfo.getPackageLabel()); String applicationLabel =
StringSanitizer.sanitize(BuildInfo.getInstance().hostPackageLabel);
String brand = StringSanitizer.sanitize(Build.BRAND); String brand = StringSanitizer.sanitize(Build.BRAND);
String model = StringSanitizer.sanitize(Build.MODEL); String model = StringSanitizer.sanitize(Build.MODEL);
return applicationLabel + ";" + brand + ";" + model; return applicationLabel + ";" + brand + ";" + model;
......
...@@ -60,7 +60,7 @@ public class VersionNumberGetter { ...@@ -60,7 +60,7 @@ public class VersionNumberGetter {
* @return The latest version if we retrieved one from the Omaha server, or "" if we haven't. * @return The latest version if we retrieved one from the Omaha server, or "" if we haven't.
*/ */
public String getCurrentlyUsedVersion(Context context) { public String getCurrentlyUsedVersion(Context context) {
return BuildInfo.getPackageVersionName(); return BuildInfo.getInstance().versionName;
} }
/** /**
......
...@@ -12,7 +12,7 @@ import android.preference.Preference; ...@@ -12,7 +12,7 @@ import android.preference.Preference;
import android.preference.PreferenceFragment; import android.preference.PreferenceFragment;
import android.provider.Settings; import android.provider.Settings;
import org.chromium.base.BuildInfo; import org.chromium.base.ContextUtils;
import org.chromium.base.VisibleForTesting; import org.chromium.base.VisibleForTesting;
import org.chromium.chrome.R; import org.chromium.chrome.R;
import org.chromium.chrome.browser.ChromeFeatureList; import org.chromium.chrome.browser.ChromeFeatureList;
...@@ -103,7 +103,8 @@ public class MainPreferences extends PreferenceFragment ...@@ -103,7 +103,8 @@ public class MainPreferences extends PreferenceFragment
notifications.setOnPreferenceClickListener(preference -> { notifications.setOnPreferenceClickListener(preference -> {
Intent intent = new Intent(); Intent intent = new Intent();
intent.setAction(Settings.ACTION_APP_NOTIFICATION_SETTINGS); intent.setAction(Settings.ACTION_APP_NOTIFICATION_SETTINGS);
intent.putExtra(Settings.EXTRA_APP_PACKAGE, BuildInfo.getPackageName()); intent.putExtra(Settings.EXTRA_APP_PACKAGE,
ContextUtils.getApplicationContext().getPackageName());
startActivity(intent); startActivity(intent);
// We handle the click so the default action (opening NotificationsPreference) // We handle the click so the default action (opening NotificationsPreference)
// isn't triggered. // isn't triggered.
......
...@@ -101,7 +101,8 @@ public class SyncPreference extends Preference { ...@@ -101,7 +101,8 @@ public class SyncPreference extends Preference {
if (profileSyncService.getProtocolErrorClientAction() if (profileSyncService.getProtocolErrorClientAction()
== ProtocolErrorClientAction.UPGRADE_CLIENT) { == ProtocolErrorClientAction.UPGRADE_CLIENT) {
return res.getString(R.string.sync_error_upgrade_client, BuildInfo.getPackageLabel()); return res.getString(
R.string.sync_error_upgrade_client, BuildInfo.getInstance().hostPackageLabel);
} }
if (profileSyncService.hasUnrecoverableError()) { if (profileSyncService.hasUnrecoverableError()) {
......
...@@ -30,7 +30,7 @@ import android.widget.TextView; ...@@ -30,7 +30,7 @@ import android.widget.TextView;
import android.widget.TextView.OnEditorActionListener; import android.widget.TextView.OnEditorActionListener;
import org.chromium.base.ApiCompatibilityUtils; import org.chromium.base.ApiCompatibilityUtils;
import org.chromium.base.BuildInfo; import org.chromium.base.ContextUtils;
import org.chromium.base.Log; import org.chromium.base.Log;
import org.chromium.base.metrics.RecordHistogram; import org.chromium.base.metrics.RecordHistogram;
import org.chromium.chrome.R; import org.chromium.chrome.R;
...@@ -202,7 +202,7 @@ public class PassphraseDialogFragment extends DialogFragment implements OnClickL ...@@ -202,7 +202,7 @@ public class PassphraseDialogFragment extends DialogFragment implements OnClickL
recordPassphraseDialogDismissal(PASSPHRASE_DIALOG_RESET_LINK); recordPassphraseDialogDismissal(PASSPHRASE_DIALOG_RESET_LINK);
Uri syncDashboardUrl = Uri.parse(ChromeStringConstants.SYNC_DASHBOARD_URL); Uri syncDashboardUrl = Uri.parse(ChromeStringConstants.SYNC_DASHBOARD_URL);
Intent intent = new Intent(Intent.ACTION_VIEW, syncDashboardUrl); Intent intent = new Intent(Intent.ACTION_VIEW, syncDashboardUrl);
intent.setPackage(BuildInfo.getPackageName()); intent.setPackage(ContextUtils.getApplicationContext().getPackageName());
IntentUtils.safePutBinderExtra( IntentUtils.safePutBinderExtra(
intent, CustomTabsIntent.EXTRA_SESSION, null); intent, CustomTabsIntent.EXTRA_SESSION, null);
context.startActivity(intent); context.startActivity(intent);
......
...@@ -26,7 +26,7 @@ import android.widget.CheckedTextView; ...@@ -26,7 +26,7 @@ import android.widget.CheckedTextView;
import android.widget.ListView; import android.widget.ListView;
import android.widget.TextView; import android.widget.TextView;
import org.chromium.base.BuildInfo; import org.chromium.base.ContextUtils;
import org.chromium.base.VisibleForTesting; import org.chromium.base.VisibleForTesting;
import org.chromium.chrome.R; import org.chromium.chrome.R;
import org.chromium.chrome.browser.ChromeStringConstants; import org.chromium.chrome.browser.ChromeStringConstants;
...@@ -195,7 +195,7 @@ public class PassphraseTypeDialogFragment extends DialogFragment implements ...@@ -195,7 +195,7 @@ public class PassphraseTypeDialogFragment extends DialogFragment implements
public void onClick(View view) { public void onClick(View view) {
Uri syncDashboardUrl = Uri.parse(ChromeStringConstants.SYNC_DASHBOARD_URL); Uri syncDashboardUrl = Uri.parse(ChromeStringConstants.SYNC_DASHBOARD_URL);
Intent intent = new Intent(Intent.ACTION_VIEW, syncDashboardUrl); Intent intent = new Intent(Intent.ACTION_VIEW, syncDashboardUrl);
intent.setPackage(BuildInfo.getPackageName()); intent.setPackage(ContextUtils.getApplicationContext().getPackageName());
IntentUtils.safePutBinderExtra( IntentUtils.safePutBinderExtra(
intent, CustomTabsIntent.EXTRA_SESSION, null); intent, CustomTabsIntent.EXTRA_SESSION, null);
context.startActivity(intent); context.startActivity(intent);
......
...@@ -31,6 +31,7 @@ import android.view.ViewGroup; ...@@ -31,6 +31,7 @@ import android.view.ViewGroup;
import org.chromium.base.ApiCompatibilityUtils; import org.chromium.base.ApiCompatibilityUtils;
import org.chromium.base.BuildInfo; import org.chromium.base.BuildInfo;
import org.chromium.base.ContextUtils;
import org.chromium.base.VisibleForTesting; import org.chromium.base.VisibleForTesting;
import org.chromium.base.metrics.RecordHistogram; import org.chromium.base.metrics.RecordHistogram;
import org.chromium.chrome.R; import org.chromium.chrome.R;
...@@ -679,7 +680,8 @@ public class SyncCustomizationFragment extends PreferenceFragment ...@@ -679,7 +680,8 @@ public class SyncCustomizationFragment extends PreferenceFragment
case SYNC_AUTH_ERROR: case SYNC_AUTH_ERROR:
return res.getString(R.string.hint_sync_auth_error); return res.getString(R.string.hint_sync_auth_error);
case SYNC_CLIENT_OUT_OF_DATE: case SYNC_CLIENT_OUT_OF_DATE:
return res.getString(R.string.hint_client_out_of_date, BuildInfo.getPackageLabel()); return res.getString(
R.string.hint_client_out_of_date, BuildInfo.getInstance().hostPackageLabel);
case SYNC_OTHER_ERRORS: case SYNC_OTHER_ERRORS:
return res.getString(R.string.hint_other_sync_errors); return res.getString(R.string.hint_other_sync_errors);
case SYNC_PASSPHRASE_REQUIRED: case SYNC_PASSPHRASE_REQUIRED:
...@@ -716,7 +718,8 @@ public class SyncCustomizationFragment extends PreferenceFragment ...@@ -716,7 +718,8 @@ public class SyncCustomizationFragment extends PreferenceFragment
if (mCurrentSyncError == SYNC_CLIENT_OUT_OF_DATE) { if (mCurrentSyncError == SYNC_CLIENT_OUT_OF_DATE) {
// Opens the client in play store for update. // Opens the client in play store for update.
Intent intent = new Intent(Intent.ACTION_VIEW); Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse("market://details?id=" + BuildInfo.getPackageName())); intent.setData(Uri.parse("market://details?id="
+ ContextUtils.getApplicationContext().getPackageName()));
startActivity(intent); startActivity(intent);
return; return;
} }
......
...@@ -13,7 +13,7 @@ import org.junit.Rule; ...@@ -13,7 +13,7 @@ import org.junit.Rule;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.chromium.base.BuildInfo; import org.chromium.base.ContextUtils;
import org.chromium.base.test.util.CommandLineFlags; import org.chromium.base.test.util.CommandLineFlags;
import org.chromium.base.test.util.DisableIf; import org.chromium.base.test.util.DisableIf;
import org.chromium.base.test.util.Feature; import org.chromium.base.test.util.Feature;
...@@ -53,7 +53,7 @@ public class ProcessIsolationTest { ...@@ -53,7 +53,7 @@ public class ProcessIsolationTest {
// in the RunningAppProcessInfo for isolated processes is the same as the parent process // in the RunningAppProcessInfo for isolated processes is the same as the parent process
// (see b/7724486, closed as "Working as intended"). // (see b/7724486, closed as "Working as intended").
// So we have to resort to parsing the ps output. // So we have to resort to parsing the ps output.
String packageName = BuildInfo.getPackageName(); String packageName = ContextUtils.getApplicationContext().getPackageName();
Assert.assertFalse("Failed to retrieve package name for current version of Chrome.", Assert.assertFalse("Failed to retrieve package name for current version of Chrome.",
TextUtils.isEmpty(packageName)); TextUtils.isEmpty(packageName));
......
...@@ -989,7 +989,7 @@ static ScopedJavaLocalRef<jobject> JNI_PrefServiceBridge_GetAboutVersionStrings( ...@@ -989,7 +989,7 @@ static ScopedJavaLocalRef<jobject> JNI_PrefServiceBridge_GetAboutVersionStrings(
base::android::BuildInfo* android_build_info = base::android::BuildInfo* android_build_info =
base::android::BuildInfo::GetInstance(); base::android::BuildInfo::GetInstance();
std::string application(android_build_info->package_label()); std::string application(android_build_info->host_package_label());
application.append(" "); application.append(" ");
application.append(version_info::GetVersionNumber()); application.append(version_info::GetVersionNumber());
......
...@@ -551,8 +551,9 @@ void DevToolsHttpHandler::OnJsonRequest( ...@@ -551,8 +551,9 @@ void DevToolsHttpHandler::OnJsonRequest(
kTargetWebSocketDebuggerUrlField, kTargetWebSocketDebuggerUrlField,
base::StringPrintf("ws://%s%s", host.c_str(), browser_guid_.c_str())); base::StringPrintf("ws://%s%s", host.c_str(), browser_guid_.c_str()));
#if defined(OS_ANDROID) #if defined(OS_ANDROID)
version.SetString("Android-Package", version.SetString(
base::android::BuildInfo::GetInstance()->package_name()); "Android-Package",
base::android::BuildInfo::GetInstance()->host_package_name());
#endif #endif
SendJson(connection_id, net::HTTP_OK, &version, std::string()); SendJson(connection_id, net::HTTP_OK, &version, std::string());
return; return;
......
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