File tree Expand file tree Collapse file tree
common/src/main/java/com/omarea/common/shell Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -66,17 +66,28 @@ class ShellTranslation(val context: Context) {
6666
6767 try {
6868 val intent = parseIntentArgs(subArgs)
69-
69+ // emulate am for SEND
70+ if ((intent.action == Intent .ACTION_SEND
71+ || intent.action == Intent .ACTION_SEND_MULTIPLE )
72+ && intent.data != null
73+ ) {
74+ intent.putExtra(Intent .EXTRA_STREAM , intent.data)
75+ intent.data = null
76+ intent.addFlags(Intent .FLAG_GRANT_READ_URI_PERMISSION )
77+ }
78+
7079 when (cmd) {
7180 " start" -> {
7281 intent.addFlags(Intent .FLAG_ACTIVITY_NEW_TASK )
73-
7482 if ((Intent .ACTION_SEND == intent.action
7583 || Intent .ACTION_SEND_MULTIPLE == intent.action)
7684 && intent.component == null
7785 ) {
7886 val chooser = Intent .createChooser(intent, null )
79- chooser.addFlags(Intent .FLAG_ACTIVITY_NEW_TASK )
87+ chooser.addFlags(
88+ Intent .FLAG_ACTIVITY_NEW_TASK or
89+ Intent .FLAG_GRANT_READ_URI_PERMISSION
90+ )
8091 ctx.startActivity(chooser)
8192 } else {
8293 ctx.startActivity(intent)
@@ -212,7 +223,16 @@ class ShellTranslation(val context: Context) {
212223 } catch (_: Exception ) {}
213224 }
214225 }
215-
226+
227+ // Uri extra
228+ " --eu" -> {
229+ if (i + 2 < tokens.size) {
230+ val key = tokens[++ i]
231+ val value = tokens[++ i]
232+ intent.putExtra(key, Uri .parse(value))
233+ }
234+ }
235+
216236 // double extra
217237 " --ed" -> {
218238 if (i + 2 < tokens.size) {
You can’t perform that action at this time.
0 commit comments