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

Commit 7712eb3b authored by Simon (Qiong) Sun's avatar Simon (Qiong) Sun
Browse files

Prevent split-screen decor animation on invalid snapshot (null)

Check if the snapshot is valid before animating the decor. This avoids a bug where `SplitScreenTransitions.onFinish` is not called, which causes the split-screen to freeze.

Bug: 434127815
Flag: com.android.wm.shell.enable_flexible_two_app_split
Test: On a foldable device (fold mode), enter split-screen and repeatedly swap the split ratio between 10:90 and 90:10.
Change-Id: Iae30083bc3f9ad4291a79f17eb02e9de2fb1b353
parent 0d147139
Loading
Loading
Loading
Loading
+9 −2
Original line number Original line Diff line number Diff line
@@ -264,6 +264,7 @@ class SplitScreenTransitions {
                startTransaction.show(leash);
                startTransaction.show(leash);
            }
            }
        }
        }

        startTransaction.apply();
        startTransaction.apply();
        onFinish(null /* wct */);
        onFinish(null /* wct */);
    }
    }
@@ -287,13 +288,19 @@ class SplitScreenTransitions {
                startTransaction.setWindowCrop(leash, change.getEndAbsBounds().width(),
                startTransaction.setWindowCrop(leash, change.getEndAbsBounds().width(),
                        change.getEndAbsBounds().height());
                        change.getEndAbsBounds().height());


                final SurfaceControl snapshot = change.getSnapshot();
                if (snapshot == null || !snapshot.isValid()) {
                    ProtoLog.d(WM_SHELL_SPLIT_SCREEN,
                            "change[%s]: snapshot is null or invalid", change);
                    continue;
                }
                SplitDecorManager decor = rootDecorMap.get(change.getContainer());
                SplitDecorManager decor = rootDecorMap.get(change.getContainer());


                // This is to ensure onFinished be called after all animations ended.
                // This is to ensure onFinished be called after all animations ended.
                ValueAnimator va = new ValueAnimator();
                ValueAnimator va = new ValueAnimator();
                mAnimations.add(va);
                mAnimations.add(va);


                decor.setScreenshotIfNeeded(change.getSnapshot(), startTransaction);
                decor.setScreenshotIfNeeded(snapshot, startTransaction);
                decor.onResized(startTransaction, animated -> {
                decor.onResized(startTransaction, animated -> {
                    mAnimations.remove(va);
                    mAnimations.remove(va);
                    if (animated) {
                    if (animated) {
@@ -304,8 +311,8 @@ class SplitScreenTransitions {
                });
                });
            }
            }
        }
        }

        startTransaction.apply();
        startTransaction.apply();

        onFinish(null /* wct */);
        onFinish(null /* wct */);
    }
    }