summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--cmds/settings/Android.mk1
-rw-r--r--cmds/settings/src/com/android/commands/settings/SettingsCmd.java73
2 files changed, 55 insertions, 19 deletions
diff --git a/cmds/settings/Android.mk b/cmds/settings/Android.mk
index 05deb99..c397535 100644
--- a/cmds/settings/Android.mk
+++ b/cmds/settings/Android.mk
@@ -4,6 +4,7 @@ LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
LOCAL_SRC_FILES := $(call all-subdir-java-files)
+LOCAL_STATIC_JAVA_LIBRARIES := org.cyanogenmod.platform.internal
LOCAL_MODULE := settings
LOCAL_MODULE_TAGS := optional
include $(BUILD_JAVA_LIBRARY)
diff --git a/cmds/settings/src/com/android/commands/settings/SettingsCmd.java b/cmds/settings/src/com/android/commands/settings/SettingsCmd.java
index c27d0c0..b6cdbeb 100644
--- a/cmds/settings/src/com/android/commands/settings/SettingsCmd.java
+++ b/cmds/settings/src/com/android/commands/settings/SettingsCmd.java
@@ -29,6 +29,7 @@ import android.os.Process;
import android.os.RemoteException;
import android.os.UserHandle;
import android.provider.Settings;
+import cyanogenmod.providers.CMSettings;
import java.util.ArrayList;
import java.util.Collections;
@@ -36,6 +37,9 @@ import java.util.List;
public final class SettingsCmd {
+ private static final String SETTINGS_AUTHORITY = Settings.AUTHORITY;
+ private static final String CMSETTINGS_AUTHORITY = CMSettings.AUTHORITY;
+
enum CommandVerb {
UNSPECIFIED,
GET,
@@ -51,6 +55,7 @@ public final class SettingsCmd {
String mTable = null;
String mKey = null;
String mValue = null;
+ boolean mUseCMSettingsProvider = false;
public static void main(String[] args) {
if (args == null || args.length < 2) {
@@ -77,6 +82,8 @@ public final class SettingsCmd {
break;
}
mUser = Integer.parseInt(nextArg());
+ } else if ("--cm".equals(arg)) {
+ mUseCMSettingsProvider = true;
} else if (mVerb == CommandVerb.UNSPECIFIED) {
if ("get".equalsIgnoreCase(arg)) {
mVerb = CommandVerb.GET;
@@ -139,7 +146,8 @@ public final class SettingsCmd {
IBinder token = new Binder();
try {
ContentProviderHolder holder = activityManager.getContentProviderExternal(
- "settings", UserHandle.USER_OWNER, token);
+ mUseCMSettingsProvider ? CMSETTINGS_AUTHORITY : SETTINGS_AUTHORITY,
+ UserHandle.USER_OWNER, token);
if (holder == null) {
throw new IllegalStateException("Could not find settings provider");
}
@@ -182,9 +190,15 @@ public final class SettingsCmd {
}
private List<String> listForUser(IContentProvider provider, int userHandle, String table) {
- final Uri uri = "system".equals(table) ? Settings.System.CONTENT_URI
- : "secure".equals(table) ? Settings.Secure.CONTENT_URI
- : "global".equals(table) ? Settings.Global.CONTENT_URI
+ final Uri systemUri = mUseCMSettingsProvider ? CMSettings.System.CONTENT_URI
+ : Settings.System.CONTENT_URI;
+ final Uri secureUri = mUseCMSettingsProvider ? CMSettings.Secure.CONTENT_URI
+ : Settings.Secure.CONTENT_URI;
+ final Uri globalUri = mUseCMSettingsProvider ? CMSettings.Global.CONTENT_URI
+ : Settings.Global.CONTENT_URI;
+ final Uri uri = "system".equals(table) ? systemUri
+ : "secure".equals(table) ? secureUri
+ : "global".equals(table) ? globalUri
: null;
final ArrayList<String> lines = new ArrayList<String>();
if (uri == null) {
@@ -220,10 +234,16 @@ public final class SettingsCmd {
String getForUser(IContentProvider provider, int userHandle,
final String table, final String key) {
+ final String systemGetCommand = mUseCMSettingsProvider ? CMSettings.CALL_METHOD_GET_SYSTEM
+ : Settings.CALL_METHOD_GET_SYSTEM;
+ final String secureGetCommand = mUseCMSettingsProvider ? CMSettings.CALL_METHOD_GET_SECURE
+ : Settings.CALL_METHOD_GET_SECURE;
+ final String globalGetCommand = mUseCMSettingsProvider ? CMSettings.CALL_METHOD_GET_GLOBAL
+ : Settings.CALL_METHOD_GET_GLOBAL;
final String callGetCommand;
- if ("system".equals(table)) callGetCommand = Settings.CALL_METHOD_GET_SYSTEM;
- else if ("secure".equals(table)) callGetCommand = Settings.CALL_METHOD_GET_SECURE;
- else if ("global".equals(table)) callGetCommand = Settings.CALL_METHOD_GET_GLOBAL;
+ if ("system".equals(table)) callGetCommand = systemGetCommand;
+ else if ("secure".equals(table)) callGetCommand = secureGetCommand;
+ else if ("global".equals(table)) callGetCommand = globalGetCommand;
else {
System.err.println("Invalid table; no put performed");
throw new IllegalArgumentException("Invalid table " + table);
@@ -232,7 +252,8 @@ public final class SettingsCmd {
String result = null;
try {
Bundle arg = new Bundle();
- arg.putInt(Settings.CALL_METHOD_USER_KEY, userHandle);
+ arg.putInt(mUseCMSettingsProvider ? CMSettings.CALL_METHOD_USER_KEY
+ : Settings.CALL_METHOD_USER_KEY, userHandle);
Bundle b = provider.call(resolveCallingPackage(), callGetCommand, key, arg);
if (b != null) {
result = b.getPairValue();
@@ -245,10 +266,16 @@ public final class SettingsCmd {
void putForUser(IContentProvider provider, int userHandle,
final String table, final String key, final String value) {
+ final String systemPutCommand = mUseCMSettingsProvider ? CMSettings.CALL_METHOD_PUT_SYSTEM
+ : Settings.CALL_METHOD_PUT_SYSTEM;
+ final String securePutCommand = mUseCMSettingsProvider ? CMSettings.CALL_METHOD_PUT_SECURE
+ : Settings.CALL_METHOD_PUT_SECURE;
+ final String globalPutCommand = mUseCMSettingsProvider ? CMSettings.CALL_METHOD_PUT_GLOBAL
+ : Settings.CALL_METHOD_PUT_GLOBAL;
final String callPutCommand;
- if ("system".equals(table)) callPutCommand = Settings.CALL_METHOD_PUT_SYSTEM;
- else if ("secure".equals(table)) callPutCommand = Settings.CALL_METHOD_PUT_SECURE;
- else if ("global".equals(table)) callPutCommand = Settings.CALL_METHOD_PUT_GLOBAL;
+ if ("system".equals(table)) callPutCommand = systemPutCommand;
+ else if ("secure".equals(table)) callPutCommand = securePutCommand;
+ else if ("global".equals(table)) callPutCommand = globalPutCommand;
else {
System.err.println("Invalid table; no put performed");
return;
@@ -257,7 +284,8 @@ public final class SettingsCmd {
try {
Bundle arg = new Bundle();
arg.putString(Settings.NameValueTable.VALUE, value);
- arg.putInt(Settings.CALL_METHOD_USER_KEY, userHandle);
+ arg.putInt(mUseCMSettingsProvider ? CMSettings.CALL_METHOD_USER_KEY
+ : Settings.CALL_METHOD_USER_KEY, userHandle);
provider.call(resolveCallingPackage(), callPutCommand, key, arg);
} catch (RemoteException e) {
System.err.println("Can't set key " + key + " in " + table + " for user " + userHandle);
@@ -266,10 +294,16 @@ public final class SettingsCmd {
int deleteForUser(IContentProvider provider, int userHandle,
final String table, final String key) {
+ final Uri systemUri = mUseCMSettingsProvider ? CMSettings.System.getUriFor(key)
+ : Settings.System.getUriFor(key);
+ final Uri secureUri = mUseCMSettingsProvider ? CMSettings.Secure.getUriFor(key)
+ : Settings.Secure.getUriFor(key);
+ final Uri globalUri = mUseCMSettingsProvider ? CMSettings.Global.getUriFor(key)
+ : Settings.Global.getUriFor(key);
Uri targetUri;
- if ("system".equals(table)) targetUri = Settings.System.getUriFor(key);
- else if ("secure".equals(table)) targetUri = Settings.Secure.getUriFor(key);
- else if ("global".equals(table)) targetUri = Settings.Global.getUriFor(key);
+ if ("system".equals(table)) targetUri = systemUri;
+ else if ("secure".equals(table)) targetUri = secureUri;
+ else if ("global".equals(table)) targetUri = globalUri;
else {
System.err.println("Invalid table; no delete performed");
throw new IllegalArgumentException("Invalid table " + table);
@@ -286,12 +320,13 @@ public final class SettingsCmd {
}
private static void printUsage() {
- System.err.println("usage: settings [--user NUM] get namespace key");
- System.err.println(" settings [--user NUM] put namespace key value");
- System.err.println(" settings [--user NUM] delete namespace key");
- System.err.println(" settings [--user NUM] list namespace");
+ System.err.println("usage: settings [--user NUM] [--cm] get namespace key");
+ System.err.println(" settings [--user NUM] [--cm] put namespace key value");
+ System.err.println(" settings [--user NUM] [--cm] delete namespace key");
+ System.err.println(" settings [--user NUM] [--cm] list namespace");
System.err.println("\n'namespace' is one of {system, secure, global}, case-insensitive");
System.err.println("If '--user NUM' is not given, the operations are performed on the owner user.");
+ System.err.println("If '--cm' is given, the operations are performed on the CMSettings provider.");
}
public static String resolveCallingPackage() {