summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteve Kondik <shade@chemlab.org>2012-09-23 05:18:41 -0700
committerSteve Kondik <shade@chemlab.org>2012-12-27 00:06:40 -0800
commit14aadb0c181f8a4264c7736d0da2f88dfb453030 (patch)
tree4c5e121e5b0c58b78d206bd86e9d5fa66927903e
parenta17c796cad4ba27682dcda377c2d775471ee4627 (diff)
downloadframeworks_base-14aadb0c181f8a4264c7736d0da2f88dfb453030.zip
frameworks_base-14aadb0c181f8a4264c7736d0da2f88dfb453030.tar.gz
frameworks_base-14aadb0c181f8a4264c7736d0da2f88dfb453030.tar.bz2
power: Add CPU boosting interface
* Boosts CPU using Power HAL for the given duration. * Duration is given in microseconds. * Power HAL must implement POWER_HINT_CPU_BOOST. Change-Id: Ic79baf7e3d0f75483c2fe8a242b4c3d93368b68b
-rw-r--r--core/java/android/os/IPowerManager.aidl2
-rw-r--r--core/java/android/os/PowerManager.java18
-rw-r--r--services/java/com/android/server/power/PowerManagerService.java18
-rw-r--r--services/jni/com_android_server_power_PowerManagerService.cpp8
-rw-r--r--tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgePowerManager.java5
5 files changed, 51 insertions, 0 deletions
diff --git a/core/java/android/os/IPowerManager.aidl b/core/java/android/os/IPowerManager.aidl
index 6d6d147..8dabfb3 100644
--- a/core/java/android/os/IPowerManager.aidl
+++ b/core/java/android/os/IPowerManager.aidl
@@ -51,4 +51,6 @@ interface IPowerManager
// sets the attention light (used by phone app only)
void setAttentionLight(boolean on, int color);
+
+ void cpuBoost(int duration);
}
diff --git a/core/java/android/os/PowerManager.java b/core/java/android/os/PowerManager.java
index 4a01113..7a54102 100644
--- a/core/java/android/os/PowerManager.java
+++ b/core/java/android/os/PowerManager.java
@@ -604,6 +604,24 @@ public final class PowerManager {
}
/**
+ * Boost the CPU. Boosts the cpu for the given duration in microseconds.
+ * Requires the {@link android.Manifest.permission#CPU_BOOST} permission.
+ *
+ * @param duration in microseconds to boost the CPU
+ *
+ * @hide
+ */
+ public void cpuBoost(int duration)
+ {
+ try {
+ if (mService != null) {
+ mService.cpuBoost(duration);
+ }
+ } catch (RemoteException e) {
+ }
+ }
+
+ /**
* A wake lock is a mechanism to indicate that your application needs
* to have the device stay on.
* <p>
diff --git a/services/java/com/android/server/power/PowerManagerService.java b/services/java/com/android/server/power/PowerManagerService.java
index 05e5aed..ac7293d 100644
--- a/services/java/com/android/server/power/PowerManagerService.java
+++ b/services/java/com/android/server/power/PowerManagerService.java
@@ -170,6 +170,9 @@ public final class PowerManagerService extends IPowerManager.Stub
// effectively and terminate the dream.
private static final int DREAM_BATTERY_LEVEL_DRAIN_CUTOFF = 5;
+ // Max time (microseconds) to allow a CPU boost for
+ private static final int MAX_CPU_BOOST_TIME = 5000000;
+
private Context mContext;
private LightsService mLightsService;
private BatteryService mBatteryService;
@@ -367,6 +370,7 @@ public final class PowerManagerService extends IPowerManager.Stub
private static native void nativeReleaseSuspendBlocker(String name);
private static native void nativeSetInteractive(boolean enable);
private static native void nativeSetAutoSuspend(boolean enable);
+ private static native void nativeCpuBoost(int duration);
public PowerManagerService() {
synchronized (mLock) {
@@ -1823,6 +1827,20 @@ public final class PowerManagerService extends IPowerManager.Stub
}
}
+ /**
+ * Boost the CPU
+ * @param duration Duration to boost the CPU for, in milliseconds.
+ * @hide
+ */
+ @Override // Binder call
+ public void cpuBoost(int duration) {
+ if (duration > 0 && duration <= MAX_CPU_BOOST_TIME) {
+ nativeCpuBoost(duration);
+ } else {
+ Log.e(TAG, "Invalid boost duration: " + duration);
+ }
+ }
+
private void shutdownOrRebootInternal(final boolean shutdown, final boolean confirm,
final String reason, boolean wait) {
if (mHandler == null || !mSystemReady) {
diff --git a/services/jni/com_android_server_power_PowerManagerService.cpp b/services/jni/com_android_server_power_PowerManagerService.cpp
index 23c33af..58af5f1 100644
--- a/services/jni/com_android_server_power_PowerManagerService.cpp
+++ b/services/jni/com_android_server_power_PowerManagerService.cpp
@@ -204,6 +204,12 @@ static void nativeReboot(JNIEnv *env, jclass clazz, jstring reason) {
jniThrowIOException(env, errno);
}
+static void nativeCpuBoost(JNIEnv *env, jobject clazz, jint duration) {
+ // Tell the Power HAL to boost the CPU
+ if (gPowerModule && gPowerModule->powerHint) {
+ gPowerModule->powerHint(gPowerModule, POWER_HINT_CPU_BOOST, (void *) duration);
+ }
+}
// ----------------------------------------------------------------------------
@@ -225,6 +231,8 @@ static JNINativeMethod gPowerManagerServiceMethods[] = {
(void*) nativeShutdown },
{ "nativeReboot", "(Ljava/lang/String;)V",
(void*) nativeReboot },
+ { "nativeCpuBoost", "(I)V",
+ (void*) nativeCpuBoost },
};
#define FIND_CLASS(var, className) \
diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgePowerManager.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgePowerManager.java
index 1ccbc40..c0151cf 100644
--- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgePowerManager.java
+++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgePowerManager.java
@@ -119,4 +119,9 @@ public class BridgePowerManager implements IPowerManager {
public void wakeUp(long time) throws RemoteException {
// pass for now.
}
+
+ @Override
+ public void cpuBoost(int duration) throws RemoteException {
+ // pass for now
+ }
}