Search in sources :

Example 6 with CommandLine

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());
}
Also used : StrictMode(android.os.StrictMode) CommandLine(org.chromium.base.CommandLine) UiThread(android.support.annotation.UiThread) SuppressFBWarnings(org.chromium.base.annotations.SuppressFBWarnings)

Example 7 with CommandLine

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());
}
Also used : CommandLine(org.chromium.base.CommandLine) TypedValue(android.util.TypedValue)

Example 8 with CommandLine

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);
    }
}
Also used : Context(android.content.Context) CommandLine(org.chromium.base.CommandLine)

Aggregations

CommandLine (org.chromium.base.CommandLine)8 Context (android.content.Context)2 SuppressLint (android.annotation.SuppressLint)1 StrictMode (android.os.StrictMode)1 UiThread (android.support.annotation.UiThread)1 TypedValue (android.util.TypedValue)1 View (android.view.View)1 OnClickListener (android.view.View.OnClickListener)1 FrameLayout (android.widget.FrameLayout)1 SuppressFBWarnings (org.chromium.base.annotations.SuppressFBWarnings)1 CompositorViewHolder (org.chromium.chrome.browser.compositor.CompositorViewHolder)1 LayoutManagerChromePhone (org.chromium.chrome.browser.compositor.layouts.LayoutManagerChromePhone)1 LayoutManagerChromeTablet (org.chromium.chrome.browser.compositor.layouts.LayoutManagerChromeTablet)1 EmptyBackgroundViewWrapper (org.chromium.chrome.browser.widget.emptybackground.EmptyBackgroundViewWrapper)1 FindToolbarManager (org.chromium.chrome.browser.widget.findinpage.FindToolbarManager)1 ContentVideoView (org.chromium.content.browser.ContentVideoView)1