Loading policy/src/com/android/internal/policy/impl/PhoneWindowManager.java +7 −1 Original line number Original line Diff line number Diff line Loading @@ -299,6 +299,7 @@ public class PhoneWindowManager implements WindowManagerPolicy { int mCarDockRotation; int mCarDockRotation; int mDeskDockRotation; int mDeskDockRotation; int mHdmiRotation; int mHdmiRotation; boolean mHdmiRotationLock; int mUserRotationMode = WindowManagerPolicy.USER_ROTATION_FREE; int mUserRotationMode = WindowManagerPolicy.USER_ROTATION_FREE; int mUserRotation = Surface.ROTATION_0; int mUserRotation = Surface.ROTATION_0; Loading Loading @@ -1035,11 +1036,14 @@ public class PhoneWindowManager implements WindowManagerPolicy { mCanHideNavigationBar = false; mCanHideNavigationBar = false; } } // For demo purposes, allow the rotation of the HDMI display to be controlled. // By default, HDMI locks rotation to landscape. if ("portrait".equals(SystemProperties.get("persist.demo.hdmirotation"))) { if ("portrait".equals(SystemProperties.get("persist.demo.hdmirotation"))) { mHdmiRotation = mPortraitRotation; mHdmiRotation = mPortraitRotation; } else { } else { mHdmiRotation = mLandscapeRotation; mHdmiRotation = mLandscapeRotation; } } mHdmiRotationLock = SystemProperties.getBoolean("persist.demo.hdmirotationlock", true); } } public void updateSettings() { public void updateSettings() { Loading Loading @@ -3873,7 +3877,7 @@ public class PhoneWindowManager implements WindowManagerPolicy { // enable 180 degree rotation while docked. // enable 180 degree rotation while docked. preferredRotation = mDeskDockEnablesAccelerometer preferredRotation = mDeskDockEnablesAccelerometer ? sensorRotation : mDeskDockRotation; ? sensorRotation : mDeskDockRotation; } else if (mHdmiPlugged) { } else if (mHdmiPlugged && mHdmiRotationLock) { // Ignore sensor when plugged into HDMI. // Ignore sensor when plugged into HDMI. // Note that the dock orientation overrides the HDMI orientation. // Note that the dock orientation overrides the HDMI orientation. preferredRotation = mHdmiRotation; preferredRotation = mHdmiRotation; Loading Loading @@ -4538,5 +4542,7 @@ public class PhoneWindowManager implements WindowManagerPolicy { pw.print(" mSeascapeRotation="); pw.println(mSeascapeRotation); pw.print(" mSeascapeRotation="); pw.println(mSeascapeRotation); pw.print(prefix); pw.print("mPortraitRotation="); pw.print(mPortraitRotation); pw.print(prefix); pw.print("mPortraitRotation="); pw.print(mPortraitRotation); pw.print(" mUpsideDownRotation="); pw.println(mUpsideDownRotation); pw.print(" mUpsideDownRotation="); pw.println(mUpsideDownRotation); pw.print(prefix); pw.print("mHdmiRotation="); pw.print(mHdmiRotation); pw.print(" mHdmiRotationLock="); pw.println(mHdmiRotationLock); } } } } services/java/com/android/server/display/DisplayDeviceInfo.java +36 −9 Original line number Original line Diff line number Diff line Loading @@ -17,6 +17,7 @@ package com.android.server.display; package com.android.server.display; import android.util.DisplayMetrics; import android.util.DisplayMetrics; import android.view.Surface; import libcore.util.Objects; import libcore.util.Objects; Loading @@ -31,11 +32,21 @@ final class DisplayDeviceInfo { public static final int FLAG_DEFAULT_DISPLAY = 1 << 0; public static final int FLAG_DEFAULT_DISPLAY = 1 << 0; /** /** * Flag: Indicates that this display device can rotate to show contents in a * Flag: Indicates that the orientation of this display device is coupled to the * different orientation. Otherwise the rotation is assumed to be fixed in the * rotation of its associated logical display. * natural orientation and the display manager should transform the content to fit. * <p> * This flag should be applied to the default display to indicate that the user * physically rotates the display when content is presented in a different orientation. * The display manager will apply a coordinate transformation assuming that the * physical orientation of the display matches the logical orientation of its content. * </p><p> * The flag should not be set when the display device is mounted in a fixed orientation * such as on a desk. The display manager will apply a coordinate transformation * such as a scale and translation to letterbox or pillarbox format under the * assumption that the physical orientation of the display is invariant. * </p> */ */ public static final int FLAG_SUPPORTS_ROTATION = 1 << 1; public static final int FLAG_ROTATES_WITH_CONTENT = 1 << 1; /** /** * Flag: Indicates that this display device has secure video output, such as HDCP. * Flag: Indicates that this display device has secure video output, such as HDCP. Loading Loading @@ -116,6 +127,17 @@ final class DisplayDeviceInfo { */ */ public int touch; public int touch; /** * The additional rotation to apply to all content presented on the display device * relative to its physical coordinate system. Default is {@link Surface#ROTATION_0}. * <p> * This field can be used to compensate for the fact that the display has been * physically rotated relative to its natural orientation such as an HDMI monitor * that has been mounted sideways to appear to be portrait rather than landscape. * </p> */ public int rotation = Surface.ROTATION_0; public void setAssumedDensityForExternalDisplay(int width, int height) { public void setAssumedDensityForExternalDisplay(int width, int height) { densityDpi = Math.min(width, height) * DisplayMetrics.DENSITY_XHIGH / 1080; densityDpi = Math.min(width, height) * DisplayMetrics.DENSITY_XHIGH / 1080; // Technically, these values should be smaller than the apparent density // Technically, these values should be smaller than the apparent density Loading @@ -139,7 +161,8 @@ final class DisplayDeviceInfo { && xDpi == other.xDpi && xDpi == other.xDpi && yDpi == other.yDpi && yDpi == other.yDpi && flags == other.flags && flags == other.flags && touch == other.touch; && touch == other.touch && rotation == other.rotation; } } @Override @Override Loading @@ -157,14 +180,18 @@ final class DisplayDeviceInfo { yDpi = other.yDpi; yDpi = other.yDpi; flags = other.flags; flags = other.flags; touch = other.touch; touch = other.touch; rotation = other.rotation; } } // For debugging purposes // For debugging purposes @Override @Override public String toString() { public String toString() { return "DisplayDeviceInfo{\"" + name + "\": " + width + " x " + height + ", " + refreshRate + " fps, " return "DisplayDeviceInfo{\"" + name + "\": " + width + " x " + height + ", " + refreshRate + " fps, " + "density " + densityDpi + ", " + xDpi + " x " + yDpi + " dpi" + "density " + densityDpi + ", " + xDpi + " x " + yDpi + " dpi" + ", touch " + touchToString(touch) + flagsToString(flags) + "}"; + ", touch " + touchToString(touch) + flagsToString(flags) + ", rotation " + rotation + "}"; } } private static String touchToString(int touch) { private static String touchToString(int touch) { Loading @@ -185,8 +212,8 @@ final class DisplayDeviceInfo { if ((flags & FLAG_DEFAULT_DISPLAY) != 0) { if ((flags & FLAG_DEFAULT_DISPLAY) != 0) { msg.append(", FLAG_DEFAULT_DISPLAY"); msg.append(", FLAG_DEFAULT_DISPLAY"); } } if ((flags & FLAG_SUPPORTS_ROTATION) != 0) { if ((flags & FLAG_ROTATES_WITH_CONTENT) != 0) { msg.append(", FLAG_SUPPORTS_ROTATION"); msg.append(", FLAG_ROTATES_WITH_CONTENT"); } } if ((flags & FLAG_SECURE) != 0) { if ((flags & FLAG_SECURE) != 0) { msg.append(", FLAG_SECURE"); msg.append(", FLAG_SECURE"); Loading services/java/com/android/server/display/DisplayManagerService.java +15 −0 Original line number Original line Diff line number Diff line Loading @@ -127,6 +127,13 @@ public final class DisplayManagerService extends IDisplayManager.Stub { // services should be started. This option may disable certain display adapters. // services should be started. This option may disable certain display adapters. public boolean mOnlyCore; public boolean mOnlyCore; // True if the display manager service should pretend there is only one display // and only tell applications about the existence of the default logical display. // The display manager can still mirror content to secondary displays but applications // cannot present unique content on those displays. // Used for demonstration purposes only. private final boolean mSingleDisplayDemoMode; // All callback records indexed by calling process id. // All callback records indexed by calling process id. public final SparseArray<CallbackRecord> mCallbacks = public final SparseArray<CallbackRecord> mCallbacks = new SparseArray<CallbackRecord>(); new SparseArray<CallbackRecord>(); Loading Loading @@ -182,6 +189,7 @@ public final class DisplayManagerService extends IDisplayManager.Stub { mHandler = new DisplayManagerHandler(mainHandler.getLooper()); mHandler = new DisplayManagerHandler(mainHandler.getLooper()); mUiHandler = uiHandler; mUiHandler = uiHandler; mDisplayAdapterListener = new DisplayAdapterListener(); mDisplayAdapterListener = new DisplayAdapterListener(); mSingleDisplayDemoMode = SystemProperties.getBoolean("persist.demo.singledisplay", false); mHandler.sendEmptyMessage(MSG_REGISTER_DEFAULT_DISPLAY_ADAPTER); mHandler.sendEmptyMessage(MSG_REGISTER_DEFAULT_DISPLAY_ADAPTER); } } Loading Loading @@ -631,6 +639,12 @@ public final class DisplayManagerService extends IDisplayManager.Stub { isDefault = false; isDefault = false; } } if (!isDefault && mSingleDisplayDemoMode) { Slog.i(TAG, "Not creating a logical display for a secondary display " + " because single display demo mode is enabled: " + deviceInfo); return; } final int displayId = assignDisplayIdLocked(isDefault); final int displayId = assignDisplayIdLocked(isDefault); final int layerStack = assignLayerStackLocked(displayId); final int layerStack = assignLayerStackLocked(displayId); Loading Loading @@ -857,6 +871,7 @@ public final class DisplayManagerService extends IDisplayManager.Stub { pw.println(" mNextNonDefaultDisplayId=" + mNextNonDefaultDisplayId); pw.println(" mNextNonDefaultDisplayId=" + mNextNonDefaultDisplayId); pw.println(" mDefaultViewport=" + mDefaultViewport); pw.println(" mDefaultViewport=" + mDefaultViewport); pw.println(" mExternalTouchViewport=" + mExternalTouchViewport); pw.println(" mExternalTouchViewport=" + mExternalTouchViewport); pw.println(" mSingleDisplayDemoMode=" + mSingleDisplayDemoMode); IndentingPrintWriter ipw = new IndentingPrintWriter(pw, " "); IndentingPrintWriter ipw = new IndentingPrintWriter(pw, " "); ipw.increaseIndent(); ipw.increaseIndent(); Loading services/java/com/android/server/display/LocalDisplayAdapter.java +8 −1 Original line number Original line Diff line number Diff line Loading @@ -20,6 +20,7 @@ import android.content.Context; import android.os.Handler; import android.os.Handler; import android.os.IBinder; import android.os.IBinder; import android.os.Looper; import android.os.Looper; import android.os.SystemProperties; import android.util.SparseArray; import android.util.SparseArray; import android.view.DisplayEventReceiver; import android.view.DisplayEventReceiver; import android.view.Surface; import android.view.Surface; Loading Loading @@ -135,7 +136,7 @@ final class LocalDisplayAdapter extends DisplayAdapter { mInfo.name = getContext().getResources().getString( mInfo.name = getContext().getResources().getString( com.android.internal.R.string.display_manager_built_in_display_name); com.android.internal.R.string.display_manager_built_in_display_name); mInfo.flags |= DisplayDeviceInfo.FLAG_DEFAULT_DISPLAY mInfo.flags |= DisplayDeviceInfo.FLAG_DEFAULT_DISPLAY | DisplayDeviceInfo.FLAG_SUPPORTS_ROTATION; | DisplayDeviceInfo.FLAG_ROTATES_WITH_CONTENT; mInfo.densityDpi = (int)(mPhys.density * 160 + 0.5f); mInfo.densityDpi = (int)(mPhys.density * 160 + 0.5f); mInfo.xDpi = mPhys.xDpi; mInfo.xDpi = mPhys.xDpi; mInfo.yDpi = mPhys.yDpi; mInfo.yDpi = mPhys.yDpi; Loading @@ -145,6 +146,12 @@ final class LocalDisplayAdapter extends DisplayAdapter { com.android.internal.R.string.display_manager_hdmi_display_name); com.android.internal.R.string.display_manager_hdmi_display_name); mInfo.touch = DisplayDeviceInfo.TOUCH_EXTERNAL; mInfo.touch = DisplayDeviceInfo.TOUCH_EXTERNAL; mInfo.setAssumedDensityForExternalDisplay(mPhys.width, mPhys.height); mInfo.setAssumedDensityForExternalDisplay(mPhys.width, mPhys.height); // For demonstration purposes, allow rotation of the external display. // In the future we might allow the user to configure this directly. if ("portrait".equals(SystemProperties.get("persist.demo.hdmirotation"))) { mInfo.rotation = Surface.ROTATION_270; } } } } } return mInfo; return mInfo; Loading services/java/com/android/server/display/LogicalDisplay.java +4 −1 Original line number Original line Diff line number Diff line Loading @@ -241,10 +241,13 @@ final class LogicalDisplay { // is rotated when the contents of the logical display are rendered. // is rotated when the contents of the logical display are rendered. int orientation = Surface.ROTATION_0; int orientation = Surface.ROTATION_0; if (device == mPrimaryDisplayDevice if (device == mPrimaryDisplayDevice && (displayDeviceInfo.flags & DisplayDeviceInfo.FLAG_SUPPORTS_ROTATION) != 0) { && (displayDeviceInfo.flags & DisplayDeviceInfo.FLAG_ROTATES_WITH_CONTENT) != 0) { orientation = displayInfo.rotation; orientation = displayInfo.rotation; } } // Apply the physical rotation of the display device itself. orientation = (orientation + displayDeviceInfo.rotation) % 4; // Set the frame. // Set the frame. // The frame specifies the rotated physical coordinates into which the viewport // The frame specifies the rotated physical coordinates into which the viewport // is mapped. We need to take care to preserve the aspect ratio of the viewport. // is mapped. We need to take care to preserve the aspect ratio of the viewport. Loading Loading
policy/src/com/android/internal/policy/impl/PhoneWindowManager.java +7 −1 Original line number Original line Diff line number Diff line Loading @@ -299,6 +299,7 @@ public class PhoneWindowManager implements WindowManagerPolicy { int mCarDockRotation; int mCarDockRotation; int mDeskDockRotation; int mDeskDockRotation; int mHdmiRotation; int mHdmiRotation; boolean mHdmiRotationLock; int mUserRotationMode = WindowManagerPolicy.USER_ROTATION_FREE; int mUserRotationMode = WindowManagerPolicy.USER_ROTATION_FREE; int mUserRotation = Surface.ROTATION_0; int mUserRotation = Surface.ROTATION_0; Loading Loading @@ -1035,11 +1036,14 @@ public class PhoneWindowManager implements WindowManagerPolicy { mCanHideNavigationBar = false; mCanHideNavigationBar = false; } } // For demo purposes, allow the rotation of the HDMI display to be controlled. // By default, HDMI locks rotation to landscape. if ("portrait".equals(SystemProperties.get("persist.demo.hdmirotation"))) { if ("portrait".equals(SystemProperties.get("persist.demo.hdmirotation"))) { mHdmiRotation = mPortraitRotation; mHdmiRotation = mPortraitRotation; } else { } else { mHdmiRotation = mLandscapeRotation; mHdmiRotation = mLandscapeRotation; } } mHdmiRotationLock = SystemProperties.getBoolean("persist.demo.hdmirotationlock", true); } } public void updateSettings() { public void updateSettings() { Loading Loading @@ -3873,7 +3877,7 @@ public class PhoneWindowManager implements WindowManagerPolicy { // enable 180 degree rotation while docked. // enable 180 degree rotation while docked. preferredRotation = mDeskDockEnablesAccelerometer preferredRotation = mDeskDockEnablesAccelerometer ? sensorRotation : mDeskDockRotation; ? sensorRotation : mDeskDockRotation; } else if (mHdmiPlugged) { } else if (mHdmiPlugged && mHdmiRotationLock) { // Ignore sensor when plugged into HDMI. // Ignore sensor when plugged into HDMI. // Note that the dock orientation overrides the HDMI orientation. // Note that the dock orientation overrides the HDMI orientation. preferredRotation = mHdmiRotation; preferredRotation = mHdmiRotation; Loading Loading @@ -4538,5 +4542,7 @@ public class PhoneWindowManager implements WindowManagerPolicy { pw.print(" mSeascapeRotation="); pw.println(mSeascapeRotation); pw.print(" mSeascapeRotation="); pw.println(mSeascapeRotation); pw.print(prefix); pw.print("mPortraitRotation="); pw.print(mPortraitRotation); pw.print(prefix); pw.print("mPortraitRotation="); pw.print(mPortraitRotation); pw.print(" mUpsideDownRotation="); pw.println(mUpsideDownRotation); pw.print(" mUpsideDownRotation="); pw.println(mUpsideDownRotation); pw.print(prefix); pw.print("mHdmiRotation="); pw.print(mHdmiRotation); pw.print(" mHdmiRotationLock="); pw.println(mHdmiRotationLock); } } } }
services/java/com/android/server/display/DisplayDeviceInfo.java +36 −9 Original line number Original line Diff line number Diff line Loading @@ -17,6 +17,7 @@ package com.android.server.display; package com.android.server.display; import android.util.DisplayMetrics; import android.util.DisplayMetrics; import android.view.Surface; import libcore.util.Objects; import libcore.util.Objects; Loading @@ -31,11 +32,21 @@ final class DisplayDeviceInfo { public static final int FLAG_DEFAULT_DISPLAY = 1 << 0; public static final int FLAG_DEFAULT_DISPLAY = 1 << 0; /** /** * Flag: Indicates that this display device can rotate to show contents in a * Flag: Indicates that the orientation of this display device is coupled to the * different orientation. Otherwise the rotation is assumed to be fixed in the * rotation of its associated logical display. * natural orientation and the display manager should transform the content to fit. * <p> * This flag should be applied to the default display to indicate that the user * physically rotates the display when content is presented in a different orientation. * The display manager will apply a coordinate transformation assuming that the * physical orientation of the display matches the logical orientation of its content. * </p><p> * The flag should not be set when the display device is mounted in a fixed orientation * such as on a desk. The display manager will apply a coordinate transformation * such as a scale and translation to letterbox or pillarbox format under the * assumption that the physical orientation of the display is invariant. * </p> */ */ public static final int FLAG_SUPPORTS_ROTATION = 1 << 1; public static final int FLAG_ROTATES_WITH_CONTENT = 1 << 1; /** /** * Flag: Indicates that this display device has secure video output, such as HDCP. * Flag: Indicates that this display device has secure video output, such as HDCP. Loading Loading @@ -116,6 +127,17 @@ final class DisplayDeviceInfo { */ */ public int touch; public int touch; /** * The additional rotation to apply to all content presented on the display device * relative to its physical coordinate system. Default is {@link Surface#ROTATION_0}. * <p> * This field can be used to compensate for the fact that the display has been * physically rotated relative to its natural orientation such as an HDMI monitor * that has been mounted sideways to appear to be portrait rather than landscape. * </p> */ public int rotation = Surface.ROTATION_0; public void setAssumedDensityForExternalDisplay(int width, int height) { public void setAssumedDensityForExternalDisplay(int width, int height) { densityDpi = Math.min(width, height) * DisplayMetrics.DENSITY_XHIGH / 1080; densityDpi = Math.min(width, height) * DisplayMetrics.DENSITY_XHIGH / 1080; // Technically, these values should be smaller than the apparent density // Technically, these values should be smaller than the apparent density Loading @@ -139,7 +161,8 @@ final class DisplayDeviceInfo { && xDpi == other.xDpi && xDpi == other.xDpi && yDpi == other.yDpi && yDpi == other.yDpi && flags == other.flags && flags == other.flags && touch == other.touch; && touch == other.touch && rotation == other.rotation; } } @Override @Override Loading @@ -157,14 +180,18 @@ final class DisplayDeviceInfo { yDpi = other.yDpi; yDpi = other.yDpi; flags = other.flags; flags = other.flags; touch = other.touch; touch = other.touch; rotation = other.rotation; } } // For debugging purposes // For debugging purposes @Override @Override public String toString() { public String toString() { return "DisplayDeviceInfo{\"" + name + "\": " + width + " x " + height + ", " + refreshRate + " fps, " return "DisplayDeviceInfo{\"" + name + "\": " + width + " x " + height + ", " + refreshRate + " fps, " + "density " + densityDpi + ", " + xDpi + " x " + yDpi + " dpi" + "density " + densityDpi + ", " + xDpi + " x " + yDpi + " dpi" + ", touch " + touchToString(touch) + flagsToString(flags) + "}"; + ", touch " + touchToString(touch) + flagsToString(flags) + ", rotation " + rotation + "}"; } } private static String touchToString(int touch) { private static String touchToString(int touch) { Loading @@ -185,8 +212,8 @@ final class DisplayDeviceInfo { if ((flags & FLAG_DEFAULT_DISPLAY) != 0) { if ((flags & FLAG_DEFAULT_DISPLAY) != 0) { msg.append(", FLAG_DEFAULT_DISPLAY"); msg.append(", FLAG_DEFAULT_DISPLAY"); } } if ((flags & FLAG_SUPPORTS_ROTATION) != 0) { if ((flags & FLAG_ROTATES_WITH_CONTENT) != 0) { msg.append(", FLAG_SUPPORTS_ROTATION"); msg.append(", FLAG_ROTATES_WITH_CONTENT"); } } if ((flags & FLAG_SECURE) != 0) { if ((flags & FLAG_SECURE) != 0) { msg.append(", FLAG_SECURE"); msg.append(", FLAG_SECURE"); Loading
services/java/com/android/server/display/DisplayManagerService.java +15 −0 Original line number Original line Diff line number Diff line Loading @@ -127,6 +127,13 @@ public final class DisplayManagerService extends IDisplayManager.Stub { // services should be started. This option may disable certain display adapters. // services should be started. This option may disable certain display adapters. public boolean mOnlyCore; public boolean mOnlyCore; // True if the display manager service should pretend there is only one display // and only tell applications about the existence of the default logical display. // The display manager can still mirror content to secondary displays but applications // cannot present unique content on those displays. // Used for demonstration purposes only. private final boolean mSingleDisplayDemoMode; // All callback records indexed by calling process id. // All callback records indexed by calling process id. public final SparseArray<CallbackRecord> mCallbacks = public final SparseArray<CallbackRecord> mCallbacks = new SparseArray<CallbackRecord>(); new SparseArray<CallbackRecord>(); Loading Loading @@ -182,6 +189,7 @@ public final class DisplayManagerService extends IDisplayManager.Stub { mHandler = new DisplayManagerHandler(mainHandler.getLooper()); mHandler = new DisplayManagerHandler(mainHandler.getLooper()); mUiHandler = uiHandler; mUiHandler = uiHandler; mDisplayAdapterListener = new DisplayAdapterListener(); mDisplayAdapterListener = new DisplayAdapterListener(); mSingleDisplayDemoMode = SystemProperties.getBoolean("persist.demo.singledisplay", false); mHandler.sendEmptyMessage(MSG_REGISTER_DEFAULT_DISPLAY_ADAPTER); mHandler.sendEmptyMessage(MSG_REGISTER_DEFAULT_DISPLAY_ADAPTER); } } Loading Loading @@ -631,6 +639,12 @@ public final class DisplayManagerService extends IDisplayManager.Stub { isDefault = false; isDefault = false; } } if (!isDefault && mSingleDisplayDemoMode) { Slog.i(TAG, "Not creating a logical display for a secondary display " + " because single display demo mode is enabled: " + deviceInfo); return; } final int displayId = assignDisplayIdLocked(isDefault); final int displayId = assignDisplayIdLocked(isDefault); final int layerStack = assignLayerStackLocked(displayId); final int layerStack = assignLayerStackLocked(displayId); Loading Loading @@ -857,6 +871,7 @@ public final class DisplayManagerService extends IDisplayManager.Stub { pw.println(" mNextNonDefaultDisplayId=" + mNextNonDefaultDisplayId); pw.println(" mNextNonDefaultDisplayId=" + mNextNonDefaultDisplayId); pw.println(" mDefaultViewport=" + mDefaultViewport); pw.println(" mDefaultViewport=" + mDefaultViewport); pw.println(" mExternalTouchViewport=" + mExternalTouchViewport); pw.println(" mExternalTouchViewport=" + mExternalTouchViewport); pw.println(" mSingleDisplayDemoMode=" + mSingleDisplayDemoMode); IndentingPrintWriter ipw = new IndentingPrintWriter(pw, " "); IndentingPrintWriter ipw = new IndentingPrintWriter(pw, " "); ipw.increaseIndent(); ipw.increaseIndent(); Loading
services/java/com/android/server/display/LocalDisplayAdapter.java +8 −1 Original line number Original line Diff line number Diff line Loading @@ -20,6 +20,7 @@ import android.content.Context; import android.os.Handler; import android.os.Handler; import android.os.IBinder; import android.os.IBinder; import android.os.Looper; import android.os.Looper; import android.os.SystemProperties; import android.util.SparseArray; import android.util.SparseArray; import android.view.DisplayEventReceiver; import android.view.DisplayEventReceiver; import android.view.Surface; import android.view.Surface; Loading Loading @@ -135,7 +136,7 @@ final class LocalDisplayAdapter extends DisplayAdapter { mInfo.name = getContext().getResources().getString( mInfo.name = getContext().getResources().getString( com.android.internal.R.string.display_manager_built_in_display_name); com.android.internal.R.string.display_manager_built_in_display_name); mInfo.flags |= DisplayDeviceInfo.FLAG_DEFAULT_DISPLAY mInfo.flags |= DisplayDeviceInfo.FLAG_DEFAULT_DISPLAY | DisplayDeviceInfo.FLAG_SUPPORTS_ROTATION; | DisplayDeviceInfo.FLAG_ROTATES_WITH_CONTENT; mInfo.densityDpi = (int)(mPhys.density * 160 + 0.5f); mInfo.densityDpi = (int)(mPhys.density * 160 + 0.5f); mInfo.xDpi = mPhys.xDpi; mInfo.xDpi = mPhys.xDpi; mInfo.yDpi = mPhys.yDpi; mInfo.yDpi = mPhys.yDpi; Loading @@ -145,6 +146,12 @@ final class LocalDisplayAdapter extends DisplayAdapter { com.android.internal.R.string.display_manager_hdmi_display_name); com.android.internal.R.string.display_manager_hdmi_display_name); mInfo.touch = DisplayDeviceInfo.TOUCH_EXTERNAL; mInfo.touch = DisplayDeviceInfo.TOUCH_EXTERNAL; mInfo.setAssumedDensityForExternalDisplay(mPhys.width, mPhys.height); mInfo.setAssumedDensityForExternalDisplay(mPhys.width, mPhys.height); // For demonstration purposes, allow rotation of the external display. // In the future we might allow the user to configure this directly. if ("portrait".equals(SystemProperties.get("persist.demo.hdmirotation"))) { mInfo.rotation = Surface.ROTATION_270; } } } } } return mInfo; return mInfo; Loading
services/java/com/android/server/display/LogicalDisplay.java +4 −1 Original line number Original line Diff line number Diff line Loading @@ -241,10 +241,13 @@ final class LogicalDisplay { // is rotated when the contents of the logical display are rendered. // is rotated when the contents of the logical display are rendered. int orientation = Surface.ROTATION_0; int orientation = Surface.ROTATION_0; if (device == mPrimaryDisplayDevice if (device == mPrimaryDisplayDevice && (displayDeviceInfo.flags & DisplayDeviceInfo.FLAG_SUPPORTS_ROTATION) != 0) { && (displayDeviceInfo.flags & DisplayDeviceInfo.FLAG_ROTATES_WITH_CONTENT) != 0) { orientation = displayInfo.rotation; orientation = displayInfo.rotation; } } // Apply the physical rotation of the display device itself. orientation = (orientation + displayDeviceInfo.rotation) % 4; // Set the frame. // Set the frame. // The frame specifies the rotated physical coordinates into which the viewport // The frame specifies the rotated physical coordinates into which the viewport // is mapped. We need to take care to preserve the aspect ratio of the viewport. // is mapped. We need to take care to preserve the aspect ratio of the viewport. Loading