summaryrefslogtreecommitdiff
path: root/core/java
diff options
context:
space:
mode:
Diffstat (limited to 'core/java')
-rw-r--r--core/java/com/android/internal/os/KernelWakelockReader.java55
1 files changed, 36 insertions, 19 deletions
diff --git a/core/java/com/android/internal/os/KernelWakelockReader.java b/core/java/com/android/internal/os/KernelWakelockReader.java
index ee0903a30e6d..b3b0ba198651 100644
--- a/core/java/com/android/internal/os/KernelWakelockReader.java
+++ b/core/java/com/android/internal/os/KernelWakelockReader.java
@@ -76,28 +76,13 @@ public class KernelWakelockReader {
boolean useSystemSuspend = (new File(sSysClassWakeupDir)).exists();
if (useSystemSuspend) {
- WakeLockInfo[] wlStats = null;
- if (mSuspendControlService == null) {
- try {
- mSuspendControlService = ISuspendControlService.Stub.asInterface(
- ServiceManager.getServiceOrThrow("suspend_control"));
- } catch (ServiceNotFoundException e) {
- Slog.wtf(TAG, "Required service suspend_control not available", e);
- return null;
- }
- }
-
- try {
- wlStats = mSuspendControlService.getWakeLockStats();
- updateVersion(staleStats);
- updateWakelockStats(wlStats, staleStats);
- } catch (RemoteException e) {
- Slog.wtf(TAG, "Failed to obtain wakelock stats from ISuspendControlService", e);
+ // Get both kernel and native wakelock stats from SystemSuspend
+ updateVersion(staleStats);
+ if (getWakelockStatsFromSystemSuspend(staleStats) == null) {
+ Slog.w(TAG, "Failed to get wakelock stats from SystemSuspend");
return null;
}
-
return removeOldStats(staleStats);
-
} else {
byte[] buffer = new byte[32*1024];
int len = 0;
@@ -153,12 +138,44 @@ public class KernelWakelockReader {
}
updateVersion(staleStats);
+ // Get native wakelock stats from SystemSuspend
+ if (getWakelockStatsFromSystemSuspend(staleStats) == null) {
+ Slog.w(TAG, "Failed to get Native wakelock stats from SystemSuspend");
+ }
+ // Get kernel wakelock stats
parseProcWakelocks(buffer, len, wakeup_sources, staleStats);
return removeOldStats(staleStats);
}
}
/**
+ * On success, returns the updated stats from SystemSupend, else returns null.
+ */
+ private KernelWakelockStats getWakelockStatsFromSystemSuspend(
+ final KernelWakelockStats staleStats) {
+ WakeLockInfo[] wlStats = null;
+ if (mSuspendControlService == null) {
+ try {
+ mSuspendControlService = ISuspendControlService.Stub.asInterface(
+ ServiceManager.getServiceOrThrow("suspend_control"));
+ } catch (ServiceNotFoundException e) {
+ Slog.wtf(TAG, "Required service suspend_control not available", e);
+ return null;
+ }
+ }
+
+ try {
+ wlStats = mSuspendControlService.getWakeLockStats();
+ updateWakelockStats(wlStats, staleStats);
+ } catch (RemoteException e) {
+ Slog.wtf(TAG, "Failed to obtain wakelock stats from ISuspendControlService", e);
+ return null;
+ }
+
+ return staleStats;
+ }
+
+ /**
* Updates statleStats with stats from SystemSuspend.
* @param staleStats Existing object to update.
* @return the updated stats.