From 7348be747940afe7c3ec6a2b133b5473bc18573a Mon Sep 17 00:00:00 2001 From: Danesh M Date: Wed, 9 Mar 2016 11:48:43 -0800 Subject: [PATCH] Move high touch sensitivity and hovering to InputService Doing so allows us to keep track of user changes and restore preferences. CYNGNOS-1166 Change-Id: I5a6af73129acefa6530ceb3f73cc4cd83a19a676 --- .../server/InputMethodManagerService.java | 48 +++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/services/core/java/com/android/server/InputMethodManagerService.java b/services/core/java/com/android/server/InputMethodManagerService.java index 6e7a7500dcd9..92407bd38c7b 100644 --- a/services/core/java/com/android/server/InputMethodManagerService.java +++ b/services/core/java/com/android/server/InputMethodManagerService.java @@ -143,6 +143,7 @@ import java.util.List; import java.util.Locale; +import cyanogenmod.hardware.CMHardwareManager; import cyanogenmod.providers.CMSettings; import org.cyanogenmod.internal.util.QSUtils; @@ -239,6 +240,7 @@ public void onQSChanged() { private boolean mShowOngoingImeSwitcherForPhones; private boolean mNotificationShown; private final boolean mImeSelectedOnBoot; + private CMHardwareManager mCMHardware; static class SessionState { final ClientState client; @@ -506,15 +508,32 @@ public void onChange(boolean selfChange) { } }, 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; } @Override public void onChange(boolean selfChange, Uri uri) { final Uri showImeUri = Settings.Secure.getUriFor(Settings.Secure.SHOW_IME_WITH_HARD_KEYBOARD); + 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(); + } else if (touchSensitivityUri.equals(uri)) { + updateTouchSensitivity(); + } else if (touchHoveringUri.equals(uri)) { + updateTouchHovering(); } else { boolean enabledChanged = false; String newEnabled = mSettings.getEnabledInputMethodsStr(); @@ -943,11 +962,17 @@ public String[] getPackages(int userId) { } } + // Must happen before registerContentObserverLocked + mCMHardware = CMHardwareManager.getInstance(mContext); + synchronized (mMethodMap) { mSettingsObserver.registerContentObserverLocked(userId); updateFromSettingsLocked(true); } + updateTouchHovering(); + updateTouchSensitivity(); + // 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(); @@ -1072,6 +1097,9 @@ private void switchUserLocked(int newUserId) { mContext.getBasePackageName()); } + updateTouchHovering(); + updateTouchSensitivity(); + if (DEBUG) Slog.d(TAG, "Switching user stage 3/3. newUserId=" + newUserId + " selectedIme=" + mSettings.getSelectedInputMethod()); } @@ -1970,6 +1998,26 @@ void updateInputMethodsFromSettingsLocked(boolean enabledMayChange) { } + private void updateTouchSensitivity() { + if (!mCMHardware.isSupported(CMHardwareManager.FEATURE_HIGH_TOUCH_SENSITIVITY)) { + return; + } + boolean touchSensitivityEnable = CMSettings.System.getInt(mContext.getContentResolver(), + CMSettings.System.HIGH_TOUCH_SENSITIVITY_ENABLE, 0) == 1; + mCMHardware.set(CMHardwareManager.FEATURE_HIGH_TOUCH_SENSITIVITY, + touchSensitivityEnable); + } + + private void updateTouchHovering() { + if (!mCMHardware.isSupported(CMHardwareManager.FEATURE_TOUCH_HOVERING)) { + return; + } + boolean touchHovering = CMSettings.Secure.getInt(mContext.getContentResolver(), + CMSettings.Secure.FEATURE_TOUCH_HOVERING, 0) == 1; + mCMHardware.set(CMHardwareManager.FEATURE_TOUCH_HOVERING, + touchHovering); + } + public void updateKeyboardFromSettingsLocked() { mShowImeWithHardKeyboard = mSettings.isShowImeWithHardKeyboardEnabled(); if (mSwitchingDialog != null