/** * The {@link DeviceClassManager} constructor should be self contained and rely on system * information and command line flags. */ private DeviceClassManager() { // Device based configurations. if (SysUtils.isLowEndDevice()) { mEnableSnapshots = false; mEnableLayerDecorationCache = true; mEnableAccessibilityLayout = true; mEnableAnimations = false; mEnablePrerendering = false; mEnableToolbarSwipe = false; mDisableDomainReliability = true; } else { mEnableSnapshots = true; mEnableLayerDecorationCache = true; mEnableAccessibilityLayout = false; mEnableAnimations = true; mEnablePrerendering = true; mEnableToolbarSwipe = true; mDisableDomainReliability = false; } if (DeviceFormFactor.isTablet(ApplicationStatus.getApplicationContext())) { mEnableAccessibilityLayout = false; } // Flag based configurations. CommandLine commandLine = CommandLine.getInstance(); mEnableAccessibilityLayout |= commandLine.hasSwitch(ChromeSwitches.ENABLE_ACCESSIBILITY_TAB_SWITCHER); mEnableFullscreen = !commandLine.hasSwitch(ChromeSwitches.DISABLE_FULLSCREEN); mEnableUndo = commandLine.hasSwitch(ChromeSwitches.ENABLE_HIGH_END_UI_UNDO); mEnableToolbarSwipeInDocumentMode = commandLine.hasSwitch(ChromeSwitches.ENABLE_TOOLBAR_SWIPE_IN_DOCUMENT_MODE); // Related features. if (mEnableAccessibilityLayout) { mEnableAnimations = false; } if (SysUtils.isLowEndDevice() || mEnableAccessibilityLayout) { mEnableUndo = true; } }
/** * Once native is loaded we can consult the command-line (set via about:flags) and also finch * state to see if we should enable WebAPKs. */ public static void cacheEnabledStateForNextLaunch() { boolean wasEnabled = isEnabledInPrefs(); CommandLine instance = CommandLine.getInstance(); String experiment = FieldTrialList.findFullName(WEBAPK_DISABLE_EXPERIMENT_NAME); boolean isEnabled = (!WEBAPK_RUNTIME_DISABLED.equals(experiment) && instance.hasSwitch(ChromeSwitches.ENABLE_WEBAPK)); if (isEnabled != wasEnabled) { Log.d(TAG, "WebApk setting changed (%s => %s)", wasEnabled, isEnabled); ChromePreferenceManager.getInstance(ContextUtils.getApplicationContext()) .setCachedWebApkRuntimeEnabled(isEnabled); } }
/** 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()); }