OSDN Git Service

Add ability to post a message at the front of the queue
authorJorim Jaggi <jjaggi@google.com>
Wed, 17 Jan 2018 21:59:33 +0000 (22:59 +0100)
committerJorim Jaggi <jjaggi@google.com>
Wed, 17 Jan 2018 21:59:33 +0000 (22:59 +0100)
Used for remote animations to minimize latency.

Test: Boots
Bug: 64674361
Change-Id: Id07295a852edf4fbc308a4e4616077275f35f0f7

packages/SystemUI/shared/src/com/android/systemui/shared/recents/utilities/Utilities.java

index 7cc1cd6..13f30b2 100644 (file)
@@ -28,6 +28,8 @@ import android.graphics.Color;
 import android.graphics.Rect;
 import android.graphics.RectF;
 import android.graphics.drawable.Drawable;
+import android.os.Handler;
+import android.os.Message;
 import android.os.Trace;
 import android.util.ArraySet;
 import android.util.IntProperty;
@@ -314,4 +316,12 @@ public class Utilities {
         }
         return r.left + "," + r.top + "-" + r.right + "," + r.bottom;
     }
+
+    /**
+     * Posts a runnable on a handler at the front of the queue ignoring any sync barriers.
+     */
+    public static void postAtFrontOfQueueAsynchronously(Handler h, Runnable r) {
+        Message msg = h.obtainMessage().setCallback(r);
+        h.sendMessageAtFrontOfQueue(msg);
+    }
 }