use of com.eveningoutpost.dexdrip.utils.DexCollectionType in project xDrip by NightscoutFoundation.
the class ListenerService method syncPrefData.
private synchronized void syncPrefData(DataMap dataMap) {
// KS
SharedPreferences.Editor prefs = PreferenceManager.getDefaultSharedPreferences(this).edit();
final PowerManager.WakeLock wl = JoH.getWakeLock(getApplicationContext(), "watchlistener-SYNC_PREF_DATA", 120000);
try {
Log.d(TAG, "syncPrefData dataMap=" + dataMap);
if (localnode == null || (localnode != null && localnode.isEmpty()))
setLocalNodeName();
// BluetoothWixel "DexcomG5"
String dexCollector = dataMap.getString(DexCollectionType.DEX_COLLECTION_METHOD, "None");
Log.d(TAG, "syncPrefData dataMap dexCollector=" + dexCollector + " mPrefs DexCollectionType.DEX_COLLECTION_METHOD:" + mPrefs.getString(DexCollectionType.DEX_COLLECTION_METHOD, "xxxxxxxx"));
DexCollectionType collectionType = DexCollectionType.getType(dexCollector);
Log.d(TAG, "syncPrefData dataMap dexCollector:" + dexCollector + " mPrefs dex_collection_method=" + mPrefs.getString(DexCollectionType.DEX_COLLECTION_METHOD, "xxxxxxxx"));
if (!dexCollector.equals(mPrefs.getString(DexCollectionType.DEX_COLLECTION_METHOD, "xxxxxxxx"))) {
Log.d(TAG, "syncPrefData dexCollector:" + dexCollector + " collectionType.name=" + collectionType.name());
DexCollectionType.setDexCollectionType(collectionType);
// Change requires collector restart
stopBtService();
}
// (collectionType == DexCollectionType.DexcomG5);
is_using_bt = DexCollectionType.hasBluetooth();
Log.d(TAG, "syncPrefData is_using_bt:" + is_using_bt);
// prefs.putBoolean("g5_collection_method", is_using_g5);
boolean enable_wearG5 = is_using_bt && dataMap.getBoolean("enable_wearG5", false);
boolean force_wearG5 = is_using_bt && dataMap.getBoolean("force_wearG5", false);
String node_wearG5 = dataMap.getString("node_wearG5", "");
String prefs_node_wearG5 = mPrefs.getString("node_wearG5", "");
Log.d(TAG, "syncPrefData enter enable_wearG5: " + enable_wearG5 + " force_wearG5:" + force_wearG5 + " node_wearG5:" + node_wearG5 + " prefs_node_wearG5:" + prefs_node_wearG5 + " localnode:" + localnode);
if (!node_wearG5.equals(prefs_node_wearG5)) {
prefs.putString("node_wearG5", node_wearG5);
Log.d(TAG, "syncPrefData node_wearG5 pref set to dataMap:" + node_wearG5);
}
if (force_wearG5 && node_wearG5.equals("")) {
prefs.putString("node_wearG5", localnode);
node_wearG5 = localnode;
Log.d(TAG, "syncPrefData node_wearG5 set empty string to localnode:" + localnode);
}
// if (!node_wearG5.equals(localnode)) {
if (force_wearG5 && !fuzzyNodeCompare(localnode, node_wearG5)) {
Log.d(TAG, "syncPrefData localnode != node_wearG5 disable force_wearG5 for this watch device! \nlocalnode: " + localnode + "\nnode_wearG5:" + node_wearG5);
force_wearG5 = false;
}
if (force_wearG5 != mPrefs.getBoolean("force_wearG5", false)) {
Log.d(TAG, "syncPrefData force_wearG5:" + force_wearG5);
prefs.putBoolean("force_wearG5", force_wearG5);
}
if (enable_wearG5 != mPrefs.getBoolean("enable_wearG5", false)) {
Log.d(TAG, "syncPrefData enable_wearG5:" + enable_wearG5);
prefs.putBoolean("enable_wearG5", enable_wearG5);
}
String dex_txid = dataMap.getString("dex_txid", "ABCDEF");
Log.d(TAG, "syncPrefData dataMap dex_txid=" + dex_txid);
if (!dex_txid.equals(mPrefs.getString("dex_txid", ""))) {
Log.d(TAG, "syncPrefData dex_txid:" + dex_txid);
prefs.putString("dex_txid", dex_txid);
// Change requires collector restart
stopBtService();
}
String share_key = dataMap.getString("share_key", "SM00000000");
Log.d(TAG, "syncPrefData dataMap share_key=" + share_key);
if (!share_key.equals(mPrefs.getString("share_key", "SM00000000"))) {
// change requires collector restart
Log.d(TAG, "syncPrefData share_key:" + share_key);
prefs.putString("share_key", share_key);
// Change requires collector restart
stopBtService();
}
final boolean adjustPast = dataMap.getBoolean("rewrite_history", true);
prefs.putBoolean("rewrite_history", adjustPast);
String units = dataMap.getString("units", "mgdl");
Log.d(TAG, "syncPrefData dataMap units=" + units);
prefs.putString("units", units);
Log.d(TAG, "syncPrefData prefs units=" + mPrefs.getString("units", "mgdl"));
Double high = dataMap.getDouble("high", 170.0);
Double low = dataMap.getDouble("low", 70.0);
Log.d(TAG, "syncPrefData dataMap highMark=" + high + " highMark=" + low);
prefs.putString("highValue", high.toString());
prefs.putString("lowValue", low.toString());
final boolean g5_non_raw_method = dataMap.getBoolean("g5_non_raw_method", false);
prefs.putBoolean("g5_non_raw_method", g5_non_raw_method);
final String extra_tags_for_logging = dataMap.getString("extra_tags_for_logging", "");
prefs.putString("extra_tags_for_logging", extra_tags_for_logging);
prefs.putBoolean("use_ob1_g5_collector_service", dataMap.getBoolean("use_ob1_g5_collector_service", false));
final String blukon_pin = dataMap.getString(Blukon.BLUKON_PIN_PREF, "");
prefs.putString(Blukon.BLUKON_PIN_PREF, blukon_pin);
// just add to this list to sync booleans with the same name
final List<String> defaultFalseBooleansToReceive = WearSyncBooleans.getBooleansToSync();
final List<String> defaultBlankPersistentStringsToReceive = WearSyncPersistentStrings.getPersistentStrings();
for (String preference_name : defaultFalseBooleansToReceive) {
prefs.putBoolean(preference_name, dataMap.getBoolean(preference_name, false));
}
for (String store_name : defaultBlankPersistentStringsToReceive) {
PersistentStore.setString(store_name, dataMap.getString(store_name, ""));
}
// Advanced Bluetooth Settings used by G4+xBridge DexCollectionService - temporarily just use the Phone's settings
// Therefore, change requires collector restart
prefs.putBoolean("use_transmiter_pl_bluetooth", dataMap.getBoolean("use_transmiter_pl_bluetooth", false));
prefs.putBoolean("use_rfduino_bluetooth", dataMap.getBoolean("use_rfduino_bluetooth", false));
prefs.putBoolean("automatically_turn_bluetooth_on", dataMap.getBoolean("automatically_turn_bluetooth_on", true));
prefs.putBoolean("bluetooth_excessive_wakelocks", dataMap.getBoolean("bluetooth_excessive_wakelocks", true));
prefs.putBoolean("close_gatt_on_ble_disconnect", dataMap.getBoolean("close_gatt_on_ble_disconnect", true));
prefs.putBoolean("bluetooth_frequent_reset", dataMap.getBoolean("bluetooth_frequent_reset", false));
prefs.putBoolean("bluetooth_watchdog", dataMap.getBoolean("bluetooth_watchdog", false));
prefs.putString("bluetooth_watchdog_timer", dataMap.getString("bluetooth_watchdog_timer", "20"));
prefs.putBoolean("sync_wear_logs", dataMap.getBoolean("sync_wear_logs", false));
// prefs.putBoolean("engineering_mode", dataMap.getBoolean("engineering_mode", false));
prefs.putInt("nfc_sensor_age", dataMap.getInt("nfc_sensor_age", -1));
prefs.putInt("bridge_battery", dataMap.getInt("bridge_battery", -1));
prefs.putBoolean("bridge_battery_alerts", dataMap.getBoolean("bridge_battery_alerts", false));
prefs.putString("bridge_battery_alert_level", dataMap.getString("bridge_battery_alert_level", "30"));
if ((DexCollectionType.getDexCollectionType().equals(DexCollectionType.DexcomG5) || DexCollectionType.getDexCollectionType().equals(DexCollectionType.DexcomShare)) && enable_wearG5) {
// /TODO confirm wear battery should be used as bridge
int wearBatteryLevel = CheckBridgeBattery.getBatteryLevel(Home.getAppContext());
Log.i(TAG, "syncPrefData wearBatteryLevel=" + wearBatteryLevel);
// TODO confirm wear battery should be used as bridge
prefs.putInt("bridge_battery", wearBatteryLevel);
}
// Alerts:
prefs.putString("persistent_high_repeat_mins", dataMap.getString("persistent_high_repeat_mins", "20"));
prefs.putString("persistent_high_threshold_mins", dataMap.getString("persistent_high_threshold_mins", "60"));
prefs.putBoolean("falling_alert", dataMap.getBoolean("falling_alert", false));
prefs.putString("falling_bg_val", dataMap.getString("falling_bg_val", "2"));
prefs.putBoolean("rising_alert", dataMap.getBoolean("rising_alert", false));
prefs.putString("rising_bg_val", dataMap.getString("rising_bg_val", "2"));
prefs.putBoolean("aggressive_service_restart", dataMap.getBoolean("aggressive_service_restart", false));
// Step Counter
prefs.putBoolean("use_wear_health", dataMap.getBoolean("use_wear_health", true));
// Extra Status Line
prefs.putBoolean("extra_status_stats_24h", dataMap.getBoolean("extra_status_stats_24h", false));
prefs.putBoolean("extra_status_line", dataMap.getBoolean("extra_status_line", false));
prefs.putBoolean("status_line_calibration_long", dataMap.getBoolean("status_line_calibration_long", false));
prefs.putBoolean("status_line_calibration_short", dataMap.getBoolean("status_line_calibration_short", false));
prefs.putBoolean("status_line_avg", dataMap.getBoolean("status_line_avg", false));
prefs.putBoolean("status_line_a1c_dcct", dataMap.getBoolean("status_line_a1c_dcct", false));
prefs.putBoolean("status_line_a1c_ifcc", dataMap.getBoolean("status_line_a1c_ifcc", false));
prefs.putBoolean("status_line_in", dataMap.getBoolean("status_line_in", false));
prefs.putBoolean("status_line_high", dataMap.getBoolean("status_line_high", false));
prefs.putBoolean("status_line_low", dataMap.getBoolean("status_line_low", false));
prefs.putBoolean("status_line_carbs", dataMap.getBoolean("status_line_carbs", false));
prefs.putBoolean("status_line_insulin", dataMap.getBoolean("status_line_insulin", false));
prefs.putBoolean("status_line_stdev", dataMap.getBoolean("status_line_stdev", false));
prefs.putBoolean("status_line_royce_ratio", dataMap.getBoolean("status_line_royce_ratio", false));
prefs.putBoolean("status_line_capture_percentage", dataMap.getBoolean("status_line_capture_percentage", false));
// Calibration plugin
prefs.putBoolean("extra_status_calibration_plugin", dataMap.getBoolean("extra_status_calibration_plugin", false));
prefs.putBoolean("display_glucose_from_plugin", dataMap.getBoolean("display_glucose_from_plugin", false));
prefs.putBoolean("use_pluggable_alg_as_primary", dataMap.getBoolean("use_pluggable_alg_as_primary", false));
prefs.putBoolean("old_school_calibration_mode", dataMap.getBoolean("old_school_calibration_mode", false));
prefs.putBoolean("show_wear_treatments", dataMap.getBoolean("show_wear_treatments", false));
overrideLocale(dataMap);
Ob1G5StateMachine.injectDexTime(dataMap.getString("dex-timekeeping"));
prefs.apply();
CheckBridgeBattery.checkBridgeBattery();
enable_wearG5 = mPrefs.getBoolean("enable_wearG5", false);
force_wearG5 = mPrefs.getBoolean("force_wearG5", false);
node_wearG5 = mPrefs.getString("node_wearG5", "");
Log.d(TAG, "syncPrefData exit enable_wearG5: " + enable_wearG5 + " force_wearG5:" + force_wearG5 + " node_wearG5:" + node_wearG5);
if (!Sensor.isActive()) {
Log.d(TAG, "syncPrefData No Active Sensor!! Request WEARABLE_INITDB_PATH before starting BT Collection Service: " + DexCollectionType.getDexCollectionType());
sendData(WEARABLE_INITDB_PATH, null);
}
VersionFixer.updateAndCheck(dataMap.getString("build-version-name", null), apkBytesVersion);
} finally {
JoH.releaseWakeLock(wl);
}
}
use of com.eveningoutpost.dexdrip.utils.DexCollectionType in project xDrip-plus by jamorham.
the class Home method updateCurrentBgInfo.
private void updateCurrentBgInfo(String source) {
Log.d(TAG, "updateCurrentBgInfo from: " + source);
if (!activityVisible) {
Log.d(TAG, "Display not visible - not updating chart");
return;
}
if (reset_viewport) {
reset_viewport = false;
holdViewport.set(0, 0, 0, 0);
if (chart != null)
chart.setZoomType(ZoomType.HORIZONTAL);
}
setupCharts();
initializeGraphicTrendArrow();
final TextView notificationText = (TextView) findViewById(R.id.notices);
final TextView lowPredictText = (TextView) findViewById(R.id.lowpredict);
if (BgGraphBuilder.isXLargeTablet(getApplicationContext())) {
notificationText.setTextSize(40);
lowPredictText.setTextSize(30);
}
notificationText.setText("");
notificationText.setTextColor(Color.RED);
UndoRedo.purgeQueues();
if (UndoRedo.undoListHasItems()) {
btnUndo.setVisibility(View.VISIBLE);
showcasemenu(SHOWCASE_UNDO);
} else {
btnUndo.setVisibility(View.INVISIBLE);
}
if (UndoRedo.redoListHasItems()) {
btnRedo.setVisibility(View.VISIBLE);
showcasemenu(SHOWCASE_REDO);
} else {
btnRedo.setVisibility(View.INVISIBLE);
}
final DexCollectionType collector = DexCollectionType.getDexCollectionType();
// TODO unify code using DexCollectionType methods
boolean isBTWixelOrLimiTTer = CollectionServiceStarter.isBTWixelOrLimiTTer(getApplicationContext());
// port this lot to DexCollectionType to avoid multiple lookups of the same preference
boolean isDexbridgeWixel = CollectionServiceStarter.isDexBridgeOrWifiandDexBridge();
boolean isWifiBluetoothWixel = CollectionServiceStarter.isWifiandBTWixel(getApplicationContext());
boolean isWifiandBTLibre = CollectionServiceStarter.isWifiandBTLibre(getApplicationContext());
isBTShare = CollectionServiceStarter.isBTShare(getApplicationContext());
isG5Share = CollectionServiceStarter.isBTG5(getApplicationContext());
boolean isWifiWixel = CollectionServiceStarter.isWifiWixel(getApplicationContext());
boolean isWifiLibre = CollectionServiceStarter.isWifiLibre(getApplicationContext());
// reset flag
alreadyDisplayedBgInfoCommon = false;
if (isBTShare) {
updateCurrentBgInfoForBtShare(notificationText);
}
if (isG5Share) {
updateCurrentBgInfoCommon(collector, notificationText);
}
if (isBTWixelOrLimiTTer || isDexbridgeWixel || isWifiBluetoothWixel || isWifiandBTLibre) {
updateCurrentBgInfoForBtBasedWixel(collector, notificationText);
}
if (isWifiWixel || isWifiBluetoothWixel || isWifiandBTLibre || isWifiLibre || collector.equals(DexCollectionType.Mock)) {
updateCurrentBgInfoForWifiWixel(collector, notificationText);
} else if (is_follower || collector.equals(DexCollectionType.NSEmulator) || collector.equals(DexCollectionType.NSFollow) || collector.equals(DexCollectionType.SHFollow) || collector.equals(DexCollectionType.LibreReceiver)) {
displayCurrentInfo();
Inevitable.task("home-notifications-start", 5000, Notifications::start);
} else if (!alreadyDisplayedBgInfoCommon && (DexCollectionType.getDexCollectionType() == DexCollectionType.LibreAlarm || collector == DexCollectionType.Medtrum)) {
updateCurrentBgInfoCommon(collector, notificationText);
}
if (collector.equals(DexCollectionType.Disabled)) {
notificationText.append("\n DATA SOURCE DISABLED");
if (!Experience.gotData()) {
// TODO should this move to Experience::processSteps ?
final Activity activity = this;
JoH.runOnUiThreadDelayed(() -> {
if ((dialog == null || !dialog.isShowing())) {
if (JoH.ratelimit("start_source_wizard", 30)) {
SourceWizard.start(activity, false);
}
}
}, 500);
}
} else if (collector.equals(DexCollectionType.Mock)) {
notificationText.append("\n USING FAKE DATA SOURCE !!!");
}
if (Pref.getLong("alerts_disabled_until", 0) > new Date().getTime()) {
notificationText.append("\n " + getString(R.string.all_alerts_currently_disabled));
} else if (Pref.getLong("low_alerts_disabled_until", 0) > new Date().getTime() && Pref.getLong("high_alerts_disabled_until", 0) > new Date().getTime()) {
notificationText.append("\n " + getString(R.string.low_and_high_alerts_currently_disabled));
} else if (Pref.getLong("low_alerts_disabled_until", 0) > new Date().getTime()) {
notificationText.append("\n " + getString(R.string.low_alerts_currently_disabled));
} else if (Pref.getLong("high_alerts_disabled_until", 0) > new Date().getTime()) {
notificationText.append("\n " + getString(R.string.high_alerts_currently_disabled));
}
NavigationDrawerFragment navigationDrawerFragment = (NavigationDrawerFragment) getFragmentManager().findFragmentById(R.id.navigation_drawer);
// DEBUG ONLY
if ((BgGraphBuilder.last_noise > 0) && (Pref.getBoolean("show_noise_workings", false))) {
notificationText.append("\nSensor Noise: " + JoH.qs(BgGraphBuilder.last_noise, 1));
if ((BgGraphBuilder.best_bg_estimate > 0) && (BgGraphBuilder.last_bg_estimate > 0)) {
final double estimated_delta = BgGraphBuilder.best_bg_estimate - BgGraphBuilder.last_bg_estimate;
// notificationText.append("\nBG Original: " + bgGraphBuilder.unitized_string(BgReading.lastNoSenssor().calculated_value)
try {
notificationText.append("\nBG Original: " + bgGraphBuilder.unitized_string(BgGraphBuilder.original_value) + " \u0394 " + bgGraphBuilder.unitizedDeltaString(false, true, true) + " " + BgReading.lastNoSenssor().slopeArrow());
notificationText.append("\nBG Estimate: " + bgGraphBuilder.unitized_string(BgGraphBuilder.best_bg_estimate) + " \u0394 " + bgGraphBuilder.unitizedDeltaStringRaw(false, true, estimated_delta) + " " + BgReading.slopeToArrowSymbol(estimated_delta / (BgGraphBuilder.DEXCOM_PERIOD / 60000)));
} catch (NullPointerException e) {
//
}
}
}
// TODO we need to consider noise level?
// when to raise the alarm
lowPredictText.setText("");
lowPredictText.setVisibility(View.INVISIBLE);
if (BgGraphBuilder.low_occurs_at > 0) {
double low_predicted_alarm_minutes;
low_predicted_alarm_minutes = JoH.tolerantParseDouble(Pref.getString("low_predict_alarm_level", "50"), 50d);
// TODO use tsl()
final double now = JoH.ts();
final double predicted_low_in_mins = (BgGraphBuilder.low_occurs_at - now) / 60000;
if (predicted_low_in_mins > 1) {
lowPredictText.append(getString(R.string.low_predicted) + "\n" + getString(R.string.in) + ": " + (int) predicted_low_in_mins + getString(R.string.space_mins));
if (predicted_low_in_mins < low_predicted_alarm_minutes) {
// low front getting too close!
lowPredictText.setTextColor(Color.RED);
} else {
final double previous_predicted_low_in_mins = (BgGraphBuilder.previous_low_occurs_at - now) / 60000;
if ((BgGraphBuilder.previous_low_occurs_at > 0) && ((previous_predicted_low_in_mins + 5) < predicted_low_in_mins)) {
// low front is getting further away
lowPredictText.setTextColor(Color.GREEN);
} else {
// low front is getting nearer!
lowPredictText.setTextColor(Color.YELLOW);
}
}
lowPredictText.setVisibility(View.VISIBLE);
}
BgGraphBuilder.previous_low_occurs_at = BgGraphBuilder.low_occurs_at;
}
if (navigationDrawerFragment == null)
Log.e("Runtime", "navigationdrawerfragment is null");
try {
navigationDrawerFragment.setUp(R.id.navigation_drawer, (DrawerLayout) findViewById(R.id.drawer_layout), getString(R.string.home_screen), this);
} catch (Exception e) {
Log.e("Runtime", "Exception with navigrationdrawerfragment: " + e.toString());
}
if (nexttoast != null) {
toast(nexttoast);
nexttoast = null;
}
// hide the treatment recognition text after some seconds
if ((last_speech_time > 0) && ((JoH.ts() - last_speech_time) > 20000)) {
voiceRecognitionText.setVisibility(View.INVISIBLE);
last_speech_time = 0;
}
if (ActivityRecognizedService.is_in_vehicle_mode()) {
btnVehicleMode.setVisibility(View.VISIBLE);
} else {
btnVehicleMode.setVisibility(View.INVISIBLE);
}
// if (isG5Share) showcasemenu(SHOWCASE_G5FIRMWARE); // nov 2016 firmware warning resolved 15/12/2016
// showcasemenu(1); // 3 dot menu
}
use of com.eveningoutpost.dexdrip.utils.DexCollectionType in project xDrip-plus by jamorham.
the class ListenerService method syncPrefData.
private synchronized void syncPrefData(DataMap dataMap) {
// KS
SharedPreferences.Editor prefs = PreferenceManager.getDefaultSharedPreferences(this).edit();
final PowerManager.WakeLock wl = JoH.getWakeLock(getApplicationContext(), "watchlistener-SYNC_PREF_DATA", 120000);
try {
Log.d(TAG, "syncPrefData dataMap=" + dataMap);
if (localnode == null || (localnode != null && localnode.isEmpty()))
setLocalNodeName();
// BluetoothWixel "DexcomG5"
String dexCollector = dataMap.getString(DexCollectionType.DEX_COLLECTION_METHOD, "None");
Log.d(TAG, "syncPrefData dataMap dexCollector=" + dexCollector + " mPrefs DexCollectionType.DEX_COLLECTION_METHOD:" + mPrefs.getString(DexCollectionType.DEX_COLLECTION_METHOD, "xxxxxxxx"));
DexCollectionType collectionType = DexCollectionType.getType(dexCollector);
Log.d(TAG, "syncPrefData dataMap dexCollector:" + dexCollector + " mPrefs dex_collection_method=" + mPrefs.getString(DexCollectionType.DEX_COLLECTION_METHOD, "xxxxxxxx"));
if (!dexCollector.equals(mPrefs.getString(DexCollectionType.DEX_COLLECTION_METHOD, "xxxxxxxx"))) {
Log.d(TAG, "syncPrefData dexCollector:" + dexCollector + " collectionType.name=" + collectionType.name());
DexCollectionType.setDexCollectionType(collectionType);
// Change requires collector restart
stopBtService();
}
// (collectionType == DexCollectionType.DexcomG5);
is_using_bt = DexCollectionType.hasBluetooth();
Log.d(TAG, "syncPrefData is_using_bt:" + is_using_bt);
// prefs.putBoolean("g5_collection_method", is_using_g5);
boolean enable_wearG5 = is_using_bt && dataMap.getBoolean("enable_wearG5", false);
boolean force_wearG5 = is_using_bt && dataMap.getBoolean("force_wearG5", false);
String node_wearG5 = dataMap.getString("node_wearG5", "");
String prefs_node_wearG5 = mPrefs.getString("node_wearG5", "");
Log.d(TAG, "syncPrefData enter enable_wearG5: " + enable_wearG5 + " force_wearG5:" + force_wearG5 + " node_wearG5:" + node_wearG5 + " prefs_node_wearG5:" + prefs_node_wearG5 + " localnode:" + localnode);
if (!node_wearG5.equals(prefs_node_wearG5)) {
prefs.putString("node_wearG5", node_wearG5);
Log.d(TAG, "syncPrefData node_wearG5 pref set to dataMap:" + node_wearG5);
}
if (force_wearG5 && node_wearG5.equals("")) {
prefs.putString("node_wearG5", localnode);
node_wearG5 = localnode;
Log.d(TAG, "syncPrefData node_wearG5 set empty string to localnode:" + localnode);
}
// if (!node_wearG5.equals(localnode)) {
if (force_wearG5 && !fuzzyNodeCompare(localnode, node_wearG5)) {
Log.d(TAG, "syncPrefData localnode != node_wearG5 disable force_wearG5 for this watch device! \nlocalnode: " + localnode + "\nnode_wearG5:" + node_wearG5);
force_wearG5 = false;
}
if (force_wearG5 != mPrefs.getBoolean("force_wearG5", false)) {
Log.d(TAG, "syncPrefData force_wearG5:" + force_wearG5);
prefs.putBoolean("force_wearG5", force_wearG5);
}
if (enable_wearG5 != mPrefs.getBoolean("enable_wearG5", false)) {
Log.d(TAG, "syncPrefData enable_wearG5:" + enable_wearG5);
prefs.putBoolean("enable_wearG5", enable_wearG5);
}
String dex_txid = dataMap.getString("dex_txid", "ABCDEF");
Log.d(TAG, "syncPrefData dataMap dex_txid=" + dex_txid);
if (!dex_txid.equals(mPrefs.getString("dex_txid", ""))) {
Log.d(TAG, "syncPrefData dex_txid:" + dex_txid);
prefs.putString("dex_txid", dex_txid);
// Change requires collector restart
stopBtService();
}
String share_key = dataMap.getString("share_key", "SM00000000");
Log.d(TAG, "syncPrefData dataMap share_key=" + share_key);
if (!share_key.equals(mPrefs.getString("share_key", "SM00000000"))) {
// change requires collector restart
Log.d(TAG, "syncPrefData share_key:" + share_key);
prefs.putString("share_key", share_key);
// Change requires collector restart
stopBtService();
}
final boolean adjustPast = dataMap.getBoolean("rewrite_history", true);
prefs.putBoolean("rewrite_history", adjustPast);
String units = dataMap.getString("units", "mgdl");
Log.d(TAG, "syncPrefData dataMap units=" + units);
prefs.putString("units", units);
Log.d(TAG, "syncPrefData prefs units=" + mPrefs.getString("units", "mgdl"));
Double high = dataMap.getDouble("high", 170.0);
Double low = dataMap.getDouble("low", 70.0);
Log.d(TAG, "syncPrefData dataMap highMark=" + high + " highMark=" + low);
prefs.putString("highValue", high.toString());
prefs.putString("lowValue", low.toString());
final boolean g5_non_raw_method = dataMap.getBoolean("g5_non_raw_method", false);
prefs.putBoolean("g5_non_raw_method", g5_non_raw_method);
final String extra_tags_for_logging = dataMap.getString("extra_tags_for_logging", "");
prefs.putString("extra_tags_for_logging", extra_tags_for_logging);
prefs.putBoolean("use_ob1_g5_collector_service", dataMap.getBoolean("use_ob1_g5_collector_service", false));
final String blukon_pin = dataMap.getString(Blukon.BLUKON_PIN_PREF, "");
prefs.putString(Blukon.BLUKON_PIN_PREF, blukon_pin);
// just add to this list to sync booleans with the same name
final List<String> defaultFalseBooleansToReceive = WearSyncBooleans.getBooleansToSync();
final List<String> defaultBlankPersistentStringsToReceive = WearSyncPersistentStrings.getPersistentStrings();
for (String preference_name : defaultFalseBooleansToReceive) {
prefs.putBoolean(preference_name, dataMap.getBoolean(preference_name, false));
}
for (String store_name : defaultBlankPersistentStringsToReceive) {
PersistentStore.setString(store_name, dataMap.getString(store_name, ""));
}
// Advanced Bluetooth Settings used by G4+xBridge DexCollectionService - temporarily just use the Phone's settings
// Therefore, change requires collector restart
prefs.putBoolean("use_transmiter_pl_bluetooth", dataMap.getBoolean("use_transmiter_pl_bluetooth", false));
prefs.putBoolean("use_rfduino_bluetooth", dataMap.getBoolean("use_rfduino_bluetooth", false));
prefs.putBoolean("automatically_turn_bluetooth_on", dataMap.getBoolean("automatically_turn_bluetooth_on", true));
prefs.putBoolean("bluetooth_excessive_wakelocks", dataMap.getBoolean("bluetooth_excessive_wakelocks", true));
prefs.putBoolean("close_gatt_on_ble_disconnect", dataMap.getBoolean("close_gatt_on_ble_disconnect", true));
prefs.putBoolean("bluetooth_frequent_reset", dataMap.getBoolean("bluetooth_frequent_reset", false));
prefs.putBoolean("bluetooth_watchdog", dataMap.getBoolean("bluetooth_watchdog", false));
prefs.putString("bluetooth_watchdog_timer", dataMap.getString("bluetooth_watchdog_timer", "20"));
prefs.putBoolean("sync_wear_logs", dataMap.getBoolean("sync_wear_logs", false));
// prefs.putBoolean("engineering_mode", dataMap.getBoolean("engineering_mode", false));
prefs.putInt("nfc_sensor_age", dataMap.getInt("nfc_sensor_age", -1));
prefs.putInt("bridge_battery", dataMap.getInt("bridge_battery", -1));
prefs.putBoolean("bridge_battery_alerts", dataMap.getBoolean("bridge_battery_alerts", false));
prefs.putString("bridge_battery_alert_level", dataMap.getString("bridge_battery_alert_level", "30"));
if ((DexCollectionType.getDexCollectionType().equals(DexCollectionType.DexcomG5) || DexCollectionType.getDexCollectionType().equals(DexCollectionType.DexcomShare)) && enable_wearG5) {
// /TODO confirm wear battery should be used as bridge
int wearBatteryLevel = CheckBridgeBattery.getBatteryLevel(Home.getAppContext());
Log.i(TAG, "syncPrefData wearBatteryLevel=" + wearBatteryLevel);
// TODO confirm wear battery should be used as bridge
prefs.putInt("bridge_battery", wearBatteryLevel);
}
// Alerts:
prefs.putString("persistent_high_repeat_mins", dataMap.getString("persistent_high_repeat_mins", "20"));
prefs.putString("persistent_high_threshold_mins", dataMap.getString("persistent_high_threshold_mins", "60"));
prefs.putBoolean("falling_alert", dataMap.getBoolean("falling_alert", false));
prefs.putString("falling_bg_val", dataMap.getString("falling_bg_val", "2"));
prefs.putBoolean("rising_alert", dataMap.getBoolean("rising_alert", false));
prefs.putString("rising_bg_val", dataMap.getString("rising_bg_val", "2"));
prefs.putBoolean("aggressive_service_restart", dataMap.getBoolean("aggressive_service_restart", false));
// Step Counter
prefs.putBoolean("use_wear_health", dataMap.getBoolean("use_wear_health", true));
// Extra Status Line
prefs.putBoolean("extra_status_stats_24h", dataMap.getBoolean("extra_status_stats_24h", false));
prefs.putBoolean("extra_status_line", dataMap.getBoolean("extra_status_line", false));
prefs.putBoolean("status_line_calibration_long", dataMap.getBoolean("status_line_calibration_long", false));
prefs.putBoolean("status_line_calibration_short", dataMap.getBoolean("status_line_calibration_short", false));
prefs.putBoolean("status_line_avg", dataMap.getBoolean("status_line_avg", false));
prefs.putBoolean("status_line_a1c_dcct", dataMap.getBoolean("status_line_a1c_dcct", false));
prefs.putBoolean("status_line_a1c_ifcc", dataMap.getBoolean("status_line_a1c_ifcc", false));
prefs.putBoolean("status_line_in", dataMap.getBoolean("status_line_in", false));
prefs.putBoolean("status_line_high", dataMap.getBoolean("status_line_high", false));
prefs.putBoolean("status_line_low", dataMap.getBoolean("status_line_low", false));
prefs.putBoolean("status_line_carbs", dataMap.getBoolean("status_line_carbs", false));
prefs.putBoolean("status_line_insulin", dataMap.getBoolean("status_line_insulin", false));
prefs.putBoolean("status_line_stdev", dataMap.getBoolean("status_line_stdev", false));
prefs.putBoolean("status_line_royce_ratio", dataMap.getBoolean("status_line_royce_ratio", false));
prefs.putBoolean("status_line_capture_percentage", dataMap.getBoolean("status_line_capture_percentage", false));
// Calibration plugin
prefs.putBoolean("extra_status_calibration_plugin", dataMap.getBoolean("extra_status_calibration_plugin", false));
prefs.putBoolean("display_glucose_from_plugin", dataMap.getBoolean("display_glucose_from_plugin", false));
prefs.putBoolean("use_pluggable_alg_as_primary", dataMap.getBoolean("use_pluggable_alg_as_primary", false));
prefs.putBoolean("old_school_calibration_mode", dataMap.getBoolean("old_school_calibration_mode", false));
prefs.putBoolean("show_wear_treatments", dataMap.getBoolean("show_wear_treatments", false));
overrideLocale(dataMap);
Ob1G5StateMachine.injectDexTime(dataMap.getString("dex-timekeeping"));
prefs.apply();
CheckBridgeBattery.checkBridgeBattery();
enable_wearG5 = mPrefs.getBoolean("enable_wearG5", false);
force_wearG5 = mPrefs.getBoolean("force_wearG5", false);
node_wearG5 = mPrefs.getString("node_wearG5", "");
Log.d(TAG, "syncPrefData exit enable_wearG5: " + enable_wearG5 + " force_wearG5:" + force_wearG5 + " node_wearG5:" + node_wearG5);
if (!Sensor.isActive()) {
Log.d(TAG, "syncPrefData No Active Sensor!! Request WEARABLE_INITDB_PATH before starting BT Collection Service: " + DexCollectionType.getDexCollectionType());
sendData(WEARABLE_INITDB_PATH, null);
}
VersionFixer.updateAndCheck(dataMap.getString("build-version-name", null), apkBytesVersion);
} finally {
JoH.releaseWakeLock(wl);
}
}
use of com.eveningoutpost.dexdrip.utils.DexCollectionType in project xDrip by NightscoutFoundation.
the class MegaStatus method populateSectionList.
private void populateSectionList() {
if (sectionList.isEmpty()) {
addAsection("Classic Status Page", "Legacy System Status");
final DexCollectionType dexCollectionType = DexCollectionType.getDexCollectionType();
// probably want a DexCollectionService related set
if (DexCollectionType.usesDexCollectionService(dexCollectionType)) {
addAsection(G4_STATUS, "Bluetooth Collector Status");
}
if (dexCollectionType.equals(DexcomG5)) {
if (Pref.getBooleanDefaultFalse(Ob1G5CollectionService.OB1G5_PREFS)) {
addAsection(G5_STATUS, "OB1 G5/G6 Collector and Transmitter Status");
} else {
addAsection(G5_STATUS, "G5 Collector and Transmitter Status");
}
} else if (dexCollectionType.equals(Medtrum)) {
addAsection(MEDTRUM_STATUS, "Medtrum A6 Status");
}
if (BlueJayEntry.isEnabled()) {
addAsection(BLUEJAY_STATUS, "BlueJay Watch Status");
}
if (DexCollectionType.getDexCollectionType() == DexCollectionType.LibreReceiver) {
addAsection(XDRIP_LIBRE2, "Libre 2 Patched App Status");
}
if (DexCollectionType.hasWifi()) {
addAsection(IP_COLLECTOR, dexCollectionType == DexCollectionType.Mock ? "FAKE / MOCK DATA SOURCE" : "Wifi Wixel / Parakeet Status");
}
if (InPenEntry.isEnabled()) {
addAsection(INPEN_STATUS, "InPen Status");
}
if (Home.get_master_or_follower()) {
addAsection(XDRIP_PLUS_SYNC, "xDrip+ Sync Group");
}
if (Pref.getBooleanDefaultFalse("cloud_storage_mongodb_enable") || Pref.getBooleanDefaultFalse("cloud_storage_api_enable") || Pref.getBooleanDefaultFalse("share_upload") || (Pref.getBooleanDefaultFalse("wear_sync") && Home.get_engineering_mode())) {
addAsection(UPLOADERS, "Cloud Uploader Queues");
}
if (LeFunEntry.isEnabled()) {
addAsection(LEFUN_STATUS, "Lefun Watch Status");
}
if (MiBandEntry.isEnabled()) {
addAsection(MIBAND_STATUS, "MiBand Watch Status");
}
if (dexCollectionType.equals(NSFollow)) {
addAsection(NIGHTSCOUT_FOLLOW, "Nightscout Follow Status");
}
if (dexCollectionType.equals(SHFollow)) {
addAsection(SHARE_FOLLOW, "Dex Share Follow Status");
}
// addAsection("Misc", "Currently Empty");
} else {
UserError.Log.d(TAG, "Section list already populated");
}
}
use of com.eveningoutpost.dexdrip.utils.DexCollectionType in project xDrip by NightscoutFoundation.
the class Home method updateCurrentBgInfo.
private void updateCurrentBgInfo(String source) {
Log.d(TAG, "updateCurrentBgInfo from: " + source);
if (!activityVisible) {
Log.d(TAG, "Display not visible - not updating chart");
return;
}
if (reset_viewport) {
reset_viewport = false;
holdViewport.set(0, 0, 0, 0);
if (chart != null)
chart.setZoomType(ZoomType.HORIZONTAL);
}
setupCharts();
initializeGraphicTrendArrow();
final TextView notificationText = (TextView) findViewById(R.id.notices);
final TextView lowPredictText = (TextView) findViewById(R.id.lowpredict);
if (BgGraphBuilder.isXLargeTablet(getApplicationContext())) {
notificationText.setTextSize(40);
lowPredictText.setTextSize(30);
}
notificationText.setText("");
notificationText.setTextColor(Color.RED);
UndoRedo.purgeQueues();
if (UndoRedo.undoListHasItems()) {
btnUndo.setVisibility(View.VISIBLE);
showcasemenu(SHOWCASE_UNDO);
} else {
btnUndo.setVisibility(View.INVISIBLE);
}
if (UndoRedo.redoListHasItems()) {
btnRedo.setVisibility(View.VISIBLE);
showcasemenu(SHOWCASE_REDO);
} else {
btnRedo.setVisibility(View.INVISIBLE);
}
final DexCollectionType collector = DexCollectionType.getDexCollectionType();
// TODO unify code using DexCollectionType methods
boolean isBTWixelOrLimiTTer = CollectionServiceStarter.isBTWixelOrLimiTTer(getApplicationContext());
// port this lot to DexCollectionType to avoid multiple lookups of the same preference
boolean isDexbridgeWixel = CollectionServiceStarter.isDexBridgeOrWifiandDexBridge();
boolean isWifiBluetoothWixel = CollectionServiceStarter.isWifiandBTWixel(getApplicationContext());
boolean isWifiandBTLibre = CollectionServiceStarter.isWifiandBTLibre(getApplicationContext());
isBTShare = CollectionServiceStarter.isBTShare(getApplicationContext());
isG5Share = CollectionServiceStarter.isBTG5(getApplicationContext());
boolean isWifiWixel = CollectionServiceStarter.isWifiWixel(getApplicationContext());
boolean isWifiLibre = CollectionServiceStarter.isWifiLibre(getApplicationContext());
// reset flag
alreadyDisplayedBgInfoCommon = false;
if (isBTShare) {
updateCurrentBgInfoForBtShare(notificationText);
}
if (isG5Share) {
updateCurrentBgInfoCommon(collector, notificationText);
}
if (isBTWixelOrLimiTTer || isDexbridgeWixel || isWifiBluetoothWixel || isWifiandBTLibre) {
updateCurrentBgInfoForBtBasedWixel(collector, notificationText);
}
if (isWifiWixel || isWifiBluetoothWixel || isWifiandBTLibre || isWifiLibre || collector.equals(DexCollectionType.Mock)) {
updateCurrentBgInfoForWifiWixel(collector, notificationText);
} else if (is_follower || collector.equals(DexCollectionType.NSEmulator) || collector.equals(DexCollectionType.NSFollow) || collector.equals(DexCollectionType.SHFollow) || collector.equals(DexCollectionType.LibreReceiver)) {
displayCurrentInfo();
Inevitable.task("home-notifications-start", 5000, Notifications::start);
} else if (!alreadyDisplayedBgInfoCommon && (DexCollectionType.getDexCollectionType() == DexCollectionType.LibreAlarm || collector == DexCollectionType.Medtrum)) {
updateCurrentBgInfoCommon(collector, notificationText);
}
if (collector.equals(DexCollectionType.Disabled)) {
notificationText.append("\n DATA SOURCE DISABLED");
if (!Experience.gotData()) {
// TODO should this move to Experience::processSteps ?
final Activity activity = this;
JoH.runOnUiThreadDelayed(() -> {
if ((dialog == null || !dialog.isShowing())) {
if (JoH.ratelimit("start_source_wizard", 30)) {
SourceWizard.start(activity, false);
}
}
}, 500);
}
} else if (collector.equals(DexCollectionType.Mock)) {
notificationText.append("\n USING FAKE DATA SOURCE !!!");
}
if (Pref.getLong("alerts_disabled_until", 0) > new Date().getTime()) {
notificationText.append("\n " + getString(R.string.all_alerts_currently_disabled));
} else if (Pref.getLong("low_alerts_disabled_until", 0) > new Date().getTime() && Pref.getLong("high_alerts_disabled_until", 0) > new Date().getTime()) {
notificationText.append("\n " + getString(R.string.low_and_high_alerts_currently_disabled));
} else if (Pref.getLong("low_alerts_disabled_until", 0) > new Date().getTime()) {
notificationText.append("\n " + getString(R.string.low_alerts_currently_disabled));
} else if (Pref.getLong("high_alerts_disabled_until", 0) > new Date().getTime()) {
notificationText.append("\n " + getString(R.string.high_alerts_currently_disabled));
}
NavigationDrawerFragment navigationDrawerFragment = (NavigationDrawerFragment) getFragmentManager().findFragmentById(R.id.navigation_drawer);
// DEBUG ONLY
if ((BgGraphBuilder.last_noise > 0) && (Pref.getBoolean("show_noise_workings", false))) {
notificationText.append("\nSensor Noise: " + JoH.qs(BgGraphBuilder.last_noise, 1));
if ((BgGraphBuilder.best_bg_estimate > 0) && (BgGraphBuilder.last_bg_estimate > 0)) {
final double estimated_delta = BgGraphBuilder.best_bg_estimate - BgGraphBuilder.last_bg_estimate;
// notificationText.append("\nBG Original: " + bgGraphBuilder.unitized_string(BgReading.lastNoSenssor().calculated_value)
try {
notificationText.append("\nBG Original: " + bgGraphBuilder.unitized_string(BgGraphBuilder.original_value) + " \u0394 " + bgGraphBuilder.unitizedDeltaString(false, true, true) + " " + BgReading.lastNoSenssor().slopeArrow());
notificationText.append("\nBG Estimate: " + bgGraphBuilder.unitized_string(BgGraphBuilder.best_bg_estimate) + " \u0394 " + bgGraphBuilder.unitizedDeltaStringRaw(false, true, estimated_delta) + " " + BgReading.slopeToArrowSymbol(estimated_delta / (BgGraphBuilder.DEXCOM_PERIOD / 60000)));
} catch (NullPointerException e) {
//
}
}
}
// TODO we need to consider noise level?
// when to raise the alarm
lowPredictText.setText("");
lowPredictText.setVisibility(View.INVISIBLE);
if (BgGraphBuilder.low_occurs_at > 0) {
double low_predicted_alarm_minutes;
low_predicted_alarm_minutes = JoH.tolerantParseDouble(Pref.getString("low_predict_alarm_level", "50"), 50d);
// TODO use tsl()
final double now = JoH.ts();
final double predicted_low_in_mins = (BgGraphBuilder.low_occurs_at - now) / 60000;
if (predicted_low_in_mins > 1) {
lowPredictText.append(getString(R.string.low_predicted) + "\n" + getString(R.string.in) + ": " + (int) predicted_low_in_mins + getString(R.string.space_mins));
if (predicted_low_in_mins < low_predicted_alarm_minutes) {
// low front getting too close!
lowPredictText.setTextColor(Color.RED);
} else {
final double previous_predicted_low_in_mins = (BgGraphBuilder.previous_low_occurs_at - now) / 60000;
if ((BgGraphBuilder.previous_low_occurs_at > 0) && ((previous_predicted_low_in_mins + 5) < predicted_low_in_mins)) {
// low front is getting further away
lowPredictText.setTextColor(Color.GREEN);
} else {
// low front is getting nearer!
lowPredictText.setTextColor(Color.YELLOW);
}
}
lowPredictText.setVisibility(View.VISIBLE);
}
BgGraphBuilder.previous_low_occurs_at = BgGraphBuilder.low_occurs_at;
}
if (navigationDrawerFragment == null)
Log.e("Runtime", "navigationdrawerfragment is null");
try {
navigationDrawerFragment.setUp(R.id.navigation_drawer, (DrawerLayout) findViewById(R.id.drawer_layout), getString(R.string.home_screen), this);
} catch (Exception e) {
Log.e("Runtime", "Exception with navigrationdrawerfragment: " + e.toString());
}
if (nexttoast != null) {
toast(nexttoast);
nexttoast = null;
}
// hide the treatment recognition text after some seconds
if ((last_speech_time > 0) && ((JoH.ts() - last_speech_time) > 20000)) {
voiceRecognitionText.setVisibility(View.INVISIBLE);
last_speech_time = 0;
}
if (ActivityRecognizedService.is_in_vehicle_mode()) {
btnVehicleMode.setVisibility(View.VISIBLE);
} else {
btnVehicleMode.setVisibility(View.INVISIBLE);
}
// if (isG5Share) showcasemenu(SHOWCASE_G5FIRMWARE); // nov 2016 firmware warning resolved 15/12/2016
// showcasemenu(1); // 3 dot menu
}
Aggregations