diff --git a/AndroidManifest.xml b/AndroidManifest.xml index 4059b806a5f..a6aa5ade66f 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -3688,17 +3688,6 @@ android:value="com.android.settings.gestures.PowerMenuSettings" /> - - - - - - - - This choice is no longer valid. Try again. - - Device controls - device controls @@ -12895,12 +12892,6 @@ Show cards & passes - - Show device controls - - - Show cards, passes, and device controls - Lock screen diff --git a/res/xml/device_controls_settings.xml b/res/xml/device_controls_settings.xml deleted file mode 100644 index c22cd4a814a..00000000000 --- a/res/xml/device_controls_settings.xml +++ /dev/null @@ -1,36 +0,0 @@ - - - - - - - - - - diff --git a/res/xml/power_menu_settings.xml b/res/xml/power_menu_settings.xml index bfe9c20679b..406cd0b3708 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" /> - - diff --git a/src/com/android/settings/core/gateway/SettingsGateway.java b/src/com/android/settings/core/gateway/SettingsGateway.java index 1ea7e177082..a6305cbb83a 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.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; @@ -306,7 +305,6 @@ public class SettingsGateway { 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 0e0c04bddbd..00000000000 --- 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 df36717cb0b..00000000000 --- 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 b11ba65c43c..7c9cd24d6a4 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 @@ 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 = @@ -38,17 +36,10 @@ public class PowerMenuPreferenceController extends BasePreferenceController { @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 @@ public class PowerMenuPreferenceController extends BasePreferenceController { @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 0cd71ee8657..0e0b3f9191b 100644 --- a/src/com/android/settings/gestures/PowerMenuPrivacyPreferenceController.java +++ b/src/com/android/settings/gestures/PowerMenuPrivacyPreferenceController.java @@ -35,7 +35,6 @@ public class PowerMenuPrivacyPreferenceController extends TogglePreferenceContro 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 @@ public class PowerMenuPrivacyPreferenceController extends TogglePreferenceContro 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 432a68d0a8b..00000000000 --- 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 2ec0f1d1602..00000000000 --- 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 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 7fa248c7c93..4ed0a0193eb 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 static com.google.common.truth.Truth.assertThat; 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.Test; 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 @@ import java.util.Collection; 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 @@ public class PowerMenuPreferenceControllerSummaryTest { @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 fc45ddb89d7..d734975dbfb 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.spy; 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.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 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 @@ public class PowerMenuPreferenceControllerTest { 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 @@ public class PowerMenuPreferenceControllerTest { @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); @@ -87,46 +78,9 @@ public class PowerMenuPreferenceControllerTest { BasePreferenceController.AVAILABLE); } - @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 @@ public class PowerMenuPreferenceControllerTest { @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 @@ public class PowerMenuPreferenceControllerTest { @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 40b94ebe33d..e1430fcc8d4 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 @@ import java.util.Collection; @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 @@ public class PowerMenuPrivacyPreferenceControllerAvailabilityTest { 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 class PowerMenuPrivacyPreferenceControllerAvailabilityTest { 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 994a3eece31..5c0ffa15c75 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 @@ public class PowerMenuPrivacyPreferenceControllerTest { 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 @@ public class PowerMenuPrivacyPreferenceControllerTest { 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); - } }