Add list-select as an inline result

Move the majority of the Setting set & get logic into
InlinePayload, but add formatting of input to each
concrete payload class.

Bug: 62022517
Test: make RunSettingsRoboTests
Change-Id: I08932871554beb4a04625f05f8555a5b3a887fe2
diff --git a/src/com/android/settings/search/CursorToSearchResultConverter.java b/src/com/android/settings/search/CursorToSearchResultConverter.java
index 26b46ff..ce64de9 100644
--- a/src/com/android/settings/search/CursorToSearchResultConverter.java
+++ b/src/com/android/settings/search/CursorToSearchResultConverter.java
@@ -113,6 +113,9 @@
                 case ResultPayload.PayloadType.INLINE_SWITCH:
                     return ResultPayloadUtils.unmarshall(marshalledPayload,
                             InlineSwitchPayload.CREATOR);
+                case ResultPayload.PayloadType.INLINE_LIST:
+                    return ResultPayloadUtils.unmarshall(marshalledPayload,
+                            InlineListPayload.CREATOR);
             }
         } catch (BadParcelableException e) {
             Log.w(TAG, "Error creating parcelable: " + e);
diff --git a/src/com/android/settings/search/InlineListPayload.java b/src/com/android/settings/search/InlineListPayload.java
new file mode 100644
index 0000000..60113b9
--- /dev/null
+++ b/src/com/android/settings/search/InlineListPayload.java
@@ -0,0 +1,62 @@
+package com.android.settings.search;
+
+import android.content.Intent;
+import android.os.Parcel;
+import android.os.Parcelable;
+
+/**
+ * Payload for settings which are selected from multiple values. For example, Location can be
+ * set to multiple degrees of accuracy.
+ */
+public class InlineListPayload extends InlinePayload {
+
+    /**
+     * Number of selections in the list.
+     */
+    private int mNumOptions;
+
+    public InlineListPayload(String key, @PayloadType int payloadType, Intent intent,
+            boolean isDeviceSupported, int numOptions) {
+        super(key, payloadType, intent, isDeviceSupported);
+        mNumOptions = numOptions;
+    }
+
+    private InlineListPayload(Parcel in) {
+        super(in);
+        mNumOptions = in.readInt();
+    }
+
+    @Override
+    public void writeToParcel(Parcel dest, int flags) {
+        super.writeToParcel(dest, flags);
+        dest.writeInt(mNumOptions);
+    }
+
+    @Override
+    protected int standardizeInput(int input) throws IllegalArgumentException {
+        if (input < 0 || input >= mNumOptions) {
+            throw new IllegalArgumentException(
+                    "Invalid argument for ListSelect. Expected between 0 and "
+                            + mNumOptions + " but found: " + input);
+        }
+        return input;
+    }
+
+    @Override
+    @PayloadType public int getType() {
+        return PayloadType.INLINE_LIST;
+    }
+
+    public static final Parcelable.Creator<InlineListPayload> CREATOR =
+            new Parcelable.Creator<InlineListPayload>() {
+                @Override
+                public InlineListPayload createFromParcel(Parcel in) {
+                    return new InlineListPayload(in);
+                }
+
+                @Override
+                public InlineListPayload[] newArray(int size) {
+                    return new InlineListPayload[size];
+                }
+            };
+}
diff --git a/src/com/android/settings/search/InlinePayload.java b/src/com/android/settings/search/InlinePayload.java
index 439f111..0807f62 100644
--- a/src/com/android/settings/search/InlinePayload.java
+++ b/src/com/android/settings/search/InlinePayload.java
@@ -21,6 +21,7 @@
 
 import android.content.Context;
 import android.os.Parcel;
+import android.provider.Settings;
 import com.android.internal.annotations.VisibleForTesting;
 
 /**
@@ -38,11 +39,6 @@
     final String mSettingKey;
 
     /**
-     * The UI type for the inline result.
-     */
-    @PayloadType final int mInlineType;
-
-    /**
      * Defines where the Setting is stored.
      */
     @SettingsSource final int mSettingSource;
@@ -54,16 +50,14 @@
 
     /**
      * @param key uniquely identifies the stored setting.
-     * @param payloadType of the setting being stored.
      * @param source of the setting. Used to determine where to get and set the setting.
      * @param intent to the setting page.
      * @param isDeviceSupported is true when the setting is valid for the given device.
      */
-    public InlinePayload(String key, @PayloadType int payloadType, @SettingsSource int source,
-            Intent intent, boolean isDeviceSupported) {
+    public InlinePayload(String key, @SettingsSource int source, Intent intent,
+            boolean isDeviceSupported) {
         super(intent);
         mSettingKey = key;
-        mInlineType = payloadType;
         mSettingSource = source;
         mIsDeviceSupported = isDeviceSupported;
     }
@@ -71,7 +65,6 @@
     InlinePayload(Parcel parcel) {
         super((Intent) parcel.readParcelable(Intent.class.getClassLoader()));
         mSettingKey = parcel.readString();
-        mInlineType = parcel.readInt();
         mSettingSource = parcel.readInt();
         mIsDeviceSupported = parcel.readInt() == TRUE;
     }
@@ -80,11 +73,13 @@
     public void writeToParcel(Parcel dest, int flags) {
         super.writeToParcel(dest, flags);
         dest.writeString(mSettingKey);
-        dest.writeInt(mInlineType);
         dest.writeInt(mSettingSource);
         dest.writeInt(mIsDeviceSupported ? TRUE : FALSE);
     }
 
+    @Override
+    @PayloadType public abstract int getType();
+
     /**
      * @returns the status of the underlying setting. See {@link ResultPayload.Availability} for
      * possible values.
@@ -97,15 +92,63 @@
     }
 
     /**
+     * Checks if the input is valid for the given setting.
+     *
+     * @param input The number to be get or set for the setting.
+     * @return {@param input} mapped to the public-facing API for settings.
+     * @throws IllegalArgumentException when the input is not valid for the given inline type.
+     */
+    protected abstract int standardizeInput(int input) throws IllegalArgumentException;
+
+    /**
      * @returns the current value of the setting.
      */
-    public abstract int getValue(Context context);
+    public int getValue(Context context) {
+        int settingsValue = -1;
+        switch(mSettingSource) {
+            case SettingsSource.SECURE:
+                settingsValue = Settings.Secure.getInt(context.getContentResolver(),
+                        mSettingKey, -1);
+                break;
+            case SettingsSource.SYSTEM:
+                settingsValue = Settings.System.getInt(context.getContentResolver(),
+                        mSettingKey, -1);
+                break;
+
+            case SettingsSource.GLOBAL:
+                settingsValue = Settings.Global.getInt(context.getContentResolver(),
+                        mSettingKey, -1);
+                break;
+        }
+
+        if (settingsValue == -1) {
+            throw new IllegalStateException("Unable to find setting from uri: "
+                    + mSettingKey.toString());
+        }
+
+        return standardizeInput(settingsValue);
+    }
 
     /**
      * Attempts to set the setting value.
      *
-     * @param newValue is the requested new value for the setting.
+     * @param newValue is the requested value for the setting.
      * @returns true when the setting was changed, and false otherwise.
      */
-    public abstract boolean setValue(Context context, int newValue);
+    public boolean setValue(Context context, int newValue) {
+        newValue = standardizeInput(newValue);
+
+        switch(mSettingSource) {
+            case SettingsSource.GLOBAL:
+                return Settings.Global.putInt(context.getContentResolver(), mSettingKey, newValue);
+            case SettingsSource.SECURE:
+                return Settings.Secure.putInt(context.getContentResolver(), mSettingKey, newValue);
+            case SettingsSource.SYSTEM:
+                return Settings.System.putInt(context.getContentResolver(), mSettingKey, newValue);
+            case SettingsSource.UNKNOWN:
+                return false;
+        }
+
+        return false;
+    }
 }
\ No newline at end of file
diff --git a/src/com/android/settings/search/InlineSwitchPayload.java b/src/com/android/settings/search/InlineSwitchPayload.java
index a232054..8916dde 100644
--- a/src/com/android/settings/search/InlineSwitchPayload.java
+++ b/src/com/android/settings/search/InlineSwitchPayload.java
@@ -17,17 +17,18 @@
 
 package com.android.settings.search;
 
-import android.content.Context;
 import android.content.Intent;
 import android.os.Parcel;
 import android.os.Parcelable;
-import android.provider.Settings;
 
 /**
  * Payload for inline Switch results. Mappings from integer to boolean.
  */
 public class InlineSwitchPayload extends InlinePayload {
 
+    private static final int ON = 1;
+    private static final int OFF = 0;
+
     /**
      * Provides a mapping for how switches are stored.
      * If mIsStandard is true, then (0 == false) and (1 == true)
@@ -45,7 +46,7 @@
      */
     public InlineSwitchPayload(String key, @SettingsSource int source,
             int onValue, Intent intent, boolean isDeviceSupported) {
-        super(key, PayloadType.INLINE_SWITCH, source, intent, isDeviceSupported);
+        super(key, source, intent, isDeviceSupported);
         // If on is stored as TRUE then the switch is standard.
         mIsStandard = onValue == TRUE;
     }
@@ -56,13 +57,20 @@
     }
 
     @Override
-    public int getType() {
-        return mInlineType;
+    @PayloadType public int getType() {
+        return PayloadType.INLINE_SWITCH;
     }
 
     @Override
-    public int describeContents() {
-        return 0;
+    protected int standardizeInput(int value) {
+        if (value != OFF && value != ON) {
+            throw new IllegalArgumentException("Invalid input for InlineSwitch. Expected: "
+                    + ON + " or " + OFF
+                    + " but found: " + value);
+        }
+        return mIsStandard
+                ? value
+                : 1 - value;
     }
 
     @Override
@@ -84,65 +92,7 @@
         }
     };
 
-    @Override
-    public int getValue(Context context) {
-        int settingsValue = -1;
-        switch(mSettingSource) {
-            case SettingsSource.SECURE:
-                settingsValue = Settings.Secure.getInt(context.getContentResolver(),
-                        mSettingKey, -1);
-                break;
-            case SettingsSource.SYSTEM:
-                settingsValue = Settings.System.getInt(context.getContentResolver(),
-                        mSettingKey, -1);
-                break;
-
-            case SettingsSource.GLOBAL:
-                settingsValue = Settings.Global.getInt(context.getContentResolver(),
-                        mSettingKey, -1);
-                break;
-        }
-
-        if (settingsValue == -1) {
-            throw new IllegalStateException("Unable to find setting from uri: "
-                    + mSettingKey.toString());
-        }
-
-        settingsValue = standardizeInput(settingsValue);
-
-        return settingsValue;
-    }
-
-    @Override
-    public boolean setValue(Context context, int newValue) {
-        if (newValue != 0 && newValue != 1) {
-            throw new IllegalArgumentException("newValue should be 0 for off and 1 for on."
-                    + "The passed value was: " + newValue);
-        }
-
-        newValue = standardizeInput(newValue);
-
-        switch(mSettingSource) {
-            case SettingsSource.GLOBAL:
-                return Settings.Global.putInt(context.getContentResolver(), mSettingKey, newValue);
-            case SettingsSource.SECURE:
-                return Settings.Secure.putInt(context.getContentResolver(), mSettingKey, newValue);
-            case SettingsSource.SYSTEM:
-                return Settings.System.putInt(context.getContentResolver(), mSettingKey, newValue);
-            case SettingsSource.UNKNOWN:
-                return false;
-        }
-
-        return false;
-    }
-
     public boolean isStandard() {
         return mIsStandard;
     }
-
-    private int standardizeInput(int value) {
-        return mIsStandard
-                ? value
-                : 1 - value;
-    }
 }
diff --git a/src/com/android/settings/search/ResultPayload.java b/src/com/android/settings/search/ResultPayload.java
index 39688ac..b008616 100644
--- a/src/com/android/settings/search/ResultPayload.java
+++ b/src/com/android/settings/search/ResultPayload.java
@@ -32,8 +32,8 @@
 public class ResultPayload implements Parcelable {
     protected final Intent mIntent;
 
-    @IntDef({PayloadType.INLINE_SLIDER, PayloadType.INLINE_SWITCH,
-            PayloadType.INTENT, PayloadType.SAVED_QUERY})
+    @IntDef({PayloadType.INTENT, PayloadType.INLINE_SLIDER, PayloadType.INLINE_SWITCH,
+            PayloadType.INLINE_LIST, PayloadType.SAVED_QUERY})
     @Retention(RetentionPolicy.SOURCE)
     public @interface PayloadType {
         /**
@@ -52,9 +52,14 @@
         int INLINE_SWITCH = 2;
 
         /**
+         * Result is an inline list-select, with an undefined UI.
+         */
+        int INLINE_LIST = 3;
+
+        /**
          * Result is a recently saved query.
          */
-        int SAVED_QUERY = 3;
+        int SAVED_QUERY = 4;
     }
 
     /**
diff --git a/src/com/android/settings/search/SearchResultsAdapter.java b/src/com/android/settings/search/SearchResultsAdapter.java
index c7a1a9f..d2ace0e 100644
--- a/src/com/android/settings/search/SearchResultsAdapter.java
+++ b/src/com/android/settings/search/SearchResultsAdapter.java
@@ -110,6 +110,10 @@
                 // InlineSwitchViewHolder.
                 view = inflater.inflate(R.layout.search_intent_item, parent, false);
                 return new IntentSearchViewHolder(view);
+            case ResultPayload.PayloadType.INLINE_LIST:
+                // TODO (b/62807132) build a inline-list view holder & layout.
+                view = inflater.inflate(R.layout.search_intent_item, parent, false);
+                return new IntentSearchViewHolder(view);
             case ResultPayload.PayloadType.SAVED_QUERY:
                 view = inflater.inflate(R.layout.search_saved_query_item, parent, false);
                 return new SavedQueryViewHolder(view);
diff --git a/tests/robotests/src/com/android/settings/search/CursorToSearchResultConverterTest.java b/tests/robotests/src/com/android/settings/search/CursorToSearchResultConverterTest.java
index 7fb4f44..1aed11d 100644
--- a/tests/robotests/src/com/android/settings/search/CursorToSearchResultConverterTest.java
+++ b/tests/robotests/src/com/android/settings/search/CursorToSearchResultConverterTest.java
@@ -244,7 +244,7 @@
             final InlineSwitchPayload newPayload = (InlineSwitchPayload) result.payload;
             final Intent rebuiltIntent = newPayload.getIntent();
             assertThat(newPayload.mSettingKey).isEqualTo(uri);
-            assertThat(newPayload.mInlineType).isEqualTo(type);
+            assertThat(newPayload.getType()).isEqualTo(type);
             assertThat(newPayload.mSettingSource).isEqualTo(source);
             assertThat(newPayload.isStandard()).isTrue();
             assertThat(newPayload.getAvailability()).isEqualTo(Availability.AVAILABLE);
diff --git a/tests/robotests/src/com/android/settings/search/InlineListPayloadTest.java b/tests/robotests/src/com/android/settings/search/InlineListPayloadTest.java
new file mode 100644
index 0000000..60e24f9
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/search/InlineListPayloadTest.java
@@ -0,0 +1,107 @@
+package com.android.settings.search;
+
+import android.content.Context;
+import android.content.Intent;
+import android.os.Parcel;
+import com.android.settings.TestConfig;
+import com.android.settings.testutils.SettingsRobolectricTestRunner;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.robolectric.RuntimeEnvironment;
+import org.robolectric.annotation.Config;
+
+import static com.google.common.truth.Truth.assertThat;
+
+@RunWith(SettingsRobolectricTestRunner.class)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+public class InlineListPayloadTest {
+
+    private static final String DUMMY_SETTING = "inline_list_key";
+
+    private Context mContext;
+
+    @Before
+    public void setUp() {
+        mContext = RuntimeEnvironment.application;
+    }
+
+    @Test
+    public void testConstructor_DataRetained() {
+        final String uri = "test.com";
+        final int type = ResultPayload.PayloadType.INLINE_LIST;
+        final int source = ResultPayload.SettingsSource.SYSTEM;
+        final String intentKey = "key";
+        final String intentVal = "value";
+        final Intent intent = new Intent();
+        intent.putExtra(intentKey, intentVal);
+
+        InlineListPayload payload = new InlineListPayload(uri, source,
+                intent, true /* isAvailable */, 1);
+
+        final Intent retainedIntent = payload.getIntent();
+        assertThat(payload.mSettingKey).isEqualTo(uri);
+        assertThat(payload.getType()).isEqualTo(type);
+        assertThat(payload.mSettingSource).isEqualTo(source);
+        assertThat(payload.getAvailability()).isEqualTo(ResultPayload.Availability.AVAILABLE);
+        assertThat(retainedIntent.getStringExtra(intentKey)).isEqualTo(intentVal);
+    }
+
+    @Test
+    public void testParcelConstructor_DataRetained() {
+        String uri = "test.com";
+        int type = ResultPayload.PayloadType.INLINE_LIST;
+        int source = ResultPayload.SettingsSource.SYSTEM;
+        final String intentKey = "key";
+        final String intentVal = "value";
+        final Intent intent = new Intent();
+        intent.putExtra(intentKey, intentVal);
+
+        Parcel parcel = Parcel.obtain();
+        parcel.writeParcelable(intent, 0);
+        parcel.writeString(uri);
+        parcel.writeInt(source);
+        parcel.writeInt(InlineSwitchPayload.TRUE);
+        parcel.writeInt(InlineSwitchPayload.TRUE);
+        parcel.setDataPosition(0);
+
+        InlineListPayload payload = InlineListPayload
+                .CREATOR.createFromParcel(parcel);
+
+        final Intent builtIntent = payload.getIntent();
+        assertThat(payload.mSettingKey).isEqualTo(uri);
+        assertThat(payload.getType()).isEqualTo(type);
+        assertThat(payload.mSettingSource).isEqualTo(source);
+        assertThat(payload.getAvailability()).isEqualTo(ResultPayload.Availability.AVAILABLE);
+        assertThat(builtIntent.getStringExtra(intentKey)).isEqualTo(intentVal);
+    }
+
+    @Test
+    public void testInputStandardization_inputDoesntChange() {
+        InlineListPayload payload = new InlineListPayload(DUMMY_SETTING,
+                ResultPayload.SettingsSource.SYSTEM, null /* intent */, true /* isDeviceSupport */,
+                3 /* numOptions */);
+        int input = 2;
+
+        assertThat(payload.standardizeInput(input)).isEqualTo(input);
+    }
+
+    @Test(expected = IllegalArgumentException.class)
+    public void testSetSystem_negativeValue_throwsError() {
+        InlineListPayload payload = new InlineListPayload(DUMMY_SETTING,
+                ResultPayload.SettingsSource.SYSTEM, null /* intent */, true /* isDeviceSupport */,
+                3 /* numOptions */);
+
+        payload.setValue(mContext, -1);
+    }
+
+    @Test(expected = IllegalArgumentException.class)
+    public void testSetSystem_exceedsMaxValue_throwsError() {
+        int maxOptions = 4;
+        InlineListPayload payload = new InlineListPayload(DUMMY_SETTING,
+                ResultPayload.SettingsSource.SYSTEM, null /* intent */, true /* isDeviceSupport */,
+                maxOptions /* numOptions */);
+
+        payload.setValue(mContext, maxOptions + 1);
+    }
+}
diff --git a/tests/robotests/src/com/android/settings/search/InlinePayloadTest.java b/tests/robotests/src/com/android/settings/search/InlinePayloadTest.java
new file mode 100644
index 0000000..b2a6211
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/search/InlinePayloadTest.java
@@ -0,0 +1,127 @@
+package com.android.settings.search;
+
+import android.content.Context;
+import android.content.ContentResolver;
+import android.content.Intent;
+import android.os.Parcel;
+import android.provider.Settings;
+import com.android.settings.TestConfig;
+import com.android.settings.search.ResultPayload.SettingsSource;
+import com.android.settings.testutils.SettingsRobolectricTestRunner;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.robolectric.RuntimeEnvironment;
+import org.robolectric.annotation.Config;
+
+import static android.provider.Settings.System.SCREEN_BRIGHTNESS_MODE;
+import static com.google.common.truth.Truth.assertThat;
+
+@RunWith(SettingsRobolectricTestRunner.class)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+public class InlinePayloadTest {
+
+    private Context mContext;
+
+    private final String KEY = "key";
+
+    @Before
+    public void setUp() {
+        mContext = RuntimeEnvironment.application;
+    }
+
+    @Test
+    public void testGetSecure_returnsSecureSetting() {
+        InlinePayload payload = getDummyPayload(SettingsSource.SECURE);
+        int currentValue = 2;
+        Settings.Secure.putInt(mContext.getContentResolver(), KEY, currentValue);
+
+        int newValue = payload.getValue(mContext);
+
+        assertThat(newValue).isEqualTo(currentValue);
+    }
+
+    @Test
+    public void testGetGlobal_returnsGlobalSetting() {
+        InlinePayload payload = getDummyPayload(SettingsSource.GLOBAL);
+        int currentValue = 2;
+        Settings.Global.putInt(mContext.getContentResolver(), KEY, currentValue);
+
+        int newValue = payload.getValue(mContext);
+
+        assertThat(newValue).isEqualTo(currentValue);
+    }
+
+    @Test
+    public void testGetSystem_returnsSystemSetting() {
+        InlinePayload payload = getDummyPayload(SettingsSource.SYSTEM);
+        int currentValue = 2;
+        Settings.System.putInt(mContext.getContentResolver(), KEY, currentValue);
+
+        int newValue = payload.getValue(mContext);
+
+        assertThat(newValue).isEqualTo(currentValue);
+    }
+
+    @Test
+    public void testSetSecure_updatesSecureSetting() {
+        InlinePayload payload = getDummyPayload(SettingsSource.SECURE);
+        int newValue = 1;
+        ContentResolver resolver = mContext.getContentResolver();
+        Settings.Secure.putInt(resolver, KEY, 0);
+
+        payload.setValue(mContext, newValue);
+        int updatedValue = Settings.System.getInt(resolver, KEY, -1);
+
+        assertThat(updatedValue).isEqualTo(newValue);
+    }
+
+    @Test
+    public void testSetGlobal_updatesGlobalSetting() {
+        InlinePayload payload = getDummyPayload(SettingsSource.GLOBAL);
+        int newValue = 1;
+        ContentResolver resolver = mContext.getContentResolver();
+        Settings.Global.putInt(resolver, KEY, 0);
+
+        payload.setValue(mContext, newValue);
+        int updatedValue = Settings.Global.getInt(resolver, KEY, -1);
+
+        assertThat(updatedValue).isEqualTo(newValue);
+    }
+
+    @Test
+    public void testSetSystem_updatesSystemSetting() {
+        InlinePayload payload = getDummyPayload(SettingsSource.SECURE);
+        int newValue = 1;
+        ContentResolver resolver = mContext.getContentResolver();
+        Settings.System.putInt(resolver, SCREEN_BRIGHTNESS_MODE, 0);
+
+        payload.setValue(mContext, newValue);
+        int updatedValue = Settings.System.getInt(resolver, KEY, -1);
+
+        assertThat(updatedValue).isEqualTo(newValue);
+    }
+
+    private InlinePayload getDummyPayload(int source) {
+        return new ConcreteInlinePayload(KEY, source, null /* intent */,
+                true /* isDeviceSupported */);
+    }
+
+    class ConcreteInlinePayload extends InlinePayload {
+
+        public ConcreteInlinePayload(String key, @SettingsSource int source, Intent intent,
+                boolean isDeviceSupported) {
+            super(key, source, intent, isDeviceSupported);
+        }
+
+        @Override
+        public int getType() {
+            return 0;
+        }
+
+        @Override
+        protected int standardizeInput(int input) throws IllegalArgumentException {
+            return input;
+        }
+    }
+}
diff --git a/tests/robotests/src/com/android/settings/search/InlineSwitchPayloadTest.java b/tests/robotests/src/com/android/settings/search/InlineSwitchPayloadTest.java
index c4d798b..2c16c13 100644
--- a/tests/robotests/src/com/android/settings/search/InlineSwitchPayloadTest.java
+++ b/tests/robotests/src/com/android/settings/search/InlineSwitchPayloadTest.java
@@ -64,7 +64,7 @@
         InlineSwitchPayload payload = new InlineSwitchPayload(uri, source, 1, intent, true);
         final Intent retainedIntent = payload.getIntent();
         assertThat(payload.mSettingKey).isEqualTo(uri);
-        assertThat(payload.mInlineType).isEqualTo(type);
+        assertThat(payload.getType()).isEqualTo(type);
         assertThat(payload.mSettingSource).isEqualTo(source);
         assertThat(payload.isStandard()).isTrue();
         assertThat(payload.getAvailability()).isEqualTo(ResultPayload.Availability.AVAILABLE);
@@ -80,20 +80,19 @@
         final String intentVal = "value";
         final Intent intent = new Intent();
         intent.putExtra(intentKey, intentVal);
-
         Parcel parcel = Parcel.obtain();
         parcel.writeParcelable(intent, 0);
         parcel.writeString(uri);
-        parcel.writeInt(type);
         parcel.writeInt(source);
         parcel.writeInt(InlineSwitchPayload.TRUE);
         parcel.writeInt(InlineSwitchPayload.TRUE);
         parcel.setDataPosition(0);
 
         InlineSwitchPayload payload = InlineSwitchPayload.CREATOR.createFromParcel(parcel);
+
         final Intent builtIntent = payload.getIntent();
         assertThat(payload.mSettingKey).isEqualTo(uri);
-        assertThat(payload.mInlineType).isEqualTo(type);
+        assertThat(payload.getType()).isEqualTo(type);
         assertThat(payload.mSettingSource).isEqualTo(source);
         assertThat(payload.isStandard()).isTrue();
         assertThat(payload.getAvailability()).isEqualTo(Availability.AVAILABLE);
@@ -101,84 +100,6 @@
     }
 
     @Test
-    public void testGetSecure_returnsSecureSetting() {
-        InlineSwitchPayload payload = new InlineSwitchPayload(DUMMY_SETTING, SettingsSource.SECURE,
-                STANDARD_ON, null /* intent */, true);
-        int currentValue = 1;
-        Settings.Secure.putInt(mContext.getContentResolver(), DUMMY_SETTING, currentValue);
-
-        int newValue = payload.getValue(mContext);
-
-        assertThat(newValue).isEqualTo(currentValue);
-    }
-
-    @Test
-    public void testGetGlobal_returnsGlobalSetting() {
-        InlineSwitchPayload payload = new InlineSwitchPayload(DUMMY_SETTING, SettingsSource.GLOBAL,
-                STANDARD_ON, null /* intent */, true);
-        int currentValue = 1;
-        Settings.Global.putInt(mContext.getContentResolver(), DUMMY_SETTING, currentValue);
-
-        int newValue = payload.getValue(mContext);
-
-        assertThat(newValue).isEqualTo(currentValue);
-    }
-
-    @Test
-    public void testGetSystem_returnsSystemSetting() {
-        InlineSwitchPayload payload = new InlineSwitchPayload(DUMMY_SETTING, SettingsSource.SYSTEM,
-                STANDARD_ON, null /* intent */, true);
-        int currentValue = 1;
-        Settings.System.putInt(mContext.getContentResolver(), DUMMY_SETTING, currentValue);
-
-        int newValue = payload.getValue(mContext);
-
-        assertThat(newValue).isEqualTo(currentValue);
-    }
-
-    @Test
-    public void testSetSecure_updatesSecureSetting() {
-        InlineSwitchPayload payload = new InlineSwitchPayload(DUMMY_SETTING, SettingsSource.SECURE,
-                STANDARD_ON, null /* intent */, true);
-        int newValue = 1;
-        ContentResolver resolver = mContext.getContentResolver();
-        Settings.Secure.putInt(resolver, SCREEN_BRIGHTNESS_MODE, 0);
-
-        payload.setValue(mContext, newValue);
-        int updatedValue = Settings.System.getInt(resolver, DUMMY_SETTING, -1);
-
-        assertThat(updatedValue).isEqualTo(newValue);
-    }
-
-    @Test
-    public void testSetGlobal_updatesGlobalSetting() {
-        InlineSwitchPayload payload = new InlineSwitchPayload(DUMMY_SETTING, SettingsSource.GLOBAL,
-                STANDARD_ON, null /* intent */, true);
-        int newValue = 1;
-        ContentResolver resolver = mContext.getContentResolver();
-        Settings.Global.putInt(resolver, SCREEN_BRIGHTNESS_MODE, 0);
-
-        payload.setValue(mContext, newValue);
-        int updatedValue = Settings.Global.getInt(resolver, DUMMY_SETTING, -1);
-
-        assertThat(updatedValue).isEqualTo(newValue);
-    }
-
-    @Test
-    public void testSetSystem_updatesSystemSetting() {
-        InlineSwitchPayload payload = new InlineSwitchPayload(DUMMY_SETTING, SettingsSource.SYSTEM,
-                STANDARD_ON, null /* intent */, true);
-        int newValue = 1;
-        ContentResolver resolver = mContext.getContentResolver();
-        Settings.System.putInt(resolver, SCREEN_BRIGHTNESS_MODE, 0);
-
-        payload.setValue(mContext, newValue);
-        int updatedValue = Settings.System.getInt(resolver, DUMMY_SETTING, -1);
-
-        assertThat(updatedValue).isEqualTo(newValue);
-    }
-
-    @Test
     public void testGetSystem_flippedSetting_returnsFlippedValue() {
         // Stores 1s as 0s, and vis versa
         InlineSwitchPayload payload = new InlineSwitchPayload(DUMMY_SETTING, SettingsSource.SYSTEM,