mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-09-11 00:36:32 +02:00
More logging for time/timezone changes
(trying to find an explanation for #91)
This commit is contained in:
parent
05ee6e46c6
commit
69b64ed4b6
@ -9,7 +9,11 @@ import android.preference.PreferenceManager;
|
|||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.GregorianCalendar;
|
||||||
|
|
||||||
import nodomain.freeyourgadget.gadgetbridge.GBApplication;
|
import nodomain.freeyourgadget.gadgetbridge.GBApplication;
|
||||||
|
import nodomain.freeyourgadget.gadgetbridge.util.DateTimeUtils;
|
||||||
|
|
||||||
|
|
||||||
public class TimeChangeReceiver extends BroadcastReceiver {
|
public class TimeChangeReceiver extends BroadcastReceiver {
|
||||||
@ -22,7 +26,8 @@ public class TimeChangeReceiver extends BroadcastReceiver {
|
|||||||
final String action = intent.getAction();
|
final String action = intent.getAction();
|
||||||
|
|
||||||
if (sharedPrefs.getBoolean("datetime_synconconnect", true) && (action.equals(Intent.ACTION_TIME_CHANGED) || action.equals(Intent.ACTION_TIMEZONE_CHANGED))) {
|
if (sharedPrefs.getBoolean("datetime_synconconnect", true) && (action.equals(Intent.ACTION_TIME_CHANGED) || action.equals(Intent.ACTION_TIMEZONE_CHANGED))) {
|
||||||
LOG.info("Time or Timezone changed, syncing with device");
|
Date newTime = GregorianCalendar.getInstance().getTime();
|
||||||
|
LOG.info("Time or Timezone changed, syncing with device: " + DateTimeUtils.formatDate(newTime) + " (" + newTime.toGMTString() + "), " + intent.getAction());
|
||||||
GBApplication.deviceService().onSetTime();
|
GBApplication.deviceService().onSetTime();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,9 +3,10 @@ package nodomain.freeyourgadget.gadgetbridge.service.btle;
|
|||||||
import android.bluetooth.BluetoothGatt;
|
import android.bluetooth.BluetoothGatt;
|
||||||
import android.bluetooth.BluetoothGattCharacteristic;
|
import android.bluetooth.BluetoothGattCharacteristic;
|
||||||
|
|
||||||
import java.text.DateFormat;
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
|
import nodomain.freeyourgadget.gadgetbridge.util.DateTimeUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Bluedroid implementation only allows performing one GATT request at a time.
|
* The Bluedroid implementation only allows performing one GATT request at a time.
|
||||||
* As they are asynchronous anyway, we encapsulate every GATT request (read and write)
|
* As they are asynchronous anyway, we encapsulate every GATT request (read and write)
|
||||||
@ -50,7 +51,7 @@ public abstract class BtLEAction {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected String getCreationTime() {
|
protected String getCreationTime() {
|
||||||
return DateFormat.getTimeInstance().format(new Date(creationTimestamp));
|
return DateTimeUtils.formatDateTime(new Date(creationTimestamp));
|
||||||
}
|
}
|
||||||
|
|
||||||
public String toString() {
|
public String toString() {
|
||||||
|
@ -12,6 +12,10 @@ import java.util.concurrent.TimeUnit;
|
|||||||
import nodomain.freeyourgadget.gadgetbridge.GBApplication;
|
import nodomain.freeyourgadget.gadgetbridge.GBApplication;
|
||||||
|
|
||||||
public class DateTimeUtils {
|
public class DateTimeUtils {
|
||||||
|
public static String formatDateTime(Date date) {
|
||||||
|
return DateUtils.formatDateTime(GBApplication.getContext(), date.getTime(), DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_SHOW_TIME);
|
||||||
|
}
|
||||||
|
|
||||||
public static String formatDate(Date date) {
|
public static String formatDate(Date date) {
|
||||||
return DateUtils.formatDateTime(GBApplication.getContext(), date.getTime(), DateUtils.FORMAT_SHOW_DATE);
|
return DateUtils.formatDateTime(GBApplication.getContext(), date.getTime(), DateUtils.FORMAT_SHOW_DATE);
|
||||||
// long dateMillis = date.getTime();
|
// long dateMillis = date.getTime();
|
||||||
|
Loading…
Reference in New Issue
Block a user