We have some old code that worked for a long time:
public static Intent getIntent(PendingIntent pendingIntent) {
Intent intent = null;
try {
Method getIntent = PendingIntent.class.getDeclaredMethod("getIntent");
intent = (Intent) getIntent.invoke(pendingIntent);
} catch (Exception e) {
// Log line
}
return intent;
}
We are now getting a security exception:
java.lang.reflect.InvocationTargetException
at java.lang.reflect.Method.invoke(Native Method)
at com.company.util.IntentUtils.getIntent(IntentUtils.java:160)
Caused by: java.lang.SecurityException: Permission Denial: getIntentForIntentSender() from pid=28128, uid=10127 requires android.permission.GET_INTENT_SENDER_INTENT
at android.os.Parcel.readException(Parcel.java:1683)
at android.os.Parcel.readException(Parcel.java:1636)
at android.app.ActivityManagerProxy.getIntentForIntentSender(ActivityManagerNative.java:5924)
at android.app.PendingIntent.getIntent(PendingIntent.java:987)
... 17 more
Looks like it might be related to AOSP change: https://android.googlesource.com/platform/frameworks/base/+/e5ad41b%5E!/
Any help getting the intend would be appreciated.
A PendingIntent itself is simply a reference to a token maintained by the system describing the original data used to retrieve it. This means that, even if its owning application's process is killed, the PendingIntent itself will remain usable from other processes that have been given it.
Android PendingIntent In other words, PendingIntent lets us pass a future Intent to another application and allow that application to execute that Intent as if it had the same permissions as our application, whether or not our application is still around when the Intent is eventually invoked.
1- requestCode is used to get the same pending intent later on (for cancelling etc) 2- Yes, they will get override as long as your specify the same Receiver to your Intent that you specify on your PendingIntent.
There's no workaround: as per the error message and commit, that hidden method that was never part of the public API now requires a signature
permission that only apps that are signed with the system signature can hold.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With