Skip to content

Commit 7f1a1df

Browse files
committed
Upload file
1 parent c3cc748 commit 7f1a1df

1 file changed

Lines changed: 14 additions & 11 deletions

File tree

common/src/main/java/com/omarea/common/shell/ShellTranslation.kt

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -68,18 +68,21 @@ class ShellTranslation(val context: Context) {
6868
try {
6969
val intent = parseIntentArgs(subArgs)
7070

71-
// emulate am for SEND (AOSP-compatible)
72-
if ((intent.action == Intent.ACTION_SEND
73-
|| intent.action == Intent.ACTION_SEND_MULTIPLE)
74-
&& intent.data != null
71+
if (intent.action == Intent.ACTION_SEND
72+
|| intent.action == Intent.ACTION_SEND_MULTIPLE
7573
) {
76-
val uri = intent.data!!
77-
intent.putExtra(Intent.EXTRA_STREAM, uri)
78-
intent.setClipData(
79-
ClipData.newUri(ctx.contentResolver, null, uri)
80-
)
81-
intent.data = null
82-
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION)
74+
val uri =
75+
intent.getParcelableExtra<Uri>(Intent.EXTRA_STREAM)
76+
?: intent.data
77+
78+
if (uri != null) {
79+
intent.setClipData(
80+
ClipData.newRawUri(null, uri)
81+
)
82+
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION)
83+
intent.removeExtra(Intent.EXTRA_STREAM)
84+
intent.data = null
85+
}
8386
}
8487

8588
when (cmd) {

0 commit comments

Comments
 (0)