am a5d5d608: Merge "add wireless charger support" into jb-mr1-dev
* commit 'a5d5d608ccd885d8328879dde782a8cc93b7cf4f': add wireless charger support
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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.
|
||||
*/
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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 {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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");
|
||||
|
||||
Reference in New Issue
Block a user