summaryrefslogtreecommitdiffstats
path: root/cmds/settings
diff options
context:
space:
mode:
authorDianne Hackborn <hackbod@google.com>2014-06-10 23:13:02 -0700
committerDianne Hackborn <hackbod@google.com>2014-06-11 10:34:26 -0700
commit14272302a8b635bd8e9267c1411d0a7ef11bff45 (patch)
tree7d77f5ef5ca90889f4afed32bdf27e668b1afac6 /cmds/settings
parent95981dc8ad08002bab932cefcb6b07c6944491f5 (diff)
downloadframeworks_base-14272302a8b635bd8e9267c1411d0a7ef11bff45.zip
frameworks_base-14272302a8b635bd8e9267c1411d0a7ef11bff45.tar.gz
frameworks_base-14272302a8b635bd8e9267c1411d0a7ef11bff45.tar.bz2
Implement control of auto power save mode.
Follow the setting for auto power save mode in both battery service and battery UI. Default level is 15 when setting is not set; otherwise it is whatever the setting gives, with 0 meaning auto battery save is off. Change how we define the "turn off warn" level to be an adjustment from the warn level, so we can have a good value for whatever auto setting is set. Fix power manager to never go in to power save mode when plugged in, even if the user has manually turned it on. Add new delete option to settings command, because I needed it for testing. Change-Id: I512b691df84399d50b8e751fd50732c6093ebe85
Diffstat (limited to 'cmds/settings')
-rw-r--r--cmds/settings/src/com/android/commands/settings/SettingsCmd.java34
1 files changed, 32 insertions, 2 deletions
diff --git a/cmds/settings/src/com/android/commands/settings/SettingsCmd.java b/cmds/settings/src/com/android/commands/settings/SettingsCmd.java
index dce0a75..e6847a9 100644
--- a/cmds/settings/src/com/android/commands/settings/SettingsCmd.java
+++ b/cmds/settings/src/com/android/commands/settings/SettingsCmd.java
@@ -20,6 +20,7 @@ import android.app.ActivityManagerNative;
import android.app.IActivityManager;
import android.app.IActivityManager.ContentProviderHolder;
import android.content.IContentProvider;
+import android.net.Uri;
import android.os.Binder;
import android.os.Bundle;
import android.os.IBinder;
@@ -33,7 +34,8 @@ public final class SettingsCmd {
enum CommandVerb {
UNSPECIFIED,
GET,
- PUT
+ PUT,
+ DELETE
}
static String[] mArgs;
@@ -74,6 +76,8 @@ public final class SettingsCmd {
mVerb = CommandVerb.GET;
} else if ("put".equalsIgnoreCase(arg)) {
mVerb = CommandVerb.PUT;
+ } else if ("delete".equalsIgnoreCase(arg)) {
+ mVerb = CommandVerb.DELETE;
} else {
// invalid
System.err.println("Invalid command: " + arg);
@@ -87,7 +91,7 @@ public final class SettingsCmd {
break; // invalid
}
mTable = arg.toLowerCase();
- } else if (mVerb == CommandVerb.GET) {
+ } else if (mVerb == CommandVerb.GET || mVerb == CommandVerb.DELETE) {
mKey = arg;
if (mNextArg >= mArgs.length) {
valid = true;
@@ -136,6 +140,10 @@ public final class SettingsCmd {
case PUT:
putForUser(provider, mUser, mTable, mKey, mValue);
break;
+ case DELETE:
+ System.out.println("Deleted "
+ + deleteForUser(provider, mUser, mTable, mKey) + " rows");
+ break;
default:
System.err.println("Unspecified command");
break;
@@ -211,9 +219,31 @@ public final class SettingsCmd {
}
}
+ int deleteForUser(IContentProvider provider, int userHandle,
+ final String table, final String 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);
+ else {
+ System.err.println("Invalid table; no delete performed");
+ throw new IllegalArgumentException("Invalid table " + table);
+ }
+
+ int num = 0;
+ try {
+ num = provider.delete(null, targetUri, null, null);
+ } catch (RemoteException e) {
+ System.err.println("Can't clear key " + key + " in " + table + " for user "
+ + userHandle);
+ }
+ return num;
+ }
+
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("\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.");
}