From 56c560a9dd0197d85c7ba95d5c8bb8e8fd3c3fee Mon Sep 17 00:00:00 2001 From: Andreas Gampe Date: Wed, 6 Apr 2016 13:03:02 -0700 Subject: [PATCH] Frameworks/base: Move Animation.USE_CLOSEGUARD to inner class Move flag to inner class to isolate Animation. This allows compile- time initialization of Animation and subclasses. Bug: 27265238 Change-Id: I3d95ab77e87de0c033f97545609461bdc9bd5d61 --- core/java/android/view/animation/Animation.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/core/java/android/view/animation/Animation.java b/core/java/android/view/animation/Animation.java index 1536c29bee5b5..d89c172be8a77 100644 --- a/core/java/android/view/animation/Animation.java +++ b/core/java/android/view/animation/Animation.java @@ -93,8 +93,12 @@ public abstract class Animation implements Cloneable { */ public static final int ZORDER_BOTTOM = -1; - private static final boolean USE_CLOSEGUARD - = SystemProperties.getBoolean("log.closeguard.Animation", false); + // Use a preload holder to isolate static initialization into inner class, which allows + // Animation and its subclasses to be compile-time initialized. + private static class NoImagePreloadHolder { + public static final boolean USE_CLOSEGUARD + = SystemProperties.getBoolean("log.closeguard.Animation", false); + } /** * Set by {@link #getTransformation(long, Transformation)} when the animation ends. @@ -859,7 +863,7 @@ public abstract class Animation implements Cloneable { if (!mStarted) { fireAnimationStart(); mStarted = true; - if (USE_CLOSEGUARD) { + if (NoImagePreloadHolder.USE_CLOSEGUARD) { guard.open("cancel or detach or getTransformation"); } }