Bug 1231554 - Disable the dynamic toolbar on Galaxy Note devices running Android 4.1.2. r=sebastian

This commit is contained in:
Kartikaya Gupta 2016-01-29 14:45:24 -05:00
parent 5e15bd1087
commit 5cd890c6fc
2 changed files with 35 additions and 0 deletions

View File

@ -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<PinReason> 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;
}

View File

@ -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,