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

Commit 83e02f0c authored by “Longbo's avatar “Longbo Committed by Longbo Wei
Browse files

autoclick: Log the autoclick usage and duration

Video: http://shortn/_rvGVAscT0M

Bug: b/409768370
Test: AutoclickControllerTest
Flag: com.android.server.accessibility.enable_autoclick_indicator
Change-Id: Ie0878d697ccf6f4ecf144eec7030255b00226621
parent 9c77a336
Loading
Loading
Loading
Loading
+13 −0
Original line number Original line Diff line number Diff line
@@ -103,6 +103,8 @@ public class AutoclickController extends BaseEventStreamTransformation {
    // further fine tuned based on user feedback.
    // further fine tuned based on user feedback.
    private static final float SCROLL_AMOUNT = 0.5f;
    private static final float SCROLL_AMOUNT = 0.5f;
    protected static final long CONTINUOUS_SCROLL_INTERVAL = 30;
    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 Handler mContinuousScrollHandler;
    private Runnable mContinuousScrollRunnable;
    private Runnable mContinuousScrollRunnable;


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

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


    @Override
    @Override
@@ -357,6 +363,13 @@ public class AutoclickController extends BaseEventStreamTransformation {
            mContinuousScrollHandler.removeCallbacks(mContinuousScrollRunnable);
            mContinuousScrollHandler.removeCallbacks(mContinuousScrollRunnable);
            mContinuousScrollHandler = null;
            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) {
    private void scheduleClick(MotionEvent event, int policyFlags) {
+17 −0
Original line number Original line Diff line number Diff line
@@ -45,4 +45,21 @@ public class AutoclickLogger {
        FrameworkStatsLog.write(FrameworkStatsLog.AUTOCLICK_EVENT_REPORTED,
        FrameworkStatsLog.write(FrameworkStatsLog.AUTOCLICK_EVENT_REPORTED,
                autoclickType);
                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);
    }
}
}