@@ -51,16 +51,21 @@ class CellDataViewModel : ViewModel(), DataViewModelInterface {
5151
5252 private val _coreConnected : MutableList <CellData > = Collections .synchronizedList(mutableListOf<CellData >())
5353 private val _coreAvailable : MutableList <CellData > = Collections .synchronizedList(mutableListOf<CellData >())
54+ private val _coreCA : MutableList <CellData > = Collections .synchronizedList(mutableListOf<CellData >())
5455
5556 private val _connectedCellDataList = MutableLiveData <List <CellData >>()
5657 val connectedCellDataList: LiveData <List <CellData >> get() = _connectedCellDataList
5758
5859 private val _availableCellDataList = MutableLiveData <List <CellData >>()
5960 val availableCellDataList: LiveData <List <CellData >> get() = _availableCellDataList
6061
62+ private val _caCellDataList = MutableLiveData <List <CellData >>()
63+ val caCellDataList: LiveData <List <CellData >> get() = _availableCellDataList
64+
6165 init {
6266 _connectedCellDataList .value = emptyList()
6367 _availableCellDataList .value = emptyList()
68+ _caCellDataList .value = emptyList()
6469 }
6570
6671 /* connected */
@@ -91,6 +96,20 @@ class CellDataViewModel : ViewModel(), DataViewModelInterface {
9196 return _coreAvailable .toMutableList()
9297 }
9398
99+ /* Carrier Aggregation (CA) */
100+
101+ private fun setCACellData (newList : List <CellData >) {
102+ _coreCA .clear()
103+ _coreCA .addAll(newList)
104+ DevPubUtils .dispatchToMainThread {
105+ _caCellDataList .value = _coreCA
106+ }
107+ }
108+
109+ fun getCACells (): List <CellData > {
110+ return _coreCA .toMutableList()
111+ }
112+
94113 /* logic */
95114
96115 private fun checkPhonePermission (context : Context ): Boolean {
@@ -142,6 +161,7 @@ class CellDataViewModel : ViewModel(), DataViewModelInterface {
142161
143162 val conList: MutableList <CellData > = mutableListOf<CellData >()
144163 val avaList: MutableList <CellData > = mutableListOf<CellData >()
164+ val caList: MutableList <CellData > = mutableListOf<CellData >()
145165
146166 currentCells.forEach { cell ->
147167 if (cell !is CellLte && cell !is CellNr ) {
@@ -186,12 +206,25 @@ class CellDataViewModel : ViewModel(), DataViewModelInterface {
186206 }
187207 if (cell.connectionStatus != NoneConnection ()) {
188208 conList.add(cellData)
209+ caList.add(cellData)
189210 } else {
190211 avaList.add(cellData)
191212 }
192213 }
214+ /* If there is one connected cell, take the best-RSRQ cell
215+ as an "estimate" to the potential Carrier Aggregation cells
216+ */
217+ if (caList.size == 1 && avaList.size >= 1 ) {
218+ val lowestRsrqCell = avaList
219+ .filter { it.rsrq != null }
220+ .maxByOrNull { it.rsrq!! }
221+ if (lowestRsrqCell != null ) {
222+ caList.add(lowestRsrqCell)
223+ }
224+ }
193225 setConnectedCellData(conList)
194226 setAvailableCellData(avaList)
227+ setCACellData(caList)
195228 }
196229
197230 companion object {
0 commit comments