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

Unverified Commit 8bca4545 authored by Danesh M's avatar Danesh M Committed by Michael Bestas
Browse files

Add high touch sensitivity and hovering to InputService

Change-Id: I5a6af73129acefa6530ceb3f73cc4cd83a19a676
parent fc6d35b2
Loading
Loading
Loading
Loading
+51 −0
Original line number Diff line number Diff line
@@ -187,6 +187,9 @@ import com.android.server.statusbar.StatusBarManagerInternal;
import com.android.server.utils.PriorityDump;
import com.android.server.wm.WindowManagerInternal;

import lineageos.hardware.LineageHardwareManager;
import lineageos.providers.LineageSettings;

import java.io.FileDescriptor;
import java.io.IOException;
import java.io.PrintWriter;
@@ -406,6 +409,8 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl.
    @MultiUserUnawareField
    Future<?> mImeDrawsImeNavBarResLazyInitFuture;

    private LineageHardwareManager mLineageHardware;

    private final ImeTracing.ServiceDumper mDumper = new ImeTracing.ServiceDumper() {
        /**
         * {@inheritDoc}
@@ -752,6 +757,16 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl.
                    Settings.Secure.ACCESSIBILITY_SOFT_KEYBOARD_MODE), false, this, userId);
            resolver.registerContentObserver(Settings.Secure.getUriFor(
                    STYLUS_HANDWRITING_ENABLED), false, this);
            if (mLineageHardware.isSupported(
                    LineageHardwareManager.FEATURE_HIGH_TOUCH_SENSITIVITY)) {
                resolver.registerContentObserver(LineageSettings.System.getUriFor(
                        LineageSettings.System.HIGH_TOUCH_SENSITIVITY_ENABLE),
                        false, this, userId);
            }
            if (mLineageHardware.isSupported(LineageHardwareManager.FEATURE_TOUCH_HOVERING)) {
                resolver.registerContentObserver(LineageSettings.Secure.getUriFor(
                        LineageSettings.Secure.FEATURE_TOUCH_HOVERING), false, this, userId);
            }
            mRegistered = true;
        }

@@ -763,6 +778,10 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl.
                    Settings.Secure.ACCESSIBILITY_SOFT_KEYBOARD_MODE);
            final Uri stylusHandwritingEnabledUri = Settings.Secure.getUriFor(
                    STYLUS_HANDWRITING_ENABLED);
            final Uri touchSensitivityUri = LineageSettings.System.getUriFor(
                    LineageSettings.System.HIGH_TOUCH_SENSITIVITY_ENABLE);
            final Uri touchHoveringUri = LineageSettings.Secure.getUriFor(
                    LineageSettings.Secure.FEATURE_TOUCH_HOVERING);
            synchronized (ImfLock.class) {
                if (showImeUri.equals(uri)) {
                    mMenuController.updateKeyboardFromSettingsLocked();
@@ -784,6 +803,10 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl.
                    InputMethodManager.invalidateLocalStylusHandwritingAvailabilityCaches();
                    InputMethodManager
                            .invalidateLocalConnectionlessStylusHandwritingAvailabilityCaches();
                } else if (touchSensitivityUri.equals(uri)) {
                    updateTouchSensitivity();
                } else if (touchHoveringUri.equals(uri)) {
                    updateTouchHovering();
                } else {
                    boolean enabledChanged = false;
                    String newEnabled = InputMethodSettingsRepository.get(mCurrentUserId)
@@ -1479,6 +1502,9 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl.
                    newSettings.getEnabledInputMethodList());
        }

        updateTouchSensitivity();
        updateTouchHovering();

        if (DEBUG) {
            Slog.d(TAG, "Switching user stage 3/3. newUserId=" + newUserId
                    + " selectedIme=" + newSettings.getSelectedInputMethod());
@@ -1505,6 +1531,13 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl.
            if (!mSystemReady) {
                mSystemReady = true;
                final int currentUserId = mCurrentUserId;

                // Must happen before registerContentObserverLocked
                mLineageHardware = LineageHardwareManager.getInstance(mContext);

                updateTouchSensitivity();
                updateTouchHovering();

                mStatusBarManagerInternal =
                        LocalServices.getService(StatusBarManagerInternal.class);
                hideStatusBarIconLocked();
@@ -3062,6 +3095,24 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl.
        sendOnNavButtonFlagsChangedLocked();
    }

    private void updateTouchSensitivity() {
        if (!mLineageHardware.isSupported(LineageHardwareManager.FEATURE_HIGH_TOUCH_SENSITIVITY)) {
            return;
        }
        final boolean enabled = LineageSettings.System.getInt(mContext.getContentResolver(),
                LineageSettings.System.HIGH_TOUCH_SENSITIVITY_ENABLE, 0) == 1;
        mLineageHardware.set(LineageHardwareManager.FEATURE_HIGH_TOUCH_SENSITIVITY, enabled);
    }

    private void updateTouchHovering() {
        if (!mLineageHardware.isSupported(LineageHardwareManager.FEATURE_TOUCH_HOVERING)) {
            return;
        }
        final boolean enabled = LineageSettings.Secure.getInt(mContext.getContentResolver(),
                LineageSettings.Secure.FEATURE_TOUCH_HOVERING, 0) == 1;
        mLineageHardware.set(LineageHardwareManager.FEATURE_TOUCH_HOVERING, enabled);
    }

    @GuardedBy("ImfLock.class")
    private void notifyInputMethodSubtypeChangedLocked(@UserIdInt int userId,
            @NonNull InputMethodInfo imi, @Nullable InputMethodSubtype subtype) {