Search in sources :

Example 46 with UiThread

use of android.support.annotation.UiThread 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)

Aggregations

UiThread (android.support.annotation.UiThread)46 View (android.view.View)9 ObjectAnimator (android.animation.ObjectAnimator)6 Animator (android.animation.Animator)5 ImageView (android.widget.ImageView)5 TextView (android.widget.TextView)5 ArrayList (java.util.ArrayList)5 Intent (android.content.Intent)4 Drawable (android.graphics.drawable.Drawable)4 Fragment (android.support.v4.app.Fragment)4 MenuItem (android.view.MenuItem)4 ViewPropertyAnimator (android.view.ViewPropertyAnimator)4 Paint (android.graphics.Paint)3 Rect (android.graphics.Rect)3 DialogFragment (android.support.v4.app.DialogFragment)3 AnimatorListenerAdapter (android.animation.AnimatorListenerAdapter)2 Location (android.location.Location)2 Bundle (android.os.Bundle)2 AlertDialog (android.support.v7.app.AlertDialog)2 RecyclerView (android.support.v7.widget.RecyclerView)2