Java Code Examples for com.eveningoutpost.dexdrip.Models.Sensor#isActive()

The following examples show how to use com.eveningoutpost.dexdrip.Models.Sensor#isActive() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: StartNewSensor.java    From xDrip with GNU General Public License v3.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    if (!Sensor.isActive()) {
        JoH.fixActionBar(this);
        setContentView(R.layout.activity_start_new_sensor);
        button = (Button) findViewById(R.id.startNewSensor);
        //dp = (DatePicker)findViewById(R.id.datePicker);
        //tp = (TimePicker)findViewById(R.id.timePicker);
        addListenerOnButton();
    } else {
        Intent intent = new Intent(this, StopSensor.class);
        startActivity(intent);
        finish();
    }
}
 
Example 2
Source File: SensorStatus.java    From xDrip-plus with GNU General Public License v3.0 6 votes vote down vote up
public static String status() {
    final StringBuilder sensor_status = new StringBuilder();
    if (Sensor.isActive()) {
        final Sensor sensor = Sensor.currentSensor();
        final Date date = new Date(sensor.started_at);
        DateFormat df = new SimpleDateFormat();
        sensor_status.append(df.format(date));
        sensor_status.append(" (");
        sensor_status.append((tsl() - sensor.started_at) / Constants.DAY_IN_MS);
        sensor_status.append("d ");
        sensor_status.append(((tsl() - sensor.started_at) % Constants.DAY_IN_MS) / Constants.HOUR_IN_MS);
        sensor_status.append("h)");
    } else {
        sensor_status.append("not available");
    }
    return sensor_status.toString();
}
 
Example 3
Source File: SystemStatus.java    From xDrip-Experimental with GNU General Public License v3.0 6 votes vote down vote up
private void setSensorStatus(){
    StringBuilder sensor_status= new StringBuilder();
    if(Sensor.isActive()){
        Sensor sens = Sensor.currentSensor();
        Date date = new Date(sens.started_at);
        DateFormat df = new SimpleDateFormat();
        sensor_status.append(df.format(date));
        sensor_status.append(" (");
        sensor_status.append((System.currentTimeMillis() - sens.started_at) / (1000 * 60 * 60 * 24));
        sensor_status.append("d ");
        sensor_status.append(((System.currentTimeMillis() - sens.started_at)%(1000 * 60 * 60 * 24))/(1000*60*60));
        sensor_status.append("h)");
    } else {
        sensor_status.append("not available");
    }
    sensor_status_view.setText(sensor_status.toString());

}
 
Example 4
Source File: StartNewSensor.java    From xDrip-plus with GNU General Public License v3.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    if (!Sensor.isActive()) {
        JoH.fixActionBar(this);
        setContentView(R.layout.activity_start_new_sensor);
        button = (Button) findViewById(R.id.startNewSensor);
        //dp = (DatePicker)findViewById(R.id.datePicker);
        //tp = (TimePicker)findViewById(R.id.timePicker);
        addListenerOnButton();
    } else {
        Intent intent = new Intent(this, StopSensor.class);
        startActivity(intent);
        finish();
    }
}
 
Example 5
Source File: SystemStatus.java    From xDrip with GNU General Public License v3.0 6 votes vote down vote up
private void setSensorStatus(){
    StringBuilder sensor_status= new StringBuilder();
    if(Sensor.isActive()){
        Sensor sens = Sensor.currentSensor();
        Date date = new Date(sens.started_at);
        DateFormat df = new SimpleDateFormat();
        sensor_status.append(df.format(date));
        sensor_status.append(" (");
        sensor_status.append((System.currentTimeMillis() - sens.started_at) / (1000 * 60 * 60 * 24));
        sensor_status.append("d ");
        sensor_status.append(((System.currentTimeMillis() - sens.started_at) % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
        sensor_status.append("h)");
    } else {
        sensor_status.append("not available");
    }
    sensor_status_view.setText(sensor_status.toString());

}
 
Example 6
Source File: SensorStatus.java    From xDrip with GNU General Public License v3.0 6 votes vote down vote up
public static String status() {
    final StringBuilder sensor_status = new StringBuilder();
    if (Sensor.isActive()) {
        final Sensor sensor = Sensor.currentSensor();
        final Date date = new Date(sensor.started_at);
        DateFormat df = new SimpleDateFormat();
        sensor_status.append(df.format(date));
        sensor_status.append(" (");
        sensor_status.append((tsl() - sensor.started_at) / Constants.DAY_IN_MS);
        sensor_status.append("d ");
        sensor_status.append(((tsl() - sensor.started_at) % Constants.DAY_IN_MS) / Constants.HOUR_IN_MS);
        sensor_status.append("h)");
    } else {
        sensor_status.append("not available");
    }
    return sensor_status.toString();
}
 
Example 7
Source File: Home.java    From xDrip with GNU General Public License v3.0 5 votes vote down vote up
private void updateCurrentBgInfoForBtShare(TextView notificationText) {
    if ((android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.JELLY_BEAN_MR2)) {
        notificationText.setText(R.string.unfortunately_andoird_version_no_blueooth_low_energy);
        return;
    }

    String receiverSn = Pref.getString("share_key", "SM00000000").toUpperCase();
    if (receiverSn.compareTo("SM00000000") == 0 || receiverSn.length() == 0) {
        notificationText.setText(R.string.please_set_dex_receiver_serial_number);
        return;
    }

    if (receiverSn.length() < 10) {
        notificationText.setText(R.string.double_check_dex_receiver_serial_number);
        return;
    }

    if (ActiveBluetoothDevice.first() == null) {
        notificationText.setText(R.string.now_pair_with_your_dexcom_share);
        return;
    }

    if (!Sensor.isActive()) {
        notificationText.setText(R.string.now_choose_start_sensor_in_settings);
        return;
    }

    displayCurrentInfo();
}
 
Example 8
Source File: PebbleSync.java    From xDrip-Experimental with GNU General Public License v3.0 5 votes vote down vote up
public String bgReading() {
    Sensor sensor = new Sensor();
    if(PreferenceManager.getDefaultSharedPreferences(mContext).getString("dex_collection_method", "DexbridgeWixel").compareTo("DexbridgeWixel")==0 ) {
        Log.d(TAG, "bgReading: found xBridge wixel, sensor.isActive=" +sensor.isActive()+", sensor.stopped_at="+sensor.currentSensor().stopped_at+", sensor.started_at="+sensor.currentSensor().started_at);
        if (!(sensor.isActive())) {
            Log.d(TAG, "bgReading: No active Sensor");
            return "?SN";
        }
        if ((sensor.currentSensor().started_at + 60000 * 60 * 2 >= System.currentTimeMillis())) {
            return "?CD";
        }
    }
    return bgGraphBuilder.unitized_string(mBgReading.calculated_value);
}
 
Example 9
Source File: GcmActivity.java    From xDrip with GNU General Public License v3.0 5 votes vote down vote up
static synchronized void syncBGTable2() {
    if (!Sensor.isActive()) return;
    new Thread() {
        @Override
        public void run() {
            final PowerManager.WakeLock wl = JoH.getWakeLock("syncBGTable", 300000);
            //if ((JoH.ts() - last_sync_fill) > (60 * 1000 * (5 + bg_sync_backoff))) {
            if (JoH.pratelimit("last-sync-fill", 60 * (5 + bg_sync_backoff))) {
                last_sync_fill = JoH.tsl();
                bg_sync_backoff++;

                // Since this is a big update, also update sensor and calibrations
                syncSensor(Sensor.currentSensor(), true);

                final List<BgReading> bgReadings = BgReading.latestForGraph(300, JoH.tsl() - (24 * 60 * 60 * 1000));

                StringBuilder stringBuilder = new StringBuilder();
                for (BgReading bgReading : bgReadings) {
                    String myrecord = bgReading.toJSON(false);
                    if (stringBuilder.length() > 0) {
                        stringBuilder.append("^");
                    }
                    stringBuilder.append(myrecord);
                }
                final String mypacket = stringBuilder.toString();
                Log.d(TAG, "Total BGreading sync packet size: " + mypacket.length());
                if (mypacket.length() > 0) {
                    DisplayQRCode.uploadBytes(mypacket.getBytes(Charset.forName("UTF-8")), 2);
                } else {
                    Log.i(TAG, "Not uploading data due to zero length");
                }
            } else {
                Log.d(TAG, "Ignoring recent sync request, backoff: " + bg_sync_backoff);
            }
            JoH.releaseWakeLock(wl);
        }
    }.start();
}
 
Example 10
Source File: GcmActivity.java    From xDrip-plus with GNU General Public License v3.0 5 votes vote down vote up
static synchronized void syncBGTable2() {
    if (!Sensor.isActive()) return;
    new Thread() {
        @Override
        public void run() {
            final PowerManager.WakeLock wl = JoH.getWakeLock("syncBGTable", 300000);
            //if ((JoH.ts() - last_sync_fill) > (60 * 1000 * (5 + bg_sync_backoff))) {
            if (JoH.pratelimit("last-sync-fill", 60 * (5 + bg_sync_backoff))) {
                last_sync_fill = JoH.tsl();
                bg_sync_backoff++;

                // Since this is a big update, also update sensor and calibrations
                syncSensor(Sensor.currentSensor(), true);

                final List<BgReading> bgReadings = BgReading.latestForGraph(300, JoH.tsl() - (24 * 60 * 60 * 1000));

                StringBuilder stringBuilder = new StringBuilder();
                for (BgReading bgReading : bgReadings) {
                    String myrecord = bgReading.toJSON(false);
                    if (stringBuilder.length() > 0) {
                        stringBuilder.append("^");
                    }
                    stringBuilder.append(myrecord);
                }
                final String mypacket = stringBuilder.toString();
                Log.d(TAG, "Total BGreading sync packet size: " + mypacket.length());
                if (mypacket.length() > 0) {
                    DisplayQRCode.uploadBytes(mypacket.getBytes(Charset.forName("UTF-8")), 2);
                } else {
                    Log.i(TAG, "Not uploading data due to zero length");
                }
            } else {
                Log.d(TAG, "Ignoring recent sync request, backoff: " + bg_sync_backoff);
            }
            JoH.releaseWakeLock(wl);
        }
    }.start();
}
 
Example 11
Source File: StopSensor.java    From xDrip-plus with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    if(!Sensor.isActive()) {
        Intent intent = new Intent(this, StartNewSensor.class);
        startActivity(intent);
        finish();
    } else {
        JoH.fixActionBar(this);
        setContentView(R.layout.activity_stop_sensor);
        button = (Button)findViewById(R.id.stop_sensor);
        addListenerOnButton();
    }
}
 
Example 12
Source File: Home.java    From xDrip-plus with GNU General Public License v3.0 5 votes vote down vote up
private void updateCurrentBgInfoForBtShare(TextView notificationText) {
    if ((android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.JELLY_BEAN_MR2)) {
        notificationText.setText(R.string.unfortunately_andoird_version_no_blueooth_low_energy);
        return;
    }

    String receiverSn = Pref.getString("share_key", "SM00000000").toUpperCase();
    if (receiverSn.compareTo("SM00000000") == 0 || receiverSn.length() == 0) {
        notificationText.setText(R.string.please_set_dex_receiver_serial_number);
        return;
    }

    if (receiverSn.length() < 10) {
        notificationText.setText(R.string.double_check_dex_receiver_serial_number);
        return;
    }

    if (ActiveBluetoothDevice.first() == null) {
        notificationText.setText(R.string.now_pair_with_your_dexcom_share);
        return;
    }

    if (!Sensor.isActive()) {
        notificationText.setText(R.string.now_choose_start_sensor_in_settings);
        return;
    }

    displayCurrentInfo();
}
 
Example 13
Source File: SystemStatus.java    From xDrip-plus with GNU General Public License v3.0 5 votes vote down vote up
private void setSensorStatus(){
    StringBuilder sensor_status= new StringBuilder();
    if(Sensor.isActive()){
        Sensor sens = Sensor.currentSensor();
        Date date = new Date(sens.started_at);
        DateFormat df = new SimpleDateFormat();
        sensor_status.append(df.format(date));
        sensor_status.append(" (");
        sensor_status.append((System.currentTimeMillis() - sens.started_at) / (1000 * 60 * 60 * 24));
        sensor_status.append("d ");
        sensor_status.append(((System.currentTimeMillis() - sens.started_at) % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
        sensor_status.append("h)");
    } else {
        sensor_status.append("not available");
    }
    sensor_status_view.setText(sensor_status.toString());

}
 
Example 14
Source File: Home.java    From xDrip-Experimental with GNU General Public License v3.0 5 votes vote down vote up
private void updateCurrentBgInfoForBtShare(TextView notificationText) {
    if ((android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.JELLY_BEAN_MR2)) {
        notificationText.setText("Unfortunately your android version does not support Bluetooth Low Energy");
        return;
    }

    String receiverSn = mPreferences.getString("share_key", "SM00000000").toUpperCase();
    if (receiverSn.compareTo("SM00000000") == 0 || receiverSn.length() == 0) {
        notificationText.setText("Please set your Dex Receiver Serial Number in App Settings");
        return;
    }

    if (receiverSn.length() < 10) {
        notificationText.setText("Double Check Dex Receiver Serial Number, should be 10 characters, don't forget the letters");
        return;
    }

    if (ActiveBluetoothDevice.first() == null) {
        notificationText.setText("Now pair with your Dexcom Share");
        return;
    }

    if (!Sensor.isActive()) {
        notificationText.setText("Now choose start your sensor in your settings");
        return;
    }

    displayCurrentInfo();
}
 
Example 15
Source File: G5CollectionService.java    From xDrip-Experimental with GNU General Public License v3.0 5 votes vote down vote up
@Override
public int onStartCommand(Intent intent, int flags, int startId) {

    Log.e(TAG, "onG5StartCommand");
    //Log.d(TAG, "SDK: " + Build.VERSION.SDK_INT);
    //stopScan();

    scanCycleCount = 0;
    mBluetoothManager = (BluetoothManager) getSystemService(Context.BLUETOOTH_SERVICE);
    mBluetoothAdapter = mBluetoothManager.getAdapter();

    if (mGatt != null) {
        mGatt.close();
        mGatt = null;
    }

    if (Sensor.isActive()){
        setupBluetooth();
        Log.d(TAG, "Active Sensor");

    } else {
        stopScan();
        Log.d(TAG, "No Active Sensor");
    }

    return START_STICKY;
}
 
Example 16
Source File: SensorDays.java    From xDrip with GNU General Public License v3.0 4 votes vote down vote up
private boolean isSessionLive() {
    return Sensor.isActive();
}
 
Example 17
Source File: MissedReadingService.java    From xDrip-plus with GNU General Public License v3.0 4 votes vote down vote up
@Override
protected void onHandleIntent(Intent intent) {
    final SharedPreferences prefs;
    final boolean bg_missed_alerts;
    final Context context;
    final int bg_missed_minutes;


    context = getApplicationContext();
    prefs = PreferenceManager.getDefaultSharedPreferences(context);

    Log.d(TAG, "MissedReadingService onHandleIntent");

    final long stale_millis = Home.stale_data_millis();

    // send to pebble
    /*if (prefs.getBoolean("broadcast_to_pebble", false) && (PebbleUtil.getCurrentPebbleSyncType(prefs) != 1) && !BgReading.last_within_millis(stale_millis)) {
        if (JoH.ratelimit("peb-miss",120)) context.startService(new Intent(context, PebbleWatchSync.class));
        // update pebble even when we don't have data to ensure missed readings show
    }*/

    /*if ((Home.get_forced_wear()) && prefs.getBoolean("disable_wearG5_on_missedreadings", false)) {
        int bg_wear_missed_minutes = readPerfsInt(prefs, "disable_wearG5_on_missedreadings_level", 30);
        if (BgReading.getTimeSinceLastReading() >= (bg_wear_missed_minutes * 1000 * 60)) {
            Log.d(TAG, "Request WatchUpdaterService to disable force_wearG5 when wear is connected");
            startWatchUpdaterService(context, WatchUpdaterService.ACTION_DISABLE_FORCE_WEAR, TAG);
        }
    }*/

    if ((prefs.getBoolean("aggressive_service_restart", false) || DexCollectionType.isFlakey())) {//!Home.get_enable_wear() &&
        if (!BgReading.last_within_millis(stale_millis) && Sensor.isActive() && (!getLocalServiceCollectingState())) {
            if (JoH.ratelimit("aggressive-restart", aggressive_backoff_timer)) {
                Log.e(TAG, "Aggressively restarting collector service due to lack of reception: backoff: "+aggressive_backoff_timer);
                if (aggressive_backoff_timer < 1200) aggressive_backoff_timer+=60;
                CollectionServiceStarter.startBtService(context);
            } else {
                aggressive_backoff_timer = 120; // reset
            }
        }
    }
    //Reminder.processAnyDueReminders();
    //BluetoothGlucoseMeter.immortality();

    bg_missed_alerts =  prefs.getBoolean("bg_missed_alerts", false);//KS TODO bg_missed_alerts pref not supported
    if (!bg_missed_alerts || !Pref.getBoolean("bg_notifications", false)) {
        // we should not do anything in this case. if the ui, changes will be called again
        return;
    }

    bg_missed_minutes =  readPerfsInt(prefs, "bg_missed_minutes", 30);
    final long now = new Date().getTime();

    if (BgReading.getTimeSinceLastReading() >= (bg_missed_minutes * 1000 * 60) &&
            prefs.getLong("alerts_disabled_until", 0) <= now &&
            inTimeFrame(prefs)) {
        Notifications.bgMissedAlert(context);
        checkBackAfterSnoozeTime(context, now);
    } else  {

        long disabletime = prefs.getLong("alerts_disabled_until", 0) - now;

        long missedTime = bg_missed_minutes* 1000 * 60 - BgReading.getTimeSinceLastReading();
        long alarmIn = Math.max(disabletime, missedTime);
        checkBackAfterMissedTime(alarmIn);
    }
}
 
Example 18
Source File: MissedReadingService.java    From xDrip with GNU General Public License v3.0 4 votes vote down vote up
@Override
protected void onHandleIntent(Intent intent) {
    final boolean bg_missed_alerts;

    final PowerManager.WakeLock wl = JoH.getWakeLock("missed-reading-service", 60000);
    try {

        final boolean sensorActive = Sensor.isActive();

        Log.d(TAG, "MissedReadingService onHandleIntent"); // test debug log

        final long stale_millis = Home.stale_data_millis();


        // send to pebble
        if (Pref.getBoolean("broadcast_to_pebble", false) && (PebbleUtil.getCurrentPebbleSyncType() != 1) && !BgReading.last_within_millis(stale_millis)) {
            if (JoH.ratelimit("peb-miss", 120)) {
                // TODO replace ratelimit with Inevitable.task?
                JoH.startService(PebbleWatchSync.class);
            }
            // update pebble even when we don't have data to ensure missed readings show
        }

        if (LeFunEntry.isEnabled() && (!BgReading.last_within_millis(stale_millis))) {
            LeFun.showLatestBG();
        }


        if ((Pref.getBoolean("aggressive_service_restart", false) || DexCollectionType.isFlakey())) {//!Home.get_enable_wear() &&
            if (!BgReading.last_within_millis(stale_millis) && sensorActive && (!getLocalServiceCollectingState())) {
                if (JoH.ratelimit("aggressive-restart", aggressive_backoff_timer)) {
                    Log.e(TAG, "Aggressively restarting collector service due to lack of reception: backoff: " + aggressive_backoff_timer);
                    if (aggressive_backoff_timer < 1200) aggressive_backoff_timer += 60;
                    CollectionServiceStarter.restartCollectionServiceBackground();
                } else {
                    aggressive_backoff_timer = 120; // reset
                }
            }
        }


        Reminder.processAnyDueReminders();
        BluetoothGlucoseMeter.immortality();
        XdripWebService.immortality(); //
        InPenEntry.immortality();
        DesertSync.pullAsEnabled();
        NanoStatus.keepFollowerUpdated();
        LockScreenWallPaper.timerPoll();

        // TODO functionalize the actual checking
        bg_missed_alerts = Pref.getBoolean("bg_missed_alerts", false);
        if (!bg_missed_alerts) {
            // we should not do anything in this case. if the ui, changes will be called again
            return;
        }
        if (!sensorActive) {
            // sensor not running we should return
            return;
        }

        if (!JoH.upForAtLeastMins(15)) {
            Log.d(TAG, "Uptime less than 15 minutes so not processing for missed reading");
            return;
        }


        if ((Home.get_forced_wear()) && Pref.getBoolean("disable_wearG5_on_missedreadings", false)) {
            int bg_wear_missed_minutes = Pref.getStringToInt("disable_wearG5_on_missedreadings_level", 30);
            if (BgReading.getTimeSinceLastReading() >= (bg_wear_missed_minutes * 1000 * 60)) {
                Log.d(TAG, "Request WatchUpdaterService to disable force_wearG5 when wear is connected");
                startWatchUpdaterService(xdrip.getAppContext(), WatchUpdaterService.ACTION_DISABLE_FORCE_WEAR, TAG);
            }
        }

        final int bg_missed_minutes = Pref.getStringToInt("bg_missed_minutes", 30);
        final long now = JoH.tsl();

        // check if readings have been missed
        if (BgReading.getTimeSinceLastReading() >= (bg_missed_minutes * 1000 * 60) &&
                Pref.getLong("alerts_disabled_until", 0) <= now &&
                (BgReading.getTimeSinceLastReading() < (Constants.HOUR_IN_MS * 6)) &&
                inTimeFrame()) {
            Notifications.bgMissedAlert(xdrip.getAppContext());
            checkBackAfterSnoozeTime(xdrip.getAppContext(), now);
        } else {

            long disabletime = Pref.getLong("alerts_disabled_until", 0) - now;

            long missedTime = bg_missed_minutes * 1000 * 60 - BgReading.getTimeSinceLastReading();
            long alarmIn = Math.max(disabletime, missedTime);
            checkBackAfterMissedTime(alarmIn);
        }
    } finally {
        JoH.releaseWakeLock(wl);
    }
}
 
Example 19
Source File: MissedReadingService.java    From xDrip with GNU General Public License v3.0 4 votes vote down vote up
@Override
protected void onHandleIntent(Intent intent) {
    final SharedPreferences prefs;
    final boolean bg_missed_alerts;
    final Context context;
    final int bg_missed_minutes;


    context = getApplicationContext();
    prefs = PreferenceManager.getDefaultSharedPreferences(context);

    Log.d(TAG, "MissedReadingService onHandleIntent");

    final long stale_millis = Home.stale_data_millis();

    // send to pebble
    /*if (prefs.getBoolean("broadcast_to_pebble", false) && (PebbleUtil.getCurrentPebbleSyncType(prefs) != 1) && !BgReading.last_within_millis(stale_millis)) {
        if (JoH.ratelimit("peb-miss",120)) context.startService(new Intent(context, PebbleWatchSync.class));
        // update pebble even when we don't have data to ensure missed readings show
    }*/

    /*if ((Home.get_forced_wear()) && prefs.getBoolean("disable_wearG5_on_missedreadings", false)) {
        int bg_wear_missed_minutes = readPerfsInt(prefs, "disable_wearG5_on_missedreadings_level", 30);
        if (BgReading.getTimeSinceLastReading() >= (bg_wear_missed_minutes * 1000 * 60)) {
            Log.d(TAG, "Request WatchUpdaterService to disable force_wearG5 when wear is connected");
            startWatchUpdaterService(context, WatchUpdaterService.ACTION_DISABLE_FORCE_WEAR, TAG);
        }
    }*/

    if ((prefs.getBoolean("aggressive_service_restart", false) || DexCollectionType.isFlakey())) {//!Home.get_enable_wear() &&
        if (!BgReading.last_within_millis(stale_millis) && Sensor.isActive() && (!getLocalServiceCollectingState())) {
            if (JoH.ratelimit("aggressive-restart", aggressive_backoff_timer)) {
                Log.e(TAG, "Aggressively restarting collector service due to lack of reception: backoff: "+aggressive_backoff_timer);
                if (aggressive_backoff_timer < 1200) aggressive_backoff_timer+=60;
                CollectionServiceStarter.startBtService(context);
            } else {
                aggressive_backoff_timer = 120; // reset
            }
        }
    }
    //Reminder.processAnyDueReminders();
    //BluetoothGlucoseMeter.immortality();

    bg_missed_alerts =  prefs.getBoolean("bg_missed_alerts", false);//KS TODO bg_missed_alerts pref not supported
    if (!bg_missed_alerts || !Pref.getBoolean("bg_notifications", false)) {
        // we should not do anything in this case. if the ui, changes will be called again
        return;
    }

    bg_missed_minutes =  readPerfsInt(prefs, "bg_missed_minutes", 30);
    final long now = new Date().getTime();

    if (BgReading.getTimeSinceLastReading() >= (bg_missed_minutes * 1000 * 60) &&
            prefs.getLong("alerts_disabled_until", 0) <= now &&
            inTimeFrame(prefs)) {
        Notifications.bgMissedAlert(context);
        checkBackAfterSnoozeTime(context, now);
    } else  {

        long disabletime = prefs.getLong("alerts_disabled_until", 0) - now;

        long missedTime = bg_missed_minutes* 1000 * 60 - BgReading.getTimeSinceLastReading();
        long alarmIn = Math.max(disabletime, missedTime);
        checkBackAfterMissedTime(alarmIn);
    }
}
 
Example 20
Source File: SensorDays.java    From xDrip-plus with GNU General Public License v3.0 4 votes vote down vote up
private boolean isSessionLive() {
    return Sensor.isActive();
}