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

Commit 2769c6a0 authored by Robert Carr's avatar Robert Carr
Browse files

WM: Mark task overlays as trusted overlays

Seemingly every use of this going forward will also require
trusted overlay so it probably just makes sense to set it
in the infrastructure. We do some renaming and documentation
cleanup to make it a little more clear whats happening.

Bug: 213603716
Bug: 214239892
Test: Existing tests pass, manual.
Change-Id: Id55ef6bf439c6d911eb3f79cad7eaca2cc6cee17
parent ee754300
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -473,7 +473,7 @@ final class GameServiceProviderInstanceImpl implements GameServiceProviderInstan
        }

        try {
            mWindowManagerInternal.addTaskOverlay(
            mWindowManagerInternal.addTrustedTaskOverlay(
                    taskId,
                    createGameSessionResult.getSurfacePackage());
        } catch (IllegalArgumentException ex) {
@@ -519,7 +519,7 @@ final class GameServiceProviderInstanceImpl implements GameServiceProviderInstan
        SurfacePackage surfacePackage = gameSessionRecord.getSurfacePackage();
        if (surfacePackage != null) {
            try {
                mWindowManagerInternal.removeTaskOverlay(
                mWindowManagerInternal.removeTrustedTaskOverlay(
                        gameSessionRecord.getTaskId(),
                        surfacePackage);
            } catch (IllegalArgumentException ex) {
+10 −2
Original line number Diff line number Diff line
@@ -32,14 +32,20 @@ import java.util.ArrayList;
 *
 * Also handles multiplexing of event dispatch and tracking of overlays
 * to make things easier for WindowContainer.
 *
 * These overlays are to be used for various types of System UI and UI
 * under the systems control. Provided SurfacePackages will be able
 * to overlay application content, without engaging the usual cross process
 * obscured touch filtering mechanisms. It's imperative that all UI provided
 * be under complete control of the system.
 */
class OverlayHost {
class TrustedOverlayHost {
    // Lazily initialized when required
    SurfaceControl mSurfaceControl;
    final ArrayList<SurfaceControlViewHost.SurfacePackage> mOverlays = new ArrayList<>();
    final WindowManagerService mWmService;

    OverlayHost(WindowManagerService wms) {
    TrustedOverlayHost(WindowManagerService wms) {
        mWmService = wms;
    }

@@ -51,6 +57,8 @@ class OverlayHost {
                .setName("Overlay Host Leash");

            mSurfaceControl = b.build();
            SurfaceControl.Transaction t = mWmService.mTransactionFactory.get();
            t.setTrustedOverlay(mSurfaceControl, true).apply();
        }
    }

+5 −5
Original line number Diff line number Diff line
@@ -314,7 +314,7 @@ class WindowContainer<E extends WindowContainer> extends ConfigurationContainer<

    private final List<WindowContainerListener> mListeners = new ArrayList<>();

    protected OverlayHost mOverlayHost;
    protected TrustedOverlayHost mOverlayHost;

    WindowContainer(WindowManagerService wms) {
        mWmService = wms;
@@ -3600,9 +3600,9 @@ class WindowContainer<E extends WindowContainer> extends ConfigurationContainer<
                @AnimationType int type, @Nullable AnimationAdapter snapshotAnim);
    }

    void addOverlay(SurfaceControlViewHost.SurfacePackage overlay) {
    void addTrustedOverlay(SurfaceControlViewHost.SurfacePackage overlay) {
        if (mOverlayHost == null) {
            mOverlayHost = new OverlayHost(mWmService);
            mOverlayHost = new TrustedOverlayHost(mWmService);
        }
        mOverlayHost.addOverlay(overlay, mSurfaceControl);

@@ -3613,11 +3613,11 @@ class WindowContainer<E extends WindowContainer> extends ConfigurationContainer<
            overlay.getRemoteInterface().onConfigurationChanged(getConfiguration());
        } catch (Exception e) {
            Slog.e(TAG, "Error sending initial configuration change to WindowContainer overlay");
            removeOverlay(overlay);
            removeTrustedOverlay(overlay);
        }
    }

    void removeOverlay(SurfaceControlViewHost.SurfacePackage overlay) {
    void removeTrustedOverlay(SurfaceControlViewHost.SurfacePackage overlay) {
        if (mOverlayHost != null && !mOverlayHost.removeOverlay(overlay)) {
            mOverlayHost.release();
            mOverlayHost = null;
+9 −2
Original line number Diff line number Diff line
@@ -827,6 +827,11 @@ public abstract class WindowManagerInternal {
     * Internal methods for other parts of SystemServer to manage
     * SurfacePackage based overlays on tasks.
     *
     * Since these overlays will overlay application content, they exist
     * in a container with setTrustedOverlay(true). This means its imperative
     * that this overlay feature only be used with UI completely under the control
     * of the system, without 3rd party content.
     *
     * Callers prepare a view hierarchy with SurfaceControlViewHost
     * and send the package to WM here. The remote view hierarchy will receive
     * configuration change, lifecycle events, etc, forwarded over the
@@ -837,8 +842,10 @@ public abstract class WindowManagerInternal {
     * The embedded hierarchy exists in a coordinate space relative to the task
     * bounds.
     */
    public abstract void addTaskOverlay(int taskId, SurfaceControlViewHost.SurfacePackage overlay);
    public abstract void removeTaskOverlay(int taskId, SurfaceControlViewHost.SurfacePackage overlay);
    public abstract void addTrustedTaskOverlay(int taskId,
            SurfaceControlViewHost.SurfacePackage overlay);
    public abstract void removeTrustedTaskOverlay(int taskId,
            SurfaceControlViewHost.SurfacePackage overlay);

    /**
     * Get a SurfaceControl that is the container layer that should be used to receive input to
+7 −5
Original line number Diff line number Diff line
@@ -7972,24 +7972,26 @@ public class WindowManagerService extends IWindowManager.Stub
       }

        @Override
        public void addTaskOverlay(int taskId, SurfaceControlViewHost.SurfacePackage overlay) {
        public void addTrustedTaskOverlay(int taskId,
                SurfaceControlViewHost.SurfacePackage overlay) {
            synchronized (mGlobalLock) {
                final Task task = mRoot.getRootTask(taskId);
                if (task == null) {
                    throw new IllegalArgumentException("no task with taskId" + taskId);
                }
                task.addOverlay(overlay);
                task.addTrustedOverlay(overlay);
            }
        }

        @Override
        public void removeTaskOverlay(int taskId, SurfaceControlViewHost.SurfacePackage overlay) {
        public void removeTrustedTaskOverlay(int taskId,
                SurfaceControlViewHost.SurfacePackage overlay) {
            synchronized (mGlobalLock) {
                final Task task = mRoot.getRootTask(taskId);
                if (task == null) {
                    throw new IllegalArgumentException("no task with taskId" + taskId);
                }
                task.removeOverlay(overlay);
                task.removeTrustedOverlay(overlay);
            }
        }

Loading