Improved USSD and MMI code handling
This commit is contained in:
@@ -1697,9 +1697,24 @@ class BaresipService: Service() {
|
||||
fun runCall(uap: Long, uri: String, conferenceCall: Boolean, onHoldCallp: Long) {
|
||||
|
||||
val ua = UserAgent.ofUap(uap)
|
||||
if (ua != null && ua.account.isMobile && Utils.isUssd(uri)) {
|
||||
sendUssd(Utils.uriUserPart(uri))
|
||||
return
|
||||
if (ua != null && ua.account.isMobile) {
|
||||
val user = Utils.uriUserPart(uri)
|
||||
if (user.startsWith("*#*#") && user.endsWith("#*#*")) {
|
||||
val code = user.substring(4, user.length - 4)
|
||||
val intent = Intent("android.provider.Telephony.SECRET_CODE", "android_secret_code://$code".toUri())
|
||||
sendBroadcast(intent)
|
||||
postServiceEvent(ServiceEvent("ussd response", arrayListOf(uap, user, ""), System.nanoTime()))
|
||||
return
|
||||
}
|
||||
if (user == "*#06#") {
|
||||
val imei = getDeviceId(this)
|
||||
postServiceEvent(ServiceEvent("imei", arrayListOf(uap, user, imei), System.nanoTime()))
|
||||
return
|
||||
}
|
||||
if (Utils.isUssd(uri)) {
|
||||
sendUssd(user)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
val executeCall = {
|
||||
@@ -2338,6 +2353,16 @@ class BaresipService: Service() {
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressLint("HardwareIds", "MissingPermission")
|
||||
private fun getDeviceId(context: Context): String {
|
||||
val tm = context.getSystemService(TELEPHONY_SERVICE) as TelephonyManager
|
||||
return try {
|
||||
tm.imei ?: tm.meid ?: "N/A"
|
||||
} catch (_: SecurityException) {
|
||||
"N/A"
|
||||
}
|
||||
}
|
||||
|
||||
private fun toast(message: String, length: Int = Toast.LENGTH_SHORT) {
|
||||
Handler(Looper.getMainLooper()).post {
|
||||
Toast.makeText(this, message, length).show()
|
||||
|
||||
Reference in New Issue
Block a user