modified logging

This commit is contained in:
dakhnod 2019-11-21 22:12:10 +01:00
parent a1816d6a8d
commit afc177078a
6 changed files with 31 additions and 13 deletions

View File

@ -112,7 +112,7 @@ public class QHybridSupport extends QHybridBaseSupport {
NotificationConfiguration config = extras == null ? null : (NotificationConfiguration) intent.getExtras().get("CONFIG");
switch (intent.getAction()) {
case QHYBRID_COMMAND_CONTROL: {
Log.d("Service", "sending control request");
log("sending control request");
watchAdapter.requestHandsControl();
if (config != null) {
watchAdapter.setHands(config.getHour(), config.getMin());
@ -261,7 +261,7 @@ public class QHybridSupport extends QHybridBaseSupport {
@Override
public void onNotification(NotificationSpec notificationSpec) {
Log.d("Service", "notif from " + notificationSpec.sourceAppId + " " + notificationSpec.sender + " " + notificationSpec.phoneNumber);
log("notif from " + notificationSpec.sourceAppId + " " + notificationSpec.sender + " " + notificationSpec.phoneNumber);
//new Exception().printStackTrace();
String packageName = notificationSpec.sourceName;
@ -274,7 +274,7 @@ public class QHybridSupport extends QHybridBaseSupport {
}
if (config == null) return;
Log.d("Service", "handling notification");
log("handling notification");
if (config.getRespectSilentMode()) {
int mode = ((AudioManager) getContext().getApplicationContext().getSystemService(Context.AUDIO_SERVICE)).getRingerMode();
@ -288,6 +288,10 @@ public class QHybridSupport extends QHybridBaseSupport {
showNotificationsByAllActive(enforceActivityHandNotification);
}
private void log(String message){
logger.debug(message);
}
@Override
public void onDeleteNotification(int id) {
super.onDeleteNotification(id);

View File

@ -7,6 +7,9 @@ import android.os.Build;
import android.util.Log;
import android.widget.Toast;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.text.DateFormat;
import java.util.ArrayList;
import java.util.Date;
@ -49,6 +52,8 @@ public class FossilWatchAdapter extends WatchAdapter {
private int lastButtonIndex = -1;
Logger logger = LoggerFactory.getLogger(getClass());
public FossilWatchAdapter(QHybridSupport deviceSupport) {
super(deviceSupport);
}
@ -371,7 +376,7 @@ public class FossilWatchAdapter extends WatchAdapter {
}
private void log(String message) {
Log.d("FossilWatchAdapter", message);
logger.debug(message);
}
public void queueWrite(SetDeviceStateRequest request, boolean priorise) {

View File

@ -55,6 +55,7 @@ import nodomain.freeyourgadget.gadgetbridge.service.devices.qhybrid.requests.mis
import nodomain.freeyourgadget.gadgetbridge.service.devices.qhybrid.requests.misfit.SetVibrationStrengthRequest;
import nodomain.freeyourgadget.gadgetbridge.service.devices.qhybrid.requests.misfit.UploadFileRequest;
import nodomain.freeyourgadget.gadgetbridge.service.devices.qhybrid.requests.misfit.VibrateRequest;
import nodomain.freeyourgadget.gadgetbridge.util.GB;
import static nodomain.freeyourgadget.gadgetbridge.service.devices.qhybrid.QHybridSupport.ITEM_ACTIVITY_POINT;
import static nodomain.freeyourgadget.gadgetbridge.service.devices.qhybrid.QHybridSupport.ITEM_STEP_COUNT;
@ -66,13 +67,14 @@ import static nodomain.freeyourgadget.gadgetbridge.service.devices.qhybrid.QHybr
public class MisfitWatchAdapter extends WatchAdapter {
private int lastButtonIndex = -1;
private final SparseArray<Request> responseFilters = new SparseArray<>();
private static final Logger logger = LoggerFactory.getLogger(QHybridSupport.class);
private UploadFileRequest uploadFileRequest;
private Request fileRequest = null;
private Queue<Request> requestQueue = new ArrayDeque<>();
Logger logger = LoggerFactory.getLogger(getClass());
public MisfitWatchAdapter(QHybridSupport deviceSupport) {
super(deviceSupport);
@ -155,7 +157,7 @@ public class MisfitWatchAdapter extends WatchAdapter {
break;
}
default: {
Log.d("Service", "unknown shit on " + characteristic.getUuid().toString() + ": " + arrayToString(characteristic.getValue()));
log("unknown shit on " + characteristic.getUuid().toString() + ": " + arrayToString(characteristic.getValue()));
try {
File charLog = new File("/sdcard/qFiles/charLog.txt");
if (!charLog.exists()) {
@ -191,10 +193,10 @@ public class MisfitWatchAdapter extends WatchAdapter {
byte[] sequence = object.getStartSequence();
if (sequence.length > 1) {
responseFilters.put((int) object.getStartSequence()[1], object);
Log.d("Service", "response filter " + object.getStartSequence()[1] + ": " + c.getSimpleName());
log("response filter " + object.getStartSequence()[1] + ": " + c.getSimpleName());
}
} catch (NoSuchMethodException | IllegalAccessException | InstantiationException e) {
Log.d("Service", "skipping class " + c.getName());
log("skipping class " + c.getName());
}
}
}
@ -209,10 +211,10 @@ public class MisfitWatchAdapter extends WatchAdapter {
for (int i = 1; i < characteristic.getValue().length; i++) {
valueString.append(", ").append(values[i]);
}
Log.d("Service", "unable to resolve " + characteristic.getUuid().toString() + ": " + valueString);
log("unable to resolve " + characteristic.getUuid().toString() + ": " + valueString);
return true;
}
Log.d("Service", "response: " + request.getClass().getSimpleName());
log("response: " + request.getClass().getSimpleName());
request.handleResponse(characteristic);
if (request instanceof GetStepGoalRequest) {
@ -347,6 +349,9 @@ public class MisfitWatchAdapter extends WatchAdapter {
return true;
}
private void log(String message){
logger.debug(message);
}
public void setActivityHand(double progress) {
queueWrite(new SetCurrentStepCountRequest(Math.min((int) (1000000 * progress), 999999)));

View File

@ -3,12 +3,16 @@ package nodomain.freeyourgadget.gadgetbridge.service.devices.qhybrid.requests;
import android.bluetooth.BluetoothGattCharacteristic;
import android.util.Log;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.util.UUID;
public abstract class Request {
protected byte[] data;
private Logger logger = (Logger) LoggerFactory.getLogger(getName());
//protected ByteBuffer buffer;
public Request(){
@ -48,7 +52,7 @@ public abstract class Request {
}
protected void log(String message){
Log.d(getName(), message);
logger.debug(message);
}
public boolean isBasicRequest(){

View File

@ -20,7 +20,7 @@ public class EraseFileRequest extends FileRequest{
public void handleResponse(BluetoothGattCharacteristic characteristic) {
super.handleResponse(characteristic);
if(!characteristic.getUuid().toString().equals(getRequestUUID().toString())){
Log.d(getName(), "wrong descriptor");
log("wrong descriptor");
return;
}
ByteBuffer buffer = ByteBuffer.wrap(characteristic.getValue());

View File

@ -25,7 +25,7 @@ public class GetCountdownSettingsRequest extends Request {
byte progress = buffer.get(13);
short offset = buffer.getShort(11);
Log.d("countdown", "progress: " + progress);
log("progress: " + progress);
}