Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b0b5b6c5 authored by Cody Heiner's avatar Cody Heiner
Browse files

Use libstatssocket_lazy to report stylus metrics

Report stylus prediction metrics using libstatssocket_lazy
as an interim solution while I working on untangling the
build dependency issues (b/338106546) that prevent us from using
libstatslog within libinput.

Test: `adb reboot`, then `adb logcat | egrep -i "statssocket|MotionPredictor"`
  → Shows no bootanimation linker error, and no other errors

Test: `statsd_testdrive -d 3000 718`, then draw with stylus
  → Shows reasonable metrics logged

Bug: 338106546
Bug: 311066949

Change-Id: I05ae5ffdd774d0b25cb7b2435015245d5f712c01
parent 7702951b
Loading
Loading
Loading
Loading
+44 −0
Original line number Diff line number Diff line
@@ -289,6 +289,10 @@ cc_library {
                "motion_predictor_model_prebuilt",
                "motion_predictor_model_config",
            ],
            static_libs: [
                "libstatslog_libinput",
                "libstatssocket_lazy",
            ],
        },
        host: {
            include_dirs: [
@@ -299,6 +303,46 @@ cc_library {
    },
}

cc_library_static {
    name: "libstatslog_libinput",
    generated_sources: ["statslog_libinput.cpp"],
    generated_headers: ["statslog_libinput.h"],
    cflags: [
        "-Wall",
        "-Werror",
    ],
    export_generated_headers: ["statslog_libinput.h"],
    shared_libs: [
        "libcutils",
        "liblog",
        "libutils",
    ],
    static_libs: [
        "libstatssocket_lazy",
    ],
}

genrule {
    name: "statslog_libinput.h",
    tools: ["stats-log-api-gen"],
    cmd: "$(location stats-log-api-gen) --header $(genDir)/statslog_libinput.h " +
        "--module libinput --namespace android,libinput",
    out: [
        "statslog_libinput.h",
    ],
}

genrule {
    name: "statslog_libinput.cpp",
    tools: ["stats-log-api-gen"],
    cmd: "$(location stats-log-api-gen) --cpp $(genDir)/statslog_libinput.cpp " +
        "--module libinput --namespace android,libinput " +
        "--importHeader statslog_libinput.h",
    out: [
        "statslog_libinput.cpp",
    ],
}

cc_defaults {
    name: "libinput_fuzz_defaults",
    cpp_std: "c++20",
+17 −3
Original line number Diff line number Diff line
@@ -21,6 +21,9 @@
#include <algorithm>

#include <android-base/logging.h>
#ifdef __ANDROID__
#include <statslog_libinput.h>
#endif // __ANDROID__

#include "Eigen/Core"
#include "Eigen/Geometry"
@@ -44,9 +47,20 @@ inline constexpr float PATH_LENGTH_EPSILON = 0.001;

void MotionPredictorMetricsManager::defaultReportAtomFunction(
        const MotionPredictorMetricsManager::AtomFields& atomFields) {
    // TODO(b/338106546): Fix bootanimation build dependency issue, then re-add
    // the stats_write function call here.
    (void)atomFields;
#ifdef __ANDROID__
    android::libinput::stats_write(android::libinput::STYLUS_PREDICTION_METRICS_REPORTED,
                                   /*stylus_vendor_id=*/0,
                                   /*stylus_product_id=*/0,
                                   atomFields.deltaTimeBucketMilliseconds,
                                   atomFields.alongTrajectoryErrorMeanMillipixels,
                                   atomFields.alongTrajectoryErrorStdMillipixels,
                                   atomFields.offTrajectoryRmseMillipixels,
                                   atomFields.pressureRmseMilliunits,
                                   atomFields.highVelocityAlongTrajectoryRmse,
                                   atomFields.highVelocityOffTrajectoryRmse,
                                   atomFields.scaleInvariantAlongTrajectoryRmse,
                                   atomFields.scaleInvariantOffTrajectoryRmse);
#endif // __ANDROID__
}

MotionPredictorMetricsManager::MotionPredictorMetricsManager(
+6 −0
Original line number Diff line number Diff line
@@ -79,6 +79,12 @@ cc_test {
    },
    test_suites: ["device-tests"],
    target: {
        android: {
            static_libs: [
                "libstatslog_libinput",
                "libstatssocket_lazy",
            ],
        },
        host: {
            sanitize: {
                address: true,