summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrian Muramatsu <btmura@google.com>2012-08-20 16:57:13 -0700
committerAndroid (Google) Code Review <android-gerrit@google.com>2012-08-20 16:57:14 -0700
commita5d5d608ccd885d8328879dde782a8cc93b7cf4f (patch)
treefa07d3db774f101e8f55210c47bf7d1b8232e63b
parent33da458dd832996d8b0ae945d6ab2896faff4afa (diff)
parent37a37f445cbcd64376af153dd79ea2a123d9405d (diff)
downloadframeworks_base-a5d5d608ccd885d8328879dde782a8cc93b7cf4f.zip
frameworks_base-a5d5d608ccd885d8328879dde782a8cc93b7cf4f.tar.gz
frameworks_base-a5d5d608ccd885d8328879dde782a8cc93b7cf4f.tar.bz2
Merge "add wireless charger support" into jb-mr1-dev
-rw-r--r--api/current.txt1
-rw-r--r--cmds/svc/src/com/android/commands/svc/PowerCommand.java10
-rw-r--r--core/java/android/os/BatteryManager.java2
-rw-r--r--core/java/android/os/BatteryStats.java3
-rw-r--r--core/java/android/provider/Settings.java1
-rw-r--r--policy/src/com/android/internal/policy/impl/KeyguardUpdateMonitor.java3
-rw-r--r--services/java/com/android/server/BatteryService.java14
-rw-r--r--services/jni/com_android_server_BatteryService.cpp12
8 files changed, 39 insertions, 7 deletions
diff --git a/api/current.txt b/api/current.txt
index 0eceb7f..e1d07e2 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -15525,6 +15525,7 @@ package android.os {
field public static final int BATTERY_HEALTH_UNSPECIFIED_FAILURE = 6; // 0x6
field public static final int BATTERY_PLUGGED_AC = 1; // 0x1
field public static final int BATTERY_PLUGGED_USB = 2; // 0x2
+ field public static final int BATTERY_PLUGGED_WIRELESS = 4; // 0x4
field public static final int BATTERY_STATUS_CHARGING = 2; // 0x2
field public static final int BATTERY_STATUS_DISCHARGING = 3; // 0x3
field public static final int BATTERY_STATUS_FULL = 5; // 0x5
diff --git a/cmds/svc/src/com/android/commands/svc/PowerCommand.java b/cmds/svc/src/com/android/commands/svc/PowerCommand.java
index deef2a3..ec3ec3e 100644
--- a/cmds/svc/src/com/android/commands/svc/PowerCommand.java
+++ b/cmds/svc/src/com/android/commands/svc/PowerCommand.java
@@ -37,7 +37,7 @@ public class PowerCommand extends Svc.Command {
public String longHelp() {
return shortHelp() + "\n"
+ "\n"
- + "usage: svc power stayon [true|false|usb|ac]\n"
+ + "usage: svc power stayon [true|false|usb|ac|wireless]\n"
+ " Set the 'keep awake while plugged in' setting.\n";
}
@@ -48,7 +48,8 @@ public class PowerCommand extends Svc.Command {
int val;
if ("true".equals(args[2])) {
val = BatteryManager.BATTERY_PLUGGED_AC |
- BatteryManager.BATTERY_PLUGGED_USB;
+ BatteryManager.BATTERY_PLUGGED_USB |
+ BatteryManager.BATTERY_PLUGGED_WIRELESS;
}
else if ("false".equals(args[2])) {
val = 0;
@@ -56,8 +57,9 @@ public class PowerCommand extends Svc.Command {
val = BatteryManager.BATTERY_PLUGGED_USB;
} else if ("ac".equals(args[2])) {
val = BatteryManager.BATTERY_PLUGGED_AC;
- }
- else {
+ } else if ("wireless".equals(args[2])) {
+ val = BatteryManager.BATTERY_PLUGGED_WIRELESS;
+ } else {
break fail;
}
IPowerManager pm
diff --git a/core/java/android/os/BatteryManager.java b/core/java/android/os/BatteryManager.java
index c62715b..7b16f4d 100644
--- a/core/java/android/os/BatteryManager.java
+++ b/core/java/android/os/BatteryManager.java
@@ -115,4 +115,6 @@ public class BatteryManager {
public static final int BATTERY_PLUGGED_AC = 1;
/** Power source is a USB port. */
public static final int BATTERY_PLUGGED_USB = 2;
+ /** Power source is wireless. */
+ public static final int BATTERY_PLUGGED_WIRELESS = 4;
}
diff --git a/core/java/android/os/BatteryStats.java b/core/java/android/os/BatteryStats.java
index fcc0ae4..54f2fe3 100644
--- a/core/java/android/os/BatteryStats.java
+++ b/core/java/android/os/BatteryStats.java
@@ -2071,6 +2071,9 @@ public abstract class BatteryStats implements Parcelable {
case BatteryManager.BATTERY_PLUGGED_USB:
pw.print("usb");
break;
+ case BatteryManager.BATTERY_PLUGGED_WIRELESS:
+ pw.print("wireless");
+ break;
default:
pw.print(oldPlug);
break;
diff --git a/core/java/android/provider/Settings.java b/core/java/android/provider/Settings.java
index 6dbba46..28273f0 100644
--- a/core/java/android/provider/Settings.java
+++ b/core/java/android/provider/Settings.java
@@ -1147,6 +1147,7 @@ public final class Settings {
* <li>{@code 0} to never stay on while plugged in</li>
* <li>{@link BatteryManager#BATTERY_PLUGGED_AC} to stay on for AC charger</li>
* <li>{@link BatteryManager#BATTERY_PLUGGED_USB} to stay on for USB charger</li>
+ * <li>{@link BatteryManager#BATTERY_PLUGGED_WIRELESS} to stay on for wireless charger</li>
* </ul>
* These values can be OR-ed together.
*/
diff --git a/policy/src/com/android/internal/policy/impl/KeyguardUpdateMonitor.java b/policy/src/com/android/internal/policy/impl/KeyguardUpdateMonitor.java
index 279314d..5c0cd4f 100644
--- a/policy/src/com/android/internal/policy/impl/KeyguardUpdateMonitor.java
+++ b/policy/src/com/android/internal/policy/impl/KeyguardUpdateMonitor.java
@@ -259,7 +259,8 @@ public class KeyguardUpdateMonitor {
*/
boolean isPluggedIn() {
return plugged == BatteryManager.BATTERY_PLUGGED_AC
- || plugged == BatteryManager.BATTERY_PLUGGED_USB;
+ || plugged == BatteryManager.BATTERY_PLUGGED_USB
+ || plugged == BatteryManager.BATTERY_PLUGGED_WIRELESS;
}
/**
diff --git a/services/java/com/android/server/BatteryService.java b/services/java/com/android/server/BatteryService.java
index 0a6f23c..6ae16a4 100644
--- a/services/java/com/android/server/BatteryService.java
+++ b/services/java/com/android/server/BatteryService.java
@@ -93,6 +93,7 @@ public class BatteryService extends Binder {
private boolean mAcOnline;
private boolean mUsbOnline;
+ private boolean mWirelessOnline;
private int mBatteryStatus;
private int mBatteryHealth;
private boolean mBatteryPresent;
@@ -150,7 +151,8 @@ public class BatteryService extends Binder {
public final boolean isPowered() {
// assume we are powered if battery state is unknown so the "stay on while plugged in" option will work.
- return (mAcOnline || mUsbOnline || mBatteryStatus == BatteryManager.BATTERY_STATUS_UNKNOWN);
+ return (mAcOnline || mUsbOnline || mWirelessOnline
+ || mBatteryStatus == BatteryManager.BATTERY_STATUS_UNKNOWN);
}
public final boolean isPowered(int plugTypeSet) {
@@ -169,6 +171,9 @@ public class BatteryService extends Binder {
if (mUsbOnline) {
plugTypeBit |= BatteryManager.BATTERY_PLUGGED_USB;
}
+ if (mWirelessOnline) {
+ plugTypeBit |= BatteryManager.BATTERY_PLUGGED_WIRELESS;
+ }
return (plugTypeSet & plugTypeBit) != 0;
}
@@ -243,6 +248,8 @@ public class BatteryService extends Binder {
mPlugType = BatteryManager.BATTERY_PLUGGED_AC;
} else if (mUsbOnline) {
mPlugType = BatteryManager.BATTERY_PLUGGED_USB;
+ } else if (mWirelessOnline) {
+ mPlugType = BatteryManager.BATTERY_PLUGGED_WIRELESS;
} else {
mPlugType = BATTERY_PLUGGED_NONE;
}
@@ -398,6 +405,7 @@ public class BatteryService extends Binder {
" temperature: " + mBatteryTemperature +
" technology: " + mBatteryTechnology +
" AC powered:" + mAcOnline + " USB powered:" + mUsbOnline +
+ " Wireless powered:" + mWirelessOnline +
" icon:" + icon + " invalid charger:" + mInvalidCharger);
}
@@ -503,6 +511,7 @@ public class BatteryService extends Binder {
pw.println("Current Battery Service state:");
pw.println(" AC powered: " + mAcOnline);
pw.println(" USB powered: " + mUsbOnline);
+ pw.println(" Wireless powered: " + mWirelessOnline);
pw.println(" status: " + mBatteryStatus);
pw.println(" health: " + mBatteryHealth);
pw.println(" present: " + mBatteryPresent);
@@ -523,6 +532,8 @@ public class BatteryService extends Binder {
mAcOnline = Integer.parseInt(value) != 0;
} else if ("usb".equals(key)) {
mUsbOnline = Integer.parseInt(value) != 0;
+ } else if ("wireless".equals(key)) {
+ mWirelessOnline = Integer.parseInt(value) != 0;
} else if ("status".equals(key)) {
mBatteryStatus = Integer.parseInt(value);
} else if ("level".equals(key)) {
@@ -603,4 +614,3 @@ public class BatteryService extends Binder {
}
}
}
-
diff --git a/services/jni/com_android_server_BatteryService.cpp b/services/jni/com_android_server_BatteryService.cpp
index ca6f206..8ebc6ea 100644
--- a/services/jni/com_android_server_BatteryService.cpp
+++ b/services/jni/com_android_server_BatteryService.cpp
@@ -42,6 +42,7 @@ struct FieldIds {
// members
jfieldID mAcOnline;
jfieldID mUsbOnline;
+ jfieldID mWirelessOnline;
jfieldID mBatteryStatus;
jfieldID mBatteryHealth;
jfieldID mBatteryPresent;
@@ -71,6 +72,7 @@ static BatteryManagerConstants gConstants;
struct PowerSupplyPaths {
char* acOnlinePath;
char* usbOnlinePath;
+ char* wirelessOnlinePath;
char* batteryStatusPath;
char* batteryHealthPath;
char* batteryPresentPath;
@@ -198,6 +200,7 @@ static void android_server_BatteryService_update(JNIEnv* env, jobject obj)
{
setBooleanField(env, obj, gPaths.acOnlinePath, gFieldIds.mAcOnline);
setBooleanField(env, obj, gPaths.usbOnlinePath, gFieldIds.mUsbOnline);
+ setBooleanField(env, obj, gPaths.wirelessOnlinePath, gFieldIds.mWirelessOnline);
setBooleanField(env, obj, gPaths.batteryPresentPath, gFieldIds.mBatteryPresent);
setIntField(env, obj, gPaths.batteryCapacityPath, gFieldIds.mBatteryLevel);
@@ -260,6 +263,11 @@ int register_android_server_BatteryService(JNIEnv* env)
if (access(path, R_OK) == 0)
gPaths.usbOnlinePath = strdup(path);
}
+ else if (strcmp(buf, "Wireless") == 0) {
+ snprintf(path, sizeof(path), "%s/%s/online", POWER_SUPPLY_PATH, name);
+ if (access(path, R_OK) == 0)
+ gPaths.wirelessOnlinePath = strdup(path);
+ }
else if (strcmp(buf, "Battery") == 0) {
snprintf(path, sizeof(path), "%s/%s/status", POWER_SUPPLY_PATH, name);
if (access(path, R_OK) == 0)
@@ -307,6 +315,8 @@ int register_android_server_BatteryService(JNIEnv* env)
ALOGE("acOnlinePath not found");
if (!gPaths.usbOnlinePath)
ALOGE("usbOnlinePath not found");
+ if (!gPaths.wirelessOnlinePath)
+ ALOGE("wirelessOnlinePath not found");
if (!gPaths.batteryStatusPath)
ALOGE("batteryStatusPath not found");
if (!gPaths.batteryHealthPath)
@@ -331,6 +341,7 @@ int register_android_server_BatteryService(JNIEnv* env)
gFieldIds.mAcOnline = env->GetFieldID(clazz, "mAcOnline", "Z");
gFieldIds.mUsbOnline = env->GetFieldID(clazz, "mUsbOnline", "Z");
+ gFieldIds.mWirelessOnline = env->GetFieldID(clazz, "mWirelessOnline", "Z");
gFieldIds.mBatteryStatus = env->GetFieldID(clazz, "mBatteryStatus", "I");
gFieldIds.mBatteryHealth = env->GetFieldID(clazz, "mBatteryHealth", "I");
gFieldIds.mBatteryPresent = env->GetFieldID(clazz, "mBatteryPresent", "Z");
@@ -341,6 +352,7 @@ int register_android_server_BatteryService(JNIEnv* env)
LOG_FATAL_IF(gFieldIds.mAcOnline == NULL, "Unable to find BatteryService.AC_ONLINE_PATH");
LOG_FATAL_IF(gFieldIds.mUsbOnline == NULL, "Unable to find BatteryService.USB_ONLINE_PATH");
+ LOG_FATAL_IF(gFieldIds.mWirelessOnline == NULL, "Unable to find BatteryService.WIRELESS_ONLINE_PATH");
LOG_FATAL_IF(gFieldIds.mBatteryStatus == NULL, "Unable to find BatteryService.BATTERY_STATUS_PATH");
LOG_FATAL_IF(gFieldIds.mBatteryHealth == NULL, "Unable to find BatteryService.BATTERY_HEALTH_PATH");
LOG_FATAL_IF(gFieldIds.mBatteryPresent == NULL, "Unable to find BatteryService.BATTERY_PRESENT_PATH");