From cc84ff4f31f20dcb4cd76db749852c47d18c4a2e Mon Sep 17 00:00:00 2001 From: Adam Powell Date: Wed, 4 Dec 2013 11:15:29 -0800 Subject: Add a config override for ViewConfiguration#hasPermanentMenuKey Allow device overlays to override the behavior of the hasPermanentMenuKey method at build time. This is useful for devices that do not behave as the usual autodetection mechanism expects. Device overlays should set config_overrideHasPermanentMenuKey to 1 if the device DOES have a permanent menu key or 2 if the device DOES NOT have a permanent menu key. Change-Id: I467b68528cf681b08adcaebc2402d8bdd84f6b5c --- core/java/android/view/ViewConfiguration.java | 39 ++++++++++++++++++++++----- 1 file changed, 33 insertions(+), 6 deletions(-) (limited to 'core/java/android/view/ViewConfiguration.java') diff --git a/core/java/android/view/ViewConfiguration.java b/core/java/android/view/ViewConfiguration.java index c3f064fdfd4a..e67659c2485e 100644 --- a/core/java/android/view/ViewConfiguration.java +++ b/core/java/android/view/ViewConfiguration.java @@ -212,6 +212,14 @@ public class ViewConfiguration { */ private static final int OVERFLING_DISTANCE = 6; + /** + * Configuration values for overriding {@link #hasPermanentMenuKey()} behavior. + * These constants must match the definition in res/values/config.xml. + */ + private static final int HAS_PERMANENT_MENU_KEY_AUTODETECT = 0; + private static final int HAS_PERMANENT_MENU_KEY_TRUE = 1; + private static final int HAS_PERMANENT_MENU_KEY_FALSE = 2; + private final int mEdgeSlop; private final int mFadingEdgeLength; private final int mMinimumFlingVelocity; @@ -296,12 +304,31 @@ public class ViewConfiguration { mOverflingDistance = (int) (sizeAndDensity * OVERFLING_DISTANCE + 0.5f); if (!sHasPermanentMenuKeySet) { - IWindowManager wm = WindowManagerGlobal.getWindowManagerService(); - try { - sHasPermanentMenuKey = !wm.hasNavigationBar(); - sHasPermanentMenuKeySet = true; - } catch (RemoteException ex) { - sHasPermanentMenuKey = false; + final int configVal = res.getInteger( + com.android.internal.R.integer.config_overrideHasPermanentMenuKey); + + switch (configVal) { + default: + case HAS_PERMANENT_MENU_KEY_AUTODETECT: { + IWindowManager wm = WindowManagerGlobal.getWindowManagerService(); + try { + sHasPermanentMenuKey = !wm.hasNavigationBar(); + sHasPermanentMenuKeySet = true; + } catch (RemoteException ex) { + sHasPermanentMenuKey = false; + } + } + break; + + case HAS_PERMANENT_MENU_KEY_TRUE: + sHasPermanentMenuKey = true; + sHasPermanentMenuKeySet = true; + break; + + case HAS_PERMANENT_MENU_KEY_FALSE: + sHasPermanentMenuKey = false; + sHasPermanentMenuKeySet = true; + break; } } -- cgit v1.2.3