本文整理汇总了Java中org.chromium.base.SysUtils类的典型用法代码示例。如果您正苦于以下问题:Java SysUtils类的具体用法?Java SysUtils怎么用?Java SysUtils使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
SysUtils类属于org.chromium.base包,在下文中一共展示了SysUtils类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: detectEnabled
import org.chromium.base.SysUtils; //导入依赖的package包/类
private static boolean detectEnabled() {
if (SysUtils.isLowEndDevice()) {
return false;
}
// Allow this user-flippable flag to disable the feature.
if (CommandLine.getInstance().hasSwitch(ChromeSwitches.DISABLE_CONTEXTUAL_SEARCH)) {
return false;
}
// Allow this user-flippable flag to enable the feature.
if (CommandLine.getInstance().hasSwitch(ChromeSwitches.ENABLE_CONTEXTUAL_SEARCH)) {
return true;
}
// Allow disabling the feature remotely.
if (getBooleanParam(DISABLED_PARAM)) {
return false;
}
return true;
}
示例2: shouldDisableHardwareAcceleration
import org.chromium.base.SysUtils; //导入依赖的package包/类
private boolean shouldDisableHardwareAcceleration() {
// Low end devices should disable hardware acceleration for memory gains.
if (SysUtils.isLowEndDevice()) return true;
// Turning off hardware acceleration reduces crash rates. See http://crbug.com/651918
// GT-S7580 on JDQ39 accounts for 42% of crashes in libPowerStretch.so on dev and beta.
if (Build.VERSION.SDK_INT == Build.VERSION_CODES.JELLY_BEAN_MR1
&& Build.MODEL.equals("GT-S7580")) {
return true;
}
// SM-N9005 on JSS15J accounts for 44% of crashes in libPowerStretch.so on stable channel.
if (Build.VERSION.SDK_INT == Build.VERSION_CODES.JELLY_BEAN_MR2
&& Build.MODEL.equals("SM-N9005")) {
return true;
}
return false;
}
示例3: startModerateBindingManagementIfNeeded
import org.chromium.base.SysUtils; //导入依赖的package包/类
private static void startModerateBindingManagementIfNeeded(Context context) {
// Ensures that a low memory device isn't included in the field trial experimental.
if (SysUtils.isLowEndDevice()) return;
String enabledValue = getModerateBindingConfigValue(MODERATE_BINDING_ENABLED_PARAM);
if (!Boolean.parseBoolean(enabledValue)) return;
String lowReduceRatioValue =
getModerateBindingConfigValue(MODERATE_BINDING_LOW_REDUCE_RATIO_PARAM);
String highReduceRatioValue =
getModerateBindingConfigValue(MODERATE_BINDING_HIGH_REDUCE_RATIO_PARAM);
float lowReduceRatio =
parseFloat(lowReduceRatioValue, DEFAULT_MODERATE_BINDING_REDUCE_RATIO);
float highReduceRatio =
parseFloat(highReduceRatioValue, DEFAULT_MODERATE_BINDING_REDUCE_RATIO * 2);
highReduceRatio = Math.max(0, Math.min(1, highReduceRatio));
lowReduceRatio = Math.max(0, Math.min(highReduceRatio, lowReduceRatio));
ChildProcessLauncher.startModerateBindingManagement(
context, lowReduceRatio, highReduceRatio);
}
示例4: enableHardwareAcceleration
import org.chromium.base.SysUtils; //导入依赖的package包/类
private void enableHardwareAcceleration() {
// HW acceleration is disabled in the manifest. Enable it only on high-end devices.
if (!SysUtils.isLowEndDevice()) {
getWindow().addFlags(WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED);
// When HW acceleration is enabled manually for an activity, child windows (e.g.
// dialogs) don't inherit HW acceleration state. However, when HW acceleration is
// enabled in the manifest, child windows do inherit HW acceleration state. That
// looks like a bug, so I filed b/23036374
//
// In the meanwhile the workaround is to call
// window.setWindowManager(..., hardwareAccelerated=true)
// to let the window know that it's HW accelerated. However, since there is no way
// to know 'appToken' argument until window's view is attached to the window (!!),
// we have to do the workaround in onAttachedToWindow()
mSetWindowHWA = true;
}
}
示例5: startBackgroundRequestsImpl
import org.chromium.base.SysUtils; //导入依赖的package包/类
/**
* Triggers processing of background offlining requests. This is called when
* system conditions are appropriate for background offlining, typically from the
* GcmTaskService onRunTask() method. In response, we will start the
* task processing by passing the call along to the C++ RequestCoordinator.
* Also starts UMA collection.
*
* @returns Whether processing will be carried out and completion will be indicated through a
* callback.
*/
static boolean startBackgroundRequestsImpl(BackgroundSchedulerProcessor bridge, Context context,
Bundle taskExtras, Callback<Boolean> callback) {
TriggerConditions triggerConditions =
TaskExtrasPacker.unpackTriggerConditionsFromBundle(taskExtras);
DeviceConditions currentConditions = DeviceConditions.getCurrentConditions(context);
if (!currentConditions.isPowerConnected()
&& currentConditions.getBatteryPercentage()
< triggerConditions.getMinimumBatteryPercentage()) {
Log.d(TAG, "Battery percentage is lower than minimum to start processing");
return false;
}
if (SysUtils.isLowEndDevice() && ApplicationStatus.hasVisibleActivities()) {
Log.d(TAG, "Application visible on low-end device so deferring background processing");
return false;
}
// Gather UMA data to measure how often the user's machine is amenable to background
// loading when we wake to do a task.
long taskScheduledTimeMillis = TaskExtrasPacker.unpackTimeFromBundle(taskExtras);
OfflinePageUtils.recordWakeupUMA(context, taskScheduledTimeMillis);
return bridge.startScheduledProcessing(currentConditions, callback);
}
示例6: Toast
import org.chromium.base.SysUtils; //导入依赖的package包/类
private Toast(Context context, android.widget.Toast toast) {
mToast = toast;
if (SysUtils.isLowEndDevice() && Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
// Don't HW accelerate Toasts. Unfortunately the only way to do that is to make
// toast.getView().getContext().getApplicationInfo() return lies to prevent
// WindowManagerGlobal.addView() from adding LayoutParams.FLAG_HARDWARE_ACCELERATED.
mSWLayout = new FrameLayout(new ContextWrapper(context) {
@Override
public ApplicationInfo getApplicationInfo() {
ApplicationInfo info = new ApplicationInfo(super.getApplicationInfo());
// On Lollipop the condition we need to fail is
// "targetSdkVersion >= Build.VERSION_CODES.LOLLIPOP"
// (and for Chrome targetSdkVersion is always the latest)
info.targetSdkVersion = Build.VERSION_CODES.KITKAT;
// On M+ the condition we need to fail is
// "flags & ApplicationInfo.FLAG_HARDWARE_ACCELERATED"
info.flags &= ~ApplicationInfo.FLAG_HARDWARE_ACCELERATED;
return info;
}
});
setView(toast.getView());
}
}
示例7: initializeAlreadyLocked
import org.chromium.base.SysUtils; //导入依赖的package包/类
private static void initializeAlreadyLocked(String[] initCommandLine)
throws ProcessInitException {
if (sInitialized) {
return;
}
int resultCode = nativeLibraryLoaded(initCommandLine);
if (resultCode != 0) {
Log.e(TAG, "error calling nativeLibraryLoaded");
throw new ProcessInitException(resultCode);
}
// From this point on, native code is ready to use and checkIsReady()
// shouldn't complain from now on (and in fact, it's used by the
// following calls).
sInitialized = true;
CommandLine.enableNativeProxy();
TraceEvent.setEnabledToMatchNative();
// Record histogram for the content linker.
if (Linker.isUsed())
nativeRecordContentAndroidLinkerHistogram(Linker.loadAtFixedAddressFailed(),
SysUtils.isLowEndDevice());
}
示例8: initializeAlreadyLocked
import org.chromium.base.SysUtils; //导入依赖的package包/类
private static void initializeAlreadyLocked(String[] initCommandLine)
throws ProcessInitException {
if (sInitialized) {
return;
}
if (!nativeLibraryLoaded(initCommandLine)) {
Log.e(TAG, "error calling nativeLibraryLoaded");
throw new ProcessInitException(LoaderErrors.LOADER_ERROR_FAILED_TO_REGISTER_JNI);
}
// From this point on, native code is ready to use and checkIsReady()
// shouldn't complain from now on (and in fact, it's used by the
// following calls).
sInitialized = true;
CommandLine.enableNativeProxy();
TraceEvent.setEnabledToMatchNative();
// Record histogram for the Chromium linker.
if (Linker.isUsed())
nativeRecordChromiumAndroidLinkerHistogram(Linker.loadAtFixedAddressFailed(),
SysUtils.isLowEndDevice());
nativeRecordNativeLibraryHack(sNativeLibraryHackWasUsed);
}
示例9: isEnabled
import org.chromium.base.SysUtils; //导入依赖的package包/类
/**
* @return Whether Reader mode and its new UI are enabled.
* @param context A context
*/
public static boolean isEnabled(Context context) {
if (context == null) return false;
boolean enabled = CommandLine.getInstance().hasSwitch(ChromeSwitches.ENABLE_DOM_DISTILLER)
&& !CommandLine.getInstance().hasSwitch(
ChromeSwitches.DISABLE_READER_MODE_BOTTOM_BAR)
&& !DeviceFormFactor.isTablet(context)
&& DomDistillerTabUtils.isDistillerHeuristicsEnabled()
&& !SysUtils.isLowEndDevice();
return enabled;
}
示例10: DeviceClassManager
import org.chromium.base.SysUtils; //导入依赖的package包/类
/**
* 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(ContextUtils.getApplicationContext())) {
mEnableAccessibilityLayout = false;
}
// Flag based configurations.
CommandLine commandLine = CommandLine.getInstance();
mEnableAccessibilityLayout |= commandLine
.hasSwitch(ChromeSwitches.ENABLE_ACCESSIBILITY_TAB_SWITCHER);
mEnableFullscreen =
!commandLine.hasSwitch(ChromeSwitches.DISABLE_FULLSCREEN);
// Related features.
if (mEnableAccessibilityLayout) {
mEnableAnimations = false;
}
}
示例11: startBackgroundRequests
import org.chromium.base.SysUtils; //导入依赖的package包/类
/**
* Triggers processing of background offlining requests. This is called when
* system conditions are appropriate for background offlining, typically from the
* GcmTaskService onRunTask() method. In response, we will start the
* task processing by passing the call along to the C++ RequestCoordinator.
* Also starts UMA collection.
*
* @returns true for success
*/
public boolean startBackgroundRequests(Context context, Bundle bundle,
ChromeBackgroundServiceWaiter waiter) {
// Set up backup scheduled task in case processing is killed before RequestCoordinator
// has a chance to reschedule base on remaining work.
TriggerConditions previousTriggerConditions =
TaskExtrasPacker.unpackTriggerConditionsFromBundle(bundle);
BackgroundScheduler.backupSchedule(context, previousTriggerConditions, DEFER_START_SECONDS);
DeviceConditions currentConditions = OfflinePageUtils.getDeviceConditions(context);
if (!currentConditions.isPowerConnected()
&& currentConditions.getBatteryPercentage()
< previousTriggerConditions.getMinimumBatteryPercentage()) {
Log.d(TAG, "Battery percentage is lower than minimum to start processing");
return false;
}
if (SysUtils.isLowEndDevice() && ApplicationStatus.hasVisibleActivities()) {
Log.d(TAG, "Application visible on low-end device so deferring background processing");
return false;
}
// Now initiate processing.
processBackgroundRequests(bundle, currentConditions, waiter);
// Gather UMA data to measure how often the user's machine is amenable to background
// loading when we wake to do a task.
long taskScheduledTimeMillis = TaskExtrasPacker.unpackTimeFromBundle(bundle);
OfflinePageUtils.recordWakeupUMA(context, taskScheduledTimeMillis);
return true;
}
示例12: startModerateBindingManagementIfNeeded
import org.chromium.base.SysUtils; //导入依赖的package包/类
private void startModerateBindingManagementIfNeeded() {
// Moderate binding doesn't apply to low end devices.
if (SysUtils.isLowEndDevice()) return;
boolean moderateBindingTillBackgrounded =
FieldTrialList.findFullName("ModerateBindingOnBackgroundTabCreation")
.equals("Enabled");
ChildProcessLauncher.startModerateBindingManagement(
mAppContext, moderateBindingTillBackgrounded);
}
示例13: warmupInternal
import org.chromium.base.SysUtils; //导入依赖的package包/类
/**
* Starts as much as possible in anticipation of a future navigation.
*
* @param mayCreatesparewebcontents true if warmup() can create a spare renderer.
* @return true for success.
*/
private boolean warmupInternal(final boolean mayCreateSpareWebContents) {
// Here and in mayLaunchUrl(), don't do expensive work for background applications.
if (!isCallerForegroundOrSelf()) return false;
mClientManager.recordUidHasCalledWarmup(Binder.getCallingUid());
final boolean initialized = !mWarmupHasBeenCalled.compareAndSet(false, true);
final int uid = Binder.getCallingUid();
// The call is non-blocking and this must execute on the UI thread, post a task.
ThreadUtils.postOnUiThread(new Runnable() {
@Override
public void run() {
if (!initialized) initializeBrowser(mApplication);
if (mayCreateSpareWebContents && mSpeculation == null
&& !SysUtils.isLowEndDevice()) {
WarmupManager.getInstance().createSpareWebContents();
// The throttling database uses shared preferences, that can cause a StrictMode
// violation on the first access. Make sure that this access is not in
// mayLauchUrl.
RequestThrottler.getForUid(mApplication, uid);
Profile profile = Profile.getLastUsedProfile();
new ResourcePrefetchPredictor(profile).startInitialization();
}
mWarmupHasBeenFinished.set(true);
}
});
return true;
}
示例14: startObservingMediaSinks
import org.chromium.base.SysUtils; //导入依赖的package包/类
/**
* Starts background monitoring for available media sinks compatible with the given
* |sourceUrn| if the device is in a state that allows it.
* @param sourceId a URL to use for filtering of the available media sinks
* @return whether the monitoring started (ie. was allowed).
*/
@CalledByNative
public boolean startObservingMediaSinks(String sourceId) {
if (SysUtils.isLowEndDevice()) return false;
for (MediaRouteProvider provider : mRouteProviders) {
provider.startObservingMediaSinks(sourceId);
}
return true;
}
示例15: detectEnabled
import org.chromium.base.SysUtils; //导入依赖的package包/类
private static boolean detectEnabled() {
if (SysUtils.isLowEndDevice()) {
return false;
}
// This is used for instrumentation tests (i.e. it is not a user-flippable flag). We cannot
// use Variations params because in the test harness, the initialization comes before any
// native methods are available. And the ContextualSearchManager is initialized very early
// in the Chrome initialization.
if (CommandLine.getInstance().hasSwitch(
ChromeSwitches.ENABLE_CONTEXTUAL_SEARCH_FOR_TESTING)) {
return true;
}
// Allow this user-flippable flag to disable the feature.
if (CommandLine.getInstance().hasSwitch(ChromeSwitches.DISABLE_CONTEXTUAL_SEARCH)) {
return false;
}
// Allow this user-flippable flag to override disabling due to language.
if (CommandLine.getInstance().hasSwitch(ChromeSwitches.ENABLE_CONTEXTUAL_SEARCH)) {
return true;
}
String languageCode = Locale.getDefault().getLanguage();
if (!isLanguageSupported(languageCode)) return false;
if (ChromeVersionInfo.isLocalBuild()) return true;
return getBooleanParam(ENABLED_PARAM);
}