Skip to content

Commit

Permalink
Fix CMin use from testing
Browse files Browse the repository at this point in the history
  • Loading branch information
danilo-delbusso committed Apr 4, 2021
1 parent 290a493 commit 7f10858
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions app/src/main/java/com/prj/app/logic/RiskAnalyser.java
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ private void sendMatchingBSSIDsPOST(@NotNull String URL, @NotNull JSONObject jso
*/
public boolean matchResult(@NotNull JSONArray matchingScans) {
List<Scan> localScans = databaseManager.getScanData();
if (localScans.size() < 1) {
if (localScans == null || matchingScans == null || localScans.size() < 1) {
if (resultTextView != null) {
resultTextView.setText("No matches found\n");
}
Expand Down Expand Up @@ -178,7 +178,7 @@ public List<Pair<Date, List<Scan>>> getFirstPositiveResult(@NotNull TreeMap<Date
double timeDiff = Math.abs(lastTimestamp.getTime() - timestamp.getTime()) / 1000.0;
if (timeDiff <= preferencesManager.getTMax()) {
dateStorage.add(new Pair<>(timestamp, timeMap.get(timestamp)));
if (dateStorage.size() >= preferencesManager.getCMin()) {
if (dateStorage.size() >= preferencesManager.getCMin() - 1 ) {
return dateStorage;
}
} else {
Expand All @@ -188,7 +188,7 @@ public List<Pair<Date, List<Scan>>> getFirstPositiveResult(@NotNull TreeMap<Date
}
}

if (dateStorage.size() <= preferencesManager.getCMin()) {
if (dateStorage.size() <= preferencesManager.getCMin()+ 1) {
dateStorage.clear();
}
return dateStorage;
Expand Down Expand Up @@ -292,7 +292,7 @@ private List<Scan> removeNonConcurrentScans(@NotNull List<Scan> localScans) {
if (scanTimeDifference(lastScan, current) <= preferencesManager.getTMax()) {
storageList.add(current);
} else {
if (storageList.size() >= preferencesManager.getCMin()) {
if (storageList.size() >= preferencesManager.getCMin() -1 ) {
validScans.addAll(storageList);
}
storageList.clear();
Expand All @@ -313,7 +313,7 @@ private List<Scan> removeNonConcurrentScans(@NotNull List<Scan> localScans) {

}
for (ArrayList<Scan> scans : storage.values()) {
if (scans.size() >= preferencesManager.getCMin()) {
if (scans.size() >= preferencesManager.getCMin() - 1) {
validScans.addAll(scans);
}
}
Expand Down

0 comments on commit 7f10858

Please sign in to comment.