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

Commit 421044be authored by Santos Cordon's avatar Santos Cordon Committed by Android (Google) Code Review
Browse files

Merge "Add name to display-layouts for debugging" into main

parents e6d9f6ec 34ad3b3d
Loading
Loading
Loading
Loading
+7 −4
Original line number Diff line number Diff line
@@ -67,6 +67,8 @@ class DeviceStateToLayoutMap {
    private static final String DATA_CONFIG_FILE_PATH =
            "system/displayconfig/display_layout_configuration.xml";

    private static final String DEFAULT_LAYOUT_NAME = "default_layout";

    private final SparseArray<Layout> mLayoutMap = new SparseArray<>();
    private final DisplayIdProducer mIdProducer;
    private final boolean mIsPortInDisplayLayoutEnabled;
@@ -80,7 +82,7 @@ class DeviceStateToLayoutMap {
        mIsPortInDisplayLayoutEnabled = flags.isPortInDisplayLayoutEnabled();
        mIdProducer = idProducer;
        loadLayoutsFromConfig(configFile);
        createLayout(STATE_DEFAULT);
        createLayout(STATE_DEFAULT, DEFAULT_LAYOUT_NAME);
    }

    static private File getConfigFile() {
@@ -135,7 +137,8 @@ class DeviceStateToLayoutMap {
            }
            for (com.android.server.display.config.layout.Layout l : layouts.getLayout()) {
                final int state = l.getState().intValue();
                final Layout layout = createLayout(state);
                final String name = l.getName();
                final Layout layout = createLayout(state, name);
                for (com.android.server.display.config.layout.Display d: l.getDisplay()) {
                    assert layout != null;
                    final DisplayAddress address = getDisplayAddressForLayoutDisplay(d);
@@ -190,13 +193,13 @@ class DeviceStateToLayoutMap {
        return positionInt;
    }

    private Layout createLayout(int state) {
    private Layout createLayout(int state, String name) {
        if (mLayoutMap.contains(state)) {
            Slog.e(TAG, "Attempted to create a second layout for state " + state);
            return null;
        }

        final Layout layout = new Layout();
        final Layout layout = new Layout(name);
        mLayoutMap.append(state, layout);
        return layout;
    }
+15 −6
Original line number Diff line number Diff line
@@ -48,25 +48,34 @@ public class Layout {

    private final List<Display> mDisplays = new ArrayList<>(2);

    private final String mName;

    public Layout() {
        this(null);
    }

    public Layout(String name) {
        mName = name;
    }

    @Override
    public String toString() {
        return mDisplays.toString();
        return "[" + (TextUtils.isEmpty(mName) ? "" : (mName + ": ")) + mDisplays.toString() + "]";
    }

    @Override
    public boolean equals(Object obj) {

        if (!(obj instanceof Layout)) {
            return false;
        }

        Layout otherLayout = (Layout) obj;
        return this.mDisplays.equals(otherLayout.mDisplays);
        return TextUtils.equals(mName, otherLayout.mName)
                && mDisplays.equals(otherLayout.mDisplays);
    }

    @Override
    public int hashCode() {
        return mDisplays.hashCode();
        return Objects.hash(mName, mDisplays);
    }

    /**
+1 −0
Original line number Diff line number Diff line
@@ -43,6 +43,7 @@
    <xs:complexType name="layout">
        <xs:sequence>
            <xs:element name="state" type="xs:nonNegativeInteger" />
            <xs:element name="name" type="xs:string" minOccurs="0" maxOccurs="1" />
            <xs:element name="display" type="display" maxOccurs="unbounded"/>
        </xs:sequence>
    </xs:complexType>