Merge "Report bounds instead of size in WindowMetrics" into rvc-dev am: 363edf449a am: f8bb4fef74
Change-Id: I03b8e519c34c4c9318239540a20d6923672b2272
This commit is contained in:
@@ -55767,8 +55767,8 @@ package android.view {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public final class WindowMetrics {
|
public final class WindowMetrics {
|
||||||
ctor public WindowMetrics(@NonNull android.util.Size, @NonNull android.view.WindowInsets);
|
ctor public WindowMetrics(@NonNull android.graphics.Rect, @NonNull android.view.WindowInsets);
|
||||||
method @NonNull public android.util.Size getSize();
|
method @NonNull public android.graphics.Rect getBounds();
|
||||||
method @NonNull public android.view.WindowInsets getWindowInsets();
|
method @NonNull public android.view.WindowInsets getWindowInsets();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -60,7 +60,6 @@ import android.text.method.MovementMethod;
|
|||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.util.PrintWriterPrinter;
|
import android.util.PrintWriterPrinter;
|
||||||
import android.util.Printer;
|
import android.util.Printer;
|
||||||
import android.util.Size;
|
|
||||||
import android.view.Gravity;
|
import android.view.Gravity;
|
||||||
import android.view.KeyCharacterMap;
|
import android.view.KeyCharacterMap;
|
||||||
import android.view.KeyEvent;
|
import android.view.KeyEvent;
|
||||||
@@ -1480,8 +1479,8 @@ public class InputMethodService extends AbstractInputMethodService {
|
|||||||
*/
|
*/
|
||||||
public int getMaxWidth() {
|
public int getMaxWidth() {
|
||||||
final WindowManager windowManager = getSystemService(WindowManager.class);
|
final WindowManager windowManager = getSystemService(WindowManager.class);
|
||||||
final Size windowSize = windowManager.getCurrentWindowMetrics().getSize();
|
final Rect windowBounds = windowManager.getCurrentWindowMetrics().getBounds();
|
||||||
return windowSize.getWidth();
|
return windowBounds.width();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -57,8 +57,8 @@ import java.util.List;
|
|||||||
* <li>The application display area specifies the part of the display that may contain
|
* <li>The application display area specifies the part of the display that may contain
|
||||||
* an application window, excluding the system decorations. The application display area may
|
* an application window, excluding the system decorations. The application display area may
|
||||||
* be smaller than the real display area because the system subtracts the space needed
|
* be smaller than the real display area because the system subtracts the space needed
|
||||||
* for decor elements such as the status bar. Use {@link WindowMetrics#getSize()} to query the
|
* for decor elements such as the status bar. Use {@link WindowMetrics#getBounds()} to query the
|
||||||
* application window size.</li>
|
* application window bounds.</li>
|
||||||
* <li>The real display area specifies the part of the display that contains content
|
* <li>The real display area specifies the part of the display that contains content
|
||||||
* including the system decorations. Even so, the real display area may be smaller than the
|
* including the system decorations. Even so, the real display area may be smaller than the
|
||||||
* physical size of the display if the window manager is emulating a smaller display
|
* physical size of the display if the window manager is emulating a smaller display
|
||||||
@@ -673,7 +673,7 @@ public final class Display {
|
|||||||
*
|
*
|
||||||
* @param outSize A {@link Point} object to receive the size information.
|
* @param outSize A {@link Point} object to receive the size information.
|
||||||
* @deprecated Use {@link WindowManager#getCurrentWindowMetrics()} to obtain an instance of
|
* @deprecated Use {@link WindowManager#getCurrentWindowMetrics()} to obtain an instance of
|
||||||
* {@link WindowMetrics} and use {@link WindowMetrics#getSize()} instead.
|
* {@link WindowMetrics} and use {@link WindowMetrics#getBounds()} instead.
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public void getSize(Point outSize) {
|
public void getSize(Point outSize) {
|
||||||
@@ -689,7 +689,7 @@ public final class Display {
|
|||||||
* Gets the size of the display as a rectangle, in pixels.
|
* Gets the size of the display as a rectangle, in pixels.
|
||||||
*
|
*
|
||||||
* @param outSize A {@link Rect} object to receive the size information.
|
* @param outSize A {@link Rect} object to receive the size information.
|
||||||
* @deprecated Use {@link WindowMetrics#getSize()} to get the dimensions of the application
|
* @deprecated Use {@link WindowMetrics#getBounds()} to get the dimensions of the application
|
||||||
* window area.
|
* window area.
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
@@ -755,7 +755,7 @@ public final class Display {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @deprecated Use {@link WindowMetrics#getSize()} instead.
|
* @deprecated Use {@link WindowMetrics#getBounds#width()} instead.
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public int getWidth() {
|
public int getWidth() {
|
||||||
@@ -766,7 +766,7 @@ public final class Display {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @deprecated Use {@link WindowMetrics#getSize()} instead.
|
* @deprecated Use {@link WindowMetrics#getBounds()#height()} instead.
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public int getHeight() {
|
public int getHeight() {
|
||||||
@@ -1105,7 +1105,7 @@ public final class Display {
|
|||||||
* </p>
|
* </p>
|
||||||
*
|
*
|
||||||
* @param outMetrics A {@link DisplayMetrics} object to receive the metrics.
|
* @param outMetrics A {@link DisplayMetrics} object to receive the metrics.
|
||||||
* @deprecated Use {@link WindowMetrics#getSize()} to get the dimensions of the application
|
* @deprecated Use {@link WindowMetrics#getBounds()} to get the dimensions of the application
|
||||||
* window area, and {@link Configuration#densityDpi} to get the current density.
|
* window area, and {@link Configuration#densityDpi} to get the current density.
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
|
|||||||
@@ -23,11 +23,11 @@ import android.compat.annotation.UnsupportedAppUsage;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.res.Configuration;
|
import android.content.res.Configuration;
|
||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
|
import android.graphics.Rect;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.RemoteException;
|
import android.os.RemoteException;
|
||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
import android.util.DisplayMetrics;
|
import android.util.DisplayMetrics;
|
||||||
import android.util.Size;
|
|
||||||
import android.util.SparseArray;
|
import android.util.SparseArray;
|
||||||
import android.util.TypedValue;
|
import android.util.TypedValue;
|
||||||
|
|
||||||
@@ -410,8 +410,8 @@ public class ViewConfiguration {
|
|||||||
|
|
||||||
// Size of the screen in bytes, in ARGB_8888 format
|
// Size of the screen in bytes, in ARGB_8888 format
|
||||||
final WindowManager windowManager = context.getSystemService(WindowManager.class);
|
final WindowManager windowManager = context.getSystemService(WindowManager.class);
|
||||||
final Size maxWindowSize = windowManager.getMaximumWindowMetrics().getSize();
|
final Rect maxWindowBounds = windowManager.getMaximumWindowMetrics().getBounds();
|
||||||
mMaximumDrawingCacheSize = 4 * maxWindowSize.getWidth() * maxWindowSize.getHeight();
|
mMaximumDrawingCacheSize = 4 * maxWindowBounds.width() * maxWindowBounds.height();
|
||||||
|
|
||||||
mOverscrollDistance = (int) (sizeAndDensity * OVERSCROLL_DISTANCE + 0.5f);
|
mOverscrollDistance = (int) (sizeAndDensity * OVERSCROLL_DISTANCE + 0.5f);
|
||||||
mOverflingDistance = (int) (sizeAndDensity * OVERFLING_DISTANCE + 0.5f);
|
mOverflingDistance = (int) (sizeAndDensity * OVERFLING_DISTANCE + 0.5f);
|
||||||
|
|||||||
@@ -35,7 +35,6 @@ import android.graphics.Region;
|
|||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.IBinder;
|
import android.os.IBinder;
|
||||||
import android.os.RemoteException;
|
import android.os.RemoteException;
|
||||||
import android.util.Size;
|
|
||||||
|
|
||||||
import com.android.internal.os.IResultReceiver;
|
import com.android.internal.os.IResultReceiver;
|
||||||
|
|
||||||
@@ -220,7 +219,7 @@ public final class WindowManagerImpl implements WindowManager {
|
|||||||
final Context context = mParentWindow != null ? mParentWindow.getContext() : mContext;
|
final Context context = mParentWindow != null ? mParentWindow.getContext() : mContext;
|
||||||
final Rect bounds = getCurrentBounds(context);
|
final Rect bounds = getCurrentBounds(context);
|
||||||
|
|
||||||
return new WindowMetrics(toSize(bounds), computeWindowInsets(bounds));
|
return new WindowMetrics(bounds, computeWindowInsets(bounds));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Rect getCurrentBounds(Context context) {
|
private static Rect getCurrentBounds(Context context) {
|
||||||
@@ -232,11 +231,7 @@ public final class WindowManagerImpl implements WindowManager {
|
|||||||
@Override
|
@Override
|
||||||
public WindowMetrics getMaximumWindowMetrics() {
|
public WindowMetrics getMaximumWindowMetrics() {
|
||||||
final Rect maxBounds = getMaximumBounds();
|
final Rect maxBounds = getMaximumBounds();
|
||||||
return new WindowMetrics(toSize(maxBounds), computeWindowInsets(maxBounds));
|
return new WindowMetrics(maxBounds, computeWindowInsets(maxBounds));
|
||||||
}
|
|
||||||
|
|
||||||
private Size toSize(Rect frame) {
|
|
||||||
return new Size(frame.width(), frame.height());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private Rect getMaximumBounds() {
|
private Rect getMaximumBounds() {
|
||||||
|
|||||||
@@ -18,10 +18,10 @@ package android.view;
|
|||||||
|
|
||||||
import android.annotation.NonNull;
|
import android.annotation.NonNull;
|
||||||
import android.graphics.Point;
|
import android.graphics.Point;
|
||||||
import android.util.Size;
|
import android.graphics.Rect;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Metrics about a Window, consisting of the size and {@link WindowInsets}.
|
* Metrics about a Window, consisting of the bounds and {@link WindowInsets}.
|
||||||
* <p>
|
* <p>
|
||||||
* This is usually obtained from {@link WindowManager#getCurrentWindowMetrics()} and
|
* This is usually obtained from {@link WindowManager#getCurrentWindowMetrics()} and
|
||||||
* {@link WindowManager#getMaximumWindowMetrics()}.
|
* {@link WindowManager#getMaximumWindowMetrics()}.
|
||||||
@@ -31,21 +31,22 @@ import android.util.Size;
|
|||||||
* @see WindowManager#getMaximumWindowMetrics()
|
* @see WindowManager#getMaximumWindowMetrics()
|
||||||
*/
|
*/
|
||||||
public final class WindowMetrics {
|
public final class WindowMetrics {
|
||||||
private final @NonNull Size mSize;
|
private final @NonNull Rect mBounds;
|
||||||
private final @NonNull WindowInsets mWindowInsets;
|
private final @NonNull WindowInsets mWindowInsets;
|
||||||
|
|
||||||
public WindowMetrics(@NonNull Size size, @NonNull WindowInsets windowInsets) {
|
public WindowMetrics(@NonNull Rect bounds, @NonNull WindowInsets windowInsets) {
|
||||||
mSize = size;
|
mBounds = bounds;
|
||||||
mWindowInsets = windowInsets;
|
mWindowInsets = windowInsets;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the size of the window.
|
* Returns the bounds of the area associated with this window or visual context.
|
||||||
* <p>
|
* <p>
|
||||||
* <b>Note that this reports a different size than {@link Display#getSize(Point)}.</b>
|
* <b>Note that the size of the reported bounds can have different size than
|
||||||
* This method reports the window size including all system bars area, while
|
* {@link Display#getSize(Point)}.</b> This method reports the window size including all system
|
||||||
* {@link Display#getSize(Point)} reports the area excluding navigation bars and display cutout
|
* bar areas, while {@link Display#getSize(Point)} reports the area excluding navigation bars
|
||||||
* areas. The value reported by {@link Display#getSize(Point)} can be obtained by using:
|
* and display cutout areas. The value reported by {@link Display#getSize(Point)} can be
|
||||||
|
* obtained by using:
|
||||||
* <pre class="prettyprint">
|
* <pre class="prettyprint">
|
||||||
* final WindowMetrics metrics = windowManager.getCurrentMetrics();
|
* final WindowMetrics metrics = windowManager.getCurrentMetrics();
|
||||||
* // Gets all excluding insets
|
* // Gets all excluding insets
|
||||||
@@ -66,16 +67,16 @@ public final class WindowMetrics {
|
|||||||
* </pre>
|
* </pre>
|
||||||
* </p>
|
* </p>
|
||||||
*
|
*
|
||||||
* @return window size in pixel.
|
* @return window bounds in pixels.
|
||||||
*/
|
*/
|
||||||
public @NonNull Size getSize() {
|
public @NonNull Rect getBounds() {
|
||||||
return mSize;
|
return mBounds;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the {@link WindowInsets} of the window.
|
* Returns the {@link WindowInsets} of the area associated with this window or visual context.
|
||||||
*
|
*
|
||||||
* @return the {@link WindowInsets} of the window.
|
* @return the {@link WindowInsets} of the visual area.
|
||||||
*/
|
*/
|
||||||
public @NonNull WindowInsets getWindowInsets() {
|
public @NonNull WindowInsets getWindowInsets() {
|
||||||
return mWindowInsets;
|
return mWindowInsets;
|
||||||
|
|||||||
@@ -25,7 +25,6 @@ import android.os.IBinder;
|
|||||||
import android.os.RemoteException;
|
import android.os.RemoteException;
|
||||||
import android.transition.Transition;
|
import android.transition.Transition;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.util.Size;
|
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.View.OnTouchListener;
|
import android.view.View.OnTouchListener;
|
||||||
import android.view.ViewTreeObserver;
|
import android.view.ViewTreeObserver;
|
||||||
@@ -129,10 +128,10 @@ public class AutofillPopupWindow extends PopupWindow {
|
|||||||
// Gravity.BOTTOM because PopupWindow base class does not expose computeGravity().
|
// Gravity.BOTTOM because PopupWindow base class does not expose computeGravity().
|
||||||
final WindowManager windowManager = anchor.getContext()
|
final WindowManager windowManager = anchor.getContext()
|
||||||
.getSystemService(WindowManager.class);
|
.getSystemService(WindowManager.class);
|
||||||
final Size windowSize = windowManager.getCurrentWindowMetrics().getSize();
|
final Rect windowBounds = windowManager.getCurrentWindowMetrics().getBounds();
|
||||||
width = windowSize.getWidth();
|
width = windowBounds.width();
|
||||||
if (height != LayoutParams.MATCH_PARENT) {
|
if (height != LayoutParams.MATCH_PARENT) {
|
||||||
offsetY = windowSize.getHeight() - height;
|
offsetY = windowBounds.height() - height;
|
||||||
}
|
}
|
||||||
actualAnchor = anchor;
|
actualAnchor = anchor;
|
||||||
} else if (virtualBounds != null) {
|
} else if (virtualBounds != null) {
|
||||||
|
|||||||
@@ -22,14 +22,10 @@ import android.annotation.Nullable;
|
|||||||
import android.annotation.StyleRes;
|
import android.annotation.StyleRes;
|
||||||
import android.compat.annotation.UnsupportedAppUsage;
|
import android.compat.annotation.UnsupportedAppUsage;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.graphics.Point;
|
|
||||||
import android.graphics.Rect;
|
import android.graphics.Rect;
|
||||||
import android.util.Size;
|
|
||||||
import android.view.Display;
|
|
||||||
import android.view.Gravity;
|
import android.view.Gravity;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.WindowManager;
|
import android.view.WindowManager;
|
||||||
import android.view.WindowMetrics;
|
|
||||||
import android.widget.PopupWindow.OnDismissListener;
|
import android.widget.PopupWindow.OnDismissListener;
|
||||||
|
|
||||||
import com.android.internal.view.menu.MenuPresenter.Callback;
|
import com.android.internal.view.menu.MenuPresenter.Callback;
|
||||||
@@ -227,9 +223,9 @@ public class MenuPopupHelper implements MenuHelper {
|
|||||||
@NonNull
|
@NonNull
|
||||||
private MenuPopup createPopup() {
|
private MenuPopup createPopup() {
|
||||||
final WindowManager windowManager = mContext.getSystemService(WindowManager.class);
|
final WindowManager windowManager = mContext.getSystemService(WindowManager.class);
|
||||||
final Size maxWindowSize = windowManager.getMaximumWindowMetrics().getSize();
|
final Rect maxWindowBounds = windowManager.getMaximumWindowMetrics().getBounds();
|
||||||
|
|
||||||
final int smallestWidth = Math.min(maxWindowSize.getWidth(), maxWindowSize.getHeight());
|
final int smallestWidth = Math.min(maxWindowBounds.width(), maxWindowBounds.height());
|
||||||
final int minSmallestWidthCascading = mContext.getResources().getDimensionPixelSize(
|
final int minSmallestWidthCascading = mContext.getResources().getDimensionPixelSize(
|
||||||
com.android.internal.R.dimen.cascading_menus_min_smallest_width);
|
com.android.internal.R.dimen.cascading_menus_min_smallest_width);
|
||||||
final boolean enableCascadingSubmenus = smallestWidth >= minSmallestWidthCascading;
|
final boolean enableCascadingSubmenus = smallestWidth >= minSmallestWidthCascading;
|
||||||
|
|||||||
@@ -25,13 +25,13 @@ import android.app.Service;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.graphics.Color;
|
import android.graphics.Color;
|
||||||
|
import android.graphics.Rect;
|
||||||
import android.hardware.display.DisplayManager;
|
import android.hardware.display.DisplayManager;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.IBinder;
|
import android.os.IBinder;
|
||||||
import android.os.Process;
|
import android.os.Process;
|
||||||
import android.os.RemoteException;
|
import android.os.RemoteException;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.util.Size;
|
|
||||||
import android.view.Display;
|
import android.view.Display;
|
||||||
import android.view.Gravity;
|
import android.view.Gravity;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
@@ -119,15 +119,15 @@ public class TestService extends Service {
|
|||||||
@Override
|
@Override
|
||||||
public void showApplicationOverlay() throws RemoteException {
|
public void showApplicationOverlay() throws RemoteException {
|
||||||
final WindowManager wm = mOverlayContext.getSystemService(WindowManager.class);
|
final WindowManager wm = mOverlayContext.getSystemService(WindowManager.class);
|
||||||
final Size size = wm.getCurrentWindowMetrics().getSize();
|
final Rect bounds = wm.getCurrentWindowMetrics().getBounds();
|
||||||
|
|
||||||
final WindowManager.LayoutParams wmlp = new WindowManager.LayoutParams(
|
final WindowManager.LayoutParams wmlp = new WindowManager.LayoutParams(
|
||||||
TYPE_APPLICATION_OVERLAY,
|
TYPE_APPLICATION_OVERLAY,
|
||||||
WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE
|
WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE
|
||||||
| WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON
|
| WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON
|
||||||
| WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE);
|
| WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE);
|
||||||
wmlp.width = size.getWidth() / 2;
|
wmlp.width = bounds.width() / 2;
|
||||||
wmlp.height = size.getHeight() / 2;
|
wmlp.height = bounds.height() / 2;
|
||||||
wmlp.gravity = Gravity.CENTER | Gravity.LEFT;
|
wmlp.gravity = Gravity.CENTER | Gravity.LEFT;
|
||||||
wmlp.setTitle(TAG);
|
wmlp.setTitle(TAG);
|
||||||
|
|
||||||
|
|||||||
@@ -233,7 +233,7 @@ public abstract class GridScenario extends Activity {
|
|||||||
// turn off title bar
|
// turn off title bar
|
||||||
requestWindowFeature(Window.FEATURE_NO_TITLE);
|
requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||||
|
|
||||||
mScreenHeight = getWindowManager().getCurrentWindowMetrics().getSize().getHeight();
|
mScreenHeight = getWindowManager().getCurrentWindowMetrics().getBounds().height();
|
||||||
|
|
||||||
final Params params = new Params();
|
final Params params = new Params();
|
||||||
init(params);
|
init(params);
|
||||||
|
|||||||
@@ -306,7 +306,7 @@ public abstract class ListScenario extends Activity {
|
|||||||
requestWindowFeature(Window.FEATURE_NO_TITLE);
|
requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||||
|
|
||||||
|
|
||||||
mScreenHeight = getWindowManager().getCurrentWindowMetrics().getSize().getHeight();
|
mScreenHeight = getWindowManager().getCurrentWindowMetrics().getBounds().height();
|
||||||
|
|
||||||
final Params params = createParams();
|
final Params params = createParams();
|
||||||
init(params);
|
init(params);
|
||||||
|
|||||||
@@ -239,7 +239,7 @@ public abstract class ScrollViewScenario extends Activity {
|
|||||||
|
|
||||||
// for test stability, turn off title bar
|
// for test stability, turn off title bar
|
||||||
requestWindowFeature(Window.FEATURE_NO_TITLE);
|
requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||||
int screenHeight = getWindowManager().getCurrentWindowMetrics().getSize().getHeight()
|
int screenHeight = getWindowManager().getCurrentWindowMetrics().getBounds().height()
|
||||||
- 25;
|
- 25;
|
||||||
mLinearLayout = new LinearLayout(this);
|
mLinearLayout = new LinearLayout(this);
|
||||||
mLinearLayout.setOrientation(LinearLayout.VERTICAL);
|
mLinearLayout.setOrientation(LinearLayout.VERTICAL);
|
||||||
|
|||||||
@@ -17,8 +17,8 @@
|
|||||||
package android.view;
|
package android.view;
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
|
import android.graphics.Rect;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.util.Size;
|
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
import android.widget.ScrollView;
|
import android.widget.ScrollView;
|
||||||
|
|
||||||
@@ -39,9 +39,9 @@ public class BigCache extends Activity {
|
|||||||
ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
|
ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
|
||||||
|
|
||||||
final int cacheSize = ViewConfiguration.getMaximumDrawingCacheSize();
|
final int cacheSize = ViewConfiguration.getMaximumDrawingCacheSize();
|
||||||
final Size windowSize = getWindowManager().getCurrentWindowMetrics().getSize();
|
final Rect windowBounds = getWindowManager().getCurrentWindowMetrics().getBounds();
|
||||||
final int screenWidth = windowSize.getWidth();
|
final int screenWidth = windowBounds.width();
|
||||||
final int screenHeight = windowSize.getHeight();
|
final int screenHeight = windowBounds.height();
|
||||||
|
|
||||||
final View tiny = new View(this);
|
final View tiny = new View(this);
|
||||||
tiny.setId(R.id.a);
|
tiny.setId(R.id.a);
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ import static androidx.test.espresso.matcher.ViewMatchers.withId;
|
|||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
import android.util.Size;
|
import android.graphics.Rect;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import androidx.test.filters.LargeTest;
|
import androidx.test.filters.LargeTest;
|
||||||
@@ -55,9 +55,9 @@ public class ScaleGestureDetectorTest {
|
|||||||
|
|
||||||
// Specify start and end coordinates with respect to the window size.
|
// Specify start and end coordinates with respect to the window size.
|
||||||
final WindowManager wm = mScaleGestureActivity.getSystemService(WindowManager.class);
|
final WindowManager wm = mScaleGestureActivity.getSystemService(WindowManager.class);
|
||||||
final Size windowSize = wm.getCurrentWindowMetrics().getSize();
|
final Rect windowBounds = wm.getCurrentWindowMetrics().getBounds();
|
||||||
final int windowWidth = windowSize.getWidth();
|
final int windowWidth = windowBounds.width();
|
||||||
final int windowHeight = windowSize.getHeight();
|
final int windowHeight = windowBounds.height();
|
||||||
|
|
||||||
// Obtain coordinates to perform pinch and zoom from the center, to 75% of the display.
|
// Obtain coordinates to perform pinch and zoom from the center, to 75% of the display.
|
||||||
final int centerX = windowWidth / 2;
|
final int centerX = windowWidth / 2;
|
||||||
|
|||||||
@@ -22,10 +22,10 @@ import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY;
|
|||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.graphics.Rect;
|
||||||
import android.hardware.display.DisplayManager;
|
import android.hardware.display.DisplayManager;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.platform.test.annotations.Presubmit;
|
import android.platform.test.annotations.Presubmit;
|
||||||
import android.util.Size;
|
|
||||||
|
|
||||||
import androidx.test.filters.FlakyTest;
|
import androidx.test.filters.FlakyTest;
|
||||||
import androidx.test.filters.SmallTest;
|
import androidx.test.filters.SmallTest;
|
||||||
@@ -87,10 +87,12 @@ public class WindowMetricsTest {
|
|||||||
|
|
||||||
private static void verifyMetricsSanity(WindowMetrics currentMetrics,
|
private static void verifyMetricsSanity(WindowMetrics currentMetrics,
|
||||||
WindowMetrics maxMetrics) {
|
WindowMetrics maxMetrics) {
|
||||||
Size currentSize = currentMetrics.getSize();
|
Rect currentBounds = currentMetrics.getBounds();
|
||||||
Size maxSize = maxMetrics.getSize();
|
Rect maxBounds = maxMetrics.getBounds();
|
||||||
|
|
||||||
assertTrue(maxSize.getWidth() >= currentSize.getWidth());
|
assertTrue(maxBounds.width() >= currentBounds.width());
|
||||||
assertTrue(maxSize.getHeight() >= currentSize.getHeight());
|
assertTrue(maxBounds.height() >= currentBounds.height());
|
||||||
|
assertTrue(maxBounds.left >= 0);
|
||||||
|
assertTrue(maxBounds.top >= 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,9 +16,9 @@
|
|||||||
|
|
||||||
package android.view.menu;
|
package android.view.menu;
|
||||||
|
|
||||||
|
import android.graphics.Rect;
|
||||||
import android.test.ActivityInstrumentationTestCase;
|
import android.test.ActivityInstrumentationTestCase;
|
||||||
import android.util.PollingCheck;
|
import android.util.PollingCheck;
|
||||||
import android.util.Size;
|
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.WindowManager;
|
import android.view.WindowManager;
|
||||||
import android.widget.espresso.ContextMenuUtils;
|
import android.widget.espresso.ContextMenuUtils;
|
||||||
@@ -81,8 +81,8 @@ public class ContextMenuTest extends ActivityInstrumentationTestCase<ContextMenu
|
|||||||
*/
|
*/
|
||||||
private int getMinScreenDimension() {
|
private int getMinScreenDimension() {
|
||||||
final WindowManager windowManager = getActivity().getSystemService(WindowManager.class);
|
final WindowManager windowManager = getActivity().getSystemService(WindowManager.class);
|
||||||
final Size maxWindowSize = windowManager.getMaximumWindowMetrics().getSize();
|
final Rect maxWindowBounds = windowManager.getMaximumWindowMetrics().getBounds();
|
||||||
return Math.min(maxWindowSize.getWidth(), maxWindowSize.getHeight());
|
return Math.min(maxWindowBounds.width(), maxWindowBounds.height());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -111,7 +111,7 @@ public class ListOfInternalSelectionViews extends Activity {
|
|||||||
protected void onCreate(Bundle icicle) {
|
protected void onCreate(Bundle icicle) {
|
||||||
super.onCreate(icicle);
|
super.onCreate(icicle);
|
||||||
|
|
||||||
mScreenHeight = getWindowManager().getCurrentWindowMetrics().getSize().getHeight();
|
mScreenHeight = getWindowManager().getCurrentWindowMetrics().getBounds().height();
|
||||||
|
|
||||||
Bundle extras = getIntent().getExtras();
|
Bundle extras = getIntent().getExtras();
|
||||||
if (extras != null) {
|
if (extras != null) {
|
||||||
|
|||||||
@@ -106,8 +106,8 @@ public class GridTouchVerticalSpacingStackFromBottomTest extends ActivityInstrum
|
|||||||
|
|
||||||
int firstTop = firstChild.getTop();
|
int firstTop = firstChild.getTop();
|
||||||
|
|
||||||
int windowHeight = mActivity.getWindowManager().getCurrentWindowMetrics().getSize()
|
int windowHeight = mActivity.getWindowManager().getCurrentWindowMetrics().getBounds()
|
||||||
.getHeight();
|
.height();
|
||||||
int distance = TouchUtils.dragViewBy(this, firstChild,
|
int distance = TouchUtils.dragViewBy(this, firstChild,
|
||||||
Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL, 0, (int) (windowHeight * 0.75f));
|
Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL, 0, (int) (windowHeight * 0.75f));
|
||||||
|
|
||||||
|
|||||||
@@ -66,7 +66,7 @@ public class AdjacentListsWithAdjacentISVsInside extends Activity {
|
|||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
final int desiredHeight =
|
final int desiredHeight =
|
||||||
(int) (0.8 * getWindowManager().getCurrentWindowMetrics().getSize().getHeight());
|
(int) (0.8 * getWindowManager().getCurrentWindowMetrics().getBounds().height());
|
||||||
|
|
||||||
mLeftListView = new ListView(this);
|
mLeftListView = new ListView(this);
|
||||||
mLeftListView.setAdapter(new AdjacentISVAdapter(desiredHeight));
|
mLeftListView.setAdapter(new AdjacentISVAdapter(desiredHeight));
|
||||||
|
|||||||
@@ -2210,14 +2210,14 @@ public class CameraTestUtils extends Assert {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static Size getPreviewSizeBound(WindowManager windowManager, Size bound) {
|
public static Size getPreviewSizeBound(WindowManager windowManager, Size bound) {
|
||||||
Size windowSize = windowManager.getCurrentWindowMetrics().getSize();
|
Rect windowBounds = windowManager.getCurrentWindowMetrics().getBounds();
|
||||||
|
|
||||||
int width = windowSize.getWidth();
|
int width = windowBounds.width();
|
||||||
int height = windowSize.getHeight();
|
int height = windowBounds.height();
|
||||||
|
|
||||||
if (height > width) {
|
if (height > width) {
|
||||||
height = width;
|
height = width;
|
||||||
width = windowSize.getHeight();
|
width = windowBounds.height();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bound.getWidth() <= width &&
|
if (bound.getWidth() <= width &&
|
||||||
|
|||||||
@@ -28,11 +28,11 @@ import android.content.ComponentName;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.ServiceConnection;
|
import android.content.ServiceConnection;
|
||||||
|
import android.graphics.Rect;
|
||||||
import android.hardware.display.DisplayManager;
|
import android.hardware.display.DisplayManager;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.IBinder;
|
import android.os.IBinder;
|
||||||
import android.os.Message;
|
import android.os.Message;
|
||||||
import android.util.Size;
|
|
||||||
import android.util.Slog;
|
import android.util.Slog;
|
||||||
import android.view.Display;
|
import android.view.Display;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
@@ -134,8 +134,8 @@ public class FakeApp extends Application {
|
|||||||
}
|
}
|
||||||
lp.width = ViewGroup.LayoutParams.MATCH_PARENT;
|
lp.width = ViewGroup.LayoutParams.MATCH_PARENT;
|
||||||
lp.height = ViewGroup.LayoutParams.MATCH_PARENT;
|
lp.height = ViewGroup.LayoutParams.MATCH_PARENT;
|
||||||
Size maxWindowSize = wm.getMaximumWindowMetrics().getSize();
|
Rect maxWindowBounds = wm.getMaximumWindowMetrics().getBounds();
|
||||||
int maxSize = Math.max(maxWindowSize.getWidth(), maxWindowSize.getHeight());
|
int maxSize = Math.max(maxWindowBounds.width(), maxWindowBounds.height());
|
||||||
maxSize *= 2;
|
maxSize *= 2;
|
||||||
lp.x = maxSize;
|
lp.x = maxSize;
|
||||||
lp.y = maxSize;
|
lp.y = maxSize;
|
||||||
|
|||||||
@@ -19,22 +19,22 @@ package com.android.fakeoemfeatures;
|
|||||||
import static android.view.Display.DEFAULT_DISPLAY;
|
import static android.view.Display.DEFAULT_DISPLAY;
|
||||||
import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY;
|
import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Random;
|
|
||||||
|
|
||||||
import android.app.Dialog;
|
import android.app.Dialog;
|
||||||
import android.app.Service;
|
import android.app.Service;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
|
import android.graphics.Rect;
|
||||||
import android.hardware.display.DisplayManager;
|
import android.hardware.display.DisplayManager;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.IBinder;
|
import android.os.IBinder;
|
||||||
import android.os.Message;
|
import android.os.Message;
|
||||||
import android.util.Size;
|
|
||||||
import android.view.Display;
|
import android.view.Display;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.view.WindowManager;
|
import android.view.WindowManager;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
public class FakeBackgroundService extends Service {
|
public class FakeBackgroundService extends Service {
|
||||||
final ArrayList<int[]> mAllocs = new ArrayList<int[]>();
|
final ArrayList<int[]> mAllocs = new ArrayList<int[]>();
|
||||||
|
|
||||||
@@ -99,8 +99,8 @@ public class FakeBackgroundService extends Service {
|
|||||||
// Create an instance of WindowManager that is adjusted to the area of the display dedicated
|
// Create an instance of WindowManager that is adjusted to the area of the display dedicated
|
||||||
// for windows with type TYPE_APPLICATION_OVERLAY.
|
// for windows with type TYPE_APPLICATION_OVERLAY.
|
||||||
final WindowManager wm = windowContext.getSystemService(WindowManager.class);
|
final WindowManager wm = windowContext.getSystemService(WindowManager.class);
|
||||||
Size maxWindowSize = wm.getMaximumWindowMetrics().getSize();
|
Rect maxWindowBounds = wm.getMaximumWindowMetrics().getBounds();
|
||||||
int maxSize = Math.max(maxWindowSize.getWidth(), maxWindowSize.getHeight());
|
int maxSize = Math.max(maxWindowBounds.width(), maxWindowBounds.height());
|
||||||
maxSize *= 2;
|
maxSize *= 2;
|
||||||
lp.x = maxSize;
|
lp.x = maxSize;
|
||||||
lp.y = maxSize;
|
lp.y = maxSize;
|
||||||
|
|||||||
@@ -37,7 +37,6 @@ import android.net.Uri;
|
|||||||
import android.os.AsyncTask;
|
import android.os.AsyncTask;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.util.Size;
|
|
||||||
import android.view.Display;
|
import android.view.Display;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
@@ -358,8 +357,8 @@ public class WallpaperCropActivity extends Activity {
|
|||||||
// Get the crop
|
// Get the crop
|
||||||
boolean ltr = mCropView.getLayoutDirection() == View.LAYOUT_DIRECTION_LTR;
|
boolean ltr = mCropView.getLayoutDirection() == View.LAYOUT_DIRECTION_LTR;
|
||||||
|
|
||||||
Size windowSize = getWindowManager().getCurrentWindowMetrics().getSize();
|
Rect windowBounds = getWindowManager().getCurrentWindowMetrics().getBounds();
|
||||||
boolean isPortrait = windowSize.getWidth() < windowSize.getHeight();
|
boolean isPortrait = windowBounds.width() < windowBounds.height();
|
||||||
|
|
||||||
Point defaultWallpaperSize = getDefaultWallpaperSize(getResources(),
|
Point defaultWallpaperSize = getDefaultWallpaperSize(getResources(),
|
||||||
getDisplay());
|
getDisplay());
|
||||||
|
|||||||
@@ -223,7 +223,7 @@ public class TouchUtils {
|
|||||||
public static void dragViewToBottom(InstrumentationTestCase test, Activity activity, View v,
|
public static void dragViewToBottom(InstrumentationTestCase test, Activity activity, View v,
|
||||||
int stepCount) {
|
int stepCount) {
|
||||||
int screenHeight =
|
int screenHeight =
|
||||||
activity.getWindowManager().getCurrentWindowMetrics().getSize().getHeight();
|
activity.getWindowManager().getCurrentWindowMetrics().getBounds().height();
|
||||||
|
|
||||||
int[] xy = new int[2];
|
int[] xy = new int[2];
|
||||||
v.getLocationOnScreen(xy);
|
v.getLocationOnScreen(xy);
|
||||||
|
|||||||
@@ -27,7 +27,6 @@ import android.graphics.Rect;
|
|||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.RemoteException;
|
import android.os.RemoteException;
|
||||||
import android.util.Size;
|
|
||||||
import android.view.Gravity;
|
import android.view.Gravity;
|
||||||
import android.view.IWindowManager;
|
import android.view.IWindowManager;
|
||||||
import android.view.MotionEvent;
|
import android.view.MotionEvent;
|
||||||
@@ -90,8 +89,8 @@ public class MirrorSurfaceActivity extends Activity implements View.OnClickListe
|
|||||||
.getSystemService(WindowManager.class);
|
.getSystemService(WindowManager.class);
|
||||||
mIWm = WindowManagerGlobal.getWindowManagerService();
|
mIWm = WindowManagerGlobal.getWindowManagerService();
|
||||||
|
|
||||||
Size windowSize = mWm.getCurrentWindowMetrics().getSize();
|
Rect windowBounds = mWm.getCurrentWindowMetrics().getBounds();
|
||||||
mWindowBounds.set(0, 0, windowSize.getWidth(), windowSize.getHeight());
|
mWindowBounds.set(0, 0, windowBounds.width(), windowBounds.height());
|
||||||
|
|
||||||
mScaleText = findViewById(R.id.scale);
|
mScaleText = findViewById(R.id.scale);
|
||||||
mDisplayFrameText = findViewById(R.id.displayFrame);
|
mDisplayFrameText = findViewById(R.id.displayFrame);
|
||||||
|
|||||||
Reference in New Issue
Block a user