diff options
Diffstat (limited to 'core')
-rw-r--r-- | core/java/android/app/ActivityThread.java | 2 | ||||
-rw-r--r-- | core/java/android/os/Message.java | 16 |
2 files changed, 16 insertions, 2 deletions
diff --git a/core/java/android/app/ActivityThread.java b/core/java/android/app/ActivityThread.java index 111689e..3a39900 100644 --- a/core/java/android/app/ActivityThread.java +++ b/core/java/android/app/ActivityThread.java @@ -4287,6 +4287,8 @@ public final class ActivityThread { AsyncTask.setDefaultExecutor(AsyncTask.THREAD_POOL_EXECUTOR); } + Message.updateCheckRecycle(data.appInfo.targetSdkVersion); + /* * Before spawning a new process, reset the time zone to be the system time zone. * This needs to be done because the system time zone could have changed after the diff --git a/core/java/android/os/Message.java b/core/java/android/os/Message.java index 1a5811c..b6b70cc 100644 --- a/core/java/android/os/Message.java +++ b/core/java/android/os/Message.java @@ -113,6 +113,8 @@ public final class Message implements Parcelable { private static final int MAX_POOL_SIZE = 50; + private static boolean gCheckRecycle = true; + /** * Return a new Message instance from the global pool. Allows us to * avoid allocating new objects in many cases. @@ -256,6 +258,13 @@ public final class Message implements Parcelable { return m; } + /** @hide */ + public static void updateCheckRecycle(int targetSdkVersion) { + if (targetSdkVersion < Build.VERSION_CODES.L) { + gCheckRecycle = false; + } + } + /** * Return a Message instance to the global pool. * <p> @@ -266,8 +275,11 @@ public final class Message implements Parcelable { */ public void recycle() { if (isInUse()) { - throw new IllegalStateException("This message cannot be recycled because it " - + "is still in use."); + if (gCheckRecycle) { + throw new IllegalStateException("This message cannot be recycled because it " + + "is still in use."); + } + return; } recycleUnchecked(); } |