diff options
author | Dianne Hackborn <hackbod@google.com> | 2014-09-07 19:04:04 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2014-09-07 19:04:05 +0000 |
commit | b30c9920df9a8b5f1515e26c65c5ce1d21e5a77a (patch) | |
tree | e7fefa6a44982fda3156c66c30c0d40914eb908d /core | |
parent | 66d557875dcb5955314dfadd0ee926ba90825982 (diff) | |
parent | 7895bc2e6309427937ab060031bfee5c99879d59 (diff) | |
download | frameworks_base-b30c9920df9a8b5f1515e26c65c5ce1d21e5a77a.zip frameworks_base-b30c9920df9a8b5f1515e26c65c5ce1d21e5a77a.tar.gz frameworks_base-b30c9920df9a8b5f1515e26c65c5ce1d21e5a77a.tar.bz2 |
Merge "Fix issue #17391969: Only exception on Message.recycle() when target-sdk > 20" into lmp-dev
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(); } |