mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2025-02-03 21:47:32 +01:00
A little cleanup
This commit is contained in:
parent
4293db5514
commit
5e8004756f
@ -145,6 +145,10 @@ public class QHybridSupport extends QHybridBaseSupport {
|
|||||||
public void onReceive(Context context, Intent intent) {
|
public void onReceive(Context context, Intent intent) {
|
||||||
Bundle extras = intent.getExtras();
|
Bundle extras = intent.getExtras();
|
||||||
NotificationConfiguration config = extras == null ? null : (NotificationConfiguration) intent.getExtras().get("CONFIG");
|
NotificationConfiguration config = extras == null ? null : (NotificationConfiguration) intent.getExtras().get("CONFIG");
|
||||||
|
if (intent.getAction() == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
switch (intent.getAction()) {
|
switch (intent.getAction()) {
|
||||||
case QHYBRID_COMMAND_CONTROL: {
|
case QHYBRID_COMMAND_CONTROL: {
|
||||||
log("sending control request");
|
log("sending control request");
|
||||||
@ -161,16 +165,21 @@ public class QHybridSupport extends QHybridBaseSupport {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case QHYBRID_COMMAND_SET: {
|
case QHYBRID_COMMAND_SET: {
|
||||||
watchAdapter.setHands(config.getHour(), config.getMin());
|
if (config != null) {
|
||||||
|
watchAdapter.setHands(config.getHour(), config.getMin());
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case QHYBRID_COMMAND_VIBRATE: {
|
case QHYBRID_COMMAND_VIBRATE: {
|
||||||
watchAdapter.vibrate(config.getVibration());
|
if (config != null) {
|
||||||
|
watchAdapter.vibrate(config.getVibration());
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case QHYBRID_COMMAND_NOTIFICATION: {
|
case QHYBRID_COMMAND_NOTIFICATION: {
|
||||||
watchAdapter.playNotification(config);
|
if (config != null) {
|
||||||
|
watchAdapter.playNotification(config);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case QHYBRID_COMMAND_UPDATE: {
|
case QHYBRID_COMMAND_UPDATE: {
|
||||||
|
@ -92,7 +92,7 @@ public class MisfitWatchAdapter extends WatchAdapter {
|
|||||||
|
|
||||||
private Queue<Request> requestQueue = new ArrayDeque<>();
|
private Queue<Request> requestQueue = new ArrayDeque<>();
|
||||||
|
|
||||||
Logger logger = LoggerFactory.getLogger(getClass());
|
private Logger logger = LoggerFactory.getLogger(getClass());
|
||||||
|
|
||||||
public MisfitWatchAdapter(QHybridSupport deviceSupport) {
|
public MisfitWatchAdapter(QHybridSupport deviceSupport) {
|
||||||
super(deviceSupport);
|
super(deviceSupport);
|
||||||
@ -179,12 +179,9 @@ public class MisfitWatchAdapter extends WatchAdapter {
|
|||||||
log("unknown shit on " + characteristic.getUuid().toString() + ": " + arrayToString(characteristic.getValue()));
|
log("unknown shit on " + characteristic.getUuid().toString() + ": " + arrayToString(characteristic.getValue()));
|
||||||
try {
|
try {
|
||||||
File charLog = new File("/sdcard/qFiles/charLog.txt");
|
File charLog = new File("/sdcard/qFiles/charLog.txt");
|
||||||
if (!charLog.exists()) {
|
try (FileOutputStream fos = new FileOutputStream(charLog, true)) {
|
||||||
charLog.createNewFile();
|
fos.write((new Date().toString() + ": " + characteristic.getUuid().toString() + ": " + arrayToString(characteristic.getValue())).getBytes());
|
||||||
}
|
}
|
||||||
|
|
||||||
FileOutputStream fos = new FileOutputStream(charLog, true);
|
|
||||||
fos.write((new Date().toString() + ": " + characteristic.getUuid().toString() + ": " + arrayToString(characteristic.getValue())).getBytes());
|
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
GB.log("error", GB.ERROR, e);
|
GB.log("error", GB.ERROR, e);
|
||||||
}
|
}
|
||||||
@ -249,13 +246,10 @@ public class MisfitWatchAdapter extends WatchAdapter {
|
|||||||
if (!f.exists()) f.mkdir();
|
if (!f.exists()) f.mkdir();
|
||||||
|
|
||||||
File file = new File("/sdcard/qFiles/steps");
|
File file = new File("/sdcard/qFiles/steps");
|
||||||
if (!file.exists()) {
|
|
||||||
file.createNewFile();
|
|
||||||
}
|
|
||||||
logger.debug("Writing file " + file.getPath());
|
logger.debug("Writing file " + file.getPath());
|
||||||
FileOutputStream fos = new FileOutputStream(file, true);
|
try (FileOutputStream fos = new FileOutputStream(file, true)) {
|
||||||
fos.write((System.currentTimeMillis() + ": " + steps + "\n").getBytes());
|
fos.write((System.currentTimeMillis() + ": " + steps + "\n").getBytes());
|
||||||
fos.close();
|
}
|
||||||
logger.debug("file written.");
|
logger.debug("file written.");
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
GB.log("error", GB.ERROR, e);
|
GB.log("error", GB.ERROR, e);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user