Merge "Ensure wallpaper hint is at least as large as the display." into klp-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
7d667ee2de
@ -40,6 +40,7 @@ import android.content.pm.ServiceInfo;
|
|||||||
import android.content.pm.PackageManager.NameNotFoundException;
|
import android.content.pm.PackageManager.NameNotFoundException;
|
||||||
import android.content.pm.UserInfo;
|
import android.content.pm.UserInfo;
|
||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
|
import android.graphics.Point;
|
||||||
import android.os.Binder;
|
import android.os.Binder;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Environment;
|
import android.os.Environment;
|
||||||
@ -637,6 +638,16 @@ class WallpaperManagerService extends IWallpaperManager.Stub {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Point getDefaultDisplaySize() {
|
||||||
|
Point p = new Point();
|
||||||
|
try {
|
||||||
|
mIWindowManager.getInitialDisplaySize(Display.DEFAULT_DISPLAY, p);
|
||||||
|
} catch (RemoteException e) {
|
||||||
|
// not remote
|
||||||
|
}
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
|
||||||
public void setDimensionHints(int width, int height) throws RemoteException {
|
public void setDimensionHints(int width, int height) throws RemoteException {
|
||||||
checkPermission(android.Manifest.permission.SET_WALLPAPER_HINTS);
|
checkPermission(android.Manifest.permission.SET_WALLPAPER_HINTS);
|
||||||
synchronized (mLock) {
|
synchronized (mLock) {
|
||||||
@ -648,10 +659,10 @@ class WallpaperManagerService extends IWallpaperManager.Stub {
|
|||||||
if (width <= 0 || height <= 0) {
|
if (width <= 0 || height <= 0) {
|
||||||
throw new IllegalArgumentException("width and height must be > 0");
|
throw new IllegalArgumentException("width and height must be > 0");
|
||||||
}
|
}
|
||||||
// Make sure it is at least as large as the display's maximum size.
|
// Make sure it is at least as large as the display.
|
||||||
int maxSizeDimension = getMaximumSizeDimension();
|
Point displaySize = getDefaultDisplaySize();
|
||||||
width = Math.max(width, maxSizeDimension);
|
width = Math.max(width, displaySize.x);
|
||||||
height = Math.max(height, maxSizeDimension);
|
height = Math.max(height, displaySize.y);
|
||||||
|
|
||||||
if (width != wallpaper.width || height != wallpaper.height) {
|
if (width != wallpaper.width || height != wallpaper.height) {
|
||||||
wallpaper.width = width;
|
wallpaper.width = width;
|
||||||
|
Reference in New Issue
Block a user