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

Commit 735f04b6 authored by Rupesh Bansal's avatar Rupesh Bansal Committed by Android (Google) Code Review
Browse files

Merge "Subscribing viewroot impl to only display state changes" into main

parents fce360da 755dd581
Loading
Loading
Loading
Loading
+15 −3
Original line number Diff line number Diff line
@@ -1236,6 +1236,8 @@ public final class ViewRootImpl implements ViewParent,
    private @ActivityInfo.ColorMode int mCurrentColorMode = ActivityInfo.COLOR_MODE_DEFAULT;
    private long mColorModeLastSetMillis = -1;
    private final boolean mIsSubscribeGranularDisplayEventsEnabled;
    public ViewRootImpl(Context context, Display display) {
        this(context, display, WindowManagerGlobal.getWindowSession(), new WindowLayout());
    }
@@ -1333,6 +1335,8 @@ public final class ViewRootImpl implements ViewParent,
        // Disable DRAW_WAKE_LOCK starting U.
        mDisableDrawWakeLock =
                CompatChanges.isChangeEnabled(DISABLE_DRAW_WAKE_LOCK) && disableDrawWakeLock();
        mIsSubscribeGranularDisplayEventsEnabled =
                com.android.server.display.feature.flags.Flags.subscribeGranularDisplayEvents();
    }
    public static void addFirstDrawHandler(Runnable callback) {
@@ -1810,14 +1814,22 @@ public final class ViewRootImpl implements ViewParent,
                mAccessibilityInteractionConnectionManager, mHandler);
        mAccessibilityManager.addHighContrastTextStateChangeListener(
                mExecutor, mHighContrastTextManager);
        long eventsToBeRegistered =
                (mIsSubscribeGranularDisplayEventsEnabled)
                ? DisplayManagerGlobal.INTERNAL_EVENT_FLAG_DISPLAY_ADDED
                        | DisplayManagerGlobal.INTERNAL_EVENT_FLAG_DISPLAY_STATE
                        | DisplayManagerGlobal.INTERNAL_EVENT_FLAG_DISPLAY_REMOVED
                : DisplayManagerGlobal.INTERNAL_EVENT_FLAG_DISPLAY_ADDED
                        | DisplayManagerGlobal.INTERNAL_EVENT_FLAG_DISPLAY_CHANGED
                        | DisplayManagerGlobal.INTERNAL_EVENT_FLAG_DISPLAY_REMOVED;
        DisplayManagerGlobal
                .getInstance()
                .registerDisplayListener(
                        mDisplayListener,
                        mHandler,
                        DisplayManagerGlobal.INTERNAL_EVENT_FLAG_DISPLAY_ADDED
                        | DisplayManagerGlobal.INTERNAL_EVENT_FLAG_DISPLAY_CHANGED
                        | DisplayManagerGlobal.INTERNAL_EVENT_FLAG_DISPLAY_REMOVED,
                        eventsToBeRegistered,
                        mBasePackageName);
        if (forceInvertColor()) {
+13 −0
Original line number Diff line number Diff line
@@ -257,6 +257,11 @@ public class DisplayManagerFlags {
            Flags::displayListenerPerformanceImprovements
    );

    private final FlagState mSubscribeGranularDisplayEvents = new FlagState(
            Flags.FLAG_SUBSCRIBE_GRANULAR_DISPLAY_EVENTS,
            Flags::subscribeGranularDisplayEvents
    );

    /**
     * @return {@code true} if 'port' is allowed in display layout configuration file.
     */
@@ -551,6 +556,13 @@ public class DisplayManagerFlags {
        return mDisplayListenerPerformanceImprovementsFlagState.isEnabled();
    }

    /**
     * @return {@code true} if the flag for subscribing to granular display events is enabled
     */
    public boolean isSubscribeGranularDisplayEventsEnabled() {
        return mSubscribeGranularDisplayEvents.isEnabled();
    }

    /**
     * dumps all flagstates
     * @param pw printWriter
@@ -605,6 +617,7 @@ public class DisplayManagerFlags {
        pw.println(" " + mGetSupportedRefreshRatesFlagState);
        pw.println(" " + mEnablePluginManagerFlagState);
        pw.println(" " + mDisplayListenerPerformanceImprovementsFlagState);
        pw.println(" " + mSubscribeGranularDisplayEvents);
    }

    private static class FlagState {
+11 −0
Original line number Diff line number Diff line
@@ -478,3 +478,14 @@ flag {
    bug: "378385869"
    is_fixed_read_only: true
}

flag {
    name: "subscribe_granular_display_events"
    namespace: "display_manager"
    description: "Enable subscription to granular display change events."
    bug: "379250634"
    is_fixed_read_only: true
    metadata {
      purpose: PURPOSE_BUGFIX
    }
}