summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Kalesh Singh <kaleshsingh@google.com> 2020-07-13 17:59:41 +0000
committer Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> 2020-07-13 17:59:41 +0000
commitda3a84e731fb910008f58b00fbb1185dce66b13f (patch)
tree40cd2c09cc9a0b9b076e49857d09832947894505
parentf65666d055cab34d058899d9a318202f217edb9b (diff)
parent1371e73894c4bf878a79dc257c723322dc9bbed8 (diff)
Merge "Don't cache suspend_control service" am: 1371e73894
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1360077 Change-Id: I83bcaf82bd7a53f97112daf043c75601c99ffa34
-rw-r--r--core/java/com/android/internal/os/KernelWakelockReader.java29
1 files changed, 21 insertions, 8 deletions
diff --git a/core/java/com/android/internal/os/KernelWakelockReader.java b/core/java/com/android/internal/os/KernelWakelockReader.java
index cffb0ad9fdb9..3d35d2fbaa82 100644
--- a/core/java/com/android/internal/os/KernelWakelockReader.java
+++ b/core/java/com/android/internal/os/KernelWakelockReader.java
@@ -153,19 +153,32 @@ public class KernelWakelockReader {
}
/**
+ * Attempt to wait for suspend_control service if not immediately available.
+ */
+ private ISuspendControlService waitForSuspendControlService() throws ServiceNotFoundException {
+ final String name = "suspend_control";
+ final int numRetries = 5;
+ for (int i = 0; i < numRetries; i++) {
+ mSuspendControlService = ISuspendControlService.Stub.asInterface(
+ ServiceManager.getService(name));
+ if (mSuspendControlService != null) {
+ return mSuspendControlService;
+ }
+ }
+ throw new ServiceNotFoundException(name);
+ }
+
+ /**
* 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 {
+ mSuspendControlService = waitForSuspendControlService();
+ } catch (ServiceNotFoundException e) {
+ Slog.wtf(TAG, "Required service suspend_control not available", e);
+ return null;
}
try {