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

Commit 6b9959e6 authored by Prabir Pradhan's avatar Prabir Pradhan
Browse files

Notify dispatcher when its configuration needs to be updated

When there is a change in the long press timeout, the key press timeout
should also be updated.

Bug: 278992287
Test: Presubmit
Change-Id: Ib0a6a932ad663dbdbc21c0888f6d35d54d01da85
parent 73dee795
Loading
Loading
Loading
Loading
+28 −21
Original line number Diff line number Diff line
@@ -64,12 +64,14 @@ class InputSettingsObserver extends ContentObserver {
                        (reason) -> updateTouchpadRightClickZoneEnabled()),
                Map.entry(Settings.System.getUriFor(Settings.System.SHOW_TOUCHES),
                        (reason) -> updateShowTouches()),
            Map.entry(Settings.Secure.getUriFor(Settings.Secure.ACCESSIBILITY_LARGE_POINTER_ICON),
                Map.entry(
                        Settings.Secure.getUriFor(Settings.Secure.ACCESSIBILITY_LARGE_POINTER_ICON),
                        (reason) -> updateAccessibilityLargePointer()),
                Map.entry(Settings.Secure.getUriFor(Settings.Secure.LONG_PRESS_TIMEOUT),
                    (reason) -> updateDeepPressStatus(reason)),
                        (reason) -> updateLongPressTimeout(reason)),
                Map.entry(
                    Settings.Global.getUriFor(Settings.Global.MAXIMUM_OBSCURING_OPACITY_FOR_TOUCH),
                        Settings.Global.getUriFor(
                                Settings.Global.MAXIMUM_OBSCURING_OPACITY_FOR_TOUCH),
                        (reason) -> updateMaximumObscuringOpacityForTouch()));
    }

@@ -151,8 +153,13 @@ class InputSettingsObserver extends ContentObserver {
        mNative.reloadPointerIcons();
    }

    private void updateDeepPressStatus(String reason) {
        // Not using ViewConfiguration.getLongPressTimeout here because it may return a stale value
    private void updateLongPressTimeout(String reason) {
        // Some key gesture timeouts are based on the long press timeout, so update key gesture
        // timeouts when the value changes. See ViewConfiguration#getKeyRepeatTimeout().
        mNative.notifyKeyGestureTimeoutsChanged();

        // Update the deep press status.
        // Not using ViewConfiguration.getLongPressTimeout here because it may return a stale value.
        final int timeout = Settings.Secure.getIntForUser(mContext.getContentResolver(),
                Settings.Secure.LONG_PRESS_TIMEOUT, ViewConfiguration.DEFAULT_LONG_PRESS_TIMEOUT,
                UserHandle.USER_CURRENT);
+13 −5
Original line number Diff line number Diff line
@@ -28,6 +28,7 @@ import android.view.InputChannel;
import android.view.InputEvent;
import android.view.PointerIcon;
import android.view.VerifiedInputEvent;
import android.view.ViewConfiguration;

import java.util.List;

@@ -198,8 +199,6 @@ interface NativeInputManagerService {

    void changeKeyboardLayoutAssociation();

    void notifyPointerDisplayIdChanged();

    void setDisplayEligibilityForPointerCapture(int displayId, boolean enabled);

    void setMotionClassifierEnabled(boolean enabled);
@@ -243,6 +242,15 @@ interface NativeInputManagerService {
     */
    void sysfsNodeChanged(String sysfsNodePath);

    /**
     * Notify there is a change in any of the key gesture timeouts, such as the key
     * repeat timeout or key repeat delay.
     *
     * @see ViewConfiguration#getKeyRepeatTimeout()
     * @see ViewConfiguration#getKeyRepeatDelay()
     */
    void notifyKeyGestureTimeoutsChanged();

    /** The native implementation of InputManagerService methods. */
    class NativeImpl implements NativeInputManagerService {
        /** Pointer to native input manager service object, used by native code. */
@@ -451,9 +459,6 @@ interface NativeInputManagerService {
        @Override
        public native void changeKeyboardLayoutAssociation();

        @Override
        public native void notifyPointerDisplayIdChanged();

        @Override
        public native void setDisplayEligibilityForPointerCapture(int displayId, boolean enabled);

@@ -493,5 +498,8 @@ interface NativeInputManagerService {

        @Override
        public native void sysfsNodeChanged(String sysfsNodePath);

        @Override
        public native void notifyKeyGestureTimeoutsChanged();
    }
}
+6 −0
Original line number Diff line number Diff line
@@ -2567,6 +2567,11 @@ static void nativeSetStylusPointerIconEnabled(JNIEnv* env, jobject nativeImplObj
    im->setStylusPointerIconEnabled(enabled);
}

static void nativeNotifyKeyGestureTimeoutsChanged(JNIEnv* env, jobject nativeImplObj) {
    NativeInputManager* im = getNativeInputManager(env, nativeImplObj);
    im->getInputManager()->getDispatcher().requestRefreshConfiguration();
}

// ----------------------------------------------------------------------------

static const JNINativeMethod gInputManagerMethods[] = {
@@ -2663,6 +2668,7 @@ static const JNINativeMethod gInputManagerMethods[] = {
         (void*)nativeSetStylusButtonMotionEventsEnabled},
        {"getMouseCursorPosition", "()[F", (void*)nativeGetMouseCursorPosition},
        {"setStylusPointerIconEnabled", "(Z)V", (void*)nativeSetStylusPointerIconEnabled},
        {"notifyKeyGestureTimeoutsChanged", "()V", (void*)nativeNotifyKeyGestureTimeoutsChanged},
};

#define FIND_CLASS(var, className) \