diff options
| author | Winson Chung <winsonc@google.com> | 2019-12-12 21:27:08 +0000 |
|---|---|---|
| committer | Android (Google) Code Review <android-gerrit@google.com> | 2019-12-12 21:27:08 +0000 |
| commit | d6e73ec8f151c084bd375b16ec8f7b6154a7b60b (patch) | |
| tree | 589dd528be4f73f2d9cdeb303e166ae65547be16 /core/java | |
| parent | f275d96b99c533469844198f6fce3f2a728fd39b (diff) | |
| parent | 00cfbeb7e5d6a90953e206070f6a2862b88a89b6 (diff) | |
Merge "Fix nav bar leak in SystemUI" into qt-qpr1-dev
Diffstat (limited to 'core/java')
| -rw-r--r-- | core/java/android/view/CompositionSamplingListener.java | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/core/java/android/view/CompositionSamplingListener.java b/core/java/android/view/CompositionSamplingListener.java index e4309a6d9aa4..f23bb40278ac 100644 --- a/core/java/android/view/CompositionSamplingListener.java +++ b/core/java/android/view/CompositionSamplingListener.java @@ -29,7 +29,7 @@ import java.util.concurrent.Executor; */ public abstract class CompositionSamplingListener { - private final long mNativeListener; + private long mNativeListener; private final Executor mExecutor; public CompositionSamplingListener(Executor executor) { @@ -37,13 +37,19 @@ public abstract class CompositionSamplingListener { mNativeListener = nativeCreate(this); } + public void destroy() { + if (mNativeListener == 0) { + return; + } + unregister(this); + nativeDestroy(mNativeListener); + mNativeListener = 0; + } + @Override protected void finalize() throws Throwable { try { - if (mNativeListener != 0) { - unregister(this); - nativeDestroy(mNativeListener); - } + destroy(); } finally { super.finalize(); } @@ -59,6 +65,9 @@ public abstract class CompositionSamplingListener { */ public static void register(CompositionSamplingListener listener, int displayId, IBinder stopLayer, Rect samplingArea) { + if (listener.mNativeListener == 0) { + return; + } Preconditions.checkArgument(displayId == Display.DEFAULT_DISPLAY, "default display only for now"); nativeRegister(listener.mNativeListener, stopLayer, samplingArea.left, samplingArea.top, @@ -69,6 +78,9 @@ public abstract class CompositionSamplingListener { * Unregisters a sampling listener. */ public static void unregister(CompositionSamplingListener listener) { + if (listener.mNativeListener == 0) { + return; + } nativeUnregister(listener.mNativeListener); } |
