mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge.git
synced 2026-07-31 07:44:24 +02:00
log: improve start/finish logging of essential device support threads
This commit is contained in:
committed by
José Rebelo
parent
0647824227
commit
741aad0674
@@ -68,6 +68,7 @@ public final class BtBRQueue {
|
||||
return new Thread("BtBRQueue_read_" + THREAD_COUNTER.getAndIncrement()) {
|
||||
@Override
|
||||
public void run() {
|
||||
LOG.debug("started thread {}", getName());
|
||||
final byte[] buffer = new byte[mBufferSize];
|
||||
int nRead;
|
||||
|
||||
@@ -107,6 +108,8 @@ public final class BtBRQueue {
|
||||
LOG.debug("Exited read thread loop, will wait for reconnect");
|
||||
mGbDevice.setUpdateState(GBDevice.State.WAITING_FOR_RECONNECT, mContext);
|
||||
}
|
||||
|
||||
LOG.debug("finished thread {}", getName());
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -122,6 +125,9 @@ public final class BtBRQueue {
|
||||
|
||||
mWriteHandlerThread.start();
|
||||
|
||||
new Handler(mWriteHandlerThread.getLooper()).post(()
|
||||
-> LOG.debug("started thread {}", Thread.currentThread().getName()));
|
||||
|
||||
LOG.debug("Write handler thread is prepared, creating write handler");
|
||||
mWriteHandler = new Handler(mWriteHandlerThread.getLooper()) {
|
||||
@SuppressLint("MissingPermission")
|
||||
@@ -266,6 +272,7 @@ public final class BtBRQueue {
|
||||
public void disconnect() {
|
||||
if (mWriteHandlerThread.isAlive()) {
|
||||
mWriteHandlerThread.quit();
|
||||
LOG.debug("finished thread {}", mWriteHandlerThread.getName());
|
||||
}
|
||||
|
||||
if (mBtSocket != null && mBtSocket.isConnected()) {
|
||||
|
||||
+3
@@ -87,6 +87,7 @@ public abstract class BtClassicIoThread extends GBDeviceIoThread {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
LOG.debug("started thread {}", getName());
|
||||
mIsConnected = connect();
|
||||
if (!mIsConnected) {
|
||||
if (GBApplication.getPrefs().getAutoReconnect(getDevice()) && !mQuit) {
|
||||
@@ -135,6 +136,8 @@ public abstract class BtClassicIoThread extends GBDeviceIoThread {
|
||||
LOG.debug("Exited read thread loop, will wait for reconnect");
|
||||
gbDevice.setUpdateState(GBDevice.State.WAITING_FOR_RECONNECT, getContext());
|
||||
}
|
||||
|
||||
LOG.debug("finished thread {}", getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -100,7 +100,7 @@ public final class BtLEQueue implements Thread.UncaughtExceptionHandler {
|
||||
private class DispatchRunnable implements Runnable {
|
||||
@Override
|
||||
public void run() {
|
||||
LOG.debug("{} started", Thread.currentThread().getName());
|
||||
LOG.debug("started thread {}", Thread.currentThread().getName());
|
||||
boolean crashed = false;
|
||||
|
||||
while (!mDisposed.get() && !crashed) {
|
||||
@@ -210,7 +210,7 @@ public final class BtLEQueue implements Thread.UncaughtExceptionHandler {
|
||||
mWaitCharacteristic = null;
|
||||
}
|
||||
}
|
||||
LOG.debug("{} terminated", Thread.currentThread().getName());
|
||||
LOG.debug("finished thread {}", Thread.currentThread().getName());
|
||||
}
|
||||
};
|
||||
|
||||
@@ -245,6 +245,7 @@ public final class BtLEQueue implements Thread.UncaughtExceptionHandler {
|
||||
mReceiverThread.setUncaughtExceptionHandler(this);
|
||||
mReceiverThread.start();
|
||||
mReceiverHandler = new Handler(mReceiverThread.getLooper());
|
||||
mReceiverHandler.post(() -> LOG.debug("started thread {}", Thread.currentThread().getName()));
|
||||
} else {
|
||||
mReceiverThread = null;
|
||||
mReceiverHandler = null;
|
||||
@@ -468,12 +469,14 @@ public final class BtLEQueue implements Thread.UncaughtExceptionHandler {
|
||||
|
||||
disconnect();
|
||||
|
||||
if (mReceiverThread != null) {
|
||||
if (mReceiverThread != null && mReceiverThread.isAlive()) {
|
||||
mReceiverHandler.post(() -> {
|
||||
mDispatchThread.interrupt();
|
||||
LOG.debug("finish thread {}", Thread.currentThread().getName());
|
||||
mReceiverThread.quitSafely();
|
||||
});
|
||||
} else {
|
||||
}
|
||||
|
||||
if (mDispatchThread != null) {
|
||||
mDispatchThread.interrupt();
|
||||
}
|
||||
}
|
||||
|
||||
+3
-1
@@ -46,6 +46,8 @@ public class CasioGB6900HandlerThread extends GBDeviceIoThread {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
LOG.debug("started thread {}", getName());
|
||||
|
||||
mQuit = false;
|
||||
|
||||
long waitTime = TX_PERIOD * 1000;
|
||||
@@ -81,7 +83,7 @@ public class CasioGB6900HandlerThread extends GBDeviceIoThread {
|
||||
now = GregorianCalendar.getInstance();
|
||||
waitTime = mTxTime.getTimeInMillis() - now.getTimeInMillis();
|
||||
}
|
||||
|
||||
LOG.debug("finished thread {}", getName());
|
||||
}
|
||||
|
||||
public void requestTxPowerLevel() {
|
||||
|
||||
+3
-1
@@ -85,6 +85,8 @@ class HPlusHandlerThread extends GBDeviceIoThread {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
LOG.debug("started thread {}", getName());
|
||||
|
||||
mQuit = false;
|
||||
|
||||
sync();
|
||||
@@ -131,7 +133,7 @@ class HPlusHandlerThread extends GBDeviceIoThread {
|
||||
now = GregorianCalendar.getInstance();
|
||||
waitTime = Math.min(mGetDaySummaryTime.getTimeInMillis(), Math.min(mGetDaySlotsTime.getTimeInMillis(), Math.min(mHelloTime.getTimeInMillis(), mGetSleepTime.getTimeInMillis()))) - now.getTimeInMillis();
|
||||
}
|
||||
|
||||
LOG.debug("finished thread {}", getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+3
@@ -241,6 +241,8 @@ class PebbleIoThread extends GBDeviceIoThread {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
LOG.debug("started thread {}", getName());
|
||||
|
||||
mIsConnected = connect();
|
||||
if (!mIsConnected) {
|
||||
if (GBApplication.getPrefs().getAutoReconnect(getDevice()) && !mQuit) {
|
||||
@@ -416,6 +418,7 @@ class PebbleIoThread extends GBDeviceIoThread {
|
||||
}
|
||||
|
||||
gbDevice.sendDeviceUpdateIntent(getContext());
|
||||
LOG.debug("finished thread {}", getName());
|
||||
}
|
||||
|
||||
private void enablePebbleKitSupport(boolean enable) {
|
||||
|
||||
+2
@@ -65,6 +65,7 @@ public class PebbleLESupport {
|
||||
mWriteHandlerThread = new HandlerThread("PebbleLESupport_write_" + THREAD_COUNTER.getAndIncrement());
|
||||
mWriteHandlerThread.start();
|
||||
mWriteHandler = new Handler(mWriteHandlerThread.getLooper());
|
||||
mWriteHandler.post(() -> LOG.debug("started thread {}", Thread.currentThread().getName()));
|
||||
|
||||
mMTULimit = GBApplication.getDevicePrefs(mgbDevice).getInt("pebble_mtu_limit", 512);
|
||||
mMTULimit = Math.max(mMTULimit, 20);
|
||||
@@ -119,6 +120,7 @@ public class PebbleLESupport {
|
||||
}
|
||||
if (mWriteHandlerThread != null) {
|
||||
mWriteHandlerThread.quit();
|
||||
LOG.debug("finished thread {}", mWriteHandlerThread.getName());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user