Merge "Share apply token between WMCore and WMShell"

This commit is contained in:
Evan Rosky
2022-11-03 16:43:25 +00:00
committed by Android (Google) Code Review
4 changed files with 33 additions and 0 deletions

View File

@@ -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();
}

View File

@@ -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();
}

View File

@@ -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);

View File

@@ -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) {