From ae7a51f14349ac070926b406a5b0ab0738231383 Mon Sep 17 00:00:00 2001 From: Svetoslav Ganov Date: Fri, 24 Feb 2012 10:47:24 -0800 Subject: [PATCH] UiTestAutomationBridge does not terminate its HandlerThread. 1. Now the thread is terminated in the disconnect() method and also it is made demon since it has no pupose outside the context of the bridge client. bug:6053108 Change-Id: Idc25373fddf501eda4f875fea3e944367e4f04bf --- .../accessibilityservice/UiTestAutomationBridge.java | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/core/java/android/accessibilityservice/UiTestAutomationBridge.java b/core/java/android/accessibilityservice/UiTestAutomationBridge.java index 9b3da53a67013..a898c3f6ae558 100644 --- a/core/java/android/accessibilityservice/UiTestAutomationBridge.java +++ b/core/java/android/accessibilityservice/UiTestAutomationBridge.java @@ -74,6 +74,8 @@ public class UiTestAutomationBridge { private volatile boolean mUnprocessedEventAvailable; + private HandlerThread mHandlerThread; + /** * Gets the last received {@link AccessibilityEvent}. * @@ -126,9 +128,10 @@ public class UiTestAutomationBridge { // is needed for making sure the binder calls are interleaved // with check for the expected event and also to make sure the // binder threads are allowed to proceed in the received order. - HandlerThread handlerThread = new HandlerThread("UiTestAutomationBridge"); - handlerThread.start(); - Looper looper = handlerThread.getLooper(); + mHandlerThread = new HandlerThread("UiTestAutomationBridge"); + mHandlerThread.setDaemon(true); + mHandlerThread.start(); + Looper looper = mHandlerThread.getLooper(); mListener = new IEventListenerWrapper(null, looper, new Callbacks() { @Override @@ -217,6 +220,8 @@ public class UiTestAutomationBridge { throw new IllegalStateException("Already disconnected."); } + mHandlerThread.quit(); + IAccessibilityManager manager = IAccessibilityManager.Stub.asInterface( ServiceManager.getService(Context.ACCESSIBILITY_SERVICE));