Skip to content

Commit 47e1deb

Browse files
Merge branch 'main' into lang
2 parents dde367c + ad9dbf8 commit 47e1deb

7 files changed

Lines changed: 96 additions & 40 deletions

File tree

app/build.gradle

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
* along with this program. If not, see <http://www.gnu.org/licenses/>
1717
*/
1818

19+
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
20+
1921
plugins {
2022
id "com.android.application"
2123
id "kotlin-android"
@@ -98,7 +100,6 @@ android {
98100
applicationIdSuffix = ".BETA"
99101
versionNameSuffix = "-BETA"
100102
minifyEnabled = false
101-
shrinkResources = false
102103
debuggable = true
103104
enableUnitTestCoverage = true
104105
}
@@ -107,23 +108,27 @@ android {
107108
testOptions {
108109
unitTests {
109110
includeAndroidResources = true
110-
all {
111-
jvmArgs("-XX:+EnableDynamicAgentLoading")
112-
testLogging {
113-
events = ["passed", "skipped", "failed", "standardOut", "standardError"]
114-
outputs.upToDateWhen { false }
115-
showStandardStreams = true
116-
}
117-
}
111+
}
112+
}
113+
114+
tasks.withType(Test).configureEach {
115+
jvmArgs("-XX:+EnableDynamicAgentLoading")
116+
testLogging {
117+
events = ["passed", "skipped", "failed", "standardOut", "standardError"]
118+
outputs.upToDateWhen { false }
119+
showStandardStreams = true
118120
}
119121
}
120122

121123
compileOptions {
122124
sourceCompatibility = JavaVersion.VERSION_17
123125
targetCompatibility = JavaVersion.VERSION_17
124126
}
125-
kotlinOptions {
126-
jvmTarget = "17"
127+
128+
kotlin {
129+
compilerOptions {
130+
jvmTarget = JvmTarget.JVM_17
131+
}
127132
}
128133

129134
lint {
@@ -217,9 +222,9 @@ def isReleaseTask() {
217222
static Properties readProperties(propertiesFile) {
218223
if (propertiesFile.canRead()) {
219224
Properties properties = new Properties()
220-
def inputStream = new FileInputStream(propertiesFile)
221-
properties.load(inputStream)
222-
inputStream.close()
225+
propertiesFile.withInputStream { inputStream ->
226+
properties.load(inputStream)
227+
}
223228
return properties
224229
} else {
225230
def message = ">>> Could not read " + propertiesFile.name + " file!"
@@ -229,12 +234,12 @@ static Properties readProperties(propertiesFile) {
229234
}
230235

231236
def static writeProperties(propertiesFile, properties) {
232-
def writer = propertiesFile.newWriter()
233-
properties.store(writer, "Build Properties")
234-
writer.close()
237+
propertiesFile.withWriter { writer ->
238+
properties.store(writer, "Build Properties")
239+
}
235240
}
236241

237-
configurations.all {
242+
configurations.configureEach {
238243
exclude group: 'org.hamcrest', module: 'hamcrest-core'
239244
exclude group: 'org.hamcrest', module: 'hamcrest-library'
240245
}

app/build.properties

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#Build Properties
2-
#Sat May 30 10:26:06 EDT 2026
3-
version_build=8
2+
#Fri Jun 12 17:09:03 EDT 2026
3+
version_build=9
44
version_major=3
55
version_minor=2
66
version_patch=2

app/src/main/kotlin/com/vrem/wifianalyzer/wifi/timegraph/DataManager.kt

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import com.vrem.wifianalyzer.wifi.graphutils.MAX_SCAN_COUNT
2525
import com.vrem.wifianalyzer.wifi.graphutils.MIN_Y
2626
import com.vrem.wifianalyzer.wifi.graphutils.MIN_Y_OFFSET
2727
import com.vrem.wifianalyzer.wifi.model.WiFiDetail
28+
import com.vrem.wifianalyzer.wifi.predicate.Predicate
2829

2930
@OpenClass
3031
internal class DataManager(
@@ -37,34 +38,42 @@ internal class DataManager(
3738
graphViewWrapper: GraphViewWrapper,
3839
wiFiDetails: List<WiFiDetail>,
3940
levelMax: Int,
41+
predicate: Predicate,
4042
): Set<WiFiDetail> {
4143
val inOrder: Set<WiFiDetail> = wiFiDetails.toSet()
4244
inOrder.forEach { addData(graphViewWrapper, it, levelMax) }
43-
adjustData(graphViewWrapper, inOrder)
45+
adjustData(graphViewWrapper, inOrder, predicate)
4446
xValue++
4547
if (scanCount < MAX_SCAN_COUNT) {
4648
scanCount++
4749
}
4850
if (scanCount == 2) {
4951
graphViewWrapper.setHorizontalLabelsVisible(true)
5052
}
51-
return newSeries(inOrder)
53+
return newSeries(inOrder, predicate)
5254
}
5355

5456
fun adjustData(
5557
graphViewWrapper: GraphViewWrapper,
5658
wiFiDetails: Set<WiFiDetail>,
59+
predicate: Predicate,
5760
) {
58-
graphViewWrapper.differenceSeries(wiFiDetails).forEach {
59-
val dataPoint = GraphDataPoint(xValue, MIN_Y + MIN_Y_OFFSET)
60-
val drawBackground = it.wiFiAdditional.wiFiConnection.connected
61-
graphViewWrapper.appendToSeries(it, dataPoint, scanCount, drawBackground)
62-
timeGraphCache.add(it)
63-
}
61+
graphViewWrapper
62+
.differenceSeries(wiFiDetails)
63+
.filter { predicate(it) }
64+
.forEach {
65+
val dataPoint = GraphDataPoint(xValue, MIN_Y + MIN_Y_OFFSET)
66+
val drawBackground = it.wiFiAdditional.wiFiConnection.connected
67+
graphViewWrapper.appendToSeries(it, dataPoint, scanCount, drawBackground)
68+
timeGraphCache.add(it)
69+
}
6470
timeGraphCache.clear()
6571
}
6672

67-
fun newSeries(wiFiDetails: Set<WiFiDetail>): Set<WiFiDetail> = wiFiDetails.plus(timeGraphCache.active())
73+
fun newSeries(
74+
wiFiDetails: Set<WiFiDetail>,
75+
predicate: Predicate,
76+
): Set<WiFiDetail> = wiFiDetails.plus(timeGraphCache.active().filter { predicate(it) })
6877

6978
fun addData(
7079
graphViewWrapper: GraphViewWrapper,

app/src/main/kotlin/com/vrem/wifianalyzer/wifi/timegraph/TimeGraphView.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ internal class TimeGraphView(
7070
graphViewWrapper,
7171
wiFiDetails,
7272
MainContext.INSTANCE.settings.graphMaximumY(),
73+
predicate,
7374
)
7475
graphViewWrapper.removeSeries(newSeries)
7576
graphViewWrapper.updateLegend(MainContext.INSTANCE.settings.timeGraphLegend())

app/src/test/kotlin/com/vrem/wifianalyzer/wifi/timegraph/DataManagerTest.kt

Lines changed: 49 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ import com.vrem.wifianalyzer.wifi.model.WiFiIdentifier
3333
import com.vrem.wifianalyzer.wifi.model.WiFiSecurity
3434
import com.vrem.wifianalyzer.wifi.model.WiFiSignal
3535
import com.vrem.wifianalyzer.wifi.model.WiFiWidth
36+
import com.vrem.wifianalyzer.wifi.predicate.falsePredicate
37+
import com.vrem.wifianalyzer.wifi.predicate.truePredicate
3638
import org.assertj.core.api.Assertions.assertThat
3739
import org.junit.Test
3840
import org.junit.runner.RunWith
@@ -59,7 +61,7 @@ class DataManagerTest {
5961
// setup
6062
assertThat(fixture.xValue).isEqualTo(0)
6163
// execute
62-
fixture.addSeriesData(graphViewWrapper, listOf(), MAX_Y)
64+
fixture.addSeriesData(graphViewWrapper, listOf(), MAX_Y, truePredicate)
6365
// validate
6466
assertThat(fixture.xValue).isEqualTo(1)
6567
}
@@ -69,7 +71,7 @@ class DataManagerTest {
6971
// setup
7072
assertThat(fixture.scanCount).isEqualTo(0)
7173
// execute
72-
fixture.addSeriesData(graphViewWrapper, listOf(), MAX_Y)
74+
fixture.addSeriesData(graphViewWrapper, listOf(), MAX_Y, truePredicate)
7375
// validate
7476
assertThat(fixture.scanCount).isEqualTo(1)
7577
}
@@ -80,7 +82,7 @@ class DataManagerTest {
8082
val wiFiDetails = makeWiFiDetails()
8183
val wiFiDetailsSet = wiFiDetails.toSet()
8284
// execute
83-
fixture.addSeriesData(graphViewWrapper, wiFiDetails, MAX_Y)
85+
fixture.addSeriesData(graphViewWrapper, wiFiDetails, MAX_Y, truePredicate)
8486
// validate
8587
wiFiDetailsSet.forEach {
8688
verify(graphViewWrapper).newSeries(it)
@@ -93,7 +95,7 @@ class DataManagerTest {
9395
// setup
9496
fixture.scanCount = MAX_SCAN_COUNT
9597
// execute
96-
fixture.addSeriesData(graphViewWrapper, listOf(), MAX_Y)
98+
fixture.addSeriesData(graphViewWrapper, listOf(), MAX_Y, truePredicate)
9799
// validate
98100
assertThat(fixture.scanCount).isEqualTo(MAX_SCAN_COUNT)
99101
}
@@ -103,7 +105,7 @@ class DataManagerTest {
103105
// setup
104106
fixture.scanCount = 1
105107
// execute
106-
fixture.addSeriesData(graphViewWrapper, listOf(), MAX_Y)
108+
fixture.addSeriesData(graphViewWrapper, listOf(), MAX_Y, truePredicate)
107109
// validate
108110
assertThat(fixture.scanCount).isEqualTo(2)
109111
verify(graphViewWrapper).setHorizontalLabelsVisible(true)
@@ -112,7 +114,7 @@ class DataManagerTest {
112114
@Test
113115
fun addSeriesDoesNotSetHorizontalLabelsVisible() {
114116
// execute
115-
fixture.addSeriesData(graphViewWrapper, listOf(), MAX_Y)
117+
fixture.addSeriesData(graphViewWrapper, listOf(), MAX_Y, truePredicate)
116118
// validate
117119
verify(graphViewWrapper, never()).setHorizontalLabelsVisible(true)
118120
}
@@ -127,7 +129,7 @@ class DataManagerTest {
127129
val dataPoint = GraphDataPoint(xValue, MIN_Y + MIN_Y_OFFSET)
128130
whenever(graphViewWrapper.differenceSeries(wiFiDetails)).thenReturn(difference)
129131
// execute
130-
fixture.adjustData(graphViewWrapper, wiFiDetails)
132+
fixture.adjustData(graphViewWrapper, wiFiDetails, truePredicate)
131133
// validate
132134
difference.forEach {
133135
verify(graphViewWrapper).appendToSeries(
@@ -148,13 +150,52 @@ class DataManagerTest {
148150
val moreWiFiDetails: Set<WiFiDetail> = makeMoreWiFiDetails().toSet()
149151
whenever(timeGraphCache.active()).thenReturn(moreWiFiDetails)
150152
// execute
151-
val actual = fixture.newSeries(wiFiDetails)
153+
val actual = fixture.newSeries(wiFiDetails, truePredicate)
152154
// validate
153155
assertThat(actual).containsAll(wiFiDetails)
154156
assertThat(actual).containsAll(moreWiFiDetails)
155157
verify(timeGraphCache).active()
156158
}
157159

160+
@Test
161+
fun newSeriesShouldNotIncludeActiveCacheEntriesNotInCurrentWiFiDetails() {
162+
// Expected: newSeries includes currentDetails and only those active cache
163+
// entries that satisfy the given predicate. Entries from timeGraphCache.active()
164+
// that do not match the predicate (e.g. filtered-out SSIDs) must be excluded.
165+
// setup
166+
val currentDetails: Set<WiFiDetail> = makeWiFiDetails().toSet()
167+
val staleEntries: Set<WiFiDetail> = makeMoreWiFiDetails().toSet()
168+
whenever(timeGraphCache.active()).thenReturn(staleEntries)
169+
// execute
170+
val actual = fixture.newSeries(currentDetails, falsePredicate)
171+
assertThat(actual).containsAll(currentDetails)
172+
assertThat(actual).doesNotContainAnyElementsOf(staleEntries)
173+
verify(timeGraphCache).active()
174+
}
175+
176+
@Test
177+
fun adjustDataShouldNotAppendToStaleCacheEntriesNotInCurrentDetails() {
178+
// Expected: adjustData only appends floor data points and increments the
179+
// TimeGraphCache counter for differenceSeries entries that satisfy the
180+
// given predicate. Entries that do not match must be left untouched.
181+
// setup
182+
val currentDetails: Set<WiFiDetail> = makeWiFiDetails().toSet()
183+
val staleEntry: WiFiDetail = makeWiFiDetail("SSID4")
184+
whenever(graphViewWrapper.differenceSeries(currentDetails))
185+
.thenReturn(listOf(staleEntry))
186+
// execute
187+
fixture.adjustData(graphViewWrapper, currentDetails, falsePredicate)
188+
verify(graphViewWrapper, never()).appendToSeries(
189+
eq(staleEntry),
190+
any(),
191+
any(),
192+
any(),
193+
)
194+
// validate: stale entries must NOT be added to the time graph cache
195+
verify(timeGraphCache, never()).add(staleEntry)
196+
verify(timeGraphCache).clear()
197+
}
198+
158199
@Test
159200
fun addDataToExistingSeries() {
160201
// setup

app/src/test/kotlin/com/vrem/wifianalyzer/wifi/timegraph/TimeGraphViewTest.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ class TimeGraphViewTest {
7070
val wiFiData = WiFiData(wiFiDetails, WiFiConnection.EMPTY)
7171
val predicate: Predicate = truePredicate
7272
doReturn(predicate).whenever(fixture).predicate(settings)
73-
whenever(dataManager.addSeriesData(graphViewWrapper, wiFiDetails, MAX_Y)).thenReturn(newSeries)
73+
whenever(dataManager.addSeriesData(graphViewWrapper, wiFiDetails, MAX_Y, predicate)).thenReturn(newSeries)
7474
whenever(settings.sortBy()).thenReturn(SortBy.SSID)
7575
whenever(settings.timeGraphLegend()).thenReturn(GraphLegend.LEFT)
7676
whenever(settings.wiFiBand()).thenReturn(WiFiBand.GHZ2)
@@ -80,7 +80,7 @@ class TimeGraphViewTest {
8080
fixture.update(wiFiData)
8181
// validate
8282
verify(fixture).predicate(settings)
83-
verify(dataManager).addSeriesData(graphViewWrapper, wiFiDetails, MAX_Y)
83+
verify(dataManager).addSeriesData(graphViewWrapper, wiFiDetails, MAX_Y, predicate)
8484
verify(graphViewWrapper).removeSeries(newSeries)
8585
verify(graphViewWrapper).updateLegend(GraphLegend.LEFT)
8686
verify(graphViewWrapper).visibility(View.VISIBLE)

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
buildscript {
2222
ext {
23-
kotlin_version = '2.3.21'
23+
kotlin_version = '2.4.0'
2424
}
2525
repositories {
2626
google()

0 commit comments

Comments
 (0)