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

Commit 9071563b authored by Evan Rosky's avatar Evan Rosky
Browse files

Share apply token between WMCore and WMShell

This means WMShell/Core/Launcher are using the same
apply token.

Barring alternatives, this is necessary to make sure
that transitions work properly (since surface operations
span multiple process). Otherwise, even if transactions
are received by SF in the correct order, they can be
applied in a different order.

Bug: 256046837
Test: atest PipRotationTest_ShellTransit and check for leaked
      tasks in surface dump.
Change-Id: I0424e66ed347576718f62b1e598ae116720aa70d
parent cfbc9e02
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -105,4 +105,7 @@ interface IWindowOrganizerController {

    /** @return An interface enabling the transition players to report its metrics. */
    ITransitionMetricsReporter getTransitionMetricsReporter();

    /** @return The transaction queue token used by WM. */
    IBinder getApplyToken();
}
+21 −0
Original line number Diff line number Diff line
@@ -26,6 +26,7 @@ import android.os.IBinder;
import android.os.RemoteException;
import android.util.Singleton;
import android.view.RemoteAnimationAdapter;
import android.view.SurfaceControl;

/**
 * Base class for organizing specific types of windows like Tasks and DisplayAreas
@@ -184,6 +185,26 @@ public class WindowOrganizer {
        }
    }

    /**
     * Use WM's transaction-queue instead of Shell's independent one. This is necessary
     * if WM and Shell need to coordinate transactions (eg. for shell transitions).
     * @return true if successful, false otherwise.
     * @hide
     */
    public boolean shareTransactionQueue() {
        final IBinder wmApplyToken;
        try {
            wmApplyToken = getWindowOrganizerController().getApplyToken();
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
        if (wmApplyToken == null) {
            return false;
        }
        SurfaceControl.Transaction.setDefaultApplyToken(wmApplyToken);
        return true;
    }

    static IWindowOrganizerController getWindowOrganizerController() {
        return IWindowOrganizerControllerSingleton.get();
    }
+3 −0
Original line number Diff line number Diff line
@@ -175,6 +175,9 @@ public class Transitions implements RemoteCallable<Transitions> {
    }

    private void onInit() {
        if (Transitions.ENABLE_SHELL_TRANSITIONS) {
            mOrganizer.shareTransactionQueue();
        }
        mShellController.addExternalInterface(KEY_EXTRA_SHELL_SHELL_TRANSITIONS,
                this::createExternalInterface, this);

+6 −0
Original line number Diff line number Diff line
@@ -1547,6 +1547,12 @@ class WindowOrganizerController extends IWindowOrganizerController.Stub
        return mTransitionController.mTransitionMetricsReporter;
    }

    @Override
    public IBinder getApplyToken() {
        enforceTaskPermission("getApplyToken()");
        return SurfaceControl.Transaction.getDefaultApplyToken();
    }

    /** Whether the configuration changes are important to report back to an organizer. */
    static boolean configurationsAreEqualForOrganizer(
            Configuration newConfig, @Nullable Configuration oldConfig) {