Do not create UHID thread if not used

The HandlerThread is used only via the looper queue.
This commit is contained in:
Romain Vimont 2024-08-08 20:29:13 +02:00
parent dd47cefa47
commit 523f939532

View file

@ -33,13 +33,13 @@ public final class UhidManager {
private final ByteBuffer buffer = ByteBuffer.allocate(SIZE_OF_UHID_EVENT).order(ByteOrder.nativeOrder());
private final DeviceMessageSender sender;
private final HandlerThread thread = new HandlerThread("UHidManager");
private final MessageQueue queue;
public UhidManager(DeviceMessageSender sender) {
this.sender = sender;
thread.start();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
HandlerThread thread = new HandlerThread("UHidManager");
thread.start();
queue = thread.getLooper().getQueue();
} else {
queue = null;