AndroidAPS/app/src/main/java/info/nightscout/androidaps/receivers/TimeDateOrTZChangeReceiver.java

45 lines
1.4 KiB
Java
Raw Normal View History

2019-07-16 21:36:37 +02:00
package info.nightscout.androidaps.receivers;
import android.bluetooth.BluetoothAdapter;
2019-07-16 21:36:37 +02:00
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
2019-07-16 21:36:37 +02:00
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import info.nightscout.androidaps.MainApp;
2019-07-16 21:36:37 +02:00
import info.nightscout.androidaps.interfaces.PumpInterface;
import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin;
public class TimeDateOrTZChangeReceiver extends BroadcastReceiver {
private static Logger LOG = LoggerFactory.getLogger(L.PUMP);
@Override
public void onReceive(Context context, Intent intent) {
final String action = intent.getAction();
PumpInterface activePump = ConfigBuilderPlugin.getPlugin().getActivePump();
LOG.debug("Date, Time and/or TimeZone changed.");
if (action != null && activePump != null) {
LOG.debug("Date, Time and/or TimeZone changed. Notifying pump driver.");
activePump.timeDateOrTimeZoneChanged();
}
}
public void registerBroadcasts(MainApp mainApp) {
IntentFilter filter = new IntentFilter();
filter.addAction(Intent.ACTION_TIME_CHANGED);
filter.addAction(Intent.ACTION_DATE_CHANGED);
filter.addAction(Intent.ACTION_TIMEZONE_CHANGED);
mainApp.registerReceiver(this, filter);
}
2019-07-16 21:36:37 +02:00
}