1#!/system/bin/sh
2# First: join all arguments with '+' as delimiter
3#
4# For example: if this was run as `media_provider method arg1 arg2`, the `cmd` variable below
5# would be `method+arg1+arg2`
6
7old_ifs=$IFS
8IFS='+'
9cmd=$(echo "$*")
10IFS=$old_ifs
11
12# Second: do `content read`.
13#
14# It may look like `content call` could be a better fit, but it's actually not the case:
15# `content call` does not allow us to redirect the output of the command to the out FS (even
16# though android.os.Bundle can hold (Parcelable) FDs com.android.commands.content.Content can't
17# handle it).
18# See: http://cs/android-internal/frameworks/base/cmds/content/src/com/android/commands/content/Content.java;l=303;rcl=b3370acc279c39e98823a2dbb9835fe0db615579
19#
20# `content read`, on the other hand, nicely copies content of the FD receives from the
21# ContentProvider to the System.out.
22# See: http://cs/android-internal/frameworks/base/cmds/content/src/com/android/commands/content/Content.java;l=630;rcl=b3370acc279c39e98823a2dbb9835fe0db615579
23
24content read --uri content://media/cli?cmd="$cmd"
25