James O'Claire
09/13/2023, 2:10 PMPermission Denial: opening provider com.thirdgate.stormtracker.ImageFileProvider from ProcessRecord{2899a4f 1117:com.google.android.apps.nexuslauncher/u0a151} (pid=1117, uid=10151) that is not exported from UID 10185
followed by a second warning:
Error inflating RemoteViews android.widget.RemoteViews$ActionException: java.lang.SecurityException: Permission Denial: opening provider com.thirdgate.stormtracker.ImageFileProvider from ProcessRecord{2899a4f 1117:com.google.android.apps.nexuslauncher/u0a151} (pid=1117, uid=10151) that is not exported from UID 10185
I think the issue it is highlighting is that the original permission was granted to the first . This is done with essentially the same code as the above example:
// Find the current launcher every time to ensure it has read permissions
val intent = Intent(Intent.ACTION_MAIN).apply { addCategory(Intent.CATEGORY_HOME) }
val resolveInfo = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
context.packageManager.resolveActivity(
intent,
PackageManager.ResolveInfoFlags.of(PackageManager.MATCH_DEFAULT_ONLY.toLong()),
)
} else {
@Suppress("DEPRECATION")
context.packageManager.resolveActivity(
intent,
PackageManager.MATCH_DEFAULT_ONLY,
)
}
val launcherName = resolveInfo?.activityInfo?.packageName
if (launcherName != null) {
context.grantUriPermission(
launcherName,
contentUri,
FLAG_GRANT_READ_URI_PERMISSION or FLAG_GRANT_PERSISTABLE_URI_PERMISSION,
)
}
How should I store the images so that the URI permissions persist across reinstalls or restarts? Is there any other way I can test this situation? As I mentioned, the whole widget appears to die, but no error logs are shown for my app in logcat.Summers Pittman
09/14/2023, 7:03 PMSummers Pittman
09/14/2023, 7:44 PMJames O'Claire
09/15/2023, 10:52 AMJames O'Claire
09/15/2023, 10:58 AM