diff --git a/mobile/android/base/java/org/mozilla/gecko/DynamicToolbar.java b/mobile/android/base/java/org/mozilla/gecko/DynamicToolbar.java index 9d9917518e3..5292d6786e6 100644 --- a/mobile/android/base/java/org/mozilla/gecko/DynamicToolbar.java +++ b/mobile/android/base/java/org/mozilla/gecko/DynamicToolbar.java @@ -6,9 +6,13 @@ import org.mozilla.gecko.PrefsHelper.PrefHandlerBase; import org.mozilla.gecko.gfx.LayerView; import org.mozilla.gecko.util.ThreadUtils; +import android.os.Build; import android.os.Bundle; +import android.util.Log; public class DynamicToolbar { + private static final String LOGTAG = "DynamicToolbar"; + private static final String STATE_ENABLED = "dynamic_toolbar"; private static final String CHROME_PREF = "browser.chrome.dynamictoolbar"; @@ -17,6 +21,9 @@ public class DynamicToolbar { // the pref from Gecko telling us to turn it on. private volatile boolean prefEnabled; private boolean accessibilityEnabled; + // On some device we have to force-disable the dynamic toolbar because of + // bugs in the Android code. See bug 1231554. + private final boolean forceDisabled; private final int prefObserverId; private final EnumSet pinFlags = EnumSet.noneOf(PinReason.class); @@ -48,6 +55,21 @@ public class DynamicToolbar { public DynamicToolbar() { // Listen to the dynamic toolbar pref prefObserverId = PrefsHelper.getPref(CHROME_PREF, new PrefHandler()); + forceDisabled = isForceDisabled(); + if (forceDisabled) { + Log.i(LOGTAG, "Force-disabling dynamic toolbar for " + Build.MODEL + " (" + Build.DEVICE + "/" + Build.PRODUCT + ")"); + } + } + + public static boolean isForceDisabled() { + // Force-disable dynamic toolbar on the variants of the Galaxy Note 10.1 + // and Note 8.0 running Android 4.1.2. (Bug 1231554). This includes + // the following model numbers: + // GT-N8000, GT-N8005, GT-N8010, GT-N8013, GT-N8020 + // GT-N5100, GT-N5110, GT-N5120 + return Build.VERSION.SDK_INT == Build.VERSION_CODES.JELLY_BEAN + && (Build.MODEL.startsWith("GT-N80") || + Build.MODEL.startsWith("GT-N51")); } public void destroy() { @@ -83,6 +105,10 @@ public class DynamicToolbar { public boolean isEnabled() { ThreadUtils.assertOnUiThread(); + if (forceDisabled) { + return false; + } + return prefEnabled && !accessibilityEnabled; } diff --git a/mobile/android/base/java/org/mozilla/gecko/preferences/GeckoPreferences.java b/mobile/android/base/java/org/mozilla/gecko/preferences/GeckoPreferences.java index 082b538063f..58874275ae4 100644 --- a/mobile/android/base/java/org/mozilla/gecko/preferences/GeckoPreferences.java +++ b/mobile/android/base/java/org/mozilla/gecko/preferences/GeckoPreferences.java @@ -12,6 +12,7 @@ import org.mozilla.gecko.AppConstants.Versions; import org.mozilla.gecko.BrowserApp; import org.mozilla.gecko.BrowserLocaleManager; import org.mozilla.gecko.DataReportingNotification; +import org.mozilla.gecko.DynamicToolbar; import org.mozilla.gecko.EventDispatcher; import org.mozilla.gecko.GeckoActivityStatus; import org.mozilla.gecko.GeckoAppShell; @@ -163,6 +164,8 @@ OnSharedPreferenceChangeListener public static final String PREFS_TAB_QUEUE_LAST_SITE = NON_PREF_PREFIX + "last_site"; public static final String PREFS_TAB_QUEUE_LAST_TIME = NON_PREF_PREFIX + "last_time"; + private static final String PREFS_DYNAMIC_TOOLBAR = "browser.chrome.dynamictoolbar"; + // These values are chosen to be distinct from other Activity constants. private static final int REQUEST_CODE_PREF_SCREEN = 5; private static final int RESULT_CODE_EXIT_SETTINGS = 6; @@ -895,6 +898,12 @@ OnSharedPreferenceChangeListener }); } }); + } else if (PREFS_DYNAMIC_TOOLBAR.equals(key)) { + if (DynamicToolbar.isForceDisabled()) { + preferences.removePreference(pref); + i--; + continue; + } } // Some Preference UI elements are not actually preferences,