summaryrefslogtreecommitdiffstats
path: root/services
diff options
context:
space:
mode:
authorJeff Brown <jeffbrown@google.com>2010-09-21 20:21:27 -0700
committerAndroid Git Automerger <android-git-automerger@android.com>2010-09-21 20:21:27 -0700
commita7553c5e330a6f743f6a62d610373214b1001663 (patch)
tree41d65cd070d4b8262af19c3aac553a3609f5f780 /services
parent6cf08937a11851403e63908b937c9de0dff5a8cf (diff)
parent77d9a5a55fa52074f18012cf997854a82500fd59 (diff)
downloadframeworks_base-a7553c5e330a6f743f6a62d610373214b1001663.zip
frameworks_base-a7553c5e330a6f743f6a62d610373214b1001663.tar.gz
frameworks_base-a7553c5e330a6f743f6a62d610373214b1001663.tar.bz2
am 77d9a5a5: am 98bcb41d: Merge "Fix race reading input configuration during system startup." into gingerbread
Merge commit '77d9a5a55fa52074f18012cf997854a82500fd59' * commit '77d9a5a55fa52074f18012cf997854a82500fd59': Fix race reading input configuration during system startup.
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;
}