Loading core/java/android/view/WindowManagerPolicy.java +5 −0 Original line number Diff line number Diff line Loading @@ -477,6 +477,11 @@ public interface WindowManagerPolicy { public void init(Context context, IWindowManager windowManager, WindowManagerFuncs windowManagerFuncs); /** * @return true if com.android.internal.R.bool#config_forceDefaultOrientation is true. */ public boolean isDefaultOrientationForced(); /** * Called by window manager once it has the initial, default native * display dimensions. Loading core/res/res/values/config.xml +5 −0 Original line number Diff line number Diff line Loading @@ -1195,4 +1195,9 @@ <item>com.android.internal.notification.DemoContactNotificationScorer</item> </string-array> <!-- Flag indicating that this device does not rotate and will always remain in its default orientation. Activities that desire to run in a non-compatible orientation will be run from an emulated display within the physical display. --> <bool name="config_forceDefaultOrientation">false</bool> </resources> core/res/res/values/symbols.xml +2 −1 Original line number Diff line number Diff line Loading @@ -280,6 +280,7 @@ <java-symbol type="bool" name="config_dontPreferApn" /> <java-symbol type="bool" name="config_speed_up_audio_on_mt_calls" /> <java-symbol type="bool" name="config_useFixedVolume" /> <java-symbol type="bool" name="config_forceDefaultOrientation" /> <java-symbol type="integer" name="config_cursorWindowSize" /> <java-symbol type="integer" name="config_extraFreeKbytesAdjust" /> Loading policy/src/com/android/internal/policy/impl/PhoneWindowManager.java +40 −19 Original line number Diff line number Diff line Loading @@ -273,6 +273,10 @@ public class PhoneWindowManager implements WindowManagerPolicy { int mDemoHdmiRotation; boolean mDemoHdmiRotationLock; // Default display does not rotate, apps that require non-default orientation will have to // have the orientation emulated. private boolean mForceDefaultOrientation = false; int mUserRotationMode = WindowManagerPolicy.USER_ROTATION_FREE; int mUserRotation = Surface.ROTATION_0; boolean mAccelerometerDefault; Loading Loading @@ -992,14 +996,14 @@ public class PhoneWindowManager implements WindowManagerPolicy { } mDisplay = display; final Resources res = mContext.getResources(); int shortSize, longSize; if (width > height) { shortSize = height; longSize = width; mLandscapeRotation = Surface.ROTATION_0; mSeascapeRotation = Surface.ROTATION_180; if (mContext.getResources().getBoolean( com.android.internal.R.bool.config_reverseDefaultRotation)) { if (res.getBoolean(com.android.internal.R.bool.config_reverseDefaultRotation)) { mPortraitRotation = Surface.ROTATION_90; mUpsideDownRotation = Surface.ROTATION_270; } else { Loading @@ -1011,8 +1015,7 @@ public class PhoneWindowManager implements WindowManagerPolicy { longSize = height; mPortraitRotation = Surface.ROTATION_0; mUpsideDownRotation = Surface.ROTATION_180; if (mContext.getResources().getBoolean( com.android.internal.R.bool.config_reverseDefaultRotation)) { if (res.getBoolean(com.android.internal.R.bool.config_reverseDefaultRotation)) { mLandscapeRotation = Surface.ROTATION_270; mSeascapeRotation = Surface.ROTATION_90; } else { Loading @@ -1021,17 +1024,15 @@ public class PhoneWindowManager implements WindowManagerPolicy { } } mStatusBarHeight = mContext.getResources().getDimensionPixelSize( com.android.internal.R.dimen.status_bar_height); mStatusBarHeight = res.getDimensionPixelSize(com.android.internal.R.dimen.status_bar_height); // Height of the navigation bar when presented horizontally at bottom mNavigationBarHeightForRotation[mPortraitRotation] = mNavigationBarHeightForRotation[mUpsideDownRotation] = mContext.getResources().getDimensionPixelSize( com.android.internal.R.dimen.navigation_bar_height); res.getDimensionPixelSize(com.android.internal.R.dimen.navigation_bar_height); mNavigationBarHeightForRotation[mLandscapeRotation] = mNavigationBarHeightForRotation[mSeascapeRotation] = mContext.getResources().getDimensionPixelSize( mNavigationBarHeightForRotation[mSeascapeRotation] = res.getDimensionPixelSize( com.android.internal.R.dimen.navigation_bar_height_landscape); // Width of the navigation bar when presented vertically along one side Loading @@ -1039,17 +1040,16 @@ public class PhoneWindowManager implements WindowManagerPolicy { mNavigationBarWidthForRotation[mUpsideDownRotation] = mNavigationBarWidthForRotation[mLandscapeRotation] = mNavigationBarWidthForRotation[mSeascapeRotation] = mContext.getResources().getDimensionPixelSize( com.android.internal.R.dimen.navigation_bar_width); res.getDimensionPixelSize(com.android.internal.R.dimen.navigation_bar_width); // SystemUI (status bar) layout policy int shortSizeDp = shortSize * DisplayMetrics.DENSITY_DEFAULT / density; int longSizeDp = longSize * DisplayMetrics.DENSITY_DEFAULT / density; // Allow the navigation bar to move on small devices (phones). mNavigationBarCanMove = shortSizeDp < 600; mHasNavigationBar = mContext.getResources().getBoolean( com.android.internal.R.bool.config_showNavigationBar); mHasNavigationBar = res.getBoolean(com.android.internal.R.bool.config_showNavigationBar); // Allow a system property to override this. Used by the emulator. // See also hasNavigationBar(). String navBarOverride = SystemProperties.get("qemu.hw.mainkeys"); Loading @@ -1075,6 +1075,20 @@ public class PhoneWindowManager implements WindowManagerPolicy { mDemoHdmiRotation = mLandscapeRotation; } mDemoHdmiRotationLock = SystemProperties.getBoolean("persist.demo.hdmirotationlock", false); // Only force the default orientation if the screen is xlarge, at least 960dp x 720dp, per // http://developer.android.com/guide/practices/screens_support.html#range mForceDefaultOrientation = longSizeDp >= 960 && shortSizeDp >= 720 && res.getBoolean(com.android.internal.R.bool.config_forceDefaultOrientation) && // For debug purposes the next line turns this feature off with: // $ adb shell setprop config.override_forced_orient true // $ adb shell wm size reset !"true".equals(SystemProperties.get("config.override_forced_orient")); } @Override public boolean isDefaultOrientationForced() { return mForceDefaultOrientation; } @Override Loading Loading @@ -1453,6 +1467,7 @@ public class PhoneWindowManager implements WindowManagerPolicy { } /** {@inheritDoc} */ @Override public int subWindowTypeToLayerLw(int type) { switch (type) { case TYPE_APPLICATION_PANEL: Loading @@ -1469,10 +1484,12 @@ public class PhoneWindowManager implements WindowManagerPolicy { return 0; } @Override public int getMaxWallpaperLayer() { return windowTypeToLayerLw(TYPE_STATUS_BAR); } @Override public int getAboveUniverseLayer() { return windowTypeToLayerLw(TYPE_SYSTEM_ERROR); } Loading Loading @@ -4345,6 +4362,10 @@ public class PhoneWindowManager implements WindowManagerPolicy { ); } if (mForceDefaultOrientation) { return Surface.ROTATION_0; } synchronized (mLock) { int sensorRotation = mOrientationListener.getProposedRotation(); // may be -1 if (sensorRotation < 0) { Loading services/java/com/android/server/wm/BlackFrame.java +18 −3 Original line number Diff line number Diff line Loading @@ -22,7 +22,6 @@ import android.graphics.Matrix; import android.graphics.PixelFormat; import android.graphics.Rect; import android.util.Slog; import android.view.Surface; import android.view.SurfaceControl; import android.view.SurfaceSession; Loading Loading @@ -62,6 +61,10 @@ public class BlackFrame { " BLACK " + surface + ": CREATE layer=" + layer); } void setAlpha(float alpha) { surface.setAlpha(alpha); } void setMatrix(Matrix matrix) { mTmpMatrix.setTranslate(left, top); mTmpMatrix.postConcat(matrix); Loading Loading @@ -93,6 +96,8 @@ public class BlackFrame { final float[] mTmpFloats = new float[9]; final BlackSurface[] mBlackSurfaces = new BlackSurface[4]; final boolean mForceDefaultOrientation; public void printTo(String prefix, PrintWriter pw) { pw.print(prefix); pw.print("Outer: "); mOuterRect.printShortString(pw); pw.print(" / Inner: "); mInnerRect.printShortString(pw); Loading @@ -106,10 +111,12 @@ public class BlackFrame { } } public BlackFrame(SurfaceSession session, Rect outer, Rect inner, int layer, final int layerStack) throws SurfaceControl.OutOfResourcesException { public BlackFrame(SurfaceSession session, Rect outer, Rect inner, int layer, int layerStack, boolean forceDefaultOrientation) throws SurfaceControl.OutOfResourcesException { boolean success = false; mForceDefaultOrientation = forceDefaultOrientation; mOuterRect = new Rect(outer); mInnerRect = new Rect(inner); try { Loading Loading @@ -162,6 +169,14 @@ public class BlackFrame { } } public void setAlpha(float alpha) { for (int i=0; i<mBlackSurfaces.length; i++) { if (mBlackSurfaces[i] != null) { mBlackSurfaces[i].setAlpha(alpha); } } } public void setMatrix(Matrix matrix) { for (int i=0; i<mBlackSurfaces.length; i++) { if (mBlackSurfaces[i] != null) { Loading Loading
core/java/android/view/WindowManagerPolicy.java +5 −0 Original line number Diff line number Diff line Loading @@ -477,6 +477,11 @@ public interface WindowManagerPolicy { public void init(Context context, IWindowManager windowManager, WindowManagerFuncs windowManagerFuncs); /** * @return true if com.android.internal.R.bool#config_forceDefaultOrientation is true. */ public boolean isDefaultOrientationForced(); /** * Called by window manager once it has the initial, default native * display dimensions. Loading
core/res/res/values/config.xml +5 −0 Original line number Diff line number Diff line Loading @@ -1195,4 +1195,9 @@ <item>com.android.internal.notification.DemoContactNotificationScorer</item> </string-array> <!-- Flag indicating that this device does not rotate and will always remain in its default orientation. Activities that desire to run in a non-compatible orientation will be run from an emulated display within the physical display. --> <bool name="config_forceDefaultOrientation">false</bool> </resources>
core/res/res/values/symbols.xml +2 −1 Original line number Diff line number Diff line Loading @@ -280,6 +280,7 @@ <java-symbol type="bool" name="config_dontPreferApn" /> <java-symbol type="bool" name="config_speed_up_audio_on_mt_calls" /> <java-symbol type="bool" name="config_useFixedVolume" /> <java-symbol type="bool" name="config_forceDefaultOrientation" /> <java-symbol type="integer" name="config_cursorWindowSize" /> <java-symbol type="integer" name="config_extraFreeKbytesAdjust" /> Loading
policy/src/com/android/internal/policy/impl/PhoneWindowManager.java +40 −19 Original line number Diff line number Diff line Loading @@ -273,6 +273,10 @@ public class PhoneWindowManager implements WindowManagerPolicy { int mDemoHdmiRotation; boolean mDemoHdmiRotationLock; // Default display does not rotate, apps that require non-default orientation will have to // have the orientation emulated. private boolean mForceDefaultOrientation = false; int mUserRotationMode = WindowManagerPolicy.USER_ROTATION_FREE; int mUserRotation = Surface.ROTATION_0; boolean mAccelerometerDefault; Loading Loading @@ -992,14 +996,14 @@ public class PhoneWindowManager implements WindowManagerPolicy { } mDisplay = display; final Resources res = mContext.getResources(); int shortSize, longSize; if (width > height) { shortSize = height; longSize = width; mLandscapeRotation = Surface.ROTATION_0; mSeascapeRotation = Surface.ROTATION_180; if (mContext.getResources().getBoolean( com.android.internal.R.bool.config_reverseDefaultRotation)) { if (res.getBoolean(com.android.internal.R.bool.config_reverseDefaultRotation)) { mPortraitRotation = Surface.ROTATION_90; mUpsideDownRotation = Surface.ROTATION_270; } else { Loading @@ -1011,8 +1015,7 @@ public class PhoneWindowManager implements WindowManagerPolicy { longSize = height; mPortraitRotation = Surface.ROTATION_0; mUpsideDownRotation = Surface.ROTATION_180; if (mContext.getResources().getBoolean( com.android.internal.R.bool.config_reverseDefaultRotation)) { if (res.getBoolean(com.android.internal.R.bool.config_reverseDefaultRotation)) { mLandscapeRotation = Surface.ROTATION_270; mSeascapeRotation = Surface.ROTATION_90; } else { Loading @@ -1021,17 +1024,15 @@ public class PhoneWindowManager implements WindowManagerPolicy { } } mStatusBarHeight = mContext.getResources().getDimensionPixelSize( com.android.internal.R.dimen.status_bar_height); mStatusBarHeight = res.getDimensionPixelSize(com.android.internal.R.dimen.status_bar_height); // Height of the navigation bar when presented horizontally at bottom mNavigationBarHeightForRotation[mPortraitRotation] = mNavigationBarHeightForRotation[mUpsideDownRotation] = mContext.getResources().getDimensionPixelSize( com.android.internal.R.dimen.navigation_bar_height); res.getDimensionPixelSize(com.android.internal.R.dimen.navigation_bar_height); mNavigationBarHeightForRotation[mLandscapeRotation] = mNavigationBarHeightForRotation[mSeascapeRotation] = mContext.getResources().getDimensionPixelSize( mNavigationBarHeightForRotation[mSeascapeRotation] = res.getDimensionPixelSize( com.android.internal.R.dimen.navigation_bar_height_landscape); // Width of the navigation bar when presented vertically along one side Loading @@ -1039,17 +1040,16 @@ public class PhoneWindowManager implements WindowManagerPolicy { mNavigationBarWidthForRotation[mUpsideDownRotation] = mNavigationBarWidthForRotation[mLandscapeRotation] = mNavigationBarWidthForRotation[mSeascapeRotation] = mContext.getResources().getDimensionPixelSize( com.android.internal.R.dimen.navigation_bar_width); res.getDimensionPixelSize(com.android.internal.R.dimen.navigation_bar_width); // SystemUI (status bar) layout policy int shortSizeDp = shortSize * DisplayMetrics.DENSITY_DEFAULT / density; int longSizeDp = longSize * DisplayMetrics.DENSITY_DEFAULT / density; // Allow the navigation bar to move on small devices (phones). mNavigationBarCanMove = shortSizeDp < 600; mHasNavigationBar = mContext.getResources().getBoolean( com.android.internal.R.bool.config_showNavigationBar); mHasNavigationBar = res.getBoolean(com.android.internal.R.bool.config_showNavigationBar); // Allow a system property to override this. Used by the emulator. // See also hasNavigationBar(). String navBarOverride = SystemProperties.get("qemu.hw.mainkeys"); Loading @@ -1075,6 +1075,20 @@ public class PhoneWindowManager implements WindowManagerPolicy { mDemoHdmiRotation = mLandscapeRotation; } mDemoHdmiRotationLock = SystemProperties.getBoolean("persist.demo.hdmirotationlock", false); // Only force the default orientation if the screen is xlarge, at least 960dp x 720dp, per // http://developer.android.com/guide/practices/screens_support.html#range mForceDefaultOrientation = longSizeDp >= 960 && shortSizeDp >= 720 && res.getBoolean(com.android.internal.R.bool.config_forceDefaultOrientation) && // For debug purposes the next line turns this feature off with: // $ adb shell setprop config.override_forced_orient true // $ adb shell wm size reset !"true".equals(SystemProperties.get("config.override_forced_orient")); } @Override public boolean isDefaultOrientationForced() { return mForceDefaultOrientation; } @Override Loading Loading @@ -1453,6 +1467,7 @@ public class PhoneWindowManager implements WindowManagerPolicy { } /** {@inheritDoc} */ @Override public int subWindowTypeToLayerLw(int type) { switch (type) { case TYPE_APPLICATION_PANEL: Loading @@ -1469,10 +1484,12 @@ public class PhoneWindowManager implements WindowManagerPolicy { return 0; } @Override public int getMaxWallpaperLayer() { return windowTypeToLayerLw(TYPE_STATUS_BAR); } @Override public int getAboveUniverseLayer() { return windowTypeToLayerLw(TYPE_SYSTEM_ERROR); } Loading Loading @@ -4345,6 +4362,10 @@ public class PhoneWindowManager implements WindowManagerPolicy { ); } if (mForceDefaultOrientation) { return Surface.ROTATION_0; } synchronized (mLock) { int sensorRotation = mOrientationListener.getProposedRotation(); // may be -1 if (sensorRotation < 0) { Loading
services/java/com/android/server/wm/BlackFrame.java +18 −3 Original line number Diff line number Diff line Loading @@ -22,7 +22,6 @@ import android.graphics.Matrix; import android.graphics.PixelFormat; import android.graphics.Rect; import android.util.Slog; import android.view.Surface; import android.view.SurfaceControl; import android.view.SurfaceSession; Loading Loading @@ -62,6 +61,10 @@ public class BlackFrame { " BLACK " + surface + ": CREATE layer=" + layer); } void setAlpha(float alpha) { surface.setAlpha(alpha); } void setMatrix(Matrix matrix) { mTmpMatrix.setTranslate(left, top); mTmpMatrix.postConcat(matrix); Loading Loading @@ -93,6 +96,8 @@ public class BlackFrame { final float[] mTmpFloats = new float[9]; final BlackSurface[] mBlackSurfaces = new BlackSurface[4]; final boolean mForceDefaultOrientation; public void printTo(String prefix, PrintWriter pw) { pw.print(prefix); pw.print("Outer: "); mOuterRect.printShortString(pw); pw.print(" / Inner: "); mInnerRect.printShortString(pw); Loading @@ -106,10 +111,12 @@ public class BlackFrame { } } public BlackFrame(SurfaceSession session, Rect outer, Rect inner, int layer, final int layerStack) throws SurfaceControl.OutOfResourcesException { public BlackFrame(SurfaceSession session, Rect outer, Rect inner, int layer, int layerStack, boolean forceDefaultOrientation) throws SurfaceControl.OutOfResourcesException { boolean success = false; mForceDefaultOrientation = forceDefaultOrientation; mOuterRect = new Rect(outer); mInnerRect = new Rect(inner); try { Loading Loading @@ -162,6 +169,14 @@ public class BlackFrame { } } public void setAlpha(float alpha) { for (int i=0; i<mBlackSurfaces.length; i++) { if (mBlackSurfaces[i] != null) { mBlackSurfaces[i].setAlpha(alpha); } } } public void setMatrix(Matrix matrix) { for (int i=0; i<mBlackSurfaces.length; i++) { if (mBlackSurfaces[i] != null) { Loading