com.eveningoutpost.dexdrip.UtilityModels.CollectionServiceStarter Java Examples

The following examples show how to use com.eveningoutpost.dexdrip.UtilityModels.CollectionServiceStarter. 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: ListenerService.java    From xDrip-plus with GNU General Public License v3.0 6 votes vote down vote up
private synchronized void startBtService() {//KS
    Log.d(TAG, "startBtService");
    if (is_using_bt) {
        if (checkLocationPermissions()) {
            Log.d(TAG, "startBtService start BT Collection Service: " + DexCollectionType.getDexCollectionType());
            //if (restartWatchDog()) {
            //    stopBtService();
            //}
            if (!isCollectorRunning()) {
                if (JoH.ratelimit("start-collector", 2)) {
                    CollectionServiceStarter.startBtService(getApplicationContext());
                }
                Log.d(TAG, "startBtService AFTER startService mLocationPermissionApproved " + mLocationPermissionApproved);
            } else {
                Log.d(TAG, "startBtService collector already running!");
            }
        }
    }
}
 
Example #2
Source File: StopSensor.java    From xDrip-plus with GNU General Public License v3.0 6 votes vote down vote up
public synchronized static void stop() {
    Sensor.stopSensor();
    Inevitable.task("stop-sensor",1000, Sensor::stopSensor);
    AlertPlayer.getPlayer().stopAlert(xdrip.getAppContext(), true, false);

    JoH.static_toast_long(gs(R.string.sensor_stopped));
    JoH.clearCache();
    LibreAlarmReceiver.clearSensorStats();
    PluggableCalibration.invalidateAllCaches();

    Ob1G5StateMachine.stopSensor();

    CollectionServiceStarter.restartCollectionServiceBackground();
    Home.staticRefreshBGCharts();
    NanoStatus.keepFollowerUpdated(false);
}
 
Example #3
Source File: StartNewSensor.java    From xDrip with GNU General Public License v3.0 6 votes vote down vote up
public void addListenerOnButton() {

        button = (Button)findViewById(R.id.startNewSensor);

        button.setOnClickListener(new View.OnClickListener() {
          public void onClick(View v) {

              Calendar calendar = Calendar.getInstance();
              calendar.set(dp.getYear(), dp.getMonth(), dp.getDayOfMonth(),
              tp.getCurrentHour(), tp.getCurrentMinute(), 0);
              long startTime = calendar.getTime().getTime();

              Sensor sensor = Sensor.create(startTime);
              Log.w("NEW SENSOR", "Sensor started at " + startTime);

              Toast.makeText(getApplicationContext(), "NEW SENSOR STARTED", Toast.LENGTH_LONG).show();
              Intent intent = new Intent(getApplicationContext(), Home.class);
              CollectionServiceStarter.newStart(getApplicationContext());
              startActivity(intent);
              finish();
          }

        });
    }
 
Example #4
Source File: SystemStatus.java    From xDrip-plus with GNU General Public License v3.0 6 votes vote down vote up
private void restartButtonListener() {
    restart_collection_service.setOnClickListener(new View.OnClickListener() {
        public void onClick(final View v) {
            v.setEnabled(false);
            JoH.static_toast_short(gs(R.string.restarting_collector));
            v.setAlpha(0.2f);
            CollectionServiceStarter.restartCollectionService(getApplicationContext());
            set_current_values();
            JoH.runOnUiThreadDelayed(new Runnable() {
                @Override
                public void run() {
                    v.setEnabled(true);
                    v.setAlpha(1.0f);
                    set_current_values();
                }
            }, 2000);
        }
    });
}
 
Example #5
Source File: SystemStatusFragment.java    From xDrip-plus with GNU General Public License v3.0 6 votes vote down vote up
private void restartButtonListener() {
    restart_collection_service.setOnClickListener(new View.OnClickListener() {
        public void onClick(final View v) {
            v.setEnabled(false);
            JoH.static_toast_short(gs(R.string.restarting_collector));
            v.setAlpha(0.2f);
            startWatchUpdaterService(safeGetContext(), WatchUpdaterService.ACTION_START_COLLECTOR, TAG);
            CollectionServiceStarter.restartCollectionService(safeGetContext());
            set_current_values();
            JoH.runOnUiThreadDelayed(new Runnable() {
                @Override
                public void run() {
                    v.setEnabled(true);
                    v.setAlpha(1.0f);
                    set_current_values();
                }
            }, 2000);
        }
    });
}
 
Example #6
Source File: DexShareCollectionService.java    From xDrip with GNU General Public License v3.0 6 votes vote down vote up
public void setFailoverTimer() { //Sometimes it gets stuck in limbo on 4.4, this should make it try again
    if (CollectionServiceStarter.isBTShare(getApplicationContext())) {
        long retry_in = (1000 * 60 * 5);
        Log.d(TAG, "Fallover Restarting in: " + (retry_in / (60 * 1000)) + " minutes");
        Calendar calendar = Calendar.getInstance();
        AlarmManager alarm = (AlarmManager) getSystemService(ALARM_SERVICE);
        if (pendingIntent != null)
            alarm.cancel(pendingIntent);
        long wakeTime = calendar.getTimeInMillis() + retry_in;
        pendingIntent = PendingIntent.getService(this, 0, new Intent(this, this.getClass()), 0);
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
            alarm.setExactAndAllowWhileIdle(AlarmManager.RTC_WAKEUP, wakeTime, pendingIntent);
        } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
            alarm.setExact(AlarmManager.RTC_WAKEUP, wakeTime, pendingIntent);
        } else
            alarm.set(AlarmManager.RTC_WAKEUP, wakeTime, pendingIntent);
    } else {
        stopSelf();
    }
}
 
Example #7
Source File: DexShareCollectionService.java    From xDrip with GNU General Public License v3.0 6 votes vote down vote up
public void setRetryTimer() {
    if (CollectionServiceStarter.isBTShare(getApplicationContext())) {
        BgReading bgReading = BgReading.last();
        long retry_in;
        if (bgReading != null) {
            retry_in = Math.min(Math.max((1000 * 30), (1000 * 60 * 5) - (new Date().getTime() - bgReading.timestamp) + (1000 * 5)), (1000 * 60 * 5));
        } else {
            retry_in = (1000 * 20);
        }
        Log.d(TAG, "Restarting in: " + (retry_in / (60 * 1000)) + " minutes");
        Calendar calendar = Calendar.getInstance();
        AlarmManager alarm = (AlarmManager) getSystemService(ALARM_SERVICE);
        if (pendingIntent != null)
            alarm.cancel(pendingIntent);
        long wakeTime = calendar.getTimeInMillis() + retry_in;
        pendingIntent = PendingIntent.getService(this, 0, new Intent(this, this.getClass()), 0);
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
            alarm.setExactAndAllowWhileIdle(AlarmManager.RTC_WAKEUP, wakeTime, pendingIntent);
        } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
            alarm.setExact(AlarmManager.RTC_WAKEUP, wakeTime, pendingIntent);
        } else
            alarm.set(AlarmManager.RTC_WAKEUP, wakeTime, pendingIntent);
    }
}
 
Example #8
Source File: ListenerService.java    From xDrip with GNU General Public License v3.0 6 votes vote down vote up
private synchronized void startBtService() {//KS
    Log.d(TAG, "startBtService");
    if (is_using_bt) {
        if (checkLocationPermissions()) {
            Log.d(TAG, "startBtService start BT Collection Service: " + DexCollectionType.getDexCollectionType());
            //if (restartWatchDog()) {
            //    stopBtService();
            //}
            if (!isCollectorRunning()) {
                if (JoH.ratelimit("start-collector", 2)) {
                    CollectionServiceStarter.startBtService(getApplicationContext());
                }
                Log.d(TAG, "startBtService AFTER startService mLocationPermissionApproved " + mLocationPermissionApproved);
            } else {
                Log.d(TAG, "startBtService collector already running!");
            }
        }
    }
}
 
Example #9
Source File: WifiCollectionService.java    From xDrip-Experimental with GNU General Public License v3.0 6 votes vote down vote up
public void setFailoverTimer() {
    Log.d(TAG, "setFailoverTimer called \n");
    if (CollectionServiceStarter.isWifiWixel(getApplicationContext())
            || CollectionServiceStarter.isWifiandBTWixel(getApplicationContext())
            || CollectionServiceStarter.isWifiandDexbridgeWixel(getApplicationContext())) {
        long retry_in = WixelReader.timeForNextRead();
        Log.e(TAG, "setFailoverTimer: Fallover Restarting in: " + (retry_in / (60 * 1000)) + " minutes");
        Calendar calendar = Calendar.getInstance();
        AlarmManager alarm = (AlarmManager) getSystemService(ALARM_SERVICE);
        
        long wakeTime = calendar.getTimeInMillis() + retry_in;
        PendingIntent serviceIntent = PendingIntent.getService(this, 0, new Intent(this, this.getClass()), 0);
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
            alarm.setExactAndAllowWhileIdle(AlarmManager.RTC_WAKEUP, wakeTime, serviceIntent);
        } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
            alarm.setExact(AlarmManager.RTC_WAKEUP, wakeTime, serviceIntent);
        } else
            alarm.set(AlarmManager.RTC_WAKEUP, wakeTime, serviceIntent);
        
    } else {
        stopSelf();
    }
}
 
Example #10
Source File: Ob1G5CollectionService.java    From xDrip-plus with GNU General Public License v3.0 6 votes vote down vote up
private static boolean shouldServiceRun() {
    if (android.os.Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) return false;
    if (!Pref.getBooleanDefaultFalse(OB1G5_PREFS)) return false;
    if (!(DexCollectionType.getDexCollectionType() == DexcomG5)) return false;

    if (!android_wear) {
        if (Home.get_forced_wear()) {
            if (JoH.quietratelimit("forced-wear-notice", 3))
                UserError.Log.d(TAG, "Not running due to forced wear");
            return false;
        }

        if (BlueJayEntry.isPhoneCollectorDisabled()) {
            UserError.Log.d(TAG,"Not running as BlueJay is collector");
            return false;
        }

    } else {
        // android wear code
        if (!PersistentStore.getBoolean(CollectionServiceStarter.pref_run_wear_collector))
            return false;
    }
    return true;
}
 
Example #11
Source File: DexShareCollectionService.java    From xDrip-plus with GNU General Public License v3.0 6 votes vote down vote up
public void setFailoverTimer() { //Sometimes it gets stuck in limbo on 4.4, this should make it try again
    if (CollectionServiceStarter.isBTShare(getApplicationContext())) {
        long retry_in = (1000 * 60 * 5);
        Log.d(TAG, "Fallover Restarting in: " + (retry_in / (60 * 1000)) + " minutes");
        Calendar calendar = Calendar.getInstance();
        AlarmManager alarm = (AlarmManager) getSystemService(ALARM_SERVICE);
        if (pendingIntent != null)
            alarm.cancel(pendingIntent);
        long wakeTime = calendar.getTimeInMillis() + retry_in;
        pendingIntent = PendingIntent.getService(this, 0, new Intent(this, this.getClass()), 0);
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
            alarm.setExactAndAllowWhileIdle(AlarmManager.RTC_WAKEUP, wakeTime, pendingIntent);
        } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
            alarm.setExact(AlarmManager.RTC_WAKEUP, wakeTime, pendingIntent);
        } else
            alarm.set(AlarmManager.RTC_WAKEUP, wakeTime, pendingIntent);
    } else {
        stopSelf();
    }
}
 
Example #12
Source File: DexShareCollectionService.java    From xDrip with GNU General Public License v3.0 6 votes vote down vote up
public void setRetryTimer() {
    if (CollectionServiceStarter.isBTShare(getApplicationContext())) {
        BgReading bgReading = BgReading.last();
        long retry_in;
        if (bgReading != null) {
            retry_in = Math.min(Math.max((1000 * 30), (1000 * 60 * 5) - (new Date().getTime() - bgReading.timestamp) + (1000 * 5)), (1000 * 60 * 5));
        } else {
            retry_in = (1000 * 20);
        }
        Log.d(TAG, "Restarting in: " + (retry_in / (60 * 1000)) + " minutes");
        Calendar calendar = Calendar.getInstance();
        AlarmManager alarm = (AlarmManager) getSystemService(ALARM_SERVICE);
        if (pendingIntent != null)
            alarm.cancel(pendingIntent);
        long wakeTime = calendar.getTimeInMillis() + retry_in;
        pendingIntent = PendingIntent.getService(this, 0, new Intent(this, this.getClass()),  PendingIntent.FLAG_UPDATE_CURRENT);
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
            alarm.setExactAndAllowWhileIdle(AlarmManager.RTC_WAKEUP, wakeTime, pendingIntent);
        } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
            alarm.setExact(AlarmManager.RTC_WAKEUP, wakeTime, pendingIntent);
        } else
            alarm.set(AlarmManager.RTC_WAKEUP, wakeTime, pendingIntent);
    }
}
 
Example #13
Source File: Calibration.java    From xDrip-plus with GNU General Public License v3.0 6 votes vote down vote up
@NonNull
private static SlopeParameters getSlopeParameters() {

    if (CollectionServiceStarter.isLibre2App((Context)null)) {
        return new Li2AppParameters();
    }

    if (CollectionServiceStarter.isLimitter()) {
        if (Pref.getBooleanDefaultFalse("use_non_fixed_li_parameters")) {
            return new LiParametersNonFixed();
        } else {
            return new LiParameters();
        }
    }
    // open question about parameters used with LibreAlarm

    if (Pref.getBooleanDefaultFalse("engineering_mode") && Pref.getBooleanDefaultFalse("old_school_calibration_mode")) {
        JoH.static_toast_long("Using old pre-2017 calibration mode!");
        return new DexOldSchoolParameters();
    }

    return new DexParameters();
}
 
Example #14
Source File: DexShareCollectionService.java    From xDrip with GNU General Public License v3.0 6 votes vote down vote up
public void setFailoverTimer() { //Sometimes it gets stuck in limbo on 4.4, this should make it try again
    if (CollectionServiceStarter.isBTShare(getApplicationContext())) {
        long retry_in = (1000 * 60 * 5);
        Log.d(TAG, "Fallover Restarting in: " + (retry_in / (60 * 1000)) + " minutes");
        Calendar calendar = Calendar.getInstance();
        AlarmManager alarm = (AlarmManager) getSystemService(ALARM_SERVICE);
        if (pendingIntent != null)
            alarm.cancel(pendingIntent);
        long wakeTime = calendar.getTimeInMillis() + retry_in;
        pendingIntent = PendingIntent.getService(this, 0, new Intent(this, this.getClass()), 0);
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
            alarm.setExactAndAllowWhileIdle(AlarmManager.RTC_WAKEUP, wakeTime, pendingIntent);
        } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
            alarm.setExact(AlarmManager.RTC_WAKEUP, wakeTime, pendingIntent);
        } else
            alarm.set(AlarmManager.RTC_WAKEUP, wakeTime, pendingIntent);
    } else {
        stopSelf();
    }
}
 
Example #15
Source File: DexShareCollectionService.java    From xDrip-plus with GNU General Public License v3.0 6 votes vote down vote up
public void setFailoverTimer() { //Sometimes it gets stuck in limbo on 4.4, this should make it try again
    if (CollectionServiceStarter.isBTShare(getApplicationContext())) {
        long retry_in = (1000 * 60 * 5);
        Log.d(TAG, "Fallover Restarting in: " + (retry_in / (60 * 1000)) + " minutes");
        Calendar calendar = Calendar.getInstance();
        AlarmManager alarm = (AlarmManager) getSystemService(ALARM_SERVICE);
        if (pendingIntent != null)
            alarm.cancel(pendingIntent);
        long wakeTime = calendar.getTimeInMillis() + retry_in;
        pendingIntent = PendingIntent.getService(this, 0, new Intent(this, this.getClass()), 0);
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
            alarm.setExactAndAllowWhileIdle(AlarmManager.RTC_WAKEUP, wakeTime, pendingIntent);
        } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
            alarm.setExact(AlarmManager.RTC_WAKEUP, wakeTime, pendingIntent);
        } else
            alarm.set(AlarmManager.RTC_WAKEUP, wakeTime, pendingIntent);
    } else {
        stopSelf();
    }
}
 
Example #16
Source File: DexShareCollectionService.java    From xDrip with GNU General Public License v3.0 6 votes vote down vote up
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
    if (android.os.Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT){
        stopSelf();
        return START_NOT_STICKY;
    }
    if (CollectionServiceStarter.isBTShare(getApplicationContext())) {
        setFailoverTimer();
    } else {
        stopSelf();
        return START_NOT_STICKY;
    }
    if (Sensor.currentSensor() == null) {
        setRetryTimer();
        return START_NOT_STICKY;
    }
    Log.w(TAG, "STARTING SERVICE");
    attemptConnection();
    return START_STICKY;
}
 
Example #17
Source File: SystemStatusFragment.java    From xDrip with GNU General Public License v3.0 6 votes vote down vote up
private void restartButtonListener() {
    restart_collection_service.setOnClickListener(new View.OnClickListener() {
        public void onClick(final View v) {
            v.setEnabled(false);
            JoH.static_toast_short(gs(R.string.restarting_collector));
            v.setAlpha(0.2f);
            startWatchUpdaterService(safeGetContext(), WatchUpdaterService.ACTION_START_COLLECTOR, TAG);
            CollectionServiceStarter.restartCollectionService(safeGetContext());
            set_current_values();
            JoH.runOnUiThreadDelayed(new Runnable() {
                @Override
                public void run() {
                    v.setEnabled(true);
                    v.setAlpha(1.0f);
                    set_current_values();
                }
            }, 2000);
        }
    });
}
 
Example #18
Source File: SystemStatus.java    From xDrip with GNU General Public License v3.0 6 votes vote down vote up
private void restartButtonListener() {
    restart_collection_service.setOnClickListener(new View.OnClickListener() {
        public void onClick(final View v) {
            v.setEnabled(false);
            JoH.static_toast_short(gs(R.string.restarting_collector));
            v.setAlpha(0.2f);
            CollectionServiceStarter.restartCollectionService(getApplicationContext());
            set_current_values();
            JoH.runOnUiThreadDelayed(new Runnable() {
                @Override
                public void run() {
                    v.setEnabled(true);
                    v.setAlpha(1.0f);
                    set_current_values();
                }
            }, 2000);
        }
    });
}
 
Example #19
Source File: DexCollectionService.java    From xDrip-Experimental with GNU General Public License v3.0 6 votes vote down vote up
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
    if (android.os.Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR2){
        stopSelf();
        return START_NOT_STICKY;
    }
    if (CollectionServiceStarter.isBteWixelorWifiandBtWixel(getApplicationContext())
            || CollectionServiceStarter.isDexbridgeWixelorWifiandDexbridgeWixel(getApplicationContext())) {
        setFailoverTimer();
    } else {
        stopSelf();
        return START_NOT_STICKY;
    }
    lastdata = null;
    attemptConnection();
    return START_STICKY;
}
 
Example #20
Source File: Ob1G5CollectionService.java    From xDrip-plus with GNU General Public License v3.0 6 votes vote down vote up
private static boolean shouldServiceRun() {
    if (android.os.Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) return false;
    if (!Pref.getBooleanDefaultFalse(OB1G5_PREFS)) return false;
    if (!(DexCollectionType.getDexCollectionType() == DexcomG5)) return false;

    if (!android_wear) {
        if (Home.get_forced_wear()) {
            if (JoH.quietratelimit("forced-wear-notice", 3))
                UserError.Log.d(TAG, "Not running due to forced wear");
            return false;
        }
    } else {
        // android wear code
        if (!PersistentStore.getBoolean(CollectionServiceStarter.pref_run_wear_collector))
            return false;
    }
    return true;
}
 
Example #21
Source File: StopSensor.java    From xDrip with GNU General Public License v3.0 6 votes vote down vote up
public synchronized static void stop() {
    Sensor.stopSensor();
    Inevitable.task("stop-sensor",1000, Sensor::stopSensor);
    AlertPlayer.getPlayer().stopAlert(xdrip.getAppContext(), true, false);

    JoH.static_toast_long(gs(R.string.sensor_stopped));
    JoH.clearCache();
    LibreAlarmReceiver.clearSensorStats();
    PluggableCalibration.invalidateAllCaches();

    Ob1G5StateMachine.stopSensor();

    CollectionServiceStarter.restartCollectionServiceBackground();
    Home.staticRefreshBGCharts();
    NanoStatus.keepFollowerUpdated(false);
}
 
Example #22
Source File: DexCollectionService.java    From xDrip-Experimental with GNU General Public License v3.0 6 votes vote down vote up
public void setFailoverTimer() {
    if (CollectionServiceStarter.isBteWixelorWifiandBtWixel(getApplicationContext())
            || CollectionServiceStarter.isDexbridgeWixelorWifiandDexbridgeWixel(getApplicationContext())) {

        long retry_in = (1000 * 60 * 6);
        Log.d(TAG, "setFailoverTimer: Fallover Restarting in: " + (retry_in / (60 * 1000)) + " minutes");
        Calendar calendar = Calendar.getInstance();
        AlarmManager alarm = (AlarmManager) getSystemService(ALARM_SERVICE);
        long wakeTime = calendar.getTimeInMillis() + retry_in;
        PendingIntent serviceIntent = PendingIntent.getService(this, 0, new Intent(this, this.getClass()), 0);
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
            alarm.setExactAndAllowWhileIdle(AlarmManager.RTC_WAKEUP, wakeTime, serviceIntent);
        } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
            alarm.setExact(AlarmManager.RTC_WAKEUP, wakeTime, serviceIntent);
        } else
            alarm.set(AlarmManager.RTC_WAKEUP, wakeTime, serviceIntent);
    } else {
        stopSelf();
    }
}
 
Example #23
Source File: Ob1G5CollectionService.java    From xDrip with GNU General Public License v3.0 6 votes vote down vote up
private static boolean shouldServiceRun() {
    if (android.os.Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) return false;
    if (!Pref.getBooleanDefaultFalse(OB1G5_PREFS)) return false;
    if (!(DexCollectionType.getDexCollectionType() == DexcomG5)) return false;

    if (!android_wear) {
        if (Home.get_forced_wear()) {
            if (JoH.quietratelimit("forced-wear-notice", 3))
                UserError.Log.d(TAG, "Not running due to forced wear");
            return false;
        }

        if (BlueJayEntry.isPhoneCollectorDisabled()) {
            UserError.Log.d(TAG,"Not running as BlueJay is collector");
            return false;
        }

    } else {
        // android wear code
        if (!PersistentStore.getBoolean(CollectionServiceStarter.pref_run_wear_collector))
            return false;
    }
    return true;
}
 
Example #24
Source File: Calibration.java    From xDrip with GNU General Public License v3.0 5 votes vote down vote up
@NonNull
private static SlopeParameters getSlopeParameters() {

    if (CollectionServiceStarter.isLimitter()) {
        return new LiParameters();
    }

    if (Pref.getBooleanDefaultFalse("engineering_mode") && Pref.getBooleanDefaultFalse("old_school_calibration_mode")) {
        JoH.static_toast_long("Using old pre-2017 calibration mode!");
        return new DexOldSchoolParameters();
    }

    return new DexParameters();
}
 
Example #25
Source File: DoubleCalibrationActivity.java    From xDrip-plus with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    xdrip.checkForcedEnglish(this);
    super.onCreate(savedInstanceState);
    if (CollectionServiceStarter.isBTShare(getApplicationContext())) {
        Intent intent = new Intent(this, Home.class);
        startActivity(intent);
        finish();
    }
    ActivityDoubleCalibrationBinding binding = ActivityDoubleCalibrationBinding.inflate(getLayoutInflater());
    binding.setPrefs(new PrefsViewImpl());
    setContentView(binding.getRoot());
    addListenerOnButton();
}
 
Example #26
Source File: BgReading.java    From xDrip-Experimental with GNU General Public License v3.0 5 votes vote down vote up
public void calculateAgeAdjustedRawValue(Context context){
    double adjust_for = AGE_ADJUSTMENT_TIME - time_since_sensor_started;
    if (adjust_for <= 0 || CollectionServiceStarter.isLimitter(context)) {
            age_adjusted_raw_value = raw_data;
        } else {
            age_adjusted_raw_value = ((AGE_ADJUSTMENT_FACTOR * (adjust_for / AGE_ADJUSTMENT_TIME)) * raw_data) + raw_data;
            Log.i(TAG, "calculateAgeAdjustedRawValue: RAW VALUE ADJUSTMENT FROM:" + raw_data + " TO: " + age_adjusted_raw_value);
    }
}
 
Example #27
Source File: DexCollectionService.java    From xDrip with GNU General Public License v3.0 5 votes vote down vote up
public void setFailoverTimer() { //Sometimes it gets stuck in limbo on 4.4, this should make it try again
    if (CollectionServiceStarter.isBTWixel(getApplicationContext())) {
        long retry_in = (1000 * 60 * 5);
        Log.d(TAG, "Fallover Restarting in: " + (retry_in / (60 * 1000)) + " minutes");
        Calendar calendar = Calendar.getInstance();
        AlarmManager alarm = (AlarmManager) getSystemService(ALARM_SERVICE);
        alarm.set(alarm.RTC_WAKEUP, calendar.getTimeInMillis() + retry_in, PendingIntent.getService(this, 0, new Intent(this, DexCollectionService.class), 0));
    } else {
        stopSelf();
    }
}
 
Example #28
Source File: DexShareCollectionService.java    From xDrip with GNU General Public License v3.0 5 votes vote down vote up
public void setFailoverTimer() { //Sometimes it gets stuck in limbo on 4.4, this should make it try again
    if (CollectionServiceStarter.isBTShare(getApplicationContext())) {
        long retry_in = (1000 * 60 * 5);
        Log.d(TAG, "Fallover Restarting in: " + (retry_in / (60 * 1000)) + " minutes");
        Calendar calendar = Calendar.getInstance();
        AlarmManager alarm = (AlarmManager) getSystemService(ALARM_SERVICE);
        alarm.set(alarm.RTC_WAKEUP, calendar.getTimeInMillis() + retry_in, PendingIntent.getService(this, 0, new Intent(this, DexShareCollectionService.class), 0));
    } else {
        stopSelf();
    }
}
 
Example #29
Source File: DexCollectionService.java    From xDrip-plus with GNU General Public License v3.0 5 votes vote down vote up
@SuppressLint("ObsoleteSdkInt")
private static boolean shouldServiceRun() {
    if (android.os.Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR2) return false;
    final boolean result = (DexCollectionType.hasXbridgeWixel() || DexCollectionType.hasBtWixel())
            && ((!Home.get_forced_wear() && (((UiModeManager) xdrip.getAppContext().getSystemService(UI_MODE_SERVICE)).getCurrentModeType() != Configuration.UI_MODE_TYPE_WATCH))
            || PersistentStore.getBoolean(CollectionServiceStarter.pref_run_wear_collector));
    if (d) Log.d(TAG, "shouldServiceRun() returning: " + result);
    return result;
}
 
Example #30
Source File: ListenerService.java    From xDrip-plus with GNU General Public License v3.0 5 votes vote down vote up
private void stopBtService() {
    Log.d(TAG, "stopService call stopService");
    CollectionServiceStarter.stopBtService(getApplicationContext());
    Log.d(TAG, "stopBtService should have called onDestroy");
    AlarmManager alarmManager = (AlarmManager) getSystemService(ALARM_SERVICE);
    PendingIntent wakeIntent = PendingIntent.getService(this, 0, new Intent(this, Notifications.class), PendingIntent.FLAG_UPDATE_CURRENT);
    wakeIntent.cancel();
    alarmManager.cancel(wakeIntent);
    Log.d(TAG, "stopBtService cancel Notifications wakeIntent");
}