Skip to content

Commit 525ece4

Browse files
sganovAndroid (Google) Code Review
authored andcommitted
Merge "UiTestAutomationBridge does not terminate its HandlerThread."
2 parents 126d0ce + ae7a51f commit 525ece4

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

core/java/android/accessibilityservice/UiTestAutomationBridge.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,8 @@ public class UiTestAutomationBridge {
7474

7575
private volatile boolean mUnprocessedEventAvailable;
7676

77+
private HandlerThread mHandlerThread;
78+
7779
/**
7880
* Gets the last received {@link AccessibilityEvent}.
7981
*
@@ -126,9 +128,10 @@ public void connect() {
126128
// is needed for making sure the binder calls are interleaved
127129
// with check for the expected event and also to make sure the
128130
// binder threads are allowed to proceed in the received order.
129-
HandlerThread handlerThread = new HandlerThread("UiTestAutomationBridge");
130-
handlerThread.start();
131-
Looper looper = handlerThread.getLooper();
131+
mHandlerThread = new HandlerThread("UiTestAutomationBridge");
132+
mHandlerThread.setDaemon(true);
133+
mHandlerThread.start();
134+
Looper looper = mHandlerThread.getLooper();
132135

133136
mListener = new IEventListenerWrapper(null, looper, new Callbacks() {
134137
@Override
@@ -217,6 +220,8 @@ public void disconnect() {
217220
throw new IllegalStateException("Already disconnected.");
218221
}
219222

223+
mHandlerThread.quit();
224+
220225
IAccessibilityManager manager = IAccessibilityManager.Stub.asInterface(
221226
ServiceManager.getService(Context.ACCESSIBILITY_SERVICE));
222227

0 commit comments

Comments
 (0)