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

Commit e0ca18fc authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Handle case of no closing surfaces in origin launch" into main

parents 7651ff15 4abad003
Loading
Loading
Loading
Loading
+45 −12
Original line number Original line Diff line number Diff line
@@ -195,7 +195,10 @@ public class OriginRemoteTransition extends IRemoteTransition.Stub {
        // Create the origin leash and add to the transition root leash.
        // Create the origin leash and add to the transition root leash.
        mOriginLeash =
        mOriginLeash =
                new SurfaceControl.Builder().setName("OriginTransition-origin-leash").build();
                new SurfaceControl.Builder().setName("OriginTransition-origin-leash").build();
        mStartTransaction

        // Create temporary transaction to build
        final SurfaceControl.Transaction tmpTransaction = new SurfaceControl.Transaction();
        tmpTransaction
                .reparent(mOriginLeash, rootLeash)
                .reparent(mOriginLeash, rootLeash)
                .show(mOriginLeash)
                .show(mOriginLeash)
                .setCornerRadius(mOriginLeash, windowRadius)
                .setCornerRadius(mOriginLeash, windowRadius)
@@ -208,14 +211,14 @@ public class OriginRemoteTransition extends IRemoteTransition.Stub {
            int mode = change.getMode();
            int mode = change.getMode();
            SurfaceControl leash = change.getLeash();
            SurfaceControl leash = change.getLeash();
            // Reparent leash to the transition root.
            // Reparent leash to the transition root.
            mStartTransaction.reparent(leash, rootLeash);
            tmpTransaction.reparent(leash, rootLeash);
            if (TransitionUtil.isOpeningMode(mode)) {
            if (TransitionUtil.isOpeningMode(mode)) {
                openingSurfaces.add(change.getLeash());
                openingSurfaces.add(change.getLeash());
                // For opening surfaces, ending bounds are base bound. Apply corner radius if
                // For opening surfaces, ending bounds are base bound. Apply corner radius if
                // it's full screen.
                // it's full screen.
                Rect bounds = change.getEndAbsBounds();
                Rect bounds = change.getEndAbsBounds();
                if (displayBounds.equals(bounds)) {
                if (displayBounds.equals(bounds)) {
                    mStartTransaction
                    tmpTransaction
                            .setCornerRadius(leash, windowRadius)
                            .setCornerRadius(leash, windowRadius)
                            .setWindowCrop(leash, bounds.width(), bounds.height());
                            .setWindowCrop(leash, bounds.width(), bounds.height());
                }
                }
@@ -226,28 +229,53 @@ public class OriginRemoteTransition extends IRemoteTransition.Stub {
                // it's full screen.
                // it's full screen.
                Rect bounds = change.getStartAbsBounds();
                Rect bounds = change.getStartAbsBounds();
                if (displayBounds.equals(bounds)) {
                if (displayBounds.equals(bounds)) {
                    mStartTransaction
                    tmpTransaction
                            .setCornerRadius(leash, windowRadius)
                            .setCornerRadius(leash, windowRadius)
                            .setWindowCrop(leash, bounds.width(), bounds.height());
                            .setWindowCrop(leash, bounds.width(), bounds.height());
                }
                }
            }
            }
        }
        }


        if (openingSurfaces.isEmpty() && closingSurfaces.isEmpty()) {
            logD("prepareUIs: no opening/closing surfaces available, nothing to prepare.");
            return false;
        }

        // Set relative order:
        // Set relative order:
        // ----  App1  ----
        // ----  App1  ----
        // ---- origin ----
        // ---- origin ----
        // ----  App2  ----
        // ----  App2  ----

        if (mIsEntry) {
        if (mIsEntry) {
            mStartTransaction
            if (!closingSurfaces.isEmpty()) {
                    .setRelativeLayer(mOriginLeash, closingSurfaces.get(0), 1)
                tmpTransaction
                        .setRelativeLayer(mOriginLeash, closingSurfaces.get(0), 1);
            } else {
                logW("Missing closing surface is entry transition");
            }
            if (!openingSurfaces.isEmpty()) {
                tmpTransaction
                        .setRelativeLayer(
                        .setRelativeLayer(
                                openingSurfaces.get(openingSurfaces.size() - 1), mOriginLeash, 1);
                                openingSurfaces.get(openingSurfaces.size() - 1), mOriginLeash, 1);
            } else {
            } else {
            mStartTransaction
                logW("Missing opening surface is entry transition");
                    .setRelativeLayer(mOriginLeash, openingSurfaces.get(0), 1)
            }
                    .setRelativeLayer(

        } else {
            if (!openingSurfaces.isEmpty()) {
                tmpTransaction
                        .setRelativeLayer(mOriginLeash, openingSurfaces.get(0), 1);
            } else {
                logW("Missing opening surface is exit transition");
            }
            if (!closingSurfaces.isEmpty()) {
                tmpTransaction.setRelativeLayer(
                        closingSurfaces.get(closingSurfaces.size() - 1), mOriginLeash, 1);
                        closingSurfaces.get(closingSurfaces.size() - 1), mOriginLeash, 1);
            } else {
                logW("Missing closing surface is exit transition");
            }
        }
        }
        mStartTransaction.merge(tmpTransaction);


        // Attach origin UIComponent to origin leash.
        // Attach origin UIComponent to origin leash.
        mOriginTransaction = mOrigin.newTransaction();
        mOriginTransaction = mOrigin.newTransaction();
@@ -300,6 +328,7 @@ public class OriginRemoteTransition extends IRemoteTransition.Stub {
    }
    }


    private void cancel() {
    private void cancel() {
        logD("cancel()");
        if (mAnimator != null) {
        if (mAnimator != null) {
            mAnimator.cancel();
            mAnimator.cancel();
        }
        }
@@ -311,6 +340,10 @@ public class OriginRemoteTransition extends IRemoteTransition.Stub {
        }
        }
    }
    }


    private static void logW(String msg) {
        Log.w(TAG, msg);
    }

    private static void logE(String msg) {
    private static void logE(String msg) {
        Log.e(TAG, msg);
        Log.e(TAG, msg);
    }
    }