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

Commit f9c7953c authored by Android Build Coastguard Worker's avatar Android Build Coastguard Worker
Browse files

Snap for 9401607 from d94b755f to tm-qpr2-release

Change-Id: Iba45fa1e1051b6e4b403420c595e65f9a831d784
parents cf76646f d94b755f
Loading
Loading
Loading
Loading
+35 −40
Original line number Diff line number Diff line
@@ -19,10 +19,10 @@ package android.animation;
import android.os.SystemClock;
import android.os.SystemProperties;
import android.util.ArrayMap;
import android.util.ArraySet;
import android.util.Log;
import android.view.Choreographer;

import java.lang.ref.WeakReference;
import java.util.ArrayList;

/**
@@ -40,7 +40,7 @@ import java.util.ArrayList;
public class AnimationHandler {

    private static final String TAG = "AnimationHandler";
    private static final boolean LOCAL_LOGV = false;
    private static final boolean LOCAL_LOGV = true;

    /**
     * Internal per-thread collections used to avoid set collisions as animations start and end
@@ -78,7 +78,7 @@ public class AnimationHandler {
     * store visible (foreground) requestors; if the set size reaches zero, there are no
     * objects in the foreground and it is time to pause animators.
     */
    private final ArrayList<WeakReference<Object>> mAnimatorRequestors = new ArrayList<>();
    private final ArraySet<Object> mAnimatorRequestors = new ArraySet<>();

    private final Choreographer.FrameCallback mFrameCallback = new Choreographer.FrameCallback() {
        @Override
@@ -141,9 +141,24 @@ public class AnimationHandler {
     * tracking obsolete+enabled requestors.
     */
    public static void removeRequestor(Object requestor) {
        getInstance().requestAnimatorsEnabledImpl(false, requestor);
        getInstance().removeRequestorImpl(requestor);
    }

    private void removeRequestorImpl(Object requestor) {
        // Also request disablement, in case that requestor was the sole object keeping
        // animators un-paused
        long startTime = System.nanoTime();
        requestAnimatorsEnabled(false, requestor);
        Log.d(TAG, "removeRequestorImpl called requestAnimatorsEnabled after " + 
              (System.nanoTime() - startTime));
        mAnimatorRequestors.remove(requestor);
        Log.d(TAG, "removeRequestorImpl removed requestor after " + 
              (System.nanoTime() - startTime));
        if (LOCAL_LOGV) {
            Log.v(TAG, "removeRequestor for " + requestor);
            Log.v(TAG, "removeRequestorImpl for " + requestor);
            for (int i = 0; i < mAnimatorRequestors.size(); ++i) {
                Log.v(TAG, "animatorRequesters " + i + " = " + mAnimatorRequestors.valueAt(i));
            }
        }
    }

@@ -161,44 +176,25 @@ public class AnimationHandler {
    }

    private void requestAnimatorsEnabledImpl(boolean enable, Object requestor) {
        long startTime = System.nanoTime();
        boolean wasEmpty = mAnimatorRequestors.isEmpty();
        setAnimatorPausingEnabled(isPauseBgAnimationsEnabledInSystemProperties());
        synchronized (mAnimatorRequestors) {
            // Only store WeakRef objects to avoid leaks
        Log.d(TAG, "requestAnimatorsEnabledImpl called setAnimatorPausingEnabled after " + 
              (System.nanoTime() - startTime));
        if (enable) {
                // First, check whether such a reference is already on the list
                WeakReference<Object> weakRef = null;
                for (int i = mAnimatorRequestors.size() - 1; i >= 0; --i) {
                    WeakReference<Object> ref = mAnimatorRequestors.get(i);
                    Object referent = ref.get();
                    if (referent == requestor) {
                        weakRef = ref;
                    } else if (referent == null) {
                        // Remove any reference that has been cleared
                        mAnimatorRequestors.remove(i);
                    }
                }
                if (weakRef == null) {
                    weakRef = new WeakReference<>(requestor);
                    mAnimatorRequestors.add(weakRef);
                }
            mAnimatorRequestors.add(requestor);
        } else {
                for (int i = mAnimatorRequestors.size() - 1; i >= 0; --i) {
                    WeakReference<Object> ref = mAnimatorRequestors.get(i);
                    Object referent = ref.get();
                    if (referent == requestor || referent == null) {
                        // remove requested item or item that has been cleared
                        mAnimatorRequestors.remove(i);
                    }
                }
                // If a reference to the requestor wasn't in the list, nothing to remove
            }
            mAnimatorRequestors.remove(requestor);
        }
        Log.d(TAG, "requestAnimatorsEnabledImpl added/removed after " + 
              (System.nanoTime() - startTime));
        if (!sAnimatorPausingEnabled) {
            // Resume any animators that have been paused in the meantime, otherwise noop
            // Leave logic above so that if pausing gets re-enabled, the state of the requestors
            // list is valid
            resumeAnimators();
            Log.d(TAG, "requestAnimatorsEnabledImpl resumed, returning after " + 
                  (System.nanoTime() - startTime));
            return;
        }
        boolean isEmpty = mAnimatorRequestors.isEmpty();
@@ -213,13 +209,12 @@ public class AnimationHandler {
                        Animator.getBackgroundPauseDelay());
            }
        }
        Log.d(TAG, "requestAnimatorsEnabledImpl post was/is check after " + 
              (System.nanoTime() - startTime));
        if (LOCAL_LOGV) {
            Log.v(TAG, (enable ? "enable" : "disable") + " animators for " + requestor
                    + " with pauseDelay of " + Animator.getBackgroundPauseDelay());
            Log.v(TAG, enable ? "enable" : "disable" + " animators for " + requestor);
            for (int i = 0; i < mAnimatorRequestors.size(); ++i) {
                Log.v(TAG, "animatorRequestors " + i + " = "
                        + mAnimatorRequestors.get(i) + " with referent "
                        + mAnimatorRequestors.get(i).get());
                Log.v(TAG, "animatorRequesters " + i + " = " + mAnimatorRequestors.valueAt(i));
            }
        }
    }
+2 −2
Original line number Diff line number Diff line
@@ -25,7 +25,7 @@ import android.annotation.SystemService;
import android.annotation.TestApi;
import android.app.compat.CompatChanges;
import android.compat.annotation.ChangeId;
import android.compat.annotation.Disabled;
import android.compat.annotation.EnabledSince;
import android.compat.annotation.Overridable;
import android.content.Context;
import android.content.pm.PackageManager;
@@ -114,7 +114,7 @@ public final class CameraManager {
     */
    @ChangeId
    @Overridable
    @Disabled
    @EnabledSince(targetSdkVersion = android.os.Build.VERSION_CODES.TIRAMISU)
    @TestApi
    public static final long OVERRIDE_FRONT_CAMERA_APP_COMPAT = 250678880L;

+2 −11
Original line number Diff line number Diff line
@@ -1417,11 +1417,7 @@ public final class ViewRootImpl implements ViewParent,
                mFirstPostImeInputStage = earlyPostImeStage;
                mPendingInputEventQueueLengthCounterName = "aq:pending:" + counterSuffix;

                if (!mRemoved || !mAppVisible) {
                AnimationHandler.requestAnimatorsEnabled(mAppVisible, this);
                } else if (LOCAL_LOGV) {
                    Log.v(mTag, "setView() enabling visibility when removed");
                }
            }
        }
    }
@@ -1759,12 +1755,7 @@ public final class ViewRootImpl implements ViewParent,
            if (!mAppVisible) {
                WindowManagerGlobal.trimForeground();
            }
            // Only enable if the window is not already removed (via earlier call to doDie())
            if (!mRemoved || !mAppVisible) {
            AnimationHandler.requestAnimatorsEnabled(mAppVisible, this);
            } else if (LOCAL_LOGV) {
                Log.v(mTag, "handleAppVisibility() enabling visibility when removed");
            }
        }
    }

+2 −2
Original line number Diff line number Diff line
@@ -1167,8 +1167,8 @@
    <string name="no" msgid="5122037903299899715">"Cancel·la"</string>
    <string name="dialog_alert_title" msgid="651856561974090712">"Atenció"</string>
    <string name="loading" msgid="3138021523725055037">"S\'està carregant…"</string>
    <string name="capital_on" msgid="2770685323900821829">""</string>
    <string name="capital_off" msgid="7443704171014626777">"NO"</string>
    <string name="capital_on" msgid="2770685323900821829">"ACTIVAT"</string>
    <string name="capital_off" msgid="7443704171014626777">"DESACTIVAT"</string>
    <string name="checked" msgid="9179896827054513119">"seleccionat"</string>
    <string name="not_checked" msgid="7972320087569023342">"no seleccionat"</string>
    <string name="selected" msgid="6614607926197755875">"seleccionat"</string>
+2 −2
Original line number Diff line number Diff line
@@ -1167,8 +1167,8 @@
    <string name="no" msgid="5122037903299899715">"Cancelar"</string>
    <string name="dialog_alert_title" msgid="651856561974090712">"Atención"</string>
    <string name="loading" msgid="3138021523725055037">"Cargando…"</string>
    <string name="capital_on" msgid="2770685323900821829">""</string>
    <string name="capital_off" msgid="7443704171014626777">"No"</string>
    <string name="capital_on" msgid="2770685323900821829">"ACTIVADO"</string>
    <string name="capital_off" msgid="7443704171014626777">"Desactivado"</string>
    <string name="checked" msgid="9179896827054513119">"activado"</string>
    <string name="not_checked" msgid="7972320087569023342">"desactivado"</string>
    <string name="selected" msgid="6614607926197755875">"seleccionado"</string>
Loading