Remove "Device Controls" from Settings
Both device controls and wallet have moved to new areas outside of the
power menu. In step 1, we are removing the device controls settings,
as the user can now fully control availability within the new Quick
Settings device controls tile.
Bug: 185597511
Test: make RunSettingsRoboTests -j ROBOTEST_FILTER=com.android.settings.gestures
Change-Id: Ib9a8c36c0532c095e58bc0ec085b788fc84945d7
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 4059b80..a6aa5ad 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -3688,17 +3688,6 @@
android:value="com.android.settings.gestures.PowerMenuSettings" />
</activity>
- <activity android:name="Settings$DeviceControlsSettingsActivity"
- android:exported="true"
- 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/raw/gesture_device_controls.mp4 b/res/raw/gesture_device_controls.mp4
deleted file mode 100644
index e69de29..0000000
--- a/res/raw/gesture_device_controls.mp4
+++ /dev/null
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 16c7e18..f4dba76 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -12874,9 +12874,6 @@
<!-- 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>
- <!-- Device controls name sentence case [CHAR LIMIT=40] -->
- <string name="device_controls_sentence">Device controls</string>
-
<!-- Device controls name lower case [CHAR LIMIT=40] -->
<string name="quick_controls_lower">device controls</string>
@@ -12895,12 +12892,6 @@
<!-- Power menu setting option cards and passes [CHAR LIMIT=NONE] -->
<string name="power_menu_cards_passes">Show cards & passes</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, device controls [CHAR LIMIT=NONE] -->
- <string name="power_menu_cards_passes_device_controls">Show cards, passes, and device controls</string>
-
<!-- Power menu setting lock screen category name [CHAR LIMIT=40] -->
<string name="power_menu_lock_screen_category">Lock screen</string>
diff --git a/res/xml/device_controls_settings.xml b/res/xml/device_controls_settings.xml
deleted file mode 100644
index c22cd4a..0000000
--- a/res/xml/device_controls_settings.xml
+++ /dev/null
@@ -1,36 +0,0 @@
-<?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"
- app:animation="@raw/gesture_device_controls"
- app:controller="com.android.settings.widget.VideoPreferenceController"/>
-
- <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/power_menu_settings.xml b/res/xml/power_menu_settings.xml
index bfe9c20..406cd0b 100644
--- a/res/xml/power_menu_settings.xml
+++ b/res/xml/power_menu_settings.xml
@@ -33,12 +33,6 @@
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" />
-
<PreferenceCategory
android:title="@string/power_menu_lock_screen_category" >
diff --git a/src/com/android/settings/core/gateway/SettingsGateway.java b/src/com/android/settings/core/gateway/SettingsGateway.java
index 1ea7e17..a6305cb 100644
--- a/src/com/android/settings/core/gateway/SettingsGateway.java
+++ b/src/com/android/settings/core/gateway/SettingsGateway.java
@@ -93,7 +93,6 @@
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;
@@ -306,7 +305,6 @@
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
deleted file mode 100644
index 0e0c04b..0000000
--- a/src/com/android/settings/gestures/DeviceControlsPreferenceController.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * 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.content.pm.PackageManager;
-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() {
- boolean available = mContext.getPackageManager().hasSystemFeature(
- PackageManager.FEATURE_CONTROLS);
- return available ? AVAILABLE : CONDITIONALLY_UNAVAILABLE;
- }
-
- @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
deleted file mode 100644
index df36717..0000000
--- a/src/com/android/settings/gestures/DeviceControlsSettings.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * 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
index b11ba65..7c9cd24 100644
--- a/src/com/android/settings/gestures/PowerMenuPreferenceController.java
+++ b/src/com/android/settings/gestures/PowerMenuPreferenceController.java
@@ -17,7 +17,6 @@
package com.android.settings.gestures;
import android.content.Context;
-import android.content.pm.PackageManager;
import android.provider.Settings;
import com.android.settings.R;
@@ -26,7 +25,6 @@
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 =
@@ -38,17 +36,10 @@
@Override
public CharSequence getSummary() {
- boolean controlsVisible = isControlsAvailable()
- && Settings.Secure.getInt(mContext.getContentResolver(),
- CONTROLS_ENABLED_SETTING, 1) == 1;
boolean cardsVisible = isCardsAvailable()
&& Settings.Secure.getInt(mContext.getContentResolver(),
CARDS_ENABLED_SETTING, 0) == 1;
- if (controlsVisible && cardsVisible) {
- return mContext.getText(R.string.power_menu_cards_passes_device_controls);
- } else if (controlsVisible) {
- return mContext.getText(R.string.power_menu_device_controls);
- } else if (cardsVisible) {
+ if (cardsVisible) {
return mContext.getText(R.string.power_menu_cards_passes);
} else {
return mContext.getText(R.string.power_menu_none);
@@ -57,14 +48,10 @@
@Override
public int getAvailabilityStatus() {
- return isCardsAvailable() || isControlsAvailable() || isAssistInvocationAvailable()
+ return isCardsAvailable() || isAssistInvocationAvailable()
? AVAILABLE : CONDITIONALLY_UNAVAILABLE;
}
- private boolean isControlsAvailable() {
- return mContext.getPackageManager().hasSystemFeature(PackageManager.FEATURE_CONTROLS);
- }
-
private boolean isCardsAvailable() {
return Settings.Secure.getInt(mContext.getContentResolver(),
CARDS_AVAILABLE_SETTING, 0) == 1;
diff --git a/src/com/android/settings/gestures/PowerMenuPrivacyPreferenceController.java b/src/com/android/settings/gestures/PowerMenuPrivacyPreferenceController.java
index 0cd71ee..0e0b3f9 100644
--- a/src/com/android/settings/gestures/PowerMenuPrivacyPreferenceController.java
+++ b/src/com/android/settings/gestures/PowerMenuPrivacyPreferenceController.java
@@ -35,7 +35,6 @@
private static final String CARDS_AVAILABLE_KEY =
Settings.Secure.GLOBAL_ACTIONS_PANEL_AVAILABLE;
private static final String CARDS_ENABLED_KEY = Settings.Secure.GLOBAL_ACTIONS_PANEL_ENABLED;
- private static final String CONTROLS_ENABLED_KEY = Settings.Secure.CONTROLS_ENABLED;
public PowerMenuPrivacyPreferenceController(Context context,
@@ -94,8 +93,7 @@
final ContentResolver resolver = mContext.getContentResolver();
boolean cardsAvailable = Settings.Secure.getInt(resolver, CARDS_AVAILABLE_KEY, 0) != 0;
boolean cardsEnabled = Settings.Secure.getInt(resolver, CARDS_ENABLED_KEY, 0) != 0;
- boolean controlsEnabled = Settings.Secure.getInt(resolver, CONTROLS_ENABLED_KEY, 1) != 0;
- return (cardsAvailable && cardsEnabled) || (isControlsAvailable() && controlsEnabled);
+ return (cardsAvailable && cardsEnabled) || isControlsAvailable();
}
private boolean isSecure() {
diff --git a/tests/robotests/src/com/android/settings/gestures/DeviceControlsPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/gestures/DeviceControlsPreferenceControllerTest.java
deleted file mode 100644
index 432a68d..0000000
--- a/tests/robotests/src/com/android/settings/gestures/DeviceControlsPreferenceControllerTest.java
+++ /dev/null
@@ -1,102 +0,0 @@
-/*
- * 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.content.pm.PackageManager;
-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;
-import org.robolectric.Shadows;
-import org.robolectric.shadows.ShadowPackageManager;
-
-@RunWith(RobolectricTestRunner.class)
-public class DeviceControlsPreferenceControllerTest {
-
- private Context mContext;
- private DeviceControlsPreferenceController mController;
- private ShadowPackageManager mShadowPackageManager;
-
- 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;
- mShadowPackageManager = Shadows.shadowOf(mContext.getPackageManager());
- 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_hasSystemFeature_panelAvailable() {
- mShadowPackageManager.setSystemFeature(PackageManager.FEATURE_CONTROLS, true);
-
- assertThat(mController.getAvailabilityStatus())
- .isEqualTo(BasePreferenceController.AVAILABLE);
- }
-
- @Test
- public void getAvailabilityStatus_hasntSystemFeature_panelUnsupported() {
- mShadowPackageManager.setSystemFeature(PackageManager.FEATURE_CONTROLS, false);
-
- assertThat(mController.getAvailabilityStatus())
- .isEqualTo(BasePreferenceController.CONDITIONALLY_UNAVAILABLE);
- }
-
- @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
deleted file mode 100644
index 2ec0f1d..0000000
--- a/tests/robotests/src/com/android/settings/gestures/DeviceControlsSettingsTest.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * 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/PowerMenuPreferenceControllerSummaryTest.java b/tests/robotests/src/com/android/settings/gestures/PowerMenuPreferenceControllerSummaryTest.java
index 7fa248c..4ed0a01 100644
--- a/tests/robotests/src/com/android/settings/gestures/PowerMenuPreferenceControllerSummaryTest.java
+++ b/tests/robotests/src/com/android/settings/gestures/PowerMenuPreferenceControllerSummaryTest.java
@@ -21,7 +21,6 @@
import android.annotation.StringRes;
import android.content.ContentResolver;
import android.content.Context;
-import android.content.pm.PackageManager;
import android.provider.Settings;
import com.android.settings.R;
@@ -31,8 +30,6 @@
import org.junit.runner.RunWith;
import org.robolectric.ParameterizedRobolectricTestRunner;
import org.robolectric.RuntimeEnvironment;
-import org.robolectric.Shadows;
-import org.robolectric.shadows.ShadowPackageManager;
import java.util.Arrays;
import java.util.Collection;
@@ -41,53 +38,32 @@
public class PowerMenuPreferenceControllerSummaryTest {
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 CONTROLS_FEATURE = PackageManager.FEATURE_CONTROLS;
private static final String CARDS_ENABLED = Settings.Secure.GLOBAL_ACTIONS_PANEL_ENABLED;
private static final String CARDS_AVAILABLE = Settings.Secure.GLOBAL_ACTIONS_PANEL_AVAILABLE;
@ParameterizedRobolectricTestRunner.Parameters(
- name = "ctrls available={0}, ctrls enabled={1}, cards available={2}, cards enabled={3}")
+ name = "cards available={0}, cards enabled={1}")
public static Collection data() {
return Arrays.asList(new Object[][]{
- // controls available, controls enabled, cards available, cards enabled, summary
- {false, false, false, false, R.string.power_menu_none},
- {false, false, false, true, R.string.power_menu_none},
- {false, false, true, false, R.string.power_menu_none},
- {false, false, true, true, R.string.power_menu_cards_passes},
- {false, true, false, false, R.string.power_menu_none},
- {false, true, false, true, R.string.power_menu_none},
- {false, true, true, false, R.string.power_menu_none},
- {false, true, true, true, R.string.power_menu_cards_passes},
- {true, false, false, false, R.string.power_menu_none},
- {true, false, false, true, R.string.power_menu_none},
- {true, false, true, false, R.string.power_menu_none},
- {true, false, true, true, R.string.power_menu_cards_passes},
- {true, true, false, false, R.string.power_menu_device_controls},
- {true, true, false, true, R.string.power_menu_device_controls},
- {true, true, true, false, R.string.power_menu_device_controls},
- {true, true, true, true, R.string.power_menu_cards_passes_device_controls}
+ // cards available, cards enabled, summary
+ {false, false, R.string.power_menu_none},
+ {false, true, R.string.power_menu_none},
+ {true, false, R.string.power_menu_none},
+ {true, true, R.string.power_menu_cards_passes}
});
}
private Context mContext;
private PowerMenuPreferenceController mController;
- private ShadowPackageManager mShadowPackageManager;
- private boolean mControlsAvailable;
- private boolean mControlsEnabled;
private boolean mCardsAvailable;
private boolean mCardsEnabled;
private @StringRes int mSummaryRes;
public PowerMenuPreferenceControllerSummaryTest(
- boolean controlsAvailable,
- boolean controlsEnabled,
boolean cardsAvailable,
boolean cardsEnabled,
@StringRes int summaryRes) {
- mControlsAvailable = controlsAvailable;
- mControlsEnabled = controlsEnabled;
mCardsAvailable = cardsAvailable;
mCardsEnabled = cardsEnabled;
mSummaryRes = summaryRes;
@@ -96,15 +72,12 @@
@Before
public void setUp() {
mContext = RuntimeEnvironment.application;
- mShadowPackageManager = Shadows.shadowOf(mContext.getPackageManager());
mController = new PowerMenuPreferenceController(mContext, KEY_GESTURE_POWER_MENU);
}
@Test
public void getSummary_possiblyAvailableAndEnabled() {
- mShadowPackageManager.setSystemFeature(CONTROLS_FEATURE, mControlsAvailable);
ContentResolver cr = mContext.getContentResolver();
- Settings.Secure.putInt(cr, CONTROLS_ENABLED, mControlsEnabled ? 1 : 0);
Settings.Secure.putInt(cr, CARDS_AVAILABLE, mCardsAvailable ? 1 : 0);
Settings.Secure.putInt(cr, CARDS_ENABLED, mCardsEnabled ? 1 : 0);
diff --git a/tests/robotests/src/com/android/settings/gestures/PowerMenuPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/gestures/PowerMenuPreferenceControllerTest.java
index fc45ddb..d734975 100644
--- a/tests/robotests/src/com/android/settings/gestures/PowerMenuPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/gestures/PowerMenuPreferenceControllerTest.java
@@ -23,7 +23,6 @@
import static org.mockito.Mockito.when;
import android.content.Context;
-import android.content.pm.PackageManager;
import android.content.res.Resources;
import android.provider.Settings;
@@ -34,19 +33,14 @@
import org.junit.runner.RunWith;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.RuntimeEnvironment;
-import org.robolectric.Shadows;
-import org.robolectric.shadows.ShadowPackageManager;
@RunWith(RobolectricTestRunner.class)
public class PowerMenuPreferenceControllerTest {
private Context mContext;
private Resources mResources;
private PowerMenuPreferenceController mController;
- private ShadowPackageManager mShadowPackageManager;
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 CONTROLS_FEATURE = PackageManager.FEATURE_CONTROLS;
private static final String CARDS_ENABLED = Settings.Secure.GLOBAL_ACTIONS_PANEL_ENABLED;
private static final String CARDS_AVAILABLE = Settings.Secure.GLOBAL_ACTIONS_PANEL_AVAILABLE;
@@ -59,14 +53,12 @@
com.android.internal.R.bool.config_longPressOnPowerForAssistantSettingAvailable))
.thenReturn(true);
when(mContext.getResources()).thenReturn(mResources);
- mShadowPackageManager = Shadows.shadowOf(mContext.getPackageManager());
mController = new PowerMenuPreferenceController(mContext, KEY_GESTURE_POWER_MENU);
}
@Test
public void getAvailabilityStatus_allAvailable_available() {
Settings.Secure.putInt(mContext.getContentResolver(), CARDS_AVAILABLE, 1);
- mShadowPackageManager.setSystemFeature(CONTROLS_FEATURE, true);
when(mResources.getBoolean(
com.android.internal.R.bool.config_longPressOnPowerForAssistantSettingAvailable))
.thenReturn(true);
@@ -78,7 +70,6 @@
@Test
public void getAvailabilityStatus_onlyCardsAvailable_available() {
Settings.Secure.putInt(mContext.getContentResolver(), CARDS_AVAILABLE, 1);
- mShadowPackageManager.setSystemFeature(CONTROLS_FEATURE, false);
when(mResources.getBoolean(
com.android.internal.R.bool.config_longPressOnPowerForAssistantSettingAvailable))
.thenReturn(false);
@@ -88,45 +79,8 @@
}
@Test
- public void getAvailabilityStatus_onlyControlsAvailable_available() {
- Settings.Secure.putInt(mContext.getContentResolver(), CARDS_AVAILABLE, 0);
- mShadowPackageManager.setSystemFeature(CONTROLS_FEATURE, true);
- when(mResources.getBoolean(
- com.android.internal.R.bool.config_longPressOnPowerForAssistantSettingAvailable))
- .thenReturn(false);
-
- assertThat(mController.getAvailabilityStatus()).isEqualTo(
- BasePreferenceController.AVAILABLE);
- }
-
- @Test
- public void getAvailabilityStatus_controlsAndCardsAvailable_available() {
- Settings.Secure.putInt(mContext.getContentResolver(), CARDS_AVAILABLE, 1);
- mShadowPackageManager.setSystemFeature(CONTROLS_FEATURE, true);
- when(mResources.getBoolean(
- com.android.internal.R.bool.config_longPressOnPowerForAssistantSettingAvailable))
- .thenReturn(false);
-
- assertThat(mController.getAvailabilityStatus()).isEqualTo(
- BasePreferenceController.AVAILABLE);
- }
-
- @Test
- public void getAvailabilityStatus_controlsAndAssistAvailable_available() {
- Settings.Secure.putInt(mContext.getContentResolver(), CARDS_AVAILABLE, 0);
- mShadowPackageManager.setSystemFeature(CONTROLS_FEATURE, true);
- when(mResources.getBoolean(
- com.android.internal.R.bool.config_longPressOnPowerForAssistantSettingAvailable))
- .thenReturn(true);
-
- assertThat(mController.getAvailabilityStatus()).isEqualTo(
- BasePreferenceController.AVAILABLE);
- }
-
- @Test
public void getAvailabilityStatus_cardsAndAssistAvailable_available() {
Settings.Secure.putInt(mContext.getContentResolver(), CARDS_AVAILABLE, 1);
- mShadowPackageManager.setSystemFeature(CONTROLS_FEATURE, false);
when(mResources.getBoolean(
com.android.internal.R.bool.config_longPressOnPowerForAssistantSettingAvailable))
.thenReturn(true);
@@ -138,7 +92,6 @@
@Test
public void getAvailabilityStatus_onlyAssistAvailable_available() {
Settings.Secure.putInt(mContext.getContentResolver(), CARDS_AVAILABLE, 0);
- mShadowPackageManager.setSystemFeature(CONTROLS_FEATURE, false);
when(mResources.getBoolean(
com.android.internal.R.bool.config_longPressOnPowerForAssistantSettingAvailable))
.thenReturn(true);
@@ -150,7 +103,6 @@
@Test
public void getAvailabilityStatus_allUnavailable_unavailable() {
Settings.Secure.putInt(mContext.getContentResolver(), CARDS_AVAILABLE, 0);
- mShadowPackageManager.setSystemFeature(CONTROLS_FEATURE, false);
when(mResources.getBoolean(
com.android.internal.R.bool.config_longPressOnPowerForAssistantSettingAvailable))
.thenReturn(false);
diff --git a/tests/robotests/src/com/android/settings/gestures/PowerMenuPrivacyPreferenceControllerAvailabilityTest.java b/tests/robotests/src/com/android/settings/gestures/PowerMenuPrivacyPreferenceControllerAvailabilityTest.java
index 40b94eb..e1430fc 100644
--- a/tests/robotests/src/com/android/settings/gestures/PowerMenuPrivacyPreferenceControllerAvailabilityTest.java
+++ b/tests/robotests/src/com/android/settings/gestures/PowerMenuPrivacyPreferenceControllerAvailabilityTest.java
@@ -46,32 +46,23 @@
@RunWith(ParameterizedRobolectricTestRunner.class)
public class PowerMenuPrivacyPreferenceControllerAvailabilityTest {
- private static final String CONTROLS_ENABLED = Settings.Secure.CONTROLS_ENABLED;
private static final String CONTROLS_FEATURE = PackageManager.FEATURE_CONTROLS;
private static final String CARDS_ENABLED = Settings.Secure.GLOBAL_ACTIONS_PANEL_ENABLED;
private static final String CARDS_AVAILABLE = Settings.Secure.GLOBAL_ACTIONS_PANEL_AVAILABLE;
@ParameterizedRobolectricTestRunner.Parameters(
- name = "ctrls available={0}, ctrls enabled={1}, cards available={2}, cards enabled={3}")
+ name = "ctrls available={0} cards available={1}, cards enabled={2}")
public static Collection data() {
return Arrays.asList(new Object[][]{
- // controls available, controls enabled, cards available, cards enabled, available
- {false, false, false, false, BasePreferenceController.DISABLED_DEPENDENT_SETTING},
- {false, false, false, true, BasePreferenceController.DISABLED_DEPENDENT_SETTING},
- {false, false, true, false, BasePreferenceController.DISABLED_DEPENDENT_SETTING},
- {false, false, true, true, BasePreferenceController.AVAILABLE},
- {false, true, false, false, BasePreferenceController.DISABLED_DEPENDENT_SETTING},
- {false, true, false, true, BasePreferenceController.DISABLED_DEPENDENT_SETTING},
- {false, true, true, false, BasePreferenceController.DISABLED_DEPENDENT_SETTING},
- {false, true, true, true, BasePreferenceController.AVAILABLE},
- {true, false, false, false, BasePreferenceController.DISABLED_DEPENDENT_SETTING},
- {true, false, false, true, BasePreferenceController.DISABLED_DEPENDENT_SETTING},
- {true, false, true, false, BasePreferenceController.DISABLED_DEPENDENT_SETTING},
- {true, false, true, true, BasePreferenceController.AVAILABLE},
- {true, true, false, false, BasePreferenceController.AVAILABLE},
- {true, true, false, true, BasePreferenceController.AVAILABLE},
- {true, true, true, false, BasePreferenceController.AVAILABLE},
- {true, true, true, true, BasePreferenceController.AVAILABLE}
+ // controls available, cards available, cards enabled, available
+ {false, false, false, BasePreferenceController.DISABLED_DEPENDENT_SETTING},
+ {false, false, true, BasePreferenceController.DISABLED_DEPENDENT_SETTING},
+ {false, true, false, BasePreferenceController.DISABLED_DEPENDENT_SETTING},
+ {false, true, true, BasePreferenceController.AVAILABLE},
+ {true, false, false, BasePreferenceController.AVAILABLE},
+ {true, false, true, BasePreferenceController.AVAILABLE},
+ {true, true, false, BasePreferenceController.AVAILABLE},
+ {true, true, true, BasePreferenceController.AVAILABLE}
});
}
@@ -83,19 +74,16 @@
private LockPatternUtils mLockPatternUtils;
private boolean mControlsAvailable;
- private boolean mControlsEnabled;
private boolean mCardsAvailable;
private boolean mCardsEnabled;
private int mAvailable;
public PowerMenuPrivacyPreferenceControllerAvailabilityTest(
boolean controlsAvailable,
- boolean controlsEnabled,
boolean cardsAvailable,
boolean cardsEnabled,
int available) {
mControlsAvailable = controlsAvailable;
- mControlsEnabled = controlsEnabled;
mCardsAvailable = cardsAvailable;
mCardsEnabled = cardsEnabled;
mAvailable = available;
@@ -120,7 +108,6 @@
public void getAvailabilityStatus_possiblyAvailableAndEnabled() {
mShadowPackageManager.setSystemFeature(CONTROLS_FEATURE, mControlsAvailable);
ContentResolver cr = mContext.getContentResolver();
- Settings.Secure.putInt(cr, CONTROLS_ENABLED, mControlsEnabled ? 1 : 0);
Settings.Secure.putInt(cr, CARDS_AVAILABLE, mCardsAvailable ? 1 : 0);
Settings.Secure.putInt(cr, CARDS_ENABLED, mCardsEnabled ? 1 : 0);
diff --git a/tests/robotests/src/com/android/settings/gestures/PowerMenuPrivacyPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/gestures/PowerMenuPrivacyPreferenceControllerTest.java
index 994a3ee..5c0ffa1 100644
--- a/tests/robotests/src/com/android/settings/gestures/PowerMenuPrivacyPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/gestures/PowerMenuPrivacyPreferenceControllerTest.java
@@ -54,7 +54,6 @@
private static final String CARDS_AVAILABLE_KEY =
Settings.Secure.GLOBAL_ACTIONS_PANEL_AVAILABLE;
private static final String CARDS_ENABLED_KEY = Settings.Secure.GLOBAL_ACTIONS_PANEL_ENABLED;
- private static final String CONTROLS_ENABLED_KEY = Settings.Secure.CONTROLS_ENABLED;
private Context mContext;
private ContentResolver mContentResolver;
@@ -171,18 +170,8 @@
mShadowPackageManager.setSystemFeature(PackageManager.FEATURE_CONTROLS, true);
Settings.Secure.putInt(mContentResolver, CARDS_AVAILABLE_KEY, 1);
Settings.Secure.putInt(mContentResolver, CARDS_ENABLED_KEY, 1);
- Settings.Secure.putInt(mContentResolver, CONTROLS_ENABLED_KEY, 1);
assertThat(mController.getAvailabilityStatus()).isEqualTo(
BasePreferenceController.DISABLED_DEPENDENT_SETTING);
}
-
- @Test
- public void getAvailabilityStatus_controlsDeletedSecure_retursAvailable() {
- Settings.Secure.putString(mContentResolver, CONTROLS_ENABLED_KEY, null);
- mShadowPackageManager.setSystemFeature(PackageManager.FEATURE_CONTROLS, true);
-
- assertThat(mController.getAvailabilityStatus()).isEqualTo(
- BasePreferenceController.AVAILABLE);
- }
}