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

Commit c9c35784 authored by Alex Stetson's avatar Alex Stetson
Browse files

Reduce over notification of topFocusedWindowChange

Registered remote inset controllers are being greatly over notified
through this API when there are no changes. This change will reduce this
notification to only occur when one (or both) of the parameters change.

Bug: 385355211
Test: manual, presubmit
Flag: NONE bugfix
Change-Id: I171dd2e7d81d86f9d5963609ecf2019a82193ab1
parent d676d13d
Loading
Loading
Loading
Loading
+21 −2
Original line number Diff line number Diff line
@@ -7046,9 +7046,22 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp

    class RemoteInsetsControlTarget implements InsetsControlTarget {
        private final IDisplayWindowInsetsController mRemoteInsetsController;
        private @InsetsType int mRequestedVisibleTypes = WindowInsets.Type.defaultVisible();
        private final boolean mCanShowTransient;

        /** The actual requested visible inset types for this display */
        private @InsetsType int mRequestedVisibleTypes = WindowInsets.Type.defaultVisible();

        /** The component name of the top focused window on this display */
        private ComponentName mTopFocusedComponentName = null;

        /**
         * The inset types that the top focused window is currently requesting to be visible.
         * This may be different than the actual visible types above depending on the remote
         * insets controller implementation.
         */
        private @InsetsType int mTopFocusedRequestedVisibleTypes =
                WindowInsets.Type.defaultVisible();

        RemoteInsetsControlTarget(IDisplayWindowInsetsController controller) {
            mRemoteInsetsController = controller;
            mCanShowTransient = mWmService.mContext.getResources().getBoolean(
@@ -7058,11 +7071,17 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
        /**
         * Notifies the remote insets controller that the top focused window has changed.
         *
         * @param component The application component that is open in the top focussed window.
         * @param component The application component that is open in the top focused window.
         * @param requestedVisibleTypes The insets types requested visible by the focused window.
         */
        void topFocusedWindowChanged(ComponentName component,
                @InsetsType int requestedVisibleTypes) {
            if (mTopFocusedComponentName != null && mTopFocusedComponentName.equals(component)
                    && mTopFocusedRequestedVisibleTypes == requestedVisibleTypes) {
                return;
            }
            mTopFocusedComponentName = component;
            mTopFocusedRequestedVisibleTypes = requestedVisibleTypes;
            try {
                mRemoteInsetsController.topFocusedWindowChanged(component, requestedVisibleTypes);
            } catch (RemoteException e) {