Merge "Fix issue #3385054: HRI24 never enters suspend (LP0) - IKXEVEREST-3439" into honeycomb
diff --git a/core/java/android/inputmethodservice/IInputMethodSessionWrapper.java b/core/java/android/inputmethodservice/IInputMethodSessionWrapper.java
index 01fc010..df8cf9a 100644
--- a/core/java/android/inputmethodservice/IInputMethodSessionWrapper.java
+++ b/core/java/android/inputmethodservice/IInputMethodSessionWrapper.java
@@ -76,6 +76,8 @@
}
public void executeMessage(Message msg) {
+ if (mInputMethodSession == null) return;
+
switch (msg.what) {
case DO_FINISH_INPUT:
mInputMethodSession.finishInput();
diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java
index 5538007..65d2e11 100644
--- a/core/java/android/view/View.java
+++ b/core/java/android/view/View.java
@@ -8087,7 +8087,7 @@
*
* @return A HardwareLayer ready to render, or null if an error occurred.
*/
- HardwareLayer getHardwareLayer(Canvas currentCanvas) {
+ HardwareLayer getHardwareLayer() {
if (mAttachInfo == null || mAttachInfo.mHardwareRenderer == null) {
return null;
}
@@ -8107,7 +8107,9 @@
mHardwareLayer.resize(width, height);
}
- final HardwareCanvas canvas = mHardwareLayer.start(mAttachInfo.mHardwareCanvas);
+ Canvas currentCanvas = mAttachInfo.mHardwareCanvas;
+ final HardwareCanvas canvas = mHardwareLayer.start(currentCanvas);
+ mAttachInfo.mHardwareCanvas = canvas;
try {
canvas.setViewport(width, height);
// TODO: We should pass the dirty rect
@@ -8131,7 +8133,8 @@
canvas.restoreToCount(restoreCount);
} finally {
canvas.onPostDraw();
- mHardwareLayer.end(mAttachInfo.mHardwareCanvas);
+ mHardwareLayer.end(currentCanvas);
+ mAttachInfo.mHardwareCanvas = currentCanvas;
}
}
diff --git a/core/java/android/view/ViewGroup.java b/core/java/android/view/ViewGroup.java
index 7c39201..f198c46 100644
--- a/core/java/android/view/ViewGroup.java
+++ b/core/java/android/view/ViewGroup.java
@@ -2475,7 +2475,7 @@
if (hasNoCache) {
boolean layerRendered = false;
if (layerType == LAYER_TYPE_HARDWARE) {
- final HardwareLayer layer = child.getHardwareLayer(canvas);
+ final HardwareLayer layer = child.getHardwareLayer();
if (layer != null && layer.isValid()) {
((HardwareCanvas) canvas).drawHardwareLayer(layer, 0, 0, child.mLayerPaint);
layerRendered = true;
diff --git a/core/java/com/android/internal/view/menu/MenuBuilder.java b/core/java/com/android/internal/view/menu/MenuBuilder.java
index ff59950..14d0ac5 100644
--- a/core/java/com/android/internal/view/menu/MenuBuilder.java
+++ b/core/java/com/android/internal/view/menu/MenuBuilder.java
@@ -215,6 +215,11 @@
private ViewGroup mMeasureActionButtonParent;
+ private final WeakReference<MenuAdapter>[] mAdapterCache =
+ new WeakReference[NUM_TYPES];
+ private final WeakReference<OverflowMenuAdapter>[] mOverflowAdapterCache =
+ new WeakReference[NUM_TYPES];
+
// Group IDs that have been added as actions - used temporarily, allocated here for reuse.
private final SparseBooleanArray mActionButtonGroups = new SparseBooleanArray();
@@ -1004,6 +1009,12 @@
MenuView menuView = menuTypes[i].mMenuView.get();
menuView.updateChildren(cleared);
}
+
+ MenuAdapter adapter = mAdapterCache[i] == null ? null : mAdapterCache[i].get();
+ if (adapter != null) adapter.notifyDataSetChanged();
+
+ adapter = mOverflowAdapterCache[i] == null ? null : mOverflowAdapterCache[i].get();
+ if (adapter != null) adapter.notifyDataSetChanged();
}
}
}
@@ -1358,7 +1369,13 @@
* @return A {@link MenuAdapter} for this menu with the given menu type.
*/
public MenuAdapter getMenuAdapter(int menuType) {
- return new MenuAdapter(menuType);
+ MenuAdapter adapter = mAdapterCache[menuType] == null ?
+ null : mAdapterCache[menuType].get();
+ if (adapter != null) return adapter;
+
+ adapter = new MenuAdapter(menuType);
+ mAdapterCache[menuType] = new WeakReference<MenuAdapter>(adapter);
+ return adapter;
}
/**
@@ -1368,7 +1385,13 @@
* @return A {@link MenuAdapter} for this menu with the given menu type.
*/
public MenuAdapter getOverflowMenuAdapter(int menuType) {
- return new OverflowMenuAdapter(menuType);
+ OverflowMenuAdapter adapter = mOverflowAdapterCache[menuType] == null ?
+ null : mOverflowAdapterCache[menuType].get();
+ if (adapter != null) return adapter;
+
+ adapter = new OverflowMenuAdapter(menuType);
+ mOverflowAdapterCache[menuType] = new WeakReference<OverflowMenuAdapter>(adapter);
+ return adapter;
}
void setOptionalIconsVisible(boolean visible) {
@@ -1469,21 +1492,18 @@
* source for overflow menu items that do not fit in the list of action items.
*/
private class OverflowMenuAdapter extends MenuAdapter {
- private ArrayList<MenuItemImpl> mOverflowItems;
-
public OverflowMenuAdapter(int menuType) {
super(menuType);
- mOverflowItems = getNonActionItems(true);
}
@Override
public MenuItemImpl getItem(int position) {
- return mOverflowItems.get(position);
+ return getNonActionItems(true).get(position);
}
@Override
public int getCount() {
- return mOverflowItems.size();
+ return getNonActionItems(true).size();
}
}
}
diff --git a/libs/hwui/DisplayListRenderer.cpp b/libs/hwui/DisplayListRenderer.cpp
index d70fba8..c2106d4 100644
--- a/libs/hwui/DisplayListRenderer.cpp
+++ b/libs/hwui/DisplayListRenderer.cpp
@@ -849,7 +849,7 @@
void DisplayListRenderer::drawArc(float left, float top, float right, float bottom,
float startAngle, float sweepAngle, bool useCenter, SkPaint* paint) {
- addOp(DisplayList::DrawOval);
+ addOp(DisplayList::DrawArc);
addBounds(left, top, right, bottom);
addPoint(startAngle, sweepAngle);
addInt(useCenter ? 1 : 0);
diff --git a/media/java/android/media/videoeditor/MediaArtistNativeHelper.java b/media/java/android/media/videoeditor/MediaArtistNativeHelper.java
index 77b7dc8..271e9dd 100755
--- a/media/java/android/media/videoeditor/MediaArtistNativeHelper.java
+++ b/media/java/android/media/videoeditor/MediaArtistNativeHelper.java
@@ -30,6 +30,9 @@
import android.util.Log;
import android.util.Pair;
import android.view.Surface;
+import android.graphics.Canvas;
+import android.graphics.Paint;
+import android.graphics.Rect;
/**
*This class provide Native methods to be used by MediaArtist {@hide}
@@ -67,7 +70,10 @@
private boolean mExportDone = false;
private int mProgressToApp;
-
+ /**
+ * The resize paint
+ */
+ private static final Paint sResizePaint = new Paint(Paint.FILTER_BITMAP_FLAG);
public static final int TASK_LOADING_SETTINGS = 1;
@@ -3838,11 +3844,39 @@
throw new IllegalArgumentException();
}
- IntBuffer rgb888 = IntBuffer.allocate(width * height * 4);
- Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
- nativeGetPixels(inputFile, rgb888.array(), width, height, timeMS);
- bitmap.copyPixelsFromBuffer(rgb888);
+ int newWidth = 0;
+ int newHeight = 0;
+ Bitmap tempBitmap = null;
+ /* Make width and height as even */
+ newWidth = (width + 1) & 0xFFFFFFFE;
+ newHeight = (height + 1) & 0xFFFFFFFE;
+
+ /* Create a temp bitmap for resized thumbnails */
+ if ((newWidth != width) || (newHeight != height)) {
+ tempBitmap = Bitmap.createBitmap(newWidth, newHeight, Bitmap.Config.ARGB_8888);
+ }
+
+ IntBuffer rgb888 = IntBuffer.allocate(newWidth * newHeight * 4);
+ Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
+ nativeGetPixels(inputFile, rgb888.array(), newWidth, newHeight, timeMS);
+
+ if ((newWidth == width) && (newHeight == height)) {
+ bitmap.copyPixelsFromBuffer(rgb888);
+ } else {
+ /* Create a temp bitmap to be used for resize */
+ tempBitmap.copyPixelsFromBuffer(rgb888);
+
+ /* Create a canvas to resize */
+ final Canvas canvas = new Canvas(bitmap);
+ canvas.drawBitmap(tempBitmap, new Rect(0, 0, newWidth, newHeight),
+ new Rect(0, 0, width, height),
+ sResizePaint);
+ }
+
+ if (tempBitmap != null) {
+ tempBitmap.recycle();
+ }
return bitmap;
}
@@ -3863,11 +3897,24 @@
public Bitmap[] getPixelsList(String filename, int width, int height, long startMs, long endMs,
int thumbnailCount) {
int[] rgb888 = null;
- int thumbnailSize = width * height * 4;
+ int thumbnailSize = 0;
+ int newWidth = 0;
+ int newHeight = 0;
+ Bitmap tempBitmap = null;
+ /* Make width and height as even */
+ newWidth = (width + 1) & 0xFFFFFFFE;
+ newHeight = (height + 1) & 0xFFFFFFFE;
+ thumbnailSize = newWidth * newHeight * 4;
+
+ /* Create a temp bitmap for resized thumbnails */
+ if ((newWidth != width) || (newHeight != height)) {
+ tempBitmap = Bitmap.createBitmap(newWidth, newHeight, Bitmap.Config.ARGB_8888);
+ }
int i = 0;
int deltaTime = (int)(endMs - startMs) / thumbnailCount;
Bitmap[] bitmap = null;
+
try {
// This may result in out of Memory Error
rgb888 = new int[thumbnailSize * thumbnailCount];
@@ -3880,19 +3927,35 @@
bitmap = new Bitmap[MAX_THUMBNAIL_PERMITTED];
thumbnailCount = MAX_THUMBNAIL_PERMITTED;
} catch (Throwable ex) {
- throw new RuntimeException("Memory allocation fails,reduce nos of thumbanail count");
+ throw new RuntimeException("Memory allocation fails, thumbnail count too large: "+thumbnailCount);
}
}
IntBuffer tmpBuffer = IntBuffer.allocate(thumbnailSize);
- nativeGetPixelsList(filename, rgb888, width, height, deltaTime, thumbnailCount, startMs,
+ nativeGetPixelsList(filename, rgb888, newWidth, newHeight, deltaTime, thumbnailCount, startMs,
endMs);
+
for (; i < thumbnailCount; i++) {
bitmap[i] = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
tmpBuffer.put(rgb888, (i * thumbnailSize), thumbnailSize);
tmpBuffer.rewind();
- bitmap[i].copyPixelsFromBuffer(tmpBuffer);
+
+ if ((newWidth == width) && (newHeight == height)) {
+ bitmap[i].copyPixelsFromBuffer(tmpBuffer);
+ } else {
+ /* Copy the out rgb buffer to temp bitmap */
+ tempBitmap.copyPixelsFromBuffer(tmpBuffer);
+
+ /* Create a canvas to resize */
+ final Canvas canvas = new Canvas(bitmap[i]);
+ canvas.drawBitmap(tempBitmap, new Rect(0, 0, newWidth, newHeight),
+ new Rect(0, 0, width, height),
+ sResizePaint);
+ }
}
+ if (tempBitmap != null) {
+ tempBitmap.recycle();
+ }
return bitmap;
}
diff --git a/media/java/android/media/videoeditor/MediaImageItem.java b/media/java/android/media/videoeditor/MediaImageItem.java
index 1c02878..a977b8e 100755
--- a/media/java/android/media/videoeditor/MediaImageItem.java
+++ b/media/java/android/media/videoeditor/MediaImageItem.java
@@ -1013,9 +1013,20 @@
if (dx > dy) {
bitmapWidth = width;
- bitmapHeight = Math.round(nativeHeight / dx);
+
+ if (((float)nativeHeight / dx) < (float)height) {
+ bitmapHeight = (float)Math.ceil(nativeHeight / dx);
+ } else { // value equals the requested height
+ bitmapHeight = (float)Math.floor(nativeHeight / dx);
+ }
+
} else {
- bitmapWidth = Math.round(nativeWidth / dy);
+ if (((float)nativeWidth / dy) > (float)width) {
+ bitmapWidth = (float)Math.floor(nativeWidth / dy);
+ } else { // value equals the requested width
+ bitmapWidth = (float)Math.ceil(nativeWidth / dy);
+ }
+
bitmapHeight = height;
}