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

Commit 74c12a04 authored by Piotr Wilczyński's avatar Piotr Wilczyński
Browse files

Send topology to input manager when input manager ready

Also, log the graph sent to input manager.

Bug: 429525174
Bug: 425924388
Test: DisplayManagerServiceTest
Flag: EXEMPT bugfix
Change-Id: Ibd298a94bc5621c6263f38772e5f683894c2c1f0
parent edc0b13d
Loading
Loading
Loading
Loading
+40 −0
Original line number Diff line number Diff line
@@ -19,12 +19,14 @@ package android.hardware.display;
import android.annotation.FlaggedApi;
import android.annotation.TestApi;
import android.graphics.RectF;
import android.util.IndentingPrintWriter;
import android.util.SparseArray;

import androidx.annotation.NonNull;

import com.android.server.display.feature.flags.Flags;

import java.io.StringWriter;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
@@ -68,6 +70,27 @@ public class DisplayTopologyGraph {
        return displayNodes;
    }

    /**
     * Print the object's state and debug information into the given stream.
     * @hide
     * @param pw The stream to dump information to.
     */
    public void dump(IndentingPrintWriter pw) {
        pw.println("DisplayTopologyGraph{" + "mPrimaryDisplayId=" + mPrimaryDisplayId + '}');
        pw.increaseIndent();
        for (DisplayNode displayNode : mDisplayNodes) {
            displayNode.dump(pw);
        }
        pw.decreaseIndent();
    }

    @Override
    public String toString() {
        StringWriter out = new StringWriter();
        dump(new IndentingPrintWriter(out));
        return out.toString();
    }

    /** Node representation of a display, including its {@link AdjacentEdge} */
    public static class DisplayNode {

@@ -111,6 +134,23 @@ public class DisplayTopologyGraph {
        public @NonNull List<AdjacentEdge> getAdjacentEdges() {
            return Collections.unmodifiableList(Arrays.asList(mAdjacentEdges));
        }

        /**
         * Print the object's state and debug information into the given stream.
         * @hide
         * @param pw The stream to dump information to.
         */
        public void dump(IndentingPrintWriter pw) {
            pw.println("DisplayNode{" + "displayId=" + mDisplayId + ", density=" + mDensity
                    + ", bounds=" + mBoundsInGlobalDp + '}');
            if (mAdjacentEdges != null) {
                pw.increaseIndent();
                for (AdjacentEdge edge : mAdjacentEdges) {
                    pw.println(edge);
                }
                pw.decreaseIndent();
            }
        }
    }

    /** Edge to adjacent display */
+11 −3
Original line number Diff line number Diff line
@@ -689,9 +689,12 @@ public final class DisplayManagerService extends SystemService {
            final var backupManager = new BackupManager(mContext);
            Consumer<Pair<DisplayTopology, DisplayTopologyGraph>> topologyChangedCallback =
                    update -> {
                        DisplayTopologyGraph graph = update.second;
                        if (mInputManagerInternal != null && graph != null) {
                            mInputManagerInternal.setDisplayTopology(graph);
                        if (mInputManagerInternal != null) {
                            Slog.d(TAG,
                                    "Sending topology graph to Input Manager: " + update.second);
                            mInputManagerInternal.setDisplayTopology(update.second);
                        } else {
                            Slog.w(TAG, "Not sending topology, mInputManagerInternal is null");
                        }
                        deliverTopologyUpdate(update.first);
                    };
@@ -843,6 +846,11 @@ public final class DisplayManagerService extends SystemService {
        synchronized (mSyncRoot) {
            mWindowManagerInternal = LocalServices.getService(WindowManagerInternal.class);
            mInputManagerInternal = LocalServices.getService(InputManagerInternal.class);
            if (mDisplayTopologyCoordinator != null) {
                DisplayTopologyGraph graph = mDisplayTopologyCoordinator.getTopology().getGraph();
                Slog.d(TAG, "Sending topology graph to Input Manager: " + graph);
                mInputManagerInternal.setDisplayTopology(graph);
            }
            mActivityManagerInternal = LocalServices.getService(ActivityManagerInternal.class);

            ActivityManager activityManager = mContext.getSystemService(ActivityManager.class);