diff options
Diffstat (limited to 'services/java')
12 files changed, 492 insertions, 161 deletions
diff --git a/services/java/com/android/server/SystemServer.java b/services/java/com/android/server/SystemServer.java index 2185456..d766afd 100644 --- a/services/java/com/android/server/SystemServer.java +++ b/services/java/com/android/server/SystemServer.java @@ -49,6 +49,7 @@ import com.android.internal.os.SamplingProfilerIntegration; import com.android.internal.widget.LockSettingsService; import com.android.server.accessibility.AccessibilityManagerService; import com.android.server.am.ActivityManagerService; +import com.android.server.display.DisplayManagerService; import com.android.server.input.InputManagerService; import com.android.server.net.NetworkPolicyManagerService; import com.android.server.net.NetworkStatsService; @@ -115,6 +116,7 @@ class ServerThread extends Thread { LightsService lights = null; PowerManagerService power = null; + DisplayManagerService display = null; BatteryService battery = null; VibratorService vibrator = null; AlarmManagerService alarm = null; @@ -148,8 +150,13 @@ class ServerThread extends Thread { power = new PowerManagerService(); ServiceManager.addService(Context.POWER_SERVICE, power); + Slog.i(TAG, "Display Manager"); + display = new DisplayManagerService(); + ServiceManager.addService(Context.DISPLAY_SERVICE, display); + Slog.i(TAG, "Activity Manager"); context = ActivityManagerService.main(factoryTest); + display.setContext(context); Slog.i(TAG, "Telephony Registry"); ServiceManager.addService("telephony.registry", new TelephonyRegistry(context)); @@ -214,7 +221,7 @@ class ServerThread extends Thread { // only initialize the power service after we have started the // lights service, content providers and the battery service. - power.init(context, lights, ActivityManagerService.self(), battery); + power.init(context, lights, ActivityManagerService.self(), battery, display); Slog.i(TAG, "Alarm Manager"); alarm = new AlarmManagerService(context); @@ -225,7 +232,7 @@ class ServerThread extends Thread { ActivityManagerService.self()); Slog.i(TAG, "Window Manager"); - wm = WindowManagerService.main(context, power, + wm = WindowManagerService.main(context, power, display, factoryTest != SystemServer.FACTORY_TEST_LOW_LEVEL, !firstBoot, onlyCore); ServiceManager.addService(Context.WINDOW_SERVICE, wm); diff --git a/services/java/com/android/server/display/DisplayAdapter.java b/services/java/com/android/server/display/DisplayAdapter.java new file mode 100644 index 0000000..e150bf8 --- /dev/null +++ b/services/java/com/android/server/display/DisplayAdapter.java @@ -0,0 +1,35 @@ +/* + * Copyright (C) 2012 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.server.display; + +/** + * A display adapter makes one or more display devices available to the system. + * <p> + * For now, all display adapters are registered in the system server but + * in principle it could be done from other processes. + * </p> + */ +public abstract class DisplayAdapter { + /** + * Gets the display adapter name. + * @return The display adapter name. + */ + public abstract String getName(); + + // TODO: dynamically register display devices + public abstract DisplayDevice[] getDisplayDevices(); +} diff --git a/services/java/com/android/server/display/DisplayDevice.java b/services/java/com/android/server/display/DisplayDevice.java new file mode 100644 index 0000000..6d723f2 --- /dev/null +++ b/services/java/com/android/server/display/DisplayDevice.java @@ -0,0 +1,25 @@ +/* + * Copyright (C) 2012 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.server.display; + +/** + * Represents a physical display device such as the built-in display + * or an external monitor. + */ +public abstract class DisplayDevice { + public abstract void getInfo(DisplayDeviceInfo outInfo); +} diff --git a/services/java/com/android/server/display/DisplayDeviceInfo.java b/services/java/com/android/server/display/DisplayDeviceInfo.java new file mode 100644 index 0000000..c28b9bb --- /dev/null +++ b/services/java/com/android/server/display/DisplayDeviceInfo.java @@ -0,0 +1,54 @@ +/* + * Copyright (C) 2012 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.server.display; + +/** + * Describes the characteristics of a physical display device. + */ +public final class DisplayDeviceInfo { + /** + * The width of the display in its natural orientation, in pixels. + * This value is not affected by display rotation. + */ + public int width; + + /** + * The height of the display in its natural orientation, in pixels. + * This value is not affected by display rotation. + */ + public int height; + + public float refreshRate; + public float density; + public float xDpi; + public float yDpi; + + public void copyFrom(DisplayDeviceInfo other) { + width = other.width; + height = other.height; + refreshRate = other.refreshRate; + density = other.density; + xDpi = other.xDpi; + yDpi = other.yDpi; + } + + @Override + public String toString() { + return width + " x " + height + ", " + refreshRate + " fps, " + + "density " + density + ", " + xDpi + " x " + yDpi + " dpi"; + } +} diff --git a/services/java/com/android/server/display/DisplayManagerService.java b/services/java/com/android/server/display/DisplayManagerService.java new file mode 100644 index 0000000..082d28f --- /dev/null +++ b/services/java/com/android/server/display/DisplayManagerService.java @@ -0,0 +1,155 @@ +/* + * Copyright (C) 2012 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.server.display; + +import android.Manifest; +import android.content.Context; +import android.content.pm.PackageManager; +import android.hardware.display.IDisplayManager; +import android.os.Binder; +import android.os.SystemProperties; +import android.view.Display; +import android.view.DisplayInfo; +import android.view.Surface; + +import java.io.FileDescriptor; +import java.io.PrintWriter; +import java.util.ArrayList; + +/** + * Manages the properties, media routing and power state of attached displays. + * <p> + * The display manager service does not own or directly control the displays. + * Instead, other components in the system register their display adapters with the + * display manager service which acts as a central controller. + * </p> + */ +public final class DisplayManagerService extends IDisplayManager.Stub { + private static final String TAG = "DisplayManagerService"; + + private static final String SYSTEM_HEADLESS = "ro.config.headless"; + + private final Object mLock = new Object(); + + private Context mContext; + private final boolean mHeadless; + private final ArrayList<DisplayAdapter> mDisplayAdapters = new ArrayList<DisplayAdapter>(); + + // TODO: represent this as a map between logical and physical devices + private DisplayInfo mDefaultDisplayInfo; + private DisplayDevice mDefaultDisplayDevice; + private DisplayDeviceInfo mDefaultDisplayDeviceInfo; + + public DisplayManagerService() { + mHeadless = SystemProperties.get(SYSTEM_HEADLESS).equals("1"); + registerDisplayAdapters(); + initializeDefaultDisplay(); + } + + public void setContext(Context context) { + mContext = context; + } + + // FIXME: this isn't the right API for the long term + public void setDefaultDisplayInfo(DisplayInfo info) { + synchronized (mLock) { + mDefaultDisplayInfo.copyFrom(info); + } + } + + // FIXME: this isn't the right API for the long term + public void getDefaultExternalDisplayDeviceInfo(DisplayDeviceInfo info) { + // hardcoded assuming 720p touch screen plugged into HDMI and USB + // need to redesign this + info.width = 1280; + info.height = 720; + } + + public boolean isHeadless() { + return mHeadless; + } + + @Override // Binder call + public boolean getDisplayInfo(int displayId, DisplayInfo outInfo) { + synchronized (mLock) { + if (displayId == Display.DEFAULT_DISPLAY) { + outInfo.copyFrom(mDefaultDisplayInfo); + return true; + } + return false; + } + } + + @Override // Binder call + public void dump(FileDescriptor fd, PrintWriter pw, String[] args) { + if (mContext == null + || mContext.checkCallingOrSelfPermission(Manifest.permission.DUMP) + != PackageManager.PERMISSION_GRANTED) { + pw.println("Permission Denial: can't dump DisplayManager from from pid=" + + Binder.getCallingPid() + ", uid=" + Binder.getCallingUid()); + return; + } + + pw.println("DISPLAY MANAGER (dumpsys display)\n"); + + pw.println("Headless: " + mHeadless); + + DisplayDeviceInfo info = new DisplayDeviceInfo(); + for (DisplayAdapter adapter : mDisplayAdapters) { + pw.println("Displays for adapter " + adapter.getName()); + for (DisplayDevice device : adapter.getDisplayDevices()) { + device.getInfo(info); + pw.print(" "); + pw.println(info); + } + } + } + + private void registerDisplayAdapters() { + if (mHeadless) { + registerDisplayAdapter(new HeadlessDisplayAdapter()); + } else { + registerDisplayAdapter(new SurfaceFlingerDisplayAdapter()); + } + } + + private void registerDisplayAdapter(DisplayAdapter adapter) { + // TODO: do this dynamically + mDisplayAdapters.add(adapter); + mDefaultDisplayDevice = adapter.getDisplayDevices()[0]; + mDefaultDisplayDeviceInfo = new DisplayDeviceInfo(); + mDefaultDisplayDevice.getInfo(mDefaultDisplayDeviceInfo); + } + + private void initializeDefaultDisplay() { + // Bootstrap the default logical display using the default physical display. + mDefaultDisplayInfo = new DisplayInfo(); + mDefaultDisplayInfo.appWidth = mDefaultDisplayDeviceInfo.width; + mDefaultDisplayInfo.appHeight = mDefaultDisplayDeviceInfo.height; + mDefaultDisplayInfo.logicalWidth = mDefaultDisplayDeviceInfo.width; + mDefaultDisplayInfo.logicalHeight = mDefaultDisplayDeviceInfo.height; + mDefaultDisplayInfo.rotation = Surface.ROTATION_0; + mDefaultDisplayInfo.refreshRate = mDefaultDisplayDeviceInfo.refreshRate; + mDefaultDisplayInfo.logicalDensity = mDefaultDisplayDeviceInfo.density; + mDefaultDisplayInfo.physicalXDpi = mDefaultDisplayDeviceInfo.xDpi; + mDefaultDisplayInfo.physicalYDpi = mDefaultDisplayDeviceInfo.yDpi; + mDefaultDisplayInfo.smallestNominalAppWidth = mDefaultDisplayDeviceInfo.width; + mDefaultDisplayInfo.smallestNominalAppHeight = mDefaultDisplayDeviceInfo.height; + mDefaultDisplayInfo.largestNominalAppWidth = mDefaultDisplayDeviceInfo.width; + mDefaultDisplayInfo.largestNominalAppHeight = mDefaultDisplayDeviceInfo.height; + } +} diff --git a/services/java/com/android/server/display/HeadlessDisplayAdapter.java b/services/java/com/android/server/display/HeadlessDisplayAdapter.java new file mode 100644 index 0000000..d2a70d2 --- /dev/null +++ b/services/java/com/android/server/display/HeadlessDisplayAdapter.java @@ -0,0 +1,44 @@ +/* + * Copyright (C) 2012 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.server.display; + +/** + * Provides a fake default display for headless systems. + */ +public final class HeadlessDisplayAdapter extends DisplayAdapter { + private final DisplayDevice mDefaultDisplay = new DisplayDevice() { + @Override + public void getInfo(DisplayDeviceInfo outInfo) { + outInfo.width = 640; + outInfo.height = 480; + outInfo.refreshRate = 60; + outInfo.density = 1.0f; + outInfo.xDpi = 160; + outInfo.yDpi = 160; + } + }; + + @Override + public String getName() { + return "HeadlessDisplayAdapter"; + } + + @Override + public DisplayDevice[] getDisplayDevices() { + return new DisplayDevice[] { mDefaultDisplay }; + } +} diff --git a/services/java/com/android/server/display/SurfaceFlingerDisplayAdapter.java b/services/java/com/android/server/display/SurfaceFlingerDisplayAdapter.java new file mode 100644 index 0000000..89934d3 --- /dev/null +++ b/services/java/com/android/server/display/SurfaceFlingerDisplayAdapter.java @@ -0,0 +1,41 @@ +/* + * Copyright (C) 2012 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.server.display; + +/** + * A display adapter for the displays managed by Surface Flinger. + */ +public final class SurfaceFlingerDisplayAdapter extends DisplayAdapter { + private static native void nativeGetDefaultDisplayDeviceInfo(DisplayDeviceInfo outInfo); + + private final DisplayDevice mDefaultDisplay = new DisplayDevice() { + @Override + public void getInfo(DisplayDeviceInfo outInfo) { + nativeGetDefaultDisplayDeviceInfo(outInfo); + } + }; + + @Override + public String getName() { + return "SurfaceFlingerDisplayAdapter"; + } + + @Override + public DisplayDevice[] getDisplayDevices() { + return new DisplayDevice[] { mDefaultDisplay }; + } +} diff --git a/services/java/com/android/server/power/PowerManagerService.java b/services/java/com/android/server/power/PowerManagerService.java index 2940b70..b3cd0f2 100644 --- a/services/java/com/android/server/power/PowerManagerService.java +++ b/services/java/com/android/server/power/PowerManagerService.java @@ -22,6 +22,7 @@ import com.android.server.EventLogTags; import com.android.server.LightsService; import com.android.server.Watchdog; import com.android.server.am.BatteryStatsService; +import com.android.server.display.DisplayManagerService; import android.app.ActivityManagerNative; import android.app.IActivityManager; @@ -254,6 +255,7 @@ public class PowerManagerService extends IPowerManager.Stub private IActivityManager mActivityService; private IBatteryStats mBatteryStats; private BatteryService mBatteryService; + private DisplayManagerService mDisplayManagerService; private SensorManager mSensorManager; private Sensor mProximitySensor; private Sensor mLightSensor; @@ -543,12 +545,13 @@ public class PowerManagerService extends IPowerManager.Stub private ContentQueryMap mSettings; public void init(Context context, LightsService lights, IActivityManager activity, - BatteryService battery) { + BatteryService battery, DisplayManagerService displayManagerService) { mLightsService = lights; mContext = context; mActivityService = activity; mBatteryStats = BatteryStatsService.getService(); mBatteryService = battery; + mDisplayManagerService = displayManagerService; mLcdLight = lights.getLight(LightsService.LIGHT_ID_BACKLIGHT); mButtonLight = lights.getLight(LightsService.LIGHT_ID_BUTTONS); diff --git a/services/java/com/android/server/wm/DragState.java b/services/java/com/android/server/wm/DragState.java index b2cf3e0..f0b0e1f 100644 --- a/services/java/com/android/server/wm/DragState.java +++ b/services/java/com/android/server/wm/DragState.java @@ -125,8 +125,8 @@ class DragState { // The drag window covers the entire display mDragWindowHandle.frameLeft = 0; mDragWindowHandle.frameTop = 0; - mDragWindowHandle.frameRight = mService.mCurDisplayWidth; - mDragWindowHandle.frameBottom = mService.mCurDisplayHeight; + mDragWindowHandle.frameRight = mService.mDisplayInfo.logicalWidth; + mDragWindowHandle.frameBottom = mService.mDisplayInfo.logicalHeight; // Pause rotations before a drag. if (WindowManagerService.DEBUG_ORIENTATION) { diff --git a/services/java/com/android/server/wm/WindowManagerService.java b/services/java/com/android/server/wm/WindowManagerService.java index d0456ee..ac0fa87 100755 --- a/services/java/com/android/server/wm/WindowManagerService.java +++ b/services/java/com/android/server/wm/WindowManagerService.java @@ -45,6 +45,8 @@ import com.android.server.AttributeCache; import com.android.server.EventLogTags; import com.android.server.Watchdog; import com.android.server.am.BatteryStatsService; +import com.android.server.display.DisplayDeviceInfo; +import com.android.server.display.DisplayManagerService; import com.android.server.input.InputManagerService; import com.android.server.power.PowerManagerService; import com.android.server.power.ShutdownThread; @@ -104,6 +106,7 @@ import android.util.SparseIntArray; import android.util.TypedValue; import android.view.Choreographer; import android.view.Display; +import android.view.DisplayInfo; import android.view.Gravity; import android.view.IApplicationToken; import android.view.IInputFilter; @@ -271,7 +274,6 @@ public class WindowManagerService extends IWindowManager.Stub private static final String SYSTEM_SECURE = "ro.secure"; private static final String SYSTEM_DEBUGGABLE = "ro.debuggable"; - private static final String SYSTEM_HEADLESS = "ro.config.headless"; /** * Condition waited on by {@link #reenableKeyguard} to know the call to @@ -482,14 +484,7 @@ public class WindowManagerService extends IWindowManager.Stub int mInitialDisplayHeight = 0; int mBaseDisplayWidth = 0; int mBaseDisplayHeight = 0; - int mCurDisplayWidth = 0; - int mCurDisplayHeight = 0; - int mAppDisplayWidth = 0; - int mAppDisplayHeight = 0; - int mSmallestDisplayWidth = 0; - int mSmallestDisplayHeight = 0; - int mLargestDisplayWidth = 0; - int mLargestDisplayHeight = 0; + final DisplayInfo mDisplayInfo = new DisplayInfo(); int mRotation = 0; int mForcedAppOrientation = ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED; @@ -616,6 +611,7 @@ public class WindowManagerService extends IWindowManager.Stub float mAnimatorDurationScale = 1.0f; final InputManagerService mInputManager; + final DisplayManagerService mDisplayManager; // Who is holding the screen on. Session mHoldingScreenOn; @@ -785,9 +781,10 @@ public class WindowManagerService extends IWindowManager.Stub final boolean mOnlyCore; public static WindowManagerService main(Context context, - PowerManagerService pm, boolean haveInputMethods, boolean allowBootMsgs, + PowerManagerService pm, DisplayManagerService dm, + boolean haveInputMethods, boolean allowBootMsgs, boolean onlyCore) { - WMThread thr = new WMThread(context, pm, haveInputMethods, allowBootMsgs, onlyCore); + WMThread thr = new WMThread(context, pm, dm, haveInputMethods, allowBootMsgs, onlyCore); thr.start(); synchronized (thr) { @@ -806,15 +803,18 @@ public class WindowManagerService extends IWindowManager.Stub private final Context mContext; private final PowerManagerService mPM; + private final DisplayManagerService mDisplayManager; private final boolean mHaveInputMethods; private final boolean mAllowBootMessages; private final boolean mOnlyCore; public WMThread(Context context, PowerManagerService pm, + DisplayManagerService dm, boolean haveInputMethods, boolean allowBootMsgs, boolean onlyCore) { super("WindowManager"); mContext = context; mPM = pm; + mDisplayManager = dm; mHaveInputMethods = haveInputMethods; mAllowBootMessages = allowBootMsgs; mOnlyCore = onlyCore; @@ -825,7 +825,7 @@ public class WindowManagerService extends IWindowManager.Stub Looper.prepare(); //Looper.myLooper().setMessageLogging(new LogPrinter( // android.util.Log.DEBUG, TAG, android.util.Log.LOG_ID_SYSTEM)); - WindowManagerService s = new WindowManagerService(mContext, mPM, + WindowManagerService s = new WindowManagerService(mContext, mPM, mDisplayManager, mHaveInputMethods, mAllowBootMessages, mOnlyCore); android.os.Process.setThreadPriority( android.os.Process.THREAD_PRIORITY_DISPLAY); @@ -892,6 +892,7 @@ public class WindowManagerService extends IWindowManager.Stub } private WindowManagerService(Context context, PowerManagerService pm, + DisplayManagerService displayManager, boolean haveInputMethods, boolean showBootMsgs, boolean onlyCore) { mContext = context; mHaveInputMethods = haveInputMethods; @@ -899,7 +900,8 @@ public class WindowManagerService extends IWindowManager.Stub mOnlyCore = onlyCore; mLimitedAlphaCompositing = context.getResources().getBoolean( com.android.internal.R.bool.config_sf_limitedAlpha); - mHeadless = "1".equals(SystemProperties.get(SYSTEM_HEADLESS, "0")); + mDisplayManager = displayManager; + mHeadless = displayManager.isHeadless(); mPowerManager = pm; mPowerManager.setPolicy(mPolicy); @@ -1650,8 +1652,8 @@ public class WindowManagerService extends IWindowManager.Stub mInnerFields.mWallpaperMayChange = false; int changed = 0; - final int dw = mAppDisplayWidth; - final int dh = mAppDisplayHeight; + final int dw = mDisplayInfo.appWidth; + final int dh = mDisplayInfo.appHeight; // First find top-most window that has asked to be on top of the // wallpaper; all wallpapers go behind it. @@ -2060,8 +2062,8 @@ public class WindowManagerService extends IWindowManager.Stub } void updateWallpaperOffsetLocked(WindowState changingTarget, boolean sync) { - final int dw = mAppDisplayWidth; - final int dh = mAppDisplayHeight; + final int dw = mDisplayInfo.appWidth; + final int dh = mDisplayInfo.appHeight; WindowState target = mWallpaperTarget; if (target != null) { @@ -2123,8 +2125,8 @@ public class WindowManagerService extends IWindowManager.Stub void updateWallpaperVisibilityLocked() { final boolean visible = isWallpaperVisible(mWallpaperTarget); - final int dw = mAppDisplayWidth; - final int dh = mAppDisplayHeight; + final int dw = mDisplayInfo.appWidth; + final int dh = mDisplayInfo.appHeight; int curTokenIndex = mWallpaperTokens.size(); while (curTokenIndex > 0) { @@ -2699,9 +2701,11 @@ public class WindowManagerService extends IWindowManager.Stub mTmpFloats[Matrix.MSKEW_X] = dsdy; mTmpFloats[Matrix.MSCALE_Y] = dtdy; matrix.setValues(mTmpFloats); - final RectF dispRect = new RectF(0, 0, mCurDisplayWidth, mCurDisplayHeight); + final RectF dispRect = new RectF(0, 0, + mDisplayInfo.logicalWidth, mDisplayInfo.logicalHeight); matrix.mapRect(dispRect); - window.mGivenTouchableRegion.set(0, 0, mCurDisplayWidth, mCurDisplayHeight); + window.mGivenTouchableRegion.set(0, 0, + mDisplayInfo.logicalWidth, mDisplayInfo.logicalHeight); window.mGivenTouchableRegion.op((int)dispRect.left, (int)dispRect.top, (int)dispRect.right, (int)dispRect.bottom, Region.Op.DIFFERENCE); window.mTouchableInsets = ViewTreeObserver.InternalInsetsInfo.TOUCHABLE_INSETS_REGION; @@ -2981,7 +2985,8 @@ public class WindowManagerService extends IWindowManager.Stub configChanged = updateOrientationFromAppTokensLocked(false); performLayoutAndPlaceSurfacesLocked(); if (toBeDisplayed && win.mIsWallpaper) { - updateWallpaperOffsetLocked(win, mAppDisplayWidth, mAppDisplayHeight, false); + updateWallpaperOffsetLocked(win, + mDisplayInfo.appWidth, mDisplayInfo.appHeight, false); } if (win.mAppToken != null) { win.mAppToken.updateReportedVisibilityLocked(); @@ -3201,8 +3206,8 @@ public class WindowManagerService extends IWindowManager.Stub } if (enter) { // Entering app zooms out from the center of the initial rect. - float scaleW = mNextAppTransitionStartWidth / (float) mAppDisplayWidth; - float scaleH = mNextAppTransitionStartHeight / (float) mAppDisplayHeight; + float scaleW = mNextAppTransitionStartWidth / (float) mDisplayInfo.appWidth; + float scaleH = mNextAppTransitionStartHeight / (float) mDisplayInfo.appHeight; Animation scale = new ScaleAnimation(scaleW, 1, scaleH, 1, computePivot(mNextAppTransitionStartX, scaleW), computePivot(mNextAppTransitionStartY, scaleH)); @@ -3222,8 +3227,8 @@ public class WindowManagerService extends IWindowManager.Stub final Interpolator interpolator = AnimationUtils.loadInterpolator(mContext, com.android.internal.R.interpolator.decelerate_cubic); a.setInterpolator(interpolator); - a.initialize(mAppDisplayWidth, mAppDisplayHeight, - mAppDisplayWidth, mAppDisplayHeight); + a.initialize(mDisplayInfo.appWidth, mDisplayInfo.appHeight, + mDisplayInfo.appWidth, mDisplayInfo.appHeight); return a; } @@ -3252,8 +3257,8 @@ public class WindowManagerService extends IWindowManager.Stub if (thumb) { // Animation for zooming thumbnail from its initial size to // filling the screen. - float scaleW = mAppDisplayWidth/thumbWidth; - float scaleH = mAppDisplayHeight/thumbHeight; + float scaleW = mDisplayInfo.appWidth/thumbWidth; + float scaleH = mDisplayInfo.appHeight/thumbHeight; Animation scale = new ScaleAnimation(1, scaleW, 1, scaleH, computePivot(mNextAppTransitionStartX, 1/scaleW), @@ -3273,8 +3278,8 @@ public class WindowManagerService extends IWindowManager.Stub a = set; } else if (enter) { // Entering app zooms out from the center of the thumbnail. - float scaleW = thumbWidth / mAppDisplayWidth; - float scaleH = thumbHeight / mAppDisplayHeight; + float scaleW = thumbWidth / mDisplayInfo.appWidth; + float scaleH = thumbHeight / mDisplayInfo.appHeight; Animation scale = new ScaleAnimation(scaleW, 1, scaleH, 1, computePivot(mNextAppTransitionStartX, scaleW), computePivot(mNextAppTransitionStartY, scaleH)); @@ -3300,8 +3305,8 @@ public class WindowManagerService extends IWindowManager.Stub final Interpolator interpolator = AnimationUtils.loadInterpolator(mContext, com.android.internal.R.interpolator.decelerate_quad); a.setInterpolator(interpolator); - a.initialize(mAppDisplayWidth, mAppDisplayHeight, - mAppDisplayWidth, mAppDisplayHeight); + a.initialize(mDisplayInfo.appWidth, mDisplayInfo.appHeight, + mDisplayInfo.appWidth, mDisplayInfo.appHeight); return a; } @@ -5498,8 +5503,8 @@ public class WindowManagerService extends IWindowManager.Stub synchronized(mWindowMap) { long ident = Binder.clearCallingIdentity(); - dw = mCurDisplayWidth; - dh = mCurDisplayHeight; + dw = mDisplayInfo.logicalWidth; + dh = mDisplayInfo.logicalHeight; int aboveAppLayer = mPolicy.windowTypeToLayerLw( WindowManager.LayoutParams.TYPE_APPLICATION) * TYPE_LAYER_MULTIPLIER @@ -5793,8 +5798,7 @@ public class WindowManagerService extends IWindowManager.Stub mWaitingForConfig = true; mLayoutNeeded = true; startFreezingDisplayLocked(inTransaction); - mInputManager.setDisplayOrientation(0, rotation, - mDisplay != null ? mDisplay.getExternalRotation() : Surface.ROTATION_0); + mInputManager.setDisplayOrientation(0, rotation, Surface.ROTATION_0); // We need to update our screen size information to match the new // rotation. Note that this is redundant with the later call to @@ -5816,7 +5820,7 @@ public class WindowManagerService extends IWindowManager.Stub && mAnimator.mScreenRotationAnimation.hasScreenshot()) { if (mAnimator.mScreenRotationAnimation.setRotation(rotation, mFxSession, MAX_ANIMATION_DURATION, mTransitionAnimationScale, - mCurDisplayWidth, mCurDisplayHeight)) { + mDisplayInfo.logicalWidth, mDisplayInfo.logicalHeight)) { updateLayoutToAnimationLocked(); } } @@ -6315,18 +6319,18 @@ public class WindowManagerService extends IWindowManager.Stub private void adjustDisplaySizeRanges(int rotation, int dw, int dh) { final int width = mPolicy.getConfigDisplayWidth(dw, dh, rotation); - if (width < mSmallestDisplayWidth) { - mSmallestDisplayWidth = width; + if (width < mDisplayInfo.smallestNominalAppWidth) { + mDisplayInfo.smallestNominalAppWidth = width; } - if (width > mLargestDisplayWidth) { - mLargestDisplayWidth = width; + if (width > mDisplayInfo.largestNominalAppWidth) { + mDisplayInfo.largestNominalAppWidth = width; } final int height = mPolicy.getConfigDisplayHeight(dw, dh, rotation); - if (height < mSmallestDisplayHeight) { - mSmallestDisplayHeight = height; + if (height < mDisplayInfo.smallestNominalAppHeight) { + mDisplayInfo.smallestNominalAppHeight = height; } - if (height > mLargestDisplayHeight) { - mLargestDisplayHeight = height; + if (height > mDisplayInfo.largestNominalAppHeight) { + mDisplayInfo.largestNominalAppHeight = height; } } @@ -6423,10 +6427,10 @@ public class WindowManagerService extends IWindowManager.Stub unrotDw = dw; unrotDh = dh; } - mSmallestDisplayWidth = 1<<30; - mSmallestDisplayHeight = 1<<30; - mLargestDisplayWidth = 0; - mLargestDisplayHeight = 0; + mDisplayInfo.smallestNominalAppWidth = 1<<30; + mDisplayInfo.smallestNominalAppHeight = 1<<30; + mDisplayInfo.largestNominalAppWidth = 0; + mDisplayInfo.largestNominalAppHeight = 0; adjustDisplaySizeRanges(Surface.ROTATION_0, unrotDw, unrotDh); adjustDisplaySizeRanges(Surface.ROTATION_90, unrotDh, unrotDw); adjustDisplaySizeRanges(Surface.ROTATION_180, unrotDw, unrotDh); @@ -6437,7 +6441,7 @@ public class WindowManagerService extends IWindowManager.Stub sl = reduceConfigLayout(sl, Surface.ROTATION_90, density, unrotDh, unrotDw); sl = reduceConfigLayout(sl, Surface.ROTATION_180, density, unrotDw, unrotDh); sl = reduceConfigLayout(sl, Surface.ROTATION_270, density, unrotDh, unrotDw); - outConfig.smallestScreenWidthDp = (int)(mSmallestDisplayWidth / density); + outConfig.smallestScreenWidthDp = (int)(mDisplayInfo.smallestNominalAppWidth / density); outConfig.screenLayout = sl; } @@ -6481,33 +6485,25 @@ public class WindowManagerService extends IWindowManager.Stub || mRotation == Surface.ROTATION_270); final int realdw = rotated ? mBaseDisplayHeight : mBaseDisplayWidth; final int realdh = rotated ? mBaseDisplayWidth : mBaseDisplayHeight; + int dw = realdw; + int dh = realdh; - synchronized(mDisplaySizeLock) { - if (mAltOrientation) { - mCurDisplayWidth = realdw; - mCurDisplayHeight = realdh; - if (realdw > realdh) { - // Turn landscape into portrait. - int maxw = (int)(realdh/1.3f); - if (maxw < realdw) { - mCurDisplayWidth = maxw; - } - } else { - // Turn portrait into landscape. - int maxh = (int)(realdw/1.3f); - if (maxh < realdh) { - mCurDisplayHeight = maxh; - } + if (mAltOrientation) { + if (realdw > realdh) { + // Turn landscape into portrait. + int maxw = (int)(realdh/1.3f); + if (maxw < realdw) { + dw = maxw; } } else { - mCurDisplayWidth = realdw; - mCurDisplayHeight = realdh; + // Turn portrait into landscape. + int maxh = (int)(realdw/1.3f); + if (maxh < realdh) { + dh = maxh; + } } } - final int dw = mCurDisplayWidth; - final int dh = mCurDisplayHeight; - if (config != null) { int orientation = Configuration.ORIENTATION_SQUARE; if (dw < dh) { @@ -6518,25 +6514,26 @@ public class WindowManagerService extends IWindowManager.Stub config.orientation = orientation; } - // Update real display metrics. - mDisplay.getMetricsWithSize(mRealDisplayMetrics, mCurDisplayWidth, mCurDisplayHeight); - // Update application display metrics. - final DisplayMetrics dm = mDisplayMetrics; final int appWidth = mPolicy.getNonDecorDisplayWidth(dw, dh, mRotation); final int appHeight = mPolicy.getNonDecorDisplayHeight(dw, dh, mRotation); synchronized(mDisplaySizeLock) { - mAppDisplayWidth = appWidth; - mAppDisplayHeight = appHeight; - mAnimator.setDisplayDimensions(mCurDisplayWidth, mCurDisplayHeight, - mAppDisplayWidth, mAppDisplayHeight); + mDisplayInfo.rotation = mRotation; + mDisplayInfo.logicalWidth = dw; + mDisplayInfo.logicalHeight = dh; + mDisplayInfo.appWidth = appWidth; + mDisplayInfo.appHeight = appHeight; + mDisplayInfo.getLogicalMetrics(mRealDisplayMetrics, null); + mDisplayInfo.getAppMetrics(mDisplayMetrics, null); + mDisplayManager.setDefaultDisplayInfo(mDisplayInfo); + + mAnimator.setDisplayDimensions(dw, dh, appWidth, appHeight); } if (false) { - Slog.i(TAG, "Set app display size: " + mAppDisplayWidth - + " x " + mAppDisplayHeight); + Slog.i(TAG, "Set app display size: " + appWidth + " x " + appHeight); } - mDisplay.getMetricsWithSize(dm, mAppDisplayWidth, mAppDisplayHeight); + final DisplayMetrics dm = mDisplayMetrics; mCompatibleScreenScale = CompatibilityInfo.computeCompatibleScaling(dm, mCompatDisplayMetrics); @@ -6843,27 +6840,26 @@ public class WindowManagerService extends IWindowManager.Stub mDisplay = wm.getDefaultDisplay(); mIsTouchDevice = mContext.getPackageManager().hasSystemFeature( PackageManager.FEATURE_TOUCHSCREEN); + synchronized(mDisplaySizeLock) { - mInitialDisplayWidth = mDisplay.getRawWidth(); - mInitialDisplayHeight = mDisplay.getRawHeight(); - int rot = mDisplay.getRotation(); - if (rot == Surface.ROTATION_90 || rot == Surface.ROTATION_270) { - // If the screen is currently rotated, we need to swap the - // initial width and height to get the true natural values. - int tmp = mInitialDisplayWidth; - mInitialDisplayWidth = mInitialDisplayHeight; - mInitialDisplayHeight = tmp; - } - mBaseDisplayWidth = mCurDisplayWidth = mAppDisplayWidth = mInitialDisplayWidth; - mBaseDisplayHeight = mCurDisplayHeight = mAppDisplayHeight = mInitialDisplayHeight; - mAnimator.setDisplayDimensions(mCurDisplayWidth, mCurDisplayHeight, - mAppDisplayWidth, mAppDisplayHeight); + // Bootstrap the default logical display from the display manager. + mDisplayManager.getDisplayInfo(Display.DEFAULT_DISPLAY, mDisplayInfo); + mInitialDisplayWidth = mDisplayInfo.logicalWidth; + mInitialDisplayHeight = mDisplayInfo.logicalHeight; + mBaseDisplayWidth = mInitialDisplayWidth; + mBaseDisplayHeight = mInitialDisplayHeight; + + mAnimator.setDisplayDimensions(mDisplayInfo.logicalWidth, mDisplayInfo.logicalHeight, + mDisplayInfo.appWidth, mDisplayInfo.appHeight); } + + DisplayDeviceInfo info = new DisplayDeviceInfo(); + mDisplayManager.getDefaultExternalDisplayDeviceInfo(info); mInputManager.setDisplaySize(Display.DEFAULT_DISPLAY, - mDisplay.getRawWidth(), mDisplay.getRawHeight(), - mDisplay.getRawExternalWidth(), mDisplay.getRawExternalHeight()); + mInitialDisplayWidth, mInitialDisplayHeight, + info.width, info.height); mInputManager.setDisplayOrientation(Display.DEFAULT_DISPLAY, - mDisplay.getRotation(), mDisplay.getExternalRotation()); + mDisplay.getRotation(), Surface.ROTATION_0); mPolicy.setInitialDisplaySize(mDisplay, mInitialDisplayWidth, mInitialDisplayHeight); } @@ -7471,20 +7467,6 @@ public class WindowManagerService extends IWindowManager.Stub return false; } - public void getDisplaySize(Point size) { - synchronized(mDisplaySizeLock) { - size.x = mAppDisplayWidth; - size.y = mAppDisplayHeight; - } - } - - public void getRealDisplaySize(Point size) { - synchronized(mDisplaySizeLock) { - size.x = mCurDisplayWidth; - size.y = mCurDisplayHeight; - } - } - public void getInitialDisplaySize(Point size) { synchronized(mDisplaySizeLock) { size.x = mInitialDisplayWidth; @@ -7492,23 +7474,6 @@ public class WindowManagerService extends IWindowManager.Stub } } - public int getMaximumSizeDimension() { - synchronized(mDisplaySizeLock) { - // Do this based on the raw screen size, until we are smarter. - return mBaseDisplayWidth > mBaseDisplayHeight - ? mBaseDisplayWidth : mBaseDisplayHeight; - } - } - - public void getCurrentSizeRange(Point smallestSize, Point largestSize) { - synchronized(mDisplaySizeLock) { - smallestSize.x = mSmallestDisplayWidth; - smallestSize.y = mSmallestDisplayHeight; - largestSize.x = mLargestDisplayWidth; - largestSize.y = mLargestDisplayHeight; - } - } - public void setForcedDisplaySize(int longDimen, int shortDimen) { synchronized(mWindowMap) { int width, height; @@ -7899,8 +7864,8 @@ public class WindowManagerService extends IWindowManager.Stub mLayoutNeeded = false; - final int dw = mCurDisplayWidth; - final int dh = mCurDisplayHeight; + final int dw = mDisplayInfo.logicalWidth; + final int dh = mDisplayInfo.logicalHeight; final int NFW = mFakeWindows.size(); for (int i=0; i<NFW; i++) { @@ -8492,8 +8457,8 @@ public class WindowManagerService extends IWindowManager.Stub if (!mAnimator.isDimming(winAnimator)) { final int width, height; if (attrs.type == WindowManager.LayoutParams.TYPE_BOOT_PROGRESS) { - width = mCurDisplayWidth; - height = mCurDisplayHeight; + width = mDisplayInfo.logicalWidth; + height = mDisplayInfo.logicalHeight; } else { width = innerDw; height = innerDh; @@ -8537,10 +8502,10 @@ public class WindowManagerService extends IWindowManager.Stub } final long currentTime = SystemClock.uptimeMillis(); - final int dw = mCurDisplayWidth; - final int dh = mCurDisplayHeight; - final int innerDw = mAppDisplayWidth; - final int innerDh = mAppDisplayHeight; + final int dw = mDisplayInfo.logicalWidth; + final int dh = mDisplayInfo.logicalHeight; + final int innerDw = mDisplayInfo.appWidth; + final int innerDh = mDisplayInfo.appHeight; int i; @@ -9456,7 +9421,7 @@ public class WindowManagerService extends IWindowManager.Stub } mAnimator.mScreenRotationAnimation = new ScreenRotationAnimation(mContext, - mFxSession, inTransaction, mCurDisplayWidth, mCurDisplayHeight, + mFxSession, inTransaction, mDisplayInfo.logicalWidth, mDisplayInfo.logicalHeight, mDisplay.getRotation()); } } @@ -9486,7 +9451,7 @@ public class WindowManagerService extends IWindowManager.Stub && mAnimator.mScreenRotationAnimation.hasScreenshot()) { if (DEBUG_ORIENTATION) Slog.i(TAG, "**** Dismissing screen rotation animation"); if (mAnimator.mScreenRotationAnimation.dismiss(mFxSession, MAX_ANIMATION_DURATION, - mTransitionAnimationScale, mCurDisplayWidth, mCurDisplayHeight)) { + mTransitionAnimationScale, mDisplayInfo.logicalWidth, mDisplayInfo.logicalHeight)) { updateLayoutToAnimationLocked(); } else { mAnimator.mScreenRotationAnimation.kill(); @@ -9935,19 +9900,21 @@ public class WindowManagerService extends IWindowManager.Stub pw.print(" base="); pw.print(mBaseDisplayWidth); pw.print("x"); pw.print(mBaseDisplayHeight); } - final int rawWidth = mDisplay.getRawWidth(); - final int rawHeight = mDisplay.getRawHeight(); - if (rawWidth != mCurDisplayWidth || rawHeight != mCurDisplayHeight) { - pw.print(" raw="); pw.print(rawWidth); pw.print("x"); pw.print(rawHeight); + if (mInitialDisplayWidth != mDisplayInfo.logicalWidth + || mInitialDisplayHeight != mDisplayInfo.logicalHeight) { + pw.print(" init="); pw.print(mInitialDisplayWidth); + pw.print("x"); pw.print(mInitialDisplayHeight); } pw.print(" cur="); - pw.print(mCurDisplayWidth); pw.print("x"); pw.print(mCurDisplayHeight); + pw.print(mDisplayInfo.logicalWidth); + pw.print("x"); pw.print(mDisplayInfo.logicalHeight); pw.print(" app="); - pw.print(mAppDisplayWidth); pw.print("x"); pw.print(mAppDisplayHeight); - pw.print(" rng="); pw.print(mSmallestDisplayWidth); - pw.print("x"); pw.print(mSmallestDisplayHeight); - pw.print("-"); pw.print(mLargestDisplayWidth); - pw.print("x"); pw.println(mLargestDisplayHeight); + pw.print(mDisplayInfo.appWidth); + pw.print("x"); pw.print(mDisplayInfo.appHeight); + pw.print(" rng="); pw.print(mDisplayInfo.smallestNominalAppWidth); + pw.print("x"); pw.print(mDisplayInfo.smallestNominalAppHeight); + pw.print("-"); pw.print(mDisplayInfo.largestNominalAppWidth); + pw.print("x"); pw.println(mDisplayInfo.largestNominalAppHeight); } else { pw.println(" NO DISPLAY"); } diff --git a/services/java/com/android/server/wm/WindowState.java b/services/java/com/android/server/wm/WindowState.java index 94fd199..d371828 100644 --- a/services/java/com/android/server/wm/WindowState.java +++ b/services/java/com/android/server/wm/WindowState.java @@ -480,7 +480,7 @@ final class WindowState implements WindowManagerPolicy.WindowState { if (mIsWallpaper && (fw != frame.width() || fh != frame.height())) { mService.updateWallpaperOffsetLocked(this, - mService.mAppDisplayWidth, mService.mAppDisplayHeight, false); + mService.mDisplayInfo.appWidth, mService.mDisplayInfo.appHeight, false); } if (WindowManagerService.localLOGV) { diff --git a/services/java/com/android/server/wm/WindowStateAnimator.java b/services/java/com/android/server/wm/WindowStateAnimator.java index f08204f..ce87f4c 100644 --- a/services/java/com/android/server/wm/WindowStateAnimator.java +++ b/services/java/com/android/server/wm/WindowStateAnimator.java @@ -151,8 +151,8 @@ class WindowStateAnimator { mAnimator = service.mAnimator; mPolicy = service.mPolicy; mContext = service.mContext; - mAnimDw = service.mAppDisplayWidth; - mAnimDh = service.mAppDisplayHeight; + mAnimDw = service.mDisplayInfo.appWidth; + mAnimDh = service.mDisplayInfo.appHeight; mWin = win; mAttachedWinAnimator = win.mAttachedWindow == null @@ -248,8 +248,8 @@ class WindowStateAnimator { " scale=" + mService.mWindowAnimationScale); mAnimation.initialize(mWin.mFrame.width(), mWin.mFrame.height(), mAnimDw, mAnimDh); - mAnimDw = mService.mAppDisplayWidth; - mAnimDh = mService.mAppDisplayHeight; + mAnimDw = mService.mDisplayInfo.appWidth; + mAnimDh = mService.mDisplayInfo.appHeight; mAnimation.setStartTime(currentTime); mLocalAnimating = true; mAnimating = true; @@ -1102,7 +1102,7 @@ class WindowStateAnimator { WindowManagerPolicy.FINISH_LAYOUT_REDO_WALLPAPER; if ((w.mAttrs.flags & LayoutParams.FLAG_DIM_BEHIND) != 0) { mService.startDimming(this, w.mExiting ? 0 : w.mAttrs.dimAmount, - mService.mAppDisplayWidth, mService.mAppDisplayHeight); + mService.mDisplayInfo.appWidth, mService.mDisplayInfo.appHeight); } } catch (RuntimeException e) { // If something goes wrong with the surface (such |