diff options
| author | 2022-08-17 17:40:30 +0200 | |
|---|---|---|
| committer | 2022-08-22 13:00:03 +0200 | |
| commit | ab0cbeffdff9ad25151646cbe9ffef6f27efd7c6 (patch) | |
| tree | b4237901608ea5268daf0c30824694b51eccf3e8 | |
| parent | fbaaa44ccf9dee345fd916bf035cf44cafdc5ea9 (diff) | |
DCL is broken and should not be used.
Use the acceptable instance holder pattern as a replacement.
Change-Id: I0164b8c17db4e6e15aee5a862fa8e625a9b1bbf4
| -rw-r--r-- | config/preloaded-classes-denylist | 1 | ||||
| -rw-r--r-- | core/java/com/android/internal/jank/InteractionJankMonitor.java | 15 |
2 files changed, 6 insertions, 10 deletions
diff --git a/config/preloaded-classes-denylist b/config/preloaded-classes-denylist index 02f2df6167a5..502d8c6dadb1 100644 --- a/config/preloaded-classes-denylist +++ b/config/preloaded-classes-denylist @@ -9,3 +9,4 @@ android.net.rtp.AudioGroup android.net.rtp.AudioStream android.net.rtp.RtpStream java.util.concurrent.ThreadLocalRandom +com.android.internal.jank.InteractionJankMonitor$InstanceHolder diff --git a/core/java/com/android/internal/jank/InteractionJankMonitor.java b/core/java/com/android/internal/jank/InteractionJankMonitor.java index 72de78c148f8..d066945cb92d 100644 --- a/core/java/com/android/internal/jank/InteractionJankMonitor.java +++ b/core/java/com/android/internal/jank/InteractionJankMonitor.java @@ -292,7 +292,10 @@ public class InteractionJankMonitor { UIINTERACTION_FRAME_INFO_REPORTED__INTERACTION_TYPE__SHADE_CLEAR_ALL, }; - private static volatile InteractionJankMonitor sInstance; + private static class InstanceHolder { + public static final InteractionJankMonitor INSTANCE = + new InteractionJankMonitor(new HandlerThread(DEFAULT_WORKER_NAME)); + } private final DeviceConfig.OnPropertiesChangedListener mPropertiesChangedListener = this::updateProperties; @@ -384,15 +387,7 @@ public class InteractionJankMonitor { * @return instance of InteractionJankMonitor */ public static InteractionJankMonitor getInstance() { - // Use DCL here since this method might be invoked very often. - if (sInstance == null) { - synchronized (InteractionJankMonitor.class) { - if (sInstance == null) { - sInstance = new InteractionJankMonitor(new HandlerThread(DEFAULT_WORKER_NAME)); - } - } - } - return sInstance; + return InstanceHolder.INSTANCE; } /** |