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

Commit c26db36f authored by Pablo Gamito's avatar Pablo Gamito
Browse files

Stop relying on background color attribute to set task transition background

Because the background attribute used to have a different use some apps still set it and it means we could run transitions with unexpected background colors

Test: Existing

Bug: 200763116
Change-Id: Id42f52760cb9a681c6c33f3c261d7db5e2f71af3
parent f3be4346
Loading
Loading
Loading
Loading
+0 −10
Original line number Original line Diff line number Diff line
@@ -19,7 +19,6 @@ package android.view.animation;
import android.annotation.AnimRes;
import android.annotation.AnimRes;
import android.annotation.ColorInt;
import android.annotation.ColorInt;
import android.annotation.InterpolatorRes;
import android.annotation.InterpolatorRes;
import android.app.ActivityThread;
import android.compat.annotation.UnsupportedAppUsage;
import android.compat.annotation.UnsupportedAppUsage;
import android.content.Context;
import android.content.Context;
import android.content.res.TypedArray;
import android.content.res.TypedArray;
@@ -270,15 +269,6 @@ public abstract class Animation implements Cloneable {


        a.recycle();
        a.recycle();


        Context uiContext = ActivityThread.currentActivityThread().getSystemUiContext();
        TypedArray uiStyledAttrs = uiContext
                .obtainStyledAttributes(attrs, com.android.internal.R.styleable.Animation);

        setBackgroundColor(
                uiStyledAttrs.getColor(com.android.internal.R.styleable.Animation_background, 0));

        uiStyledAttrs.recycle();

        if (resID > 0) {
        if (resID > 0) {
            setInterpolator(context, resID);
            setInterpolator(context, resID);
        }
        }
+24 −10
Original line number Original line Diff line number Diff line
@@ -32,6 +32,10 @@ import static android.os.UserHandle.USER_NULL;
import static android.view.SurfaceControl.Transaction;
import static android.view.SurfaceControl.Transaction;
import static android.view.WindowManager.LayoutParams.INVALID_WINDOW_TYPE;
import static android.view.WindowManager.LayoutParams.INVALID_WINDOW_TYPE;
import static android.view.WindowManager.TRANSIT_CHANGE;
import static android.view.WindowManager.TRANSIT_CHANGE;
import static android.view.WindowManager.TRANSIT_OLD_TASK_CLOSE;
import static android.view.WindowManager.TRANSIT_OLD_TASK_OPEN;
import static android.view.WindowManager.TRANSIT_OLD_TASK_TO_BACK;
import static android.view.WindowManager.TRANSIT_OLD_TASK_TO_FRONT;


import static com.android.internal.protolog.ProtoLogGroup.WM_DEBUG_APP_TRANSITIONS;
import static com.android.internal.protolog.ProtoLogGroup.WM_DEBUG_APP_TRANSITIONS;
import static com.android.internal.protolog.ProtoLogGroup.WM_DEBUG_APP_TRANSITIONS_ANIM;
import static com.android.internal.protolog.ProtoLogGroup.WM_DEBUG_APP_TRANSITIONS_ANIM;
@@ -61,10 +65,13 @@ import static com.android.server.wm.WindowManagerService.logWithStack;
import static com.android.server.wm.WindowStateAnimator.ROOT_TASK_CLIP_AFTER_ANIM;
import static com.android.server.wm.WindowStateAnimator.ROOT_TASK_CLIP_AFTER_ANIM;


import android.annotation.CallSuper;
import android.annotation.CallSuper;
import android.annotation.ColorInt;
import android.annotation.IntDef;
import android.annotation.IntDef;
import android.annotation.NonNull;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.Nullable;
import android.app.ActivityThread;
import android.app.WindowConfiguration;
import android.app.WindowConfiguration;
import android.content.Context;
import android.content.pm.ActivityInfo;
import android.content.pm.ActivityInfo;
import android.content.res.Configuration;
import android.content.res.Configuration;
import android.graphics.Point;
import android.graphics.Point;
@@ -90,6 +97,7 @@ import android.view.animation.Animation;
import android.window.IWindowContainerToken;
import android.window.IWindowContainerToken;
import android.window.WindowContainerToken;
import android.window.WindowContainerToken;


import com.android.internal.R;
import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.protolog.common.ProtoLog;
import com.android.internal.protolog.common.ProtoLog;
import com.android.internal.util.ToBooleanFunction;
import com.android.internal.util.ToBooleanFunction;
@@ -2814,24 +2822,23 @@ class WindowContainer<E extends WindowContainer> extends ConfigurationContainer<
            }
            }


            TaskDisplayArea taskDisplayArea = getTaskDisplayArea();
            TaskDisplayArea taskDisplayArea = getTaskDisplayArea();
            int backgroundColor = adapter.getBackgroundColor();
            boolean isSettingBackgroundColor = taskDisplayArea != null
                    && isTransitionWithBackgroundColor(transit);


            boolean shouldSetBackgroundColor = taskDisplayArea != null && backgroundColor != 0;
            if (isSettingBackgroundColor) {
                Context uiContext = ActivityThread.currentActivityThread().getSystemUiContext();
                @ColorInt int backgroundColor = uiContext.getColor(R.color.overview_background);


            if (shouldSetBackgroundColor) {
                taskDisplayArea.setBackgroundColor(backgroundColor);
                taskDisplayArea.setBackgroundColor(backgroundColor);
            }
            }


            Runnable clearColorBackground = () -> {
            final Runnable cleanUpCallback = isSettingBackgroundColor
                if (shouldSetBackgroundColor) {
                    ? taskDisplayArea::clearBackgroundColor : () -> {};
                    taskDisplayArea.clearBackgroundColor();
                }
            };


            startAnimation(getPendingTransaction(), adapter, !isVisible(),
            startAnimation(getPendingTransaction(), adapter, !isVisible(),
                    ANIMATION_TYPE_APP_TRANSITION,
                    ANIMATION_TYPE_APP_TRANSITION,
                    (type, anim) -> clearColorBackground.run(),
                    (type, anim) -> cleanUpCallback.run(),
                    clearColorBackground);
                    cleanUpCallback);


            if (adapter.getShowWallpaper()) {
            if (adapter.getShowWallpaper()) {
                getDisplayContent().pendingLayoutChanges |= FINISH_LAYOUT_REDO_WALLPAPER;
                getDisplayContent().pendingLayoutChanges |= FINISH_LAYOUT_REDO_WALLPAPER;
@@ -2843,6 +2850,13 @@ class WindowContainer<E extends WindowContainer> extends ConfigurationContainer<
        }
        }
    }
    }


    private boolean isTransitionWithBackgroundColor(@TransitionOldType int transit) {
        return transit == TRANSIT_OLD_TASK_OPEN
                || transit == TRANSIT_OLD_TASK_CLOSE
                || transit == TRANSIT_OLD_TASK_TO_FRONT
                || transit == TRANSIT_OLD_TASK_TO_BACK;
    }

    final SurfaceAnimationRunner getSurfaceAnimationRunner() {
    final SurfaceAnimationRunner getSurfaceAnimationRunner() {
        return mWmService.mSurfaceAnimationRunner;
        return mWmService.mSurfaceAnimationRunner;
    }
    }