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

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

Add high touch sensitivity and hovering to InputService

Doing so allows us to keep track of user changes and restore
preferences.

This commit is squash of the following commits from CM 13.0:
7348be74 Move high touch sensitivity and hovering to InputService
f9a9d504 InputMethodManager : Move registration to systemReady

Since lineage-17.1 services/core/java/com/android/server/InputMethodManagerService.java is moved to
services/core/java/com/android/server/inputmethod/InputMethodManagerService.java

Change-Id: I5a6af73129acefa6530ceb3f73cc4cd83a19a676
Ticket-Id: CYNGNOS-1166
parent 3c2dec69
Loading
Loading
Loading
Loading
+51 −0
Original line number Diff line number Diff line
@@ -189,6 +189,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;
@@ -351,6 +354,8 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub
    @Nullable
    Future<?> mImeDrawsImeNavBarResLazyInitFuture;

    private LineageHardwareManager mLineageHardware;

    static class SessionState {
        final ClientState mClient;
        final IInputMethodInvoker mMethod;
@@ -1177,6 +1182,16 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub
                    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;
        }

@@ -1187,6 +1202,10 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub
                    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();
@@ -1206,6 +1225,10 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub
                    }
                } else if (stylusHandwritingEnabledUri.equals(uri)) {
                    InputMethodManager.invalidateLocalStylusHandwritingAvailabilityCaches();
                } else if (touchSensitivityUri.equals(uri)) {
                    updateTouchSensitivity();
                } else if (touchHoveringUri.equals(uri)) {
                    updateTouchHovering();
                } else {
                    boolean enabledChanged = false;
                    String newEnabled = mSettings.getEnabledInputMethodsStr();
@@ -1889,6 +1912,9 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub
                    mSettings.getEnabledInputMethodListLocked());
        }

        updateTouchSensitivity();
        updateTouchHovering();

        if (DEBUG) {
            Slog.d(TAG, "Switching user stage 3/3. newUserId=" + newUserId
                    + " selectedIme=" + mSettings.getSelectedInputMethod());
@@ -1941,6 +1967,13 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub
                final int currentUserId = mSettings.getCurrentUserId();
                mSettings.switchCurrentUser(currentUserId,
                        !mUserManagerInternal.isUserUnlockingOrUnlocked(currentUserId));

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

                updateTouchSensitivity();
                updateTouchHovering();

                mStatusBarManagerInternal =
                        LocalServices.getService(StatusBarManagerInternal.class);
                hideStatusBarIconLocked();
@@ -3330,6 +3363,24 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub
        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) {