Migrate Glide to default to ALWAYS_ARGB_8888

Due to issues where we were seeing Camera builds request 8888 and
not always get it, employ a simple fix to just change Glide defaults
for Android across the board to 8888. The BitmapDecoders are what
really matter for Camera, changing the Builder as well for consistency.

Also added cache debugging lines to Engine to characterize issue.

Bug: 17523927
Change-Id: I10827561d0dbfc9e22365cceee16e030329071ff
(cherry picked from commit 39cf2a57e54423787928bd310ebf9aed2f274f15)
diff --git a/library/src/main/java/com/bumptech/glide/BitmapRequestBuilder.java b/library/src/main/java/com/bumptech/glide/BitmapRequestBuilder.java
index 9d43c8c..52fa9f8 100644
--- a/library/src/main/java/com/bumptech/glide/BitmapRequestBuilder.java
+++ b/library/src/main/java/com/bumptech/glide/BitmapRequestBuilder.java
@@ -5,6 +5,7 @@
 import android.graphics.drawable.Drawable;
 import android.os.ParcelFileDescriptor;
 import android.view.animation.Animation;
+
 import com.bumptech.glide.load.DecodeFormat;
 import com.bumptech.glide.load.Encoder;
 import com.bumptech.glide.load.ResourceDecoder;
@@ -39,7 +40,7 @@
         Bitmap, TranscodeType> {
     private final BitmapPool bitmapPool;
     private Downsampler downsampler = Downsampler.AT_LEAST;
-    private DecodeFormat decodeFormat = DecodeFormat.PREFER_RGB_565;
+    private DecodeFormat decodeFormat = DecodeFormat.ALWAYS_ARGB_8888;
     private ResourceDecoder<InputStream, Bitmap> imageDecoder;
     private ResourceDecoder<ParcelFileDescriptor, Bitmap> videoDecoder;
     private Glide glide;
@@ -147,7 +148,7 @@
 
     /**
      * Sets the preferred format for {@link Bitmap}s decoded in this request. Defaults to
-     * {@link DecodeFormat#PREFER_RGB_565}. This replaces any previous calls to {@link #imageDecoder(ResourceDecoder)},
+     * {@link DecodeFormat#ALWAYS_ARGB_8888}. This replaces any previous calls to {@link #imageDecoder(ResourceDecoder)},
      * {@link #videoDecoder(ResourceDecoder)} and {@link #decoder(ResourceDecoder)} with default decoders with the
      * appropriate options set.
      *
diff --git a/library/src/main/java/com/bumptech/glide/load/engine/Engine.java b/library/src/main/java/com/bumptech/glide/load/engine/Engine.java
index 7aaf258..a38dee4 100644
--- a/library/src/main/java/com/bumptech/glide/load/engine/Engine.java
+++ b/library/src/main/java/com/bumptech/glide/load/engine/Engine.java
@@ -4,6 +4,7 @@
 import android.os.Looper;
 import android.os.MessageQueue;
 import android.util.Log;
+
 import com.bumptech.glide.Priority;
 import com.bumptech.glide.load.Encoder;
 import com.bumptech.glide.load.Key;
@@ -104,6 +105,9 @@
         final String id = fetcher.getId();
         EngineKey key = keyFactory.buildKey(id, width, height, cacheDecoder, decoder, transformation, encoder,
                 transcoder, sourceEncoder);
+        if (Log.isLoggable(TAG, Log.VERBOSE)) {
+            Log.v(TAG, "loading: " + key);
+        }
 
         Resource cached = cache.remove(key);
         if (cached != null) {
@@ -177,10 +181,19 @@
 
     @Override
     public void onResourceReleased(Key cacheKey, Resource resource) {
+        if (Log.isLoggable(TAG, Log.VERBOSE)) {
+            Log.v(TAG, "released: " + cacheKey);
+        }
         activeResources.remove(cacheKey);
         if (resource.isCacheable()) {
+            if (Log.isLoggable(TAG, Log.VERBOSE)) {
+                Log.v(TAG, "recaching: " + cacheKey);
+            }
             cache.put(cacheKey, resource);
         } else {
+            if (Log.isLoggable(TAG, Log.VERBOSE)) {
+                Log.v(TAG, "recycling: " + cacheKey);
+            }
             resource.recycle();
         }
     }
diff --git a/library/src/main/java/com/bumptech/glide/load/resource/bitmap/FileDescriptorBitmapDecoder.java b/library/src/main/java/com/bumptech/glide/load/resource/bitmap/FileDescriptorBitmapDecoder.java
index 15dc490..fb056d4 100644
--- a/library/src/main/java/com/bumptech/glide/load/resource/bitmap/FileDescriptorBitmapDecoder.java
+++ b/library/src/main/java/com/bumptech/glide/load/resource/bitmap/FileDescriptorBitmapDecoder.java
@@ -2,10 +2,11 @@
 
 import android.graphics.Bitmap;
 import android.os.ParcelFileDescriptor;
-import com.bumptech.glide.load.engine.Resource;
-import com.bumptech.glide.load.ResourceDecoder;
-import com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool;
+
 import com.bumptech.glide.load.DecodeFormat;
+import com.bumptech.glide.load.ResourceDecoder;
+import com.bumptech.glide.load.engine.Resource;
+import com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool;
 
 import java.io.IOException;
 
@@ -15,7 +16,7 @@
     private DecodeFormat decodeFormat;
 
     public FileDescriptorBitmapDecoder(BitmapPool bitmapPool) {
-        this(new VideoBitmapDecoder(), bitmapPool, DecodeFormat.PREFER_RGB_565);
+        this(new VideoBitmapDecoder(), bitmapPool, DecodeFormat.ALWAYS_ARGB_8888);
     }
 
     public FileDescriptorBitmapDecoder(VideoBitmapDecoder bitmapDecoder, BitmapPool bitmapPool,
diff --git a/library/src/main/java/com/bumptech/glide/load/resource/bitmap/StreamBitmapDecoder.java b/library/src/main/java/com/bumptech/glide/load/resource/bitmap/StreamBitmapDecoder.java
index b8bdb5b..0064e2f 100644
--- a/library/src/main/java/com/bumptech/glide/load/resource/bitmap/StreamBitmapDecoder.java
+++ b/library/src/main/java/com/bumptech/glide/load/resource/bitmap/StreamBitmapDecoder.java
@@ -23,7 +23,7 @@
     }
 
     public StreamBitmapDecoder(BitmapPool bitmapPool) {
-        this(Downsampler.AT_LEAST, bitmapPool, DecodeFormat.PREFER_RGB_565);
+        this(Downsampler.AT_LEAST, bitmapPool, DecodeFormat.ALWAYS_ARGB_8888);
     }
 
     public StreamBitmapDecoder(Downsampler downsampler, BitmapPool bitmapPool, DecodeFormat decodeFormat) {