summaryrefslogtreecommitdiffstats
path: root/core/java/android/os
diff options
context:
space:
mode:
Diffstat (limited to 'core/java/android/os')
-rw-r--r--core/java/android/os/BatteryManager.java160
-rw-r--r--core/java/android/os/BatteryManagerInternal.java21
-rw-r--r--core/java/android/os/BatteryProperties.java54
-rw-r--r--core/java/android/os/Environment.java2
-rw-r--r--core/java/android/os/IBatteryPropertiesRegistrar.aidl2
-rw-r--r--core/java/android/os/PowerManagerInternal.java6
6 files changed, 240 insertions, 5 deletions
diff --git a/core/java/android/os/BatteryManager.java b/core/java/android/os/BatteryManager.java
index 1f3e9a7..050820c 100644
--- a/core/java/android/os/BatteryManager.java
+++ b/core/java/android/os/BatteryManager.java
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2008 The Android Open Source Project
+ * Copyright (C) 2016 The CyanogenMod Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,6 +17,7 @@
package android.os;
+import android.app.IBatteryService;
import android.content.Context;
import android.os.BatteryProperty;
import android.os.IBatteryPropertiesRegistrar;
@@ -95,6 +97,79 @@ public class BatteryManager {
/**
* Extra for {@link android.content.Intent#ACTION_BATTERY_CHANGED}:
+ * integer containing the current dock status constant.
+ * @hide
+ */
+ public static final String EXTRA_DOCK_STATUS = "dock_status";
+
+ /**
+ * Extra for {@link android.content.Intent#ACTION_BATTERY_CHANGED}:
+ * integer containing the current dock health constant.
+ * @hide
+ */
+ public static final String EXTRA_DOCK_HEALTH = "dock_health";
+
+ /**
+ * Extra for {@link android.content.Intent#ACTION_BATTERY_CHANGED}:
+ * boolean indicating whether a dock battery is present.
+ * @hide
+ */
+ public static final String EXTRA_DOCK_PRESENT = "dock_present";
+
+ /**
+ * Extra for {@link android.content.Intent#ACTION_BATTERY_CHANGED}:
+ * integer field containing the current dock battery level, from 0 to
+ * {@link #EXTRA_SCALE}.
+ * @hide
+ */
+ public static final String EXTRA_DOCK_LEVEL = "dock_level";
+
+ /**
+ * Extra for {@link android.content.Intent#ACTION_BATTERY_CHANGED}:
+ * integer containing the maximum dock battery level.
+ * @hide
+ */
+ public static final String EXTRA_DOCK_SCALE = "dock_scale";
+
+ /**
+ * Extra for {@link android.content.Intent#ACTION_BATTERY_CHANGED}:
+ * integer containing the resource ID of a small status bar icon
+ * indicating the current dock battery state.
+ * @hide
+ */
+ public static final String EXTRA_DOCK_ICON_SMALL = "dock_icon-small";
+
+ /**
+ * Extra for {@link android.content.Intent#ACTION_BATTERY_CHANGED}:
+ * integer indicating whether the device is plugged in to a dock power
+ * source.
+ * @hide
+ */
+ public static final String EXTRA_DOCK_PLUGGED = "dock_plugged";
+
+ /**
+ * Extra for {@link android.content.Intent#ACTION_BATTERY_CHANGED}:
+ * integer containing the current dock battery voltage level.
+ * @hide
+ */
+ public static final String EXTRA_DOCK_VOLTAGE = "dock_voltage";
+
+ /**
+ * Extra for {@link android.content.Intent#ACTION_BATTERY_CHANGED}:
+ * integer containing the current dock battery temperature.
+ * @hide
+ */
+ public static final String EXTRA_DOCK_TEMPERATURE = "dock_temperature";
+
+ /**
+ * Extra for {@link android.content.Intent#ACTION_BATTERY_CHANGED}:
+ * String describing the technology of the current dock battery.
+ * @hide
+ */
+ public static final String EXTRA_DOCK_TECHNOLOGY = "dock_technology";
+
+ /**
+ * Extra for {@link android.content.Intent#ACTION_BATTERY_CHANGED}:
* Int value set to nonzero if an unsupported charger is attached
* to the device.
* {@hide}
@@ -133,10 +208,23 @@ public class BatteryManager {
/** Power source is wireless. */
public static final int BATTERY_PLUGGED_WIRELESS = 4;
+ // values of the "dock_plugged" field in the ACTION_BATTERY_CHANGED intent.
+ // These must be powers of 2.
+ /** Power source is an DockAC charger.
+ * @hide*/
+ public static final int BATTERY_DOCK_PLUGGED_AC = 1;
+ /** Power source is an DockUSB charger.
+ * @hide*/
+ public static final int BATTERY_DOCK_PLUGGED_USB = 2;
+
/** @hide */
public static final int BATTERY_PLUGGED_ANY =
BATTERY_PLUGGED_AC | BATTERY_PLUGGED_USB | BATTERY_PLUGGED_WIRELESS;
+ /** @hide */
+ public static final int BATTERY_DOCK_PLUGGED_ANY =
+ BATTERY_DOCK_PLUGGED_AC | BATTERY_DOCK_PLUGGED_USB;
+
/**
* Sent when the device's battery has started charging (or has reached full charge
* and the device is on power). This is a good time to do work that you would like to
@@ -191,6 +279,7 @@ public class BatteryManager {
*/
public static final int BATTERY_PROPERTY_ENERGY_COUNTER = 5;
+ private final IBatteryService mBatteryService;
private final IBatteryStats mBatteryStats;
private final IBatteryPropertiesRegistrar mBatteryPropertiesRegistrar;
@@ -202,6 +291,27 @@ public class BatteryManager {
ServiceManager.getService(BatteryStats.SERVICE_NAME));
mBatteryPropertiesRegistrar = IBatteryPropertiesRegistrar.Stub.asInterface(
ServiceManager.getService("batteryproperties"));
+ mBatteryService = null;
+ }
+
+ /** @hide */
+ public BatteryManager(IBatteryService service) {
+ super();
+ mBatteryStats = IBatteryStats.Stub.asInterface(
+ ServiceManager.getService(BatteryStats.SERVICE_NAME));
+ mBatteryPropertiesRegistrar = IBatteryPropertiesRegistrar.Stub.asInterface(
+ ServiceManager.getService("batteryproperties"));
+ mBatteryService = service;
+ }
+
+ /** @hide */
+ public boolean isDockBatterySupported() {
+ try {
+ return mBatteryService != null && mBatteryService.isDockBatterySupported();
+ } catch (RemoteException ex) {
+ // Ignore
+ }
+ return false;
}
/**
@@ -223,8 +333,10 @@ public class BatteryManager {
*
* Returns the requested value, or Long.MIN_VALUE if property not
* supported on this system or on other error.
+ * fromDock determines if the property is query from the normal battery
+ * or the dock battery.
*/
- private long queryProperty(int id) {
+ private long queryProperty(int id, boolean fromDock) {
long ret;
if (mBatteryPropertiesRegistrar == null) {
@@ -234,7 +346,13 @@ public class BatteryManager {
try {
BatteryProperty prop = new BatteryProperty();
- if (mBatteryPropertiesRegistrar.getProperty(id, prop) == 0)
+ final int callResult;
+ if (!fromDock) {
+ callResult = mBatteryPropertiesRegistrar.getProperty(id, prop);
+ } else {
+ callResult = mBatteryPropertiesRegistrar.getDockProperty(id, prop);
+ }
+ if (callResult == 0)
ret = prop.getLong();
else
ret = Long.MIN_VALUE;
@@ -255,7 +373,7 @@ public class BatteryManager {
* @return the property value, or Integer.MIN_VALUE if not supported.
*/
public int getIntProperty(int id) {
- return (int)queryProperty(id);
+ return (int)queryProperty(id, false);
}
/**
@@ -268,6 +386,40 @@ public class BatteryManager {
* @return the property value, or Long.MIN_VALUE if not supported.
*/
public long getLongProperty(int id) {
- return queryProperty(id);
+ return queryProperty(id, false);
+ }
+
+ /**
+ * Return the value of a dock battery property of integer type. If the
+ * platform does not provide the property queried, this value will
+ * be Integer.MIN_VALUE.
+ *
+ * @param id identifier of the requested property
+ *
+ * @return the property value, or Integer.MIN_VALUE if not supported.
+ * @hide
+ */
+ public int getIntDockProperty(int id) {
+ if (!isDockBatterySupported()) {
+ return Integer.MIN_VALUE;
+ }
+ return (int)queryProperty(id, true);
+ }
+
+ /**
+ * Return the value of a dock battery property of long type If the
+ * platform does not provide the property queried, this value will
+ * be Long.MIN_VALUE.
+ *
+ * @param id identifier of the requested property
+ *
+ * @return the property value, or Long.MIN_VALUE if not supported.
+ * @hide
+ */
+ public long getLongDockProperty(int id) {
+ if (!isDockBatterySupported()) {
+ return Long.MIN_VALUE;
+ }
+ return queryProperty(id, true);
}
}
diff --git a/core/java/android/os/BatteryManagerInternal.java b/core/java/android/os/BatteryManagerInternal.java
index f3a95b9..1abb3d5 100644
--- a/core/java/android/os/BatteryManagerInternal.java
+++ b/core/java/android/os/BatteryManagerInternal.java
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2014 The Android Open Source Project
+ * Copyright (C) 2016 The CyanogenMod Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -43,6 +44,26 @@ public abstract class BatteryManagerInternal {
public abstract boolean getBatteryLevelLow();
/**
+ * Returns whether dock batteries is supported
+ */
+ public abstract boolean isDockBatterySupported();
+
+ /**
+ * Returns the current dock plug type.
+ */
+ public abstract int getDockPlugType();
+
+ /**
+ * Returns dock battery level as a percentage.
+ */
+ public abstract int getDockBatteryLevel();
+
+ /**
+ * Returns whether we currently consider the dock battery level to be low.
+ */
+ public abstract boolean getDockBatteryLevelLow();
+
+ /**
* Returns a non-zero value if an unsupported charger is attached.
*/
public abstract int getInvalidCharger();
diff --git a/core/java/android/os/BatteryProperties.java b/core/java/android/os/BatteryProperties.java
index 29e868c..cad741a 100644
--- a/core/java/android/os/BatteryProperties.java
+++ b/core/java/android/os/BatteryProperties.java
@@ -1,4 +1,5 @@
/* Copyright 2013, The Android Open Source Project
+ * Copyright 2016, The CyanogenMod Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -31,6 +32,16 @@ public class BatteryProperties implements Parcelable {
public int batteryTemperature;
public String batteryTechnology;
+ public boolean dockBatterySupported;
+ public boolean chargerDockAcOnline;
+ public int dockBatteryStatus;
+ public int dockBatteryHealth;
+ public boolean dockBatteryPresent;
+ public int dockBatteryLevel;
+ public int dockBatteryVoltage;
+ public int dockBatteryTemperature;
+ public String dockBatteryTechnology;
+
public BatteryProperties() {
}
@@ -46,6 +57,16 @@ public class BatteryProperties implements Parcelable {
batteryVoltage = other.batteryVoltage;
batteryTemperature = other.batteryTemperature;
batteryTechnology = other.batteryTechnology;
+
+ dockBatterySupported = other.dockBatterySupported;
+ chargerDockAcOnline = other.chargerDockAcOnline;
+ dockBatteryStatus = other.dockBatteryStatus;
+ dockBatteryHealth = other.dockBatteryHealth;
+ dockBatteryPresent = other.dockBatteryPresent;
+ dockBatteryLevel = other.dockBatteryLevel;
+ dockBatteryVoltage = other.dockBatteryVoltage;
+ dockBatteryTemperature = other.dockBatteryTemperature;
+ dockBatteryTechnology = other.dockBatteryTechnology;
}
/*
@@ -65,6 +86,27 @@ public class BatteryProperties implements Parcelable {
batteryVoltage = p.readInt();
batteryTemperature = p.readInt();
batteryTechnology = p.readString();
+
+ dockBatterySupported = p.readInt() == 1 ? true : false;
+ if (dockBatterySupported) {
+ chargerDockAcOnline = p.readInt() == 1 ? true : false;
+ dockBatteryStatus = p.readInt();
+ dockBatteryHealth = p.readInt();
+ dockBatteryPresent = p.readInt() == 1 ? true : false;
+ dockBatteryLevel = p.readInt();
+ dockBatteryVoltage = p.readInt();
+ dockBatteryTemperature = p.readInt();
+ dockBatteryTechnology = p.readString();
+ } else {
+ chargerDockAcOnline = false;
+ dockBatteryStatus = BatteryManager.BATTERY_STATUS_UNKNOWN;
+ dockBatteryHealth = BatteryManager.BATTERY_HEALTH_UNKNOWN;
+ dockBatteryPresent = false;
+ dockBatteryLevel = 0;
+ dockBatteryVoltage = 0;
+ dockBatteryTemperature = 0;
+ dockBatteryTechnology = "";
+ }
}
public void writeToParcel(Parcel p, int flags) {
@@ -79,6 +121,18 @@ public class BatteryProperties implements Parcelable {
p.writeInt(batteryVoltage);
p.writeInt(batteryTemperature);
p.writeString(batteryTechnology);
+
+ p.writeInt(dockBatterySupported ? 1 : 0);
+ if (dockBatterySupported) {
+ p.writeInt(chargerDockAcOnline ? 1 : 0);
+ p.writeInt(dockBatteryStatus);
+ p.writeInt(dockBatteryHealth);
+ p.writeInt(dockBatteryPresent ? 1 : 0);
+ p.writeInt(dockBatteryLevel);
+ p.writeInt(dockBatteryVoltage);
+ p.writeInt(dockBatteryTemperature);
+ p.writeString(dockBatteryTechnology);
+ }
}
public static final Parcelable.Creator<BatteryProperties> CREATOR
diff --git a/core/java/android/os/Environment.java b/core/java/android/os/Environment.java
index 2567a41..a800ed6 100644
--- a/core/java/android/os/Environment.java
+++ b/core/java/android/os/Environment.java
@@ -56,7 +56,7 @@ public class Environment {
private static final File DIR_ANDROID_STORAGE = getDirectory(ENV_ANDROID_STORAGE, "/storage");
private static final File DIR_OEM_ROOT = getDirectory(ENV_OEM_ROOT, "/oem");
private static final File DIR_VENDOR_ROOT = getDirectory(ENV_VENDOR_ROOT, "/vendor");
- private static final File DIR_PREBUNDLED_ROOT = getDirectory(ENV_PREBUNDLED_ROOT, "/vendor/bundled-app");
+ private static final File DIR_PREBUNDLED_ROOT = getDirectory(ENV_PREBUNDLED_ROOT, "/bundled-app");
private static final String SYSTEM_PROPERTY_EFS_ENABLED = "persist.security.efs.enabled";
diff --git a/core/java/android/os/IBatteryPropertiesRegistrar.aidl b/core/java/android/os/IBatteryPropertiesRegistrar.aidl
index fd01802..43b9650 100644
--- a/core/java/android/os/IBatteryPropertiesRegistrar.aidl
+++ b/core/java/android/os/IBatteryPropertiesRegistrar.aidl
@@ -1,5 +1,6 @@
/*
** Copyright 2013, The Android Open Source Project
+** Copyright 2016, The CyanogenMod Project
**
** Licensed under the Apache License, Version 2.0 (the "License");
** you may not use this file except in compliance with the License.
@@ -27,4 +28,5 @@ interface IBatteryPropertiesRegistrar {
void registerListener(IBatteryPropertiesListener listener);
void unregisterListener(IBatteryPropertiesListener listener);
int getProperty(in int id, out BatteryProperty prop);
+ int getDockProperty(in int id, out BatteryProperty prop);
}
diff --git a/core/java/android/os/PowerManagerInternal.java b/core/java/android/os/PowerManagerInternal.java
index 38037a6..39c12f0 100644
--- a/core/java/android/os/PowerManagerInternal.java
+++ b/core/java/android/os/PowerManagerInternal.java
@@ -117,6 +117,12 @@ public abstract class PowerManagerInternal {
public abstract void setUserActivityTimeoutOverrideFromWindowManager(long timeoutMillis);
/**
+ * Used by the window manager to tell the power manager that the user is no longer actively
+ * using the device.
+ */
+ public abstract void setUserInactiveOverrideFromWindowManager();
+
+ /**
* Used by device administration to set the maximum screen off timeout.
*
* This method must only be called by the device administration policy manager.