GesturesSettingPreferenceController to Toggle

Convert GesturesSettingPreferenceController to
TogglePreferenceController,
All of its children need follow the change,
add setter and robotest for them:
AssistGestureSettingsPreferenceController
DoubleTapPowerPreferenceController
DoubleTapScreenPreferenceController
DoubleTwistPreferenceController
PickupGesturePreferenceController
SwipeToNotificationPreferenceController

Change-Id: I792b2d370eea828bf345fb2b1cc3eac260eb66f4
Merged-In: I792b2d370eea828bf345fb2b1cc3eac260eb66f4
Fixes: 74913806
Fixes: 67998110
Fixes: 67998098
Fixes: 67998048
Fixes: 67998069
Fixes: 67997452
Test: make RunSettingsRoboTests
diff --git a/res/xml/ambient_display_settings.xml b/res/xml/ambient_display_settings.xml
index a23aeaa..4688a80 100644
--- a/res/xml/ambient_display_settings.xml
+++ b/res/xml/ambient_display_settings.xml
@@ -35,12 +35,14 @@
         <Preference
             android:key="ambient_display_double_tap"
             android:title="@string/ambient_display_title"
-            android:fragment="com.android.settings.gestures.DoubleTapScreenSettings" />
+            android:fragment="com.android.settings.gestures.DoubleTapScreenSettings"
+            settings:controller="com.android.settings.gestures.DoubleTapScreenPreferenceController" />
 
         <Preference
             android:key="ambient_display_pick_up"
             android:title="@string/ambient_display_pickup_title"
-            android:fragment="com.android.settings.gestures.PickupGestureSettings" />
+            android:fragment="com.android.settings.gestures.PickupGestureSettings"
+            settings:controller="com.android.settings.gestures.PickupGesturePreferenceController" />
 
     </PreferenceCategory>
 
@@ -52,7 +54,7 @@
             android:key="ambient_display_notification"
             android:title="@string/doze_title"
             android:summary="@string/doze_summary"
-            settings:controller="com.android.settings.display.AmbientDisplayNotificationsPreferenceController"/>
+            settings:controller="com.android.settings.display.AmbientDisplayNotificationsPreferenceController" />
 
     </PreferenceCategory>
 
diff --git a/res/xml/assist_gesture_settings.xml b/res/xml/assist_gesture_settings.xml
index 53b6526..b2ceac9 100644
--- a/res/xml/assist_gesture_settings.xml
+++ b/res/xml/assist_gesture_settings.xml
@@ -29,6 +29,7 @@
     <SwitchPreference
         android:key="gesture_assist"
         android:title="@string/assist_gesture_title"
-        app:keywords="@string/keywords_assist_gesture_launch" />
+        app:keywords="@string/keywords_assist_gesture_launch"
+        app:controller="com.android.settings.gestures.AssistGestureSettingsPreferenceController" />
 
 </PreferenceScreen>
diff --git a/res/xml/configure_notification_settings.xml b/res/xml/configure_notification_settings.xml
index 73c1d6f..612f5e7 100644
--- a/res/xml/configure_notification_settings.xml
+++ b/res/xml/configure_notification_settings.xml
@@ -46,7 +46,8 @@
     <Preference
         android:key="gesture_swipe_down_fingerprint_notifications"
         android:title="@string/fingerprint_swipe_for_notifications_title"
-        android:fragment="com.android.settings.gestures.SwipeToNotificationSettings" />
+        android:fragment="com.android.settings.gestures.SwipeToNotificationSettings"
+        settings:controller="com.android.settings.gestures.SwipeToNotificationPreferenceController" />
 
     <com.android.settingslib.RestrictedPreference
         android:key="zen_mode_notifications"
diff --git a/res/xml/double_tap_power_settings.xml b/res/xml/double_tap_power_settings.xml
index 26d0415..6614899 100644
--- a/res/xml/double_tap_power_settings.xml
+++ b/res/xml/double_tap_power_settings.xml
@@ -30,6 +30,7 @@
         android:key="gesture_double_tap_power"
         android:title="@string/double_tap_power_for_camera_title"
         android:summary="@string/double_tap_power_for_camera_summary"
-        app:keywords="@string/keywords_gesture" />
+        app:keywords="@string/keywords_gesture"
+        app:controller="com.android.settings.gestures.DoubleTapPowerPreferenceController" />
 
 </PreferenceScreen>
\ No newline at end of file
diff --git a/res/xml/double_tap_screen_settings.xml b/res/xml/double_tap_screen_settings.xml
index d40602e..4d2e168 100644
--- a/res/xml/double_tap_screen_settings.xml
+++ b/res/xml/double_tap_screen_settings.xml
@@ -30,6 +30,7 @@
         android:key="gesture_double_tap_screen"
         android:title="@string/ambient_display_title"
         android:summary="@string/ambient_display_summary"
-        app:keywords="@string/keywords_gesture" />
+        app:keywords="@string/keywords_gesture"
+        app:controller="com.android.settings.gestures.DoubleTapScreenPreferenceController" />
 
 </PreferenceScreen>
\ No newline at end of file
diff --git a/res/xml/double_twist_gesture_settings.xml b/res/xml/double_twist_gesture_settings.xml
index a2af1e4..1da862d 100644
--- a/res/xml/double_twist_gesture_settings.xml
+++ b/res/xml/double_twist_gesture_settings.xml
@@ -30,6 +30,7 @@
         android:key="gesture_double_twist"
         android:title="@string/double_twist_for_camera_mode_title"
         android:summary="@string/double_twist_for_camera_mode_summary"
-        app:keywords="@string/keywords_gesture" />
+        app:keywords="@string/keywords_gesture"
+        app:controller="com.android.settings.gestures.DoubleTwistPreferenceController" />
 
 </PreferenceScreen>
\ No newline at end of file
diff --git a/res/xml/gestures.xml b/res/xml/gestures.xml
index 7083a31..0eaa2a6 100644
--- a/res/xml/gestures.xml
+++ b/res/xml/gestures.xml
@@ -17,38 +17,45 @@
 
 <PreferenceScreen
     xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:settings="http://schemas.android.com/apk/res-auto"
     android:key="gesture_settings_screen"
-    android:title="@string/gesture_preference_title" >
+    android:title="@string/gesture_preference_title">
 
     <Preference
         android:key="gesture_assist_input_summary"
         android:title="@string/assist_gesture_title"
-        android:fragment="com.android.settings.gestures.AssistGestureSettings" />
+        android:fragment="com.android.settings.gestures.AssistGestureSettings"
+        settings:controller="com.android.settings.gestures.AssistGestureSettingsPreferenceController" />
 
     <Preference
         android:key="gesture_swipe_down_fingerprint_input_summary"
         android:title="@string/fingerprint_swipe_for_notifications_title"
-        android:fragment="com.android.settings.gestures.SwipeToNotificationSettings" />
+        android:fragment="com.android.settings.gestures.SwipeToNotificationSettings"
+        settings:controller="com.android.settings.gestures.SwipeToNotificationPreferenceController" />
 
     <Preference
         android:key="gesture_double_tap_power_input_summary"
         android:title="@string/double_tap_power_for_camera_title"
-        android:fragment="com.android.settings.gestures.DoubleTapPowerSettings" />
+        android:fragment="com.android.settings.gestures.DoubleTapPowerSettings"
+        settings:controller="com.android.settings.gestures.DoubleTapPowerPreferenceController" />
 
     <Preference
         android:key="gesture_double_twist_input_summary"
         android:title="@string/double_twist_for_camera_mode_title"
-        android:fragment="com.android.settings.gestures.DoubleTwistGestureSettings" />
+        android:fragment="com.android.settings.gestures.DoubleTwistGestureSettings"
+        settings:controller="com.android.settings.gestures.DoubleTwistPreferenceController" />
 
     <Preference
         android:key="gesture_double_tap_screen_input_summary"
         android:title="@string/ambient_display_title"
-        android:fragment="com.android.settings.gestures.DoubleTapScreenSettings" />
+        android:fragment="com.android.settings.gestures.DoubleTapScreenSettings"
+        settings:controller="com.android.settings.gestures.DoubleTapScreenPreferenceController" />
 
     <Preference
         android:key="gesture_pick_up_input_summary"
         android:title="@string/ambient_display_pickup_title"
-        android:fragment="com.android.settings.gestures.PickupGestureSettings" />
+        android:fragment="com.android.settings.gestures.PickupGestureSettings"
+        settings:controller="com.android.settings.gestures.PickupGesturePreferenceController" />
 
     <Preference
         android:key="gesture_prevent_ringing_summary"
diff --git a/res/xml/manage_assist.xml b/res/xml/manage_assist.xml
index 047f1ca..dec8bc3 100644
--- a/res/xml/manage_assist.xml
+++ b/res/xml/manage_assist.xml
@@ -17,6 +17,7 @@
 
 <PreferenceScreen
     xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:settings="http://schemas.android.com/apk/res-auto"
     android:key="manage_assist_screen"
     android:title="@string/assist_and_voice_input_title">
 
@@ -24,31 +25,32 @@
         android:key="default_assist"
         android:title="@string/default_assist_title"
         android:summary="@string/summary_placeholder"
-        android:fragment="com.android.settings.applications.assist.DefaultAssistPicker"/>
+        android:fragment="com.android.settings.applications.assist.DefaultAssistPicker" />
 
     <Preference
         android:key="gesture_assist_application"
         android:title="@string/assist_gesture_title"
-        android:fragment="com.android.settings.gestures.AssistGestureSettings"/>
+        android:fragment="com.android.settings.gestures.AssistGestureSettings"
+        settings:controller="com.android.settings.gestures.AssistGestureSettingsPreferenceController" />
 
     <SwitchPreference
         android:key="context"
         android:title="@string/assist_access_context_title"
-        android:summary="@string/assist_access_context_summary"/>
+        android:summary="@string/assist_access_context_summary" />
 
     <SwitchPreference
         android:key="screenshot"
         android:title="@string/assist_access_screenshot_title"
-        android:summary="@string/assist_access_screenshot_summary"/>
+        android:summary="@string/assist_access_screenshot_summary" />
 
     <SwitchPreference
         android:key="flash"
         android:title="@string/assist_flash_title"
-        android:summary="@string/assist_flash_summary"/>
+        android:summary="@string/assist_flash_summary" />
 
     <com.android.settings.widget.GearPreference
         android:key="voice_input_settings"
         android:title="@string/voice_input_settings_title"
-        android:fragment="com.android.settings.applications.assist.DefaultVoiceInputPicker"/>
+        android:fragment="com.android.settings.applications.assist.DefaultVoiceInputPicker" />
 
 </PreferenceScreen>
diff --git a/res/xml/pick_up_gesture_settings.xml b/res/xml/pick_up_gesture_settings.xml
index e1414cd..ccf2d8a 100644
--- a/res/xml/pick_up_gesture_settings.xml
+++ b/res/xml/pick_up_gesture_settings.xml
@@ -30,6 +30,7 @@
         android:key="gesture_pick_up"
         android:title="@string/ambient_display_pickup_title"
         android:summary="@string/ambient_display_pickup_summary"
-        app:keywords="@string/keywords_gesture" />
+        app:keywords="@string/keywords_gesture"
+        app:controller="com.android.settings.gestures.PickupGesturePreferenceController" />
 
 </PreferenceScreen>
\ No newline at end of file
diff --git a/res/xml/swipe_to_notification_settings.xml b/res/xml/swipe_to_notification_settings.xml
index 5b53c10..04dc0c7 100644
--- a/res/xml/swipe_to_notification_settings.xml
+++ b/res/xml/swipe_to_notification_settings.xml
@@ -23,12 +23,13 @@
     <com.android.settings.widget.VideoPreference
         android:key="gesture_swipe_down_fingerprint_video"
         app:animation="@raw/gesture_fingerprint_swipe"
-        app:preview="@drawable/gesture_fingerprint_swipe"/>
+        app:preview="@drawable/gesture_fingerprint_swipe" />
 
     <SwitchPreference
         android:key="gesture_swipe_down_fingerprint"
         android:title="@string/fingerprint_swipe_for_notifications_title"
         android:summary="@string/fingerprint_swipe_for_notifications_summary"
-        app:keywords="@string/keywords_gesture"/>
+        app:keywords="@string/keywords_gesture"
+        app:controller="com.android.settings.gestures.SwipeToNotificationPreferenceController" />
 
 </PreferenceScreen>
\ No newline at end of file
diff --git a/src/com/android/settings/applications/assist/ManageAssist.java b/src/com/android/settings/applications/assist/ManageAssist.java
index f5a3838..82db01f 100644
--- a/src/com/android/settings/applications/assist/ManageAssist.java
+++ b/src/com/android/settings/applications/assist/ManageAssist.java
@@ -61,6 +61,12 @@
     }
 
     @Override
+    public void onAttach(Context context) {
+        super.onAttach(context);
+        use(AssistGestureSettingsPreferenceController.class).setAssistOnly(true);
+    }
+
+    @Override
     public void onResume() {
         super.onResume();
 
@@ -73,8 +79,6 @@
         final List<AbstractPreferenceController> controllers = new ArrayList<>();
         controllers.add(new DefaultAssistPreferenceController(context, "default_assist",
                 true /* showSetting */));
-        controllers.add(new AssistGestureSettingsPreferenceController(context, lifecycle,
-                KEY_ASSIST, true /* assistOnly */));
         controllers.add(new AssistContextPreferenceController(context, lifecycle));
         controllers.add(new AssistScreenshotPreferenceController(context, lifecycle));
         controllers.add(new AssistFlashScreenPreferenceController(context, lifecycle));
diff --git a/src/com/android/settings/display/AmbientDisplayAlwaysOnPreferenceController.java b/src/com/android/settings/display/AmbientDisplayAlwaysOnPreferenceController.java
index 5de49bb..a6d5363 100644
--- a/src/com/android/settings/display/AmbientDisplayAlwaysOnPreferenceController.java
+++ b/src/com/android/settings/display/AmbientDisplayAlwaysOnPreferenceController.java
@@ -69,12 +69,16 @@
         return true;
     }
 
-    public void setConfig(AmbientDisplayConfiguration config) {
+    public AmbientDisplayAlwaysOnPreferenceController setConfig(
+            AmbientDisplayConfiguration config) {
         mConfig = config;
+        return this;
     }
 
-    public void setCallback(OnPreferenceChangedCallback callback) {
+    public AmbientDisplayAlwaysOnPreferenceController setCallback(
+            OnPreferenceChangedCallback callback) {
         mCallback = callback;
+        return this;
     }
 
     public static boolean isAlwaysOnEnabled(AmbientDisplayConfiguration config) {
diff --git a/src/com/android/settings/display/AmbientDisplayNotificationsPreferenceController.java b/src/com/android/settings/display/AmbientDisplayNotificationsPreferenceController.java
index 9cff088..15eb8b3 100644
--- a/src/com/android/settings/display/AmbientDisplayNotificationsPreferenceController.java
+++ b/src/com/android/settings/display/AmbientDisplayNotificationsPreferenceController.java
@@ -56,8 +56,10 @@
      *
      * @param config AmbientDisplayConfiguration for this controller
      */
-    public void setConfig(AmbientDisplayConfiguration config) {
+    public AmbientDisplayNotificationsPreferenceController setConfig(
+            AmbientDisplayConfiguration config) {
         mConfig = config;
+        return this;
     }
 
     @Override
diff --git a/src/com/android/settings/display/AmbientDisplaySettings.java b/src/com/android/settings/display/AmbientDisplaySettings.java
index cab28fa..8745e3f 100644
--- a/src/com/android/settings/display/AmbientDisplaySettings.java
+++ b/src/com/android/settings/display/AmbientDisplaySettings.java
@@ -44,35 +44,18 @@
     public static final String KEY_AMBIENT_DISPLAY_ALWAYS_ON = "ambient_display_always_on";
 
     private static final String TAG = "AmbientDisplaySettings";
-    private static final int MY_USER_ID = UserHandle.myUserId();
-
-    private static final String KEY_AMBIENT_DISPLAY_DOUBLE_TAP = "ambient_display_double_tap";
-    private static final String KEY_AMBIENT_DISPLAY_PICK_UP = "ambient_display_pick_up";
-    private static final String KEY_AMBIENT_DISPLAY_NOTIFICATION = "ambient_display_notification";
 
     private AmbientDisplayConfiguration mConfig;
 
-    private static List<AbstractPreferenceController> buildPreferenceControllers(Context context,
-            Lifecycle lifecycle, AmbientDisplayConfiguration config) {
-
-        final List<AbstractPreferenceController> controllers = new ArrayList<>();
-        controllers.add(new DoubleTapScreenPreferenceController(context, lifecycle, config,
-                MY_USER_ID, KEY_AMBIENT_DISPLAY_DOUBLE_TAP));
-        controllers.add(new PickupGesturePreferenceController(context, lifecycle, config,
-                MY_USER_ID, KEY_AMBIENT_DISPLAY_PICK_UP));
-        return controllers;
-    }
-
     @Override
     public void onAttach(Context context) {
         super.onAttach(context);
-        final AmbientDisplayAlwaysOnPreferenceController controller = use(
-                AmbientDisplayAlwaysOnPreferenceController.class);
-        controller.setConfig(getConfig(context));
-        controller.setCallback(this::updatePreferenceStates);
-        final AmbientDisplayNotificationsPreferenceController notificationController = use(
-                AmbientDisplayNotificationsPreferenceController.class);
-        notificationController.setConfig(getConfig(context));
+        use(AmbientDisplayAlwaysOnPreferenceController.class)
+            .setConfig(getConfig(context))
+            .setCallback(this::updatePreferenceStates);
+        use(AmbientDisplayNotificationsPreferenceController.class).setConfig(getConfig(context));
+        use(DoubleTapScreenPreferenceController.class).setConfig(getConfig(context));
+        use(PickupGesturePreferenceController.class).setConfig(getConfig(context));
     }
 
     @Override
@@ -86,11 +69,6 @@
     }
 
     @Override
-    protected List<AbstractPreferenceController> createPreferenceControllers(Context context) {
-        return buildPreferenceControllers(context, getLifecycle(), getConfig(context));
-    }
-
-    @Override
     public int getMetricsCategory() {
         return MetricsProto.MetricsEvent.AMBIENT_DISPLAY_SETTINGS;
     }
@@ -107,13 +85,6 @@
                     result.add(sir);
                     return result;
                 }
-
-                @Override
-                public List<AbstractPreferenceController> createPreferenceControllers(
-                        Context context) {
-                    return buildPreferenceControllers(context, null,
-                            new AmbientDisplayConfiguration(context));
-                }
             };
 
     private AmbientDisplayConfiguration getConfig(Context context) {
diff --git a/src/com/android/settings/gestures/AssistGestureSettings.java b/src/com/android/settings/gestures/AssistGestureSettings.java
index 84f4ab2..df2dd93 100644
--- a/src/com/android/settings/gestures/AssistGestureSettings.java
+++ b/src/com/android/settings/gestures/AssistGestureSettings.java
@@ -82,9 +82,11 @@
 
                 @Override
                 protected boolean isPageSearchEnabled(Context context) {
-                    return new AssistGestureSettingsPreferenceController(context,
-                            null /* lifecycle */, null /* key */, false /* assistOnly */)
-                            .isAvailable();
+                    AssistGestureSettingsPreferenceController controller =
+                            new AssistGestureSettingsPreferenceController(context,
+                                    "gesture_assist_input_summary");
+                    controller.setAssistOnly(false);
+                    return controller.isAvailable();
                 }
             };
 }
diff --git a/src/com/android/settings/gestures/AssistGestureSettingsPreferenceController.java b/src/com/android/settings/gestures/AssistGestureSettingsPreferenceController.java
index 1ecba0d..fd94f9f 100644
--- a/src/com/android/settings/gestures/AssistGestureSettingsPreferenceController.java
+++ b/src/com/android/settings/gestures/AssistGestureSettingsPreferenceController.java
@@ -24,7 +24,6 @@
 import android.provider.Settings;
 import android.support.v7.preference.Preference;
 import android.support.v7.preference.PreferenceScreen;
-import android.support.v7.preference.TwoStatePreference;
 
 import com.android.internal.annotations.VisibleForTesting;
 import com.android.settings.R;
@@ -32,11 +31,8 @@
 import com.android.settings.search.DatabaseIndexingUtils;
 import com.android.settings.search.InlineSwitchPayload;
 import com.android.settings.search.ResultPayload;
-import com.android.settingslib.core.lifecycle.Lifecycle;
-import com.android.settingslib.core.lifecycle.events.OnResume;
 
-public class AssistGestureSettingsPreferenceController extends GesturePreferenceController
-        implements OnResume {
+public class AssistGestureSettingsPreferenceController extends GesturePreferenceController {
 
     private static final String PREF_KEY_VIDEO = "gesture_assist_video";
 
@@ -55,30 +51,25 @@
     @VisibleForTesting
     boolean mAssistOnly;
 
-    public AssistGestureSettingsPreferenceController(Context context, Lifecycle lifecycle,
-            String key, boolean assistOnly) {
-        super(context, lifecycle);
+    public AssistGestureSettingsPreferenceController(Context context,
+            String key) {
+        super(context, key);
         mFeatureProvider = FeatureFactory.getFactory(context).getAssistGestureFeatureProvider();
         mWasAvailable = isAvailable();
         mAssistGesturePrefKey = key;
-        mAssistOnly = assistOnly;
     }
 
     @Override
-    public boolean isAvailable() {
-        if (mAssistOnly) {
-            return mFeatureProvider.isSupported(mContext);
-        } else {
-            return mFeatureProvider.isSensorAvailable(mContext);
-        }
+    public int getAvailabilityStatus() {
+        final boolean isAvailable = mAssistOnly ? mFeatureProvider.isSupported(mContext)
+                : mFeatureProvider.isSensorAvailable(mContext);
+        return isAvailable ? AVAILABLE : DISABLED_UNSUPPORTED;
     }
 
     @Override
     public void displayPreference(PreferenceScreen screen) {
         mScreen = screen;
         mPreference = screen.findPreference(getPreferenceKey());
-        // Call super last or AbstractPreferenceController might remove the preference from the
-        // screen (if !isAvailable()) before we can save a reference to it.
         super.displayPreference(screen);
     }
 
@@ -92,6 +83,11 @@
         }
     }
 
+    public AssistGestureSettingsPreferenceController setAssistOnly(boolean assistOnly) {
+        mAssistOnly = assistOnly;
+        return this;
+    }
+
     private void updatePreference() {
         if (mPreference == null) {
             return;
@@ -117,31 +113,9 @@
     }
 
     @Override
-    public void updateState(Preference preference) {
-        boolean isEnabled = isAssistGestureEnabled() && mFeatureProvider.isSupported(mContext);
-
-        if (!mAssistOnly) {
-            isEnabled = isEnabled || isSilenceGestureEnabled();
-        }
-
-        if (preference != null) {
-            if (preference instanceof TwoStatePreference) {
-                ((TwoStatePreference) preference).setChecked(isSwitchPrefEnabled());
-            } else {
-                preference.setSummary(isEnabled
-                        ? R.string.gesture_setting_on
-                        : R.string.gesture_setting_off);
-            }
-        }
-    }
-
-    @Override
-    public boolean onPreferenceChange(Preference preference, Object newValue) {
-        final boolean enabled = (boolean) newValue;
-        Settings.Secure.putInt(mContext.getContentResolver(), SECURE_KEY_ASSIST,
-                enabled ? ON : OFF);
-        updateState(preference);
-        return true;
+    public boolean setChecked(boolean isChecked) {
+        return Settings.Secure.putInt(mContext.getContentResolver(), SECURE_KEY_ASSIST,
+                isChecked ? ON : OFF);
     }
 
     @Override
@@ -150,17 +124,22 @@
     }
 
     @Override
-    public String getPreferenceKey() {
-        return mAssistGesturePrefKey;
+    public CharSequence getSummary() {
+        boolean isEnabled = isAssistGestureEnabled() && mFeatureProvider.isSupported(mContext);
+        if (!mAssistOnly) {
+            isEnabled = isEnabled || isSilenceGestureEnabled();
+        }
+        return mContext.getText(
+                isEnabled ? R.string.gesture_setting_on : R.string.gesture_setting_off);
     }
 
     @Override
-    protected boolean isSwitchPrefEnabled() {
-        // Does nothing
-        return true;
+    public boolean isChecked() {
+        return Settings.Secure.getInt(mContext.getContentResolver(), SECURE_KEY_ASSIST, OFF) == ON;
     }
 
     @Override
+    //TODO (b/69808376): Remove result payload
     public ResultPayload getResultPayload() {
         final Intent intent = DatabaseIndexingUtils.buildSearchResultPageIntent(mContext,
                 AssistGestureSettings.class.getName(), mAssistGesturePrefKey,
diff --git a/src/com/android/settings/gestures/DoubleTapPowerPreferenceController.java b/src/com/android/settings/gestures/DoubleTapPowerPreferenceController.java
index 049ee18..aebda18 100644
--- a/src/com/android/settings/gestures/DoubleTapPowerPreferenceController.java
+++ b/src/com/android/settings/gestures/DoubleTapPowerPreferenceController.java
@@ -23,13 +23,11 @@
 import android.content.SharedPreferences;
 import android.provider.Settings;
 import android.support.annotation.VisibleForTesting;
-import android.support.v7.preference.Preference;
 
 import com.android.settings.R;
 import com.android.settings.search.DatabaseIndexingUtils;
 import com.android.settings.search.InlineSwitchPayload;
 import com.android.settings.search.ResultPayload;
-import com.android.settingslib.core.lifecycle.Lifecycle;
 
 public class DoubleTapPowerPreferenceController extends GesturePreferenceController {
 
@@ -43,8 +41,8 @@
 
     private final String SECURE_KEY = CAMERA_DOUBLE_TAP_POWER_GESTURE_DISABLED;
 
-    public DoubleTapPowerPreferenceController(Context context, Lifecycle lifecycle, String key) {
-        super(context, lifecycle);
+    public DoubleTapPowerPreferenceController(Context context, String key) {
+        super(context, key);
         mDoubleTapPowerKey = key;
     }
 
@@ -59,8 +57,8 @@
     }
 
     @Override
-    public boolean isAvailable() {
-        return isGestureAvailable(mContext);
+    public int getAvailabilityStatus() {
+        return isGestureAvailable(mContext) ? AVAILABLE : DISABLED_UNSUPPORTED;
     }
 
     @Override
@@ -69,25 +67,20 @@
     }
 
     @Override
-    public String getPreferenceKey() {
-        return mDoubleTapPowerKey;
-    }
-
-    @Override
-    public boolean onPreferenceChange(Preference preference, Object newValue) {
-        boolean enabled = (boolean) newValue;
-        Settings.Secure.putInt(mContext.getContentResolver(), SECURE_KEY, enabled ? ON : OFF);
-        return true;
-    }
-
-    @Override
-    protected boolean isSwitchPrefEnabled() {
+    public boolean isChecked() {
         final int cameraDisabled = Settings.Secure.getInt(mContext.getContentResolver(),
                 SECURE_KEY, ON);
         return cameraDisabled == ON;
     }
 
     @Override
+    public boolean setChecked(boolean isChecked) {
+        return Settings.Secure.putInt(mContext.getContentResolver(), SECURE_KEY,
+                isChecked ? ON : OFF);
+    }
+
+    @Override
+    //TODO (b/69808376): Remove result payload
     public ResultPayload getResultPayload() {
         final Intent intent = DatabaseIndexingUtils.buildSearchResultPageIntent(mContext,
                 DoubleTapPowerSettings.class.getName(), mDoubleTapPowerKey,
diff --git a/src/com/android/settings/gestures/DoubleTapPowerSettings.java b/src/com/android/settings/gestures/DoubleTapPowerSettings.java
index 6b15923..6eec6cd 100644
--- a/src/com/android/settings/gestures/DoubleTapPowerSettings.java
+++ b/src/com/android/settings/gestures/DoubleTapPowerSettings.java
@@ -26,17 +26,13 @@
 import com.android.settings.dashboard.suggestions.SuggestionFeatureProvider;
 import com.android.settings.overlay.FeatureFactory;
 import com.android.settings.search.BaseSearchIndexProvider;
-import com.android.settingslib.core.AbstractPreferenceController;
-import com.android.settingslib.core.lifecycle.Lifecycle;
 
-import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.List;
 
 public class DoubleTapPowerSettings extends DashboardFragment {
 
     private static final String TAG = "DoubleTapPower";
-    private static final String KEY_DOUBLE_TAP_POWER = "gesture_double_tap_power";
 
     public static final String PREF_KEY_SUGGESTION_COMPLETE =
             "pref_double_tap_power_suggestion_complete";
@@ -65,19 +61,6 @@
         return R.xml.double_tap_power_settings;
     }
 
-    @Override
-    protected List<AbstractPreferenceController> createPreferenceControllers(Context context) {
-        return buildPreferenceControllers(context, getLifecycle());
-    }
-
-    private static List<AbstractPreferenceController> buildPreferenceControllers(Context context,
-            Lifecycle lifecycle) {
-        final List<AbstractPreferenceController> controllers = new ArrayList<>();
-        controllers.add(new DoubleTapPowerPreferenceController(context, lifecycle,
-                KEY_DOUBLE_TAP_POWER));
-        return controllers;
-    }
-
     public static final SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
             new BaseSearchIndexProvider() {
                 @Override
@@ -87,11 +70,5 @@
                     sir.xmlResId = R.xml.double_tap_power_settings;
                     return Arrays.asList(sir);
                 }
-
-                @Override
-                public List<AbstractPreferenceController> createPreferenceControllers(
-                        Context context) {
-                    return buildPreferenceControllers(context, null /* lifecycle */);
-                }
             };
 }
diff --git a/src/com/android/settings/gestures/DoubleTapScreenPreferenceController.java b/src/com/android/settings/gestures/DoubleTapScreenPreferenceController.java
index aa08e6f..00fb956 100644
--- a/src/com/android/settings/gestures/DoubleTapScreenPreferenceController.java
+++ b/src/com/android/settings/gestures/DoubleTapScreenPreferenceController.java
@@ -20,6 +20,7 @@
 import android.content.Context;
 import android.content.Intent;
 import android.content.SharedPreferences;
+import android.os.UserHandle;
 import android.provider.Settings;
 import android.support.v7.preference.Preference;
 import android.support.annotation.VisibleForTesting;
@@ -29,7 +30,6 @@
 import com.android.settings.search.DatabaseIndexingUtils;
 import com.android.settings.search.InlineSwitchPayload;
 import com.android.settings.search.ResultPayload;
-import com.android.settingslib.core.lifecycle.Lifecycle;
 
 import static android.provider.Settings.Secure.DOZE_PULSE_ON_DOUBLE_TAP;
 
@@ -43,18 +43,21 @@
 
     private final String SECURE_KEY = DOZE_PULSE_ON_DOUBLE_TAP;
 
-    private final AmbientDisplayConfiguration mAmbientConfig;
+    private AmbientDisplayConfiguration mAmbientConfig;
     @UserIdInt
     private final int mUserId;
 
-    public DoubleTapScreenPreferenceController(Context context, Lifecycle lifecycle,
-            AmbientDisplayConfiguration config, @UserIdInt int userId, String key) {
-        super(context, lifecycle);
-        mAmbientConfig = config;
-        mUserId = userId;
+    public DoubleTapScreenPreferenceController(Context context, String key) {
+        super(context, key);
+        mUserId = UserHandle.myUserId();
         mDoubleTapScreenPrefKey = key;
     }
 
+    public DoubleTapScreenPreferenceController setConfig(AmbientDisplayConfiguration config) {
+        mAmbientConfig = config;
+        return this;
+    }
+
     public static boolean isSuggestionComplete(Context context, SharedPreferences prefs) {
         return isSuggestionComplete(new AmbientDisplayConfiguration(context), prefs);
     }
@@ -67,20 +70,17 @@
     }
 
     @Override
-    public boolean isAvailable() {
-        return mAmbientConfig.pulseOnDoubleTapAvailable();
+    public int getAvailabilityStatus() {
+        if (mAmbientConfig == null) {
+            mAmbientConfig = new AmbientDisplayConfiguration(mContext);
+        }
+        return mAmbientConfig.pulseOnDoubleTapAvailable() ? AVAILABLE : DISABLED_UNSUPPORTED;
     }
 
     @Override
-    public String getPreferenceKey() {
-        return mDoubleTapScreenPrefKey;
-    }
-
-    @Override
-    public boolean onPreferenceChange(Preference preference, Object newValue) {
-        final boolean enabled = (boolean) newValue;
-        Settings.Secure.putInt(mContext.getContentResolver(), SECURE_KEY, enabled ? ON : OFF);
-        return true;
+    public boolean setChecked(boolean isChecked) {
+        return Settings.Secure.putInt(mContext.getContentResolver(), SECURE_KEY,
+                isChecked ? ON : OFF);
     }
 
     @Override
@@ -89,11 +89,12 @@
     }
 
     @Override
-    protected boolean isSwitchPrefEnabled() {
+    public boolean isChecked() {
         return mAmbientConfig.pulseOnDoubleTapEnabled(mUserId);
     }
 
     @Override
+    //TODO (b/69808376): Remove result payload
     public ResultPayload getResultPayload() {
         final Intent intent = DatabaseIndexingUtils.buildSearchResultPageIntent(mContext,
                 DoubleTapScreenSettings.class.getName(), mDoubleTapScreenPrefKey,
diff --git a/src/com/android/settings/gestures/DoubleTapScreenSettings.java b/src/com/android/settings/gestures/DoubleTapScreenSettings.java
index 1f0ff03..29e0a1a 100644
--- a/src/com/android/settings/gestures/DoubleTapScreenSettings.java
+++ b/src/com/android/settings/gestures/DoubleTapScreenSettings.java
@@ -28,8 +28,6 @@
 import com.android.settings.dashboard.suggestions.SuggestionFeatureProvider;
 import com.android.settings.overlay.FeatureFactory;
 import com.android.settings.search.BaseSearchIndexProvider;
-import com.android.settingslib.core.AbstractPreferenceController;
-import com.android.settingslib.core.lifecycle.Lifecycle;
 
 import java.util.ArrayList;
 import java.util.Arrays;
@@ -38,7 +36,6 @@
 public class DoubleTapScreenSettings extends DashboardFragment {
 
     private static final String TAG = "DoubleTapScreen";
-    private static final String KEY_DOUBLE_TAP_SCREEN = "gesture_double_tap_screen";
 
     public static final String PREF_KEY_SUGGESTION_COMPLETE =
             "pref_double_tap_screen_suggestion_complete";
@@ -50,6 +47,9 @@
                 .getSuggestionFeatureProvider(context);
         SharedPreferences prefs = suggestionFeatureProvider.getSharedPrefs(context);
         prefs.edit().putBoolean(PREF_KEY_SUGGESTION_COMPLETE, true).apply();
+
+        use(DoubleTapScreenPreferenceController.class)
+            .setConfig(new AmbientDisplayConfiguration(context));
     }
 
     @Override
@@ -72,20 +72,6 @@
         return R.string.help_url_double_tap_screen;
     }
 
-    @Override
-    protected List<AbstractPreferenceController> createPreferenceControllers(Context context) {
-        return buildPreferenceControllers(context, getLifecycle());
-    }
-
-    private static List<AbstractPreferenceController> buildPreferenceControllers(Context context,
-            Lifecycle lifecycle) {
-        final List<AbstractPreferenceController> controllers = new ArrayList<>();
-        controllers.add(new DoubleTapScreenPreferenceController(context, lifecycle,
-                new AmbientDisplayConfiguration(context), UserHandle.myUserId(),
-                KEY_DOUBLE_TAP_SCREEN));
-        return controllers;
-    }
-
     public static final SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
             new BaseSearchIndexProvider() {
                 @Override
@@ -95,11 +81,5 @@
                     sir.xmlResId = R.xml.double_tap_screen_settings;
                     return Arrays.asList(sir);
                 }
-
-                @Override
-                public List<AbstractPreferenceController> createPreferenceControllers(
-                        Context context) {
-                    return buildPreferenceControllers(context, null /* lifecycle */);
-                }
             };
 }
diff --git a/src/com/android/settings/gestures/DoubleTwistGestureSettings.java b/src/com/android/settings/gestures/DoubleTwistGestureSettings.java
index 69517fe..a3f37f0 100644
--- a/src/com/android/settings/gestures/DoubleTwistGestureSettings.java
+++ b/src/com/android/settings/gestures/DoubleTwistGestureSettings.java
@@ -26,17 +26,13 @@
 import com.android.settings.dashboard.suggestions.SuggestionFeatureProvider;
 import com.android.settings.overlay.FeatureFactory;
 import com.android.settings.search.BaseSearchIndexProvider;
-import com.android.settingslib.core.AbstractPreferenceController;
-import com.android.settingslib.core.lifecycle.Lifecycle;
 
-import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.List;
 
 public class DoubleTwistGestureSettings extends DashboardFragment {
 
     private static final String TAG = "DoubleTwistGesture";
-    private static final String KEY_DOUBLE_TWIST = "gesture_double_twist";
 
     public static final String PREF_KEY_SUGGESTION_COMPLETE =
             "pref_double_twist_suggestion_complete";
@@ -65,18 +61,6 @@
         return R.xml.double_twist_gesture_settings;
     }
 
-    @Override
-    protected List<AbstractPreferenceController> createPreferenceControllers(Context context) {
-        return buildPreferenceControllers(context, getLifecycle());
-    }
-
-    private static List<AbstractPreferenceController> buildPreferenceControllers(Context context,
-            Lifecycle lifecycle) {
-        final List<AbstractPreferenceController> controllers = new ArrayList<>();
-        controllers.add(new DoubleTwistPreferenceController(context, lifecycle, KEY_DOUBLE_TWIST));
-        return controllers;
-    }
-
     public static final SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
             new BaseSearchIndexProvider() {
                 @Override
@@ -86,11 +70,6 @@
                     sir.xmlResId = R.xml.double_twist_gesture_settings;
                     return Arrays.asList(sir);
                 }
-
-                @Override
-                public List<AbstractPreferenceController> createPreferenceControllers(Context context) {
-                    return buildPreferenceControllers(context, null /* lifecycle */);
-                }
             };
 
 }
diff --git a/src/com/android/settings/gestures/DoubleTwistPreferenceController.java b/src/com/android/settings/gestures/DoubleTwistPreferenceController.java
index 922f74b..f819508 100644
--- a/src/com/android/settings/gestures/DoubleTwistPreferenceController.java
+++ b/src/com/android/settings/gestures/DoubleTwistPreferenceController.java
@@ -25,12 +25,10 @@
 import android.os.UserManager;
 import android.provider.Settings;
 import android.support.annotation.VisibleForTesting;
-import android.support.v7.preference.Preference;
 import android.text.TextUtils;
 
 import com.android.settings.R;
 import com.android.settings.Utils;
-import com.android.settingslib.core.lifecycle.Lifecycle;
 
 public class DoubleTwistPreferenceController extends GesturePreferenceController {
 
@@ -41,8 +39,8 @@
     private final String mDoubleTwistPrefKey;
     private final UserManager mUserManager;
 
-    public DoubleTwistPreferenceController(Context context, Lifecycle lifecycle, String key) {
-        super(context, lifecycle);
+    public DoubleTwistPreferenceController(Context context, String key) {
+        super(context, key);
         mDoubleTwistPrefKey = key;
         mUserManager = (UserManager) context.getSystemService(Context.USER_SERVICE);
     }
@@ -69,8 +67,8 @@
     }
 
     @Override
-    public boolean isAvailable() {
-        return isGestureAvailable(mContext);
+    public int getAvailabilityStatus() {
+        return isGestureAvailable(mContext) ? AVAILABLE : DISABLED_UNSUPPORTED;
     }
 
     @Override
@@ -84,9 +82,8 @@
     }
 
     @Override
-    public boolean onPreferenceChange(Preference preference, Object newValue) {
-        final int enabled = (boolean) newValue ? ON : OFF;
-        setDoubleTwistPreference(mContext, mUserManager, enabled);
+    public boolean setChecked(boolean isChecked) {
+        setDoubleTwistPreference(mContext, mUserManager, isChecked ? ON : OFF);
         return true;
     }
 
@@ -97,12 +94,13 @@
         final int managedProfileUserId = getManagedProfileId(userManager);
         if (managedProfileUserId != UserHandle.USER_NULL) {
             Settings.Secure.putIntForUser(context.getContentResolver(),
-                Settings.Secure.CAMERA_DOUBLE_TWIST_TO_FLIP_ENABLED, enabled, managedProfileUserId);
+                    Settings.Secure.CAMERA_DOUBLE_TWIST_TO_FLIP_ENABLED, enabled,
+                    managedProfileUserId);
         }
     }
 
     @Override
-    protected boolean isSwitchPrefEnabled() {
+    public boolean isChecked() {
         final int doubleTwistEnabled = Settings.Secure.getInt(mContext.getContentResolver(),
                 Settings.Secure.CAMERA_DOUBLE_TWIST_TO_FLIP_ENABLED, ON);
         return doubleTwistEnabled != 0;
diff --git a/src/com/android/settings/gestures/GesturePreferenceController.java b/src/com/android/settings/gestures/GesturePreferenceController.java
index a7f8997..7f1100b 100644
--- a/src/com/android/settings/gestures/GesturePreferenceController.java
+++ b/src/com/android/settings/gestures/GesturePreferenceController.java
@@ -24,19 +24,17 @@
 import android.support.v7.preference.TwoStatePreference;
 
 import com.android.settings.R;
-import com.android.settings.core.PreferenceControllerMixin;
+import com.android.settings.core.TogglePreferenceController;
 import com.android.settings.widget.VideoPreference;
-import com.android.settingslib.core.AbstractPreferenceController;
-import com.android.settingslib.core.lifecycle.Lifecycle;
 import com.android.settingslib.core.lifecycle.LifecycleObserver;
 import com.android.settingslib.core.lifecycle.events.OnCreate;
 import com.android.settingslib.core.lifecycle.events.OnPause;
 import com.android.settingslib.core.lifecycle.events.OnResume;
 import com.android.settingslib.core.lifecycle.events.OnSaveInstanceState;
 
-public abstract class GesturePreferenceController extends AbstractPreferenceController
-        implements PreferenceControllerMixin, Preference.OnPreferenceChangeListener,
-        LifecycleObserver, OnResume, OnPause, OnCreate, OnSaveInstanceState  {
+public abstract class GesturePreferenceController extends TogglePreferenceController
+        implements Preference.OnPreferenceChangeListener,
+        LifecycleObserver, OnResume, OnPause, OnCreate, OnSaveInstanceState {
 
     @VisibleForTesting
     static final String KEY_VIDEO_PAUSED = "key_video_paused";
@@ -45,11 +43,8 @@
     @VisibleForTesting
     boolean mVideoPaused;
 
-    public GesturePreferenceController(Context context, Lifecycle lifecycle) {
-        super(context);
-        if (lifecycle != null) {
-            lifecycle.addObserver(this);
-        }
+    public GesturePreferenceController(Context context, String key) {
+        super(context, key);
     }
 
     @Override
@@ -63,14 +58,9 @@
     @Override
     public void updateState(Preference preference) {
         super.updateState(preference);
-        final boolean isEnabled = isSwitchPrefEnabled();
         if (preference != null) {
-            if (preference instanceof TwoStatePreference) {
-                ((TwoStatePreference) preference).setChecked(isEnabled);
-            } else {
-                preference.setSummary(isEnabled
-                        ? R.string.gesture_setting_on
-                        : R.string.gesture_setting_off);
+            if (!(preference instanceof TwoStatePreference)) {
+                preference.setSummary(getSummary());
             }
             // Different meanings of "Enabled" for the Preference and Controller.
             preference.setEnabled(canHandleClicks());
@@ -78,6 +68,12 @@
     }
 
     @Override
+    public CharSequence getSummary() {
+        return mContext.getText(
+                isChecked() ? R.string.gesture_setting_on : R.string.gesture_setting_off);
+    }
+
+    @Override
     public void onCreate(Bundle savedInstanceState) {
         if (savedInstanceState != null) {
             mVideoPaused = savedInstanceState.getBoolean(KEY_VIDEO_PAUSED, false);
@@ -106,8 +102,6 @@
 
     protected abstract String getVideoPrefKey();
 
-    protected abstract boolean isSwitchPrefEnabled();
-
     protected boolean canHandleClicks() {
         return true;
     }
diff --git a/src/com/android/settings/gestures/GestureSettings.java b/src/com/android/settings/gestures/GestureSettings.java
index b3f8b79..f6fe82c 100644
--- a/src/com/android/settings/gestures/GestureSettings.java
+++ b/src/com/android/settings/gestures/GestureSettings.java
@@ -65,33 +65,32 @@
 
     @Override
     protected List<AbstractPreferenceController> createPreferenceControllers(Context context) {
-        if (mAmbientDisplayConfig == null) {
-            mAmbientDisplayConfig = new AmbientDisplayConfiguration(context);
-        }
-
-        return buildPreferenceControllers(context, getLifecycle(), mAmbientDisplayConfig);
+        return buildPreferenceControllers(context, getLifecycle());
     }
 
     static List<AbstractPreferenceController> buildPreferenceControllers(
-            @NonNull Context context, @Nullable Lifecycle lifecycle,
-            @NonNull AmbientDisplayConfiguration ambientDisplayConfiguration) {
+            @NonNull Context context, @Nullable Lifecycle lifecycle) {
         final List<AbstractPreferenceController> controllers = new ArrayList<>();
-        controllers.add(new AssistGestureSettingsPreferenceController(context, lifecycle,
-                KEY_ASSIST, false /* assistOnly */));
-        controllers.add(new SwipeToNotificationPreferenceController(context, lifecycle,
-                KEY_SWIPE_DOWN));
-        controllers.add(new DoubleTwistPreferenceController(context, lifecycle, KEY_DOUBLE_TWIST));
-        controllers.add(new DoubleTapPowerPreferenceController(context, lifecycle,
-                KEY_DOUBLE_TAP_POWER));
-        controllers.add(new PickupGesturePreferenceController(context, lifecycle,
-                ambientDisplayConfiguration, UserHandle.myUserId(), KEY_PICK_UP));
-        controllers.add(new DoubleTapScreenPreferenceController(context, lifecycle,
-                ambientDisplayConfiguration, UserHandle.myUserId(), KEY_DOUBLE_TAP_SCREEN));
         controllers.add(new PreventRingingPreferenceController(
                 context, lifecycle, UserHandle.myUserId(), KEY_PREVENT_RINGING));
         return controllers;
     }
 
+    @Override
+    public void onAttach(Context context) {
+        super.onAttach(context);
+        use(AssistGestureSettingsPreferenceController.class).setAssistOnly(false);
+        use(PickupGesturePreferenceController.class).setConfig(getConfig(context));
+        use(DoubleTapScreenPreferenceController.class).setConfig(getConfig(context));
+    }
+
+    private AmbientDisplayConfiguration getConfig(Context context) {
+        if (mAmbientDisplayConfig == null) {
+            mAmbientDisplayConfig = new AmbientDisplayConfiguration(context);
+        }
+        return mAmbientDisplayConfig;
+    }
+
     public static final SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
             new BaseSearchIndexProvider() {
                 @Override
@@ -105,8 +104,7 @@
                 @Override
                 public List<AbstractPreferenceController> createPreferenceControllers(
                         Context context) {
-                    return buildPreferenceControllers(context, null,
-                            new AmbientDisplayConfiguration(context));
+                    return buildPreferenceControllers(context, null);
                 }
 
                 @Override
diff --git a/src/com/android/settings/gestures/GesturesSettingPreferenceController.java b/src/com/android/settings/gestures/GesturesSettingPreferenceController.java
index 1df5b90..e4e24d8 100644
--- a/src/com/android/settings/gestures/GesturesSettingPreferenceController.java
+++ b/src/com/android/settings/gestures/GesturesSettingPreferenceController.java
@@ -19,6 +19,7 @@
 import android.content.ContentResolver;
 import android.content.Context;
 import android.provider.Settings;
+import android.support.annotation.NonNull;
 
 import com.android.internal.hardware.AmbientDisplayConfiguration;
 import com.android.settings.R;
@@ -33,6 +34,7 @@
     private List<AbstractPreferenceController> mGestureControllers;
 
     private static final String KEY_GESTURES_SETTINGS = "gesture_settings";
+    private static final String FAKE_PREF_KEY = "fake_key_only_for_get_available";
 
     public GesturesSettingPreferenceController(Context context) {
         super(context, KEY_GESTURES_SETTINGS);
@@ -42,16 +44,38 @@
     @Override
     public int getAvailabilityStatus() {
         if (mGestureControllers == null) {
-            mGestureControllers = GestureSettings.buildPreferenceControllers(mContext,
-                    null /* lifecycle */, new AmbientDisplayConfiguration(mContext));
+            mGestureControllers = buildAllPreferenceControllers(mContext);
         }
         boolean isAvailable = false;
         for (AbstractPreferenceController controller : mGestureControllers) {
             isAvailable = isAvailable || controller.isAvailable();
         }
-        return isAvailable
-                ? AVAILABLE
-                : DISABLED_UNSUPPORTED;
+        return isAvailable ? AVAILABLE : DISABLED_UNSUPPORTED;
+    }
+
+    /**
+     * Get all controllers for their availability status when doing getAvailabilityStatus.
+     * Do not use this method to add controllers into fragment, most of below controllers already
+     * convert to TogglePreferenceController, please register them in xml.
+     * The key is fake because those controllers won't be use to control preference.
+     */
+    private static List<AbstractPreferenceController> buildAllPreferenceControllers(
+            @NonNull Context context) {
+        final AmbientDisplayConfiguration ambientDisplayConfiguration =
+                new AmbientDisplayConfiguration(context);
+        final List<AbstractPreferenceController> controllers =
+                GestureSettings.buildPreferenceControllers(context, null);
+
+        controllers.add(new AssistGestureSettingsPreferenceController(context, FAKE_PREF_KEY)
+                .setAssistOnly(false));
+        controllers.add(new SwipeToNotificationPreferenceController(context, FAKE_PREF_KEY));
+        controllers.add(new DoubleTwistPreferenceController(context, FAKE_PREF_KEY));
+        controllers.add(new DoubleTapPowerPreferenceController(context, FAKE_PREF_KEY));
+        controllers.add(new PickupGesturePreferenceController(context, FAKE_PREF_KEY)
+                .setConfig(ambientDisplayConfiguration));
+        controllers.add(new DoubleTapScreenPreferenceController(context, FAKE_PREF_KEY)
+                .setConfig(ambientDisplayConfiguration));
+        return controllers;
     }
 
     @Override
diff --git a/src/com/android/settings/gestures/PickupGesturePreferenceController.java b/src/com/android/settings/gestures/PickupGesturePreferenceController.java
index 02107c1..46318f5 100644
--- a/src/com/android/settings/gestures/PickupGesturePreferenceController.java
+++ b/src/com/android/settings/gestures/PickupGesturePreferenceController.java
@@ -22,8 +22,8 @@
 import android.content.Context;
 import android.content.Intent;
 import android.content.SharedPreferences;
+import android.os.UserHandle;
 import android.provider.Settings;
-import android.support.v7.preference.Preference;
 import android.support.annotation.VisibleForTesting;
 
 import com.android.internal.hardware.AmbientDisplayConfiguration;
@@ -31,7 +31,6 @@
 import com.android.settings.search.DatabaseIndexingUtils;
 import com.android.settings.search.InlineSwitchPayload;
 import com.android.settings.search.ResultPayload;
-import com.android.settingslib.core.lifecycle.Lifecycle;
 
 public class PickupGesturePreferenceController extends GesturePreferenceController {
 
@@ -43,18 +42,21 @@
 
     private final String SECURE_KEY = DOZE_PULSE_ON_PICK_UP;
 
-    private final AmbientDisplayConfiguration mAmbientConfig;
+    private AmbientDisplayConfiguration mAmbientConfig;
     @UserIdInt
     private final int mUserId;
 
-    public PickupGesturePreferenceController(Context context, Lifecycle lifecycle,
-            AmbientDisplayConfiguration config, @UserIdInt int userId, String key) {
-        super(context, lifecycle);
-        mAmbientConfig = config;
-        mUserId = userId;
+    public PickupGesturePreferenceController(Context context, String key) {
+        super(context, key);
+        mUserId = UserHandle.myUserId();
         mPickUpPrefKey = key;
     }
 
+    public PickupGesturePreferenceController setConfig(AmbientDisplayConfiguration config) {
+        mAmbientConfig = config;
+        return this;
+    }
+
     public static boolean isSuggestionComplete(Context context, SharedPreferences prefs) {
         AmbientDisplayConfiguration ambientConfig = new AmbientDisplayConfiguration(context);
         return prefs.getBoolean(PickupGestureSettings.PREF_KEY_SUGGESTION_COMPLETE, false)
@@ -62,8 +64,11 @@
     }
 
     @Override
-    public boolean isAvailable() {
-        return mAmbientConfig.pulseOnPickupAvailable();
+    public int getAvailabilityStatus() {
+        if (mAmbientConfig == null) {
+            mAmbientConfig = new AmbientDisplayConfiguration(mContext);
+        }
+        return mAmbientConfig.pulseOnPickupAvailable() ? AVAILABLE : DISABLED_UNSUPPORTED;
     }
 
     @Override
@@ -72,7 +77,7 @@
     }
 
     @Override
-    protected boolean isSwitchPrefEnabled() {
+    public boolean isChecked() {
         return mAmbientConfig.pulseOnPickupEnabled(mUserId);
     }
 
@@ -82,11 +87,9 @@
     }
 
     @Override
-    public boolean onPreferenceChange(Preference preference, Object newValue) {
-        final boolean enabled = (boolean) newValue;
-        Settings.Secure.putInt(mContext.getContentResolver(),
-                SECURE_KEY, enabled ? ON : OFF);
-        return true;
+    public boolean setChecked(boolean isChecked) {
+        return Settings.Secure.putInt(mContext.getContentResolver(), SECURE_KEY,
+                isChecked ? ON : OFF);
     }
 
     @Override
diff --git a/src/com/android/settings/gestures/PickupGestureSettings.java b/src/com/android/settings/gestures/PickupGestureSettings.java
index 78ae9c4..8f4e7b3 100644
--- a/src/com/android/settings/gestures/PickupGestureSettings.java
+++ b/src/com/android/settings/gestures/PickupGestureSettings.java
@@ -18,7 +18,6 @@
 
 import android.content.Context;
 import android.content.SharedPreferences;
-import android.os.UserHandle;
 import android.provider.SearchIndexableResource;
 
 import com.android.internal.hardware.AmbientDisplayConfiguration;
@@ -28,17 +27,13 @@
 import com.android.settings.dashboard.suggestions.SuggestionFeatureProvider;
 import com.android.settings.overlay.FeatureFactory;
 import com.android.settings.search.BaseSearchIndexProvider;
-import com.android.settingslib.core.AbstractPreferenceController;
-import com.android.settingslib.core.lifecycle.Lifecycle;
 
-import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.List;
 
 public class PickupGestureSettings extends DashboardFragment {
 
     private static final String TAG = "PickupGestureSettings";
-    private static final String KEY_PICK_UP = "gesture_pick_up";
 
     public static final String PREF_KEY_SUGGESTION_COMPLETE =
             "pref_pickup_gesture_suggestion_complete";
@@ -50,6 +45,9 @@
                 .getSuggestionFeatureProvider(context);
         SharedPreferences prefs = suggestionFeatureProvider.getSharedPrefs(context);
         prefs.edit().putBoolean(PREF_KEY_SUGGESTION_COMPLETE, true).apply();
+
+        use(PickupGesturePreferenceController.class)
+            .setConfig(new AmbientDisplayConfiguration(context));
     }
 
     @Override
@@ -72,19 +70,6 @@
         return R.string.help_url_pickup_gesture;
     }
 
-    @Override
-    protected List<AbstractPreferenceController> createPreferenceControllers(Context context) {
-        return buildPreferenceControllers(context, getLifecycle());
-    }
-
-    private static List<AbstractPreferenceController> buildPreferenceControllers(Context context,
-            Lifecycle lifecycle) {
-        final List<AbstractPreferenceController> controllers = new ArrayList<>();
-        controllers.add(new PickupGesturePreferenceController(context, lifecycle,
-                new AmbientDisplayConfiguration(context), UserHandle.myUserId(), KEY_PICK_UP));
-        return controllers;
-    }
-
     public static final SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
             new BaseSearchIndexProvider() {
                 @Override
@@ -94,12 +79,6 @@
                     sir.xmlResId = R.xml.pick_up_gesture_settings;
                     return Arrays.asList(sir);
                 }
-
-                @Override
-                public List<AbstractPreferenceController> createPreferenceControllers(
-                        Context context) {
-                    return buildPreferenceControllers(context, null /* lifecycle */);
-                }
             };
 
 }
diff --git a/src/com/android/settings/gestures/SwipeToNotificationPreferenceController.java b/src/com/android/settings/gestures/SwipeToNotificationPreferenceController.java
index b50968f..d755d72 100644
--- a/src/com/android/settings/gestures/SwipeToNotificationPreferenceController.java
+++ b/src/com/android/settings/gestures/SwipeToNotificationPreferenceController.java
@@ -21,10 +21,8 @@
 import android.content.Context;
 import android.content.SharedPreferences;
 import android.provider.Settings;
-import android.support.v7.preference.Preference;
 
 import com.android.settings.Utils;
-import com.android.settingslib.core.lifecycle.Lifecycle;
 
 public class SwipeToNotificationPreferenceController extends GesturePreferenceController {
 
@@ -32,14 +30,11 @@
     private static final int OFF = 0;
 
     private static final String PREF_KEY_VIDEO = "gesture_swipe_down_fingerprint_video";
-    private final String mSwipeDownFingerPrefKey;
 
     private static final String SECURE_KEY = SYSTEM_NAVIGATION_KEYS_ENABLED;
 
-    public SwipeToNotificationPreferenceController(Context context, Lifecycle lifecycle,
-            String key) {
-        super(context, lifecycle);
-        mSwipeDownFingerPrefKey = key;
+    public SwipeToNotificationPreferenceController(Context context, String key) {
+        super(context, key);
     }
 
     public static boolean isSuggestionComplete(Context context, SharedPreferences prefs) {
@@ -55,28 +50,23 @@
     }
 
     @Override
-    public String getPreferenceKey() {
-        return mSwipeDownFingerPrefKey;
-    }
-
-    @Override
     protected String getVideoPrefKey() {
         return PREF_KEY_VIDEO;
     }
 
     @Override
-    public boolean isAvailable() {
-        return SwipeToNotificationPreferenceController.isAvailable(mContext);
+    public int getAvailabilityStatus() {
+        return isAvailable(mContext) ? AVAILABLE : DISABLED_UNSUPPORTED;
     }
 
     @Override
-    public boolean onPreferenceChange(Preference preference, Object newValue) {
-        setSwipeToNotification(mContext, (boolean) newValue);
+    public boolean setChecked(boolean isChecked) {
+        setSwipeToNotification(mContext, isChecked);
         return true;
     }
 
     @Override
-    protected boolean isSwitchPrefEnabled() {
+    public boolean isChecked() {
         return isSwipeToNotificationOn(mContext);
     }
 
diff --git a/src/com/android/settings/gestures/SwipeToNotificationSettings.java b/src/com/android/settings/gestures/SwipeToNotificationSettings.java
index 9ddf0d4..c18289c 100644
--- a/src/com/android/settings/gestures/SwipeToNotificationSettings.java
+++ b/src/com/android/settings/gestures/SwipeToNotificationSettings.java
@@ -26,10 +26,7 @@
 import com.android.settings.dashboard.suggestions.SuggestionFeatureProvider;
 import com.android.settings.overlay.FeatureFactory;
 import com.android.settings.search.BaseSearchIndexProvider;
-import com.android.settingslib.core.AbstractPreferenceController;
-import com.android.settingslib.core.lifecycle.Lifecycle;
 
-import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.List;
 
@@ -37,8 +34,6 @@
 
     private static final String TAG = "SwipeToNotifSettings";
 
-    private static final String KEY = "gesture_swipe_down_fingerprint";
-
     public static final String PREF_KEY_SUGGESTION_COMPLETE =
             "pref_swipe_to_notification_suggestion_complete";
 
@@ -66,18 +61,6 @@
         return R.xml.swipe_to_notification_settings;
     }
 
-    @Override
-    protected List<AbstractPreferenceController> createPreferenceControllers(Context context) {
-        return buildPreferenceControllers(context, getLifecycle());
-    }
-
-    private static List<AbstractPreferenceController> buildPreferenceControllers(Context context,
-            Lifecycle lifecycle) {
-        final List<AbstractPreferenceController> controllers = new ArrayList<>();
-        controllers.add(new SwipeToNotificationPreferenceController(context, lifecycle, KEY));
-        return controllers;
-    }
-
     public static final SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
             new BaseSearchIndexProvider() {
                 @Override
@@ -87,11 +70,5 @@
                     sir.xmlResId = R.xml.swipe_to_notification_settings;
                     return Arrays.asList(sir);
                 }
-
-                @Override
-                public List<AbstractPreferenceController> createPreferenceControllers(
-                        Context context) {
-                    return buildPreferenceControllers(context, null /* lifecycle */);
-                }
             };
 }
diff --git a/src/com/android/settings/notification/ConfigureNotificationSettings.java b/src/com/android/settings/notification/ConfigureNotificationSettings.java
index 26c1bc8..c9aa19d 100644
--- a/src/com/android/settings/notification/ConfigureNotificationSettings.java
+++ b/src/com/android/settings/notification/ConfigureNotificationSettings.java
@@ -106,8 +106,6 @@
         }
         controllers.add(new RecentNotifyingAppsPreferenceController(
                 context, new NotificationBackend(), app, host));
-        controllers.add(new SwipeToNotificationPreferenceController(context, lifecycle,
-                KEY_SWIPE_DOWN));
         controllers.add(badgeController);
         controllers.add(pulseController);
         controllers.add(lockScreenNotificationController);
diff --git a/tests/robotests/assets/grandfather_slice_controller_not_in_xml b/tests/robotests/assets/grandfather_slice_controller_not_in_xml
index ae1c86a..5a09997 100644
--- a/tests/robotests/assets/grandfather_slice_controller_not_in_xml
+++ b/tests/robotests/assets/grandfather_slice_controller_not_in_xml
@@ -1,2 +1,2 @@
 com.android.settings.testutils.FakeToggleController
-com.android.settings.testutils.FakeSliderController
+com.android.settings.testutils.FakeSliderController
\ No newline at end of file
diff --git a/tests/robotests/src/com/android/settings/display/AmbientDisplaySettingsTest.java b/tests/robotests/src/com/android/settings/display/AmbientDisplaySettingsTest.java
index 2f61252..4361b7c 100644
--- a/tests/robotests/src/com/android/settings/display/AmbientDisplaySettingsTest.java
+++ b/tests/robotests/src/com/android/settings/display/AmbientDisplaySettingsTest.java
@@ -24,6 +24,8 @@
 
 import android.content.Context;
 
+import com.android.settings.gestures.DoubleTapScreenPreferenceController;
+import com.android.settings.gestures.PickupGesturePreferenceController;
 import com.android.settings.testutils.SettingsRobolectricTestRunner;
 import com.android.settingslib.core.AbstractPreferenceController;
 
@@ -48,18 +50,48 @@
     }
 
     @Test
-    public void onAttach_shouldInvokeSetters() {
-        final AmbientDisplayAlwaysOnPreferenceController controller = mock(
-                AmbientDisplayAlwaysOnPreferenceController.class);
+    public void onAttach_alwaysOn_shouldInvokeSetters() {
+        final AmbientDisplayAlwaysOnPreferenceController controller = spy(
+                new AmbientDisplayAlwaysOnPreferenceController(mContext, "key"));
         doReturn(controller).when(mTestFragment).use(
                 AmbientDisplayAlwaysOnPreferenceController.class);
 
         mTestFragment.onAttach(mContext);
-
         verify(controller).setConfig(any());
         verify(controller).setCallback(any());
     }
 
+    @Test
+    public void onAttach_notifications_shouldInvokeSetters() {
+        final AmbientDisplayNotificationsPreferenceController controller = spy(
+                new AmbientDisplayNotificationsPreferenceController(mContext, "key"));
+        doReturn(controller).when(mTestFragment).use(
+                AmbientDisplayNotificationsPreferenceController.class);
+
+        mTestFragment.onAttach(mContext);
+        verify(controller).setConfig(any());
+    }
+
+    @Test
+    public void onAttach_doubleTap_shouldInvokeSetters() {
+        final DoubleTapScreenPreferenceController controller = spy(
+                new DoubleTapScreenPreferenceController(mContext, "key"));
+        doReturn(controller).when(mTestFragment).use(DoubleTapScreenPreferenceController.class);
+
+        mTestFragment.onAttach(mContext);
+        verify(controller).setConfig(any());
+    }
+
+    @Test
+    public void onAttach_pickUp_shouldInvokeSetters() {
+        final PickupGesturePreferenceController controller = spy(
+                new PickupGesturePreferenceController(mContext, "key"));
+        doReturn(controller).when(mTestFragment).use(PickupGesturePreferenceController.class);
+
+        mTestFragment.onAttach(mContext);
+        verify(controller).setConfig(any());
+    }
+
     public static class TestFragment extends AmbientDisplaySettings {
         @Override
         protected <T extends AbstractPreferenceController> T use(Class<T> clazz) {
diff --git a/tests/robotests/src/com/android/settings/gestures/AssistGestureSettingsPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/gestures/AssistGestureSettingsPreferenceControllerTest.java
index 3b5facd..bd96f0f 100644
--- a/tests/robotests/src/com/android/settings/gestures/AssistGestureSettingsPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/gestures/AssistGestureSettingsPreferenceControllerTest.java
@@ -55,8 +55,8 @@
     public void setUp() {
         MockitoAnnotations.initMocks(this);
         mFactory = FakeFeatureFactory.setupForTest();
-        mController =
-            new AssistGestureSettingsPreferenceController(mContext, null, KEY_ASSIST, false);
+        mController = new AssistGestureSettingsPreferenceController(mContext, KEY_ASSIST);
+        mController.setAssistOnly(false);
     }
 
     @Test
@@ -76,8 +76,8 @@
     public void testPreferenceController_ProperResultPayloadType() {
         final Context context = RuntimeEnvironment.application;
         AssistGestureSettingsPreferenceController controller =
-                new AssistGestureSettingsPreferenceController(context, null /* lifecycle */,
-                        KEY_ASSIST, false /* assistOnly */);
+                new AssistGestureSettingsPreferenceController(context, KEY_ASSIST);
+        controller.setAssistOnly(false);
         ResultPayload payload = controller.getResultPayload();
         assertThat(payload).isInstanceOf(InlineSwitchPayload.class);
     }
diff --git a/tests/robotests/src/com/android/settings/gestures/DoubleTapPowerPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/gestures/DoubleTapPowerPreferenceControllerTest.java
index e8c036e..d681bc3 100644
--- a/tests/robotests/src/com/android/settings/gestures/DoubleTapPowerPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/gestures/DoubleTapPowerPreferenceControllerTest.java
@@ -56,7 +56,7 @@
     public void setUp() {
         mContext = RuntimeEnvironment.application;
         mContentResolver = mContext.getContentResolver();
-        mController = new DoubleTapPowerPreferenceController(mContext, null, KEY_DOUBLE_TAP_POWER);
+        mController = new DoubleTapPowerPreferenceController(mContext, KEY_DOUBLE_TAP_POWER);
     }
 
     @After
@@ -81,28 +81,27 @@
     }
 
     @Test
-    public void testSwitchEnabled_configIsNotSet_shouldReturnTrue() {
+    public void testIsChecked_configIsNotSet_shouldReturnTrue() {
         // Set the setting to be enabled.
         Settings.System.putInt(mContentResolver, CAMERA_DOUBLE_TAP_POWER_GESTURE_DISABLED, ON);
-        mController = new DoubleTapPowerPreferenceController(mContext, null, KEY_DOUBLE_TAP_POWER);
+        mController = new DoubleTapPowerPreferenceController(mContext, KEY_DOUBLE_TAP_POWER);
 
-        assertThat(mController.isSwitchPrefEnabled()).isTrue();
+        assertThat(mController.isChecked()).isTrue();
     }
 
     @Test
-    public void testSwitchEnabled_configIsSet_shouldReturnFalse() {
+    public void testIsChecked_configIsSet_shouldReturnFalse() {
         // Set the setting to be disabled.
         Settings.System.putInt(mContentResolver, CAMERA_DOUBLE_TAP_POWER_GESTURE_DISABLED, OFF);
-        mController = new DoubleTapPowerPreferenceController(mContext, null, KEY_DOUBLE_TAP_POWER);
+        mController = new DoubleTapPowerPreferenceController(mContext, KEY_DOUBLE_TAP_POWER);
 
-        assertThat(mController.isSwitchPrefEnabled()).isFalse();
+        assertThat(mController.isChecked()).isFalse();
     }
 
     @Test
     public void testPreferenceController_ProperResultPayloadType() {
         DoubleTapPowerPreferenceController controller =
-            new DoubleTapPowerPreferenceController(mContext, null /* lifecycle */,
-                KEY_DOUBLE_TAP_POWER);
+            new DoubleTapPowerPreferenceController(mContext, KEY_DOUBLE_TAP_POWER);
         ResultPayload payload = controller.getResultPayload();
         assertThat(payload).isInstanceOf(InlineSwitchPayload.class);
     }
diff --git a/tests/robotests/src/com/android/settings/gestures/DoubleTapScreenPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/gestures/DoubleTapScreenPreferenceControllerTest.java
index 344156c..cc9347d 100644
--- a/tests/robotests/src/com/android/settings/gestures/DoubleTapScreenPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/gestures/DoubleTapScreenPreferenceControllerTest.java
@@ -56,8 +56,8 @@
     @Before
     public void setUp() {
         MockitoAnnotations.initMocks(this);
-        mController = new DoubleTapScreenPreferenceController(
-                mContext, null, mAmbientDisplayConfiguration, 0, KEY_DOUBLE_TAP_SCREEN);
+        mController = new DoubleTapScreenPreferenceController(mContext, KEY_DOUBLE_TAP_SCREEN);
+        mController.setConfig(mAmbientDisplayConfiguration);
     }
 
     @Test
@@ -75,26 +75,26 @@
     }
 
     @Test
-    public void testSwitchEnabled_configIsSet_shouldReturnTrue() {
+    public void testIsChecked_configIsSet_shouldReturnTrue() {
         // Set the setting to be enabled.
         when(mAmbientDisplayConfiguration.pulseOnDoubleTapEnabled(anyInt())).thenReturn(true);
 
-        assertThat(mController.isSwitchPrefEnabled()).isTrue();
+        assertThat(mController.isChecked()).isTrue();
     }
 
     @Test
-    public void testSwitchEnabled_configIsNotSet_shouldReturnFalse() {
+    public void testIsChecked_configIsNotSet_shouldReturnFalse() {
         when(mAmbientDisplayConfiguration.pulseOnDoubleTapEnabled(anyInt())).thenReturn(false);
 
-        assertThat(mController.isSwitchPrefEnabled()).isFalse();
+        assertThat(mController.isChecked()).isFalse();
     }
 
     @Test
     public void testPreferenceController_ProperResultPayloadType() {
         final Context context = RuntimeEnvironment.application;
         DoubleTapScreenPreferenceController controller =
-                new DoubleTapScreenPreferenceController(context, null /* lifecycle */,
-                        mAmbientDisplayConfiguration, 0 /* userid */, KEY_DOUBLE_TAP_SCREEN);
+                new DoubleTapScreenPreferenceController(context, KEY_DOUBLE_TAP_SCREEN);
+        controller.setConfig(mAmbientDisplayConfiguration);
         ResultPayload payload = controller.getResultPayload();
         assertThat(payload).isInstanceOf(InlineSwitchPayload.class);
     }
diff --git a/tests/robotests/src/com/android/settings/gestures/DoubleTwistPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/gestures/DoubleTwistPreferenceControllerTest.java
index d633ebe..901da37 100644
--- a/tests/robotests/src/com/android/settings/gestures/DoubleTwistPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/gestures/DoubleTwistPreferenceControllerTest.java
@@ -61,7 +61,7 @@
     public void setUp() {
         MockitoAnnotations.initMocks(this);
         when(mContext.getSystemService(Context.USER_SERVICE)).thenReturn(mock(UserManager.class));
-        mController = new DoubleTwistPreferenceController(mContext, null, KEY_DOUBLE_TWIST);
+        mController = new DoubleTwistPreferenceController(mContext, KEY_DOUBLE_TWIST);
     }
 
     @After
@@ -120,7 +120,7 @@
         Settings.Secure.putIntForUser(
                 null, Settings.Secure.CAMERA_DOUBLE_TWIST_TO_FLIP_ENABLED, 0, managedId);
         DoubleTwistPreferenceController controller =
-                spy(new DoubleTwistPreferenceController(mContext, null, KEY_DOUBLE_TWIST));
+                spy(new DoubleTwistPreferenceController(mContext, KEY_DOUBLE_TWIST));
         ShadowDoubleTwistPreferenceController.setManagedProfileId(managedId);
 
         // enable the gesture
@@ -135,24 +135,24 @@
     }
 
     @Test
-    public void testSwitchEnabled_configIsSet_shouldReturnTrue() {
+    public void testIsChecked_configIsSet_shouldReturnTrue() {
         // Set the setting to be enabled.
         final Context context = RuntimeEnvironment.application;
         Settings.System.putInt(context.getContentResolver(),
                 Settings.Secure.CAMERA_DOUBLE_TWIST_TO_FLIP_ENABLED, 1);
-        mController = new DoubleTwistPreferenceController(context, null, KEY_DOUBLE_TWIST);
+        mController = new DoubleTwistPreferenceController(context, KEY_DOUBLE_TWIST);
 
-        assertThat(mController.isSwitchPrefEnabled()).isTrue();
+        assertThat(mController.isChecked()).isTrue();
     }
 
     @Test
-    public void testSwitchEnabled_configIsNotSet_shouldReturnFalse() {
+    public void testIsChecked_configIsNotSet_shouldReturnFalse() {
         // Set the setting to be disabled.
         final Context context = RuntimeEnvironment.application;
         Settings.System.putInt(context.getContentResolver(),
                 Settings.Secure.CAMERA_DOUBLE_TWIST_TO_FLIP_ENABLED, 0);
-        mController = new DoubleTwistPreferenceController(context, null, KEY_DOUBLE_TWIST);
+        mController = new DoubleTwistPreferenceController(context, KEY_DOUBLE_TWIST);
 
-        assertThat(mController.isSwitchPrefEnabled()).isFalse();
+        assertThat(mController.isChecked()).isFalse();
     }
 }
diff --git a/tests/robotests/src/com/android/settings/gestures/GesturePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/gestures/GesturePreferenceControllerTest.java
index 361c95d..d4b7706 100644
--- a/tests/robotests/src/com/android/settings/gestures/GesturePreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/gestures/GesturePreferenceControllerTest.java
@@ -17,6 +17,9 @@
 package com.android.settings.gestures;
 
 import static com.google.common.truth.Truth.assertThat;
+
+import static junit.framework.Assert.assertEquals;
+
 import static org.mockito.Matchers.anyString;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.reset;
@@ -31,7 +34,6 @@
 
 import com.android.settings.testutils.SettingsRobolectricTestRunner;
 import com.android.settings.widget.VideoPreference;
-import com.android.settingslib.core.lifecycle.Lifecycle;
 
 import org.junit.Before;
 import org.junit.Test;
@@ -49,7 +51,6 @@
     @Mock(answer = Answers.RETURNS_DEEP_STUBS)
     private PreferenceScreen mScreen;
     @Mock(answer = Answers.RETURNS_DEEP_STUBS)
-    private Lifecycle mLifecycle;
 
     private TestPrefController mController;
     private Preference mPreference;
@@ -57,7 +58,7 @@
     @Before
     public void setUp() {
         MockitoAnnotations.initMocks(this);
-        mController = new TestPrefController(mContext, mLifecycle);
+        mController = new TestPrefController(mContext, "testKey");
         mPreference = new Preference(RuntimeEnvironment.application);
         mPreference.setKey(mController.getPreferenceKey());
         when(mScreen.findPreference(mPreference.getKey())).thenReturn(mPreference);
@@ -187,7 +188,8 @@
         mController.updateState(preference);
 
         // Verify summary is set to off (as setting is disabled).
-        verify(preference).setSummary(com.android.settings.R.string.gesture_setting_off);
+        assertThat(preference.getSummary()).isEqualTo(
+                mContext.getString(com.android.settings.R.string.gesture_setting_off));
     }
 
     private class TestPrefController extends GesturePreferenceController {
@@ -196,18 +198,13 @@
         boolean mIsPrefEnabled;
 
         private TestPrefController(Context context,
-                Lifecycle lifecycle) {
-            super(context, lifecycle);
+                String key) {
+            super(context, key);
         }
 
         @Override
-        public boolean isAvailable() {
-            return mIsPrefAvailable;
-        }
-
-        @Override
-        public String getPreferenceKey() {
-            return "testKey";
+        public int getAvailabilityStatus() {
+            return mIsPrefAvailable ? AVAILABLE : DISABLED_UNSUPPORTED;
         }
 
         @Override
@@ -216,12 +213,12 @@
         }
 
         @Override
-        protected boolean isSwitchPrefEnabled() {
+        public boolean isChecked() {
             return mIsPrefEnabled;
         }
 
         @Override
-        public boolean onPreferenceChange(Preference preference, Object newValue) {
+        public boolean setChecked(boolean isChecked) {
             return false;
         }
     }
diff --git a/tests/robotests/src/com/android/settings/gestures/PickupGesturePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/gestures/PickupGesturePreferenceControllerTest.java
index 09e9ff7..6aa451c 100644
--- a/tests/robotests/src/com/android/settings/gestures/PickupGesturePreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/gestures/PickupGesturePreferenceControllerTest.java
@@ -57,8 +57,8 @@
     @Before
     public void setUp() {
         MockitoAnnotations.initMocks(this);
-        mController = new PickupGesturePreferenceController(
-                mContext, null, mAmbientDisplayConfiguration, 0, KEY_PICK_UP);
+        mController = new PickupGesturePreferenceController(mContext, KEY_PICK_UP);
+        mController.setConfig(mAmbientDisplayConfiguration);
     }
 
     @Test
@@ -76,19 +76,19 @@
     }
 
     @Test
-    public void testSwitchEnabled_configIsSet_shouldReturnTrue() {
+    public void testIsChecked_configIsSet_shouldReturnTrue() {
         // Set the setting to be enabled.
         when(mAmbientDisplayConfiguration.pulseOnPickupEnabled(anyInt())).thenReturn(true);
 
-        assertThat(mController.isSwitchPrefEnabled()).isTrue();
+        assertThat(mController.isChecked()).isTrue();
     }
 
     @Test
-    public void testSwitchEnabled_configIsNotSet_shouldReturnFalse() {
+    public void testIsChecked_configIsNotSet_shouldReturnFalse() {
         // Set the setting to be disabled.
         when(mAmbientDisplayConfiguration.pulseOnPickupEnabled(anyInt())).thenReturn(false);
 
-        assertThat(mController.isSwitchPrefEnabled()).isFalse();
+        assertThat(mController.isChecked()).isFalse();
     }
 
     @Test
@@ -111,8 +111,8 @@
     public void testPreferenceController_ProperResultPayloadType() {
         final Context context = RuntimeEnvironment.application;
         PickupGesturePreferenceController controller =
-                new PickupGesturePreferenceController(
-                        context, null, mAmbientDisplayConfiguration, 0, KEY_PICK_UP);
+                new PickupGesturePreferenceController(context, KEY_PICK_UP);
+        controller.setConfig(mAmbientDisplayConfiguration);
         ResultPayload payload = controller.getResultPayload();
         assertThat(payload).isInstanceOf(InlineSwitchPayload.class);
     }
diff --git a/tests/robotests/src/com/android/settings/gestures/SwipeToNotificationPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/gestures/SwipeToNotificationPreferenceControllerTest.java
index 69226b6..c164fbf 100644
--- a/tests/robotests/src/com/android/settings/gestures/SwipeToNotificationPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/gestures/SwipeToNotificationPreferenceControllerTest.java
@@ -53,7 +53,7 @@
     @Before
     public void setUp() {
         MockitoAnnotations.initMocks(this);
-        mController = new SwipeToNotificationPreferenceController(mContext, null, KEY_SWIPE_DOWN);
+        mController = new SwipeToNotificationPreferenceController(mContext, KEY_SWIPE_DOWN);
         when(mContext.getPackageManager()).thenReturn(mPackageManager);
         when(mContext.getSystemService(Context.FINGERPRINT_SERVICE))
                 .thenReturn(mFingerprintManager);
@@ -93,27 +93,27 @@
     }
 
     @Test
-    public void testSwitchEnabled_configIsSet_shouldReturnTrue() {
+    public void testIsChecked_configIsSet_shouldReturnTrue() {
         stubFingerprintSupported(true);
         when(mFingerprintManager.isHardwareDetected()).thenReturn(true);
         // Set the setting to be enabled.
         final Context context = RuntimeEnvironment.application;
         Settings.System.putInt(context.getContentResolver(), SYSTEM_NAVIGATION_KEYS_ENABLED, 1);
-        mController = new SwipeToNotificationPreferenceController(context, null, KEY_SWIPE_DOWN);
+        mController = new SwipeToNotificationPreferenceController(context, KEY_SWIPE_DOWN);
 
-        assertThat(mController.isSwitchPrefEnabled()).isTrue();
+        assertThat(mController.isChecked()).isTrue();
     }
 
     @Test
-    public void testSwitchEnabled_configIsNotSet_shouldReturnFalse() {
+    public void testIsChecked_configIsNotSet_shouldReturnFalse() {
         stubFingerprintSupported(true);
         when(mFingerprintManager.isHardwareDetected()).thenReturn(true);
         // Set the setting to be disabled.
         final Context context = RuntimeEnvironment.application;
         Settings.System.putInt(context.getContentResolver(), SYSTEM_NAVIGATION_KEYS_ENABLED, 0);
-        mController = new SwipeToNotificationPreferenceController(context, null, KEY_SWIPE_DOWN);
+        mController = new SwipeToNotificationPreferenceController(context, KEY_SWIPE_DOWN);
 
-        assertThat(mController.isSwitchPrefEnabled()).isFalse();
+        assertThat(mController.isChecked()).isFalse();
     }
 
     @Test
diff --git a/tests/robotests/src/com/android/settings/gestures/SwipeToNotificationSettingsTest.java b/tests/robotests/src/com/android/settings/gestures/SwipeToNotificationSettingsTest.java
index 78f1917..78e8603 100644
--- a/tests/robotests/src/com/android/settings/gestures/SwipeToNotificationSettingsTest.java
+++ b/tests/robotests/src/com/android/settings/gestures/SwipeToNotificationSettingsTest.java
@@ -54,14 +54,6 @@
     }
 
     @Test
-    public void testGetPreferenceControllers_shouldAllBeCreated() {
-        final List<AbstractPreferenceController> controllers =
-                mFragment.createPreferenceControllers(mContext);
-
-        assertThat(controllers.isEmpty()).isFalse();
-    }
-
-    @Test
     public void testSearchIndexProvider_shouldIndexResource() {
         final List<SearchIndexableResource> indexRes =
             SwipeToNotificationSettings.SEARCH_INDEX_DATA_PROVIDER