summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Fritze <mfritze@google.com>2018-05-18 17:59:26 -0700
committerAndrew Sapperstein <asapperstein@google.com>2018-05-22 22:43:24 +0000
commit1dd25fd87c727fbf175027faf6a9a533c5cf7220 (patch)
tree709d8970d2ab4f253b3408a66ee11d3147f83840
parenta419c4717dd0ed0e762c7451bf990baf1a703906 (diff)
downloadpackages_apps_Settings-1dd25fd87c727fbf175027faf6a9a533c5cf7220.tar.gz
packages_apps_Settings-1dd25fd87c727fbf175027faf6a9a533c5cf7220.tar.bz2
packages_apps_Settings-1dd25fd87c727fbf175027faf6a9a533c5cf7220.zip
Add isSliceable API to BasePrefController
Only support explicitly approved Settings Slices, dictated by controllers which return true for the new method isSliceable. Updating the supported settings to a whitelist means that the method to return all available slices must be updated, and checking slicability when we index slices. Test: robotests Change-Id: I85848c2cdf3e151fa94b33dd1dc5c0374ef94b5b Merged-In: Ib2b9690cdd0036b5cc4a1cb846c52bce7c824ab9 Fixes: 79779103
-rw-r--r--src/com/android/settings/accessibility/AccessibilitySlicePreferenceController.java5
-rw-r--r--src/com/android/settings/core/BasePreferenceController.java17
-rw-r--r--src/com/android/settings/display/AmbientDisplayAlwaysOnPreferenceController.java6
-rw-r--r--src/com/android/settings/display/AmbientDisplayNotificationsPreferenceController.java6
-rw-r--r--src/com/android/settings/display/AutoBrightnessPreferenceController.java6
-rw-r--r--src/com/android/settings/display/AutoRotatePreferenceController.java8
-rw-r--r--src/com/android/settings/display/NightDisplayActivationPreferenceController.java6
-rw-r--r--src/com/android/settings/display/NightDisplayIntensityPreferenceController.java7
-rw-r--r--src/com/android/settings/gestures/DoubleTapPowerPreferenceController.java6
-rw-r--r--src/com/android/settings/gestures/DoubleTapScreenPreferenceController.java5
-rw-r--r--src/com/android/settings/gestures/DoubleTwistPreferenceController.java5
-rw-r--r--src/com/android/settings/gestures/PickupGesturePreferenceController.java5
-rw-r--r--src/com/android/settings/gestures/SwipeToNotificationPreferenceController.java6
-rw-r--r--src/com/android/settings/gestures/SwipeUpPreferenceController.java6
-rw-r--r--src/com/android/settings/network/AirplaneModePreferenceController.java6
-rw-r--r--src/com/android/settings/notification/BadgingNotificationPreferenceController.java6
-rw-r--r--src/com/android/settings/notification/CallVolumePreferenceController.java6
-rw-r--r--src/com/android/settings/notification/MediaVolumePreferenceController.java6
-rw-r--r--src/com/android/settings/notification/NotificationVolumePreferenceController.java6
-rw-r--r--src/com/android/settings/notification/RingVolumePreferenceController.java6
-rw-r--r--src/com/android/settings/notification/VibrateWhenRingPreferenceController.java6
-rw-r--r--src/com/android/settings/slices/SettingsSliceProvider.java34
-rw-r--r--src/com/android/settings/slices/SliceDataConverter.java11
-rw-r--r--tests/robotests/src/com/android/settings/display/AmbientDisplayAlwaysOnPreferenceControllerTest.java15
-rw-r--r--tests/robotests/src/com/android/settings/display/AmbientDisplayNotificationsPreferenceControllerTest.java15
-rw-r--r--tests/robotests/src/com/android/settings/display/AutoBrightnessPreferenceControllerTest.java15
-rw-r--r--tests/robotests/src/com/android/settings/display/AutoRotatePreferenceControllerTest.java18
-rw-r--r--tests/robotests/src/com/android/settings/display/NightDisplayActivationPreferenceControllerTest.java14
-rw-r--r--tests/robotests/src/com/android/settings/display/NightDisplayIntensityPreferenceControllerTest.java14
-rw-r--r--tests/robotests/src/com/android/settings/gestures/DoubleTapPowerPreferenceControllerTest.java32
-rw-r--r--tests/robotests/src/com/android/settings/gestures/DoubleTapScreenPreferenceControllerTest.java14
-rw-r--r--tests/robotests/src/com/android/settings/gestures/DoubleTwistPreferenceControllerTest.java14
-rw-r--r--tests/robotests/src/com/android/settings/gestures/PickupGesturePreferenceControllerTest.java14
-rw-r--r--tests/robotests/src/com/android/settings/gestures/SwipeToNotificationPreferenceControllerTest.java14
-rw-r--r--tests/robotests/src/com/android/settings/gestures/SwipeUpPreferenceControllerTest.java14
-rw-r--r--tests/robotests/src/com/android/settings/network/AirplaneModePreferenceControllerTest.java14
-rw-r--r--tests/robotests/src/com/android/settings/notification/BadgingNotificationPreferenceControllerTest.java15
-rw-r--r--tests/robotests/src/com/android/settings/notification/CallVolumePreferenceControllerTest.java14
-rw-r--r--tests/robotests/src/com/android/settings/notification/MediaVolumePreferenceControllerTest.java13
-rw-r--r--tests/robotests/src/com/android/settings/notification/NotificationVolumePreferenceControllerTest.java7
-rw-r--r--tests/robotests/src/com/android/settings/notification/RingVolumePreferenceControllerTest.java7
-rw-r--r--tests/robotests/src/com/android/settings/notification/VibrateWhenRingPreferenceControllerTest.java14
-rw-r--r--tests/robotests/src/com/android/settings/slices/FakePreferenceController.java5
-rw-r--r--tests/robotests/src/com/android/settings/slices/SlicesDatabaseAccessorTest.java9
-rw-r--r--tests/robotests/src/com/android/settings/testutils/FakeSliderController.java5
-rw-r--r--tests/robotests/src/com/android/settings/testutils/FakeToggleController.java5
-rw-r--r--tests/robotests/src/com/android/settings/testutils/FakeUnavailablePreferenceController.java5
47 files changed, 471 insertions, 16 deletions
diff --git a/src/com/android/settings/accessibility/AccessibilitySlicePreferenceController.java b/src/com/android/settings/accessibility/AccessibilitySlicePreferenceController.java
index ec988cd0f2..d1a60faa74 100644
--- a/src/com/android/settings/accessibility/AccessibilitySlicePreferenceController.java
+++ b/src/com/android/settings/accessibility/AccessibilitySlicePreferenceController.java
@@ -90,6 +90,11 @@ public class AccessibilitySlicePreferenceController extends TogglePreferenceCont
return getAccessibilityServiceInfo() == null ? UNSUPPORTED_ON_DEVICE : AVAILABLE;
}
+ @Override
+ public boolean isSliceable() {
+ return true;
+ }
+
private AccessibilityServiceInfo getAccessibilityServiceInfo() {
final AccessibilityManager accessibilityManager = mContext.getSystemService(
AccessibilityManager.class);
diff --git a/src/com/android/settings/core/BasePreferenceController.java b/src/com/android/settings/core/BasePreferenceController.java
index 816141eab9..c2d1cf52fa 100644
--- a/src/com/android/settings/core/BasePreferenceController.java
+++ b/src/com/android/settings/core/BasePreferenceController.java
@@ -230,6 +230,23 @@ public abstract class BasePreferenceController extends AbstractPreferenceControl
}
/**
+ * Determines if the controller should be used as a Slice.
+ * <p>
+ * Important criteria for a Slice are:
+ * - Must be secure
+ * - Must not be a privacy leak
+ * - Must be understandable as a stand-alone Setting.
+ * <p>
+ * This does not guarantee the setting is available. {@link #isAvailable()} should sill be
+ * called.
+ *
+ * @return {@code true} if the controller should be used externally as a Slice.
+ */
+ public boolean isSliceable() {
+ return false;
+ }
+
+ /**
* Updates non-indexable keys for search provider.
*
* Called by SearchIndexProvider#getNonIndexableKeys
diff --git a/src/com/android/settings/display/AmbientDisplayAlwaysOnPreferenceController.java b/src/com/android/settings/display/AmbientDisplayAlwaysOnPreferenceController.java
index cb04ed4ca1..e91ddbece9 100644
--- a/src/com/android/settings/display/AmbientDisplayAlwaysOnPreferenceController.java
+++ b/src/com/android/settings/display/AmbientDisplayAlwaysOnPreferenceController.java
@@ -19,6 +19,7 @@ import android.content.Context;
import android.content.Intent;
import android.os.UserHandle;
import android.provider.Settings;
+import android.text.TextUtils;
import com.android.internal.hardware.AmbientDisplayConfiguration;
import com.android.settings.R;
@@ -54,6 +55,11 @@ public class AmbientDisplayAlwaysOnPreferenceController extends TogglePreference
}
@Override
+ public boolean isSliceable() {
+ return TextUtils.equals(getPreferenceKey(), "ambient_display_always_on");
+ }
+
+ @Override
public boolean isChecked() {
return mConfig.alwaysOnEnabled(MY_USER);
}
diff --git a/src/com/android/settings/display/AmbientDisplayNotificationsPreferenceController.java b/src/com/android/settings/display/AmbientDisplayNotificationsPreferenceController.java
index a44b294fd6..5c33596790 100644
--- a/src/com/android/settings/display/AmbientDisplayNotificationsPreferenceController.java
+++ b/src/com/android/settings/display/AmbientDisplayNotificationsPreferenceController.java
@@ -23,6 +23,7 @@ import android.os.UserHandle;
import android.provider.Settings;
import android.support.annotation.VisibleForTesting;
import android.support.v7.preference.Preference;
+import android.text.TextUtils;
import com.android.internal.hardware.AmbientDisplayConfiguration;
import com.android.settings.R;
@@ -90,6 +91,11 @@ public class AmbientDisplayNotificationsPreferenceController extends
}
@Override
+ public boolean isSliceable() {
+ return TextUtils.equals(getPreferenceKey(), "ambient_display_notification");
+ }
+
+ @Override
//TODO (b/69808376): Remove result payload
public ResultPayload getResultPayload() {
final Intent intent = DatabaseIndexingUtils.buildSearchResultPageIntent(mContext,
diff --git a/src/com/android/settings/display/AutoBrightnessPreferenceController.java b/src/com/android/settings/display/AutoBrightnessPreferenceController.java
index 564e27ad3d..7c93d28590 100644
--- a/src/com/android/settings/display/AutoBrightnessPreferenceController.java
+++ b/src/com/android/settings/display/AutoBrightnessPreferenceController.java
@@ -16,6 +16,7 @@ package com.android.settings.display;
import android.content.Context;
import android.content.Intent;
import android.provider.Settings;
+import android.text.TextUtils;
import com.android.settings.DisplaySettings;
import com.android.settings.core.TogglePreferenceController;
@@ -61,6 +62,11 @@ public class AutoBrightnessPreferenceController extends TogglePreferenceControll
}
@Override
+ public boolean isSliceable() {
+ return TextUtils.equals(getPreferenceKey(), "auto_brightness");
+ }
+
+ @Override
public ResultPayload getResultPayload() {
// TODO remove result payload
final Intent intent = DatabaseIndexingUtils.buildSearchResultPageIntent(mContext,
diff --git a/src/com/android/settings/display/AutoRotatePreferenceController.java b/src/com/android/settings/display/AutoRotatePreferenceController.java
index 6580b03f01..324d66c817 100644
--- a/src/com/android/settings/display/AutoRotatePreferenceController.java
+++ b/src/com/android/settings/display/AutoRotatePreferenceController.java
@@ -15,6 +15,7 @@ package com.android.settings.display;
import android.content.Context;
import android.support.v7.preference.Preference;
+import android.text.TextUtils;
import com.android.internal.logging.nano.MetricsProto;
import com.android.internal.view.RotationPolicy;
@@ -71,7 +72,12 @@ public class AutoRotatePreferenceController extends TogglePreferenceController i
@Override
public int getAvailabilityStatus() {
return RotationPolicy.isRotationLockToggleVisible(mContext)
- ? AVAILABLE : CONDITIONALLY_UNAVAILABLE;
+ ? AVAILABLE : UNSUPPORTED_ON_DEVICE;
+ }
+
+ @Override
+ public boolean isSliceable() {
+ return TextUtils.equals(getPreferenceKey(), "auto_rotate");
}
@Override
diff --git a/src/com/android/settings/display/NightDisplayActivationPreferenceController.java b/src/com/android/settings/display/NightDisplayActivationPreferenceController.java
index 7f50d0aba7..622aff88a0 100644
--- a/src/com/android/settings/display/NightDisplayActivationPreferenceController.java
+++ b/src/com/android/settings/display/NightDisplayActivationPreferenceController.java
@@ -19,6 +19,7 @@ package com.android.settings.display;
import android.content.Context;
import android.support.v7.preference.Preference;
import android.support.v7.preference.PreferenceScreen;
+import android.text.TextUtils;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
@@ -54,6 +55,11 @@ public class NightDisplayActivationPreferenceController extends TogglePreference
}
@Override
+ public boolean isSliceable() {
+ return TextUtils.equals(getPreferenceKey(), "night_display_activated");
+ }
+
+ @Override
public void displayPreference(PreferenceScreen screen) {
super.displayPreference(screen);
diff --git a/src/com/android/settings/display/NightDisplayIntensityPreferenceController.java b/src/com/android/settings/display/NightDisplayIntensityPreferenceController.java
index ec7e5776cb..bb498ab711 100644
--- a/src/com/android/settings/display/NightDisplayIntensityPreferenceController.java
+++ b/src/com/android/settings/display/NightDisplayIntensityPreferenceController.java
@@ -19,6 +19,8 @@ package com.android.settings.display;
import android.content.Context;
import android.support.v7.preference.Preference;
import android.support.v7.preference.PreferenceScreen;
+import android.text.TextUtils;
+
import com.android.internal.app.ColorDisplayController;
import com.android.settings.core.SliderPreferenceController;
import com.android.settings.widget.SeekBarPreference;
@@ -43,6 +45,11 @@ public class NightDisplayIntensityPreferenceController extends SliderPreferenceC
}
@Override
+ public boolean isSliceable() {
+ return TextUtils.equals(getPreferenceKey(), "night_display_temperature");
+ }
+
+ @Override
public void displayPreference(PreferenceScreen screen) {
super.displayPreference(screen);
final SeekBarPreference preference = (SeekBarPreference) screen.findPreference(
diff --git a/src/com/android/settings/gestures/DoubleTapPowerPreferenceController.java b/src/com/android/settings/gestures/DoubleTapPowerPreferenceController.java
index c400cbda1e..002a4477f6 100644
--- a/src/com/android/settings/gestures/DoubleTapPowerPreferenceController.java
+++ b/src/com/android/settings/gestures/DoubleTapPowerPreferenceController.java
@@ -23,6 +23,7 @@ import android.content.Intent;
import android.content.SharedPreferences;
import android.provider.Settings;
import android.support.annotation.VisibleForTesting;
+import android.text.TextUtils;
import com.android.settings.R;
import com.android.settings.search.DatabaseIndexingUtils;
@@ -62,6 +63,11 @@ public class DoubleTapPowerPreferenceController extends GesturePreferenceControl
}
@Override
+ public boolean isSliceable() {
+ return TextUtils.equals(getPreferenceKey(), "gesture_double_tap_power");
+ }
+
+ @Override
protected String getVideoPrefKey() {
return PREF_KEY_VIDEO;
}
diff --git a/src/com/android/settings/gestures/DoubleTapScreenPreferenceController.java b/src/com/android/settings/gestures/DoubleTapScreenPreferenceController.java
index 4dd483a4fe..521e81ff02 100644
--- a/src/com/android/settings/gestures/DoubleTapScreenPreferenceController.java
+++ b/src/com/android/settings/gestures/DoubleTapScreenPreferenceController.java
@@ -90,6 +90,11 @@ public class DoubleTapScreenPreferenceController extends GesturePreferenceContro
}
@Override
+ public boolean isSliceable() {
+ return TextUtils.equals(getPreferenceKey(), "gesture_double_tap_screen");
+ }
+
+ @Override
public boolean setChecked(boolean isChecked) {
return Settings.Secure.putInt(mContext.getContentResolver(), SECURE_KEY,
isChecked ? ON : OFF);
diff --git a/src/com/android/settings/gestures/DoubleTwistPreferenceController.java b/src/com/android/settings/gestures/DoubleTwistPreferenceController.java
index 2dd8635247..10b278a5e5 100644
--- a/src/com/android/settings/gestures/DoubleTwistPreferenceController.java
+++ b/src/com/android/settings/gestures/DoubleTwistPreferenceController.java
@@ -72,6 +72,11 @@ public class DoubleTwistPreferenceController extends GesturePreferenceController
}
@Override
+ public boolean isSliceable() {
+ return TextUtils.equals(getPreferenceKey(), "gesture_double_twist");
+ }
+
+ @Override
protected String getVideoPrefKey() {
return PREF_KEY_VIDEO;
}
diff --git a/src/com/android/settings/gestures/PickupGesturePreferenceController.java b/src/com/android/settings/gestures/PickupGesturePreferenceController.java
index d0f247ec14..4ecad14d97 100644
--- a/src/com/android/settings/gestures/PickupGesturePreferenceController.java
+++ b/src/com/android/settings/gestures/PickupGesturePreferenceController.java
@@ -84,6 +84,11 @@ public class PickupGesturePreferenceController extends GesturePreferenceControll
}
@Override
+ public boolean isSliceable() {
+ return TextUtils.equals(getPreferenceKey(), "gesture_pick_up");
+ }
+
+ @Override
protected String getVideoPrefKey() {
return PREF_KEY_VIDEO;
}
diff --git a/src/com/android/settings/gestures/SwipeToNotificationPreferenceController.java b/src/com/android/settings/gestures/SwipeToNotificationPreferenceController.java
index bb6a26d880..104abf98d1 100644
--- a/src/com/android/settings/gestures/SwipeToNotificationPreferenceController.java
+++ b/src/com/android/settings/gestures/SwipeToNotificationPreferenceController.java
@@ -21,6 +21,7 @@ import static android.provider.Settings.Secure.SYSTEM_NAVIGATION_KEYS_ENABLED;
import android.content.Context;
import android.content.SharedPreferences;
import android.provider.Settings;
+import android.text.TextUtils;
import com.android.settings.Utils;
@@ -60,6 +61,11 @@ public class SwipeToNotificationPreferenceController extends GesturePreferenceCo
}
@Override
+ public boolean isSliceable() {
+ return TextUtils.equals(getPreferenceKey(), "gesture_swipe_down_fingerprint");
+ }
+
+ @Override
public boolean setChecked(boolean isChecked) {
setSwipeToNotification(mContext, isChecked);
return true;
diff --git a/src/com/android/settings/gestures/SwipeUpPreferenceController.java b/src/com/android/settings/gestures/SwipeUpPreferenceController.java
index b768a2ce63..f6358737f8 100644
--- a/src/com/android/settings/gestures/SwipeUpPreferenceController.java
+++ b/src/com/android/settings/gestures/SwipeUpPreferenceController.java
@@ -23,6 +23,7 @@ import android.content.pm.PackageManager;
import android.os.UserManager;
import android.provider.Settings;
import android.support.annotation.VisibleForTesting;
+import android.text.TextUtils;
import com.android.internal.R;
@@ -62,6 +63,11 @@ public class SwipeUpPreferenceController extends GesturePreferenceController {
}
@Override
+ public boolean isSliceable() {
+ return TextUtils.equals(getPreferenceKey(), "gesture_swipe_up");
+ }
+
+ @Override
protected String getVideoPrefKey() {
return PREF_KEY_VIDEO;
}
diff --git a/src/com/android/settings/network/AirplaneModePreferenceController.java b/src/com/android/settings/network/AirplaneModePreferenceController.java
index b6246e344a..2b9a35de6e 100644
--- a/src/com/android/settings/network/AirplaneModePreferenceController.java
+++ b/src/com/android/settings/network/AirplaneModePreferenceController.java
@@ -23,6 +23,7 @@ import android.os.SystemProperties;
import android.support.v14.preference.SwitchPreference;
import android.support.v7.preference.Preference;
import android.support.v7.preference.PreferenceScreen;
+import android.text.TextUtils;
import com.android.internal.telephony.TelephonyIntents;
import com.android.internal.telephony.TelephonyProperties;
@@ -91,6 +92,11 @@ public class AirplaneModePreferenceController extends TogglePreferenceController
}
@Override
+ public boolean isSliceable() {
+ return TextUtils.equals(getPreferenceKey(), "toggle_airplane");
+ }
+
+ @Override
@AvailabilityStatus
public int getAvailabilityStatus() {
return isAvailable(mContext) ? AVAILABLE : UNSUPPORTED_ON_DEVICE;
diff --git a/src/com/android/settings/notification/BadgingNotificationPreferenceController.java b/src/com/android/settings/notification/BadgingNotificationPreferenceController.java
index 260a415246..9e3757a86d 100644
--- a/src/com/android/settings/notification/BadgingNotificationPreferenceController.java
+++ b/src/com/android/settings/notification/BadgingNotificationPreferenceController.java
@@ -27,6 +27,7 @@ import android.support.annotation.VisibleForTesting;
import android.support.v7.preference.Preference;
import android.support.v7.preference.PreferenceScreen;
import android.support.v7.preference.TwoStatePreference;
+import android.text.TextUtils;
import com.android.settings.core.PreferenceControllerMixin;
import com.android.settings.core.TogglePreferenceController;
@@ -88,6 +89,11 @@ public class BadgingNotificationPreferenceController extends TogglePreferenceCon
}
@Override
+ public boolean isSliceable() {
+ return TextUtils.equals(getPreferenceKey(), "notification_badging");
+ }
+
+ @Override
public boolean isChecked() {
return Settings.Secure.getInt(mContext.getContentResolver(),
NOTIFICATION_BADGING, ON) == ON;
diff --git a/src/com/android/settings/notification/CallVolumePreferenceController.java b/src/com/android/settings/notification/CallVolumePreferenceController.java
index c0e16331f4..a3eb87f898 100644
--- a/src/com/android/settings/notification/CallVolumePreferenceController.java
+++ b/src/com/android/settings/notification/CallVolumePreferenceController.java
@@ -18,6 +18,7 @@ package com.android.settings.notification;
import android.content.Context;
import android.media.AudioManager;
+import android.text.TextUtils;
import com.android.settings.R;
@@ -38,6 +39,11 @@ public class CallVolumePreferenceController extends VolumeSeekBarPreferenceContr
}
@Override
+ public boolean isSliceable() {
+ return TextUtils.equals(getPreferenceKey(), "call_volume");
+ }
+
+ @Override
public int getAudioStream() {
if (mAudioManager.isBluetoothScoOn()) {
return AudioManager.STREAM_BLUETOOTH_SCO;
diff --git a/src/com/android/settings/notification/MediaVolumePreferenceController.java b/src/com/android/settings/notification/MediaVolumePreferenceController.java
index f3bffe075e..46f57292a3 100644
--- a/src/com/android/settings/notification/MediaVolumePreferenceController.java
+++ b/src/com/android/settings/notification/MediaVolumePreferenceController.java
@@ -18,6 +18,7 @@ package com.android.settings.notification;
import android.content.Context;
import android.media.AudioManager;
+import android.text.TextUtils;
import com.android.settings.R;
@@ -38,6 +39,11 @@ public class MediaVolumePreferenceController extends
}
@Override
+ public boolean isSliceable() {
+ return TextUtils.equals(getPreferenceKey(), KEY_MEDIA_VOLUME);
+ }
+
+ @Override
public String getPreferenceKey() {
return KEY_MEDIA_VOLUME;
}
diff --git a/src/com/android/settings/notification/NotificationVolumePreferenceController.java b/src/com/android/settings/notification/NotificationVolumePreferenceController.java
index c3c8793cf2..5995462053 100644
--- a/src/com/android/settings/notification/NotificationVolumePreferenceController.java
+++ b/src/com/android/settings/notification/NotificationVolumePreferenceController.java
@@ -18,6 +18,7 @@ package com.android.settings.notification;
import android.content.Context;
import android.media.AudioManager;
+import android.text.TextUtils;
import com.android.settings.R;
import com.android.settings.Utils;
@@ -39,6 +40,11 @@ public class NotificationVolumePreferenceController extends
}
@Override
+ public boolean isSliceable() {
+ return TextUtils.equals(getPreferenceKey(), KEY_NOTIFICATION_VOLUME);
+ }
+
+ @Override
public String getPreferenceKey() {
return KEY_NOTIFICATION_VOLUME;
}
diff --git a/src/com/android/settings/notification/RingVolumePreferenceController.java b/src/com/android/settings/notification/RingVolumePreferenceController.java
index c4c71c408f..d58eabd4a7 100644
--- a/src/com/android/settings/notification/RingVolumePreferenceController.java
+++ b/src/com/android/settings/notification/RingVolumePreferenceController.java
@@ -28,6 +28,7 @@ import android.os.Handler;
import android.os.Looper;
import android.os.Message;
import android.os.Vibrator;
+import android.text.TextUtils;
import com.android.settings.R;
import com.android.settings.Utils;
@@ -89,6 +90,11 @@ public class RingVolumePreferenceController extends VolumeSeekBarPreferenceContr
}
@Override
+ public boolean isSliceable() {
+ return TextUtils.equals(getPreferenceKey(), KEY_RING_VOLUME);
+ }
+
+ @Override
public int getAudioStream() {
return AudioManager.STREAM_RING;
}
diff --git a/src/com/android/settings/notification/VibrateWhenRingPreferenceController.java b/src/com/android/settings/notification/VibrateWhenRingPreferenceController.java
index d2ff7c52e4..4fe6fd9bd2 100644
--- a/src/com/android/settings/notification/VibrateWhenRingPreferenceController.java
+++ b/src/com/android/settings/notification/VibrateWhenRingPreferenceController.java
@@ -26,6 +26,7 @@ import android.os.Handler;
import android.provider.Settings;
import android.support.v7.preference.Preference;
import android.support.v7.preference.PreferenceScreen;
+import android.text.TextUtils;
import com.android.settings.Utils;
import com.android.settings.core.TogglePreferenceController;
@@ -64,6 +65,11 @@ public class VibrateWhenRingPreferenceController extends TogglePreferenceControl
}
@Override
+ public boolean isSliceable() {
+ return TextUtils.equals(getPreferenceKey(), "vibrate_when_ringing");
+ }
+
+ @Override
public void displayPreference(PreferenceScreen screen) {
super.displayPreference(screen);
Preference preference = screen.findPreference(KEY_VIBRATE_WHEN_RINGING);
diff --git a/src/com/android/settings/slices/SettingsSliceProvider.java b/src/com/android/settings/slices/SettingsSliceProvider.java
index 915621e965..3ed6185563 100644
--- a/src/com/android/settings/slices/SettingsSliceProvider.java
+++ b/src/com/android/settings/slices/SettingsSliceProvider.java
@@ -23,11 +23,13 @@ import android.content.ContentResolver;
import android.content.Intent;
import android.content.IntentFilter;
import android.net.Uri;
+import android.provider.Settings;
import android.provider.SettingsSlicesContract;
import android.support.annotation.VisibleForTesting;
import android.support.v4.graphics.drawable.IconCompat;
import android.text.TextUtils;
import android.util.ArraySet;
+import android.util.KeyValueListParser;
import android.util.Log;
import android.util.Pair;
@@ -44,6 +46,7 @@ import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
+import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -115,10 +118,13 @@ public class SettingsSliceProvider extends SliceProvider {
@VisibleForTesting
Map<Uri, SliceData> mSliceDataCache;
+ private final KeyValueListParser mParser;
+
final Set<Uri> mRegisteredUris = new ArraySet<>();
public SettingsSliceProvider() {
super(READ_SEARCH_INDEXABLES);
+ mParser = new KeyValueListParser(',');
}
@Override
@@ -351,4 +357,32 @@ public class SettingsSliceProvider extends SliceProvider {
SliceBroadcastRelay.registerReceiver(getContext(), sliceUri, SliceBroadcastReceiver.class,
intentFilter);
}
+
+ @VisibleForTesting
+ Set<String> getBlockedKeys() {
+ final String value = Settings.Global.getString(getContext().getContentResolver(),
+ Settings.Global.BLOCKED_SLICES);
+ final Set<String> set = new ArraySet<>();
+
+ try {
+ mParser.setString(value);
+ } catch (IllegalArgumentException e) {
+ Log.e(TAG, "Bad Settings Slices Whitelist flags", e);
+ return set;
+ }
+
+ final String[] parsedValues = parseStringArray(value);
+ Collections.addAll(set, parsedValues);
+ return set;
+ }
+
+ private String[] parseStringArray(String value) {
+ if (value != null) {
+ String[] parts = value.split(":");
+ if (parts.length > 0) {
+ return parts;
+ }
+ }
+ return new String[0];
+ }
}
diff --git a/src/com/android/settings/slices/SliceDataConverter.java b/src/com/android/settings/slices/SliceDataConverter.java
index 7bd66baa39..bfe090e846 100644
--- a/src/com/android/settings/slices/SliceDataConverter.java
+++ b/src/com/android/settings/slices/SliceDataConverter.java
@@ -19,7 +19,6 @@ package com.android.settings.slices;
import static com.android.settings.core.PreferenceXmlParserUtils.METADATA_CONTROLLER;
import static com.android.settings.core.PreferenceXmlParserUtils.METADATA_ICON;
import static com.android.settings.core.PreferenceXmlParserUtils.METADATA_KEY;
-import static com.android.settings.core.PreferenceXmlParserUtils.METADATA_KEYWORDS;
import static com.android.settings.core.PreferenceXmlParserUtils.METADATA_PLATFORM_SLICE_FLAG;
import static com.android.settings.core.PreferenceXmlParserUtils.METADATA_SUMMARY;
import static com.android.settings.core.PreferenceXmlParserUtils.METADATA_TITLE;
@@ -44,6 +43,7 @@ import com.android.internal.annotations.VisibleForTesting;
import com.android.settings.R;
import com.android.settings.accessibility.AccessibilitySettings;
import com.android.settings.accessibility.AccessibilitySlicePreferenceController;
+import com.android.settings.core.BasePreferenceController;
import com.android.settings.core.PreferenceXmlParserUtils;
import com.android.settings.core.PreferenceXmlParserUtils.MetadataFlag;
import com.android.settings.dashboard.DashboardFragment;
@@ -194,6 +194,7 @@ class SliceDataConverter {
if (TextUtils.isEmpty(controllerClassName)) {
continue;
}
+
final String key = bundle.getString(METADATA_KEY);
final String title = bundle.getString(METADATA_TITLE);
final String summary = bundle.getString(METADATA_SUMMARY);
@@ -214,7 +215,13 @@ class SliceDataConverter {
.setPlatformDefined(isPlatformSlice)
.build();
- xmlSliceData.add(xmlSlice);
+ final BasePreferenceController controller =
+ SliceBuilderUtils.getPreferenceController(mContext, xmlSlice);
+
+ // Only add pre-approved Slices available on the device.
+ if (controller.isAvailable() && controller.isSliceable()) {
+ xmlSliceData.add(xmlSlice);
+ }
}
} catch (SliceData.InvalidSliceDataException e) {
Log.w(TAG, "Invalid data when building SliceData for " + fragmentName, e);
diff --git a/tests/robotests/src/com/android/settings/display/AmbientDisplayAlwaysOnPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/display/AmbientDisplayAlwaysOnPreferenceControllerTest.java
index 624b07fbd9..42d24f8e35 100644
--- a/tests/robotests/src/com/android/settings/display/AmbientDisplayAlwaysOnPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/display/AmbientDisplayAlwaysOnPreferenceControllerTest.java
@@ -150,4 +150,19 @@ public class AmbientDisplayAlwaysOnPreferenceControllerTest {
assertThat(newValue).isEqualTo(currentValue);
}
+
+ @Test
+ public void isSliceableCorrectKey_returnsTrue() {
+ final AmbientDisplayAlwaysOnPreferenceController controller =
+ new AmbientDisplayAlwaysOnPreferenceController(mContext,
+ "ambient_display_always_on");
+ assertThat(controller.isSliceable()).isTrue();
+ }
+
+ @Test
+ public void isSliceableIncorrectKey_returnsFalse() {
+ final AmbientDisplayAlwaysOnPreferenceController controller =
+ new AmbientDisplayAlwaysOnPreferenceController(mContext, "bad_key");
+ assertThat(controller.isSliceable()).isFalse();
+ }
}
diff --git a/tests/robotests/src/com/android/settings/display/AmbientDisplayNotificationsPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/display/AmbientDisplayNotificationsPreferenceControllerTest.java
index 119d29417b..5cbed2c717 100644
--- a/tests/robotests/src/com/android/settings/display/AmbientDisplayNotificationsPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/display/AmbientDisplayNotificationsPreferenceControllerTest.java
@@ -182,4 +182,19 @@ public class AmbientDisplayNotificationsPreferenceControllerTest {
assertThat(newValue).isEqualTo(currentValue);
}
+
+ @Test
+ public void isSliceableCorrectKey_returnsTrue() {
+ final AmbientDisplayNotificationsPreferenceController controller =
+ new AmbientDisplayNotificationsPreferenceController(mContext,
+ "ambient_display_notification");
+ assertThat(controller.isSliceable()).isTrue();
+ }
+
+ @Test
+ public void isSliceableIncorrectKey_returnsFalse() {
+ final AmbientDisplayNotificationsPreferenceController controller =
+ new AmbientDisplayNotificationsPreferenceController(mContext, "bad_key");
+ assertThat(controller.isSliceable()).isFalse();
+ }
}
diff --git a/tests/robotests/src/com/android/settings/display/AutoBrightnessPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/display/AutoBrightnessPreferenceControllerTest.java
index 5bd77111db..188cb92a64 100644
--- a/tests/robotests/src/com/android/settings/display/AutoBrightnessPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/display/AutoBrightnessPreferenceControllerTest.java
@@ -93,4 +93,19 @@ public class AutoBrightnessPreferenceControllerTest {
assertThat(newValue).isEqualTo(SCREEN_BRIGHTNESS_MODE_AUTOMATIC);
}
+
+ @Test
+ public void isSliceableCorrectKey_returnsTrue() {
+ final AutoBrightnessPreferenceController controller =
+ new AutoBrightnessPreferenceController(mContext,
+ "auto_brightness");
+ assertThat(controller.isSliceable()).isTrue();
+ }
+
+ @Test
+ public void isSliceableIncorrectKey_returnsFalse() {
+ final AutoBrightnessPreferenceController controller =
+ new AutoBrightnessPreferenceController(mContext, "bad_key");
+ assertThat(controller.isSliceable()).isFalse();
+ }
}
diff --git a/tests/robotests/src/com/android/settings/display/AutoRotatePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/display/AutoRotatePreferenceControllerTest.java
index f0ce95f4d9..fe3ae76a17 100644
--- a/tests/robotests/src/com/android/settings/display/AutoRotatePreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/display/AutoRotatePreferenceControllerTest.java
@@ -104,7 +104,7 @@ public class AutoRotatePreferenceControllerTest {
@Test
public void testGetAvailabilityStatus() {
assertThat(mController.getAvailabilityStatus()).isEqualTo(BasePreferenceController
- .CONDITIONALLY_UNAVAILABLE);
+ .UNSUPPORTED_ON_DEVICE);
enableAutoRotationPreference();
@@ -114,7 +114,7 @@ public class AutoRotatePreferenceControllerTest {
disableAutoRotationPreference();
assertThat(mController.getAvailabilityStatus()).isEqualTo(BasePreferenceController
- .CONDITIONALLY_UNAVAILABLE);
+ .UNSUPPORTED_ON_DEVICE);
}
@Test
@@ -144,6 +144,20 @@ public class AutoRotatePreferenceControllerTest {
assertThat(RotationPolicy.isRotationLocked(mContext)).isFalse();
}
+ @Test
+ public void isSliceableCorrectKey_returnsTrue() {
+ final AutoRotatePreferenceController controller =
+ new AutoRotatePreferenceController(mContext, "auto_rotate");
+ assertThat(controller.isSliceable()).isTrue();
+ }
+
+ @Test
+ public void isSliceableIncorrectKey_returnsFalse() {
+ final AutoRotatePreferenceController controller =
+ new AutoRotatePreferenceController(mContext, "bad_key");
+ assertThat(controller.isSliceable()).isFalse();
+ }
+
private void enableAutoRotationPreference() {
when(mPackageManager.hasSystemFeature(anyString())).thenReturn(true);
when(mContext.getResources().getBoolean(anyInt())).thenReturn(true);
diff --git a/tests/robotests/src/com/android/settings/display/NightDisplayActivationPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/display/NightDisplayActivationPreferenceControllerTest.java
index 88adc51c4a..7b6ecd14ed 100644
--- a/tests/robotests/src/com/android/settings/display/NightDisplayActivationPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/display/NightDisplayActivationPreferenceControllerTest.java
@@ -73,6 +73,20 @@ public class NightDisplayActivationPreferenceControllerTest {
}
@Test
+ public void isSliceableCorrectKey_returnsTrue() {
+ final NightDisplayActivationPreferenceController controller =
+ new NightDisplayActivationPreferenceController(mContext,"night_display_activated");
+ assertThat(controller.isSliceable()).isTrue();
+ }
+
+ @Test
+ public void isSliceableIncorrectKey_returnsFalse() {
+ final NightDisplayActivationPreferenceController controller =
+ new NightDisplayActivationPreferenceController(mContext, "bad_key");
+ assertThat(controller.isSliceable()).isFalse();
+ }
+
+ @Test
public void onClick_activates() {
Secure.putInt(mContext.getContentResolver(), Secure.NIGHT_DISPLAY_ACTIVATED, 0);
diff --git a/tests/robotests/src/com/android/settings/display/NightDisplayIntensityPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/display/NightDisplayIntensityPreferenceControllerTest.java
index 1a69b6b84e..40101a4bd7 100644
--- a/tests/robotests/src/com/android/settings/display/NightDisplayIntensityPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/display/NightDisplayIntensityPreferenceControllerTest.java
@@ -76,4 +76,18 @@ public class NightDisplayIntensityPreferenceControllerTest {
Secure.NIGHT_DISPLAY_COLOR_TEMPERATURE, -1))
.isEqualTo(3030);
}
+
+ @Test
+ public void isSliceableCorrectKey_returnsTrue() {
+ final NightDisplayIntensityPreferenceController controller =
+ new NightDisplayIntensityPreferenceController(mContext,"night_display_temperature");
+ assertThat(controller.isSliceable()).isTrue();
+ }
+
+ @Test
+ public void isSliceableIncorrectKey_returnsFalse() {
+ final NightDisplayIntensityPreferenceController controller =
+ new NightDisplayIntensityPreferenceController(mContext, "bad_key");
+ assertThat(controller.isSliceable()).isFalse();
+ }
}
diff --git a/tests/robotests/src/com/android/settings/gestures/DoubleTapPowerPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/gestures/DoubleTapPowerPreferenceControllerTest.java
index d681bc36f2..8c0be96d26 100644
--- a/tests/robotests/src/com/android/settings/gestures/DoubleTapPowerPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/gestures/DoubleTapPowerPreferenceControllerTest.java
@@ -17,10 +17,13 @@
package com.android.settings.gestures;
import static android.provider.Settings.Secure.CAMERA_DOUBLE_TAP_POWER_GESTURE_DISABLED;
+
import static com.android.settings.gestures.DoubleTapPowerPreferenceController.OFF;
import static com.android.settings.gestures.DoubleTapPowerPreferenceController.ON;
import static com.android.settings.gestures.DoubleTapPowerPreferenceController.isSuggestionComplete;
+
import static com.google.common.truth.Truth.assertThat;
+
import static org.mockito.Mockito.when;
import android.content.ContentResolver;
@@ -29,6 +32,7 @@ import android.content.SharedPreferences;
import android.provider.Settings;
import com.android.settings.dashboard.suggestions.SuggestionFeatureProviderImpl;
+import com.android.settings.display.AmbientDisplayAlwaysOnPreferenceController;
import com.android.settings.search.InlinePayload;
import com.android.settings.search.InlineSwitchPayload;
import com.android.settings.search.ResultPayload;
@@ -67,7 +71,8 @@ public class DoubleTapPowerPreferenceControllerTest {
@Test
public void isAvailable_configIsTrue_shouldReturnTrue() {
SettingsShadowResources.overrideResource(
- com.android.internal.R.bool.config_cameraDoubleTapPowerGestureEnabled, Boolean.TRUE);
+ com.android.internal.R.bool.config_cameraDoubleTapPowerGestureEnabled,
+ Boolean.TRUE);
assertThat(mController.isAvailable()).isTrue();
}
@@ -75,7 +80,8 @@ public class DoubleTapPowerPreferenceControllerTest {
@Test
public void isAvailable_configIsTrue_shouldReturnFalse() {
SettingsShadowResources.overrideResource(
- com.android.internal.R.bool.config_cameraDoubleTapPowerGestureEnabled, Boolean.FALSE);
+ com.android.internal.R.bool.config_cameraDoubleTapPowerGestureEnabled,
+ Boolean.FALSE);
assertThat(mController.isAvailable()).isFalse();
}
@@ -101,7 +107,7 @@ public class DoubleTapPowerPreferenceControllerTest {
@Test
public void testPreferenceController_ProperResultPayloadType() {
DoubleTapPowerPreferenceController controller =
- new DoubleTapPowerPreferenceController(mContext, KEY_DOUBLE_TAP_POWER);
+ new DoubleTapPowerPreferenceController(mContext, KEY_DOUBLE_TAP_POWER);
ResultPayload payload = controller.getResultPayload();
assertThat(payload).isInstanceOf(InlineSwitchPayload.class);
}
@@ -111,7 +117,7 @@ public class DoubleTapPowerPreferenceControllerTest {
public void testSetValue_updatesCorrectly() {
int newValue = 1;
Settings.Secure.putInt(mContentResolver,
- Settings.Secure.CAMERA_DOUBLE_TAP_POWER_GESTURE_DISABLED, 0);
+ Settings.Secure.CAMERA_DOUBLE_TAP_POWER_GESTURE_DISABLED, 0);
InlinePayload payload = ((InlineSwitchPayload) mController.getResultPayload());
payload.setValue(mContext, newValue);
@@ -148,7 +154,7 @@ public class DoubleTapPowerPreferenceControllerTest {
com.android.internal.R.bool.config_cameraDoubleTapPowerGestureEnabled, true);
// No stored value in shared preferences if not visited yet.
final SharedPreferences prefs =
- new SuggestionFeatureProviderImpl(mContext).getSharedPrefs(mContext);
+ new SuggestionFeatureProviderImpl(mContext).getSharedPrefs(mContext);
assertThat(isSuggestionComplete(mContext, prefs)).isFalse();
}
@@ -158,9 +164,23 @@ public class DoubleTapPowerPreferenceControllerTest {
com.android.internal.R.bool.config_cameraDoubleTapPowerGestureEnabled, true);
// No stored value in shared preferences if not visited yet.
final SharedPreferences prefs =
- new SuggestionFeatureProviderImpl(mContext).getSharedPrefs(mContext);
+ new SuggestionFeatureProviderImpl(mContext).getSharedPrefs(mContext);
prefs.edit().putBoolean(DoubleTapPowerSettings.PREF_KEY_SUGGESTION_COMPLETE, true).commit();
assertThat(isSuggestionComplete(mContext, prefs)).isTrue();
}
+
+ @Test
+ public void isSliceableCorrectKey_returnsTrue() {
+ final DoubleTapPowerPreferenceController controller =
+ new DoubleTapPowerPreferenceController(mContext, "gesture_double_tap_power");
+ assertThat(controller.isSliceable()).isTrue();
+ }
+
+ @Test
+ public void isSliceableIncorrectKey_returnsFalse() {
+ final DoubleTapPowerPreferenceController controller =
+ new DoubleTapPowerPreferenceController(mContext, "bad_key");
+ assertThat(controller.isSliceable()).isFalse();
+ }
}
diff --git a/tests/robotests/src/com/android/settings/gestures/DoubleTapScreenPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/gestures/DoubleTapScreenPreferenceControllerTest.java
index 63a1027615..efc9f4fe8f 100644
--- a/tests/robotests/src/com/android/settings/gestures/DoubleTapScreenPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/gestures/DoubleTapScreenPreferenceControllerTest.java
@@ -179,4 +179,18 @@ public class DoubleTapScreenPreferenceControllerTest {
assertThat(availabilityStatus).isEqualTo(AVAILABLE);
}
+
+ @Test
+ public void isSliceableCorrectKey_returnsTrue() {
+ final DoubleTapScreenPreferenceController controller =
+ new DoubleTapScreenPreferenceController(mContext,"gesture_double_tap_screen");
+ assertThat(controller.isSliceable()).isTrue();
+ }
+
+ @Test
+ public void isSliceableIncorrectKey_returnsFalse() {
+ final DoubleTapScreenPreferenceController controller =
+ new DoubleTapScreenPreferenceController(mContext, "bad_key");
+ assertThat(controller.isSliceable()).isFalse();
+ }
}
diff --git a/tests/robotests/src/com/android/settings/gestures/DoubleTwistPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/gestures/DoubleTwistPreferenceControllerTest.java
index 901da37086..0ec5ae1d5b 100644
--- a/tests/robotests/src/com/android/settings/gestures/DoubleTwistPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/gestures/DoubleTwistPreferenceControllerTest.java
@@ -155,4 +155,18 @@ public class DoubleTwistPreferenceControllerTest {
assertThat(mController.isChecked()).isFalse();
}
+
+ @Test
+ public void isSliceableCorrectKey_returnsTrue() {
+ final DoubleTwistPreferenceController controller =
+ new DoubleTwistPreferenceController(mContext,"gesture_double_twist");
+ assertThat(controller.isSliceable()).isTrue();
+ }
+
+ @Test
+ public void isSliceableIncorrectKey_returnsFalse() {
+ final DoubleTwistPreferenceController controller =
+ new DoubleTwistPreferenceController(mContext, "bad_key");
+ assertThat(controller.isSliceable()).isFalse();
+ }
}
diff --git a/tests/robotests/src/com/android/settings/gestures/PickupGesturePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/gestures/PickupGesturePreferenceControllerTest.java
index 98c32ad9ba..f609373aa7 100644
--- a/tests/robotests/src/com/android/settings/gestures/PickupGesturePreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/gestures/PickupGesturePreferenceControllerTest.java
@@ -170,4 +170,18 @@ public class PickupGesturePreferenceControllerTest {
assertThat(availabilityStatus).isEqualTo(AVAILABLE);
}
+
+ @Test
+ public void isSliceableCorrectKey_returnsTrue() {
+ final PickupGesturePreferenceController controller =
+ new PickupGesturePreferenceController(mContext,"gesture_pick_up");
+ assertThat(controller.isSliceable()).isTrue();
+ }
+
+ @Test
+ public void isSliceableIncorrectKey_returnsFalse() {
+ final PickupGesturePreferenceController controller =
+ new PickupGesturePreferenceController(mContext, "bad_key");
+ assertThat(controller.isSliceable()).isFalse();
+ }
}
diff --git a/tests/robotests/src/com/android/settings/gestures/SwipeToNotificationPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/gestures/SwipeToNotificationPreferenceControllerTest.java
index c164fbf737..8522229b8e 100644
--- a/tests/robotests/src/com/android/settings/gestures/SwipeToNotificationPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/gestures/SwipeToNotificationPreferenceControllerTest.java
@@ -168,4 +168,18 @@ public class SwipeToNotificationPreferenceControllerTest {
when(mPackageManager.hasSystemFeature(PackageManager.FEATURE_FINGERPRINT))
.thenReturn(enabled);
}
+
+ @Test
+ public void isSliceableCorrectKey_returnsTrue() {
+ final SwipeToNotificationPreferenceController controller = new
+ SwipeToNotificationPreferenceController(mContext,"gesture_swipe_down_fingerprint");
+ assertThat(controller.isSliceable()).isTrue();
+ }
+
+ @Test
+ public void isSliceableIncorrectKey_returnsFalse() {
+ final SwipeToNotificationPreferenceController controller =
+ new SwipeToNotificationPreferenceController(mContext, "bad_key");
+ assertThat(controller.isSliceable()).isFalse();
+ }
}
diff --git a/tests/robotests/src/com/android/settings/gestures/SwipeUpPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/gestures/SwipeUpPreferenceControllerTest.java
index 3585650a58..a001a4a36a 100644
--- a/tests/robotests/src/com/android/settings/gestures/SwipeUpPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/gestures/SwipeUpPreferenceControllerTest.java
@@ -123,4 +123,18 @@ public class SwipeUpPreferenceControllerTest {
mController.setChecked(false);
assertThat(mController.isChecked()).isFalse();
}
+
+ @Test
+ public void isSliceableCorrectKey_returnsTrue() {
+ final SwipeUpPreferenceController controller =
+ new SwipeUpPreferenceController(mContext,"gesture_swipe_up");
+ assertThat(controller.isSliceable()).isTrue();
+ }
+
+ @Test
+ public void isSliceableIncorrectKey_returnsFalse() {
+ final SwipeUpPreferenceController controller =
+ new SwipeUpPreferenceController(mContext, "bad_key");
+ assertThat(controller.isSliceable()).isFalse();
+ }
}
diff --git a/tests/robotests/src/com/android/settings/network/AirplaneModePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/network/AirplaneModePreferenceControllerTest.java
index a255333e53..0e7d80ee77 100644
--- a/tests/robotests/src/com/android/settings/network/AirplaneModePreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/network/AirplaneModePreferenceControllerTest.java
@@ -177,4 +177,18 @@ public class AirplaneModePreferenceControllerTest {
assertThat(mPreference.isChecked()).isTrue();
}
+
+ @Test
+ public void isSliceableCorrectKey_returnsTrue() {
+ final AirplaneModePreferenceController controller =
+ new AirplaneModePreferenceController(mContext,"toggle_airplane");
+ assertThat(controller.isSliceable()).isTrue();
+ }
+
+ @Test
+ public void isSliceableIncorrectKey_returnsFalse() {
+ final AirplaneModePreferenceController controller =
+ new AirplaneModePreferenceController(mContext, "bad_key");
+ assertThat(controller.isSliceable()).isFalse();
+ }
}
diff --git a/tests/robotests/src/com/android/settings/notification/BadgingNotificationPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/BadgingNotificationPreferenceControllerTest.java
index 12ecbfe3ed..1d3c239549 100644
--- a/tests/robotests/src/com/android/settings/notification/BadgingNotificationPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/BadgingNotificationPreferenceControllerTest.java
@@ -183,4 +183,19 @@ public class BadgingNotificationPreferenceControllerTest {
assertThat(updatedValue).isEqualTo(ON);
}
+
+ @Test
+ public void isSliceableCorrectKey_returnsTrue() {
+ final BadgingNotificationPreferenceController controller =
+ new BadgingNotificationPreferenceController(mContext,
+ "notification_badging");
+ assertThat(controller.isSliceable()).isTrue();
+ }
+
+ @Test
+ public void isSliceableIncorrectKey_returnsFalse() {
+ final BadgingNotificationPreferenceController controller =
+ new BadgingNotificationPreferenceController(mContext, "bad_key");
+ assertThat(controller.isSliceable()).isFalse();
+ }
}
diff --git a/tests/robotests/src/com/android/settings/notification/CallVolumePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/CallVolumePreferenceControllerTest.java
index bed45e5081..f20409a6ab 100644
--- a/tests/robotests/src/com/android/settings/notification/CallVolumePreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/CallVolumePreferenceControllerTest.java
@@ -92,4 +92,18 @@ public class CallVolumePreferenceControllerTest {
assertThat(mController.getAudioStream()).isEqualTo(AudioManager.STREAM_BLUETOOTH_SCO);
}
+
+ @Test
+ public void isSliceableCorrectKey_returnsTrue() {
+ final CallVolumePreferenceController controller =
+ new CallVolumePreferenceController(mContext,"call_volume");
+ assertThat(controller.isSliceable()).isTrue();
+ }
+
+ @Test
+ public void isSliceableIncorrectKey_returnsFalse() {
+ final CallVolumePreferenceController controller =
+ new CallVolumePreferenceController(mContext, "bad_key");
+ assertThat(controller.isSliceable()).isFalse();
+ }
}
diff --git a/tests/robotests/src/com/android/settings/notification/MediaVolumePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/MediaVolumePreferenceControllerTest.java
index 3659a30adc..49fd6d4937 100644
--- a/tests/robotests/src/com/android/settings/notification/MediaVolumePreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/MediaVolumePreferenceControllerTest.java
@@ -18,6 +18,7 @@ package com.android.settings.notification;
import static com.google.common.truth.Truth.assertThat;
+import android.content.Context;
import android.media.AudioManager;
import com.android.settings.testutils.SettingsRobolectricTestRunner;
@@ -33,9 +34,12 @@ public class MediaVolumePreferenceControllerTest {
private MediaVolumePreferenceController mController;
+ private Context mContext;
+
@Before
public void setUp() {
- mController = new MediaVolumePreferenceController(RuntimeEnvironment.application);
+ mContext = RuntimeEnvironment.application;
+ mController = new MediaVolumePreferenceController(mContext);
}
@Test
@@ -53,4 +57,11 @@ public class MediaVolumePreferenceControllerTest {
public void getAudioStream_shouldReturnMusic() {
assertThat(mController.getAudioStream()).isEqualTo(AudioManager.STREAM_MUSIC);
}
+
+ @Test
+ public void isSliceableCorrectKey_returnsTrue() {
+ final MediaVolumePreferenceController controller = new MediaVolumePreferenceController(
+ mContext);
+ assertThat(controller.isSliceable()).isTrue();
+ }
}
diff --git a/tests/robotests/src/com/android/settings/notification/NotificationVolumePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/NotificationVolumePreferenceControllerTest.java
index c209c1befa..9d805e8785 100644
--- a/tests/robotests/src/com/android/settings/notification/NotificationVolumePreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/NotificationVolumePreferenceControllerTest.java
@@ -95,4 +95,11 @@ public class NotificationVolumePreferenceControllerTest {
public void getAudioStream_shouldReturnNotification() {
assertThat(mController.getAudioStream()).isEqualTo(AudioManager.STREAM_NOTIFICATION);
}
+
+ @Test
+ public void isSliceableCorrectKey_returnsTrue() {
+ final NotificationVolumePreferenceController controller =
+ new NotificationVolumePreferenceController(mContext);
+ assertThat(controller.isSliceable()).isTrue();
+ }
}
diff --git a/tests/robotests/src/com/android/settings/notification/RingVolumePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/RingVolumePreferenceControllerTest.java
index e0065304fb..65bc7e6c40 100644
--- a/tests/robotests/src/com/android/settings/notification/RingVolumePreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/RingVolumePreferenceControllerTest.java
@@ -97,4 +97,11 @@ public class RingVolumePreferenceControllerTest {
public void getAudioStream_shouldReturnRing() {
assertThat(mController.getAudioStream()).isEqualTo(AudioManager.STREAM_RING);
}
+
+ @Test
+ public void isSliceableCorrectKey_returnsTrue() {
+ final RingVolumePreferenceController controller =
+ new RingVolumePreferenceController(mContext);
+ assertThat(controller.isSliceable()).isTrue();
+ }
}
diff --git a/tests/robotests/src/com/android/settings/notification/VibrateWhenRingPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/VibrateWhenRingPreferenceControllerTest.java
index 4e69c46fb8..de5e2cdd54 100644
--- a/tests/robotests/src/com/android/settings/notification/VibrateWhenRingPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/VibrateWhenRingPreferenceControllerTest.java
@@ -183,4 +183,18 @@ public class VibrateWhenRingPreferenceControllerTest {
assertThat(shadowContentResolver.getContentObservers(
Settings.System.getUriFor(VIBRATE_WHEN_RINGING))).isEmpty();
}
+
+ @Test
+ public void isSliceableCorrectKey_returnsTrue() {
+ final VibrateWhenRingPreferenceController controller =
+ new VibrateWhenRingPreferenceController(mContext, "vibrate_when_ringing");
+ assertThat(controller.isSliceable()).isTrue();
+ }
+
+ @Test
+ public void isSliceableIncorrectKey_returnsFalse() {
+ final VibrateWhenRingPreferenceController controller =
+ new VibrateWhenRingPreferenceController(mContext, "bad_key");
+ assertThat(controller.isSliceable()).isFalse();
+ }
}
diff --git a/tests/robotests/src/com/android/settings/slices/FakePreferenceController.java b/tests/robotests/src/com/android/settings/slices/FakePreferenceController.java
index 6c861dbb34..d0e33f0ec2 100644
--- a/tests/robotests/src/com/android/settings/slices/FakePreferenceController.java
+++ b/tests/robotests/src/com/android/settings/slices/FakePreferenceController.java
@@ -35,4 +35,9 @@ public class FakePreferenceController extends BasePreferenceController {
public int getSliceType() {
return SliceData.SliceType.SLIDER;
}
+
+ @Override
+ public boolean isSliceable() {
+ return true;
+ }
}
diff --git a/tests/robotests/src/com/android/settings/slices/SlicesDatabaseAccessorTest.java b/tests/robotests/src/com/android/settings/slices/SlicesDatabaseAccessorTest.java
index 1788d93075..c571d85ccb 100644
--- a/tests/robotests/src/com/android/settings/slices/SlicesDatabaseAccessorTest.java
+++ b/tests/robotests/src/com/android/settings/slices/SlicesDatabaseAccessorTest.java
@@ -70,6 +70,11 @@ public class SlicesDatabaseAccessorTest {
mAccessor = spy(new SlicesDatabaseAccessor(mContext));
mDb = SlicesDatabaseHelper.getInstance(mContext).getWritableDatabase();
SlicesDatabaseHelper.getInstance(mContext).setIndexedState();
+
+ // Register the fake a11y Service
+ ShadowAccessibilityManager shadowAccessibilityManager = Shadow.extract(
+ RuntimeEnvironment.application.getSystemService(AccessibilityManager.class));
+ shadowAccessibilityManager.setInstalledAccessibilityServiceList(new ArrayList<>());
}
@After
@@ -173,10 +178,6 @@ public class SlicesDatabaseAccessorTest {
public void getSliceKeys_indexesDatabase() {
// Force new indexing
Locale.setDefault(new Locale("ca"));
- // Register the fake a11y Service
- ShadowAccessibilityManager shadowAccessibilityManager = Shadow.extract(
- RuntimeEnvironment.application.getSystemService(AccessibilityManager.class));
- shadowAccessibilityManager.setInstalledAccessibilityServiceList(new ArrayList<>());
final SearchFeatureProvider provider = new SearchFeatureProviderImpl();
final SlicesFeatureProvider sliceProvider = spy(new SlicesFeatureProviderImpl());
final FakeFeatureFactory factory = FakeFeatureFactory.setupForTest();
diff --git a/tests/robotests/src/com/android/settings/testutils/FakeSliderController.java b/tests/robotests/src/com/android/settings/testutils/FakeSliderController.java
index 530bdee97f..ca306dad8f 100644
--- a/tests/robotests/src/com/android/settings/testutils/FakeSliderController.java
+++ b/tests/robotests/src/com/android/settings/testutils/FakeSliderController.java
@@ -53,4 +53,9 @@ public class FakeSliderController extends SliderPreferenceController {
return Settings.Global.getInt(mContext.getContentResolver(),
AVAILABILITY_KEY, AVAILABLE);
}
+
+ @Override
+ public boolean isSliceable() {
+ return true;
+ }
}
diff --git a/tests/robotests/src/com/android/settings/testutils/FakeToggleController.java b/tests/robotests/src/com/android/settings/testutils/FakeToggleController.java
index bae267a622..680a04de10 100644
--- a/tests/robotests/src/com/android/settings/testutils/FakeToggleController.java
+++ b/tests/robotests/src/com/android/settings/testutils/FakeToggleController.java
@@ -62,4 +62,9 @@ public class FakeToggleController extends TogglePreferenceController {
public IntentFilter getIntentFilter() {
return INTENT_FILTER;
}
+
+ @Override
+ public boolean isSliceable() {
+ return true;
+ }
}
diff --git a/tests/robotests/src/com/android/settings/testutils/FakeUnavailablePreferenceController.java b/tests/robotests/src/com/android/settings/testutils/FakeUnavailablePreferenceController.java
index 1ceaad864e..eef4761ecb 100644
--- a/tests/robotests/src/com/android/settings/testutils/FakeUnavailablePreferenceController.java
+++ b/tests/robotests/src/com/android/settings/testutils/FakeUnavailablePreferenceController.java
@@ -18,4 +18,9 @@ public class FakeUnavailablePreferenceController extends BasePreferenceControlle
return Settings.Global.getInt(mContext.getContentResolver(),
AVAILABILITY_KEY, 0);
}
+
+ @Override
+ public boolean isSliceable() {
+ return true;
+ }
}