mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge.git
synced 2026-07-31 07:44:24 +02:00
log: use specific log instead of generic GB.log to streamline debugging
This commit is contained in:
committed by
José Rebelo
parent
741aad0674
commit
11e25b68aa
+1
-1
@@ -1117,7 +1117,7 @@ public class DebugActivity extends AbstractGBActivity {
|
||||
|
||||
} catch (
|
||||
Exception e) {
|
||||
GB.log("Error accessing database", GB.ERROR, e);
|
||||
LOG.error("Error accessing database", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -188,7 +188,7 @@ public class MiBandPairingActivity extends AbstractGBActivity implements Bonding
|
||||
DBHelper.getDevice(gbDevice, daoSession);
|
||||
gbDevice.sendDeviceUpdateIntent(this);
|
||||
} catch (final Exception e) {
|
||||
GB.log("Error accessing database", GB.ERROR, e);
|
||||
LOG.error("Error accessing database", e);
|
||||
}
|
||||
}
|
||||
Intent intent = new Intent(this, ControlCenterv2.class).setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||||
|
||||
+9
-9
@@ -326,22 +326,22 @@ public class DeviceCommunicationService extends Service implements SharedPrefere
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
if (!allowBluetoothIntentApi){
|
||||
GB.log("Connection API not allowed in settings", GB.ERROR, null);
|
||||
LOG.error("Connection API not allowed in settings");
|
||||
return;
|
||||
}
|
||||
Bundle extras = intent.getExtras();
|
||||
if (extras == null) {
|
||||
GB.log("no extras provided in Intent", GB.ERROR, null);
|
||||
LOG.error("no extras provided in Intent");
|
||||
return;
|
||||
}
|
||||
final String action = intent.getAction();
|
||||
if (action == null) {
|
||||
GB.log("Action for bluetooth command is null", GB.ERROR, null);
|
||||
LOG.error("Action for bluetooth command is null");
|
||||
return;
|
||||
}
|
||||
String address = extras.getString("EXTRA_DEVICE_ADDRESS", "");
|
||||
if (address.isEmpty()){
|
||||
GB.log("no bluetooth address provided in Intent", GB.ERROR, null);
|
||||
LOG.error("no bluetooth address provided in Intent");
|
||||
return;
|
||||
}
|
||||
GBDevice targetDevice = GBApplication.app()
|
||||
@@ -349,25 +349,25 @@ public class DeviceCommunicationService extends Service implements SharedPrefere
|
||||
.getDeviceByAddress(address);
|
||||
|
||||
if (targetDevice == null){
|
||||
GB.log(String.format("device %s not registered", address), GB.ERROR, null);
|
||||
LOG.error("device {} not registered", address);
|
||||
return;
|
||||
}
|
||||
|
||||
switch (action) {
|
||||
case API_LEGACY_COMMAND_BLUETOOTH_CONNECT:
|
||||
if (isDeviceConnected(address)){
|
||||
GB.log(String.format("device %s already connected", address), GB.INFO, null);
|
||||
LOG.info("device {} already connected", address);
|
||||
sendDeviceConnectedBroadcast(address);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
GB.log(String.format("connecting to %s", address), GB.INFO, null);
|
||||
LOG.info("connecting to {}", address);
|
||||
|
||||
GBApplication.deviceService(targetDevice).connect();
|
||||
break;
|
||||
case API_LEGACY_COMMAND_BLUETOOTH_DISCONNECT:
|
||||
GB.log(String.format("disconnecting from %s", address), GB.INFO, null);
|
||||
LOG.info("disconnecting from {}", address);
|
||||
|
||||
GBApplication.deviceService(targetDevice).disconnect();
|
||||
break;
|
||||
@@ -1618,7 +1618,7 @@ public class DeviceCommunicationService extends Service implements SharedPrefere
|
||||
}
|
||||
if (GBPrefs.PREF_ALLOW_INTENT_API.equals(key)){
|
||||
allowBluetoothIntentApi = sharedPreferences.getBoolean(GBPrefs.PREF_ALLOW_INTENT_API, false);
|
||||
GB.log("allowBluetoothIntentApi changed to " + allowBluetoothIntentApi, GB.INFO, null);
|
||||
LOG.info("allowBluetoothIntentApi changed to {}", allowBluetoothIntentApi);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+6
-2
@@ -26,6 +26,9 @@ import android.widget.Toast;
|
||||
|
||||
import androidx.core.content.ContextCompat;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
@@ -48,6 +51,7 @@ import nodomain.freeyourgadget.gadgetbridge.util.protobuf.messagefields.StringMe
|
||||
import nodomain.freeyourgadget.gadgetbridge.util.protobuf.messagefields.VarintMessageField;
|
||||
|
||||
public class FlipperZeroSupport extends FlipperZeroBaseSupport{
|
||||
private static final Logger LOG = LoggerFactory.getLogger(FlipperZeroSupport.class);
|
||||
private static final AtomicLong THREAD_COUNTER = new AtomicLong(0L);
|
||||
|
||||
private BatteryInfoProfile batteryInfoProfile = new BatteryInfoProfile(this);
|
||||
@@ -87,11 +91,11 @@ public class FlipperZeroSupport extends FlipperZeroBaseSupport{
|
||||
|
||||
String filePath = intent.getStringExtra("EXTRA_FILE_PATH");
|
||||
if(filePath == null){
|
||||
GB.log("missing EXTRA_FILE_PATH in intent", GB.ERROR, null);
|
||||
LOG.error("missing EXTRA_FILE_PATH in intent");
|
||||
return;
|
||||
}
|
||||
if(filePath.isEmpty()){
|
||||
GB.log("empty EXTRA_FILE_PATH in intent", GB.ERROR, null);
|
||||
LOG.error("empty EXTRA_FILE_PATH in intent");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
+18
-2
@@ -1,3 +1,20 @@
|
||||
/* Copyright (C) 2024-2025 Linos Giannopoulos, Thomas Kuehne
|
||||
|
||||
This file is part of Gadgetbridge.
|
||||
|
||||
Gadgetbridge is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as published
|
||||
by the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Gadgetbridge is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>. */
|
||||
|
||||
package nodomain.freeyourgadget.gadgetbridge.service.devices.idasen;
|
||||
|
||||
import android.bluetooth.BluetoothGatt;
|
||||
@@ -26,7 +43,6 @@ import nodomain.freeyourgadget.gadgetbridge.service.btle.AbstractBTLESingleDevic
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.btle.BLETypeConversions;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.btle.TransactionBuilder;
|
||||
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
|
||||
import nodomain.freeyourgadget.gadgetbridge.util.GB;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.idasen.IdasenConstants;
|
||||
|
||||
public class IdasenDeviceSupport extends AbstractBTLESingleDeviceSupport {
|
||||
@@ -102,7 +118,7 @@ public class IdasenDeviceSupport extends AbstractBTLESingleDeviceSupport {
|
||||
try {
|
||||
Thread.sleep(300);
|
||||
} catch (InterruptedException e) {
|
||||
GB.log("error", GB.ERROR, e);
|
||||
LOG.error("error", e);
|
||||
}
|
||||
cutOff--;
|
||||
} while (deskSpeed != 0F && cutOff != 0);
|
||||
|
||||
+4
-4
@@ -335,7 +335,7 @@ public class QHybridSupport extends QHybridBaseSupport {
|
||||
PlayNotificationRequest.VibrationType.NO_VIBE
|
||||
));
|
||||
} catch (Exception e) {
|
||||
GB.log("wrong number format", GB.ERROR, e);
|
||||
logger.error("wrong number format", e);
|
||||
logger.debug("trash extra should be number 0.0-1.0");
|
||||
}
|
||||
break;
|
||||
@@ -543,7 +543,7 @@ public class QHybridSupport extends QHybridBaseSupport {
|
||||
try {
|
||||
watchAdapter.setMusicInfo(musicSpec);
|
||||
}catch (Exception e){
|
||||
GB.log("setMusicInfo error", GB.ERROR, e);
|
||||
logger.error("setMusicInfo error", e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -741,7 +741,7 @@ public class QHybridSupport extends QHybridBaseSupport {
|
||||
//TODO file stuff
|
||||
// queueWrite(new EraseFileRequest((short) request.fileHandle));
|
||||
} catch (Exception e) {
|
||||
GB.log("error", GB.ERROR, e);
|
||||
logger.error("error", e);
|
||||
if (request.fileHandle > 257) {
|
||||
// queueWrite(new DownloadFileRequest((short) (request.fileHandle - 1)));
|
||||
}
|
||||
@@ -781,7 +781,7 @@ public class QHybridSupport extends QHybridBaseSupport {
|
||||
gbDevice.addDeviceInfo(new GenericItem(ITEM_EXTENDED_VIBRATION_SUPPORT, String.valueOf(watchAdapter.supportsExtendedVibration())));
|
||||
gbDevice.addDeviceInfo(new GenericItem(ITEM_HAS_ACTIVITY_HAND, String.valueOf(watchAdapter.supportsActivityHand())));
|
||||
} catch (UnsupportedOperationException e) {
|
||||
GB.log("error", GB.ERROR, e);
|
||||
logger.error("error", e);
|
||||
gbDevice.addDeviceInfo(new GenericItem(ITEM_EXTENDED_VIBRATION_SUPPORT, "false"));
|
||||
}
|
||||
break;
|
||||
|
||||
+7
-7
@@ -228,7 +228,7 @@ public class FossilWatchAdapter extends WatchAdapter {
|
||||
public void onCharacteristicWrite(BluetoothGatt gatt, BluetoothGattCharacteristic characteristic, int status) {
|
||||
if (status != BluetoothGatt.GATT_SUCCESS) {
|
||||
if (characteristic.getUuid().toString().equals("3dda0005-957f-7d4a-34a6-74696673696d")) {
|
||||
GB.log("authentication failed", GB.ERROR, null);
|
||||
LOG.error("authentication failed");
|
||||
setDeviceState(GBDevice.State.AUTHENTICATION_REQUIRED);
|
||||
requestQueue.clear();
|
||||
}
|
||||
@@ -350,7 +350,7 @@ public class FossilWatchAdapter extends WatchAdapter {
|
||||
};
|
||||
queueWrite(fileUploadRequets);
|
||||
} catch (JSONException e) {
|
||||
GB.log("error", GB.ERROR, e);
|
||||
LOG.error("error", e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -456,7 +456,7 @@ public class FossilWatchAdapter extends WatchAdapter {
|
||||
}
|
||||
}, false);
|
||||
} catch (Exception e) {
|
||||
GB.log("error", GB.ERROR, e);
|
||||
LOG.error("error", e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -669,10 +669,10 @@ public class FossilWatchAdapter extends WatchAdapter {
|
||||
requestFinished = fossilRequest.isFinished();
|
||||
} catch (RuntimeException e) {
|
||||
if (characteristic.getUuid().toString().equals("3dda0005-957f-7d4a-34a6-74696673696d")) {
|
||||
GB.log("authentication failed", GB.ERROR, e);
|
||||
LOG.error("authentication failed", e);
|
||||
// setDeviceState(GBDevice.State.AUTHENTICATION_REQUIRED);
|
||||
}else {
|
||||
GB.log("error", GB.ERROR, e);
|
||||
LOG.error("error", e);
|
||||
if (BuildConfig.DEBUG)
|
||||
GB.toast(fossilRequest.getName() + " failed", Toast.LENGTH_SHORT, GB.ERROR);
|
||||
}
|
||||
@@ -718,7 +718,7 @@ public class FossilWatchAdapter extends WatchAdapter {
|
||||
}
|
||||
}
|
||||
} catch (UnsupportedOperationException e) {
|
||||
GB.log("error", GB.ERROR, e);
|
||||
LOG.error("error", e);
|
||||
}
|
||||
|
||||
if (start && getDeviceSupport().searchDevice) return;
|
||||
@@ -735,7 +735,7 @@ public class FossilWatchAdapter extends WatchAdapter {
|
||||
try {
|
||||
Thread.sleep(2500);
|
||||
} catch (InterruptedException e) {
|
||||
GB.log("error", GB.ERROR, e);
|
||||
LOG.error("error", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+12
-12
@@ -231,13 +231,13 @@ public class FossilHRWatchAdapter extends FossilWatchAdapter {
|
||||
ServiceConnection voiceServiceConnection = new ServiceConnection() {
|
||||
@Override
|
||||
public void onServiceConnected(ComponentName name, IBinder service) {
|
||||
GB.log("attached to voice service", GB.INFO, null);
|
||||
LOG.info("attached to voice service");
|
||||
voiceMessenger = new Messenger(service);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onServiceDisconnected(ComponentName name) {
|
||||
GB.log("detached from voice service", GB.INFO, null);
|
||||
LOG.info("detached from voice service");
|
||||
voiceMessenger = null;
|
||||
}
|
||||
};
|
||||
@@ -328,7 +328,7 @@ public class FossilHRWatchAdapter extends FossilWatchAdapter {
|
||||
queueWrite(new CheckDeviceNeedsConfirmationRequest() {
|
||||
@Override
|
||||
public void onResult(boolean needsConfirmation) {
|
||||
GB.log("needs confirmation: " + needsConfirmation, GB.INFO, null);
|
||||
LOG.info("needs confirmation: {}", needsConfirmation);
|
||||
if (needsConfirmation) {
|
||||
final Timer timer = new Timer();
|
||||
GB.toast(getContext().getString(R.string.fossil_hr_confirm_connection), Toast.LENGTH_SHORT, GB.INFO);
|
||||
@@ -357,13 +357,13 @@ public class FossilHRWatchAdapter extends FossilWatchAdapter {
|
||||
queueWrite(new CheckDevicePairingRequest() {
|
||||
@Override
|
||||
public void onResult(boolean pairingStatus) {
|
||||
GB.log("watch pairing status: " + pairingStatus, GB.INFO, null);
|
||||
LOG.info("watch pairing status: {}", pairingStatus);
|
||||
if (!pairingStatus) {
|
||||
queueWrite(new PerformDevicePairingRequest() {
|
||||
@Override
|
||||
public void onResult(boolean pairingSuccess) {
|
||||
isFinished = true;
|
||||
GB.log("watch pairing result: " + pairingSuccess, GB.INFO, null);
|
||||
LOG.info("watch pairing result: {}", pairingSuccess);
|
||||
if (pairingSuccess) {
|
||||
GB.toast(getContext().getString(R.string.fossil_hr_pairing_successful), Toast.LENGTH_LONG, GB.ERROR);
|
||||
} else {
|
||||
@@ -406,7 +406,7 @@ public class FossilHRWatchAdapter extends FossilWatchAdapter {
|
||||
|
||||
flags |= Service.BIND_AUTO_CREATE;
|
||||
|
||||
GB.log("binding to voice service...", GB.INFO, null);
|
||||
LOG.info("binding to voice service...");
|
||||
|
||||
getContext().bindService(
|
||||
voiceIntent,
|
||||
@@ -466,7 +466,7 @@ public class FossilHRWatchAdapter extends FossilWatchAdapter {
|
||||
try {
|
||||
voiceMessenger.send(message);
|
||||
} catch (RemoteException e) {
|
||||
GB.log("error sending voice data to service", GB.ERROR, e);
|
||||
LOG.error("error sending voice data to service", e);
|
||||
GB.toast("error sending voice data to service", Toast.LENGTH_LONG, GB.ERROR);
|
||||
voiceMessenger = null;
|
||||
detachFromVoiceService();
|
||||
@@ -675,7 +675,7 @@ public class FossilHRWatchAdapter extends FossilWatchAdapter {
|
||||
}
|
||||
}
|
||||
} catch (IOException | RuntimeException e) {
|
||||
GB.log("error opening background file", GB.ERROR, e);
|
||||
LOG.error("error opening background file", e);
|
||||
GB.toast("error opening background file", Toast.LENGTH_LONG, GB.ERROR);
|
||||
}
|
||||
}
|
||||
@@ -691,7 +691,7 @@ public class FossilHRWatchAdapter extends FossilWatchAdapter {
|
||||
FileOutputStream fos = new FileOutputStream(getBackgroundFile(), false);
|
||||
fos.write(pixels);
|
||||
} catch (IOException e) {
|
||||
GB.log("error saving background", GB.ERROR, e);
|
||||
LOG.error("error saving background", e);
|
||||
GB.toast("error persistent saving background", Toast.LENGTH_LONG, GB.ERROR);
|
||||
}
|
||||
}
|
||||
@@ -1139,7 +1139,7 @@ public class FossilHRWatchAdapter extends FossilWatchAdapter {
|
||||
@Override
|
||||
protected void handleAuthenticationResult(boolean success) {
|
||||
if (success) {
|
||||
GB.log("success auth", GB.INFO, null);
|
||||
LOG.info("success auth");
|
||||
queueWrite((FossilRequest) request, true);
|
||||
}
|
||||
}
|
||||
@@ -1215,7 +1215,7 @@ public class FossilHRWatchAdapter extends FossilWatchAdapter {
|
||||
this
|
||||
));
|
||||
} catch (BufferOverflowException e) {
|
||||
GB.log("musicInfo: " + musicSpec, GB.ERROR, e);
|
||||
LOG.error("musicInfo: {}", musicSpec, e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1325,7 +1325,7 @@ public class FossilHRWatchAdapter extends FossilWatchAdapter {
|
||||
fos.close();
|
||||
GB.toast("saved file data", Toast.LENGTH_SHORT, GB.INFO);
|
||||
} catch (IOException e) {
|
||||
GB.log("file error", GB.ERROR, e);
|
||||
LOG.error("file error", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -182,7 +182,7 @@ public class MisfitWatchAdapter extends WatchAdapter {
|
||||
fos.write((new Date().toString() + ": " + characteristic.getUuid().toString() + ": " + arrayToString(value)).getBytes());
|
||||
}
|
||||
} catch (IOException e) {
|
||||
GB.log("error", GB.ERROR, e);
|
||||
logger.error("error", e);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -247,7 +247,7 @@ public class MisfitWatchAdapter extends WatchAdapter {
|
||||
}
|
||||
logger.debug("file written.");
|
||||
} catch (Exception e) {
|
||||
GB.log("error", GB.ERROR, e);
|
||||
logger.error("error", e);
|
||||
}
|
||||
gbDevice.addDeviceInfo(new GenericItem(ITEM_STEP_COUNT, String.valueOf(((GetCurrentStepCountRequest) request).steps)));
|
||||
} else if (request instanceof OTAEnterRequest) {
|
||||
|
||||
+6
-2
@@ -19,6 +19,9 @@ package nodomain.freeyourgadget.gadgetbridge.service.devices.qhybrid.requests.fo
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
import java.util.ArrayList;
|
||||
@@ -27,9 +30,10 @@ import java.util.HashMap;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.qhybrid.adapter.fossil.FossilWatchAdapter;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.qhybrid.file.FileHandle;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.qhybrid.requests.fossil.file.FilePutRequest;
|
||||
import nodomain.freeyourgadget.gadgetbridge.util.GB;
|
||||
|
||||
public class ConfigurationPutRequest extends FilePutRequest {
|
||||
private static final Logger LOG = LoggerFactory.getLogger(ConfigurationPutRequest.class);
|
||||
|
||||
private static final HashMap<Short, Class<? extends ConfigItem>> itemsById = new HashMap<>();
|
||||
|
||||
static {
|
||||
@@ -68,7 +72,7 @@ public class ConfigurationPutRequest extends FilePutRequest {
|
||||
try {
|
||||
item = configClass.newInstance();
|
||||
} catch (IllegalAccessException | InstantiationException e) {
|
||||
GB.log("error", GB.ERROR, e);
|
||||
LOG.error("pasePayload", e);
|
||||
continue;
|
||||
}
|
||||
item.parseData(payload);
|
||||
|
||||
Reference in New Issue
Block a user