Skip to content

Commit 2e7760e

Browse files
author
Jeff Brown
committed
Don't do anything on lid state change by default.
Because a lid switch can be used to do many things, it's best if the framework does not do anything by default when the lid is opened or closed. The behavior of the lid switch should be configured on a per-product basis in a config.xml resource overlay. Bug: 6320088 Change-Id: I9f768dd11d76c3c17c49f46c92f993ee2ff1409f
1 parent 4d6a82d commit 2e7760e

File tree

2 files changed

+14
-13
lines changed

2 files changed

+14
-13
lines changed

core/res/res/values/config.xml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -323,8 +323,9 @@
323323
true here reverses that logic. -->
324324
<bool name="config_reverseDefaultRotation">false</bool>
325325

326-
<!-- The number of degrees to rotate the display when the keyboard is open. -->
327-
<integer name="config_lidOpenRotation">90</integer>
326+
<!-- The number of degrees to rotate the display when the keyboard is open.
327+
A value of -1 means no change in orientation by default. -->
328+
<integer name="config_lidOpenRotation">-1</integer>
328329

329330
<!-- The number of degrees to rotate the display when the device is in a desk dock.
330331
A value of -1 means no change in orientation by default. -->
@@ -370,8 +371,8 @@
370371
<!-- Indicate whether the lid state impacts the accessibility of
371372
the physical keyboard. 0 means it doesn't, 1 means it is accessible
372373
when the lid is open, 2 means it is accessible when the lid is
373-
closed. The default is 1. -->
374-
<integer name="config_lidKeyboardAccessibility">1</integer>
374+
closed. The default is 0. -->
375+
<integer name="config_lidKeyboardAccessibility">0</integer>
375376

376377
<!-- Indicate whether the lid state impacts the accessibility of
377378
the physical keyboard. 0 means it doesn't, 1 means it is accessible

policy/src/com/android/internal/policy/impl/PhoneWindowManager.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
327327
RecentApplicationsDialog mRecentAppsDialog;
328328
int mRecentAppsDialogHeldModifiers;
329329

330-
int mLidOpen = LID_ABSENT;
330+
int mLidState = LID_ABSENT;
331331

332332
boolean mSystemReady;
333333
boolean mSystemBooted;
@@ -1225,16 +1225,16 @@ public void adjustWindowParamsLw(WindowManager.LayoutParams attrs) {
12251225
}
12261226

12271227
void readLidState() {
1228-
mLidOpen = mWindowManagerFuncs.getLidState();
1228+
mLidState = mWindowManagerFuncs.getLidState();
12291229
}
12301230

12311231
private int determineHiddenState(int mode, int hiddenValue, int visibleValue) {
1232-
if (mLidOpen != LID_ABSENT) {
1232+
if (mLidState != LID_ABSENT) {
12331233
switch (mode) {
12341234
case 1:
1235-
return mLidOpen == LID_OPEN ? visibleValue : hiddenValue;
1235+
return mLidState == LID_OPEN ? visibleValue : hiddenValue;
12361236
case 2:
1237-
return mLidOpen == LID_OPEN ? hiddenValue : visibleValue;
1237+
return mLidState == LID_OPEN ? hiddenValue : visibleValue;
12381238
}
12391239
}
12401240
return visibleValue;
@@ -2797,7 +2797,7 @@ public void notifyLidSwitchChanged(long whenNanos, boolean lidOpen) {
27972797
if (mHeadless) return;
27982798

27992799
// lid changed state
2800-
mLidOpen = lidOpen ? LID_OPEN : LID_CLOSED;
2800+
mLidState = lidOpen ? LID_OPEN : LID_CLOSED;
28012801
updateKeyboardVisibility();
28022802

28032803
boolean awakeNow = mKeyguardMediator.doLidChangeTq(lidOpen);
@@ -3486,7 +3486,7 @@ public int rotationForOrientationLw(int orientation, int lastRotation) {
34863486
}
34873487

34883488
final int preferredRotation;
3489-
if (mLidOpen == LID_OPEN && mLidOpenRotation >= 0) {
3489+
if (mLidState == LID_OPEN && mLidOpenRotation >= 0) {
34903490
// Ignore sensor when lid switch is open and rotation is forced.
34913491
preferredRotation = mLidOpenRotation;
34923492
} else if (mDockMode == Intent.EXTRA_DOCK_STATE_CAR
@@ -3878,7 +3878,7 @@ public void enableScreenAfterBoot() {
38783878
}
38793879

38803880
private void updateKeyboardVisibility() {
3881-
mPowerManager.setKeyboardVisibility(mLidOpen == LID_OPEN);
3881+
mPowerManager.setKeyboardVisibility(mLidState == LID_OPEN);
38823882
}
38833883

38843884
void updateRotation(boolean alwaysSendConfiguration) {
@@ -4132,7 +4132,7 @@ public void dump(String prefix, FileDescriptor fd, PrintWriter pw, String[] args
41324132
pw.print(prefix); pw.print("mSafeMode="); pw.print(mSafeMode);
41334133
pw.print(" mSystemReady="); pw.print(mSystemReady);
41344134
pw.print(" mSystemBooted="); pw.println(mSystemBooted);
4135-
pw.print(prefix); pw.print("mLidOpen="); pw.print(mLidOpen);
4135+
pw.print(prefix); pw.print("mLidState="); pw.print(mLidState);
41364136
pw.print(" mLidOpenRotation="); pw.print(mLidOpenRotation);
41374137
pw.print(" mHdmiPlugged="); pw.println(mHdmiPlugged);
41384138
if (mLastSystemUiFlags != 0 || mResettingSystemUiFlags != 0

0 commit comments

Comments
 (0)