Skip to content

Commit

Permalink
OB1: disallow scan by mac
Browse files Browse the repository at this point in the history
  • Loading branch information
jamorham committed Jul 2, 2023
1 parent 498962f commit 35c1519
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import static com.eveningoutpost.dexdrip.g5model.Ob1G5StateMachine.pendingStart;
import static com.eveningoutpost.dexdrip.g5model.Ob1G5StateMachine.pendingStop;
import static com.eveningoutpost.dexdrip.g5model.Ob1G5StateMachine.usingAlt;
import static com.eveningoutpost.dexdrip.models.JoH.emptyString;
import static com.eveningoutpost.dexdrip.models.JoH.msSince;
import static com.eveningoutpost.dexdrip.models.JoH.niceTimeScalar;
import static com.eveningoutpost.dexdrip.models.JoH.tolerantHexStringToByteArray;
Expand Down Expand Up @@ -227,6 +228,7 @@ public class Ob1G5CollectionService extends G5BaseService {
private static volatile int skippedConnects = 0;
private static final boolean d = false;

private static final boolean allow_scan_by_mac = false;
private static boolean use_auto_connect = false;
private static volatile boolean minimize_scanning = false; // set by preference
private static volatile boolean always_scan = false;
Expand Down Expand Up @@ -553,7 +555,7 @@ private synchronized void scan_for_device() {
historicalTransmitterMAC = PersistentStore.getString(OB1G5_MACSTORE + transmitterID); // "" if unset

ScanFilter filter;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O && historicalTransmitterMAC.length() > 5) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O && historicalTransmitterMAC.length() > 5 && allow_scan_by_mac) {
filter = new ScanFilter.Builder()
.setDeviceAddress(historicalTransmitterMAC)
.build();
Expand Down Expand Up @@ -1176,7 +1178,7 @@ private synchronized void stopDiscover() {
}

private boolean isScanMatch(final String this_address, final String historical_address, final String this_name, final String search_name) {
if (search_name == null && (this_address.equalsIgnoreCase(historical_address) || this_name == null || this_name.startsWith("DXCM"))) {
if (search_name == null && (this_address.equalsIgnoreCase(historical_address) || this_name == null || (emptyString(historical_address) && this_name.startsWith("DXCM")))) {
return !inFailureTally(this_address);
}

Expand Down

0 comments on commit 35c1519

Please sign in to comment.