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

Commit 659793bc authored by Chet Haase's avatar Chet Haase Committed by Android (Google) Code Review
Browse files

Merge "Add Developer Option setting for Animator scaling."

parents 306eed22 c38fa1f6
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -17583,6 +17583,7 @@ package android.provider {
    field public static final java.lang.String ALARM_ALERT = "alarm_alert";
    field public static final java.lang.String ALWAYS_FINISH_ACTIVITIES = "always_finish_activities";
    field public static final deprecated java.lang.String ANDROID_ID = "android_id";
    field public static final java.lang.String ANIMATOR_DURATION_SCALE = "animator_duration_scale";
    field public static final java.lang.String APPEND_FOR_LAST_AUDIBLE = "_last_audible";
    field public static final java.lang.String AUTO_TIME = "auto_time";
    field public static final java.lang.String AUTO_TIME_ZONE = "auto_time_zone";
+9 −11
Original line number Diff line number Diff line
@@ -54,7 +54,6 @@ public class ValueAnimator extends Animator {
     * Internal constants
     */
    private static float sDurationScale = 1.0f;
    private static boolean sDurationScaleInitialized = false;

    /**
     * Messages sent to timing handler: START is sent when an animation first begins.
@@ -161,7 +160,7 @@ public class ValueAnimator extends Animator {
    //

    // How long the animation should last in ms
    private long mDuration = 300;
    private long mDuration = (long)(300 * sDurationScale);
    private long mUnscaledDuration = 300;

    // The amount of time in ms to delay starting the animation after start() is called
@@ -222,21 +221,20 @@ public class ValueAnimator extends Animator {
     */
    public static final int INFINITE = -1;


    /**
     * @hide
     */
    public static void setDurationScale(float durationScale) {
        sDurationScale = durationScale;
    }

    /**
     * Creates a new ValueAnimator object. This default constructor is primarily for
     * use internally; the factory methods which take parameters are more generally
     * useful.
     */
    public ValueAnimator() {
        if (!sDurationScaleInitialized) {
            // Scale value initialized per-process when first animator is constructed
            String scaleString = SystemProperties.get("persist.sys.ui.animation");
            if (!scaleString.isEmpty()) {
                sDurationScale = Float.parseFloat(scaleString);
            }
            sDurationScaleInitialized = true;
        }
        mDuration *= sDurationScale;
    }

    /**
+7 −0
Original line number Diff line number Diff line
@@ -1677,6 +1677,13 @@ public final class Settings {
         */
        public static final String TRANSITION_ANIMATION_SCALE = "transition_animation_scale";

        /**
         * Scaling factor for Animator-based animations. This affects both the start delay and
         * duration of all such animations. Setting to 0 will cause animations to end immediately.
         * The default value is 1.
         */
        public static final String ANIMATOR_DURATION_SCALE = "animator_duration_scale";

        /**
         * Scaling factor for normal window animations. Setting to 0 will disable window
         * animations.
+5 −1
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@ package android.view;

import android.Manifest;
import android.animation.LayoutTransition;
import android.animation.ValueAnimator;
import android.app.ActivityManagerNative;
import android.content.ClipDescription;
import android.content.ComponentCallbacks;
@@ -323,8 +324,11 @@ public final class ViewRootImpl extends Handler implements ViewParent,
            if (!mInitialized) {
                try {
                    InputMethodManager imm = InputMethodManager.getInstance(mainLooper);
                    sWindowSession = Display.getWindowManager().openSession(
                    IWindowManager windowManager = Display.getWindowManager();
                    sWindowSession = windowManager.openSession(
                            imm.getClient(), imm.getInputContext());
                    float animatorScale = windowManager.getAnimationScale(2);
                    ValueAnimator.setDurationScale(animatorScale);
                    mInitialized = true;
                } catch (RemoteException e) {
                }
+13 −1
Original line number Diff line number Diff line
@@ -563,6 +563,7 @@ public class WindowManagerService extends IWindowManager.Stub

    float mWindowAnimationScale = 1.0f;
    float mTransitionAnimationScale = 1.0f;
    float mAnimatorDurationScale = 1.0f;

    final InputManager mInputManager;

@@ -779,6 +780,8 @@ public class WindowManagerService extends IWindowManager.Stub
                Settings.System.WINDOW_ANIMATION_SCALE, mWindowAnimationScale);
        mTransitionAnimationScale = Settings.System.getFloat(context.getContentResolver(),
                Settings.System.TRANSITION_ANIMATION_SCALE, mTransitionAnimationScale);
        mAnimatorDurationScale = Settings.System.getFloat(context.getContentResolver(),
                Settings.System.ANIMATOR_DURATION_SCALE, mTransitionAnimationScale);

        // Track changes to DevicePolicyManager state so we can enable/disable keyguard.
        IntentFilter filter = new IntentFilter();
@@ -4662,6 +4665,7 @@ public class WindowManagerService extends IWindowManager.Stub
        switch (which) {
            case 0: mWindowAnimationScale = fixScale(scale); break;
            case 1: mTransitionAnimationScale = fixScale(scale); break;
            case 2: mAnimatorDurationScale = fixScale(scale); break;
        }

        // Persist setting
@@ -4681,6 +4685,9 @@ public class WindowManagerService extends IWindowManager.Stub
            if (scales.length >= 2) {
                mTransitionAnimationScale = fixScale(scales[1]);
            }
            if (scales.length >= 3) {
                mAnimatorDurationScale = fixScale(scales[2]);
            }
        }

        // Persist setting
@@ -4691,12 +4698,14 @@ public class WindowManagerService extends IWindowManager.Stub
        switch (which) {
            case 0: return mWindowAnimationScale;
            case 1: return mTransitionAnimationScale;
            case 2: return mAnimatorDurationScale;
        }
        return 0;
    }

    public float[] getAnimationScales() {
        return new float[] { mWindowAnimationScale, mTransitionAnimationScale };
        return new float[] { mWindowAnimationScale, mTransitionAnimationScale,
                mAnimatorDurationScale };
    }

    public int getSwitchState(int sw) {
@@ -6830,6 +6839,8 @@ public class WindowManagerService extends IWindowManager.Stub
                            Settings.System.WINDOW_ANIMATION_SCALE, mWindowAnimationScale);
                    Settings.System.putFloat(mContext.getContentResolver(),
                            Settings.System.TRANSITION_ANIMATION_SCALE, mTransitionAnimationScale);
                    Settings.System.putFloat(mContext.getContentResolver(),
                            Settings.System.ANIMATOR_DURATION_SCALE, mAnimatorDurationScale);
                    break;
                }

@@ -9773,6 +9784,7 @@ public class WindowManagerService extends IWindowManager.Stub
            pw.print("  mTraversalScheduled="); pw.print(mTraversalScheduled);
                    pw.print(" mWindowAnimationScale="); pw.print(mWindowAnimationScale);
                    pw.print(" mTransitionWindowAnimationScale="); pw.println(mTransitionAnimationScale);
                    pw.print(" mAnimatorDurationScale="); pw.println(mAnimatorDurationScale);
            pw.print("  mNextAppTransition=0x");
                    pw.print(Integer.toHexString(mNextAppTransition));
                    pw.print(" mAppTransitionReady="); pw.println(mAppTransitionReady);