diff --git a/src/com/android/settings/core/BasePreferenceController.java b/src/com/android/settings/core/BasePreferenceController.java index 1c850099554..324b5097b06 100644 --- a/src/com/android/settings/core/BasePreferenceController.java +++ b/src/com/android/settings/core/BasePreferenceController.java @@ -15,7 +15,6 @@ package com.android.settings.core; import android.annotation.IntDef; import android.content.Context; -import android.content.IntentFilter; import android.text.TextUtils; import android.util.Log; @@ -24,6 +23,7 @@ import androidx.preference.PreferenceScreen; import com.android.settings.search.SearchIndexableRaw; import com.android.settings.slices.SliceData; +import com.android.settings.slices.Sliceable; import com.android.settingslib.core.AbstractPreferenceController; import java.lang.annotation.Retention; @@ -37,7 +37,8 @@ import java.util.List; * for Slices. The abstract classes that inherit from this class will act as the direct interfaces * for each type when plugging into Slices. */ -public abstract class BasePreferenceController extends AbstractPreferenceController { +public abstract class BasePreferenceController extends AbstractPreferenceController implements + Sliceable { private static final String TAG = "SettingsPrefController"; @@ -119,7 +120,7 @@ public abstract class BasePreferenceController extends AbstractPreferenceControl final Class> clazz = Class.forName(controllerName); final Constructor> preferenceConstructor = clazz.getConstructor(Context.class, String.class); - final Object[] params = new Object[] {context, key}; + final Object[] params = new Object[]{context, key}; return (BasePreferenceController) preferenceConstructor.newInstance(params); } catch (ClassNotFoundException | NoSuchMethodException | InstantiationException | IllegalArgumentException | InvocationTargetException | IllegalAccessException e) { @@ -137,7 +138,7 @@ public abstract class BasePreferenceController extends AbstractPreferenceControl try { final Class> clazz = Class.forName(controllerName); final Constructor> preferenceConstructor = clazz.getConstructor(Context.class); - final Object[] params = new Object[] {context}; + final Object[] params = new Object[]{context}; return (BasePreferenceController) preferenceConstructor.newInstance(params); } catch (ClassNotFoundException | NoSuchMethodException | InstantiationException | IllegalArgumentException | InvocationTargetException | IllegalAccessException e) { @@ -226,41 +227,6 @@ public abstract class BasePreferenceController extends AbstractPreferenceControl return SliceData.SliceType.INTENT; } - /** - * @return an {@link IntentFilter} that includes all broadcasts which can affect the state of - * this Setting. - */ - public IntentFilter getIntentFilter() { - return null; - } - - /** - * Determines if the controller should be used as a Slice. - *
- * Important criteria for a Slice are: - * - Must be secure - * - Must not be a privacy leak - * - Must be understandable as a stand-alone Setting. - *
- * 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; - } - - /** - * @return {@code true} if the setting update asynchronously. - *
- * For example, a Wifi controller would return true, because it needs to update the radio - * and wait for it to turn on. - */ - public boolean hasAsyncUpdate() { - return false; - } - /** * Updates non-indexable keys for search provider. * @@ -293,6 +259,7 @@ public abstract class BasePreferenceController extends AbstractPreferenceControl /** * Set {@link UiBlockListener} + * * @param uiBlockListener listener to set */ public void setUiBlockListener(UiBlockListener uiBlockListener) { @@ -306,6 +273,7 @@ public abstract class BasePreferenceController extends AbstractPreferenceControl /** * To notify client that UI related background work is finished. * (i.e. Slice is fully loaded.) + * * @param controller Controller that contains background work */ void onBlockerWorkFinished(BasePreferenceController controller); @@ -321,5 +289,6 @@ public abstract class BasePreferenceController extends AbstractPreferenceControl * * This music be used in {@link BasePreferenceController} */ - public interface UiBlocker {} + public interface UiBlocker { + } } \ No newline at end of file diff --git a/src/com/android/settings/slices/CustomSliceable.java b/src/com/android/settings/slices/CustomSliceable.java index 220cdc80dbf..d32e2665d1c 100644 --- a/src/com/android/settings/slices/CustomSliceable.java +++ b/src/com/android/settings/slices/CustomSliceable.java @@ -52,7 +52,7 @@ import java.lang.reflect.InvocationTargetException; *
* If you implement this interface, you should add your Slice to {@link CustomSliceManager}.
*/
-public interface CustomSliceable {
+public interface CustomSliceable extends Sliceable {
/**
* @return an complete instance of the {@link Slice}.
@@ -78,17 +78,6 @@ public interface CustomSliceable {
*/
Intent getIntent();
- /**
- * Settings Slices which can represent components that are updatable by the framework should
- * listen to changes matched to the {@link IntentFilter} returned here.
- *
- * @return an {@link IntentFilter} for updates related to the {@link Slice} returned by
- * {@link #getSlice()}.
- */
- default IntentFilter getIntentFilter() {
- return null;
- }
-
/**
* Settings Slices which require background work, such as updating lists should implement a
* {@link SliceBackgroundWorker} and return it here. An example of background work is updating
@@ -116,12 +105,16 @@ public interface CustomSliceable {
PendingIntent.FLAG_CANCEL_CURRENT);
}
+ @Override
+ default boolean isSliceable() {
+ return true;
+ }
+
/**
* Build an instance of a {@link CustomSliceable} which has a {@link Context}-only constructor.
*/
static CustomSliceable createInstance(Context context, Class
+ * Important criteria for a Slice are:
+ * - Must be secure
+ * - Must not be a privacy leak
+ * - Must be understandable as a stand-alone Setting.
+ *
+ * This does not guarantee the setting is available.
+ *
+ * @return {@code true} if the controller should be used externally as a Slice.
+ */
+ default boolean isSliceable() {
+ return false;
+ }
+
+ /**
+ * @return {@code true} if the setting update asynchronously.
+ *
+ * For example, a Wifi controller would return true, because it needs to update the radio
+ * and wait for it to turn on.
+ */
+ default boolean hasAsyncUpdate() {
+ return false;
+ }
+}