Merge "Fix race reading input configuration during system startup." into gingerbread
This commit is contained in:
@@ -53,10 +53,6 @@ public class InputManager {
|
|||||||
private final Context mContext;
|
private final Context mContext;
|
||||||
private final WindowManagerService mWindowManagerService;
|
private final WindowManagerService mWindowManagerService;
|
||||||
|
|
||||||
private int mTouchScreenConfig;
|
|
||||||
private int mKeyboardConfig;
|
|
||||||
private int mNavigationConfig;
|
|
||||||
|
|
||||||
private static native void nativeInit(Callbacks callbacks);
|
private static native void nativeInit(Callbacks callbacks);
|
||||||
private static native void nativeStart();
|
private static native void nativeStart();
|
||||||
private static native void nativeSetDisplaySize(int displayId, int width, int height);
|
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 nativeSetInputDispatchMode(boolean enabled, boolean frozen);
|
||||||
private static native void nativeSetFocusedApplication(InputApplication application);
|
private static native void nativeSetFocusedApplication(InputApplication application);
|
||||||
private static native InputDevice nativeGetInputDevice(int deviceId);
|
private static native InputDevice nativeGetInputDevice(int deviceId);
|
||||||
|
private static native void nativeGetInputConfiguration(Configuration configuration);
|
||||||
private static native int[] nativeGetInputDeviceIds();
|
private static native int[] nativeGetInputDeviceIds();
|
||||||
private static native String nativeDump();
|
private static native String nativeDump();
|
||||||
|
|
||||||
@@ -114,10 +111,6 @@ public class InputManager {
|
|||||||
|
|
||||||
this.mCallbacks = new Callbacks();
|
this.mCallbacks = new Callbacks();
|
||||||
|
|
||||||
mTouchScreenConfig = Configuration.TOUCHSCREEN_NOTOUCH;
|
|
||||||
mKeyboardConfig = Configuration.KEYBOARD_NOKEYS;
|
|
||||||
mNavigationConfig = Configuration.NAVIGATION_NONAV;
|
|
||||||
|
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -154,9 +147,7 @@ public class InputManager {
|
|||||||
throw new IllegalArgumentException("config must not be null.");
|
throw new IllegalArgumentException("config must not be null.");
|
||||||
}
|
}
|
||||||
|
|
||||||
config.touchscreen = mTouchScreenConfig;
|
nativeGetInputConfiguration(config);
|
||||||
config.keyboard = mKeyboardConfig;
|
|
||||||
config.navigation = mNavigationConfig;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -367,12 +358,7 @@ public class InputManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
public void notifyConfigurationChanged(long whenNanos,
|
public void notifyConfigurationChanged(long whenNanos) {
|
||||||
int touchScreenConfig, int keyboardConfig, int navigationConfig) {
|
|
||||||
mTouchScreenConfig = touchScreenConfig;
|
|
||||||
mKeyboardConfig = keyboardConfig;
|
|
||||||
mNavigationConfig = navigationConfig;
|
|
||||||
|
|
||||||
mWindowManagerService.sendNewConfiguration();
|
mWindowManagerService.sendNewConfiguration();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -138,6 +138,14 @@ static struct {
|
|||||||
jfieldID mMotionRanges;
|
jfieldID mMotionRanges;
|
||||||
} gInputDeviceClassInfo;
|
} gInputDeviceClassInfo;
|
||||||
|
|
||||||
|
static struct {
|
||||||
|
jclass clazz;
|
||||||
|
|
||||||
|
jfieldID touchscreen;
|
||||||
|
jfieldID keyboard;
|
||||||
|
jfieldID navigation;
|
||||||
|
} gConfigurationClassInfo;
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
static inline nsecs_t now() {
|
static inline nsecs_t now() {
|
||||||
@@ -698,11 +706,7 @@ void NativeInputManager::notifyConfigurationChanged(nsecs_t when) {
|
|||||||
|
|
||||||
JNIEnv* env = jniEnv();
|
JNIEnv* env = jniEnv();
|
||||||
|
|
||||||
InputConfiguration config;
|
env->CallVoidMethod(mCallbacksObj, gCallbacksClassInfo.notifyConfigurationChanged, when);
|
||||||
mInputManager->getReader()->getInputConfiguration(& config);
|
|
||||||
|
|
||||||
env->CallVoidMethod(mCallbacksObj, gCallbacksClassInfo.notifyConfigurationChanged,
|
|
||||||
when, config.touchScreen, config.keyboard, config.navigation);
|
|
||||||
checkAndClearExceptionFromCallback(env, "notifyConfigurationChanged");
|
checkAndClearExceptionFromCallback(env, "notifyConfigurationChanged");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1270,6 +1274,20 @@ static jintArray android_server_InputManager_nativeGetInputDeviceIds(JNIEnv* env
|
|||||||
return deviceIdsObj;
|
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) {
|
static jstring android_server_InputManager_nativeDump(JNIEnv* env, jclass clazz) {
|
||||||
if (checkInputManagerUnitialized(env)) {
|
if (checkInputManagerUnitialized(env)) {
|
||||||
return NULL;
|
return NULL;
|
||||||
@@ -1316,6 +1334,8 @@ static JNINativeMethod gInputManagerMethods[] = {
|
|||||||
(void*) android_server_InputManager_nativeGetInputDevice },
|
(void*) android_server_InputManager_nativeGetInputDevice },
|
||||||
{ "nativeGetInputDeviceIds", "()[I",
|
{ "nativeGetInputDeviceIds", "()[I",
|
||||||
(void*) android_server_InputManager_nativeGetInputDeviceIds },
|
(void*) android_server_InputManager_nativeGetInputDeviceIds },
|
||||||
|
{ "nativeGetInputConfiguration", "(Landroid/content/res/Configuration;)V",
|
||||||
|
(void*) android_server_InputManager_nativeGetInputConfiguration },
|
||||||
{ "nativeDump", "()Ljava/lang/String;",
|
{ "nativeDump", "()Ljava/lang/String;",
|
||||||
(void*) android_server_InputManager_nativeDump },
|
(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");
|
FIND_CLASS(gCallbacksClassInfo.clazz, "com/android/server/InputManager$Callbacks");
|
||||||
|
|
||||||
GET_METHOD_ID(gCallbacksClassInfo.notifyConfigurationChanged, gCallbacksClassInfo.clazz,
|
GET_METHOD_ID(gCallbacksClassInfo.notifyConfigurationChanged, gCallbacksClassInfo.clazz,
|
||||||
"notifyConfigurationChanged", "(JIII)V");
|
"notifyConfigurationChanged", "(J)V");
|
||||||
|
|
||||||
GET_METHOD_ID(gCallbacksClassInfo.notifyLidSwitchChanged, gCallbacksClassInfo.clazz,
|
GET_METHOD_ID(gCallbacksClassInfo.notifyLidSwitchChanged, gCallbacksClassInfo.clazz,
|
||||||
"notifyLidSwitchChanged", "(JZ)V");
|
"notifyLidSwitchChanged", "(JZ)V");
|
||||||
@@ -1543,6 +1563,19 @@ int register_android_server_InputManager(JNIEnv* env) {
|
|||||||
GET_FIELD_ID(gInputDeviceClassInfo.mMotionRanges, gInputDeviceClassInfo.clazz,
|
GET_FIELD_ID(gInputDeviceClassInfo.mMotionRanges, gInputDeviceClassInfo.clazz,
|
||||||
"mMotionRanges", "[Landroid/view/InputDevice$MotionRange;");
|
"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;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user