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

Commit f930a4f7 authored by Lee Shombert's avatar Lee Shombert Committed by Android (Google) Code Review
Browse files

Merge "Handle autocork message on the background thread" into main

parents 1f44ec39 64ef04b4
Loading
Loading
Loading
Loading
+11 −2
Original line number Diff line number Diff line
@@ -29,6 +29,7 @@ import android.text.TextUtils;
import android.util.Log;

import com.android.internal.annotations.GuardedBy;
import com.android.internal.os.BackgroundThread;
import com.android.internal.util.FastPrintWriter;

import java.lang.annotation.Retention;
@@ -1260,7 +1261,7 @@ public class PropertyInvalidatedCache<Query, Result> {
        }

        public void autoCork() {
            if (Looper.getMainLooper() == null) {
            if (getLooper() == null) {
                // We're not ready to auto-cork yet, so just invalidate the cache immediately.
                if (DEBUG) {
                    Log.w(TAG, "invalidating instead of autocorking early in init: "
@@ -1322,7 +1323,7 @@ public class PropertyInvalidatedCache<Query, Result> {
        @GuardedBy("mLock")
        private Handler getHandlerLocked() {
            if (mHandler == null) {
                mHandler = new Handler(Looper.getMainLooper()) {
                mHandler = new Handler(getLooper()) {
                        @Override
                        public void handleMessage(Message msg) {
                            AutoCorker.this.handleMessage(msg);
@@ -1331,6 +1332,14 @@ public class PropertyInvalidatedCache<Query, Result> {
            }
            return mHandler;
        }

        /**
         * Return a looper for auto-uncork messages.  Messages should be processed on the
         * background thread, not on the main thread.
         */
        private static Looper getLooper() {
            return BackgroundThread.getHandler().getLooper();
        }
    }

    /**