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