Scenario: We are sending SMS to particular number if user grantees the SMS permission.
Devices: Only Samsung devices with Android 11.
Code:
SmsManager.getSmsManagerForSubscriptionId(subscriptionId)
.sendTextMessage(destinationAddress, null, getString(R.string.xyz)
.format(token), sendSMSPendingIntent, null)
Exception:
java.lang.SecurityException: Package com.android.phone (uid=1001) does not match provided uid 10246
android.os.Parcel.createExceptionOrNull Parcel.java:2385
android.os.Parcel.createException Parcel.java:2369
android.os.Parcel.readException Parcel.java:2352
android.os.Parcel.readException Parcel.java:2294
com.android.internal.telephony.ISms$Stub$Proxy.sendTextForSubscriber ISms.java:2102
android.telephony.SmsManager$1.onSuccess SmsManager.java:618
android.telephony.SmsManager.sendResolverResult SmsManager.java:1627
android.telephony.SmsManager.resolveSubscriptionForOperation SmsManager.java:1588
android.telephony.SmsManager.sendTextMessageInternal SmsManager.java:613
android.telephony.SmsManager.sendTextMessage SmsManager.java:451```