2019-07-16 21:36:37 +02:00
|
|
|
package info.nightscout.androidaps.receivers;
|
|
|
|
|
2019-07-18 19:09:49 +02:00
|
|
|
import android.bluetooth.BluetoothAdapter;
|
2019-07-16 21:36:37 +02:00
|
|
|
import android.content.BroadcastReceiver;
|
|
|
|
import android.content.Context;
|
|
|
|
import android.content.Intent;
|
2019-07-18 19:09:49 +02:00
|
|
|
import android.content.IntentFilter;
|
2019-07-16 21:36:37 +02:00
|
|
|
|
|
|
|
import org.slf4j.Logger;
|
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
|
2019-07-18 19:09:49 +02:00
|
|
|
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();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-07-18 19:09:49 +02:00
|
|
|
|
|
|
|
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
|
|
|
}
|