#165 viewer: fixed edit intent flags for some environments
This commit is contained in:
parent
ab62d3ea28
commit
a3bed14ee1
1 changed files with 11 additions and 1 deletions
|
@ -143,6 +143,7 @@ class AppAdapterHandler(private val context: Context) : MethodCallHandler {
|
||||||
.submit(size, size)
|
.submit(size, size)
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@Suppress("BlockingMethodInNonBlockingContext")
|
||||||
data = target.get()?.getBytes(canHaveAlpha = true, recycle = false)
|
data = target.get()?.getBytes(canHaveAlpha = true, recycle = false)
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
Log.w(LOG_TAG, "failed to decode app icon for packageName=$packageName", e)
|
Log.w(LOG_TAG, "failed to decode app icon for packageName=$packageName", e)
|
||||||
|
@ -312,7 +313,16 @@ class AppAdapterHandler(private val context: Context) : MethodCallHandler {
|
||||||
context.startActivity(Intent.createChooser(intent, title))
|
context.startActivity(Intent.createChooser(intent, title))
|
||||||
return true
|
return true
|
||||||
} catch (e: SecurityException) {
|
} catch (e: SecurityException) {
|
||||||
Log.w(LOG_TAG, "failed to start activity chooser for intent=$intent", e)
|
if (intent.flags and Intent.FLAG_GRANT_WRITE_URI_PERMISSION != 0) {
|
||||||
|
// in some environments, providing the write flag yields a `SecurityException`:
|
||||||
|
// "UID XXXX does not have permission to content://XXXX"
|
||||||
|
// so we retry without it
|
||||||
|
Log.i(LOG_TAG, "retry intent=$intent without FLAG_GRANT_WRITE_URI_PERMISSION")
|
||||||
|
intent.flags = intent.flags and Intent.FLAG_GRANT_WRITE_URI_PERMISSION.inv()
|
||||||
|
return safeStartActivityChooser(title, intent)
|
||||||
|
} else {
|
||||||
|
Log.w(LOG_TAG, "failed to start activity chooser for intent=$intent", e)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue