Loading core/java/android/app/SearchDialog.java +2 −2 Original line number Diff line number Diff line Loading @@ -139,8 +139,8 @@ public class SearchDialog extends Dialog implements OnItemClickListener, OnItemS // A weak map of drawables we've gotten from other packages, so we don't load them // more than once. private final WeakHashMap<String, Drawable> mOutsideDrawablesCache = new WeakHashMap<String, Drawable>(); private final WeakHashMap<String, Drawable.ConstantState> mOutsideDrawablesCache = new WeakHashMap<String, Drawable.ConstantState>(); // Last known IME options value for the search edit text. private int mSearchAutoCompleteImeOptions; Loading core/java/android/app/SuggestionsAdapter.java +19 −15 Original line number Diff line number Diff line Loading @@ -61,8 +61,8 @@ class SuggestionsAdapter extends ResourceCursorAdapter { private SearchDialog mSearchDialog; private SearchableInfo mSearchable; private Context mProviderContext; private WeakHashMap<String, Drawable> mOutsideDrawablesCache; private SparseArray<Drawable> mBackgroundsCache; private WeakHashMap<String, Drawable.ConstantState> mOutsideDrawablesCache; private SparseArray<Drawable.ConstantState> mBackgroundsCache; private boolean mGlobalSearchMode; // Cached column indexes, updated when the cursor changes. Loading Loading @@ -97,8 +97,10 @@ class SuggestionsAdapter extends ResourceCursorAdapter { */ private static final long DELETE_KEY_POST_DELAY = 500L; public SuggestionsAdapter(Context context, SearchDialog searchDialog, SearchableInfo searchable, WeakHashMap<String, Drawable> outsideDrawablesCache, boolean globalSearchMode) { public SuggestionsAdapter(Context context, SearchDialog searchDialog, SearchableInfo searchable, WeakHashMap<String, Drawable.ConstantState> outsideDrawablesCache, boolean globalSearchMode) { super(context, com.android.internal.R.layout.search_dropdown_item_icons_2line, null, // no initial cursor Loading @@ -112,7 +114,7 @@ class SuggestionsAdapter extends ResourceCursorAdapter { mProviderContext = mSearchable.getProviderContext(mContext, activityContext); mOutsideDrawablesCache = outsideDrawablesCache; mBackgroundsCache = new SparseArray<Drawable>(); mBackgroundsCache = new SparseArray<Drawable.ConstantState>(); mGlobalSearchMode = globalSearchMode; mStartSpinnerRunnable = new Runnable() { Loading Loading @@ -345,11 +347,10 @@ class SuggestionsAdapter extends ResourceCursorAdapter { if (backgroundColor == 0) { return null; } else { Drawable cachedBg = mBackgroundsCache.get(backgroundColor); Drawable.ConstantState cachedBg = mBackgroundsCache.get(backgroundColor); if (cachedBg != null) { if (DBG) Log.d(LOG_TAG, "Background cache hit for color " + backgroundColor); // copy the drawable so that they don't share states return cachedBg.getConstantState().newDrawable(); return cachedBg.newDrawable(); } if (DBG) Log.d(LOG_TAG, "Creating new background for color " + backgroundColor); ColorDrawable transparent = new ColorDrawable(0); Loading @@ -358,7 +359,7 @@ class SuggestionsAdapter extends ResourceCursorAdapter { newBg.addState(new int[]{android.R.attr.state_selected}, transparent); newBg.addState(new int[]{android.R.attr.state_pressed}, transparent); newBg.addState(new int[]{}, background); mBackgroundsCache.put(backgroundColor, newBg); mBackgroundsCache.put(backgroundColor, newBg.getConstantState()); return newBg; } } Loading Loading @@ -523,12 +524,13 @@ class SuggestionsAdapter extends ResourceCursorAdapter { } // First, check the cache. Drawable drawable = mOutsideDrawablesCache.get(drawableId); if (drawable != null) { Drawable.ConstantState cached = mOutsideDrawablesCache.get(drawableId); if (cached != null) { if (DBG) Log.d(LOG_TAG, "Found icon in cache: " + drawableId); return drawable; return cached.newDrawable(); } Drawable drawable = null; try { // Not cached, try using it as a plain resource ID in the provider's context. int resourceId = Integer.parseInt(drawableId); Loading Loading @@ -560,7 +562,7 @@ class SuggestionsAdapter extends ResourceCursorAdapter { // If we got a drawable for this resource id, then stick it in the // map so we don't do this lookup again. if (drawable != null) { mOutsideDrawablesCache.put(drawableId, drawable); mOutsideDrawablesCache.put(drawableId, drawable.getConstantState()); } } catch (Resources.NotFoundException nfe) { if (DBG) Log.d(LOG_TAG, "Icon resource not found: " + drawableId); Loading Loading @@ -615,12 +617,14 @@ class SuggestionsAdapter extends ResourceCursorAdapter { String componentIconKey = component.flattenToShortString(); // Using containsKey() since we also store null values. if (mOutsideDrawablesCache.containsKey(componentIconKey)) { return mOutsideDrawablesCache.get(componentIconKey); Drawable.ConstantState cached = mOutsideDrawablesCache.get(componentIconKey); return cached == null ? null : cached.newDrawable(); } // Then try the activity or application icon Drawable drawable = getActivityIcon(component); // Stick it in the cache so we don't do this lookup again. mOutsideDrawablesCache.put(componentIconKey, drawable); Drawable.ConstantState toCache = drawable == null ? null : drawable.getConstantState(); mOutsideDrawablesCache.put(componentIconKey, toCache); return drawable; } Loading core/java/android/appwidget/AppWidgetProvider.java +3 −5 Original line number Diff line number Diff line Loading @@ -64,11 +64,9 @@ public class AppWidgetProvider extends BroadcastReceiver { } else if (AppWidgetManager.ACTION_APPWIDGET_DELETED.equals(action)) { Bundle extras = intent.getExtras(); if (extras != null) { int[] appWidgetIds = extras.getIntArray(AppWidgetManager.EXTRA_APPWIDGET_IDS); if (appWidgetIds != null && appWidgetIds.length > 0) { this.onDeleted(context, appWidgetIds); } if (extras != null && extras.containsKey(AppWidgetManager.EXTRA_APPWIDGET_ID)) { final int appWidgetId = extras.getInt(AppWidgetManager.EXTRA_APPWIDGET_ID); this.onDeleted(context, new int[] { appWidgetId }); } } else if (AppWidgetManager.ACTION_APPWIDGET_ENABLED.equals(action)) { Loading core/java/android/content/res/CompatibilityInfo.java +7 −2 Original line number Diff line number Diff line Loading @@ -38,7 +38,12 @@ public class CompatibilityInfo { private static final String TAG = "CompatibilityInfo"; /** default compatibility info object for compatible applications */ public static final CompatibilityInfo DEFAULT_COMPATIBILITY_INFO = new CompatibilityInfo(); public static final CompatibilityInfo DEFAULT_COMPATIBILITY_INFO = new CompatibilityInfo() { @Override public void setExpandable(boolean expandable) { throw new UnsupportedOperationException("trying to change default compatibility info"); } }; /** * The default width of the screen in portrait mode. Loading Loading @@ -191,7 +196,7 @@ public class CompatibilityInfo { @Override public String toString() { return "CompatibilityInfo{scale=" + applicationScale + ", compatibility flag=" + mCompatibilityFlags + "}"; ", supports screen=" + supportsScreen() + "}"; } /** Loading core/java/android/view/SurfaceView.java +14 −2 Original line number Diff line number Diff line Loading @@ -17,7 +17,6 @@ package android.view; import android.content.Context; import android.content.res.CompatibilityInfo; import android.content.res.CompatibilityInfo.Translator; import android.graphics.Canvas; import android.graphics.PixelFormat; Loading Loading @@ -256,7 +255,7 @@ public class SurfaceView extends View { public boolean dispatchTouchEvent(MotionEvent event) { // SurfaceView uses pre-scaled size unless fixed size is requested. This hook // scales the event back to the pre-scaled coordinates for such surface. if (mRequestedWidth < 0 && mTranslator != null) { if (mScaled) { MotionEvent scaledBack = MotionEvent.obtain(event); scaledBack.scale(mTranslator.applicationScale); try { Loading Loading @@ -291,6 +290,8 @@ public class SurfaceView extends View { mWindowType = type; } boolean mScaled = false; private void updateWindow(boolean force) { if (!mHaveFrame) { return; Loading @@ -309,6 +310,9 @@ public class SurfaceView extends View { if (mRequestedWidth <= 0 && mTranslator != null) { myWidth *= appScale; myHeight *= appScale; mScaled = true; } else { mScaled = false; } getLocationInWindow(mLocation); Loading Loading @@ -533,6 +537,7 @@ public class SurfaceView extends View { private SurfaceHolder mSurfaceHolder = new SurfaceHolder() { private static final String LOG_TAG = "SurfaceHolder"; private int mSaveCount; public boolean isCreating() { return mIsCreating; Loading Loading @@ -627,6 +632,10 @@ public class SurfaceView extends View { if (localLOGV) Log.i(TAG, "Returned canvas: " + c); if (c != null) { mLastLockTime = SystemClock.uptimeMillis(); if (mScaled) { mSaveCount = c.save(); mTranslator.translateCanvas(c); } return c; } Loading @@ -649,6 +658,9 @@ public class SurfaceView extends View { } public void unlockCanvasAndPost(Canvas canvas) { if (mScaled) { canvas.restoreToCount(mSaveCount); } mSurface.unlockCanvasAndPost(canvas); mSurfaceLock.unlock(); } Loading Loading
core/java/android/app/SearchDialog.java +2 −2 Original line number Diff line number Diff line Loading @@ -139,8 +139,8 @@ public class SearchDialog extends Dialog implements OnItemClickListener, OnItemS // A weak map of drawables we've gotten from other packages, so we don't load them // more than once. private final WeakHashMap<String, Drawable> mOutsideDrawablesCache = new WeakHashMap<String, Drawable>(); private final WeakHashMap<String, Drawable.ConstantState> mOutsideDrawablesCache = new WeakHashMap<String, Drawable.ConstantState>(); // Last known IME options value for the search edit text. private int mSearchAutoCompleteImeOptions; Loading
core/java/android/app/SuggestionsAdapter.java +19 −15 Original line number Diff line number Diff line Loading @@ -61,8 +61,8 @@ class SuggestionsAdapter extends ResourceCursorAdapter { private SearchDialog mSearchDialog; private SearchableInfo mSearchable; private Context mProviderContext; private WeakHashMap<String, Drawable> mOutsideDrawablesCache; private SparseArray<Drawable> mBackgroundsCache; private WeakHashMap<String, Drawable.ConstantState> mOutsideDrawablesCache; private SparseArray<Drawable.ConstantState> mBackgroundsCache; private boolean mGlobalSearchMode; // Cached column indexes, updated when the cursor changes. Loading Loading @@ -97,8 +97,10 @@ class SuggestionsAdapter extends ResourceCursorAdapter { */ private static final long DELETE_KEY_POST_DELAY = 500L; public SuggestionsAdapter(Context context, SearchDialog searchDialog, SearchableInfo searchable, WeakHashMap<String, Drawable> outsideDrawablesCache, boolean globalSearchMode) { public SuggestionsAdapter(Context context, SearchDialog searchDialog, SearchableInfo searchable, WeakHashMap<String, Drawable.ConstantState> outsideDrawablesCache, boolean globalSearchMode) { super(context, com.android.internal.R.layout.search_dropdown_item_icons_2line, null, // no initial cursor Loading @@ -112,7 +114,7 @@ class SuggestionsAdapter extends ResourceCursorAdapter { mProviderContext = mSearchable.getProviderContext(mContext, activityContext); mOutsideDrawablesCache = outsideDrawablesCache; mBackgroundsCache = new SparseArray<Drawable>(); mBackgroundsCache = new SparseArray<Drawable.ConstantState>(); mGlobalSearchMode = globalSearchMode; mStartSpinnerRunnable = new Runnable() { Loading Loading @@ -345,11 +347,10 @@ class SuggestionsAdapter extends ResourceCursorAdapter { if (backgroundColor == 0) { return null; } else { Drawable cachedBg = mBackgroundsCache.get(backgroundColor); Drawable.ConstantState cachedBg = mBackgroundsCache.get(backgroundColor); if (cachedBg != null) { if (DBG) Log.d(LOG_TAG, "Background cache hit for color " + backgroundColor); // copy the drawable so that they don't share states return cachedBg.getConstantState().newDrawable(); return cachedBg.newDrawable(); } if (DBG) Log.d(LOG_TAG, "Creating new background for color " + backgroundColor); ColorDrawable transparent = new ColorDrawable(0); Loading @@ -358,7 +359,7 @@ class SuggestionsAdapter extends ResourceCursorAdapter { newBg.addState(new int[]{android.R.attr.state_selected}, transparent); newBg.addState(new int[]{android.R.attr.state_pressed}, transparent); newBg.addState(new int[]{}, background); mBackgroundsCache.put(backgroundColor, newBg); mBackgroundsCache.put(backgroundColor, newBg.getConstantState()); return newBg; } } Loading Loading @@ -523,12 +524,13 @@ class SuggestionsAdapter extends ResourceCursorAdapter { } // First, check the cache. Drawable drawable = mOutsideDrawablesCache.get(drawableId); if (drawable != null) { Drawable.ConstantState cached = mOutsideDrawablesCache.get(drawableId); if (cached != null) { if (DBG) Log.d(LOG_TAG, "Found icon in cache: " + drawableId); return drawable; return cached.newDrawable(); } Drawable drawable = null; try { // Not cached, try using it as a plain resource ID in the provider's context. int resourceId = Integer.parseInt(drawableId); Loading Loading @@ -560,7 +562,7 @@ class SuggestionsAdapter extends ResourceCursorAdapter { // If we got a drawable for this resource id, then stick it in the // map so we don't do this lookup again. if (drawable != null) { mOutsideDrawablesCache.put(drawableId, drawable); mOutsideDrawablesCache.put(drawableId, drawable.getConstantState()); } } catch (Resources.NotFoundException nfe) { if (DBG) Log.d(LOG_TAG, "Icon resource not found: " + drawableId); Loading Loading @@ -615,12 +617,14 @@ class SuggestionsAdapter extends ResourceCursorAdapter { String componentIconKey = component.flattenToShortString(); // Using containsKey() since we also store null values. if (mOutsideDrawablesCache.containsKey(componentIconKey)) { return mOutsideDrawablesCache.get(componentIconKey); Drawable.ConstantState cached = mOutsideDrawablesCache.get(componentIconKey); return cached == null ? null : cached.newDrawable(); } // Then try the activity or application icon Drawable drawable = getActivityIcon(component); // Stick it in the cache so we don't do this lookup again. mOutsideDrawablesCache.put(componentIconKey, drawable); Drawable.ConstantState toCache = drawable == null ? null : drawable.getConstantState(); mOutsideDrawablesCache.put(componentIconKey, toCache); return drawable; } Loading
core/java/android/appwidget/AppWidgetProvider.java +3 −5 Original line number Diff line number Diff line Loading @@ -64,11 +64,9 @@ public class AppWidgetProvider extends BroadcastReceiver { } else if (AppWidgetManager.ACTION_APPWIDGET_DELETED.equals(action)) { Bundle extras = intent.getExtras(); if (extras != null) { int[] appWidgetIds = extras.getIntArray(AppWidgetManager.EXTRA_APPWIDGET_IDS); if (appWidgetIds != null && appWidgetIds.length > 0) { this.onDeleted(context, appWidgetIds); } if (extras != null && extras.containsKey(AppWidgetManager.EXTRA_APPWIDGET_ID)) { final int appWidgetId = extras.getInt(AppWidgetManager.EXTRA_APPWIDGET_ID); this.onDeleted(context, new int[] { appWidgetId }); } } else if (AppWidgetManager.ACTION_APPWIDGET_ENABLED.equals(action)) { Loading
core/java/android/content/res/CompatibilityInfo.java +7 −2 Original line number Diff line number Diff line Loading @@ -38,7 +38,12 @@ public class CompatibilityInfo { private static final String TAG = "CompatibilityInfo"; /** default compatibility info object for compatible applications */ public static final CompatibilityInfo DEFAULT_COMPATIBILITY_INFO = new CompatibilityInfo(); public static final CompatibilityInfo DEFAULT_COMPATIBILITY_INFO = new CompatibilityInfo() { @Override public void setExpandable(boolean expandable) { throw new UnsupportedOperationException("trying to change default compatibility info"); } }; /** * The default width of the screen in portrait mode. Loading Loading @@ -191,7 +196,7 @@ public class CompatibilityInfo { @Override public String toString() { return "CompatibilityInfo{scale=" + applicationScale + ", compatibility flag=" + mCompatibilityFlags + "}"; ", supports screen=" + supportsScreen() + "}"; } /** Loading
core/java/android/view/SurfaceView.java +14 −2 Original line number Diff line number Diff line Loading @@ -17,7 +17,6 @@ package android.view; import android.content.Context; import android.content.res.CompatibilityInfo; import android.content.res.CompatibilityInfo.Translator; import android.graphics.Canvas; import android.graphics.PixelFormat; Loading Loading @@ -256,7 +255,7 @@ public class SurfaceView extends View { public boolean dispatchTouchEvent(MotionEvent event) { // SurfaceView uses pre-scaled size unless fixed size is requested. This hook // scales the event back to the pre-scaled coordinates for such surface. if (mRequestedWidth < 0 && mTranslator != null) { if (mScaled) { MotionEvent scaledBack = MotionEvent.obtain(event); scaledBack.scale(mTranslator.applicationScale); try { Loading Loading @@ -291,6 +290,8 @@ public class SurfaceView extends View { mWindowType = type; } boolean mScaled = false; private void updateWindow(boolean force) { if (!mHaveFrame) { return; Loading @@ -309,6 +310,9 @@ public class SurfaceView extends View { if (mRequestedWidth <= 0 && mTranslator != null) { myWidth *= appScale; myHeight *= appScale; mScaled = true; } else { mScaled = false; } getLocationInWindow(mLocation); Loading Loading @@ -533,6 +537,7 @@ public class SurfaceView extends View { private SurfaceHolder mSurfaceHolder = new SurfaceHolder() { private static final String LOG_TAG = "SurfaceHolder"; private int mSaveCount; public boolean isCreating() { return mIsCreating; Loading Loading @@ -627,6 +632,10 @@ public class SurfaceView extends View { if (localLOGV) Log.i(TAG, "Returned canvas: " + c); if (c != null) { mLastLockTime = SystemClock.uptimeMillis(); if (mScaled) { mSaveCount = c.save(); mTranslator.translateCanvas(c); } return c; } Loading @@ -649,6 +658,9 @@ public class SurfaceView extends View { } public void unlockCanvasAndPost(Canvas canvas) { if (mScaled) { canvas.restoreToCount(mSaveCount); } mSurface.unlockCanvasAndPost(canvas); mSurfaceLock.unlock(); } Loading