summaryrefslogtreecommitdiff
path: root/core/java
diff options
context:
space:
mode:
authorKalesh Singh <kaleshsingh@google.com>2019-07-30 12:15:24 -0700
committerandroid-build-merger <android-build-merger@google.com>2019-07-30 12:15:24 -0700
commit5f669a500918a04556d842d8d18025ac146aa8cd (patch)
treed05488fc13a224b34fc4d6c9728e5696555de3f4 /core/java
parentd0353c05da98411a7b7a0df4d5d3d8463cdd3c27 (diff)
parent9c1224cfa3cbf83465cdfc27226d070a1381d804 (diff)
Merge "Get native wakelock stats from SystemSuspend if /sys/class/wakeup not available." am: dec3796249 am: 8ad549cdf2
am: 9c1224cfa3 Change-Id: I31802f57dcf2e6fc4fd509ea95864259ab90565a
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 d53fadacb609..e09e0e609380 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.