Loading core/java/android/appwidget/AppWidgetManager.java +8 −0 Original line number Diff line number Diff line Loading @@ -321,6 +321,10 @@ public class AppWidgetManager { * and outside of the handler. * This method will only work when called from the uid that owns the AppWidget provider. * * <p> * The total Bitmap memory used by the RemoteViews object cannot exceed that required to * fill the screen once, ie. (screen width x screen height x 4) bytes. * * @param appWidgetIds The AppWidget instances for which to set the RemoteViews. * @param views The RemoteViews object to show. */ Loading Loading @@ -385,6 +389,10 @@ public class AppWidgetManager { * and outside of the handler. * This method will only work when called from the uid that owns the AppWidget provider. * * <p> * The total Bitmap memory used by the RemoteViews object cannot exceed that required to * fill the screen once, ie. (screen width x screen height x 4) bytes. * * @param appWidgetId The AppWidget instance for which to set the RemoteViews. * @param views The RemoteViews object to show. */ Loading core/java/android/widget/RemoteViews.java +2 −1 Original line number Diff line number Diff line Loading @@ -1445,7 +1445,8 @@ public class RemoteViews implements Parcelable, Filter { /** * Returns an estimate of the bitmap heap memory usage for this RemoteViews. */ int estimateMemoryUsage() { /** @hide */ public int estimateMemoryUsage() { return mMemoryUsageCounter.getMemoryUsage(); } Loading services/java/com/android/server/AppWidgetServiceImpl.java +19 −0 Original line number Diff line number Diff line Loading @@ -49,6 +49,7 @@ import android.util.Pair; import android.util.Slog; import android.util.TypedValue; import android.util.Xml; import android.view.WindowManager; import android.widget.RemoteViews; import com.android.internal.appwidget.IAppWidgetHost; Loading Loading @@ -171,6 +172,7 @@ class AppWidgetServiceImpl { boolean mSafeMode; int mUserId; boolean mStateLoaded; int mMaxWidgetBitmapMemory; // These are for debugging only -- widgets are going missing in some rare instances ArrayList<Provider> mDeletedProviders = new ArrayList<Provider>(); Loading @@ -181,6 +183,14 @@ class AppWidgetServiceImpl { mPm = AppGlobals.getPackageManager(); mAlarmManager = (AlarmManager) mContext.getSystemService(Context.ALARM_SERVICE); mUserId = userId; computeMaximumWidgetBitmapMemory(); } void computeMaximumWidgetBitmapMemory() { WindowManager wm = (WindowManager) mContext.getSystemService(Context.WINDOW_SERVICE); int height = wm.getDefaultDisplay().getRawHeight(); int width = wm.getDefaultDisplay().getRawWidth(); mMaxWidgetBitmapMemory = 4 * width * height; } public void systemReady(boolean safeMode) { Loading Loading @@ -806,6 +816,15 @@ class AppWidgetServiceImpl { if (appWidgetIds == null) { return; } int bitmapMemoryUsage = views.estimateMemoryUsage(); if (bitmapMemoryUsage > mMaxWidgetBitmapMemory) { throw new IllegalArgumentException("RemoteViews for widget update exceeds maximum" + " bitmap memory usage (used: " + bitmapMemoryUsage + ", max: " + mMaxWidgetBitmapMemory + ") The total memory cannot exceed that required to" + " fill the device's screen once."); } if (appWidgetIds.length == 0) { return; } Loading Loading
core/java/android/appwidget/AppWidgetManager.java +8 −0 Original line number Diff line number Diff line Loading @@ -321,6 +321,10 @@ public class AppWidgetManager { * and outside of the handler. * This method will only work when called from the uid that owns the AppWidget provider. * * <p> * The total Bitmap memory used by the RemoteViews object cannot exceed that required to * fill the screen once, ie. (screen width x screen height x 4) bytes. * * @param appWidgetIds The AppWidget instances for which to set the RemoteViews. * @param views The RemoteViews object to show. */ Loading Loading @@ -385,6 +389,10 @@ public class AppWidgetManager { * and outside of the handler. * This method will only work when called from the uid that owns the AppWidget provider. * * <p> * The total Bitmap memory used by the RemoteViews object cannot exceed that required to * fill the screen once, ie. (screen width x screen height x 4) bytes. * * @param appWidgetId The AppWidget instance for which to set the RemoteViews. * @param views The RemoteViews object to show. */ Loading
core/java/android/widget/RemoteViews.java +2 −1 Original line number Diff line number Diff line Loading @@ -1445,7 +1445,8 @@ public class RemoteViews implements Parcelable, Filter { /** * Returns an estimate of the bitmap heap memory usage for this RemoteViews. */ int estimateMemoryUsage() { /** @hide */ public int estimateMemoryUsage() { return mMemoryUsageCounter.getMemoryUsage(); } Loading
services/java/com/android/server/AppWidgetServiceImpl.java +19 −0 Original line number Diff line number Diff line Loading @@ -49,6 +49,7 @@ import android.util.Pair; import android.util.Slog; import android.util.TypedValue; import android.util.Xml; import android.view.WindowManager; import android.widget.RemoteViews; import com.android.internal.appwidget.IAppWidgetHost; Loading Loading @@ -171,6 +172,7 @@ class AppWidgetServiceImpl { boolean mSafeMode; int mUserId; boolean mStateLoaded; int mMaxWidgetBitmapMemory; // These are for debugging only -- widgets are going missing in some rare instances ArrayList<Provider> mDeletedProviders = new ArrayList<Provider>(); Loading @@ -181,6 +183,14 @@ class AppWidgetServiceImpl { mPm = AppGlobals.getPackageManager(); mAlarmManager = (AlarmManager) mContext.getSystemService(Context.ALARM_SERVICE); mUserId = userId; computeMaximumWidgetBitmapMemory(); } void computeMaximumWidgetBitmapMemory() { WindowManager wm = (WindowManager) mContext.getSystemService(Context.WINDOW_SERVICE); int height = wm.getDefaultDisplay().getRawHeight(); int width = wm.getDefaultDisplay().getRawWidth(); mMaxWidgetBitmapMemory = 4 * width * height; } public void systemReady(boolean safeMode) { Loading Loading @@ -806,6 +816,15 @@ class AppWidgetServiceImpl { if (appWidgetIds == null) { return; } int bitmapMemoryUsage = views.estimateMemoryUsage(); if (bitmapMemoryUsage > mMaxWidgetBitmapMemory) { throw new IllegalArgumentException("RemoteViews for widget update exceeds maximum" + " bitmap memory usage (used: " + bitmapMemoryUsage + ", max: " + mMaxWidgetBitmapMemory + ") The total memory cannot exceed that required to" + " fill the device's screen once."); } if (appWidgetIds.length == 0) { return; } Loading