summaryrefslogtreecommitdiffstats
path: root/cmds
diff options
context:
space:
mode:
authorAdnan Begovic <adnan@cyngn.com>2015-11-13 15:01:58 -0800
committerAdnan Begovic <adnan@cyngn.com>2015-11-17 12:10:11 -0800
commit8d9ce61ae7c0e602d70e8d95422e173cf1a99d2b (patch)
tree6b80c455a16f4b6c117574e6850846ebc242db2c /cmds
parenta5a5a9839f4b0ca3024df309cf25a073550bc832 (diff)
downloadframeworks_base-8d9ce61ae7c0e602d70e8d95422e173cf1a99d2b.zip
frameworks_base-8d9ce61ae7c0e602d70e8d95422e173cf1a99d2b.tar.gz
frameworks_base-8d9ce61ae7c0e602d70e8d95422e173cf1a99d2b.tar.bz2
content: Add "--show-type" argument for content queries.
Allows you to append the argument "--show-type" to a query command which can detail each projection columns value type in the response. Change-Id: I10640b25203e2ff8202b93707dc85923ad9e990f
Diffstat (limited to 'cmds')
-rw-r--r--cmds/content/src/com/android/commands/content/Content.java24
1 files changed, 21 insertions, 3 deletions
diff --git a/cmds/content/src/com/android/commands/content/Content.java b/cmds/content/src/com/android/commands/content/Content.java
index c0ed893..1d8b8b1 100644
--- a/cmds/content/src/com/android/commands/content/Content.java
+++ b/cmds/content/src/com/android/commands/content/Content.java
@@ -103,10 +103,12 @@ public class Content {
+ "--where \"name=\'new_setting\'\"\n"
+ "\n"
+ "usage: adb shell content query --uri <URI> [--user <USER_ID>]"
- + " [--projection <PROJECTION>] [--where <WHERE>] [--sort <SORT_ORDER>]\n"
+ + " [--projection <PROJECTION>] [--where <WHERE>] [--sort <SORT_ORDER>] "
+ + " [--show-type <SHOW-TYPE>] \n"
+ " <PROJECTION> is a list of colon separated column names and is formatted:\n"
+ " <COLUMN_NAME>[:<COLUMN_NAME>...]\n"
+ " <SORT_ORDER> is the order in which rows in the result should be sorted.\n"
+ + " <SHOW-TYPE> if true shows the type of value of each projection column"
+ " Example:\n"
+ " # Select \"name\" and \"value\" columns from secure settings where \"name\" is "
+ "equal to \"new_setting\" and sort the result by name in ascending order.\n"
@@ -142,6 +144,7 @@ public class Content {
private static final String ARGUMENT_METHOD = "--method";
private static final String ARGUMENT_ARG = "--arg";
private static final String ARGUMENT_EXTRA = "--extra";
+ private static final String ARGUMENT_SHOW_TYPE = "--show-type";
private static final String TYPE_BOOLEAN = "b";
private static final String TYPE_STRING = "s";
private static final String TYPE_INTEGER = "i";
@@ -316,6 +319,7 @@ public class Content {
String[] projection = null;
String sort = null;
String where = null;
+ boolean showType = false;
for (String argument; (argument = mTokenizer.nextArg())!= null;) {
if (ARGUMENT_URI.equals(argument)) {
uri = Uri.parse(argumentValueRequired(argument));
@@ -327,6 +331,8 @@ public class Content {
sort = argumentValueRequired(argument);
} else if (ARGUMENT_PROJECTION.equals(argument)) {
projection = argumentValueRequired(argument).split("[\\s]*:[\\s]*");
+ } else if (ARGUMENT_SHOW_TYPE.equals(argument)) {
+ showType = argumentValueRequiredForBoolean(argument);
} else {
throw new IllegalArgumentException("Unsupported argument: " + argument);
}
@@ -335,7 +341,7 @@ public class Content {
throw new IllegalArgumentException("Content provider URI not specified."
+ " Did you specify --uri argument?");
}
- return new QueryCommand(uri, userId, projection, where, sort);
+ return new QueryCommand(uri, userId, projection, where, sort, showType);
}
private void parseBindValue(ContentValues values) {
@@ -367,6 +373,14 @@ public class Content {
}
}
+ private boolean argumentValueRequiredForBoolean(String argument) {
+ String value = mTokenizer.nextArg();
+ if (TextUtils.isEmpty(value) || value.startsWith(ARGUMENT_PREFIX)) {
+ throw new IllegalArgumentException("No value for argument: " + argument);
+ }
+ return value.equals("true");
+ }
+
private String argumentValueRequired(String argument) {
String value = mTokenizer.nextArg();
if (TextUtils.isEmpty(value) || value.startsWith(ARGUMENT_PREFIX)) {
@@ -539,12 +553,15 @@ public class Content {
private static class QueryCommand extends DeleteCommand {
final String[] mProjection;
final String mSortOrder;
+ final boolean mShowType;
public QueryCommand(
- Uri uri, int userId, String[] projection, String where, String sortOrder) {
+ Uri uri, int userId, String[] projection, String where, String sortOrder,
+ boolean showType) {
super(uri, userId, where);
mProjection = projection;
mSortOrder = sortOrder;
+ mShowType = showType;
}
@Override
@@ -590,6 +607,7 @@ public class Content {
break;
}
builder.append(columnName).append("=").append(columnValue);
+ if (mShowType) builder.append(", type=").append(type);
}
System.out.println(builder);
} while (cursor.moveToNext());