Added settings screens for Power Menu

This CL adds a new Preference in Gestures (Power Menu), moves Global
Actions to it (now renamed Cards & passes) and adds a new Preference for
Device controls.

Missing:
* Explanation video for Device controls
* Privacy settings

Test: robotests
Test: manual change settings
Bug: 152212779
Bug: 152329723
Change-Id: Ia8f69565307a5961c8435bc1f441abeb389acf8b
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 98789bd..07bc06c 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -3314,7 +3314,7 @@
         </activity>
 
         <activity android:name="Settings$GlobalActionsPanelSettingsActivity"
-            android:label="@string/global_actions_panel_title">
+            android:label="@string/cards_passes_sentence">
             <intent-filter>
                 <action android:name="com.android.settings.GLOBAL_ACTIONS_PANEL_SETTINGS" />
                 <category android:name="android.intent.category.DEFAULT" />
@@ -3323,6 +3323,26 @@
                 android:value="com.android.settings.gestures.GlobalActionsPanelSettings" />
         </activity>
 
+        <activity android:name="Settings$PowerMenuSettingsActivity"
+                  android:label="@string/power_menu_setting_name">
+            <intent-filter>
+                <action android:name="android.settings.ACTION_POWER_MENU_SETTINGS" />
+                <category android:name="android.intent.category.DEFAULT" />
+            </intent-filter>
+            <meta-data android:name="com.android.settings.FRAGMENT_CLASS"
+                       android:value="com.android.settings.gestures.PowerMenuSettings" />
+        </activity>
+
+        <activity android:name="Settings$DeviceControlsSettingsActivity"
+                      android:label="@string/device_controls_sentence">
+            <intent-filter>
+                <action android:name="android.settings.ACTION_DEVICE_CONTROLS_SETTINGS" />
+                <category android:name="android.intent.category.DEFAULT" />
+            </intent-filter>
+            <meta-data android:name="com.android.settings.FRAGMENT_CLASS"
+                       android:value="com.android.settings.gestures.DeviceControlsSettings" />
+        </activity>
+
         <activity
             android:name="Settings$GestureNavigationSettingsActivity"
             android:label="@string/gesture_settings_activity_title"
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 8a642ac..be1222e 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -7534,8 +7534,8 @@
     <string name="keywords_profile_challenge">work challenge, work, profile</string>
     <string name="keywords_unification">work profile, managed profile, unify, unification, work, profile</string>
     <string name="keywords_gesture">gestures</string>
-    <!-- Search keywords for Global Actions Panel. [DO NOT TRANSLATE] -->
-    <string name="keywords_global_actions_panel" translatable="false">global actions</string>
+    <string name="keywords_cards_passes">cards, passes</string>
+    <string name="keywords_device_controls">device controls, controls</string>
     <string name="keywords_payment_settings">pay, tap, payments</string>
     <string name="keywords_backup">backup, back up</string>
     <string name="keywords_assist_gesture_launch">gesture</string>
@@ -10737,13 +10737,6 @@
     <!-- Summary text for ambient display tap [CHAR LIMIT=NONE]-->
     <string name="ambient_display_tap_screen_summary">To check time, notifications, and other info, tap your screen.</string>
 
-    <!-- Summary text for global actions panel [CHAR LIMIT=NONE] [DO NOT TRANSLATE]-->
-    <string name="global_actions_panel_summary" translatable="false">To show the global actions panel, press &amp; hold Power button</string>
-    <!-- Preference and settings suggestion title text for global actions panel [CHAR LIMIT=60] [DO NOT TRANSLATE]-->
-    <string name="global_actions_panel_title" translatable="false">Show global actions</string>
-    <!-- Short title text for global actions panel [CHAR LIMIT=40] [DO NOT TRANSLATE]-->
-    <string name="global_actions_panel_short_title" translatable="false">Global actions</string>
-
     <!-- Title text for swiping downwards on fingerprint sensor for notifications [CHAR LIMIT=80]-->
     <string name="fingerprint_swipe_for_notifications_title">Swipe fingerprint for notifications</string>
     <!-- Title text for fingerprint gesture preference screen [CHAR LIMIT=25] -->
@@ -11866,11 +11859,11 @@
     <!-- Developer settings: text for the bug report handler selection toast shown if an invalid bug report handler was chosen. [CHAR LIMIT=NONE] -->
     <string name="select_invalid_bug_report_handler_toast_text">This choice is no longer valid. Try again.</string>
 
-    <!-- Quick controls name sentence case [CHAR LIMIT=40] -->
-    <string name="quick_controls_sentence">Quick controls</string>
+    <!-- Device controls name sentence case [CHAR LIMIT=40] -->
+    <string name="device_controls_sentence">Device controls</string>
 
-    <!-- Quick controls name lower case [CHAR LIMIT=40] -->
-    <string name="quick_controls_lower">quick controls</string>
+    <!-- Device controls name lower case [CHAR LIMIT=40] -->
+    <string name="quick_controls_lower">device controls</string>
 
     <!-- Cards and passes name sentence case [CHAR LIMIT=40] -->
     <string name="cards_passes_sentence">Cards &amp; passes</string>
@@ -11887,11 +11880,11 @@
     <!-- Power menu setting option cards and passes [CHAR LIMIT=NONE] -->
     <string name="power_menu_cards_passes">Show cards &amp; passes</string>
 
-    <!-- Power menu setting option quick controls [CHAR LIMIT=NONE] -->
-    <string name="power_menu_quick_controls">Show quick controls</string>
+    <!-- Power menu setting option device controls [CHAR LIMIT=NONE] -->
+    <string name="power_menu_device_controls">Show device controls</string>
 
-    <!-- Power menu setting option cards, passes, quick controls [CHAR LIMIT=NONE] -->
-    <string name="power_menu_cards_passes_quick_controls">Show cards, passes, and quick controls</string>
+    <!-- Power menu setting option cards, passes, device controls [CHAR LIMIT=NONE] -->
+    <string name="power_menu_cards_passes_device_controls">Show cards, passes, and device controls</string>
 
     <!-- Power menu setting option none [CHAR LIMIT=NONE] -->
     <string name="power_menu_none">Don\u2019t show any content</string>
@@ -11905,11 +11898,17 @@
     <!-- Power menu setting privacy hide all [CHAR LIMIT=NONE] -->
     <string name="power_menu_privacy_hide">Hide cards and controls when locked</string>
 
-    <!-- Quick controls toggle name [CHAR LIMIT=NONE] -->
-    <string name="quick_controls_setting_toggle">Show quick controls</string>
+    <!-- Device controls toggle name [CHAR LIMIT=60] -->
+    <string name="device_controls_setting_toggle">Show device controls</string>
 
-    <!-- Quick controls toggle subtitle [CHAR LIMIT=NONE] -->
-    <string name="quick_controls_setting_subtitle">To access controls for connected devices, hold the Power button</string>
+    <!-- Cards and passes toggle name [CHAR LIMIT=60] -->
+    <string name="cards_passes_setting_toggle">Show cards &amp; passes</string>
+
+    <!-- Device controls toggle subtitle [CHAR LIMIT=NONE] -->
+    <string name="device_controls_setting_subtitle">To access controls for connected devices, hold the Power button</string>
+
+    <!-- Cards and passes toggle subtitle [CHAR LIMIT=NONE] -->
+    <string name="cards_passes_setting_subtitle">To access things like your payment methods and boarding passes, press and hold the Power button.</string>
 
     <!-- Title for RTT setting. [CHAR LIMIT=NONE] -->
     <string name="rtt_settings_title"></string>
diff --git a/res/xml/device_controls_settings.xml b/res/xml/device_controls_settings.xml
new file mode 100644
index 0000000..998b982
--- /dev/null
+++ b/res/xml/device_controls_settings.xml
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+  ~ Copyright (C) 2020 The Android Open Source Project
+  ~
+  ~ Licensed under the Apache License, Version 2.0 (the "License");
+  ~ you may not use this file except in compliance with the License.
+  ~ You may obtain a copy of the License at
+  ~
+  ~      http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing, software
+  ~ distributed under the License is distributed on an "AS IS" BASIS,
+  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  ~ See the License for the specific language governing permissions and
+  ~ limitations under the License.
+  -->
+
+<PreferenceScreen
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:app="http://schemas.android.com/apk/res-auto"
+    android:title="@string/device_controls_sentence">
+
+    <com.android.settings.widget.VideoPreference
+        android:key="device_controls_video"/>
+
+    <SwitchPreference
+        android:key="gesture_device_controls_switch"
+        android:title="@string/device_controls_setting_toggle"
+        android:summary="@string/device_controls_setting_subtitle"
+        app:keywords="@string/keywords_device_controls"
+        app:controller="com.android.settings.gestures.DeviceControlsPreferenceController"
+        app:allowDividerAbove="true" />
+
+</PreferenceScreen>
diff --git a/res/xml/gestures.xml b/res/xml/gestures.xml
index a523ec6..ed191ce 100644
--- a/res/xml/gestures.xml
+++ b/res/xml/gestures.xml
@@ -81,9 +81,8 @@
         settings:controller="com.android.settings.gestures.PreventRingingParentPreferenceController" />
 
     <Preference
-        android:key="gesture_global_actions_panel_summary"
-        android:title="@string/global_actions_panel_short_title"
-        android:fragment="com.android.settings.gestures.GlobalActionsPanelSettings"
-        settings:controller="com.android.settings.gestures.GlobalActionsPanelPreferenceController" />
-
+        android:key="gesture_power_menu_summary"
+        android:title="@string/power_menu_setting_name"
+        android:fragment="com.android.settings.gestures.PowerMenuSettings"
+        settings:controller="com.android.settings.gestures.PowerMenuPreferenceController" />
 </PreferenceScreen>
diff --git a/res/xml/global_actions_panel_settings.xml b/res/xml/global_actions_panel_settings.xml
index 3b7bef3..980c756 100644
--- a/res/xml/global_actions_panel_settings.xml
+++ b/res/xml/global_actions_panel_settings.xml
@@ -18,7 +18,7 @@
 <PreferenceScreen
     xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:app="http://schemas.android.com/apk/res-auto"
-    android:title="@string/global_actions_panel_title">
+    android:title="@string/cards_passes_sentence">
 
     <com.android.settings.widget.VideoPreference
         android:key="global_actions_panel_video"
@@ -26,9 +26,9 @@
 
     <SwitchPreference
         android:key="gesture_global_actions_panel_switch"
-        android:title="@string/global_actions_panel_title"
-        android:summary="@string/global_actions_panel_summary"
-        app:keywords="@string/keywords_global_actions_panel"
+        android:title="@string/cards_passes_setting_toggle"
+        android:summary="@string/cards_passes_setting_subtitle"
+        app:keywords="@string/keywords_cards_passes"
         app:controller="com.android.settings.gestures.GlobalActionsPanelPreferenceController"
         app:allowDividerAbove="true" />
 
diff --git a/res/xml/power_menu_settings.xml b/res/xml/power_menu_settings.xml
new file mode 100644
index 0000000..453a7e6
--- /dev/null
+++ b/res/xml/power_menu_settings.xml
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+  ~ Copyright (C) 2020 The Android Open Source Project
+  ~
+  ~ Licensed under the Apache License, Version 2.0 (the "License");
+  ~ you may not use this file except in compliance with the License.
+  ~ You may obtain a copy of the License at
+  ~
+  ~      http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing, software
+  ~ distributed under the License is distributed on an "AS IS" BASIS,
+  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  ~ See the License for the specific language governing permissions and
+  ~ limitations under the License.
+  -->
+
+<PreferenceScreen
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:settings="http://schemas.android.com/apk/res-auto"
+    android:title="@string/power_menu_setting_name">
+
+    <Preference
+        android:key="gesture_global_actions_panel_summary"
+        android:title="@string/cards_passes_sentence"
+        android:fragment="com.android.settings.gestures.GlobalActionsPanelSettings"
+        settings:controller="com.android.settings.gestures.GlobalActionsPanelPreferenceController" />
+
+    <Preference
+        android:key="gesture_device_controls_summary"
+        android:title="@string/device_controls_sentence"
+        android:fragment="com.android.settings.gestures.DeviceControlsSettings"
+        settings:controller="com.android.settings.gestures.DeviceControlsPreferenceController" />
+</PreferenceScreen>
diff --git a/src/com/android/settings/Settings.java b/src/com/android/settings/Settings.java
index d25d7e9..f5494fa 100644
--- a/src/com/android/settings/Settings.java
+++ b/src/com/android/settings/Settings.java
@@ -218,6 +218,8 @@
     public static class WifiCallingDisclaimerActivity extends SettingsActivity { /* empty */ }
     public static class MobileNetworkListActivity extends SettingsActivity {}
     public static class GlobalActionsPanelSettingsActivity extends SettingsActivity {}
+    public static class PowerMenuSettingsActivity extends SettingsActivity {}
+    public static class QuickControlsSettingsActivity extends SettingsActivity {}
     /**
      * Activity for BugReportHandlerPicker.
      */
diff --git a/src/com/android/settings/core/gateway/SettingsGateway.java b/src/com/android/settings/core/gateway/SettingsGateway.java
index 8c49e58..fea32cf 100644
--- a/src/com/android/settings/core/gateway/SettingsGateway.java
+++ b/src/com/android/settings/core/gateway/SettingsGateway.java
@@ -88,12 +88,14 @@
 import com.android.settings.fuelgauge.batterysaver.BatterySaverScheduleSettings;
 import com.android.settings.fuelgauge.batterysaver.BatterySaverSettings;
 import com.android.settings.gestures.AssistGestureSettings;
+import com.android.settings.gestures.DeviceControlsSettings;
 import com.android.settings.gestures.DoubleTapPowerSettings;
 import com.android.settings.gestures.DoubleTapScreenSettings;
 import com.android.settings.gestures.DoubleTwistGestureSettings;
 import com.android.settings.gestures.GestureNavigationSettingsFragment;
 import com.android.settings.gestures.GlobalActionsPanelSettings;
 import com.android.settings.gestures.PickupGestureSettings;
+import com.android.settings.gestures.PowerMenuSettings;
 import com.android.settings.gestures.SwipeToNotificationSettings;
 import com.android.settings.gestures.SystemNavigationGestureSettings;
 import com.android.settings.inputmethod.AvailableVirtualKeyboardFragment;
@@ -294,7 +296,9 @@
             PreviouslyConnectedDeviceDashboardFragment.class.getName(),
             BatterySaverScheduleSettings.class.getName(),
             MobileNetworkListFragment.class.getName(),
+            PowerMenuSettings.class.getName(),
             GlobalActionsPanelSettings.class.getName(),
+            DeviceControlsSettings.class.getName(),
             DarkModeSettingsFragment.class.getName(),
             BugReportHandlerPicker.class.getName(),
             GestureNavigationSettingsFragment.class.getName(),
diff --git a/src/com/android/settings/gestures/DeviceControlsPreferenceController.java b/src/com/android/settings/gestures/DeviceControlsPreferenceController.java
new file mode 100644
index 0000000..e588e86
--- /dev/null
+++ b/src/com/android/settings/gestures/DeviceControlsPreferenceController.java
@@ -0,0 +1,69 @@
+/*
+ * Copyright (C) 2020 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.gestures;
+
+import android.content.Context;
+import android.provider.Settings;
+import android.text.TextUtils;
+
+import com.android.internal.annotations.VisibleForTesting;
+
+public class DeviceControlsPreferenceController extends GesturePreferenceController {
+    private static final String PREF_KEY_VIDEO = "device_controls_video";
+
+    @VisibleForTesting
+    protected static final String ENABLED_SETTING = Settings.Secure.CONTROLS_ENABLED;
+
+    @VisibleForTesting
+    protected static final String TOGGLE_KEY = "gesture_device_controls_switch";
+
+    public DeviceControlsPreferenceController(Context context, String key) {
+        super(context, key);
+    }
+
+    @Override
+    public int getAvailabilityStatus() {
+        return AVAILABLE;
+    }
+
+    @Override
+    public boolean setChecked(boolean isChecked) {
+        return Settings.Secure.putInt(mContext.getContentResolver(), ENABLED_SETTING,
+                isChecked ? 1 : 0);
+    }
+
+    @Override
+    protected String getVideoPrefKey() {
+        return PREF_KEY_VIDEO;
+    }
+
+    @Override
+    public boolean isSliceable() {
+        return TextUtils.equals(getPreferenceKey(), TOGGLE_KEY);
+    }
+
+    @Override
+    public boolean isPublicSlice() {
+        return true;
+    }
+
+    @Override
+    public boolean isChecked() {
+        int enabled = Settings.Secure.getInt(mContext.getContentResolver(), ENABLED_SETTING, 1);
+        return enabled == 1;
+    }
+}
diff --git a/src/com/android/settings/gestures/DeviceControlsSettings.java b/src/com/android/settings/gestures/DeviceControlsSettings.java
new file mode 100644
index 0000000..df36717
--- /dev/null
+++ b/src/com/android/settings/gestures/DeviceControlsSettings.java
@@ -0,0 +1,48 @@
+/*
+ * Copyright (C) 2020 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.gestures;
+
+import android.app.settings.SettingsEnums;
+
+import com.android.settings.R;
+import com.android.settings.dashboard.DashboardFragment;
+import com.android.settings.search.BaseSearchIndexProvider;
+import com.android.settingslib.search.SearchIndexable;
+
+@SearchIndexable
+public class DeviceControlsSettings extends DashboardFragment {
+
+    private static final String TAG = "QuickControlsSettings";
+
+    @Override
+    public int getMetricsCategory() {
+        return SettingsEnums.DEVICE_CONTROLS_SETTINGS;
+    }
+
+    @Override
+    protected String getLogTag() {
+        return TAG;
+    }
+
+    @Override
+    protected int getPreferenceScreenResId() {
+        return R.xml.device_controls_settings;
+    }
+
+    public static final BaseSearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
+            new BaseSearchIndexProvider(R.xml.device_controls_settings);
+}
diff --git a/src/com/android/settings/gestures/PowerMenuPreferenceController.java b/src/com/android/settings/gestures/PowerMenuPreferenceController.java
new file mode 100644
index 0000000..e65d140
--- /dev/null
+++ b/src/com/android/settings/gestures/PowerMenuPreferenceController.java
@@ -0,0 +1,61 @@
+/*
+ * Copyright (C) 2020 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.gestures;
+
+import android.content.Context;
+import android.provider.Settings;
+
+import com.android.settings.R;
+import com.android.settings.core.BasePreferenceController;
+
+public class PowerMenuPreferenceController extends BasePreferenceController {
+
+    private static final String KEY = "gesture_power_menu_summary";
+    private static final String CONTROLS_ENABLED_SETTING = Settings.Secure.CONTROLS_ENABLED;
+    private static final String CARDS_ENABLED_SETTING =
+            Settings.Secure.GLOBAL_ACTIONS_PANEL_ENABLED;
+    private static final String CARDS_AVAILABLE_SETTING =
+            Settings.Secure.GLOBAL_ACTIONS_PANEL_AVAILABLE;
+
+    public PowerMenuPreferenceController(Context context, String key) {
+        super(context, key);
+    }
+
+    @Override
+    public CharSequence getSummary() {
+        boolean controlsEnabled = Settings.Secure.getInt(mContext.getContentResolver(),
+                CONTROLS_ENABLED_SETTING, 1) == 1;
+        boolean cardsEnabled = Settings.Secure.getInt(mContext.getContentResolver(),
+                CARDS_ENABLED_SETTING, 0) == 1;
+        boolean cardsVisible = cardsEnabled && Settings.Secure.getInt(mContext.getContentResolver(),
+                CARDS_AVAILABLE_SETTING, 0) == 1;
+        if (controlsEnabled && cardsVisible) {
+            return mContext.getText(R.string.power_menu_cards_passes_device_controls);
+        } else if (controlsEnabled) {
+            return mContext.getText(R.string.power_menu_device_controls);
+        } else if (cardsVisible) {
+            return mContext.getText(R.string.power_menu_cards_passes);
+        } else {
+            return mContext.getText(R.string.power_menu_none);
+        }
+    }
+
+    @Override
+    public int getAvailabilityStatus() {
+        return AVAILABLE;
+    }
+}
diff --git a/src/com/android/settings/gestures/PowerMenuSettings.java b/src/com/android/settings/gestures/PowerMenuSettings.java
new file mode 100644
index 0000000..3b4c5c3
--- /dev/null
+++ b/src/com/android/settings/gestures/PowerMenuSettings.java
@@ -0,0 +1,46 @@
+/*
+ * Copyright (C) 2020 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.gestures;
+
+import android.app.settings.SettingsEnums;
+
+import com.android.settings.R;
+import com.android.settings.dashboard.DashboardFragment;
+import com.android.settings.search.BaseSearchIndexProvider;
+
+public class PowerMenuSettings extends DashboardFragment {
+
+    private static final String TAG = "PowerMenuSettings";
+
+    @Override
+    protected int getPreferenceScreenResId() {
+        return R.xml.power_menu_settings;
+    }
+
+    @Override
+    protected String getLogTag() {
+        return TAG;
+    }
+
+    @Override
+    public int getMetricsCategory() {
+        return SettingsEnums.POWER_MENU_SETTINGS;
+    }
+
+    public static final BaseSearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
+            new BaseSearchIndexProvider(R.xml.power_menu_settings);
+}
diff --git a/tests/robotests/src/com/android/settings/gestures/DeviceControlsPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/gestures/DeviceControlsPreferenceControllerTest.java
new file mode 100644
index 0000000..c31971a
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/gestures/DeviceControlsPreferenceControllerTest.java
@@ -0,0 +1,87 @@
+/*
+ * Copyright (C) 2020 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.gestures;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import android.content.Context;
+import android.provider.Settings;
+
+import com.android.settings.core.BasePreferenceController;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.robolectric.RobolectricTestRunner;
+import org.robolectric.RuntimeEnvironment;
+
+@RunWith(RobolectricTestRunner.class)
+public class DeviceControlsPreferenceControllerTest {
+
+    private Context mContext;
+    private DeviceControlsPreferenceController mController;
+
+    private static final String KEY_GESTURE_PANEL = "gesture_device_controls";
+    private static final String ENABLED_SETTING =
+            DeviceControlsPreferenceController.ENABLED_SETTING;
+
+    @Before
+    public void setUp() {
+        mContext = RuntimeEnvironment.application;
+        mController = new DeviceControlsPreferenceController(mContext, KEY_GESTURE_PANEL);
+    }
+
+    @Test
+    public void testIsChecked_panelEnabled() {
+        Settings.Secure.putInt(
+                mContext.getContentResolver(), ENABLED_SETTING, 1);
+        assertThat(mController.isChecked()).isTrue();
+    }
+
+    @Test
+    public void testIsChecked_panelDisabled() {
+        Settings.Secure.putInt(
+                mContext.getContentResolver(), ENABLED_SETTING, 0);
+        assertThat(mController.isChecked()).isFalse();
+    }
+
+    @Test
+    public void getAvailabilityStatus_panelAvailable() {
+        assertThat(mController.getAvailabilityStatus())
+                .isEqualTo(BasePreferenceController.AVAILABLE);
+    }
+
+    @Test
+    public void isSliceable_correctKey() {
+        final DeviceControlsPreferenceController controller =
+                new DeviceControlsPreferenceController(mContext,
+                        DeviceControlsPreferenceController.TOGGLE_KEY);
+        assertThat(controller.isSliceable()).isTrue();
+    }
+
+    @Test
+    public void isSliceable_incorrectKey() {
+        final DeviceControlsPreferenceController controller =
+                new DeviceControlsPreferenceController(mContext, "bad_key");
+        assertThat(controller.isSliceable()).isFalse();
+    }
+
+    @Test
+    public void isPublicSlice_returnTrue() {
+        assertThat(mController.isPublicSlice()).isTrue();
+    }
+}
diff --git a/tests/robotests/src/com/android/settings/gestures/DeviceControlsSettingsTest.java b/tests/robotests/src/com/android/settings/gestures/DeviceControlsSettingsTest.java
new file mode 100644
index 0000000..2ec0f1d
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/gestures/DeviceControlsSettingsTest.java
@@ -0,0 +1,50 @@
+/*
+ * Copyright (C) 2020 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.gestures;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import android.provider.SearchIndexableResource;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.robolectric.RobolectricTestRunner;
+import org.robolectric.RuntimeEnvironment;
+
+import java.util.List;
+
+@RunWith(RobolectricTestRunner.class)
+public class DeviceControlsSettingsTest {
+
+    private DeviceControlsSettings mSettings;
+
+    @Before
+    public void setUp() {
+        mSettings = new DeviceControlsSettings();
+    }
+
+    @Test
+    public void testSearchIndexProvider_shouldIndexResource() {
+        final List<SearchIndexableResource> indexRes =
+                DeviceControlsSettings.SEARCH_INDEX_DATA_PROVIDER.getXmlResourcesToIndex(
+                        RuntimeEnvironment.application, true /* enabled */);
+
+        assertThat(indexRes).isNotNull();
+        assertThat(indexRes.get(0).xmlResId).isEqualTo(mSettings.getPreferenceScreenResId());
+    }
+}
diff --git a/tests/robotests/src/com/android/settings/gestures/PowerMenuPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/gestures/PowerMenuPreferenceControllerTest.java
new file mode 100644
index 0000000..e14293e
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/gestures/PowerMenuPreferenceControllerTest.java
@@ -0,0 +1,136 @@
+/*
+ * Copyright (C) 2020 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.gestures;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import android.content.Context;
+import android.provider.Settings;
+
+import com.android.settings.R;
+import com.android.settings.core.BasePreferenceController;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.MockitoAnnotations;
+import org.robolectric.RobolectricTestRunner;
+import org.robolectric.RuntimeEnvironment;
+
+@RunWith(RobolectricTestRunner.class)
+public class PowerMenuPreferenceControllerTest {
+    private Context mContext;
+    private PowerMenuPreferenceController mController;
+
+    private static final String KEY_GESTURE_POWER_MENU = "gesture_power_menu";
+    private static final String CONTROLS_ENABLED = Settings.Secure.CONTROLS_ENABLED;
+    private static final String CARDS_ENABLED = Settings.Secure.GLOBAL_ACTIONS_PANEL_ENABLED;
+    private static final String CARDS_AVAILABLE = Settings.Secure.GLOBAL_ACTIONS_PANEL_AVAILABLE;
+
+    @Before
+    public void setUp() {
+        MockitoAnnotations.initMocks(this);
+        mContext = RuntimeEnvironment.application;
+        mController = new PowerMenuPreferenceController(mContext, KEY_GESTURE_POWER_MENU);
+    }
+
+    @Test
+    public void getAvailabilityStatus_available() {
+        assertThat(mController.getAvailabilityStatus()).isEqualTo(
+                BasePreferenceController.AVAILABLE);
+    }
+
+    @Test
+    public void getSummary_allDisabled() {
+        Settings.Secure.putInt(mContext.getContentResolver(), CONTROLS_ENABLED, 0);
+        Settings.Secure.putInt(mContext.getContentResolver(), CARDS_ENABLED, 0);
+        Settings.Secure.putInt(mContext.getContentResolver(), CARDS_AVAILABLE, 0);
+
+        assertThat(mController.getSummary())
+                .isEqualTo(mContext.getText(R.string.power_menu_none));
+    }
+
+    @Test
+    public void getSummary_onlyControlsEnabled() {
+        Settings.Secure.putInt(mContext.getContentResolver(), CONTROLS_ENABLED, 1);
+        Settings.Secure.putInt(mContext.getContentResolver(), CARDS_ENABLED, 0);
+        Settings.Secure.putInt(mContext.getContentResolver(), CARDS_AVAILABLE, 0);
+
+        assertThat(mController.getSummary())
+                .isEqualTo(mContext.getText(R.string.power_menu_device_controls));
+    }
+
+    @Test
+    public void getSummary_onlyCardsEnabled_notAvailable() {
+        Settings.Secure.putInt(mContext.getContentResolver(), CONTROLS_ENABLED, 0);
+        Settings.Secure.putInt(mContext.getContentResolver(), CARDS_ENABLED, 1);
+        Settings.Secure.putInt(mContext.getContentResolver(), CARDS_AVAILABLE, 0);
+
+        assertThat(mController.getSummary())
+                .isEqualTo(mContext.getText(R.string.power_menu_none));
+    }
+
+    @Test
+    public void getSummary_cardsAvailable_notEnabled() {
+        Settings.Secure.putInt(mContext.getContentResolver(), CONTROLS_ENABLED, 0);
+        Settings.Secure.putInt(mContext.getContentResolver(), CARDS_ENABLED, 0);
+        Settings.Secure.putInt(mContext.getContentResolver(), CARDS_AVAILABLE, 1);
+
+        assertThat(mController.getSummary())
+                .isEqualTo(mContext.getText(R.string.power_menu_none));
+    }
+
+    @Test
+    public void getSummary_allEnabled_cardsNotAvailable() {
+        Settings.Secure.putInt(mContext.getContentResolver(), CONTROLS_ENABLED, 1);
+        Settings.Secure.putInt(mContext.getContentResolver(), CARDS_ENABLED, 1);
+        Settings.Secure.putInt(mContext.getContentResolver(), CARDS_AVAILABLE, 0);
+
+        assertThat(mController.getSummary())
+                .isEqualTo(mContext.getText(R.string.power_menu_device_controls));
+    }
+
+    @Test
+    public void getSummary_controlsEnabled_cardsDisabledAvailable() {
+        Settings.Secure.putInt(mContext.getContentResolver(), CONTROLS_ENABLED, 1);
+        Settings.Secure.putInt(mContext.getContentResolver(), CARDS_ENABLED, 0);
+        Settings.Secure.putInt(mContext.getContentResolver(), CARDS_AVAILABLE, 1);
+
+        assertThat(mController.getSummary())
+                .isEqualTo(mContext.getText(R.string.power_menu_device_controls));
+    }
+
+    @Test
+    public void getSummary_controlsDisabled() {
+        Settings.Secure.putInt(mContext.getContentResolver(), CONTROLS_ENABLED, 0);
+        Settings.Secure.putInt(mContext.getContentResolver(), CARDS_ENABLED, 1);
+        Settings.Secure.putInt(mContext.getContentResolver(), CARDS_AVAILABLE, 1);
+
+        assertThat(mController.getSummary())
+                .isEqualTo(mContext.getText(R.string.power_menu_cards_passes));
+    }
+
+    @Test
+    public void getSummary_allEnabled() {
+        Settings.Secure.putInt(mContext.getContentResolver(), CONTROLS_ENABLED, 1);
+        Settings.Secure.putInt(mContext.getContentResolver(), CARDS_ENABLED, 1);
+        Settings.Secure.putInt(mContext.getContentResolver(), CARDS_AVAILABLE, 1);
+
+        assertThat(mController.getSummary())
+                .isEqualTo(mContext.getText(R.string.power_menu_cards_passes_device_controls));
+    }
+}
diff --git a/tests/robotests/src/com/android/settings/gestures/PowerMenuSettingsTest.java b/tests/robotests/src/com/android/settings/gestures/PowerMenuSettingsTest.java
new file mode 100644
index 0000000..4448ee3
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/gestures/PowerMenuSettingsTest.java
@@ -0,0 +1,50 @@
+/*
+ * Copyright (C) 2020 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.gestures;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import android.provider.SearchIndexableResource;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.robolectric.RobolectricTestRunner;
+import org.robolectric.RuntimeEnvironment;
+
+import java.util.List;
+
+@RunWith(RobolectricTestRunner.class)
+public class PowerMenuSettingsTest {
+
+    private PowerMenuSettings mSettings;
+
+    @Before
+    public void setUp() {
+        mSettings = new PowerMenuSettings();
+    }
+
+    @Test
+    public void testSearchIndexProvider_shouldIndexResource() {
+        final List<SearchIndexableResource> indexRes =
+                PowerMenuSettings.SEARCH_INDEX_DATA_PROVIDER.getXmlResourcesToIndex(
+                        RuntimeEnvironment.application, true /* enabled */);
+
+        assertThat(indexRes).isNotNull();
+        assertThat(indexRes.get(0).xmlResId).isEqualTo(mSettings.getPreferenceScreenResId());
+    }
+}