Commit d543ff67 authored by Clark DuVall's avatar Clark DuVall Committed by Commit Bot

Reland "Add synthetic field trial for isolated splits"

This is a reland of 86c3def7

Changed this to use a field on BuildConfig.java so it wouldn't change
the native lib.

Original change's description:
> Add synthetic field trial for isolated splits
>
> This should make analysis easier for a binary experiment, since the
> Finch dashboard can be used.
>
> Bug: 1150162
> Change-Id: Id90204398234938c441982d5c2bc5c6f7c63d575
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2545874
> Commit-Queue: Clark DuVall <cduvall@chromium.org>
> Reviewed-by: Yaron Friedman <yfriedman@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#829494}

Bug: 1150162
Change-Id: I9447c7f5e1303f036545287738028443c67551d4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2554032Reviewed-by: default avatarYaron Friedman <yfriedman@chromium.org>
Reviewed-by: default avatarPeter Wen <wnwen@chromium.org>
Commit-Queue: Clark DuVall <cduvall@chromium.org>
Cr-Commit-Position: refs/heads/master@{#830242}
parent 7887eba0
......@@ -66,8 +66,12 @@ std::string BundleUtils::ResolveLibraryPath(const std::string& library_name,
// static
bool BundleUtils::IsBundle() {
return Java_BundleUtils_isBundleForNative(
base::android::AttachCurrentThread());
return Java_BundleUtils_isBundleForNative(AttachCurrentThread());
}
// static
bool BundleUtils::IsolatedSplitsEnabled() {
return Java_BundleUtils_isolatedSplitsEnabled(AttachCurrentThread());
}
// static
......
......@@ -18,6 +18,9 @@ class BASE_EXPORT BundleUtils {
// Returns true if the current build is a bundle.
static bool IsBundle();
// Returns true if isolated splits are enabled.
static bool IsolatedSplitsEnabled();
// Helper function asking Java to resolve a library path. This is required for
// resolving a module library made available via SplitCompat, rather than in
// its eventual fully-installed state.
......
......@@ -65,6 +65,11 @@ public final class BundleUtils {
sIsBundle = isBundle;
}
@CalledByNative
public static boolean isolatedSplitsEnabled() {
return BuildConfig.ISOLATED_SPLITS_ENABLED;
}
/**
* Returns whether splitName is installed. Note, this will return false on Android versions
* below O, where isolated splits are not supported.
......
......@@ -86,4 +86,10 @@ public class BuildConfig {
#else
public static MAYBE_FINAL boolean IS_CHROMECAST_BRANDING_INTERNAL MAYBE_FALSE;
#endif
#if defined(_ISOLATED_SPLITS_ENABLED)
public static MAYBE_FINAL boolean ISOLATED_SPLITS_ENABLED = true;
#else
public static MAYBE_FINAL boolean ISOLATED_SPLITS_ENABLED MAYBE_FALSE;
#endif
}
......@@ -1935,6 +1935,7 @@ if (enable_java_templates) {
# bundles_supported: Whether or not this target can be treated as a bundle.
# resources_version_variable:
# is_incremental_install:
# isolated_splits_enabled: Value for ISOLATED_SPLITS_ENABLED.
template("generate_build_config_srcjar") {
java_cpp_template(target_name) {
sources = [ "//base/android/java/templates/BuildConfig.template" ]
......@@ -1961,6 +1962,11 @@ if (enable_java_templates) {
defines += [ "_BUNDLES_SUPPORTED" ]
}
if (defined(invoker.isolated_splits_enabled) &&
invoker.isolated_splits_enabled) {
defines += [ "_ISOLATED_SPLITS_ENABLED" ]
}
if (defined(invoker.is_incremental_install) &&
invoker.is_incremental_install) {
defines += [ "_IS_INCREMENTAL_INSTALL" ]
......@@ -2702,7 +2708,11 @@ if (enable_java_templates) {
if (_generate_buildconfig_java) {
generate_build_config_srcjar("${_template_name}__build_config_srcjar") {
forward_variables_from(invoker, [ "min_sdk_version" ])
forward_variables_from(invoker,
[
"min_sdk_version",
"isolated_splits_enabled",
])
_bundles_supported = _is_bundle_module || _is_static_library_provider
if (defined(invoker.bundles_supported)) {
_bundles_supported = invoker.bundles_supported
......@@ -3628,6 +3638,7 @@ if (enable_java_templates) {
"generate_buildconfig_java",
"generate_final_jni",
"input_jars_paths",
"isolated_splits_enabled",
"is_base_module",
"jacoco_never_instrument",
"jar_excluded_patterns",
......
......@@ -528,6 +528,9 @@ template("monochrome_public_common_apk_or_module_tmpl") {
# Add all loadable modules and shared libraries from DFMs.
if (_enable_chrome_module) {
# Sets ISOLATED_SPLITS_ENABLED in BuildConfig.java.
isolated_splits_enabled = true
# The arcore manifest needs to be merged into the base module because the Play
# Store verifies the com.google.ar.core.min_apk_version meta-data tag is in
# the base manifest.
......@@ -790,6 +793,7 @@ template("monochrome_public_common_apk_or_module_tmpl") {
"deps",
"is_monochrome",
"is_trichrome",
"isolated_splits_enabled",
"loadable_modules",
"native_lib_placeholders",
"negative_main_dex_globs",
......
......@@ -26,6 +26,8 @@
#include "components/version_info/version_info.h"
#if defined(OS_ANDROID)
#include "base/android/build_info.h"
#include "base/android/bundle_utils.h"
#include "chrome/browser/chrome_browser_field_trials_mobile.h"
#include "chrome/browser/flags/android/cached_feature_flags.h"
#include "chrome/common/chrome_features.h"
......@@ -133,6 +135,18 @@ void ChromeBrowserFieldTrials::RegisterSyntheticTrials() {
static constexpr char kEarlyLibraryLoadTrial[] = "EarlyLibraryLoadSynthetic";
ChromeMetricsServiceAccessor::RegisterSyntheticFieldTrial(
kEarlyLibraryLoadTrial, group_name);
// If isolated splits are enabled at build time, Monochrome and Trichrome will
// have a different bundle layout, so measure N+ even though isolated splits
// are only supported by Android in O+.
if (base::android::BuildInfo::GetInstance()->sdk_int() >=
base::android::SDK_VERSION_NOUGAT) {
static constexpr char kIsolatedSplitsTrial[] = "IsolatedSplitsSynthetic";
ChromeMetricsServiceAccessor::RegisterSyntheticFieldTrial(
kIsolatedSplitsTrial,
base::android::BundleUtils::IsolatedSplitsEnabled() ? "Enabled"
: "Disabled");
}
#endif // defined(OS_ANDROID)
}
......
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