diff options
5 files changed, 47 insertions, 87 deletions
diff --git a/services/inputflinger/reader/InputReader.cpp b/services/inputflinger/reader/InputReader.cpp index 7ab000bbd0..845cab05d3 100644 --- a/services/inputflinger/reader/InputReader.cpp +++ b/services/inputflinger/reader/InputReader.cpp @@ -196,9 +196,8 @@ void InputReader::loopOnce() { if (mNextTimeout != LLONG_MAX) { nsecs_t now = systemTime(SYSTEM_TIME_MONOTONIC); if (now >= mNextTimeout) { - if (debugRawEvents()) { - ALOGD("Timeout expired, latency=%0.3fms", (now - mNextTimeout) * 0.000001f); - } + ALOGD_IF(debugRawEvents(), "Timeout expired, latency=%0.3fms", + (now - mNextTimeout) * 0.000001f); mNextTimeout = LLONG_MAX; mPendingArgs += timeoutExpiredLocked(now); } @@ -263,9 +262,7 @@ std::list<NotifyArgs> InputReader::processEventsLocked(const RawEvent* rawEvents } batchSize += 1; } - if (debugRawEvents()) { - ALOGD("BatchSize: %zu Count: %zu", batchSize, count); - } + ALOGD_IF(debugRawEvents(), "BatchSize: %zu Count: %zu", batchSize, count); out += processEventsForDeviceLocked(deviceId, rawEvent, batchSize); } else { switch (rawEvent->type) { diff --git a/services/inputflinger/reader/controller/PeripheralController.cpp b/services/inputflinger/reader/controller/PeripheralController.cpp index 7434ae4b0a..df22890319 100644 --- a/services/inputflinger/reader/controller/PeripheralController.cpp +++ b/services/inputflinger/reader/controller/PeripheralController.cpp @@ -78,10 +78,8 @@ std::optional<std::int32_t> PeripheralController::Light::getRawLightBrightness(i if (rawMaxBrightness != MAX_BRIGHTNESS) { brightness = brightness * ratio; } - if (DEBUG_LIGHT_DETAILS) { - ALOGD("getRawLightBrightness rawLightId %d brightness 0x%x ratio %.2f", rawLightId, - brightness, ratio); - } + ALOGD_IF(DEBUG_LIGHT_DETAILS, "getRawLightBrightness rawLightId %d brightness 0x%x ratio %.2f", + rawLightId, brightness, ratio); return brightness; } @@ -97,10 +95,8 @@ void PeripheralController::Light::setRawLightBrightness(int32_t rawLightId, int3 if (rawMaxBrightness != MAX_BRIGHTNESS) { brightness = ceil(brightness / ratio); } - if (DEBUG_LIGHT_DETAILS) { - ALOGD("setRawLightBrightness rawLightId %d brightness 0x%x ratio %.2f", rawLightId, - brightness, ratio); - } + ALOGD_IF(DEBUG_LIGHT_DETAILS, "setRawLightBrightness rawLightId %d brightness 0x%x ratio %.2f", + rawLightId, brightness, ratio); context.setLightBrightness(rawLightId, brightness); } @@ -453,10 +449,9 @@ void PeripheralController::configureLights() { if (rawInfo->flags.test(InputLightClass::GLOBAL)) { rawGlobalId = rawId; } - if (DEBUG_LIGHT_DETAILS) { - ALOGD("Light rawId %d name %s max %d flags %s \n", rawInfo->id, rawInfo->name.c_str(), - rawInfo->maxBrightness.value_or(MAX_BRIGHTNESS), rawInfo->flags.string().c_str()); - } + ALOGD_IF(DEBUG_LIGHT_DETAILS, "Light rawId %d name %s max %d flags %s\n", rawInfo->id, + rawInfo->name.c_str(), rawInfo->maxBrightness.value_or(MAX_BRIGHTNESS), + rawInfo->flags.string().c_str()); } // Construct a player ID light @@ -473,10 +468,8 @@ void PeripheralController::configureLights() { } // Construct a RGB light for composed RGB light if (hasRedLed && hasGreenLed && hasBlueLed) { - if (DEBUG_LIGHT_DETAILS) { - ALOGD("Rgb light ids [%d, %d, %d] \n", rawRgbIds.at(LightColor::RED), - rawRgbIds.at(LightColor::GREEN), rawRgbIds.at(LightColor::BLUE)); - } + ALOGD_IF(DEBUG_LIGHT_DETAILS, "Rgb light ids [%d, %d, %d]\n", rawRgbIds.at(LightColor::RED), + rawRgbIds.at(LightColor::GREEN), rawRgbIds.at(LightColor::BLUE)); bool isKeyboardBacklight = keyboardBacklightIds.find(rawRgbIds.at(LightColor::RED)) != keyboardBacklightIds.end() && keyboardBacklightIds.find(rawRgbIds.at(LightColor::GREEN)) != @@ -518,9 +511,8 @@ void PeripheralController::configureLights() { // If the node is multi-color led, construct a MULTI_COLOR light if (rawInfo.flags.test(InputLightClass::MULTI_INDEX) && rawInfo.flags.test(InputLightClass::MULTI_INTENSITY)) { - if (DEBUG_LIGHT_DETAILS) { - ALOGD("Multicolor light Id %d name %s \n", rawInfo.id, rawInfo.name.c_str()); - } + ALOGD_IF(DEBUG_LIGHT_DETAILS, "Multicolor light Id %d name %s\n", rawInfo.id, + rawInfo.name.c_str()); std::unique_ptr<Light> light = std::make_unique<MultiColorLight>(getDeviceContext(), rawInfo.name, ++mNextId, type, rawInfo.id); @@ -528,9 +520,8 @@ void PeripheralController::configureLights() { continue; } // Construct a Mono LED light - if (DEBUG_LIGHT_DETAILS) { - ALOGD("Mono light Id %d name %s \n", rawInfo.id, rawInfo.name.c_str()); - } + ALOGD_IF(DEBUG_LIGHT_DETAILS, "Mono light Id %d name %s\n", rawInfo.id, + rawInfo.name.c_str()); std::unique_ptr<Light> light = std::make_unique<MonoLight>(getDeviceContext(), rawInfo.name, ++mNextId, type, rawInfo.id); @@ -552,10 +543,8 @@ bool PeripheralController::setLightColor(int32_t lightId, int32_t color) { return false; } auto& light = it->second; - if (DEBUG_LIGHT_DETAILS) { - ALOGD("setLightColor lightId %d type %s color 0x%x", lightId, - ftl::enum_string(light->type).c_str(), color); - } + ALOGD_IF(DEBUG_LIGHT_DETAILS, "setLightColor lightId %d type %s color 0x%x", lightId, + ftl::enum_string(light->type).c_str(), color); return light->setLightColor(color); } @@ -566,10 +555,8 @@ std::optional<int32_t> PeripheralController::getLightColor(int32_t lightId) { } auto& light = it->second; std::optional<int32_t> color = light->getLightColor(); - if (DEBUG_LIGHT_DETAILS) { - ALOGD("getLightColor lightId %d type %s color 0x%x", lightId, - ftl::enum_string(light->type).c_str(), color.value_or(0)); - } + ALOGD_IF(DEBUG_LIGHT_DETAILS, "getLightColor lightId %d type %s color 0x%x", lightId, + ftl::enum_string(light->type).c_str(), color.value_or(0)); return color; } diff --git a/services/inputflinger/reader/mapper/MultiTouchInputMapper.cpp b/services/inputflinger/reader/mapper/MultiTouchInputMapper.cpp index fd8224a608..4d08f1965e 100644 --- a/services/inputflinger/reader/mapper/MultiTouchInputMapper.cpp +++ b/services/inputflinger/reader/mapper/MultiTouchInputMapper.cpp @@ -79,19 +79,17 @@ void MultiTouchInputMapper::syncTouch(nsecs_t when, RawState* outState) { if (id) { outState->rawPointerData.canceledIdBits.markBit(id.value()); } - if (DEBUG_POINTERS) { - ALOGI("Stop processing slot %zu for it received a palm event from device %s", - inIndex, getDeviceName().c_str()); - } + ALOGI_IF(DEBUG_POINTERS, + "Stop processing slot %zu for it received a palm event from device %s", + inIndex, getDeviceName().c_str()); continue; } if (outCount >= MAX_POINTERS) { - if (DEBUG_POINTERS) { - ALOGD("MultiTouch device %s emitted more than maximum of %zu pointers; " - "ignoring the rest.", - getDeviceName().c_str(), MAX_POINTERS); - } + ALOGD_IF(DEBUG_POINTERS, + "MultiTouch device %s emitted more than maximum of %zu pointers; ignoring the " + "rest.", + getDeviceName().c_str(), MAX_POINTERS); break; // too many fingers! } diff --git a/services/inputflinger/reader/mapper/SensorInputMapper.cpp b/services/inputflinger/reader/mapper/SensorInputMapper.cpp index 1f6600d3f6..0d1d8844c1 100644 --- a/services/inputflinger/reader/mapper/SensorInputMapper.cpp +++ b/services/inputflinger/reader/mapper/SensorInputMapper.cpp @@ -235,9 +235,8 @@ void SensorInputMapper::processHardWareTimestamp(nsecs_t evTime, int32_t mscTime // else calculate difference between previous and current MSC_TIMESTAMP if (mPrevMscTime == 0) { mHardwareTimestamp = evTime; - if (DEBUG_SENSOR_EVENT_DETAILS) { - ALOGD("Initialize hardware timestamp = %" PRId64, mHardwareTimestamp); - } + ALOGD_IF(DEBUG_SENSOR_EVENT_DETAILS, "Initialize hardware timestamp = %" PRId64, + mHardwareTimestamp); } else { // Calculate the difference between current msc_timestamp and // previous msc_timestamp, including when msc_timestamp wraps around. @@ -330,11 +329,10 @@ void SensorInputMapper::flushSensor(InputDeviceSensorType sensorType) { bool SensorInputMapper::enableSensor(InputDeviceSensorType sensorType, std::chrono::microseconds samplingPeriod, std::chrono::microseconds maxBatchReportLatency) { - if (DEBUG_SENSOR_EVENT_DETAILS) { - ALOGD("Enable Sensor %s samplingPeriod %lld maxBatchReportLatency %lld", - ftl::enum_string(sensorType).c_str(), samplingPeriod.count(), - maxBatchReportLatency.count()); - } + ALOGD_IF(DEBUG_SENSOR_EVENT_DETAILS, + "Enable Sensor %s samplingPeriod %lld maxBatchReportLatency %lld", + ftl::enum_string(sensorType).c_str(), samplingPeriod.count(), + maxBatchReportLatency.count()); if (!setSensorEnabled(sensorType, /*enabled=*/true)) { return false; @@ -355,9 +353,7 @@ bool SensorInputMapper::enableSensor(InputDeviceSensorType sensorType, } void SensorInputMapper::disableSensor(InputDeviceSensorType sensorType) { - if (DEBUG_SENSOR_EVENT_DETAILS) { - ALOGD("Disable Sensor %s", ftl::enum_string(sensorType).c_str()); - } + ALOGD_IF(DEBUG_SENSOR_EVENT_DETAILS, "Disable Sensor %s", ftl::enum_string(sensorType).c_str()); if (!setSensorEnabled(sensorType, /*enabled=*/false)) { return; @@ -389,15 +385,12 @@ std::list<NotifyArgs> SensorInputMapper::sync(nsecs_t when, bool force) { } nsecs_t timestamp = mHasHardwareTimestamp ? mHardwareTimestamp : when; - if (DEBUG_SENSOR_EVENT_DETAILS) { - ALOGD("Sensor %s timestamp %" PRIu64 " values [%f %f %f]", - ftl::enum_string(sensorType).c_str(), timestamp, values[0], values[1], values[2]); - } + ALOGD_IF(DEBUG_SENSOR_EVENT_DETAILS, "Sensor %s timestamp %" PRIu64 " values [%f %f %f]", + ftl::enum_string(sensorType).c_str(), timestamp, values[0], values[1], values[2]); if (sensor.lastSampleTimeNs.has_value() && timestamp - sensor.lastSampleTimeNs.value() < sensor.samplingPeriod.count()) { - if (DEBUG_SENSOR_EVENT_DETAILS) { - ALOGD("Sensor %s Skip a sample.", ftl::enum_string(sensorType).c_str()); - } + ALOGD_IF(DEBUG_SENSOR_EVENT_DETAILS, "Sensor %s Skip a sample.", + ftl::enum_string(sensorType).c_str()); } else { // Convert to Android unit convertFromLinuxToAndroid(values, sensorType); diff --git a/services/inputflinger/reader/mapper/VibratorInputMapper.cpp b/services/inputflinger/reader/mapper/VibratorInputMapper.cpp index a3a48ef034..264ef6f3e0 100644 --- a/services/inputflinger/reader/mapper/VibratorInputMapper.cpp +++ b/services/inputflinger/reader/mapper/VibratorInputMapper.cpp @@ -43,10 +43,8 @@ std::list<NotifyArgs> VibratorInputMapper::process(const RawEvent& rawEvent) { std::list<NotifyArgs> VibratorInputMapper::vibrate(const VibrationSequence& sequence, ssize_t repeat, int32_t token) { - if (DEBUG_VIBRATOR) { - ALOGD("vibrate: deviceId=%d, pattern=[%s], repeat=%zd, token=%d", getDeviceId(), - sequence.toString().c_str(), repeat, token); - } + ALOGD_IF(DEBUG_VIBRATOR, "vibrate: deviceId=%d, pattern=[%s], repeat=%zd, token=%d", + getDeviceId(), sequence.toString().c_str(), repeat, token); std::list<NotifyArgs> out; mVibrating = true; @@ -63,9 +61,7 @@ std::list<NotifyArgs> VibratorInputMapper::vibrate(const VibrationSequence& sequ } std::list<NotifyArgs> VibratorInputMapper::cancelVibrate(int32_t token) { - if (DEBUG_VIBRATOR) { - ALOGD("cancelVibrate: deviceId=%d, token=%d", getDeviceId(), token); - } + ALOGD_IF(DEBUG_VIBRATOR, "cancelVibrate: deviceId=%d, token=%d", getDeviceId(), token); std::list<NotifyArgs> out; if (mVibrating && mToken == token) { @@ -95,9 +91,7 @@ std::list<NotifyArgs> VibratorInputMapper::timeoutExpired(nsecs_t when) { } std::list<NotifyArgs> VibratorInputMapper::nextStep() { - if (DEBUG_VIBRATOR) { - ALOGD("nextStep: index=%d, vibrate deviceId=%d", (int)mIndex, getDeviceId()); - } + ALOGD_IF(DEBUG_VIBRATOR, "nextStep: index=%d, vibrate deviceId=%d", (int)mIndex, getDeviceId()); std::list<NotifyArgs> out; mIndex += 1; if (size_t(mIndex) >= mSequence.pattern.size()) { @@ -111,16 +105,11 @@ std::list<NotifyArgs> VibratorInputMapper::nextStep() { const VibrationElement& element = mSequence.pattern[mIndex]; if (element.isOn()) { - if (DEBUG_VIBRATOR) { - std::string description = element.toString(); - ALOGD("nextStep: sending vibrate deviceId=%d, element=%s", getDeviceId(), - description.c_str()); - } + ALOGD_IF(DEBUG_VIBRATOR, "nextStep: sending vibrate deviceId=%d, element=%s", getDeviceId(), + element.toString().c_str()); getDeviceContext().vibrate(element); } else { - if (DEBUG_VIBRATOR) { - ALOGD("nextStep: sending cancel vibrate deviceId=%d", getDeviceId()); - } + ALOGD_IF(DEBUG_VIBRATOR, "nextStep: sending cancel vibrate deviceId=%d", getDeviceId()); getDeviceContext().cancelVibrate(); } nsecs_t now = systemTime(SYSTEM_TIME_MONOTONIC); @@ -128,17 +117,13 @@ std::list<NotifyArgs> VibratorInputMapper::nextStep() { std::chrono::duration_cast<std::chrono::nanoseconds>(element.duration); mNextStepTime = now + duration.count(); getContext()->requestTimeoutAtTime(mNextStepTime); - if (DEBUG_VIBRATOR) { - ALOGD("nextStep: scheduled timeout in %lldms", element.duration.count()); - } + ALOGD_IF(DEBUG_VIBRATOR, "nextStep: scheduled timeout in %lldms", element.duration.count()); return out; } NotifyVibratorStateArgs VibratorInputMapper::stopVibrating() { mVibrating = false; - if (DEBUG_VIBRATOR) { - ALOGD("stopVibrating: sending cancel vibrate deviceId=%d", getDeviceId()); - } + ALOGD_IF(DEBUG_VIBRATOR, "stopVibrating: sending cancel vibrate deviceId=%d", getDeviceId()); getDeviceContext().cancelVibrate(); // Request InputReader to notify InputManagerService for vibration complete. |