Skip to content

Commit 8672cb6

Browse files
bastian-srcBastian Schmidt
authored andcommitted
Fix nullable cell and split cell id in enb, cid, and pci
1 parent b5e0b39 commit 8672cb6

File tree

5 files changed

+223
-148
lines changed

5 files changed

+223
-148
lines changed

.idea/deploymentTargetDropDown.xml

Lines changed: 14 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ android {
1010

1111
defaultConfig {
1212
applicationId = "eu.bschmidt.devicepublisher"
13-
minSdk = 28
13+
minSdk = 25
1414
targetSdk = 34
1515
versionCode = 1
1616
versionName = "1.0"

app/src/main/java/eu/bschmidt/devicepublisher/model/celldata/CellDataViewModel.kt

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,37 +5,24 @@ import android.content.Context
55
import android.content.pm.PackageManager
66
import android.net.ConnectivityManager
77
import android.net.Network
8-
import android.net.NetworkCapabilities
98
import android.os.Build
10-
import android.provider.SimPhonebookContract.ElementaryFiles.SUBSCRIPTION_ID
11-
import android.telephony.SubscriptionInfo
129
import android.util.Log
1310
import androidx.annotation.RequiresApi
1411
import androidx.core.app.ActivityCompat
15-
import androidx.core.content.ContextCompat.getSystemService
1612
import androidx.lifecycle.LiveData
1713
import androidx.lifecycle.MutableLiveData
1814
import androidx.lifecycle.ViewModel
19-
import cz.mroczis.netmonster.core.db.model.NetworkType
2015
import cz.mroczis.netmonster.core.factory.NetMonsterFactory
21-
import cz.mroczis.netmonster.core.feature.detect.DetectorHspaDc
22-
import cz.mroczis.netmonster.core.feature.detect.DetectorLteAdvancedNrDisplayInfo
23-
import cz.mroczis.netmonster.core.feature.detect.DetectorLteAdvancedNrServiceState
24-
import cz.mroczis.netmonster.core.feature.detect.DetectorLteAdvancedPhysicalChannel
2516
import cz.mroczis.netmonster.core.model.cell.CellLte
2617
import cz.mroczis.netmonster.core.model.cell.CellNr
2718
import cz.mroczis.netmonster.core.model.cell.ICell
2819
import cz.mroczis.netmonster.core.model.connection.NoneConnection
29-
import cz.mroczis.netmonster.core.model.nr.NrNsaState
30-
import eu.bschmidt.devicepublisher.MainActivity
3120
import eu.bschmidt.devicepublisher.MainApplication
3221
import eu.bschmidt.devicepublisher.model.DataViewModelInterface
33-
import eu.bschmidt.devicepublisher.service.APIService
3422
import eu.bschmidt.devicepublisher.util.DevPubUtils
3523
import kotlinx.coroutines.runBlocking
3624
import kotlinx.serialization.Serializable
3725
import java.util.Collections
38-
import kotlin.random.Random
3926

4027
@Serializable
4128
enum class CellType(val type: String) {
@@ -46,7 +33,9 @@ enum class CellType(val type: String) {
4633

4734
@Serializable
4835
data class CellData (
49-
val id: Int? = 0,
36+
val nodeB: Int? = 0,
37+
val cid: Long? = 0,
38+
val pci: Int? = 0,
5039
val type: CellType = CellType.None,
5140
val arfcn: Int = 0,
5241
val frequency: Int? = 0,
@@ -163,7 +152,10 @@ class CellDataViewModel : ViewModel(), DataViewModelInterface {
163152
when (cell) {
164153
is CellLte -> {
165154
val lteCell: CellLte = cell
166-
cellData = CellData(id = lteCell.cid,
155+
cellData = CellData(
156+
cid = lteCell.cid?.toLong(),
157+
nodeB = lteCell.enb,
158+
pci = lteCell.pci,
167159
type = CellType.LTE,
168160
arfcn = lteCell.band!!.downlinkEarfcn,
169161
band = lteCell.band!!.name!!,
@@ -176,7 +168,10 @@ class CellDataViewModel : ViewModel(), DataViewModelInterface {
176168
}
177169
is CellNr -> {
178170
val nrCell: CellNr = cell
179-
cellData = CellData(id = nrCell.pci,
171+
cellData = CellData(
172+
cid = nrCell.nci,
173+
nodeB = null,
174+
pci = nrCell.pci,
180175
type = CellType.NR,
181176
arfcn = nrCell.band!!.downlinkArfcn,
182177
band = nrCell.band!!.name!!,

app/src/main/java/eu/bschmidt/devicepublisher/ui/celldata/CellDataRecyclerViewAdapter.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,11 @@ class CellDataRecyclerViewAdapter(
2525

2626
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
2727
val item = values[position]
28-
holder.cellIdTextView.text = item.id.toString()
28+
val mostLikelyId = item.cid ?: item.pci ?: item.nodeB
29+
holder.cellIdTextView.text = mostLikelyId.toString()
2930
holder.cellTypeTextView.text = item.type.toString()
3031
holder.arfcnTextView.text = item.arfcn.toString()
31-
holder.bandTextView.text = item.band.toString()
32+
holder.bandTextView.text = item.band
3233
holder.rssiTextView.text = item.rssi.toString()
3334
holder.rsrpTextView.text = item.rsrq.toString()
3435
holder.rsrqTextView.text = item.rsrp.toString()

0 commit comments

Comments
 (0)