Loading core/java/android/view/ViewConfiguration.java +2 −1 Original line number Diff line number Diff line Loading @@ -64,8 +64,9 @@ public class ViewConfiguration { /** * Defines the default duration in milliseconds before a press turns into * a long press * @hide */ private static final int DEFAULT_LONG_PRESS_TIMEOUT = 500; public static final int DEFAULT_LONG_PRESS_TIMEOUT = 400; /** * Defines the default duration in milliseconds between the first tap's up event and the second Loading services/core/java/com/android/server/input/InputManagerService.java +39 −3 Original line number Diff line number Diff line Loading @@ -59,6 +59,7 @@ import android.os.MessageQueue; import android.os.Process; import android.os.RemoteException; import android.os.UserHandle; import android.provider.DeviceConfig; import android.provider.Settings; import android.provider.Settings.SettingNotFoundException; import android.text.TextUtils; Loading Loading @@ -126,6 +127,9 @@ public class InputManagerService extends IInputManager.Stub private static final String EXCLUDED_DEVICES_PATH = "etc/excluded-input-devices.xml"; private static final String PORT_ASSOCIATIONS_PATH = "etc/input-port-associations.xml"; // Feature flag name for the deep press feature private static final String DEEP_PRESS_ENABLED = "deep_press_enabled"; private static final int MSG_DELIVER_INPUT_DEVICES_CHANGED = 1; private static final int MSG_SWITCH_KEYBOARD_LAYOUT = 2; private static final int MSG_RELOAD_KEYBOARD_LAYOUTS = 3; Loading Loading @@ -241,6 +245,7 @@ public class InputManagerService extends IInputManager.Stub private static native void nativeSetCustomPointerIcon(long ptr, PointerIcon icon); private static native void nativeSetPointerCapture(long ptr, boolean detached); private static native boolean nativeCanDispatchToDisplay(long ptr, int deviceId, int displayId); private static native void nativeSetMotionClassifierEnabled(long ptr, boolean enabled); // Input event injection constants defined in InputDispatcher.h. private static final int INPUT_EVENT_INJECTION_SUCCEEDED = 0; Loading Loading @@ -346,6 +351,7 @@ public class InputManagerService extends IInputManager.Stub registerPointerSpeedSettingObserver(); registerShowTouchesSettingObserver(); registerAccessibilityLargePointerSettingObserver(); registerLongPressTimeoutObserver(); mContext.registerReceiver(new BroadcastReceiver() { @Override Loading @@ -353,12 +359,14 @@ public class InputManagerService extends IInputManager.Stub updatePointerSpeedFromSettings(); updateShowTouchesFromSettings(); updateAccessibilityLargePointerFromSettings(); updateDeepPressStatusFromSettings("user switched"); } }, new IntentFilter(Intent.ACTION_USER_SWITCHED), null, mHandler); updatePointerSpeedFromSettings(); updateShowTouchesFromSettings(); updateAccessibilityLargePointerFromSettings(); updateDeepPressStatusFromSettings("just booted"); } // TODO(BT) Pass in parameter for bluetooth system Loading Loading @@ -1572,7 +1580,7 @@ public class InputManagerService extends IInputManager.Stub setPointerSpeedUnchecked(speed); } public void updatePointerSpeedFromSettings() { private void updatePointerSpeedFromSettings() { int speed = getPointerSpeedSetting(); setPointerSpeedUnchecked(speed); } Loading Loading @@ -1604,7 +1612,7 @@ public class InputManagerService extends IInputManager.Stub return speed; } public void updateShowTouchesFromSettings() { private void updateShowTouchesFromSettings() { int setting = getShowTouchesSetting(0); nativeSetShowTouches(mPtr, setting != 0); } Loading @@ -1620,7 +1628,7 @@ public class InputManagerService extends IInputManager.Stub }, UserHandle.USER_ALL); } public void updateAccessibilityLargePointerFromSettings() { private void updateAccessibilityLargePointerFromSettings() { final int accessibilityConfig = Settings.Secure.getIntForUser( mContext.getContentResolver(), Settings.Secure.ACCESSIBILITY_LARGE_POINTER_ICON, 0, UserHandle.USER_CURRENT); Loading @@ -1639,6 +1647,34 @@ public class InputManagerService extends IInputManager.Stub }, UserHandle.USER_ALL); } private void updateDeepPressStatusFromSettings(String reason) { // Not using ViewConfiguration.getLongPressTimeout here because it may return a stale value final int timeout = Settings.Secure.getIntForUser(mContext.getContentResolver(), Settings.Secure.LONG_PRESS_TIMEOUT, ViewConfiguration.DEFAULT_LONG_PRESS_TIMEOUT, UserHandle.USER_CURRENT); final boolean featureEnabledFlag = DeviceConfig.getBoolean(DeviceConfig.NAMESPACE_INPUT_NATIVE_BOOT, DEEP_PRESS_ENABLED, true /* default */); final boolean enabled = featureEnabledFlag && timeout <= ViewConfiguration.DEFAULT_LONG_PRESS_TIMEOUT; Log.i(TAG, (enabled ? "Enabling" : "Disabling") + " motion classifier because " + reason + ": feature " + (featureEnabledFlag ? "enabled" : "disabled") + ", long press timeout = " + timeout); nativeSetMotionClassifierEnabled(mPtr, enabled); } private void registerLongPressTimeoutObserver() { mContext.getContentResolver().registerContentObserver( Settings.Secure.getUriFor(Settings.Secure.LONG_PRESS_TIMEOUT), true, new ContentObserver(mHandler) { @Override public void onChange(boolean selfChange) { updateDeepPressStatusFromSettings("timeout changed"); } }, UserHandle.USER_ALL); } private int getShowTouchesSetting(int defaultValue) { int result = defaultValue; try { Loading services/core/jni/com_android_server_input_InputManagerService.cpp +15 −0 Original line number Diff line number Diff line Loading @@ -227,6 +227,7 @@ public: void reloadPointerIcons(); void setCustomPointerIcon(const SpriteIcon& icon); void setPointerCapture(bool enabled); void setMotionClassifierEnabled(bool enabled); /* --- InputReaderPolicyInterface implementation --- */ Loading Loading @@ -1312,6 +1313,10 @@ int32_t NativeInputManager::getCustomPointerIconId() { return POINTER_ICON_STYLE_CUSTOM; } void NativeInputManager::setMotionClassifierEnabled(bool enabled) { mInputManager->setMotionClassifierEnabled(enabled); } // ---------------------------------------------------------------------------- static jlong nativeInit(JNIEnv* env, jclass /* clazz */, Loading Loading @@ -1744,6 +1749,14 @@ static jboolean nativeCanDispatchToDisplay(JNIEnv* env, jclass /* clazz */, jlon return im->getInputManager()->getReader()->canDispatchToDisplay(deviceId, displayId); } static void nativeSetMotionClassifierEnabled(JNIEnv* /* env */, jclass /* clazz */, jlong ptr, jboolean enabled) { NativeInputManager* im = reinterpret_cast<NativeInputManager*>(ptr); im->setMotionClassifierEnabled(enabled); } // ---------------------------------------------------------------------------- static const JNINativeMethod gInputManagerMethods[] = { Loading Loading @@ -1827,6 +1840,8 @@ static const JNINativeMethod gInputManagerMethods[] = { (void*) nativeSetCustomPointerIcon }, { "nativeCanDispatchToDisplay", "(JII)Z", (void*) nativeCanDispatchToDisplay }, {"nativeSetMotionClassifierEnabled", "(JZ)V", (void*) nativeSetMotionClassifierEnabled}, }; #define FIND_CLASS(var, className) \ Loading Loading
core/java/android/view/ViewConfiguration.java +2 −1 Original line number Diff line number Diff line Loading @@ -64,8 +64,9 @@ public class ViewConfiguration { /** * Defines the default duration in milliseconds before a press turns into * a long press * @hide */ private static final int DEFAULT_LONG_PRESS_TIMEOUT = 500; public static final int DEFAULT_LONG_PRESS_TIMEOUT = 400; /** * Defines the default duration in milliseconds between the first tap's up event and the second Loading
services/core/java/com/android/server/input/InputManagerService.java +39 −3 Original line number Diff line number Diff line Loading @@ -59,6 +59,7 @@ import android.os.MessageQueue; import android.os.Process; import android.os.RemoteException; import android.os.UserHandle; import android.provider.DeviceConfig; import android.provider.Settings; import android.provider.Settings.SettingNotFoundException; import android.text.TextUtils; Loading Loading @@ -126,6 +127,9 @@ public class InputManagerService extends IInputManager.Stub private static final String EXCLUDED_DEVICES_PATH = "etc/excluded-input-devices.xml"; private static final String PORT_ASSOCIATIONS_PATH = "etc/input-port-associations.xml"; // Feature flag name for the deep press feature private static final String DEEP_PRESS_ENABLED = "deep_press_enabled"; private static final int MSG_DELIVER_INPUT_DEVICES_CHANGED = 1; private static final int MSG_SWITCH_KEYBOARD_LAYOUT = 2; private static final int MSG_RELOAD_KEYBOARD_LAYOUTS = 3; Loading Loading @@ -241,6 +245,7 @@ public class InputManagerService extends IInputManager.Stub private static native void nativeSetCustomPointerIcon(long ptr, PointerIcon icon); private static native void nativeSetPointerCapture(long ptr, boolean detached); private static native boolean nativeCanDispatchToDisplay(long ptr, int deviceId, int displayId); private static native void nativeSetMotionClassifierEnabled(long ptr, boolean enabled); // Input event injection constants defined in InputDispatcher.h. private static final int INPUT_EVENT_INJECTION_SUCCEEDED = 0; Loading Loading @@ -346,6 +351,7 @@ public class InputManagerService extends IInputManager.Stub registerPointerSpeedSettingObserver(); registerShowTouchesSettingObserver(); registerAccessibilityLargePointerSettingObserver(); registerLongPressTimeoutObserver(); mContext.registerReceiver(new BroadcastReceiver() { @Override Loading @@ -353,12 +359,14 @@ public class InputManagerService extends IInputManager.Stub updatePointerSpeedFromSettings(); updateShowTouchesFromSettings(); updateAccessibilityLargePointerFromSettings(); updateDeepPressStatusFromSettings("user switched"); } }, new IntentFilter(Intent.ACTION_USER_SWITCHED), null, mHandler); updatePointerSpeedFromSettings(); updateShowTouchesFromSettings(); updateAccessibilityLargePointerFromSettings(); updateDeepPressStatusFromSettings("just booted"); } // TODO(BT) Pass in parameter for bluetooth system Loading Loading @@ -1572,7 +1580,7 @@ public class InputManagerService extends IInputManager.Stub setPointerSpeedUnchecked(speed); } public void updatePointerSpeedFromSettings() { private void updatePointerSpeedFromSettings() { int speed = getPointerSpeedSetting(); setPointerSpeedUnchecked(speed); } Loading Loading @@ -1604,7 +1612,7 @@ public class InputManagerService extends IInputManager.Stub return speed; } public void updateShowTouchesFromSettings() { private void updateShowTouchesFromSettings() { int setting = getShowTouchesSetting(0); nativeSetShowTouches(mPtr, setting != 0); } Loading @@ -1620,7 +1628,7 @@ public class InputManagerService extends IInputManager.Stub }, UserHandle.USER_ALL); } public void updateAccessibilityLargePointerFromSettings() { private void updateAccessibilityLargePointerFromSettings() { final int accessibilityConfig = Settings.Secure.getIntForUser( mContext.getContentResolver(), Settings.Secure.ACCESSIBILITY_LARGE_POINTER_ICON, 0, UserHandle.USER_CURRENT); Loading @@ -1639,6 +1647,34 @@ public class InputManagerService extends IInputManager.Stub }, UserHandle.USER_ALL); } private void updateDeepPressStatusFromSettings(String reason) { // Not using ViewConfiguration.getLongPressTimeout here because it may return a stale value final int timeout = Settings.Secure.getIntForUser(mContext.getContentResolver(), Settings.Secure.LONG_PRESS_TIMEOUT, ViewConfiguration.DEFAULT_LONG_PRESS_TIMEOUT, UserHandle.USER_CURRENT); final boolean featureEnabledFlag = DeviceConfig.getBoolean(DeviceConfig.NAMESPACE_INPUT_NATIVE_BOOT, DEEP_PRESS_ENABLED, true /* default */); final boolean enabled = featureEnabledFlag && timeout <= ViewConfiguration.DEFAULT_LONG_PRESS_TIMEOUT; Log.i(TAG, (enabled ? "Enabling" : "Disabling") + " motion classifier because " + reason + ": feature " + (featureEnabledFlag ? "enabled" : "disabled") + ", long press timeout = " + timeout); nativeSetMotionClassifierEnabled(mPtr, enabled); } private void registerLongPressTimeoutObserver() { mContext.getContentResolver().registerContentObserver( Settings.Secure.getUriFor(Settings.Secure.LONG_PRESS_TIMEOUT), true, new ContentObserver(mHandler) { @Override public void onChange(boolean selfChange) { updateDeepPressStatusFromSettings("timeout changed"); } }, UserHandle.USER_ALL); } private int getShowTouchesSetting(int defaultValue) { int result = defaultValue; try { Loading
services/core/jni/com_android_server_input_InputManagerService.cpp +15 −0 Original line number Diff line number Diff line Loading @@ -227,6 +227,7 @@ public: void reloadPointerIcons(); void setCustomPointerIcon(const SpriteIcon& icon); void setPointerCapture(bool enabled); void setMotionClassifierEnabled(bool enabled); /* --- InputReaderPolicyInterface implementation --- */ Loading Loading @@ -1312,6 +1313,10 @@ int32_t NativeInputManager::getCustomPointerIconId() { return POINTER_ICON_STYLE_CUSTOM; } void NativeInputManager::setMotionClassifierEnabled(bool enabled) { mInputManager->setMotionClassifierEnabled(enabled); } // ---------------------------------------------------------------------------- static jlong nativeInit(JNIEnv* env, jclass /* clazz */, Loading Loading @@ -1744,6 +1749,14 @@ static jboolean nativeCanDispatchToDisplay(JNIEnv* env, jclass /* clazz */, jlon return im->getInputManager()->getReader()->canDispatchToDisplay(deviceId, displayId); } static void nativeSetMotionClassifierEnabled(JNIEnv* /* env */, jclass /* clazz */, jlong ptr, jboolean enabled) { NativeInputManager* im = reinterpret_cast<NativeInputManager*>(ptr); im->setMotionClassifierEnabled(enabled); } // ---------------------------------------------------------------------------- static const JNINativeMethod gInputManagerMethods[] = { Loading Loading @@ -1827,6 +1840,8 @@ static const JNINativeMethod gInputManagerMethods[] = { (void*) nativeSetCustomPointerIcon }, { "nativeCanDispatchToDisplay", "(JII)Z", (void*) nativeCanDispatchToDisplay }, {"nativeSetMotionClassifierEnabled", "(JZ)V", (void*) nativeSetMotionClassifierEnabled}, }; #define FIND_CLASS(var, className) \ Loading