diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 98789bdc86c..07bc06cf354 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -3314,7 +3314,7 @@
+ android:label="@string/cards_passes_sentence">
@@ -3323,6 +3323,26 @@
android:value="com.android.settings.gestures.GlobalActionsPanelSettings" />
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
work challenge, work, profile
work profile, managed profile, unify, unification, work, profile
gestures
-
- global actions
+ cards, passes
+ device controls, controls
pay, tap, payments
backup, back up
gesture
@@ -10737,13 +10737,6 @@
To check time, notifications, and other info, tap your screen.
-
- To show the global actions panel, press & hold Power button
-
- Show global actions
-
- Global actions
-
Swipe fingerprint for notifications
@@ -11866,11 +11859,11 @@
This choice is no longer valid. Try again.
-
- Quick controls
+
+ Device controls
-
- quick controls
+
+ device controls
Cards & passes
@@ -11887,11 +11880,11 @@
Show cards & passes
-
- Show quick controls
+
+ Show device controls
-
- Show cards, passes, and quick controls
+
+ Show cards, passes, and device controls
Don\u2019t show any content
@@ -11905,11 +11898,17 @@
Hide cards and controls when locked
-
- Show quick controls
+
+ Show device controls
-
- To access controls for connected devices, hold the Power button
+
+ Show cards & passes
+
+
+ To access controls for connected devices, hold the Power button
+
+
+ To access things like your payment methods and boarding passes, press and hold the Power button.
diff --git a/res/xml/device_controls_settings.xml b/res/xml/device_controls_settings.xml
new file mode 100644
index 00000000000..998b98202c6
--- /dev/null
+++ b/res/xml/device_controls_settings.xml
@@ -0,0 +1,34 @@
+
+
+
+
+
+
+
+
+
+
diff --git a/res/xml/gestures.xml b/res/xml/gestures.xml
index a523ec629b5..ed191ce5282 100644
--- a/res/xml/gestures.xml
+++ b/res/xml/gestures.xml
@@ -81,9 +81,8 @@
settings:controller="com.android.settings.gestures.PreventRingingParentPreferenceController" />
-
+ 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" />
diff --git a/res/xml/global_actions_panel_settings.xml b/res/xml/global_actions_panel_settings.xml
index 3b7bef3f57e..980c75681d9 100644
--- a/res/xml/global_actions_panel_settings.xml
+++ b/res/xml/global_actions_panel_settings.xml
@@ -18,7 +18,7 @@
+ android:title="@string/cards_passes_sentence">
diff --git a/res/xml/power_menu_settings.xml b/res/xml/power_menu_settings.xml
new file mode 100644
index 00000000000..453a7e6a1f8
--- /dev/null
+++ b/res/xml/power_menu_settings.xml
@@ -0,0 +1,34 @@
+
+
+
+
+
+
+
+
+
diff --git a/src/com/android/settings/Settings.java b/src/com/android/settings/Settings.java
index d25d7e9dd24..f5494faa8ee 100644
--- a/src/com/android/settings/Settings.java
+++ b/src/com/android/settings/Settings.java
@@ -218,6 +218,8 @@ public class Settings extends SettingsActivity {
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 8c49e580c06..fea32cf8512 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.PowerUsageSummary;
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 @@ public class SettingsGateway {
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 00000000000..e588e86354d
--- /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 00000000000..df36717cb0b
--- /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 00000000000..e65d140dbdb
--- /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 00000000000..3b4c5c31f74
--- /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 00000000000..c31971a991b
--- /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 00000000000..2ec0f1d1602
--- /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 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 00000000000..e14293eb82a
--- /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 00000000000..4448ee38e12
--- /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 indexRes =
+ PowerMenuSettings.SEARCH_INDEX_DATA_PROVIDER.getXmlResourcesToIndex(
+ RuntimeEnvironment.application, true /* enabled */);
+
+ assertThat(indexRes).isNotNull();
+ assertThat(indexRes.get(0).xmlResId).isEqualTo(mSettings.getPreferenceScreenResId());
+ }
+}