summaryrefslogtreecommitdiffstats
path: root/services
diff options
context:
space:
mode:
authorJeff Brown <jeffbrown@google.com>2010-09-21 18:22:55 -0700
committerJeff Brown <jeffbrown@google.com>2010-09-21 18:22:55 -0700
commit57c59376f4432bdb285acb242bd9b3bec81f6bca (patch)
treeea68bafcc2b79df9129ff83e2225efc808e8c6bb /services
parenta6dc4699222a484222d1c54d5319f302a02e406b (diff)
downloadframeworks_base-57c59376f4432bdb285acb242bd9b3bec81f6bca.zip
frameworks_base-57c59376f4432bdb285acb242bd9b3bec81f6bca.tar.gz
frameworks_base-57c59376f4432bdb285acb242bd9b3bec81f6bca.tar.bz2
Fix race reading input configuration during system startup.
Change-Id: I9360c4ec5c29937fce06b44ffc71fca58c8b3d5f
Diffstat (limited to 'services')
-rw-r--r--services/java/com/android/server/InputManager.java20
-rw-r--r--services/jni/com_android_server_InputManager.cpp45
2 files changed, 42 insertions, 23 deletions
diff --git a/services/java/com/android/server/InputManager.java b/services/java/com/android/server/InputManager.java
index 024aec5..29ca9a4 100644
--- a/services/java/com/android/server/InputManager.java
+++ b/services/java/com/android/server/InputManager.java
@@ -53,10 +53,6 @@ public class InputManager {
private final Context mContext;
private final WindowManagerService mWindowManagerService;
- private int mTouchScreenConfig;
- private int mKeyboardConfig;
- private int mNavigationConfig;
-
private static native void nativeInit(Callbacks callbacks);
private static native void nativeStart();
private static native void nativeSetDisplaySize(int displayId, int width, int height);
@@ -79,6 +75,7 @@ public class InputManager {
private static native void nativeSetInputDispatchMode(boolean enabled, boolean frozen);
private static native void nativeSetFocusedApplication(InputApplication application);
private static native InputDevice nativeGetInputDevice(int deviceId);
+ private static native void nativeGetInputConfiguration(Configuration configuration);
private static native int[] nativeGetInputDeviceIds();
private static native String nativeDump();
@@ -114,10 +111,6 @@ public class InputManager {
this.mCallbacks = new Callbacks();
- mTouchScreenConfig = Configuration.TOUCHSCREEN_NOTOUCH;
- mKeyboardConfig = Configuration.KEYBOARD_NOKEYS;
- mNavigationConfig = Configuration.NAVIGATION_NONAV;
-
init();
}
@@ -154,9 +147,7 @@ public class InputManager {
throw new IllegalArgumentException("config must not be null.");
}
- config.touchscreen = mTouchScreenConfig;
- config.keyboard = mKeyboardConfig;
- config.navigation = mNavigationConfig;
+ nativeGetInputConfiguration(config);
}
/**
@@ -367,12 +358,7 @@ public class InputManager {
}
@SuppressWarnings("unused")
- public void notifyConfigurationChanged(long whenNanos,
- int touchScreenConfig, int keyboardConfig, int navigationConfig) {
- mTouchScreenConfig = touchScreenConfig;
- mKeyboardConfig = keyboardConfig;
- mNavigationConfig = navigationConfig;
-
+ public void notifyConfigurationChanged(long whenNanos) {
mWindowManagerService.sendNewConfiguration();
}
diff --git a/services/jni/com_android_server_InputManager.cpp b/services/jni/com_android_server_InputManager.cpp
index d27c2c6..e3bae56 100644
--- a/services/jni/com_android_server_InputManager.cpp
+++ b/services/jni/com_android_server_InputManager.cpp
@@ -138,6 +138,14 @@ static struct {
jfieldID mMotionRanges;
} gInputDeviceClassInfo;
+static struct {
+ jclass clazz;
+
+ jfieldID touchscreen;
+ jfieldID keyboard;
+ jfieldID navigation;
+} gConfigurationClassInfo;
+
// ----------------------------------------------------------------------------
static inline nsecs_t now() {
@@ -698,11 +706,7 @@ void NativeInputManager::notifyConfigurationChanged(nsecs_t when) {
JNIEnv* env = jniEnv();
- InputConfiguration config;
- mInputManager->getReader()->getInputConfiguration(& config);
-
- env->CallVoidMethod(mCallbacksObj, gCallbacksClassInfo.notifyConfigurationChanged,
- when, config.touchScreen, config.keyboard, config.navigation);
+ env->CallVoidMethod(mCallbacksObj, gCallbacksClassInfo.notifyConfigurationChanged, when);
checkAndClearExceptionFromCallback(env, "notifyConfigurationChanged");
}
@@ -1270,6 +1274,20 @@ static jintArray android_server_InputManager_nativeGetInputDeviceIds(JNIEnv* env
return deviceIdsObj;
}
+static void android_server_InputManager_nativeGetInputConfiguration(JNIEnv* env,
+ jclass clazz, jobject configObj) {
+ if (checkInputManagerUnitialized(env)) {
+ return;
+ }
+
+ InputConfiguration config;
+ gNativeInputManager->getInputManager()->getReader()->getInputConfiguration(& config);
+
+ env->SetIntField(configObj, gConfigurationClassInfo.touchscreen, config.touchScreen);
+ env->SetIntField(configObj, gConfigurationClassInfo.keyboard, config.keyboard);
+ env->SetIntField(configObj, gConfigurationClassInfo.navigation, config.navigation);
+}
+
static jstring android_server_InputManager_nativeDump(JNIEnv* env, jclass clazz) {
if (checkInputManagerUnitialized(env)) {
return NULL;
@@ -1316,6 +1334,8 @@ static JNINativeMethod gInputManagerMethods[] = {
(void*) android_server_InputManager_nativeGetInputDevice },
{ "nativeGetInputDeviceIds", "()[I",
(void*) android_server_InputManager_nativeGetInputDeviceIds },
+ { "nativeGetInputConfiguration", "(Landroid/content/res/Configuration;)V",
+ (void*) android_server_InputManager_nativeGetInputConfiguration },
{ "nativeDump", "()Ljava/lang/String;",
(void*) android_server_InputManager_nativeDump },
};
@@ -1343,7 +1363,7 @@ int register_android_server_InputManager(JNIEnv* env) {
FIND_CLASS(gCallbacksClassInfo.clazz, "com/android/server/InputManager$Callbacks");
GET_METHOD_ID(gCallbacksClassInfo.notifyConfigurationChanged, gCallbacksClassInfo.clazz,
- "notifyConfigurationChanged", "(JIII)V");
+ "notifyConfigurationChanged", "(J)V");
GET_METHOD_ID(gCallbacksClassInfo.notifyLidSwitchChanged, gCallbacksClassInfo.clazz,
"notifyLidSwitchChanged", "(JZ)V");
@@ -1543,6 +1563,19 @@ int register_android_server_InputManager(JNIEnv* env) {
GET_FIELD_ID(gInputDeviceClassInfo.mMotionRanges, gInputDeviceClassInfo.clazz,
"mMotionRanges", "[Landroid/view/InputDevice$MotionRange;");
+ // Configuration
+
+ FIND_CLASS(gConfigurationClassInfo.clazz, "android/content/res/Configuration");
+
+ GET_FIELD_ID(gConfigurationClassInfo.touchscreen, gConfigurationClassInfo.clazz,
+ "touchscreen", "I");
+
+ GET_FIELD_ID(gConfigurationClassInfo.keyboard, gConfigurationClassInfo.clazz,
+ "keyboard", "I");
+
+ GET_FIELD_ID(gConfigurationClassInfo.navigation, gConfigurationClassInfo.clazz,
+ "navigation", "I");
+
return 0;
}