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

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

Change-Id: I7ffd281376232b4ca71699dbc3f0f0d9c8367599
This commit is contained in:
Kalesh Singh
2020-07-13 18:38:18 +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 {