Merge "fix typo" into klp-dev
diff --git a/core/jni/android/graphics/BitmapFactory.cpp b/core/jni/android/graphics/BitmapFactory.cpp
index 9c20de2..0d757f7 100644
--- a/core/jni/android/graphics/BitmapFactory.cpp
+++ b/core/jni/android/graphics/BitmapFactory.cpp
@@ -297,6 +297,9 @@
             (SkBitmap::Allocator*)&recyclingAllocator : (SkBitmap::Allocator*)&javaAllocator;
     if (decodeMode != SkImageDecoder::kDecodeBounds_Mode) {
         if (!willScale) {
+            // If the java allocator is being used to allocate the pixel memory, the decoder
+            // need not write zeroes, since the memory is initialized to 0.
+            decoder->setSkipWritingZeroes(outputAllocator == &javaAllocator);
             decoder->setAllocator(outputAllocator);
         } else if (javaBitmap != NULL) {
             // check for eventual scaled bounds at allocation time, so we don't decode the bitmap
@@ -403,7 +406,12 @@
         if (!outputBitmap->allocPixels(outputAllocator, NULL)) {
             return nullObjectReturn("allocation failed for scaled bitmap");
         }
-        outputBitmap->eraseColor(0);
+
+        // If outputBitmap's pixels are newly allocated by Java, there is no need
+        // to erase to 0, since the pixels were initialized to 0.
+        if (outputAllocator != &javaAllocator) {
+            outputBitmap->eraseColor(0);
+        }
 
         SkPaint paint;
         paint.setFilterBitmap(true);
diff --git a/libs/hwui/FontRenderer.cpp b/libs/hwui/FontRenderer.cpp
index 7e99a5f..00e7870 100644
--- a/libs/hwui/FontRenderer.cpp
+++ b/libs/hwui/FontRenderer.cpp
@@ -353,7 +353,7 @@
                 memset(dstR += dstStride, 0, borderSize); // trailing border column
             }
             // write trailing border line
-            memset(dstL, 0, rowSize + 2 * borderSize);
+            memset(dstL += dstStride, 0, rowSize + 2 * borderSize);
             break;
         }
         case SkMask::kBW_Format: {
diff --git a/services/java/com/android/server/am/ActivityStackSupervisor.java b/services/java/com/android/server/am/ActivityStackSupervisor.java
index 9c5bdf6..9549e0a 100644
--- a/services/java/com/android/server/am/ActivityStackSupervisor.java
+++ b/services/java/com/android/server/am/ActivityStackSupervisor.java
@@ -2105,12 +2105,12 @@
                 mService.mHandler.removeMessages(LAUNCH_TIMEOUT_MSG);
             }
         }
+        checkReadyForSleepLocked();
     }
 
     boolean shutdownLocked(int timeout) {
         boolean timedout = false;
         goingToSleepLocked();
-        checkReadyForSleepLocked();
 
         final long endTime = System.currentTimeMillis() + timeout;
         while (true) {