diff options
author | jdduke@chromium.org <jdduke@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-11-27 16:40:53 +0000 |
---|---|---|
committer | jdduke@chromium.org <jdduke@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-11-27 16:40:53 +0000 |
commit | 705872bdc38e14bac98b4999acc8d6294ea06218 (patch) | |
tree | ce999e48fb384a4b4a5ff39f1405800ee72042da | |
parent | 48b902d876262215df2a783f01597a48c5b93715 (diff) | |
download | chromium_src-705872bdc38e14bac98b4999acc8d6294ea06218.zip chromium_src-705872bdc38e14bac98b4999acc8d6294ea06218.tar.gz chromium_src-705872bdc38e14bac98b4999acc8d6294ea06218.tar.bz2 |
[Android] Add a low-end device mode override flag
The current low-end device optimizations are restricted to devices that meet
certain memory and OS version criteria. Add a flag that overrides this
detection, simplifying testing and allowing power users to take advantage
of the optimizations.
BUG=320747
Review URL: https://codereview.chromium.org/62833002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@237584 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | base/android/java/src/org/chromium/base/BaseSwitches.java | 6 | ||||
-rw-r--r-- | base/android/java/src/org/chromium/base/SysUtils.java | 28 | ||||
-rw-r--r-- | base/base_switches.cc | 8 | ||||
-rw-r--r-- | base/base_switches.h | 5 | ||||
-rw-r--r-- | chrome/app/generated_resources.grd | 6 | ||||
-rw-r--r-- | chrome/browser/about_flags.cc | 8 | ||||
-rw-r--r-- | content/browser/renderer_host/render_process_host_impl.cc | 2 |
7 files changed, 57 insertions, 6 deletions
diff --git a/base/android/java/src/org/chromium/base/BaseSwitches.java b/base/android/java/src/org/chromium/base/BaseSwitches.java index 4cda1f5..f9832dd 100644 --- a/base/android/java/src/org/chromium/base/BaseSwitches.java +++ b/base/android/java/src/org/chromium/base/BaseSwitches.java @@ -12,6 +12,12 @@ public abstract class BaseSwitches { // Block onCreate() of Chrome until a Java debugger is attached. public static final String WAIT_FOR_JAVA_DEBUGGER = "wait-for-java-debugger"; + // Overrides low-end device detection, disabling low-end device optimizations. + public static final String DISABLE_LOW_END_DEVICE_MODE = "disable-low-end-device-mode"; + + // Overrides low-end device detection, enabling low-end device optimizations. + public static final String ENABLE_LOW_END_DEVICE_MODE = "enable-low-end-device-mode"; + // Prevent instantiation. private BaseSwitches() {} }; diff --git a/base/android/java/src/org/chromium/base/SysUtils.java b/base/android/java/src/org/chromium/base/SysUtils.java index 6c2ef5f..61a1a08 100644 --- a/base/android/java/src/org/chromium/base/SysUtils.java +++ b/base/android/java/src/org/chromium/base/SysUtils.java @@ -15,6 +15,9 @@ import android.content.Context; import android.os.Build; import android.util.Log; +import org.chromium.base.BaseSwitches; +import org.chromium.base.CommandLine; + /** * Exposes system related information about the current device. */ @@ -98,15 +101,28 @@ public class SysUtils { */ @CalledByNative public static boolean isLowEndDevice() { - if (Build.VERSION.SDK_INT <= ANDROID_LOW_MEMORY_ANDROID_SDK_THRESHOLD) { - return false; - } if (sLowEndDevice == null) { - int ramSizeKB = amountOfPhysicalMemoryKB(); - sLowEndDevice = (ramSizeKB > 0 && - ramSizeKB / 1024 < ANDROID_LOW_MEMORY_DEVICE_THRESHOLD_MB); + sLowEndDevice = detectLowEndDevice(); } return sLowEndDevice.booleanValue(); } + + private static boolean detectLowEndDevice() { + if (CommandLine.isInitialized()) { + if (CommandLine.getInstance().hasSwitch(BaseSwitches.ENABLE_LOW_END_DEVICE_MODE)) { + return true; + } + if (CommandLine.getInstance().hasSwitch(BaseSwitches.DISABLE_LOW_END_DEVICE_MODE)) { + return false; + } + } + + if (Build.VERSION.SDK_INT <= ANDROID_LOW_MEMORY_ANDROID_SDK_THRESHOLD) { + return false; + } + + int ramSizeKB = amountOfPhysicalMemoryKB(); + return (ramSizeKB > 0 && ramSizeKB / 1024 < ANDROID_LOW_MEMORY_DEVICE_THRESHOLD_MB); + } } diff --git a/base/base_switches.cc b/base/base_switches.cc index c6dce9b..526633c 100644 --- a/base/base_switches.cc +++ b/base/base_switches.cc @@ -61,4 +61,12 @@ const char kEnableCrashReporterForTesting[] = "enable-crash-reporter-for-testing"; #endif +#if defined(OS_ANDROID) +// Overrides low-end device detection, disabling low-end device optimizations. +const char kDisableLowEndDeviceMode[] = "disable-low-end-device-mode"; + +// Overrides low-end device detection, enabling low-end device optimizations. +const char kEnableLowEndDeviceMode[] = "enable-low-end-device-mode"; +#endif + } // namespace switches diff --git a/base/base_switches.h b/base/base_switches.h index 33b2b68..b2bf7ab 100644 --- a/base/base_switches.h +++ b/base/base_switches.h @@ -27,6 +27,11 @@ extern const char kTraceToConsole[]; extern const char kEnableCrashReporterForTesting[]; #endif +#if defined(OS_ANDROID) +extern const char kDisableLowEndDeviceMode[]; +extern const char kEnableLowEndDeviceMode[]; +#endif + } // namespace switches #endif // BASE_BASE_SWITCHES_H_ diff --git a/chrome/app/generated_resources.grd b/chrome/app/generated_resources.grd index 42ab546..afc5b6f 100644 --- a/chrome/app/generated_resources.grd +++ b/chrome/app/generated_resources.grd @@ -6673,6 +6673,12 @@ Keep your key file in a safe place. You will need it to create new versions of y <message name="IDS_FLAGS_DISABLE_CLICK_DELAY_DESCRIPTION" desc="Description of the flag to disable the click delay."> Always send click events immediate upon a tap, even when it's part of a double-tap gesture. This speeds up navigation and other tap actions by 300ms on most pages, but means links and buttons must be avoided when double tapping to zoom. </message> + <message name="IDS_FLAGS_LOW_END_DEVICE_MODE_DESCRIPTION" desc="Description of the flag to tweak low end device optimizations."> + Overrides low end device optimizations. + </message> + <message name="IDS_FLAGS_LOW_END_DEVICE_MODE_NAME" desc="Name of the flag to tweak low end device optimizations."> + Low end device mode. + </message> </if> <message name="IDS_FLAGS_ENABLE_TRANSLATE_NEW_UX_NAME" desc="Name of the flag to enable the new Translate UX."> Enable the new Translate UX. diff --git a/chrome/browser/about_flags.cc b/chrome/browser/about_flags.cc index b6fb23f..9bab032 100644 --- a/chrome/browser/about_flags.cc +++ b/chrome/browser/about_flags.cc @@ -1799,6 +1799,14 @@ const Experiment kExperiments[] = { // Java-only switch: CommandLine.DISABLE_CLICK_DELAY SINGLE_VALUE_TYPE("disable-click-delay") }, + { + "low-end-device-mode", + IDS_FLAGS_LOW_END_DEVICE_MODE_NAME, + IDS_FLAGS_LOW_END_DEVICE_MODE_DESCRIPTION, + kOsAndroid, + ENABLE_DISABLE_VALUE_TYPE(switches::kEnableLowEndDeviceMode, + switches::kDisableLowEndDeviceMode) + }, #endif #if defined(OS_CHROMEOS) { diff --git a/content/browser/renderer_host/render_process_host_impl.cc b/content/browser/renderer_host/render_process_host_impl.cc index 455f36d..08e75cf 100644 --- a/content/browser/renderer_host/render_process_host_impl.cc +++ b/content/browser/renderer_host/render_process_host_impl.cc @@ -1115,7 +1115,9 @@ void RenderProcessHostImpl::PropagateBrowserCommandLineToRenderer( #endif #if defined(OS_ANDROID) switches::kDisableGestureRequirementForMediaPlayback, + switches::kDisableLowEndDeviceMode, switches::kDisableWebRTC, + switches::kEnableLowEndDeviceMode, switches::kEnableSpeechRecognition, switches::kHideScrollbars, switches::kMediaDrmEnableNonCompositing, |