EuiccManagementFragment: Show alert dialog if timed out waiting for SIM
All checks were successful
/ build-debug (push) Successful in 4m17s
All checks were successful
/ build-debug (push) Successful in 4m17s
This commit is contained in:
parent
d9d0cf2e75
commit
92d8f9079f
|
@ -16,6 +16,7 @@ import android.widget.ImageButton
|
||||||
import android.widget.PopupMenu
|
import android.widget.PopupMenu
|
||||||
import android.widget.TextView
|
import android.widget.TextView
|
||||||
import android.widget.Toast
|
import android.widget.Toast
|
||||||
|
import androidx.appcompat.app.AlertDialog
|
||||||
import androidx.fragment.app.Fragment
|
import androidx.fragment.app.Fragment
|
||||||
import androidx.lifecycle.lifecycleScope
|
import androidx.lifecycle.lifecycleScope
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager
|
import androidx.recyclerview.widget.LinearLayoutManager
|
||||||
|
@ -26,6 +27,7 @@ import net.typeblog.lpac_jni.LocalProfileInfo
|
||||||
import im.angry.openeuicc.common.R
|
import im.angry.openeuicc.common.R
|
||||||
import im.angry.openeuicc.util.*
|
import im.angry.openeuicc.util.*
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
|
import kotlinx.coroutines.TimeoutCancellationException
|
||||||
import kotlinx.coroutines.flow.first
|
import kotlinx.coroutines.flow.first
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import kotlinx.coroutines.withContext
|
import kotlinx.coroutines.withContext
|
||||||
|
@ -138,6 +140,19 @@ open class EuiccManagementFragment : Fragment(), EuiccProfilesChangedListener,
|
||||||
}
|
}
|
||||||
refresh()
|
refresh()
|
||||||
fab.isEnabled = true
|
fab.isEnabled = true
|
||||||
|
} catch (e: TimeoutCancellationException) {
|
||||||
|
// Timed out waiting for SIM to come back online, we can no longer assume that the LPA is still valid
|
||||||
|
AlertDialog.Builder(requireContext()).apply {
|
||||||
|
setMessage(R.string.enable_disable_timeout)
|
||||||
|
setPositiveButton(android.R.string.ok) { dialog, _ ->
|
||||||
|
dialog.dismiss()
|
||||||
|
requireActivity().finish()
|
||||||
|
}
|
||||||
|
setOnDismissListener { _ ->
|
||||||
|
requireActivity().finish()
|
||||||
|
}
|
||||||
|
show()
|
||||||
|
}
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
Log.d(TAG, "Failed to enable / disable profile $iccid")
|
Log.d(TAG, "Failed to enable / disable profile $iccid")
|
||||||
Log.d(TAG, Log.getStackTraceString(e))
|
Log.d(TAG, Log.getStackTraceString(e))
|
||||||
|
|
|
@ -16,6 +16,8 @@
|
||||||
<string name="delete">Delete</string>
|
<string name="delete">Delete</string>
|
||||||
<string name="rename">Rename</string>
|
<string name="rename">Rename</string>
|
||||||
|
|
||||||
|
<string name="enable_disable_timeout">Timed out waiting for the eSIM chip to switch profiles. You might want to restart the application or even the phone.</string>
|
||||||
|
|
||||||
<string name="toast_profile_enable_failed">Cannot switch to new eSIM profile.</string>
|
<string name="toast_profile_enable_failed">Cannot switch to new eSIM profile.</string>
|
||||||
<string name="toast_profile_name_too_long">Nickname cannot be longer than 64 characters</string>
|
<string name="toast_profile_name_too_long">Nickname cannot be longer than 64 characters</string>
|
||||||
|
|
||||||
|
|
|
@ -90,11 +90,7 @@ class LocalProfileAssistantImpl(
|
||||||
override fun enableProfile(iccid: String, reconnectTimeout: Long): Boolean {
|
override fun enableProfile(iccid: String, reconnectTimeout: Long): Boolean {
|
||||||
val res = LpacJni.es10cEnableProfile(contextHandle, iccid) == 0
|
val res = LpacJni.es10cEnableProfile(contextHandle, iccid) == 0
|
||||||
if (reconnectTimeout > 0) {
|
if (reconnectTimeout > 0) {
|
||||||
try {
|
tryReconnect(reconnectTimeout)
|
||||||
tryReconnect(reconnectTimeout)
|
|
||||||
} catch (e: Exception) {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
|
@ -102,11 +98,7 @@ class LocalProfileAssistantImpl(
|
||||||
override fun disableProfile(iccid: String, reconnectTimeout: Long): Boolean {
|
override fun disableProfile(iccid: String, reconnectTimeout: Long): Boolean {
|
||||||
val res = LpacJni.es10cDisableProfile(contextHandle, iccid) == 0
|
val res = LpacJni.es10cDisableProfile(contextHandle, iccid) == 0
|
||||||
if (reconnectTimeout > 0) {
|
if (reconnectTimeout > 0) {
|
||||||
try {
|
tryReconnect(reconnectTimeout)
|
||||||
tryReconnect(reconnectTimeout)
|
|
||||||
} catch (e: Exception) {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue