From a9703163c0edbd70d4acac6ea89d4bc15edbc946 Mon Sep 17 00:00:00 2001 From: Connor O'Brien Date: Mon, 8 May 2017 12:14:06 -0700 Subject: [PATCH] PowerManagerService: open power HAL less aggressively Once the power HAL has failed to open once, don't try to open it again on subsequent calls to the service. Test: remove power HAL on marlin & confirm log spam stops. Bug: 38028137 Change-Id: If7bc4f7080e8822b68da0d1bd81df8de1ce388aa Signed-off-by: Connor O'Brien --- .../core/jni/com_android_server_power_PowerManagerService.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/services/core/jni/com_android_server_power_PowerManagerService.cpp b/services/core/jni/com_android_server_power_PowerManagerService.cpp index 1bdcd7aa9bd6e..c722629a28f46 100644 --- a/services/core/jni/com_android_server_power_PowerManagerService.cpp +++ b/services/core/jni/com_android_server_power_PowerManagerService.cpp @@ -57,6 +57,7 @@ static struct { static jobject gPowerManagerServiceObj; sp gPowerHal = nullptr; +bool gPowerHalExists = true; std::mutex gPowerHalMutex; static nsecs_t gLastEventTime[USER_ACTIVITY_EVENT_LAST + 1]; @@ -78,12 +79,13 @@ static bool checkAndClearExceptionFromCallback(JNIEnv* env, const char* methodNa // Check validity of current handle to the power HAL service, and call getService() if necessary. // The caller must be holding gPowerHalMutex. bool getPowerHal() { - if (gPowerHal == nullptr) { + if (gPowerHalExists && gPowerHal == nullptr) { gPowerHal = IPower::getService(); if (gPowerHal != nullptr) { ALOGI("Loaded power HAL service"); } else { ALOGI("Couldn't load power HAL service"); + gPowerHalExists = false; } } return gPowerHal != nullptr;