summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDohyun Lee <dohyun.lee@lge.com>2015-03-21 17:03:04 +0900
committerSteve Kondik <steve@cyngn.com>2015-11-07 13:11:52 -0800
commit6d4a04ab3082ceb9bef6beb5d50ebc6abe2a33de (patch)
tree2c40fa52e1f12d677fb00eb6168af3640f522c27
parent32ed0738affd158b7f8fd7ce978aafda38d8d8b6 (diff)
downloadframeworks_base-6d4a04ab3082ceb9bef6beb5d50ebc6abe2a33de.zip
frameworks_base-6d4a04ab3082ceb9bef6beb5d50ebc6abe2a33de.tar.gz
frameworks_base-6d4a04ab3082ceb9bef6beb5d50ebc6abe2a33de.tar.bz2
Assign more reasonable width and height of a window surface
When the surface of a window is created during relayoutWindow, there is the case that the width and height of the surface are not given appropriately, e.g. the staring windows. In this case, the width and height are set to 1, which cause resizing the size of the surface during setSurfaceBoundariesLocked. Since setting the size of a surface is processed synchronously in the SurfaceFlinger, there is usually a few milliseconds delay (up to 1 vsync interval) when we launch an application. To remove such cases, this patch assign the width and height more reasonably like below: 1. If FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS is set then assign the size of the display we can use. (i.e. DisplayInfo.logical[Width|Height]) 2. Otherwise, assign the width and height of the portion of the display that is available to applications. (i.e. DisplayInfo.app[Width|Height]) Change-Id: Ie8265b9ff0fdb6ecc4577687935adf7cfb4439ad Signed-off-by: Dohyun Lee <dohyun.lee@lge.com>
-rw-r--r--services/core/java/com/android/server/wm/WindowManagerService.java1
-rw-r--r--services/core/java/com/android/server/wm/WindowStateAnimator.java28
2 files changed, 24 insertions, 5 deletions
diff --git a/services/core/java/com/android/server/wm/WindowManagerService.java b/services/core/java/com/android/server/wm/WindowManagerService.java
index 54115d0..f0cbbb4 100644
--- a/services/core/java/com/android/server/wm/WindowManagerService.java
+++ b/services/core/java/com/android/server/wm/WindowManagerService.java
@@ -155,6 +155,7 @@ import static android.view.WindowManager.LayoutParams.FIRST_APPLICATION_WINDOW;
import static android.view.WindowManager.LayoutParams.FIRST_SUB_WINDOW;
import static android.view.WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM;
import static android.view.WindowManager.LayoutParams.FLAG_DIM_BEHIND;
+import static android.view.WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS;
import static android.view.WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON;
import static android.view.WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE;
import static android.view.WindowManager.LayoutParams.FLAG_SECURE;
diff --git a/services/core/java/com/android/server/wm/WindowStateAnimator.java b/services/core/java/com/android/server/wm/WindowStateAnimator.java
index 726d29d..308aa67 100644
--- a/services/core/java/com/android/server/wm/WindowStateAnimator.java
+++ b/services/core/java/com/android/server/wm/WindowStateAnimator.java
@@ -29,6 +29,7 @@ import static com.android.server.wm.WindowManagerService.SHOW_SURFACE_ALLOC;
import static com.android.server.wm.WindowManagerService.localLOGV;
import static com.android.server.wm.WindowManagerService.LayoutFields.SET_ORIENTATION_CHANGE_COMPLETE;
import static com.android.server.wm.WindowManagerService.LayoutFields.SET_TURN_ON_SCREEN;
+import static android.view.WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS;
import android.content.Context;
import android.graphics.Matrix;
@@ -791,6 +792,24 @@ class WindowStateAnimator {
flags |= SurfaceControl.SECURE;
}
+ final boolean consumingNavBar =
+ (attrs.flags & FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS) != 0
+ && (attrs.systemUiVisibility & View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION) == 0
+ && (attrs.systemUiVisibility & View.SYSTEM_UI_FLAG_HIDE_NAVIGATION) == 0;
+
+ final DisplayContent displayContent = w.getDisplayContent();
+
+ int defaultWidth = 1;
+ int defaultHeight = 1;
+ if (displayContent != null) {
+ final DisplayInfo displayInfo = displayContent.getDisplayInfo();
+ // When we need to expand the window with FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS,
+ // set the default width and height of the window to the size of the display
+ // we can use.
+ defaultWidth = consumingNavBar ? displayInfo.logicalWidth : displayInfo.appWidth;
+ defaultHeight = consumingNavBar ? displayInfo.logicalHeight : displayInfo.appHeight;
+ }
+
int width;
int height;
if ((attrs.flags & LayoutParams.FLAG_SCALED) != 0) {
@@ -799,17 +818,17 @@ class WindowStateAnimator {
width = w.mRequestedWidth;
height = w.mRequestedHeight;
} else {
- width = w.mCompatFrame.width();
- height = w.mCompatFrame.height();
+ width = consumingNavBar ? defaultWidth : w.mCompatFrame.width();
+ height = consumingNavBar ? defaultHeight : w.mCompatFrame.height();
}
// Something is wrong and SurfaceFlinger will not like this,
// try to revert to sane values
if (width <= 0) {
- width = 1;
+ width = defaultWidth;
}
if (height <= 0) {
- height = 1;
+ height = defaultHeight;
}
float left = w.mFrame.left + w.mXOffset;
@@ -916,7 +935,6 @@ class WindowStateAnimator {
try {
mSurfaceControl.setPosition(left, top);
mSurfaceLayer = mAnimLayer;
- final DisplayContent displayContent = w.getDisplayContent();
if (displayContent != null) {
mSurfaceControl.setLayerStack(displayContent.getDisplay().getLayerStack());
}