Merge "Migrate to @Override to remove warnings."
diff --git a/services/input/EventHub.cpp b/services/input/EventHub.cpp
index 665d711..7060ae2 100644
--- a/services/input/EventHub.cpp
+++ b/services/input/EventHub.cpp
@@ -1103,18 +1103,35 @@
// Enable wake-lock behavior on kernels that support it.
// TODO: Only need this for devices that can really wake the system.
- bool usingSuspendBlock = ioctl(fd, EVIOCSSUSPENDBLOCK, 1) == 0;
+ bool usingSuspendBlockIoctl = !ioctl(fd, EVIOCSSUSPENDBLOCK, 1);
+
+ // Tell the kernel that we want to use the monotonic clock for reporting timestamps
+ // associated with input events. This is important because the input system
+ // uses the timestamps extensively and assumes they were recorded using the monotonic
+ // clock.
+ //
+ // In older kernel, before Linux 3.4, there was no way to tell the kernel which
+ // clock to use to input event timestamps. The standard kernel behavior was to
+ // record a real time timestamp, which isn't what we want. Android kernels therefore
+ // contained a patch to the evdev_event() function in drivers/input/evdev.c to
+ // replace the call to do_gettimeofday() with ktime_get_ts() to cause the monotonic
+ // clock to be used instead of the real time clock.
+ //
+ // As of Linux 3.4, there is a new EVIOCSCLOCKID ioctl to set the desired clock.
+ // Therefore, we no longer require the Android-specific kernel patch described above
+ // as long as we make sure to set select the monotonic clock. We do that here.
+ bool usingClockIoctl = !ioctl(fd, EVIOCSCLOCKID, CLOCK_MONOTONIC);
ALOGI("New device: id=%d, fd=%d, path='%s', name='%s', classes=0x%x, "
"configuration='%s', keyLayout='%s', keyCharacterMap='%s', builtinKeyboard=%s, "
- "usingSuspendBlock=%s",
+ "usingSuspendBlockIoctl=%s, usingClockIoctl=%s",
deviceId, fd, devicePath, device->identifier.name.string(),
device->classes,
device->configurationFile.string(),
device->keyMap.keyLayoutFile.string(),
device->keyMap.keyCharacterMapFile.string(),
toString(mBuiltInKeyboardId == deviceId),
- toString(usingSuspendBlock));
+ toString(usingSuspendBlockIoctl), toString(usingClockIoctl));
mDevices.add(deviceId, device);
diff --git a/services/java/com/android/server/wm/WindowManagerService.java b/services/java/com/android/server/wm/WindowManagerService.java
index 6f7852d..a7af8fb 100644
--- a/services/java/com/android/server/wm/WindowManagerService.java
+++ b/services/java/com/android/server/wm/WindowManagerService.java
@@ -4807,10 +4807,13 @@
final int SW_LID = 0x00;
int sw = mInputManager.getSwitchState(-1, InputDevice.SOURCE_ANY, SW_LID);
if (sw > 0) {
- return LID_OPEN;
- } else if (sw == 0) {
+ // Switch state: AKEY_STATE_DOWN or AKEY_STATE_VIRTUAL.
return LID_CLOSED;
+ } else if (sw == 0) {
+ // Switch state: AKEY_STATE_UP.
+ return LID_OPEN;
} else {
+ // Switch state: AKEY_STATE_UNKNOWN.
return LID_ABSENT;
}
}
@@ -4818,10 +4821,6 @@
// Called by window manager policy. Not exposed externally.
@Override
public InputChannel monitorInput(String inputChannelName) {
- if (!checkCallingPermission(android.Manifest.permission.READ_INPUT_STATE,
- "monitorInput()")) {
- throw new SecurityException("Requires READ_INPUT_STATE permission");
- }
return mInputManager.monitorInput(inputChannelName);
}
diff --git a/services/jni/com_android_server_input_InputManagerService.cpp b/services/jni/com_android_server_input_InputManagerService.cpp
index 75c20f3..c137a78 100644
--- a/services/jni/com_android_server_input_InputManagerService.cpp
+++ b/services/jni/com_android_server_input_InputManagerService.cpp
@@ -510,8 +510,9 @@
switch (switchCode) {
case SW_LID:
+ // When switch value is set indicates lid is closed.
env->CallVoidMethod(mServiceObj, gServiceClassInfo.notifyLidSwitchChanged,
- when, switchValue == 0);
+ when, switchValue == 0 /*lidOpen*/);
checkAndClearExceptionFromCallback(env, "notifyLidSwitchChanged");
break;
}