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

Commit 52691b0d authored by Hongwei Wang's avatar Hongwei Wang
Browse files

Add logs for PiP exclusion bounds

- Add extra logs when the PiP exclusion bounds, usually listened by back
  gesture in SysUI, is updated
- Update the internal interface for adding/removing the listener

Flag: EXEMPT logonly
Bug: 407227077
Test: atest WMShellUnitTests:PipBoundsStateTest
Test: Verify the logs are properly printed out
Change-Id: I2c120f508f8721121bb9300e49f4c43086889a14
parent a0c5e071
Loading
Loading
Loading
Loading
+10 −6
Original line number Diff line number Diff line
@@ -189,6 +189,8 @@ public class PipBoundsState implements PipDisplayLayoutState.DisplayIdListener {
    /** Set the current PIP bounds. */
    public void setBounds(@NonNull Rect bounds) {
        mBounds.set(bounds);
        ProtoLog.d(ShellProtoLogGroup.WM_SHELL_PICTURE_IN_PICTURE,
                "Update exclusion bounds to %s", bounds);
        for (Consumer<Rect> callback : mOnPipExclusionBoundsChangeCallbacks) {
            callback.accept(bounds);
        }
@@ -595,10 +597,10 @@ public class PipBoundsState implements PipDisplayLayoutState.DisplayIdListener {
     * Back-gesture handler, to avoid conflicting with PiP when it's stashed.
     */
    public void addPipExclusionBoundsChangeCallback(
            @Nullable Consumer<Rect> onPipExclusionBoundsChangeCallback) {
            @NonNull Consumer<Rect> onPipExclusionBoundsChangeCallback) {
        if (onPipExclusionBoundsChangeCallback != null) {
            mOnPipExclusionBoundsChangeCallbacks.add(onPipExclusionBoundsChangeCallback);
        for (Consumer<Rect> callback : mOnPipExclusionBoundsChangeCallbacks) {
            callback.accept(getBounds());
            onPipExclusionBoundsChangeCallback.accept(getBounds());
        }
    }

@@ -606,9 +608,11 @@ public class PipBoundsState implements PipDisplayLayoutState.DisplayIdListener {
     * Remove a callback that was previously added.
     */
    public void removePipExclusionBoundsChangeCallback(
            @Nullable Consumer<Rect> onPipExclusionBoundsChangeCallback) {
            @NonNull Consumer<Rect> onPipExclusionBoundsChangeCallback) {
        if (onPipExclusionBoundsChangeCallback != null) {
            mOnPipExclusionBoundsChangeCallbacks.remove(onPipExclusionBoundsChangeCallback);
        }
    }

    /** Adds callback to listen on aspect ratio change. */
    public void addOnAspectRatioChangedCallback(
+4 −0
Original line number Diff line number Diff line
@@ -778,6 +778,8 @@ public class PipController implements ConfigurationChangeListener,
        @Override
        public void addPipExclusionBoundsChangeListener(Consumer<Rect> listener) {
            mMainExecutor.execute(() -> {
                ProtoLog.d(ShellProtoLogGroup.WM_SHELL_PICTURE_IN_PICTURE,
                        "addPipExclusionBoundsChangeListener: %s", listener);
                mPipBoundsState.addPipExclusionBoundsChangeCallback(listener);
            });
        }
@@ -785,6 +787,8 @@ public class PipController implements ConfigurationChangeListener,
        @Override
        public void removePipExclusionBoundsChangeListener(Consumer<Rect> listener) {
            mMainExecutor.execute(() -> {
                ProtoLog.d(ShellProtoLogGroup.WM_SHELL_PICTURE_IN_PICTURE,
                        "removePipExclusionBoundsChangeListener: %s", listener);
                mPipBoundsState.removePipExclusionBoundsChangeCallback(listener);
            });
        }