Merge "Don't cache suspend_control service" am: 1371e73894

Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1360077

Change-Id: I83bcaf82bd7a53f97112daf043c75601c99ffa34
This commit is contained in:
Kalesh Singh
2020-07-13 17:59:41 +00:00
committed by Automerger Merge Worker

View File

@@ -152,20 +152,33 @@ 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 {