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

Commit 30624dc2 authored by Johannes Gallmann's avatar Johannes Gallmann
Browse files

Update cross-task and cross-activity corner radius on config change

Bug: 331956114
Flag: ACONFIG com.android.window.flags.predictive_back_system_anims TRUNKFOOD
Test: Manual, i.e. verifying that corner radius matches display radius (even after folding/unfolding on Felix)
Change-Id: Id5661b3f681f00e6c19a363184041b02076b9658
parent ef54218e
Loading
Loading
Loading
Loading
+10 −1
Original line number Diff line number Diff line
@@ -32,6 +32,7 @@ import android.app.ActivityTaskManager;
import android.app.IActivityTaskManager;
import android.content.ContentResolver;
import android.content.Context;
import android.content.res.Configuration;
import android.database.ContentObserver;
import android.hardware.input.InputManager;
import android.net.Uri;
@@ -71,6 +72,7 @@ import com.android.wm.shell.common.RemoteCallable;
import com.android.wm.shell.common.ShellExecutor;
import com.android.wm.shell.shared.annotations.ShellBackgroundThread;
import com.android.wm.shell.shared.annotations.ShellMainThread;
import com.android.wm.shell.sysui.ConfigurationChangeListener;
import com.android.wm.shell.sysui.ShellCommandHandler;
import com.android.wm.shell.sysui.ShellController;
import com.android.wm.shell.sysui.ShellInit;
@@ -81,7 +83,8 @@ import java.util.concurrent.atomic.AtomicBoolean;
/**
 * Controls the window animation run when a user initiates a back gesture.
 */
public class BackAnimationController implements RemoteCallable<BackAnimationController> {
public class BackAnimationController implements RemoteCallable<BackAnimationController>,
        ConfigurationChangeListener {
    private static final String TAG = "ShellBackPreview";
    private static final int SETTING_VALUE_OFF = 0;
    private static final int SETTING_VALUE_ON = 1;
@@ -248,6 +251,7 @@ public class BackAnimationController implements RemoteCallable<BackAnimationCont
        mShellController.addExternalInterface(KEY_EXTRA_SHELL_BACK_ANIMATION,
                this::createExternalInterface, this);
        mShellCommandHandler.addDumpCallback(this::dump, this);
        mShellController.addConfigurationChangeListener(this);
    }

    private void setupAnimationDeveloperSettingsObserver(
@@ -296,6 +300,11 @@ public class BackAnimationController implements RemoteCallable<BackAnimationCont

    private final BackAnimationImpl mBackAnimation = new BackAnimationImpl();

    @Override
    public void onConfigurationChanged(Configuration newConfig) {
        mShellBackAnimationRegistry.onConfigurationChanged(newConfig);
    }

    @Override
    public Context getContext() {
        return mContext;
+6 −2
Original line number Diff line number Diff line
@@ -67,7 +67,7 @@ class CrossActivityBackAnimation @Inject constructor(

    private val backAnimRect = Rect()

    private val cornerRadius = ScreenDecorationsUtils.getWindowCornerRadius(context)
    private var cornerRadius = ScreenDecorationsUtils.getWindowCornerRadius(context)

    private val backAnimationRunner = BackAnimationRunner(
        Callback(), Runner(), context, Cuj.CUJ_PREDICTIVE_BACK_CROSS_ACTIVITY
@@ -93,6 +93,10 @@ class CrossActivityBackAnimation @Inject constructor(
    private var scrimLayer: SurfaceControl? = null
    private var maxScrimAlpha: Float = 0f

    override fun onConfigurationChanged(newConfiguration: Configuration) {
        cornerRadius = ScreenDecorationsUtils.getWindowCornerRadius(context)
    }

    override fun getRunner() = backAnimationRunner

    private fun startBackAnimation(backMotionEvent: BackMotionEvent) {
@@ -287,7 +291,7 @@ class CrossActivityBackAnimation @Inject constructor(
            // in case we're still animating an onBackCancelled event, let's remove the finish-
            // callback from the progress animator to prevent calling finishAnimation() before
            // restarting a new animation
            progressAnimator.removeOnBackCancelledFinishCallback();
            progressAnimator.removeOnBackCancelledFinishCallback()

            startBackAnimation(backMotionEvent)
            progressAnimator.onBackStarted(backMotionEvent) { backEvent: BackEvent ->
+7 −1
Original line number Diff line number Diff line
@@ -29,6 +29,7 @@ import android.animation.AnimatorListenerAdapter;
import android.animation.ValueAnimator;
import android.annotation.NonNull;
import android.content.Context;
import android.content.res.Configuration;
import android.graphics.Matrix;
import android.graphics.PointF;
import android.graphics.Rect;
@@ -79,7 +80,7 @@ public class CrossTaskBackAnimation extends ShellBackAnimation {
    private static final int POST_ANIMATION_DURATION_MS = 500;

    private final Rect mStartTaskRect = new Rect();
    private final float mCornerRadius;
    private float mCornerRadius;

    // The closing window properties.
    private final Rect mClosingStartRect = new Rect();
@@ -119,6 +120,11 @@ public class CrossTaskBackAnimation extends ShellBackAnimation {
        mContext = context;
    }

    @Override
    public void onConfigurationChanged(Configuration newConfig) {
        mCornerRadius = ScreenDecorationsUtils.getWindowCornerRadius(mContext);
    }

    private static float mapRange(float value, float min, float max) {
        return min + (value * (max - min));
    }
+9 −1
Original line number Diff line number Diff line
@@ -29,6 +29,7 @@ import android.annotation.NonNull;
import android.annotation.Nullable;
import android.app.Activity;
import android.content.Context;
import android.content.res.Configuration;
import android.graphics.Color;
import android.graphics.Rect;
import android.os.RemoteException;
@@ -63,7 +64,7 @@ import javax.inject.Inject;
public class CustomizeActivityAnimation extends ShellBackAnimation {
    private final BackProgressAnimator mProgressAnimator = new BackProgressAnimator();
    private final BackAnimationRunner mBackAnimationRunner;
    private final float mCornerRadius;
    private float mCornerRadius;
    private final SurfaceControl.Transaction mTransaction;
    private final BackAnimationBackground mBackground;
    private RemoteAnimationTarget mEnteringTarget;
@@ -88,6 +89,7 @@ public class CustomizeActivityAnimation extends ShellBackAnimation {
    final Transformation mTransformation = new Transformation();

    private final Choreographer mChoreographer;
    private final Context mContext;

    @Inject
    public CustomizeActivityAnimation(Context context, BackAnimationBackground background) {
@@ -108,6 +110,12 @@ public class CustomizeActivityAnimation extends ShellBackAnimation {
                .setDampingRatio(SpringForce.DAMPING_RATIO_NO_BOUNCY));
        mTransaction = transaction == null ? new SurfaceControl.Transaction() : transaction;
        mChoreographer = choreographer != null ? choreographer : Choreographer.getInstance();
        mContext = context;
    }

    @Override
    public void onConfigurationChanged(Configuration newConfig) {
        mCornerRadius = ScreenDecorationsUtils.getWindowCornerRadius(mContext);
    }

    private float getLatestProgress() {
+5 −0
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package com.android.wm.shell.back;

import android.content.res.Configuration;
import android.window.BackNavigationInfo;

import javax.inject.Qualifier;
@@ -48,4 +49,8 @@ public abstract class ShellBackAnimation {
    public boolean prepareNextAnimation(BackNavigationInfo.CustomAnimationInfo animationInfo) {
        return false;
    }

    void onConfigurationChanged(Configuration newConfig) {

    }
}
Loading