From ebca8bfedb1aa181b7830fa12540c3d7b362d73b Mon Sep 17 00:00:00 2001 From: Danesh M <daneshm90@gmail.com> Date: Wed, 9 Mar 2016 11:48:43 -0800 Subject: [PATCH] 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: 7348be747940afe7c3ec6a2b133b5473bc18573a Move high touch sensitivity and hovering to InputService f9a9d50491dc583ea568a4f12e57a2f97b9baacb 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 --- core/java/android/provider/Settings.java | 14 ++++++ .../InputMethodManagerService.java | 50 +++++++++++++++++++ 2 files changed, 64 insertions(+) diff --git a/core/java/android/provider/Settings.java b/core/java/android/provider/Settings.java index 068173acbc37..d14cee87e3af 100644 --- a/core/java/android/provider/Settings.java +++ b/core/java/android/provider/Settings.java @@ -5264,6 +5264,14 @@ public final class Settings { */ public static final String TOUCHSCREEN_GESTURE_HAPTIC_FEEDBACK = "touchscreen_gesture_haptic_feedback"; + /** + * Whether the HighTouchSensitivity is activated or not. + * 0 = off, 1 = on + * @hide + */ + public static final String HIGH_TOUCH_SENSITIVITY_ENABLE = + "high_touch_sensitivity_enable"; + /** * IMPORTANT: If you add a new public settings you also have to add it to * PUBLIC_SETTINGS below. If the new setting is hidden you have to add @@ -10370,6 +10378,12 @@ public final class Settings { */ public static final String SWAP_CAPACITIVE_KEYS = "swap_capacitive_keys"; + /** + * Whether touch hovering is enabled on supported hardware + * @hide + */ + public static final String FEATURE_TOUCH_HOVERING = "feature_touch_hovering"; + /** * These entries are considered common between the personal and the managed profile, * since the managed profile doesn't get to change them. diff --git a/services/core/java/com/android/server/inputmethod/InputMethodManagerService.java b/services/core/java/com/android/server/inputmethod/InputMethodManagerService.java index 1516739de99f..7d18a5681c4d 100644 --- a/services/core/java/com/android/server/inputmethod/InputMethodManagerService.java +++ b/services/core/java/com/android/server/inputmethod/InputMethodManagerService.java @@ -192,6 +192,8 @@ import com.android.server.statusbar.StatusBarManagerService; import com.android.server.utils.PriorityDump; import com.android.server.wm.WindowManagerInternal; +import com.android.internal.libremobileos.hardware.LineageHardwareManager; + import java.io.FileDescriptor; import java.io.IOException; import java.io.PrintWriter; @@ -365,6 +367,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; @@ -1066,6 +1070,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(Settings.System.getUriFor( + Settings.System.HIGH_TOUCH_SENSITIVITY_ENABLE), + false, this, userId); + } + if (mLineageHardware.isSupported(LineageHardwareManager.FEATURE_TOUCH_HOVERING)) { + resolver.registerContentObserver(Settings.Secure.getUriFor( + Settings.Secure.FEATURE_TOUCH_HOVERING), false, this, userId); + } mRegistered = true; } @@ -1074,6 +1088,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 = Settings.System.getUriFor( + Settings.System.HIGH_TOUCH_SENSITIVITY_ENABLE); + final Uri touchHoveringUri = Settings.Secure.getUriFor( + Settings.Secure.FEATURE_TOUCH_HOVERING); synchronized (mMethodMap) { if (showImeUri.equals(uri)) { mMenuController.updateKeyboardFromSettingsLocked(); @@ -1094,6 +1112,10 @@ public class InputMethodManagerService extends IInputMethodManager.Stub InputMethodManager.SHOW_IMPLICIT, null, SoftInputShowHideReason.SHOW_SETTINGS_ON_CHANGE); } + } else if (touchSensitivityUri.equals(uri)) { + updateTouchSensitivity(); + } else if (touchHoveringUri.equals(uri)) { + updateTouchHovering(); } else { boolean enabledChanged = false; String newEnabled = mSettings.getEnabledInputMethodsStr(); @@ -1721,6 +1743,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()); @@ -1770,6 +1795,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; @@ -2979,6 +3011,24 @@ public class InputMethodManagerService extends IInputMethodManager.Stub } + private void updateTouchSensitivity() { + if (!mLineageHardware.isSupported(LineageHardwareManager.FEATURE_HIGH_TOUCH_SENSITIVITY)) { + return; + } + final boolean enabled = Settings.System.getInt(mContext.getContentResolver(), + Settings.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 = Settings.Secure.getInt(mContext.getContentResolver(), + Settings.Secure.FEATURE_TOUCH_HOVERING, 0) == 1; + mLineageHardware.set(LineageHardwareManager.FEATURE_TOUCH_HOVERING, enabled); + } + /* package */ void setInputMethodLocked(String id, int subtypeId) { InputMethodInfo info = mMethodMap.get(id); if (info == null) { -- GitLab