use of org.chromium.base.CommandLine in project AndroidChromium by JackyAndroid.
the class ChromeStrictMode method configureStrictMode.
/**
* Turn on StrictMode detection based on build and command-line switches.
*/
@UiThread
// FindBugs doesn't like conditionals with compile time results
@SuppressFBWarnings("UCF_USELESS_CONTROL_FLOW")
public static void configureStrictMode() {
assert ThreadUtils.runningOnUiThread();
if (sIsStrictModeAlreadyConfigured) {
return;
}
sIsStrictModeAlreadyConfigured = true;
StrictMode.ThreadPolicy.Builder threadPolicy = new StrictMode.ThreadPolicy.Builder(StrictMode.getThreadPolicy());
StrictMode.VmPolicy.Builder vmPolicy = new StrictMode.VmPolicy.Builder(StrictMode.getVmPolicy());
CommandLine commandLine = CommandLine.getInstance();
if ("eng".equals(Build.TYPE) || BuildConfig.DCHECK_IS_ON || ChromeVersionInfo.isLocalBuild() || commandLine.hasSwitch(ChromeSwitches.STRICT_MODE)) {
turnOnDetection(threadPolicy, vmPolicy);
addDefaultPenalties(threadPolicy, vmPolicy);
if ("death".equals(commandLine.getSwitchValue(ChromeSwitches.STRICT_MODE))) {
addThreadDeathPenalty(threadPolicy);
addVmDeathPenalty(vmPolicy);
} else if ("testing".equals(commandLine.getSwitchValue(ChromeSwitches.STRICT_MODE))) {
addThreadDeathPenalty(threadPolicy);
// Currently VmDeathPolicy kills the process, and is not visible on bot test output.
}
}
// Enroll 1% of dev sessions into StrictMode watch. This is done client-side rather than
// through finch because this decision is as early as possible in the browser initialization
// process. We need to detect early start-up StrictMode violations before loading native and
// before warming the SharedPreferences (that is a violation in an of itself). We will
// closely monitor this on dev channel.
boolean enableStrictModeWatch = (ChromeVersionInfo.isDevBuild() && Math.random() < UPLOAD_PROBABILITY);
if ((ChromeVersionInfo.isLocalBuild() && !BuildConfig.DCHECK_IS_ON) || enableStrictModeWatch) {
turnOnDetection(threadPolicy, vmPolicy);
initializeStrictModeWatch();
}
StrictMode.setThreadPolicy(threadPolicy.build());
StrictMode.setVmPolicy(vmPolicy.build());
}
use of org.chromium.base.CommandLine in project AndroidChromium by JackyAndroid.
the class ApplicationInitialization method enableFullscreenFlags.
/**
* Enable fullscreen related startup flags.
* @param resources Resources to use while calculating initialization constants.
* @param resControlContainerHeight The resource id for the height of the top controls.
*/
public static void enableFullscreenFlags(Resources resources, Context context, int resControlContainerHeight) {
ContentApplication.initCommandLine(context);
CommandLine commandLine = CommandLine.getInstance();
if (commandLine.hasSwitch(ChromeSwitches.DISABLE_FULLSCREEN))
return;
TypedValue threshold = new TypedValue();
resources.getValue(R.dimen.top_controls_show_threshold, threshold, true);
commandLine.appendSwitchWithValue(ContentSwitches.TOP_CONTROLS_SHOW_THRESHOLD, threshold.coerceToString().toString());
resources.getValue(R.dimen.top_controls_hide_threshold, threshold, true);
commandLine.appendSwitchWithValue(ContentSwitches.TOP_CONTROLS_HIDE_THRESHOLD, threshold.coerceToString().toString());
}
use of org.chromium.base.CommandLine in project AndroidChromium by JackyAndroid.
the class InstantAppsHandler method cacheInstantAppsEnabled.
/**
* Cache whether the Instant Apps feature is enabled.
* This should only be called with the native library loaded.
*/
public void cacheInstantAppsEnabled() {
Context context = ContextUtils.getApplicationContext();
boolean isEnabled = false;
boolean wasEnabled = isEnabled(context);
CommandLine instance = CommandLine.getInstance();
if (instance.hasSwitch(ChromeSwitches.DISABLE_APP_LINK)) {
isEnabled = false;
} else if (instance.hasSwitch(ChromeSwitches.ENABLE_APP_LINK)) {
isEnabled = true;
} else {
String experiment = FieldTrialList.findFullName(INSTANT_APPS_EXPERIMENT_NAME);
if (INSTANT_APPS_DISABLED_ARM.equals(experiment)) {
isEnabled = false;
} else if (INSTANT_APPS_ENABLED_ARM.equals(experiment)) {
isEnabled = true;
}
}
if (isEnabled != wasEnabled) {
ChromePreferenceManager.getInstance(context).setCachedInstantAppsEnabled(isEnabled);
}
}
Aggregations