Skip to content

Commit ebb37ee

Browse files
committed
Fixed companion app IoB reporting when CV is empty
1 parent c9d97e5 commit ebb37ee

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

app/src/main/java/com/eveningoutpost/dexdrip/services/UiBasedCollector.java

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,10 +171,24 @@ private void processCompanionAppIoBNotification(final Notification notification)
171171
if (notification.contentView != null) {
172172
processCompanionAppIoBNotificationCV(notification.contentView);
173173
} else {
174-
UserError.Log.e(TAG, "Content is empty");
174+
processCompanionAppIoBNotificationTitle(notification);
175175
}
176176
}
177177

178+
private void processCompanionAppIoBNotificationTitle(final Notification notification) {
179+
Double iob = null;
180+
try {
181+
String notificationTitle = notification.extras.getString("android.title");
182+
iob = parseIoB(notificationTitle);
183+
184+
if (iob != null) {
185+
if (debug) UserError.Log.d(TAG, "Inserting new IoB value extracted from title: " + iob);
186+
iob_store.set(iob);
187+
}
188+
} catch (Exception e) {
189+
UserError.Log.e(TAG, "exception in processCompanionAppIoBNotificationTitle: " + e);
190+
}
191+
}
178192
private void processCompanionAppIoBNotificationCV(final RemoteViews cview) {
179193
if (cview == null) return;
180194
val applied = cview.apply(this, null);
@@ -196,7 +210,7 @@ private void processCompanionAppIoBNotificationCV(final RemoteViews cview) {
196210
}
197211

198212
if (iob != null) {
199-
if (debug) UserError.Log.d(TAG, "Inserting new IoB value: " + iob);
213+
if (debug) UserError.Log.d(TAG, "Inserting new IoB value extracted from CV: " + iob);
200214
iob_store.set(iob);
201215
}
202216
} catch (Exception e) {

0 commit comments

Comments
 (0)