Skip to content

Commit 27fd342

Browse files
author
Jeff Brown
committed
Fix lid switch interpretation.
Also remove unnecessary permission check for method that is only called internally. Change-Id: I32f63fc3e96b06709d18b046ee2d3c8f310de70d
1 parent eca3cf5 commit 27fd342

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

services/java/com/android/server/wm/WindowManagerService.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4807,21 +4807,20 @@ public int getLidState() {
48074807
final int SW_LID = 0x00;
48084808
int sw = mInputManager.getSwitchState(-1, InputDevice.SOURCE_ANY, SW_LID);
48094809
if (sw > 0) {
4810-
return LID_OPEN;
4811-
} else if (sw == 0) {
4810+
// Switch state: AKEY_STATE_DOWN or AKEY_STATE_VIRTUAL.
48124811
return LID_CLOSED;
4812+
} else if (sw == 0) {
4813+
// Switch state: AKEY_STATE_UP.
4814+
return LID_OPEN;
48134815
} else {
4816+
// Switch state: AKEY_STATE_UNKNOWN.
48144817
return LID_ABSENT;
48154818
}
48164819
}
48174820

48184821
// Called by window manager policy. Not exposed externally.
48194822
@Override
48204823
public InputChannel monitorInput(String inputChannelName) {
4821-
if (!checkCallingPermission(android.Manifest.permission.READ_INPUT_STATE,
4822-
"monitorInput()")) {
4823-
throw new SecurityException("Requires READ_INPUT_STATE permission");
4824-
}
48254824
return mInputManager.monitorInput(inputChannelName);
48264825
}
48274826

services/jni/com_android_server_input_InputManagerService.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -510,8 +510,9 @@ void NativeInputManager::notifySwitch(nsecs_t when, int32_t switchCode,
510510

511511
switch (switchCode) {
512512
case SW_LID:
513+
// When switch value is set indicates lid is closed.
513514
env->CallVoidMethod(mServiceObj, gServiceClassInfo.notifyLidSwitchChanged,
514-
when, switchValue == 0);
515+
when, switchValue == 0 /*lidOpen*/);
515516
checkAndClearExceptionFromCallback(env, "notifyLidSwitchChanged");
516517
break;
517518
}

0 commit comments

Comments
 (0)