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

Unverified Commit 8c63f719 authored by Danesh M's avatar Danesh M Committed by Arian
Browse files

Move 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 62115695
Loading
Loading
Loading
Loading
+51 −0
Original line number Diff line number Diff line
@@ -156,6 +156,9 @@ import com.android.server.inputmethod.InputMethodUtils.InputMethodSettings;
import com.android.server.statusbar.StatusBarManagerService;
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;
@@ -357,6 +360,8 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
    private boolean mShowOngoingImeSwitcherForPhones;
    private boolean mNotificationShown;

    private LineageHardwareManager mLineageHardware;

    static class SessionState {
        final ClientState client;
        final IInputMethod method;
@@ -955,6 +960,16 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
                    Settings.Secure.SHOW_IME_WITH_HARD_KEYBOARD), false, this, userId);
            resolver.registerContentObserver(Settings.Secure.getUriFor(
                    Settings.Secure.ACCESSIBILITY_SOFT_KEYBOARD_MODE), false, this, userId);
            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;
        }

@@ -963,6 +978,10 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
                    Settings.Secure.SHOW_IME_WITH_HARD_KEYBOARD);
            final Uri accessibilityRequestingNoImeUri = Settings.Secure.getUriFor(
                    Settings.Secure.ACCESSIBILITY_SOFT_KEYBOARD_MODE);
            final Uri touchSensitivityUri = LineageSettings.System.getUriFor(
                    LineageSettings.System.HIGH_TOUCH_SENSITIVITY_ENABLE);
            final Uri touchHoveringUri = LineageSettings.Secure.getUriFor(
                    LineageSettings.Secure.FEATURE_TOUCH_HOVERING);
            synchronized (mMethodMap) {
                if (showImeUri.equals(uri)) {
                    updateKeyboardFromSettingsLocked();
@@ -980,6 +999,10 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
                    } else if (mShowRequested) {
                        showCurrentInputLocked(InputMethodManager.SHOW_IMPLICIT, null);
                    }
                } else if (touchSensitivityUri.equals(uri)) {
                    updateTouchSensitivity();
                } else if (touchHoveringUri.equals(uri)) {
                    updateTouchHovering();
                } else {
                    boolean enabledChanged = false;
                    String newEnabled = mSettings.getEnabledInputMethodsStr();
@@ -1574,6 +1597,9 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
                    mContext.getBasePackageName());
        }

        updateTouchHovering();
        updateTouchSensitivity();

        if (DEBUG) Slog.d(TAG, "Switching user stage 3/3. newUserId=" + newUserId
                + " selectedIme=" + mSettings.getSelectedInputMethod());

@@ -1611,6 +1637,13 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
                final int currentUserId = mSettings.getCurrentUserId();
                mSettings.switchCurrentUser(currentUserId,
                        !mUserManagerInternal.isUserUnlockingOrUnlocked(currentUserId));

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

                updateTouchHovering();
                updateTouchSensitivity();

                mKeyguardManager = mContext.getSystemService(KeyguardManager.class);
                mNotificationManager = mContext.getSystemService(NotificationManager.class);
                mStatusBar = statusBar;
@@ -2670,6 +2703,24 @@ public class InputMethodManagerService extends IInputMethodManager.Stub

    }

    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);
    }

    public void updateKeyboardFromSettingsLocked() {
        mShowImeWithHardKeyboard = mSettings.isShowImeWithHardKeyboardEnabled();
        if (mSwitchingDialog != null