From 289c273ec49462c7bfdbf6238e9016936da7307c Mon Sep 17 00:00:00 2001 From: Donghan Ryu Date: Mon, 14 Nov 2011 18:56:11 -0800 Subject: [PATCH] wallpaper: limit wallpaper width to sys.max_texture_size Image wallpapers are created ~1.5x screen size. On some devices this may exceed the maximum supported texture size, which will either fail allocation or fail to composite. Bug 991597 Change-Id: I9948b09f6e00a724212e73d36901f2bbea42e2f4 --- core/java/android/app/WallpaperManager.java | 30 +++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/core/java/android/app/WallpaperManager.java b/core/java/android/app/WallpaperManager.java index c2bbff0e743a5..62d791fe80fae 100644 --- a/core/java/android/app/WallpaperManager.java +++ b/core/java/android/app/WallpaperManager.java @@ -45,6 +45,7 @@ import android.os.Message; import android.os.ParcelFileDescriptor; import android.os.RemoteException; import android.os.ServiceManager; +import android.os.SystemProperties; import android.util.DisplayMetrics; import android.util.Log; import android.view.WindowManager; @@ -928,6 +929,35 @@ public class WallpaperManager { */ public void suggestDesiredDimensions(int minimumWidth, int minimumHeight) { try { + /** + * The framework makes no attempt to limit the window size + * to the maximum texture size. Any window larger than this + * cannot be composited. + * + * Read maximum texture size from system property and scale down + * minimumWidth and minimumHeight accordingly. + */ + int maximumTextureSize; + try { + maximumTextureSize = SystemProperties.getInt("sys.max_texture_size", 0); + } catch (Exception e) { + maximumTextureSize = 0; + } + + if (maximumTextureSize > 0) { + if ((minimumWidth > maximumTextureSize) || + (minimumHeight > maximumTextureSize)) { + float aspect = (float)minimumHeight / (float)minimumWidth; + if (minimumWidth > minimumHeight) { + minimumWidth = maximumTextureSize; + minimumHeight = (int)((minimumWidth * aspect) + 0.5); + } else { + minimumHeight = maximumTextureSize; + minimumWidth = (int)((minimumHeight / aspect) + 0.5); + } + } + } + if (sGlobals.mService == null) { Log.w(TAG, "WallpaperService not running"); } else {