diff options
-rw-r--r-- | services/inputflinger/reader/Android.bp | 3 | ||||
-rw-r--r-- | services/inputflinger/reader/mapper/TouchpadInputMapper.cpp | 14 | ||||
-rw-r--r-- | services/inputflinger/reader/mapper/gestures/GesturesLogcatAdapter.cpp (renamed from services/inputflinger/reader/mapper/gestures/GesturesLogging.cpp) | 16 | ||||
-rw-r--r-- | services/inputflinger/reader/mapper/gestures/Logging.cpp | 46 | ||||
-rw-r--r-- | services/inputflinger/reader/mapper/gestures/Logging.h | 29 |
5 files changed, 82 insertions, 26 deletions
diff --git a/services/inputflinger/reader/Android.bp b/services/inputflinger/reader/Android.bp index 3934e783d1..dc7f7c1d26 100644 --- a/services/inputflinger/reader/Android.bp +++ b/services/inputflinger/reader/Android.bp @@ -66,9 +66,10 @@ filegroup { "mapper/accumulator/SingleTouchMotionAccumulator.cpp", "mapper/accumulator/TouchButtonAccumulator.cpp", "mapper/gestures/GestureConverter.cpp", - "mapper/gestures/GesturesLogging.cpp", + "mapper/gestures/GesturesLogcatAdapter.cpp", "mapper/gestures/HardwareProperties.cpp", "mapper/gestures/HardwareStateConverter.cpp", + "mapper/gestures/Logging.cpp", "mapper/gestures/PropertyProvider.cpp", "mapper/gestures/TimerProvider.cpp", ], diff --git a/services/inputflinger/reader/mapper/TouchpadInputMapper.cpp b/services/inputflinger/reader/mapper/TouchpadInputMapper.cpp index 18a7102514..c982dab019 100644 --- a/services/inputflinger/reader/mapper/TouchpadInputMapper.cpp +++ b/services/inputflinger/reader/mapper/TouchpadInputMapper.cpp @@ -40,6 +40,7 @@ #include "TouchCursorInputMapperCommon.h" #include "TouchpadInputMapper.h" #include "gestures/HardwareProperties.h" +#include "gestures/Logging.h" #include "gestures/TimerProvider.h" #include "ui/Rotation.h" @@ -49,15 +50,6 @@ namespace android { namespace { -/** - * Log details of each gesture output by the gestures library. - * Enable this via "adb shell setprop log.tag.TouchpadInputMapperGestures DEBUG" (requires - * restarting the shell) - */ -const bool DEBUG_TOUCHPAD_GESTURES = - __android_log_is_loggable(ANDROID_LOG_DEBUG, "TouchpadInputMapperGestures", - ANDROID_LOG_INFO); - std::vector<double> createAccelerationCurveForSensitivity(int32_t sensitivity, bool accelerationEnabled, size_t propertySize) { @@ -470,7 +462,7 @@ void TouchpadInputMapper::updatePalmDetectionMetrics() { std::list<NotifyArgs> TouchpadInputMapper::sendHardwareState(nsecs_t when, nsecs_t readTime, SelfContainedHardwareState schs) { - ALOGD_IF(DEBUG_TOUCHPAD_GESTURES, "New hardware state: %s", schs.state.String().c_str()); + ALOGD_IF(debugTouchpadGestures(), "New hardware state: %s", schs.state.String().c_str()); mGestureInterpreter->PushHardwareState(&schs.state); return processGestures(when, readTime); } @@ -481,7 +473,7 @@ std::list<NotifyArgs> TouchpadInputMapper::timeoutExpired(nsecs_t when) { } void TouchpadInputMapper::consumeGesture(const Gesture* gesture) { - ALOGD_IF(DEBUG_TOUCHPAD_GESTURES, "Gesture ready: %s", gesture->String().c_str()); + ALOGD_IF(debugTouchpadGestures(), "Gesture ready: %s", gesture->String().c_str()); if (mResettingInterpreter) { // We already handle tidying up fake fingers etc. in GestureConverter::reset, so we should // ignore any gestures produced from the interpreter while we're resetting it. diff --git a/services/inputflinger/reader/mapper/gestures/GesturesLogging.cpp b/services/inputflinger/reader/mapper/gestures/GesturesLogcatAdapter.cpp index 26028c5643..51905f92cf 100644 --- a/services/inputflinger/reader/mapper/gestures/GesturesLogging.cpp +++ b/services/inputflinger/reader/mapper/gestures/GesturesLogcatAdapter.cpp @@ -22,29 +22,17 @@ #include <log/log.h> +#include "Logging.h" #include "include/gestures.h" extern "C" { -namespace { - -/** - * Log details of each gesture output by the gestures library. - * Enable this via "adb shell setprop log.tag.TouchpadInputMapperGestures DEBUG" (requires - * restarting the shell) - */ -const bool DEBUG_TOUCHPAD_GESTURES = - __android_log_is_loggable(ANDROID_LOG_DEBUG, "TouchpadInputMapperGestures", - ANDROID_LOG_INFO); - -} // namespace - void gestures_log(int verb, const char* fmt, ...) { va_list args; va_start(args, fmt); if (verb == GESTURES_LOG_ERROR) { LOG_PRI_VA(ANDROID_LOG_ERROR, LOG_TAG, fmt, args); - } else if (DEBUG_TOUCHPAD_GESTURES) { + } else if (android::debugTouchpadGestures()) { if (verb == GESTURES_LOG_INFO) { LOG_PRI_VA(ANDROID_LOG_INFO, LOG_TAG, fmt, args); } else { diff --git a/services/inputflinger/reader/mapper/gestures/Logging.cpp b/services/inputflinger/reader/mapper/gestures/Logging.cpp new file mode 100644 index 0000000000..b9b97c330c --- /dev/null +++ b/services/inputflinger/reader/mapper/gestures/Logging.cpp @@ -0,0 +1,46 @@ +/* + * Copyright 2025 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "Logging.h" + +#include <android-base/properties.h> +#include <log/log.h> + +namespace { + +const bool IS_DEBUGGABLE_BUILD = +#if defined(__ANDROID__) + android::base::GetBoolProperty("ro.debuggable", false); +#else + true; +#endif + +} // namespace + +namespace android { + +bool debugTouchpadGestures() { + if (!IS_DEBUGGABLE_BUILD) { + static const bool DEBUG_RAW_EVENTS = + __android_log_is_loggable(ANDROID_LOG_DEBUG, "TouchpadInputMapperGestures", + ANDROID_LOG_INFO); + return DEBUG_RAW_EVENTS; + } + return __android_log_is_loggable(ANDROID_LOG_DEBUG, "TouchpadInputMapperGestures", + ANDROID_LOG_INFO); +} + +} // namespace android
\ No newline at end of file diff --git a/services/inputflinger/reader/mapper/gestures/Logging.h b/services/inputflinger/reader/mapper/gestures/Logging.h new file mode 100644 index 0000000000..db59fb3dca --- /dev/null +++ b/services/inputflinger/reader/mapper/gestures/Logging.h @@ -0,0 +1,29 @@ +/* + * Copyright 2025 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once + +namespace android { + +/** + * Log details of touchpad gesture library input, output, and processing. + * Enable this via "adb shell setprop log.tag.TouchpadInputMapperGestures DEBUG". + * This requires a restart on non-debuggable (e.g. user) builds, but should take effect immediately + * on debuggable builds (e.g. userdebug). + */ +bool debugTouchpadGestures(); + +} // namespace android
\ No newline at end of file |