Prevent IndexOutOfBoundsException in PipTransition

Monkey test detects IndexOutOfBoundsException thrown from
PipTransition#removePipImmediately, log and bypass the
IndexOutOfBoundsException while the investigation is in progress.

Bug: 335524017
Test: N/A
Change-Id: Idfa6c2592746c696057965e21be8ed2249e046e0
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/pip/PipTransition.java b/libs/WindowManager/Shell/src/com/android/wm/shell/pip/PipTransition.java
index d60f5a6..10b7619 100644
--- a/libs/WindowManager/Shell/src/com/android/wm/shell/pip/PipTransition.java
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/pip/PipTransition.java
@@ -818,8 +818,13 @@
             @NonNull Transitions.TransitionFinishCallback finishCallback,
             @NonNull TaskInfo taskInfo) {
         startTransaction.apply();
-        finishTransaction.setWindowCrop(info.getChanges().get(0).getLeash(),
-                mPipDisplayLayoutState.getDisplayBounds());
+        if (info.getChanges().isEmpty()) {
+            ProtoLog.e(ShellProtoLogGroup.WM_SHELL_PICTURE_IN_PICTURE,
+                    "removePipImmediately is called with empty changes");
+        } else {
+            finishTransaction.setWindowCrop(info.getChanges().get(0).getLeash(),
+                    mPipDisplayLayoutState.getDisplayBounds());
+        }
         mPipOrganizer.onExitPipFinished(taskInfo);
         finishCallback.onTransitionFinished(null);
     }