From 3ffad04adda722fc7784e689f4b0e961fb4b85a3 Mon Sep 17 00:00:00 2001 From: Steven Moreland Date: Tue, 27 Aug 2019 17:58:17 -0700 Subject: [PATCH 1/2] ServiceManagerProxy: add APIs. This class is hanging around for UnsupportedApiUsage. Adding additional APIs here which do nothing in order to satisfy the inherited interface. Bug: 136027762 Test: compile :) Change-Id: I47b57c6876afd77b47083bf905ade9951ff0b42d --- core/java/android/os/ServiceManagerNative.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/core/java/android/os/ServiceManagerNative.java b/core/java/android/os/ServiceManagerNative.java index 7991cd46b65cf..f641731fa08fe 100644 --- a/core/java/android/os/ServiceManagerNative.java +++ b/core/java/android/os/ServiceManagerNative.java @@ -76,6 +76,16 @@ class ServiceManagerProxy implements IServiceManager { return mServiceManager.listServices(dumpPriority); } + public void registerForNotifications(String name, IServiceCallback cb) + throws RemoteException { + throw new RemoteException(); + } + + public void unregisterForNotifications(String name, IServiceCallback cb) + throws RemoteException { + throw new RemoteException(); + } + /** * Same as mServiceManager but used by apps. * From d9b00ae794271c8d4b36b51ebbdec798887a2fbd Mon Sep 17 00:00:00 2001 From: Steven Moreland Date: Tue, 27 Aug 2019 18:20:05 -0700 Subject: [PATCH 2/2] PowerManagerService: use waitForService. Instead of while(true) sleep1 Bug: N/A Test: boot Change-Id: I6f316fd1f9634b827f003998995e6358dde15a83 --- .../jni/com_android_server_power_PowerManagerService.cpp | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/services/core/jni/com_android_server_power_PowerManagerService.cpp b/services/core/jni/com_android_server_power_PowerManagerService.cpp index 73bb579bd2740..4e0434873944b 100644 --- a/services/core/jni/com_android_server_power_PowerManagerService.cpp +++ b/services/core/jni/com_android_server_power_PowerManagerService.cpp @@ -201,13 +201,8 @@ sp getSuspendHal() { sp getSuspendControl() { static std::once_flag suspendControlFlag; std::call_once(suspendControlFlag, [](){ - while(gSuspendControl == nullptr) { - sp control = - defaultServiceManager()->getService(String16("suspend_control")); - if (control != nullptr) { - gSuspendControl = interface_cast(control); - } - } + gSuspendControl = waitForService(String16("suspend_control")); + LOG_ALWAYS_FATAL_IF(gSuspendControl == nullptr); }); return gSuspendControl; }