From c34dfa4af43da547ecee2fe6f8145fe25fad39ac Mon Sep 17 00:00:00 2001 From: Jens Date: Mon, 18 Dec 2023 22:55:18 +0100 Subject: [PATCH] Bugfix for Android 14 for auto dialing mmi codes --- app/src/main/java/com/jens/automation2/Actions.java | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/com/jens/automation2/Actions.java b/app/src/main/java/com/jens/automation2/Actions.java index 3021ce0..52fcd6b 100644 --- a/app/src/main/java/com/jens/automation2/Actions.java +++ b/app/src/main/java/com/jens/automation2/Actions.java @@ -2287,7 +2287,18 @@ public class Actions public static void startPhoneCall(Context context, String phoneNumber) { - Intent intent = new Intent(Intent.ACTION_CALL, Uri.parse("tel:" + Uri.encode(phoneNumber))); + Intent intent; + + /* + Bug in Android 14 makes it necessary to add double quotes around MMI code. + More precisely it's required for codes containing the # character. + */ + + if(Build.VERSION.SDK_INT >= 34) + intent = new Intent(Intent.ACTION_CALL, Uri.parse("tel:" + Uri.encode("\"" + phoneNumber + "\""))); + else + intent = new Intent(Intent.ACTION_CALL, Uri.parse("tel:" + Uri.encode(phoneNumber))); + // intent.setClassName("com.android.phone","com.android.phone.OutgoingCallBroadcaster"); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.addFlags(Intent.FLAG_FROM_BACKGROUND);