here's a strange exception: ContentProviderHelper.checkAssociationAndPermissionLocked
the method referred to is easily found in com.android.server.am.ContentProviderHelper. instances of the exception are not so easy to find.
below please find the exception that was logged by my app, as well as 3 other examples found on the internet. finding those 3 took some time.
my log:
ALL EXTRAS: Bundle[{job=receiving, android.intent.extra.STREAM=Supplier{VAL_PARCELABLE@104+180}}]
error: android.os.RemoteException: Remote stack trace:
at com.android.server.am.ContentProviderHelper.checkAssociationAndPermissionLocked(ContentProviderHelper.java:651)
at com.android.server.am.ContentProviderHelper.getContentProviderImpl(ContentProviderHelper.java:264)
at com.android.server.am.ContentProviderHelper.getContentProvider(ContentProviderHelper.java:140)
at com.android.server.am.ActivityManagerService.getContentProvider(ActivityManagerService.java:6474)
at android.app.IActivityManager$Stub.onTransact(IActivityManager.java:2395)
similar. some as late as aug, 2022
found here: https://github.com/GrapheneOS/os-issue-tracker/issues/1179
05-08 03:20:39.160 22814 22814 E AndroidRuntime: Caused by: android.os.RemoteException: Remote stack trace:
05-08 03:20:39.160 22814 22814 E AndroidRuntime: at com.android.server.am.ContentProviderHelper.checkAssociationAndPermissionLocked(ContentProviderHelper.java:611)
05-08 03:20:39.160 22814 22814 E AndroidRuntime: at com.android.server.am.ContentProviderHelper.getContentProviderImpl(ContentProviderHelper.java:235)
05-08 03:20:39.160 22814 22814 E AndroidRuntime: at com.android.server.am.ContentProviderHelper.getContentProvider(ContentProviderHelper.java:125)
05-08 03:20:39.160 22814 22814 E AndroidRuntime: at com.android.server.am.ActivityManagerService.getContentProvider(ActivityManagerService.java:6047)
05-08 03:20:39.160 22814 22814 E AndroidRuntime: at android.app.IActivityManager$Stub.onTransact(IActivityManager.java:2463)
and here: https://github.com/ankidroid/Anki-Android/issues/12675
Caused by: android.os.RemoteException: Remote stack trace:
at com.android.server.am.ContentProviderHelper.checkAssociationAndPermissionLocked(ContentProviderHelper.java:744)
at com.android.server.am.ContentProviderHelper.getContentProviderImpl(ContentProviderHelper.java:307)
at com.android.server.am.ContentProviderHelper.getContentProviderImpl(ContentProviderHelper.java:168)
at com.android.server.am.ContentProviderHelper.getContentProvider(ContentProviderHelper.java:142)
at com.android.server.am.ActivityManagerService.getContentProvider(ActivityManagerService.java:7630)
and here: https://codeberg.org/Freeyourgadget/Gadgetbridge/pulls/2577
Caused by: android.os.RemoteException: Remote stack trace:
at com.android.server.am.ContentProviderHelper.checkAssociationAndPermissionLocked(ContentProviderHelper.java:796)
at com.android.server.am.ContentProviderHelper.getContentProviderImpl(ContentProviderHelper.java:329)
at com.android.server.am.ContentProviderHelper.getContentProviderImpl(ContentProviderHelper.java:168)
at com.android.server.am.ContentProviderHelper.getContentProvider(ContentProviderHelper.java:142)
at com.android.server.am.ActivityManagerService.getContentProvider(ActivityManagerService.java:7550)
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
here's the story:
app 1 ("sender") sends a bitmap to app 2 ("receiver") using startactivityforresult and the fileprovider. app 2 ("receiver") receives the bitmap,
manipulates it and sends the manipulated bitmap back to app 1 ("sender") using setresult and an intent with the bitmap's uri as determined by fileprovider.
in reality, both apps are very large, so, for simplicity's sake, i built 2 simple apps to handle sending, receiving and returning the bitmap. "sender" sends the
bitmap, "receiver" receives it, saves it, loads it back in and returns it to "sender". both apps are found attached below. the exception occurs in both the
full versions and the simplified versions. not surprising, presumably, since the code was copied from the full versions.
"sender" has no problem sending the bitmap to "receiver", and "receiver" has no problem receiving it. "receiver" has no (evident) problem returning
the bitmap using fileprovider. "sender" has no problem receiving the intent as returned by "receiver". it can read the intent's extras. what it cannot do
is obtain the bitmap at the uri specified in the intent. it throws the exception above.
i've tried in using b4a 12.2, java 11 and 2 devices running android 12 and 13, respectively.
in addition to the attached examples, i also attach the full log showing program flow between the 2 apps.
after failing with fileprovider, i also tried converting the bitmap to bytes and returning it that way, but there is a limit to what you can stuff in the transaction
buffer, and the bitmaps i use are generally at or over the limit (fyi: android.os.TransactionTooLargeException is the exception thrown when overflowing the buffer.)
there are potentially a couple workarounds, but they ruin the flow, and, in any case, fileprovider is supposed to work, no?
since the test bitmap is on the small side, i've set up the examples so that they can handle a bitmap or a byte array. in "receiver" there is a a flag to set/unset to toggle
which version to use. "sender" can accept either. since the bitmap is small, there shouldn't be any problem transferring a byte array. you'll see the length of the byte
array returned in the log. but when you try to return a bitmap, you should get the exception. so even returning a small bitmap will trigger the exception.
is anyone familiar with this exception?
the method referred to is easily found in com.android.server.am.ContentProviderHelper. instances of the exception are not so easy to find.
below please find the exception that was logged by my app, as well as 3 other examples found on the internet. finding those 3 took some time.
my log:
ALL EXTRAS: Bundle[{job=receiving, android.intent.extra.STREAM=Supplier{VAL_PARCELABLE@104+180}}]
error: android.os.RemoteException: Remote stack trace:
at com.android.server.am.ContentProviderHelper.checkAssociationAndPermissionLocked(ContentProviderHelper.java:651)
at com.android.server.am.ContentProviderHelper.getContentProviderImpl(ContentProviderHelper.java:264)
at com.android.server.am.ContentProviderHelper.getContentProvider(ContentProviderHelper.java:140)
at com.android.server.am.ActivityManagerService.getContentProvider(ActivityManagerService.java:6474)
at android.app.IActivityManager$Stub.onTransact(IActivityManager.java:2395)
similar. some as late as aug, 2022
found here: https://github.com/GrapheneOS/os-issue-tracker/issues/1179
05-08 03:20:39.160 22814 22814 E AndroidRuntime: Caused by: android.os.RemoteException: Remote stack trace:
05-08 03:20:39.160 22814 22814 E AndroidRuntime: at com.android.server.am.ContentProviderHelper.checkAssociationAndPermissionLocked(ContentProviderHelper.java:611)
05-08 03:20:39.160 22814 22814 E AndroidRuntime: at com.android.server.am.ContentProviderHelper.getContentProviderImpl(ContentProviderHelper.java:235)
05-08 03:20:39.160 22814 22814 E AndroidRuntime: at com.android.server.am.ContentProviderHelper.getContentProvider(ContentProviderHelper.java:125)
05-08 03:20:39.160 22814 22814 E AndroidRuntime: at com.android.server.am.ActivityManagerService.getContentProvider(ActivityManagerService.java:6047)
05-08 03:20:39.160 22814 22814 E AndroidRuntime: at android.app.IActivityManager$Stub.onTransact(IActivityManager.java:2463)
and here: https://github.com/ankidroid/Anki-Android/issues/12675
Caused by: android.os.RemoteException: Remote stack trace:
at com.android.server.am.ContentProviderHelper.checkAssociationAndPermissionLocked(ContentProviderHelper.java:744)
at com.android.server.am.ContentProviderHelper.getContentProviderImpl(ContentProviderHelper.java:307)
at com.android.server.am.ContentProviderHelper.getContentProviderImpl(ContentProviderHelper.java:168)
at com.android.server.am.ContentProviderHelper.getContentProvider(ContentProviderHelper.java:142)
at com.android.server.am.ActivityManagerService.getContentProvider(ActivityManagerService.java:7630)
and here: https://codeberg.org/Freeyourgadget/Gadgetbridge/pulls/2577
Caused by: android.os.RemoteException: Remote stack trace:
at com.android.server.am.ContentProviderHelper.checkAssociationAndPermissionLocked(ContentProviderHelper.java:796)
at com.android.server.am.ContentProviderHelper.getContentProviderImpl(ContentProviderHelper.java:329)
at com.android.server.am.ContentProviderHelper.getContentProviderImpl(ContentProviderHelper.java:168)
at com.android.server.am.ContentProviderHelper.getContentProvider(ContentProviderHelper.java:142)
at com.android.server.am.ActivityManagerService.getContentProvider(ActivityManagerService.java:7550)
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
here's the story:
app 1 ("sender") sends a bitmap to app 2 ("receiver") using startactivityforresult and the fileprovider. app 2 ("receiver") receives the bitmap,
manipulates it and sends the manipulated bitmap back to app 1 ("sender") using setresult and an intent with the bitmap's uri as determined by fileprovider.
in reality, both apps are very large, so, for simplicity's sake, i built 2 simple apps to handle sending, receiving and returning the bitmap. "sender" sends the
bitmap, "receiver" receives it, saves it, loads it back in and returns it to "sender". both apps are found attached below. the exception occurs in both the
full versions and the simplified versions. not surprising, presumably, since the code was copied from the full versions.
"sender" has no problem sending the bitmap to "receiver", and "receiver" has no problem receiving it. "receiver" has no (evident) problem returning
the bitmap using fileprovider. "sender" has no problem receiving the intent as returned by "receiver". it can read the intent's extras. what it cannot do
is obtain the bitmap at the uri specified in the intent. it throws the exception above.
i've tried in using b4a 12.2, java 11 and 2 devices running android 12 and 13, respectively.
in addition to the attached examples, i also attach the full log showing program flow between the 2 apps.
after failing with fileprovider, i also tried converting the bitmap to bytes and returning it that way, but there is a limit to what you can stuff in the transaction
buffer, and the bitmaps i use are generally at or over the limit (fyi: android.os.TransactionTooLargeException is the exception thrown when overflowing the buffer.)
there are potentially a couple workarounds, but they ruin the flow, and, in any case, fileprovider is supposed to work, no?
since the test bitmap is on the small side, i've set up the examples so that they can handle a bitmap or a byte array. in "receiver" there is a a flag to set/unset to toggle
which version to use. "sender" can accept either. since the bitmap is small, there shouldn't be any problem transferring a byte array. you'll see the length of the byte
array returned in the log. but when you try to return a bitmap, you should get the exception. so even returning a small bitmap will trigger the exception.
is anyone familiar with this exception?