|
@@ -20,7 +20,6 @@ import androidx.recyclerview.widget.LinearLayoutManager
|
|
|
import androidx.recyclerview.widget.RecyclerView
|
|
import androidx.recyclerview.widget.RecyclerView
|
|
|
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout
|
|
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout
|
|
|
import im.angry.openeuicc.common.R
|
|
import im.angry.openeuicc.common.R
|
|
|
-import im.angry.openeuicc.core.EuiccChannel
|
|
|
|
|
import im.angry.openeuicc.core.EuiccChannelManager
|
|
import im.angry.openeuicc.core.EuiccChannelManager
|
|
|
import im.angry.openeuicc.util.*
|
|
import im.angry.openeuicc.util.*
|
|
|
import kotlinx.coroutines.Dispatchers
|
|
import kotlinx.coroutines.Dispatchers
|
|
@@ -33,7 +32,7 @@ class NotificationsActivity: BaseEuiccAccessActivity(), OpenEuiccContextMarker {
|
|
|
private lateinit var notificationList: RecyclerView
|
|
private lateinit var notificationList: RecyclerView
|
|
|
private val notificationAdapter = NotificationAdapter()
|
|
private val notificationAdapter = NotificationAdapter()
|
|
|
|
|
|
|
|
- private lateinit var euiccChannel: EuiccChannel
|
|
|
|
|
|
|
+ private var logicalSlotId = -1
|
|
|
|
|
|
|
|
override fun onCreate(savedInstanceState: Bundle?) {
|
|
override fun onCreate(savedInstanceState: Bundle?) {
|
|
|
enableEdgeToEdge()
|
|
enableEdgeToEdge()
|
|
@@ -56,7 +55,7 @@ class NotificationsActivity: BaseEuiccAccessActivity(), OpenEuiccContextMarker {
|
|
|
notificationList.adapter = notificationAdapter
|
|
notificationList.adapter = notificationAdapter
|
|
|
registerForContextMenu(notificationList)
|
|
registerForContextMenu(notificationList)
|
|
|
|
|
|
|
|
- val logicalSlotId = intent.getIntExtra("logicalSlotId", 0)
|
|
|
|
|
|
|
+ logicalSlotId = intent.getIntExtra("logicalSlotId", 0)
|
|
|
|
|
|
|
|
// This is slightly different from the MainActivity logic
|
|
// This is slightly different from the MainActivity logic
|
|
|
// due to the length (we don't want to display the full USB product name)
|
|
// due to the length (we don't want to display the full USB product name)
|
|
@@ -104,16 +103,8 @@ class NotificationsActivity: BaseEuiccAccessActivity(), OpenEuiccContextMarker {
|
|
|
swipeRefresh.isRefreshing = true
|
|
swipeRefresh.isRefreshing = true
|
|
|
|
|
|
|
|
lifecycleScope.launch {
|
|
lifecycleScope.launch {
|
|
|
- if (!this@NotificationsActivity::euiccChannel.isInitialized) {
|
|
|
|
|
- withContext(Dispatchers.IO) {
|
|
|
|
|
- euiccChannelManagerLoaded.await()
|
|
|
|
|
- euiccChannel = euiccChannelManager.findEuiccChannelBySlotBlocking(
|
|
|
|
|
- intent.getIntExtra(
|
|
|
|
|
- "logicalSlotId",
|
|
|
|
|
- 0
|
|
|
|
|
- )
|
|
|
|
|
- )!!
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ withContext(Dispatchers.IO) {
|
|
|
|
|
+ euiccChannelManagerLoaded.await()
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
task()
|
|
task()
|
|
@@ -124,13 +115,11 @@ class NotificationsActivity: BaseEuiccAccessActivity(), OpenEuiccContextMarker {
|
|
|
|
|
|
|
|
private fun refresh() {
|
|
private fun refresh() {
|
|
|
launchTask {
|
|
launchTask {
|
|
|
- val profiles = withContext(Dispatchers.IO) {
|
|
|
|
|
- euiccChannel.lpa.profiles
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
notificationAdapter.notifications =
|
|
notificationAdapter.notifications =
|
|
|
- withContext(Dispatchers.IO) {
|
|
|
|
|
- euiccChannel.lpa.notifications.map {
|
|
|
|
|
|
|
+ euiccChannelManager.withEuiccChannel(logicalSlotId) { channel ->
|
|
|
|
|
+ val profiles = channel.lpa.profiles
|
|
|
|
|
+
|
|
|
|
|
+ channel.lpa.notifications.map {
|
|
|
val profile = profiles.find { p -> p.iccid == it.iccid }
|
|
val profile = profiles.find { p -> p.iccid == it.iccid }
|
|
|
LocalProfileNotificationWrapper(it, profile?.displayName ?: "???")
|
|
LocalProfileNotificationWrapper(it, profile?.displayName ?: "???")
|
|
|
}
|
|
}
|
|
@@ -205,7 +194,9 @@ class NotificationsActivity: BaseEuiccAccessActivity(), OpenEuiccContextMarker {
|
|
|
R.id.notification_process -> {
|
|
R.id.notification_process -> {
|
|
|
launchTask {
|
|
launchTask {
|
|
|
withContext(Dispatchers.IO) {
|
|
withContext(Dispatchers.IO) {
|
|
|
- euiccChannel.lpa.handleNotification(notification.inner.seqNumber)
|
|
|
|
|
|
|
+ euiccChannelManager.withEuiccChannel(logicalSlotId) { channel ->
|
|
|
|
|
+ channel.lpa.handleNotification(notification.inner.seqNumber)
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
refresh()
|
|
refresh()
|
|
@@ -215,7 +206,9 @@ class NotificationsActivity: BaseEuiccAccessActivity(), OpenEuiccContextMarker {
|
|
|
R.id.notification_delete -> {
|
|
R.id.notification_delete -> {
|
|
|
launchTask {
|
|
launchTask {
|
|
|
withContext(Dispatchers.IO) {
|
|
withContext(Dispatchers.IO) {
|
|
|
- euiccChannel.lpa.deleteNotification(notification.inner.seqNumber)
|
|
|
|
|
|
|
+ euiccChannelManager.withEuiccChannel(logicalSlotId) { channel ->
|
|
|
|
|
+ channel.lpa.deleteNotification(notification.inner.seqNumber)
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
refresh()
|
|
refresh()
|