diff --git a/core/jni/android_view_SurfaceControl.cpp b/core/jni/android_view_SurfaceControl.cpp index 8b82314476430..c42ba710079a8 100644 --- a/core/jni/android_view_SurfaceControl.cpp +++ b/core/jni/android_view_SurfaceControl.cpp @@ -24,6 +24,7 @@ #include "android/graphics/Region.h" #include "core_jni_helpers.h" +#include #include #include #include @@ -552,8 +553,9 @@ static void nativeSetDisplayPowerMode(JNIEnv* env, jclass clazz, jobject tokenOb sp token(ibinderForJavaObject(env, tokenObj)); if (token == NULL) return; - ALOGD_IF_SLOW(100, "Excessive delay in setPowerMode()"); + android::base::Timer t; SurfaceComposerClient::setDisplayPowerMode(token, mode); + if (t.duration() > 100ms) ALOGD("Excessive delay in setPowerMode()"); } static jboolean nativeClearContentFrameStats(JNIEnv* env, jclass clazz, jlong nativeObject) { diff --git a/services/core/jni/com_android_server_lights_LightsService.cpp b/services/core/jni/com_android_server_lights_LightsService.cpp index 514e996fe5409..c873bdc1bd5ac 100644 --- a/services/core/jni/com_android_server_lights_LightsService.cpp +++ b/services/core/jni/com_android_server_lights_LightsService.cpp @@ -22,6 +22,7 @@ #include #include +#include #include #include #include @@ -178,9 +179,10 @@ static void setLight_native( colorARGB, flashMode, onMS, offMS, brightnessMode); { - ALOGD_IF_SLOW(50, "Excessive delay setting light"); + android::base::Timer t; Return ret = hal->setLight(type, state); processReturn(ret, type, state); + if (t.duration() > 50ms) ALOGD("Excessive delay setting light"); } } diff --git a/services/core/jni/com_android_server_power_PowerManagerService.cpp b/services/core/jni/com_android_server_power_PowerManagerService.cpp index c722629a28f46..29924dd60dcf3 100644 --- a/services/core/jni/com_android_server_power_PowerManagerService.cpp +++ b/services/core/jni/com_android_server_power_PowerManagerService.cpp @@ -26,6 +26,7 @@ #include +#include #include #include #include @@ -157,20 +158,29 @@ static void nativeReleaseSuspendBlocker(JNIEnv *env, jclass /* clazz */, jstring static void nativeSetInteractive(JNIEnv* /* env */, jclass /* clazz */, jboolean enable) { std::lock_guard lock(gPowerHalMutex); if (getPowerHal()) { - String8 err("Excessive delay in setInteractive(%s) while turning screen %s"); - ALOGD_IF_SLOW(20, String8::format(err, enable ? "true" : "false", enable ? "on" : "off")); + android::base::Timer t; Return ret = gPowerHal->setInteractive(enable); processReturn(ret, "setInteractive"); + if (t.duration() > 20ms) { + ALOGD("Excessive delay in setInteractive(%s) while turning screen %s", + enable ? "true" : "false", enable ? "on" : "off"); + } } } static void nativeSetAutoSuspend(JNIEnv* /* env */, jclass /* clazz */, jboolean enable) { if (enable) { - ALOGD_IF_SLOW(100, "Excessive delay in autosuspend_enable() while turning screen off"); + android::base::Timer t; autosuspend_enable(); + if (t.duration() > 100ms) { + ALOGD("Excessive delay in autosuspend_enable() while turning screen off"); + } } else { - ALOGD_IF_SLOW(100, "Excessive delay in autosuspend_disable() while turning screen on"); + android::base::Timer t; autosuspend_disable(); + if (t.duration() > 100ms) { + ALOGD("Excessive delay in autosuspend_disable() while turning screen on"); + } } }