Skip to content

Commit 0463377

Browse files
committed
2 parents 0c9bf6b + 8568fd3 commit 0463377

22 files changed

+92
-47
lines changed

app/src/main/java/com/eveningoutpost/dexdrip/GcmListenerSvc.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -392,6 +392,7 @@ public void onMessageReceived(RemoteMessage rmessage) {
392392
final String body = payloadA[1];
393393
final PendingIntent pendingIntent = android.app.PendingIntent.getActivity(xdrip.getAppContext(), 0, new Intent(xdrip.getAppContext(), Home.class), android.app.PendingIntent.FLAG_UPDATE_CURRENT);
394394
showNotification(title, body, pendingIntent, GCM_NOTIFICATION_ITEM, true, true, false);
395+
UserError.Log.uel(TAG, "Follower Notification with payload");
395396
} catch (Exception e) {
396397
UserError.Log.e(TAG, "Error showing follower notification with payload: " + payload);
397398
}
@@ -466,6 +467,7 @@ public void onMessageReceived(RemoteMessage rmessage) {
466467
}
467468
if (Pref.getBooleanDefaultFalse("follower_chime") && JoH.pratelimit("bgs-notify", 1200)) {
468469
JoH.showNotification("New glucose data @" + JoH.hourMinuteString(), "Follower Chime: will alert whenever it has been more than 20 minutes since last", null, 60311, true, true, true);
470+
UserError.Log.uel(TAG, "Follower Chime");
469471
}
470472
} else {
471473
Log.e(TAG, "Received remote BG packet but we are not set as a follower");

app/src/main/java/com/eveningoutpost/dexdrip/Home.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1007,6 +1007,7 @@ public void run() {
10071007
}
10081008
final PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, notificationIntent, PendingIntent.FLAG_UPDATE_CURRENT);
10091009
JoH.showNotification(bundle.getString(SHOW_NOTIFICATION), bundle.getString("notification_body"), pendingIntent, notification_id, true, true, true);
1010+
UserError.Log.uel(TAG, bundle.getString("notification_body"));
10101011
} else if (bundle.getString(Home.BLUETOOTH_METER_CALIBRATION) != null) {
10111012
try {
10121013
processFingerStickCalibration(JoH.tolerantParseDouble(bundle.getString(Home.BLUETOOTH_METER_CALIBRATION), 0d),

app/src/main/java/com/eveningoutpost/dexdrip/NFCReaderX.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -668,9 +668,13 @@ protected Tag doInBackground(Tag... params) {
668668
Log.d(TAG, "Not using addressed mode since not a libre 1 sensor");
669669
addressed = false;
670670
}
671-
if (sensorType == SensorType.Libre2) {
671+
if (sensorType == SensorType.Libre2 || sensorType == SensorType.Libre2Plus) {
672672
startLibre2Streaming(nfcvTag, patchUid, patchInfo);
673+
}
674+
if (sensorType == SensorType.Libre2) {
673675
PersistentStore.setString("LibreVersion", "2");
676+
} else if (sensorType == SensorType.Libre2Plus) {
677+
PersistentStore.setString("LibreVersion", "3");
674678
} else {
675679
PersistentStore.setString("LibreVersion", "1");
676680
}
@@ -680,7 +684,7 @@ protected Tag doInBackground(Tag... params) {
680684
for (int i = 0; i < 43; i = i + 3) {
681685
int read_blocks = 3;
682686
int correct_reply_size = addressed ? 28 : 25;
683-
if (i == 42 && sensorType == SensorType.Libre2) {
687+
if (i == 42 && (sensorType == SensorType.Libre2 || sensorType == SensorType.Libre2Plus)) {
684688
read_blocks = 1;
685689
correct_reply_size = 9;
686690
}

app/src/main/java/com/eveningoutpost/dexdrip/NavDrawerBuilder.java

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import android.content.Context;
44
import android.content.Intent;
55
import android.content.SharedPreferences;
6-
import android.os.Build;
76
import android.preference.PreferenceManager;
87

98
import com.eveningoutpost.dexdrip.g5model.FirmwareCapability;
@@ -41,6 +40,7 @@ public class NavDrawerBuilder {
4140
private static boolean use_note_search = false;
4241

4342
public NavDrawerBuilder(final Context context) {
43+
final DexCollectionType collector = DexCollectionType.getDexCollectionType();
4444

4545
final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
4646
boolean IUnderstand = prefs.getBoolean("I_understand", false);
@@ -68,33 +68,34 @@ public NavDrawerBuilder(final Context context) {
6868
if ((prefs.getString("dex_collection_method", "").equals("Follower"))) {
6969
this.nav_drawer_options.add(context.getString(R.string.add_calibration));
7070
this.nav_drawer_intents.add(new Intent(context, AddCalibration.class));
71-
} else {
71+
} else if (!collector.canNotStartStopOrCal()) {
72+
// Only if the collector can start/stop sensor and submit calibrations (is not passive)
7273

7374
if (is_active_sensor) {
7475
if (!CollectionServiceStarter.isBTShare(context)) {
7576
if (last_two_bgReadings.size() > 1 || Ob1G5CollectionService.isG5WantingCalibration()) {
76-
if ((last_two_calibrations.size() > 1) && !Ob1G5CollectionService.isG5WantingInitialCalibration()) { //After two successful initial calibrations
77+
if ((last_two_calibrations.size() > 1) && !Ob1G5CollectionService.isG5WantingInitialCalibration()) { // After two successful initial calibrations
7778
// TODO tighten this time limit
7879
if (bGreadings_in_last_30_mins.size() >= 2) {
7980
long time_now = JoH.tsl();
8081
if ((time_now - last_two_calibrations.get(0).timestamp < (1000 * 60 * 60))
81-
&& !Ob1G5CollectionService.isG5WantingCalibration()) { //Put steps in place to discourage over calibration
82+
&& !Ob1G5CollectionService.isG5WantingCalibration()) { // Put steps in place to discourage over calibration
8283
this.nav_drawer_options.add(context.getString(R.string.override_calibration));
8384
this.nav_drawer_intents.add(new Intent(context, CalibrationOverride.class));
84-
} else { //G5, old G6, or Firefly in no-code mode, after initial calibration and long enough after previous calibration
85+
} else { // G5, old G6, or Firefly in no-code mode, after initial calibration and long enough after previous calibration
8586
this.nav_drawer_options.add(context.getString(R.string.add_calibration));
8687
this.nav_drawer_intents.add(new Intent(context, AddCalibration.class));
8788
}
88-
} else { //G5, old G6 or Firefly in no-code mode, not long after a calibration
89+
} else { // G5, old G6 or Firefly in no-code mode, not long after a calibration
8990
this.nav_drawer_options.add(context.getString(R.string.cannot_calibrate_right_now));
9091
this.nav_drawer_intents.add(new Intent(context, Home.class));
9192
}
92-
} else { //If there haven't been two initial calibrations
93+
} else { // If there haven't been two initial calibrations
9394
if (BgReading.isDataSuitableForDoubleCalibration() || Ob1G5CollectionService.isG5WantingInitialCalibration()) {
9495
if ((FirmwareCapability.isTransmitterRawIncapable(getTransmitterID()) && last_two_bgReadings.size() > 1) || FirmwareCapability.isDeviceAltOrAlt2(getTransmitterID()) ) { //A Firefly G6 after third reading or a G7
9596
this.nav_drawer_options.add(context.getString(R.string.add_calibration));
9697
this.nav_drawer_intents.add(new Intent(context, AddCalibration.class));
97-
} else { //G5 or non-Firefly G6 or Firefly G6 in no-code mode, after warm-up before initial calibration
98+
} else { // G5 or non-Firefly G6 or Firefly G6 in no-code mode, after warm-up before initial calibration
9899
this.nav_drawer_options.add(context.getString(R.string.initial_calibration));
99100
this.nav_drawer_intents.add(new Intent(context, DoubleCalibrationActivity.class));
100101
}
@@ -112,12 +113,9 @@ public NavDrawerBuilder(final Context context) {
112113
}
113114
}
114115

115-
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
116-
if (DexCollectionType.hasBluetooth() && (DexCollectionType.getDexCollectionType() != DexCollectionType.DexcomG5)) {
117-
118-
this.nav_drawer_options.add(context.getString(R.string.bluetooth_scan));
119-
this.nav_drawer_intents.add(new Intent(context, BluetoothScan.class));
120-
}
116+
if (DexCollectionType.hasBluetooth() && (DexCollectionType.getDexCollectionType() != DexCollectionType.DexcomG5)) {
117+
this.nav_drawer_options.add(context.getString(R.string.bluetooth_scan));
118+
this.nav_drawer_intents.add(new Intent(context, BluetoothScan.class));
121119
}
122120

123121
//if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.JELLY_BEAN_MR2) {

app/src/main/java/com/eveningoutpost/dexdrip/alert/SensorExpiry.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import com.eveningoutpost.dexdrip.R;
1111
import com.eveningoutpost.dexdrip.g5model.SensorDays;
1212
import com.eveningoutpost.dexdrip.models.Treatments;
13+
import com.eveningoutpost.dexdrip.models.UserError;
1314
import com.eveningoutpost.dexdrip.models.UserError.Log;
1415
import com.eveningoutpost.dexdrip.utilitymodels.Constants;
1516
import com.eveningoutpost.dexdrip.xdrip;
@@ -49,6 +50,7 @@ public boolean activate() {
4950
val expireMsg = xdrip.gs(R.string.sensor_will_expire_in, expiry);
5051
showNotification(xdrip.gs(R.string.sensor_expiring), expireMsg, null, notificationId, null, true, true, null, null, null, true);
5152
Treatments.create_note("Warning: " + expireMsg, tsl()); // TODO i18n but note classifier also needs updating for that
53+
UserError.Log.uel(TAG, "Sensor will expire soon");
5254
return true;
5355
}
5456

app/src/main/java/com/eveningoutpost/dexdrip/alert/UpdateAvailable.java

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,16 @@
11
package com.eveningoutpost.dexdrip.alert;
22

33
import static com.eveningoutpost.dexdrip.models.JoH.cancelNotification;
4-
import static com.eveningoutpost.dexdrip.models.JoH.niceTimeScalar;
5-
import static com.eveningoutpost.dexdrip.models.JoH.niceTimeScalarNatural;
64
import static com.eveningoutpost.dexdrip.models.JoH.showNotification;
7-
import static com.eveningoutpost.dexdrip.models.JoH.tsl;
8-
import static com.eveningoutpost.dexdrip.utilitymodels.Constants.SENSORY_EXPIRY_NOTIFICATION_ID;
95
import static com.eveningoutpost.dexdrip.utilitymodels.Constants.XDRIP_UPDATE_NOTIFICATION_ID;
106
import static com.eveningoutpost.dexdrip.utilitymodels.UpdateActivity.AUTO_UPDATE_PREFS_NAME;
117

128
import android.app.PendingIntent;
139
import android.content.Intent;
1410

1511
import com.eveningoutpost.dexdrip.R;
16-
import com.eveningoutpost.dexdrip.g5model.SensorDays;
1712
import com.eveningoutpost.dexdrip.models.JoH;
18-
import com.eveningoutpost.dexdrip.models.Treatments;
1913
import com.eveningoutpost.dexdrip.models.UserError;
20-
import com.eveningoutpost.dexdrip.models.UserError.Log;
21-
import com.eveningoutpost.dexdrip.utilitymodels.Constants;
2214
import com.eveningoutpost.dexdrip.utilitymodels.PersistentStore;
2315
import com.eveningoutpost.dexdrip.utilitymodels.Pref;
2416
import com.eveningoutpost.dexdrip.utilitymodels.UpdateActivity;
@@ -55,6 +47,7 @@ public boolean activate() {
5547

5648
val channel = Pref.getString("update_channel", "beta"); // get the current update channel
5749
showNotification(xdrip.gs(R.string.xdrip_update), xdrip.gs(R.string.a_new_version_on_channel_1_s_is_available, channel), pendingIntent, notificationId, null, true, true, null, null, null, false);
50+
UserError.Log.uel(TAG, "A new version is available");
5851
return true;
5952
}
6053

app/src/main/java/com/eveningoutpost/dexdrip/cloud/backup/BackupActivity.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,7 @@ static PendingIntent getStartIntent() {
321321
static void notifySecurityError() {
322322
if (JoH.pratelimit("backup-security-notification-n", 60 * 60 * 12)) {
323323
showNotification(xdrip.gs(R.string.please_reselect_backup_file), xdrip.gs(R.string.backup_file_security_error_advice), getStartIntent(), BACKUP_ACTIVITY_ID, true, true, true);
324+
UserError.Log.uel(TAG, "Backup file is reporting security error. Re-select it to continue to allow xDrip access.");
324325
}
325326
}
326327
}

app/src/main/java/com/eveningoutpost/dexdrip/g5model/Ob1G5StateMachine.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1623,6 +1623,7 @@ private static void processGlucoseRxMessage(Ob1G5CollectionService parent, final
16231623
if (glucose.calibrationState().sensorFailed() && Sensor.isActive()) {
16241624
if (JoH.pratelimit("G5 Sensor Failed", 3600 * 3)) {
16251625
JoH.showNotification(devName() + " SENSOR FAILED", "Sensor reporting failed", null, Constants.G5_SENSOR_ERROR, true, true, false);
1626+
UserError.Log.uel(TAG, "Sensor reporting failed");
16261627
}
16271628
}
16281629
}
@@ -1726,6 +1727,7 @@ public static void evaluateG6Settings() {
17261727
if (!usingG6()) {
17271728
setG6Defaults();
17281729
JoH.showNotification("Enabled defaults", "Default settings automatically enabled", null, Constants.G6_DEFAULTS_MESSAGE, false, true, false);
1730+
UserError.Log.uel(TAG, "Default Dex settings automatically enabled");
17291731
} else if (!onlyUsingNativeMode() && !Home.get_engineering_mode()) {
17301732
// TODO revisit this now that there is scaling
17311733
setG6Defaults();
@@ -1824,6 +1826,7 @@ public synchronized static boolean setStoredBatteryBytes(String transmitterId, b
18241826
final boolean loud = !PowerStateReceiver.is_power_connected();
18251827
JoH.showNotification("Battery Low", "Transmitter battery has dropped to: " + batteryInfoRxMessage.voltagea + " it may fail soon",
18261828
null, 770, NotificationChannels.LOW_TRANSMITTER_BATTERY_CHANNEL, loud, loud, null, null, null);
1829+
UserError.Log.uel(TAG, "Dex battery has dropped to: " + batteryInfoRxMessage.voltagea);
18271830
}
18281831
}
18291832
PersistentStore.cleanupOld(G5_BATTERY_LEVEL_MARKER);

app/src/main/java/com/eveningoutpost/dexdrip/g5model/SensorDays.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import com.eveningoutpost.dexdrip.models.Sensor;
77
import com.eveningoutpost.dexdrip.R;
88
import com.eveningoutpost.dexdrip.utilitymodels.Constants;
9+
import com.eveningoutpost.dexdrip.utilitymodels.PersistentStore;
910
import com.eveningoutpost.dexdrip.utilitymodels.Pref;
1011
import com.eveningoutpost.dexdrip.utilitymodels.StatusItem.Highlight;
1112
import com.eveningoutpost.dexdrip.ui.helpers.Span;
@@ -80,7 +81,11 @@ public static SensorDays get(DexCollectionType type, final String tx_id) {
8081
val ths = new SensorDays();
8182

8283
if (hasLibre(type)) {
84+
String libreVersion = PersistentStore.getString("LibreVersion");
8385
ths.period = DAY_IN_MS * 14; // TODO 10 day sensors?
86+
if (libreVersion.equals("3")) {
87+
ths.period = DAY_IN_MS * 15;
88+
}
8489
ths.strategy = USE_LIBRE_STRATEGY;
8590
ths.warmupMs = HOUR_IN_MS;
8691

app/src/main/java/com/eveningoutpost/dexdrip/models/LibreOOPAlgorithm.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,8 @@ public enum SensorType {
5555
Libre1New(1),
5656
LibreUS14Day(2),
5757
Libre2(3),
58-
LibreProH(4);
58+
LibreProH(4),
59+
Libre2Plus(5);
5960

6061
int value;
6162

@@ -303,9 +304,10 @@ public static SensorType getSensorType(byte[] SensorInfo) {
303304
return SensorType.LibreUS14Day;
304305
case 0x9d0830:
305306
case 0xc50930:
306-
case 0xc60931:
307-
case 0x7f0e31:
308307
return SensorType.Libre2;
308+
case 0xc60931:
309+
case 0x7f0e31:
310+
return SensorType.Libre2Plus;
309311
case 0x700010:
310312
return SensorType.LibreProH;
311313
}
@@ -417,7 +419,7 @@ public static ArrayList<GlucoseData> parseBleDataHistory(byte[] ble_data, int[]
417419
// Functions that are used for an external decoder.
418420
static public boolean isDecodeableData(byte[] patchInfo) {
419421
SensorType sensorType = getSensorType(patchInfo);
420-
return sensorType == SensorType.LibreUS14Day || sensorType == SensorType.Libre2;
422+
return sensorType == SensorType.LibreUS14Day || sensorType == SensorType.Libre2 || sensorType == SensorType.Libre2Plus;
421423
}
422424

423425
// Two variables that are used to see if oop2 is installed.

0 commit comments

Comments
 (0)