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

Unverified Commit fb3b6c52 authored by Danesh M's avatar Danesh M Committed by Michael Bestas
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

Change-Id: I5a6af73129acefa6530ceb3f73cc4cd83a19a676
Ticket-Id: CYNGNOS-1166
parent 0eb9e705
Loading
Loading
Loading
Loading
+50 −5
Original line number Diff line number Diff line
@@ -145,6 +145,7 @@ import java.util.Collections;
import java.util.HashMap;
import java.util.List;

import cyanogenmod.hardware.CMHardwareManager;
import cyanogenmod.providers.CMSettings;

/**
@@ -240,6 +241,8 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
    private boolean mNotificationShown;
    private final boolean mImeSelectedOnBoot;

    private CMHardwareManager mCMHardware;

    static class SessionState {
        final ClientState client;
        final IInputMethod method;
@@ -525,6 +528,14 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
                            updateFromSettingsLocked(true);
                        }
                    }, userId);
            if (mCMHardware.isSupported(CMHardwareManager.FEATURE_HIGH_TOUCH_SENSITIVITY)) {
                resolver.registerContentObserver(CMSettings.System.getUriFor(
                        CMSettings.System.HIGH_TOUCH_SENSITIVITY_ENABLE), false, this, userId);
            }
            if (mCMHardware.isSupported(CMHardwareManager.FEATURE_TOUCH_HOVERING)) {
                resolver.registerContentObserver(CMSettings.Secure.getUriFor(
                        CMSettings.Secure.FEATURE_TOUCH_HOVERING), false, this, userId);
            }

            mRegistered = true;
        }
@@ -534,6 +545,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 =
                    CMSettings.System.getUriFor(CMSettings.System.HIGH_TOUCH_SENSITIVITY_ENABLE);
            final Uri touchHoveringUri =
                    CMSettings.Secure.getUriFor(CMSettings.Secure.FEATURE_TOUCH_HOVERING);
            synchronized (mMethodMap) {
                if (showImeUri.equals(uri)) {
                    updateKeyboardFromSettingsLocked();
@@ -549,6 +564,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();
@@ -945,11 +964,6 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
            }
        }

        synchronized (mMethodMap) {
            mSettingsObserver.registerContentObserverLocked(userId);
            updateFromSettingsLocked(true);
        }

        // IMMS wants to receive Intent.ACTION_LOCALE_CHANGED in order to update the current IME
        // according to the new system locale.
        final IntentFilter filter = new IntentFilter();
@@ -1060,6 +1074,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());
    }
@@ -1094,6 +1111,16 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
                final int currentUserId = mSettings.getCurrentUserId();
                mSettings.switchCurrentUser(currentUserId,
                        !mUserManager.isUserUnlockingOrUnlocked(currentUserId));

                // Must happen before registerContentObserverLocked
                mCMHardware = CMHardwareManager.getInstance(mContext);

                mSettingsObserver.registerContentObserverLocked(currentUserId);
                updateFromSettingsLocked(true);

                updateTouchHovering();
                updateTouchSensitivity();

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

    }

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

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

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