Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 503170cb authored by Marcelo Arteiro's avatar Marcelo Arteiro
Browse files

Fixes ThemeSettings Parcel writing.

An outdated instruction was left on ThemeSettings parcel writing which caused errors instantiating it's subclasses. ThemeSettingsTest also update to reflect this change.

Bug: 333694176
Test: atest FrameworksServicesTests_theme
Flag: android.server.enable_theme_service
Change-Id: Ib2f257368dbde8a3c6fb7beb0447bb8c03111f68
parent 76e77d1f
Loading
Loading
Loading
Loading
+3 −5
Original line number Diff line number Diff line
@@ -151,14 +151,12 @@ public abstract sealed class ThemeSettings implements Parcelable permits ThemeSe
        @Override
        public ThemeSettings createFromParcel(Parcel in) {
            // The first string read is the concrete type, used by the sealed class's parceling
            // to delegate to the correct subclass constructor.
            // We then read the actual type string that we wrote in the subclass's writeToParcel.
            in.readString(); // Consume the type written by the sealed class itself for dispatch
            String type = in.readString(); // This is the type we're interested in
            // to delegate to the correct subclass constructor..
            String type = in.readString();
            return switch (type) {
                case VALUE_HOME_WALLPAPER -> new ThemeSettingsWallpaper(in);
                case VALUE_PRESET -> new ThemeSettingsPreset(in);
                default -> throw new IllegalArgumentException(
                case null, default -> throw new IllegalArgumentException(
                        "Invalid type for ThemeSetting: " + type);
            };
        }
+1 −4
Original line number Diff line number Diff line
@@ -16,7 +16,6 @@

package com.android.server.theming;

import static android.content.theming.FieldColorSource.VALUE_HOME_WALLPAPER;
import static android.content.theming.FieldColorSource.VALUE_PRESET;
import static android.content.theming.ThemeSettings.OVERLAY_CATEGORY_ACCENT_COLOR;
import static android.content.theming.ThemeSettings.OVERLAY_CATEGORY_SYSTEM_PALETTE;
@@ -105,7 +104,6 @@ public class ThemeSettingsTests {
        ThemeSettings originalSettings = ThemeSettings.fromJson(WALLPAPER_JSON);

        Parcel parcel = Parcel.obtain();
        parcel.writeString(VALUE_HOME_WALLPAPER);
        originalSettings.writeToParcel(parcel, 0);
        parcel.setDataPosition(0);

@@ -122,7 +120,6 @@ public class ThemeSettingsTests {
        ThemeSettings originalSettings = ThemeSettings.fromJson(PRESET_JSON);

        Parcel parcel = Parcel.obtain();
        parcel.writeString(VALUE_PRESET);
        originalSettings.writeToParcel(parcel, 0);
        parcel.setDataPosition(0);