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

Commit 3a2028a5 authored by Riddle Hsu's avatar Riddle Hsu
Browse files

Use user activity touch event to reduce latency of UDFPS

- Send USER_ACTIVITY_EVENT_TOUCH at the beginning of recognizing
  a motion event in the sensor area.
- Currently only UDFPS may trigger the event when the device is not
  awake. Then boost the process scheduling group to top-app for
  systemui so it can update the UI faster. Though the boost timeout
  is 2s, it is usually canceled earlier once the keygaurd finishes
  unlocking which will call setHasTopUi(false).

Also remove the outdated comment in PWM#userActivity because the
method runs on the handler of com.android.server.power.Notifier,
which isn't locked outside years.

Bug: 242775562
Test: Enable AOD and UDFPS, lock device. Unlock with fingerprint.
      The trace "setProcessGroup com.android.systemui to 5" should
      appear with ACTION_UDFPS_ILLUMINATE together.

Change-Id: I1a0174e4b106522ada005089618056861e93d375
parent d8ebffe4
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -517,8 +517,6 @@ public class UdfpsController implements DozeReceiver {
                                    scaledMajor);
                            Log.v(TAG, "onTouch | finger down: " + touchInfo);
                            mTouchLogTime = mSystemClock.elapsedRealtime();
                            mPowerManager.userActivity(mSystemClock.uptimeMillis(),
                                    PowerManager.USER_ACTIVITY_EVENT_TOUCH, 0);
                            handled = true;
                        } else if (sinceLastLog >= MIN_TOUCH_LOG_INTERVAL) {
                            Log.v(TAG, "onTouch | finger move: " + touchInfo);
@@ -846,6 +844,9 @@ public class UdfpsController implements DozeReceiver {
            return;
        }
        mLatencyTracker.onActionStart(LatencyTracker.ACTION_UDFPS_ILLUMINATE);
        // Refresh screen timeout and boost process priority if possible.
        mPowerManager.userActivity(mSystemClock.uptimeMillis(),
                PowerManager.USER_ACTIVITY_EVENT_TOUCH, 0);

        if (!mOnFingerDown) {
            playStartHaptic();
+4 −12
Original line number Diff line number Diff line
@@ -5107,18 +5107,10 @@ public class PhoneWindowManager implements WindowManagerPolicy {

    /** {@inheritDoc} */
    @Override
    public void userActivity() {
        // ***************************************
        // NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE
        // ***************************************
        // THIS IS CALLED FROM DEEP IN THE POWER MANAGER
        // WITH ITS LOCKS HELD.
        //
        // This code must be VERY careful about the locks
        // it acquires.
        // In fact, the current code acquires way too many,
        // and probably has lurking deadlocks.

    public void userActivity(int displayGroupId, int event) {
        if (displayGroupId == DEFAULT_DISPLAY && event == PowerManager.USER_ACTIVITY_EVENT_TOUCH) {
            mDefaultDisplayPolicy.onUserActivityEventTouch();
        }
        synchronized (mScreenLockTimeout) {
            if (mLockScreenTimerActive) {
                // reset the timer
+1 −1
Original line number Diff line number Diff line
@@ -1006,7 +1006,7 @@ public interface WindowManagerPolicy extends WindowManagerPolicyConstants {
     * Called when userActivity is signalled in the power manager.
     * This is safe to call from any thread, with any window manager locks held or not.
     */
    public void userActivity();
    void userActivity(int displayGroupId, int event);

    /**
     * Called when we have finished booting and can now display the home
+1 −1
Original line number Diff line number Diff line
@@ -712,7 +712,7 @@ public class Notifier {
        }
        TelephonyManager tm = mContext.getSystemService(TelephonyManager.class);
        tm.notifyUserActivity();
        mPolicy.userActivity();
        mPolicy.userActivity(displayGroupId, event);
        mFaceDownDetector.userActivity(event);
        mScreenUndimDetector.userActivity(displayGroupId);
    }
+8 −6
Original line number Diff line number Diff line
@@ -311,7 +311,7 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {

    /**
     * The duration to keep a process in animating state (top scheduling group) when the
     * wakefulness is changing from awake to doze or sleep.
     * wakefulness is dozing (unlocking) or changing from awake to doze or sleep (locking).
     */
    private static final long DOZE_ANIMATING_STATE_RETAIN_TIME_MS = 2000;

@@ -2927,12 +2927,14 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {
            mDemoteTopAppReasons &= ~DEMOTE_TOP_REASON_DURING_UNLOCKING;
            final WindowState notificationShade = mRootWindowContainer.getDefaultDisplay()
                    .getDisplayPolicy().getNotificationShade();
            proc = notificationShade != null
                    ? mProcessMap.getProcess(notificationShade.mSession.mPid) : null;
            proc = notificationShade != null ? notificationShade.getProcess() : null;
        }
        if (proc == null) {
            return;
        setProcessAnimatingWhileDozing(proc);
    }

    // The caller MUST NOT hold the global lock because it calls AM method directly.
    void setProcessAnimatingWhileDozing(WindowProcessController proc) {
        if (proc == null) return;
        // Set to activity manager directly to make sure the state can be seen by the subsequent
        // update of scheduling group.
        proc.setRunningAnimationUnsafe();
Loading