Skip to content

Commit f89933a

Browse files
Merge branch 'feature'
2 parents de97d5b + b8438d7 commit f89933a

File tree

124 files changed

+2098
-1141
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

124 files changed

+2098
-1141
lines changed

.github/workflows/android_ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ jobs:
1515
- name: unit tests
1616
run: bash ./gradlew testDebugUnitTest --stacktrace
1717
- name: coverage
18-
run: bash ./gradlew jacocoTestReport --stacktrace
18+
run: bash ./gradlew jacocoTestCoverageVerification --stacktrace
1919
- name: Upload coverage to Codecov
20-
uses: codecov/codecov-action@v1
20+
uses: codecov/codecov-action@v2
2121
with:
2222
token: ${{ secrets.CODECOV_TOKEN }}
2323
file: ./app/build/reports/jacoco/jacocoTestReport/jacocoTestReport.xml

README.md

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
<h1>WiFi Analyzer <img src="images/icon.png" alt="Application Icon" width="45" height="45"></h1>
22

3-
## News:
4-
- WiFi Analyzer rated as one of the 15 most useful apps for Android by [Android Authority](https://www.androidauthority.com/most-useful-apps-for-android-603100/amp)
5-
- [Gizmodo](https://gizmodo.com/the-best-wifi-analyzer-apps-to-troubleshoot-your-networ-1843957301) rates WiFi Analyzer one of The Best Apps for Fixing Your WiFi
6-
73
[<img src="https://play.google.com/intl/en_us/badges/images/generic/en_badge_web_generic.png" alt="Get it on Google Play" height="80">](https://play.google.com/store/apps/details?id=com.vrem.wifianalyzer)
84
[<img src="https://f-droid.org/badge/get-it-on.png" alt="Get it on F-Droid" height="80">](https://f-droid.org/repository/browse/?fdid=com.vrem.wifianalyzer)
95
[<img src="https://images-na.ssl-images-amazon.com/images/G/01/mobile-apps/devportal2/res/images/amazon-underground-app-us-white.png" alt="Get it at Amazon Store" height="70">
@@ -30,6 +26,7 @@ This is the official repository of WiFi Analyzer.
3026
* Graph Access Point signal strength over time
3127
* Analyze WiFi networks to rate channels
3228
* HT/VHT Detection - 40/80/160MHz (Requires Android OS 6+)
29+
* 2.4 GHz, 5 GHz and 6 GHz WiFi bands (Requires hardware support)
3330
* Access Point view complete or compact
3431
* Estimated Distance to the Access Points
3532
* Export access points details
@@ -42,7 +39,7 @@ This is the official repository of WiFi Analyzer.
4239
**Please note WiFi Analyzer is not a WiFi password cracking or phishing tool.**
4340

4441
## Usage Tips
45-
* Tap the title bar to switch between 2.4 and 5 GHz WiFi band.
42+
* Tap the title bar to switch between 2.4, 5 and 6 GHz WiFi band.
4643
* SSID with `***` or `*hidden*` means it is hidden.
4744
* Access Point security:
4845
* <img src="images/ic_lock_black_18dp.png" alt="WPA2/WPA" height="20"> WPA3(SAE)/WPA2/WPA
@@ -121,9 +118,9 @@ WiFi Analyzer is licensed under the GNU General Public License v3.0 (GPLv3).
121118
* Select the root directory of the WiFi Analyzer repository and click "OK".
122119
* WiFi Analyzer will build automatically.
123120

124-
### Running unit tests and jacoco coverage report
121+
### Running lint, unit tests and jacoco coverage report
125122
```
126-
./gradlew lint testDebugUnitTest jacocoTestReport
123+
./gradlew lintDebug jacocoTestCoverageVerification
127124
```
128125

129126
- lint report: `app/build/reports/lint-results.html`

app/build.gradle

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,22 +27,22 @@ dependencies {
2727
// Compile Build Dependencies
2828
implementation fileTree(include: ["*.jar"], dir: "libs")
2929
implementation 'com.google.android.material:material:1.4.0'
30-
implementation 'androidx.annotation:annotation:1.2.0'
31-
implementation 'androidx.collection:collection-ktx:1.1.0'
30+
implementation 'androidx.annotation:annotation:1.3.0'
31+
implementation 'androidx.collection:collection-ktx:1.2.0'
3232
implementation 'androidx.core:core-ktx:1.6.0'
3333
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
34-
implementation 'androidx.media:media:1.4.1'
34+
implementation 'androidx.media:media:1.4.3'
3535
implementation 'androidx.preference:preference-ktx:1.1.1'
3636
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
3737
implementation 'com.jjoe64:graphview:4.2.2'
3838
// Unit Test Dependencies
3939
testImplementation 'androidx.test.ext:junit:1.1.3'
4040
testImplementation 'com.googlecode.junit-toolbox:junit-toolbox:2.4'
4141
testImplementation 'com.nhaarman.mockitokotlin2:mockito-kotlin:2.2.0'
42-
testImplementation 'io.mockk:mockk:1.12.0'
42+
testImplementation 'io.mockk:mockk:1.12.1'
4343
testImplementation 'junit:junit:4.13.2'
44-
testImplementation 'org.mockito:mockito-core:3.11.2'
45-
testImplementation 'org.robolectric:robolectric:4.6.1'
44+
testImplementation 'org.mockito:mockito-core:4.2.0'
45+
testImplementation 'org.robolectric:robolectric:4.7.3'
4646
testImplementation "org.jetbrains.kotlin:kotlin-test:$kotlin_version"
4747
testImplementation "org.jetbrains.kotlin:kotlin-test-junit:$kotlin_version"
4848
// Android Test Dependencies

app/build.properties

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#Build Properties
2-
#Sat Aug 07 14:32:46 EDT 2021
2+
#Sat Dec 25 09:47:27 EST 2021
33
version_minor=0
44
version_store=57
55
version_patch=5
6-
version_build=2
6+
version_build=9
77
version_major=3

app/jacoco.gradle

Lines changed: 55 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -22,39 +22,71 @@ jacoco {
2222
toolVersion = "0.8.7"
2323
}
2424

25+
def executionPath = 'outputs/unit_test_code_coverage/debugUnitTest/testDebugUnitTest.exec'
26+
27+
def fileFilter = [
28+
'**/R.class',
29+
'**/R$*.class',
30+
'**/BuildConfig.*',
31+
'**/databinding/*.*',
32+
'**/Manifest*.*',
33+
'**/*Test*.*',
34+
'android/**/*.*',
35+
'**/com/jjoe64/*'
36+
]
37+
38+
def classJavaDir = "$project.buildDir/intermediates/javac/debug/classes"
39+
def classKotlinDir = "$project.buildDir/tmp/kotlin-classes/debug"
40+
def mainJavaSrc = "$project.projectDir/src/main/java"
41+
def mainKotlinSrc = "$project.projectDir/src/main/kotlin"
42+
def debugTree = fileTree(dir: classJavaDir, excludes: fileFilter) + fileTree(dir: classKotlinDir, excludes: fileFilter)
43+
2544
tasks.withType(Test) {
2645
jacoco.includeNoLocationClasses = true
2746
jacoco.excludes = ['jdk.internal.*']
2847
}
2948

3049
task jacocoTestReport(type: JacocoReport, dependsOn: ['testDebugUnitTest']) {
31-
3250
reports {
3351
xml.enabled = true
3452
html.enabled = true
3553
}
36-
37-
def fileFilter = [
38-
'**/R.class',
39-
'**/R$*.class',
40-
'**/BuildConfig.*',
41-
'**/databinding/*.*',
42-
'**/Manifest*.*',
43-
'**/*Test*.*',
44-
'android/**/*.*',
45-
'**/com/jjoe64/*'
46-
]
47-
48-
def classJavaDir = "$project.buildDir/intermediates/javac/debug/classes"
49-
def classKotlinDir = "$project.buildDir/tmp/kotlin-classes/debug"
50-
def mainJavaSrc = "$project.projectDir/src/main/java"
51-
def mainKotlinSrc = "$project.projectDir/src/main/kotlin"
52-
def debugTree = fileTree(dir: classJavaDir, excludes: fileFilter) +
53-
fileTree(dir: classKotlinDir, excludes: fileFilter)
54-
5554
sourceDirectories.from = files([mainJavaSrc, mainKotlinSrc])
5655
classDirectories.from = files([debugTree])
57-
executionData.from = fileTree(dir: project.buildDir, includes: [
58-
'outputs/unit_test_code_coverage/debugUnitTest/testDebugUnitTest.exec'
59-
])
56+
executionData.from = fileTree(dir: project.buildDir, includes: [executionPath])
57+
}
58+
59+
task jacocoTestCoverageVerification(type: JacocoCoverageVerification, dependsOn: 'jacocoTestReport') {
60+
sourceDirectories.from = files([[mainJavaSrc, mainKotlinSrc]])
61+
classDirectories.from = files([debugTree])
62+
executionData.from = fileTree(dir: project.buildDir, includes: [executionPath])
63+
violationRules {
64+
failOnViolation = true
65+
rule {
66+
limit {
67+
counter = 'INSTRUCTION'
68+
minimum = 0.96
69+
}
70+
limit {
71+
counter = 'BRANCH'
72+
minimum = 0.82
73+
}
74+
limit {
75+
counter = 'COMPLEXITY'
76+
minimum = 0.87
77+
}
78+
limit {
79+
counter = 'LINE'
80+
minimum = 0.97
81+
}
82+
limit {
83+
counter = 'METHOD'
84+
minimum = 0.97
85+
}
86+
limit {
87+
counter = 'CLASS'
88+
minimum = 0.99
89+
}
90+
}
91+
}
6092
}

app/src/main/kotlin/com/vrem/util/StringUtils.kt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,5 @@ val String.Companion.SPACE_SEPARATOR: String get() = " "
2525
fun String.specialTrim(): String =
2626
this.trim { it <= ' ' }.replace(" +".toRegex(), String.SPACE_SEPARATOR)
2727

28-
fun String.toHtml(color: Int, small: Boolean): String =
29-
"<font color='" + color + "'><" + (if (small) "small" else "strong") +
30-
">" + this + "</" + (if (small) "small" else "strong") + "></font>"
31-
3228
fun String.toCapitalize(locale: Locale): String =
3329
this.replaceFirstChar { word -> word.uppercase(locale) }

app/src/main/kotlin/com/vrem/wifianalyzer/ActivityUtils.kt

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ internal fun MainActivity.keepScreenOn() =
3333

3434
internal fun MainActivity.setupToolbar(): Toolbar {
3535
val toolbar: Toolbar = this.findViewById(R.id.toolbar)
36-
toolbar.setOnClickListener { toggleWiFiBand() }
3736
this.setSupportActionBar(toolbar)
3837
this.supportActionBar?.let {
3938
it.setHomeButtonEnabled(true)
@@ -42,12 +41,6 @@ internal fun MainActivity.setupToolbar(): Toolbar {
4241
return toolbar
4342
}
4443

45-
internal fun MainActivity.toggleWiFiBand() {
46-
if (this.currentNavigationMenu().wiFiBandSwitchable()) {
47-
MainContext.INSTANCE.settings.toggleWiFiBand()
48-
}
49-
}
50-
5144
internal fun makeIntent(action: String): Intent = Intent(action)
5245

5346
@TargetApi(Build.VERSION_CODES.Q)

app/src/main/kotlin/com/vrem/wifianalyzer/Configuration.kt

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,38 @@
1818
package com.vrem.wifianalyzer
1919

2020
import com.vrem.annotation.OpenClass
21+
import com.vrem.wifianalyzer.wifi.band.WiFiBand
22+
import com.vrem.wifianalyzer.wifi.band.WiFiChannelPair
2123
import com.vrem.wifianalyzer.wifi.band.WiFiChannels
2224

2325
const val SIZE_MIN = 1024
2426
const val SIZE_MAX = 4096
2527

2628
@OpenClass
2729
class Configuration(val largeScreen: Boolean) {
28-
var size = SIZE_MAX
30+
private var wiFiChannelPair = mutableMapOf<WiFiBand, WiFiChannelPair>()
2931

30-
var wiFiChannelPair = WiFiChannels.UNKNOWN
32+
var size = SIZE_MAX
3133

3234
val sizeAvailable: Boolean
3335
get() = size == SIZE_MAX
3436

37+
fun wiFiChannelPair(countryCode: String): Unit =
38+
WiFiBand.values().forEach {
39+
this.wiFiChannelPair[it] = it.wiFiChannels.wiFiChannelPairFirst(countryCode)
40+
}
41+
42+
fun wiFiChannelPair(wiFiBand: WiFiBand): WiFiChannelPair =
43+
this.wiFiChannelPair[wiFiBand]!!
44+
45+
fun wiFiChannelPair(wiFiBand: WiFiBand, wiFiChannelPair: WiFiChannelPair) {
46+
this.wiFiChannelPair[wiFiBand] = wiFiChannelPair
47+
}
48+
49+
init {
50+
WiFiBand.values().forEach {
51+
this.wiFiChannelPair[it] = WiFiChannels.UNKNOWN
52+
}
53+
54+
}
3555
}

app/src/main/kotlin/com/vrem/wifianalyzer/MainActivity.kt

Lines changed: 27 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -41,20 +41,21 @@ import com.vrem.wifianalyzer.permission.PermissionService
4141
import com.vrem.wifianalyzer.settings.Repository
4242
import com.vrem.wifianalyzer.settings.Settings
4343
import com.vrem.wifianalyzer.wifi.accesspoint.ConnectionView
44-
import com.vrem.wifianalyzer.wifi.band.WiFiBand
44+
import com.vrem.wifianalyzer.wifi.scanner.ScannerService
4545

4646
@OpenClass
4747
class MainActivity : AppCompatActivity(), NavigationMenuControl, OnSharedPreferenceChangeListener {
48-
lateinit var drawerNavigation: DrawerNavigation
49-
lateinit var mainReload: MainReload
50-
lateinit var navigationMenuController: NavigationMenuController
51-
lateinit var optionMenu: OptionMenu
52-
lateinit var permissionService: PermissionService
48+
internal lateinit var drawerNavigation: DrawerNavigation
49+
internal lateinit var mainReload: MainReload
50+
internal lateinit var navigationMenuController: NavigationMenuController
51+
internal lateinit var optionMenu: OptionMenu
52+
internal lateinit var permissionService: PermissionService
53+
internal lateinit var connectionView: ConnectionView
5354

5455
private var currentCountryCode: String = String.EMPTY
5556

5657
override fun attachBaseContext(newBase: Context) =
57-
super.attachBaseContext(newBase.createContext(Settings(Repository(newBase)).languageLocale()))
58+
super.attachBaseContext(newBase.createContext(Settings(Repository(newBase)).languageLocale()))
5859

5960
override fun onCreate(savedInstanceState: Bundle?) {
6061
val mainContext = MainContext.INSTANCE
@@ -84,11 +85,9 @@ class MainActivity : AppCompatActivity(), NavigationMenuControl, OnSharedPrefere
8485
navigationMenuController.currentNavigationMenu(settings.selectedMenu())
8586
onNavigationItemSelected(currentMenuItem())
8687

87-
val connectionView = ConnectionView(this)
88-
mainContext.scannerService.register(connectionView)
88+
connectionView = ConnectionView(this)
8989

9090
permissionService = PermissionService(this)
91-
permissionService.check()
9291
}
9392

9493
public override fun onPostCreate(savedInstanceState: Bundle?) {
@@ -112,8 +111,7 @@ class MainActivity : AppCompatActivity(), NavigationMenuControl, OnSharedPrefere
112111
val settings = mainContext.settings
113112
val countryCode = settings.countryCode()
114113
if (countryCode != currentCountryCode) {
115-
val pair = WiFiBand.GHZ5.wiFiChannels.wiFiChannelPairFirst(countryCode)
116-
mainContext.configuration.wiFiChannelPair = pair
114+
mainContext.configuration.wiFiChannelPair(countryCode)
117115
currentCountryCode = countryCode
118116
}
119117
}
@@ -172,27 +170,42 @@ class MainActivity : AppCompatActivity(), NavigationMenuControl, OnSharedPrefere
172170
}
173171

174172
public override fun onPause() {
175-
MainContext.INSTANCE.scannerService.pause()
173+
val scannerService: ScannerService = MainContext.INSTANCE.scannerService
174+
scannerService.pause()
175+
scannerService.unregister(connectionView)
176176
updateActionBar()
177177
super.onPause()
178178
}
179179

180180
public override fun onResume() {
181181
super.onResume()
182+
val scannerService: ScannerService = MainContext.INSTANCE.scannerService
182183
if (permissionService.permissionGranted()) {
183184
if (!permissionService.systemEnabled()) {
184185
startLocationSettings()
185186
}
186-
MainContext.INSTANCE.scannerService.resume()
187+
scannerService.resume()
188+
} else {
189+
scannerService.pause()
187190
}
188191
updateActionBar()
192+
scannerService.register(connectionView)
189193
}
190194

191195
public override fun onStop() {
192196
MainContext.INSTANCE.scannerService.stop()
193197
super.onStop()
194198
}
195199

200+
public override fun onStart() {
201+
super.onStart()
202+
if (permissionService.permissionGranted()) {
203+
MainContext.INSTANCE.scannerService.resume()
204+
} else {
205+
permissionService.check()
206+
}
207+
}
208+
196209
override fun onCreateOptionsMenu(menu: Menu): Boolean {
197210
optionMenu.create(this, menu)
198211
updateActionBar()

app/src/main/kotlin/com/vrem/wifianalyzer/MainContext.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ enum class MainContext {
6060
settings = Settings(Repository(context))
6161
vendorService = VendorService(activity.resources)
6262
wiFiManagerWrapper = WiFiManagerWrapper(wiFiManager)
63-
scannerService = makeScannerService(wiFiManagerWrapper, Handler(Looper.getMainLooper()), settings)
63+
scannerService = makeScannerService(mainActivity, wiFiManagerWrapper, Handler(Looper.getMainLooper()), settings)
6464
filtersAdapter = FiltersAdapter(settings)
6565
}
6666

0 commit comments

Comments
 (0)