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

Commit 04e2a47a authored by Adam Lesinski's avatar Adam Lesinski Committed by Android Git Automerger
Browse files

am 461f06f4: am 53a5e317: Merge "Wrap measurement optimization in targetSdk check" into klp-dev

* commit '461f06f4':
  Wrap measurement optimization in targetSdk check
parents 10f64650 461f06f4
Loading
Loading
Loading
Loading
+26 −4
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@ package android.view;
import android.content.ClipData;
import android.content.Context;
import android.content.pm.ApplicationInfo;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.content.res.TypedArray;
@@ -691,8 +692,22 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
     */
    public static final int NO_ID = -1;
    /**
     * Signals that compatibility booleans have been initialized according to
     * target SDK versions.
     */
    private static boolean sCompatibilityDone = false;
    /**
     * Use the old (broken) way of building MeasureSpecs.
     */
    private static boolean sUseBrokenMakeMeasureSpec = false;
    /**
     * Ignore any optimizations using the measure cache.
     */
    private static boolean sIgnoreMeasureCache = false;
    /**
     * This view does not want keystrokes. Use with TAKES_FOCUS_MASK when
     * calling setFlags.
@@ -3426,10 +3441,17 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
        mUserPaddingStart = UNDEFINED_PADDING;
        mUserPaddingEnd = UNDEFINED_PADDING;
        if (!sUseBrokenMakeMeasureSpec && context != null &&
                context.getApplicationInfo().targetSdkVersion <= JELLY_BEAN_MR1) {
        if (!sCompatibilityDone && context != null) {
            final int targetSdkVersion = context.getApplicationInfo().targetSdkVersion;
            // Older apps may need this compatibility hack for measurement.
            sUseBrokenMakeMeasureSpec = true;
            sUseBrokenMakeMeasureSpec = targetSdkVersion <= JELLY_BEAN_MR1;
            // Older apps expect onMeasure() to always be called on a layout pass, regardless
            // of whether a layout was requested on that View.
            sIgnoreMeasureCache = targetSdkVersion < KITKAT;
            sCompatibilityDone = true;
        }
    }
@@ -16431,7 +16453,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
            int cacheIndex = (mPrivateFlags & PFLAG_FORCE_LAYOUT) == PFLAG_FORCE_LAYOUT ? -1 :
                    mMeasureCache.indexOfKey(key);
            if (cacheIndex < 0) {
            if (cacheIndex < 0 || sIgnoreMeasureCache) {
                // measure ourselves, this should set the measured dimension flag back
                onMeasure(widthMeasureSpec, heightMeasureSpec);
                mPrivateFlags3 &= ~PFLAG3_MEASURE_NEEDED_BEFORE_LAYOUT;