Add condition check for double tap gesture settings.

Only shows the double tap gesture preference if the config is enabled.

Test: manual - launch gesture settings on different devices and check
for double tap preference. Auto test pending.
Bug: 31930457

Change-Id: Id972f60035d0c74f0832395f0229691cd3296d60
diff --git a/res/values/config.xml b/res/values/config.xml
index 75d8697..7513cef 100755
--- a/res/values/config.xml
+++ b/res/values/config.xml
@@ -58,4 +58,7 @@
     <!-- If the Storage Manager settings are enabled. -->
     <bool name="config_storage_manager_settings_enabled">false</bool>
 
+    <!-- When true show double-tap gesture setting. -->
+    <bool name="config_gesture_double_tap_settings_enabled">false</bool>
+
 </resources>
diff --git a/src/com/android/settings/gestures/GestureSettings.java b/src/com/android/settings/gestures/GestureSettings.java
index 88a7bb4..b18bc05 100644
--- a/src/com/android/settings/gestures/GestureSettings.java
+++ b/src/com/android/settings/gestures/GestureSettings.java
@@ -71,7 +71,7 @@
         Context context = getActivity();
         mPreferences = new ArrayList();
 
-         // Double tap power for camera
+        // Double tap power for camera
         if (isCameraDoubleTapPowerGestureAvailable(getResources())) {
             int cameraDisabled = Secure.getInt(
                     getContentResolver(), Secure.CAMERA_DOUBLE_TAP_POWER_GESTURE_DISABLED, 0);
@@ -81,13 +81,17 @@
         }
 
         // Ambient Display
-        if (isDozeAvailable(context)) {
+        boolean dozeEnabled = isDozeAvailable(context);
+        if (dozeEnabled) {
             int pickup = Secure.getInt(getContentResolver(), Secure.DOZE_PULSE_ON_PICK_UP, 1);
             addPreference(PREF_KEY_PICK_UP, pickup != 0, PREF_ID_PICK_UP);
+        } else {
+            removePreference(PREF_KEY_PICK_UP);
+        }
+        if (dozeEnabled && isDoubleTapAvailable(context)) {
             int doubleTap = Secure.getInt(getContentResolver(), Secure.DOZE_PULSE_ON_DOUBLE_TAP, 1);
             addPreference(PREF_KEY_DOUBLE_TAP_SCREEN, doubleTap != 0, PREF_ID_DOUBLE_TAP_SCREEN);
         } else {
-            removePreference(PREF_KEY_PICK_UP);
             removePreference(PREF_KEY_DOUBLE_TAP_SCREEN);
         }
 
@@ -215,6 +219,11 @@
         return false;
     }
 
+    private static boolean isDoubleTapAvailable(Context context) {
+        return context.getResources().getBoolean(
+                R.bool.config_gesture_double_tap_settings_enabled);
+    }
+
     private void addPreference(String key, boolean enabled, int id) {
         GesturePreference preference = (GesturePreference) findPreference(key);
         preference.setChecked(enabled);
@@ -247,6 +256,8 @@
                 if (!isDozeAvailable(context)) {
                     result.add(PREF_KEY_PICK_UP);
                     result.add(PREF_KEY_DOUBLE_TAP_SCREEN);
+                } else if (!isDoubleTapAvailable(context)) {
+                    result.add(PREF_KEY_DOUBLE_TAP_SCREEN);
                 }
                 if (!isSystemUINavigationAvailable(context)) {
                     result.add(PREF_KEY_SWIPE_DOWN_FINGERPRINT);