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

Commit 7dde6d40 authored by Massimo Carli's avatar Massimo Carli
Browse files

Demote exception to log message

For some race condition it might happen that the parent surface
is not present when creating a CompatUI components.
This might happens when the parent surface is removed and some
steps in the compat ui component lifecycle tries to add the component
again.

In that case it's ok to ignore the operation and just avoid to add the
child Surface.

Flag: EXEMPT Refactoring
Fix: 408185221
Test: atest WMShellUnitTests:CompatUIWindowManagerTest

Change-Id: Id0c388d8488fa4b44a67181f65d0a8d9a3d60d95
parent d103719c
Loading
Loading
Loading
Loading
+14 −5
Original line number Diff line number Diff line
@@ -143,20 +143,29 @@ public class FullscreenTaskListener implements ShellTaskOrganizer.TaskListener {

    @Override
    public void attachChildSurfaceToTask(int taskId, SurfaceControl.Builder b) {
        b.setParent(findTaskSurface(taskId));
        final SurfaceControl taskSurface = findTaskSurface(taskId);
        if (taskSurface != null) {
            b.setParent(taskSurface);
        }
    }

    @Override
    public void reparentChildSurfaceToTask(int taskId, SurfaceControl sc,
            SurfaceControl.Transaction t) {
        t.reparent(sc, findTaskSurface(taskId));
        final SurfaceControl taskSurface = findTaskSurface(taskId);
        if (taskSurface != null) {
            t.reparent(sc, taskSurface);
        }
    }

    private SurfaceControl findTaskSurface(int taskId) {
        if (!mTasks.contains(taskId)) {
            throw new IllegalArgumentException("There is no surface for taskId=" + taskId);
        final State state = mTasks.get(taskId);
        if (state != null) {
            return state.mLeash;
        }
        return mTasks.get(taskId).mLeash;
        ProtoLog.w(ShellProtoLogGroup.WM_SHELL_TASK_ORG, "Surface not found: #%d",
                taskId);
        return null;
    }

    @Override