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

Commit 28118aff authored by Longbo Wei's avatar Longbo Wei Committed by Android (Google) Code Review
Browse files

Merge "autoclick: Log the autoclick usage and duration" into main

parents d54d96fa 83e02f0c
Loading
Loading
Loading
Loading
+13 −0
Original line number Diff line number Diff line
@@ -106,6 +106,8 @@ public class AutoclickController extends BaseEventStreamTransformation {
    // further fine tuned based on user feedback.
    private static final float SCROLL_AMOUNT = 0.5f;
    protected static final long CONTINUOUS_SCROLL_INTERVAL = 30;
    // Timestamp when autoclick was enabled, used to calculate session duration.
    private final long mAutoclickEnabledTimestamp;
    private Handler mContinuousScrollHandler;
    private Runnable mContinuousScrollRunnable;

@@ -234,6 +236,10 @@ public class AutoclickController extends BaseEventStreamTransformation {
        mTrace = trace;
        mContext = context;
        mUserId = userId;

        // Record when autoclick is enabled, and store the enabled timestamp.
        mAutoclickEnabledTimestamp = SystemClock.elapsedRealtime();
        AutoclickLogger.logAutoclickEnabled();
    }

    @Override
@@ -362,6 +368,13 @@ public class AutoclickController extends BaseEventStreamTransformation {
            mContinuousScrollHandler.removeCallbacks(mContinuousScrollRunnable);
            mContinuousScrollHandler = null;
        }

        // Calculate session duration and log when autoclick is disabled.
        if (mAutoclickEnabledTimestamp > 0) {
            int sessionDurationSeconds =
                    (int) ((SystemClock.elapsedRealtime() - mAutoclickEnabledTimestamp) / 1000);
            AutoclickLogger.logAutoclickSessionDuration(sessionDurationSeconds);
        }
    }

    private void scheduleClick(MotionEvent event, int policyFlags) {
+17 −0
Original line number Diff line number Diff line
@@ -45,4 +45,21 @@ public class AutoclickLogger {
        FrameworkStatsLog.write(FrameworkStatsLog.AUTOCLICK_EVENT_REPORTED,
                autoclickType);
    }

    /**
     * Logs when autoclick feature is enabled.
     */
    public static void logAutoclickEnabled() {
        FrameworkStatsLog.write(FrameworkStatsLog.AUTOCLICK_ENABLED_REPORTED, true);
    }

    /**
     * Logs autoclick session duration when the feature is disabled.
     *
     * @param sessionDurationSeconds How long the feature was enabled.
     */
    public static void logAutoclickSessionDuration(int sessionDurationSeconds) {
        FrameworkStatsLog.write(FrameworkStatsLog.AUTOCLICK_SESSION_DURATION_REPORTED,
                sessionDurationSeconds);
    }
}