Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7895bc2e authored by Dianne Hackborn's avatar Dianne Hackborn
Browse files

Fix issue #17391969: Only exception on Message.recycle() when target-sdk > 20

Change-Id: Iaf271c96901c5dba15831681269a49ad4aaa57fd
parent 71cc3b8e
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -4283,6 +4283,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
+14 −2
Original line number Diff line number Diff line
@@ -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,9 +275,12 @@ public final class Message implements Parcelable {
     */
    public void recycle() {
        if (isInUse()) {
            if (gCheckRecycle) {
                throw new IllegalStateException("This message cannot be recycled because it "
                        + "is still in use.");
            }
            return;
        }
        recycleUnchecked();
    }