diff options
| author | 2011-11-15 14:08:20 -0800 | |
|---|---|---|
| committer | 2011-11-15 14:14:02 -0800 | |
| commit | dec6cf4f30a823a004d853915bc13c59d607f285 (patch) | |
| tree | efa589a992c9da1ef858972bf324f1597f083d39 | |
| parent | 9058435dc1a741030c042c4d6f2512f5d1605e5d (diff) | |
Override app requested orientation when docked.
Applies to docks, lid switch, HDMI and rotation lock.
We always choose a mode that is compatible with the application's
request, so if in a landscape dock, we might override a request
for seascape but we leave requests for portrait alone.
Bug: 5620454
Change-Id: Ib0c4f60f7f9e3aeafaba9c717233a950fccb8af2
| -rwxr-xr-x | policy/src/com/android/internal/policy/impl/PhoneWindowManager.java | 31 |
1 files changed, 21 insertions, 10 deletions
diff --git a/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java b/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java index 921f3313fb0f..b4dd07bffcfe 100755 --- a/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java +++ b/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java @@ -3097,7 +3097,7 @@ public class PhoneWindowManager implements WindowManagerPolicy { sensorRotation = lastRotation; } - int preferredRotation = -1; + final int preferredRotation; if (mHdmiPlugged) { // Ignore sensor when plugged into HDMI. preferredRotation = mHdmiRotation; @@ -3146,28 +3146,39 @@ public class PhoneWindowManager implements WindowManagerPolicy { } else if (mUserRotationMode == WindowManagerPolicy.USER_ROTATION_LOCKED) { // Apply rotation lock. preferredRotation = mUserRotation; + } else { + // No overriding preference. + // We will do exactly what the application asked us to do. + preferredRotation = -1; } - // TODO: Sometimes, we might want to override the application-requested - // orientation, such as when HDMI is plugged in or when docked. - // We can do that by modifying the appropriate cases above to return - // the preferred orientation directly instead of continuing on down here. - switch (orientation) { case ActivityInfo.SCREEN_ORIENTATION_PORTRAIT: - // Always return portrait if orientation set to portrait. + // Return portrait unless overridden. + if (isAnyPortrait(preferredRotation)) { + return preferredRotation; + } return mPortraitRotation; case ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE: - // Always return landscape if orientation set to landscape. + // Return landscape unless overridden. + if (isLandscapeOrSeascape(preferredRotation)) { + return preferredRotation; + } return mLandscapeRotation; case ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT: - // Always return portrait if orientation set to portrait. + // Return reverse portrait unless overridden. + if (isAnyPortrait(preferredRotation)) { + return preferredRotation; + } return mUpsideDownRotation; case ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE: - // Always return seascape if orientation set to reverse landscape. + // Return seascape unless overridden. + if (isLandscapeOrSeascape(preferredRotation)) { + return preferredRotation; + } return mSeascapeRotation; case ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE: |