diff options
author | Doris Liu <tianliu@google.com> | 2015-06-01 13:18:43 -0700 |
---|---|---|
committer | Doris Liu <tianliu@google.com> | 2015-06-01 17:34:20 -0700 |
commit | 06d582d4e42893e7e061477004d991d35b5f0d78 (patch) | |
tree | 4497b34765e519afb96cfe8058eafe2a0a7a4d5d /services/core/java/com/android/server/wm | |
parent | 63428ccde7e925ceb94aa40e933b3d51954a7797 (diff) | |
download | frameworks_base-06d582d4e42893e7e061477004d991d35b5f0d78.zip frameworks_base-06d582d4e42893e7e061477004d991d35b5f0d78.tar.gz frameworks_base-06d582d4e42893e7e061477004d991d35b5f0d78.tar.bz2 |
Fix calls to Rect.intersect(Rect) in package com.android.server.wm
This CL checks for the return value for Rect.intersect(Rect) for whether
there is actually an intersection before taking the calling rect as the
intersection. In addtion, this CL handles the cases where there is no
intersection (Rect.intersect(Rect) returns false).
bug: 7368679
Change-Id: I7d5ef7059ac432170470a108c0d6dece230ec0b3
Diffstat (limited to 'services/core/java/com/android/server/wm')
4 files changed, 19 insertions, 5 deletions
diff --git a/services/core/java/com/android/server/wm/DisplayContent.java b/services/core/java/com/android/server/wm/DisplayContent.java index f914369..5d6df26 100644 --- a/services/core/java/com/android/server/wm/DisplayContent.java +++ b/services/core/java/com/android/server/wm/DisplayContent.java @@ -238,6 +238,7 @@ class DisplayContent { final TaskStack stack = win.getStack(); if (win.isVisibleLw() && stack != null && stack != focusedStack) { mTmpRect.set(win.mVisibleFrame); + // If no intersection, we need mTmpRect to be unmodified. mTmpRect.intersect(win.mVisibleInsets); mTouchExcludeRegion.op(mTmpRect, Region.Op.DIFFERENCE); } diff --git a/services/core/java/com/android/server/wm/TaskStack.java b/services/core/java/com/android/server/wm/TaskStack.java index 7cdf8b2..4545032 100644 --- a/services/core/java/com/android/server/wm/TaskStack.java +++ b/services/core/java/com/android/server/wm/TaskStack.java @@ -144,7 +144,11 @@ public class TaskStack { bounds = mTmpRect; mFullscreen = true; } else { - bounds.intersect(mTmpRect); // ensure bounds are entirely within the display rect + // ensure bounds are entirely within the display rect + if (!bounds.intersect(mTmpRect)) { + // Can't set bounds outside the containing display.. Sorry! + return false; + } mFullscreen = mTmpRect.equals(bounds); } } diff --git a/services/core/java/com/android/server/wm/WindowManagerService.java b/services/core/java/com/android/server/wm/WindowManagerService.java index 5d8979f..6bc089d 100644 --- a/services/core/java/com/android/server/wm/WindowManagerService.java +++ b/services/core/java/com/android/server/wm/WindowManagerService.java @@ -6221,7 +6221,10 @@ public class WindowManagerService extends IWindowManager.Stub int bottom = wf.bottom - cr.bottom; frame.union(left, top, right, bottom); ws.getStackBounds(stackBounds); - frame.intersect(stackBounds); + if (!frame.intersect(stackBounds)) { + // Set frame empty if there's no intersection. + frame.setEmpty(); + } } if (ws.mAppToken != null && ws.mAppToken.token == appToken && @@ -6268,12 +6271,16 @@ public class WindowManagerService extends IWindowManager.Stub if (!includeFullDisplay) { // Constrain frame to the screen size. - frame.intersect(0, 0, dw, dh); + if (!frame.intersect(0, 0, dw, dh)) { + frame.setEmpty(); + } } else { // Caller just wants entire display. frame.set(0, 0, dw, dh); } - + if (frame.isEmpty()) { + return null; + } if (width < 0) { width = frame.width(); diff --git a/services/core/java/com/android/server/wm/WindowState.java b/services/core/java/com/android/server/wm/WindowState.java index 193d812..62a8420 100644 --- a/services/core/java/com/android/server/wm/WindowState.java +++ b/services/core/java/com/android/server/wm/WindowState.java @@ -534,7 +534,9 @@ final class WindowState implements WindowManagerPolicy.WindowState { } // Make sure the containing frame is within the content frame so we don't layout // resized window under screen decorations. - mContainingFrame.intersect(cf); + if (!mContainingFrame.intersect(cf)) { + mContainingFrame.set(cf); + } mDisplayFrame.set(mContainingFrame); } else { mContainingFrame.set(pf); |