Fix issues with photo selection on Prime.

1. Per Marco's request, we no longer expand the photo in landscape
   on phone.
2. Passing the full bitmap through the intent appears to be a no-no,
   which was exposed in the "black-screen" behavior when clicking on
   a default avatar photo on Prime.  To handle that, we now retrieve
   the photo from the default avatar resource if no URI is specified,
   and we retrieve the bitmap for real photos through the photo
   manager cache.  To ensure performance, I've added a method to the
   cache to force caching a given bitmap/byte[] for a photo URI.

Bug 5703659
Bug 5703700

Change-Id: I316f27c7ded575dd1bb00c0bb2e2c75917df1e19
diff --git a/src/com/android/contacts/ContactPhotoManager.java b/src/com/android/contacts/ContactPhotoManager.java
index 7c54e80..f53766d 100644
--- a/src/com/android/contacts/ContactPhotoManager.java
+++ b/src/com/android/contacts/ContactPhotoManager.java
@@ -177,6 +177,14 @@
     public abstract void refreshCache();
 
     /**
+     * Stores the given bitmap directly in the LRU bitmap cache.
+     * @param photoUri The URI of the photo (for future requests).
+     * @param bitmap The bitmap.
+     * @param photoBytes The bytes that were parsed to create the bitmap.
+     */
+    public abstract void cacheBitmap(Uri photoUri, Bitmap bitmap, byte[] photoBytes);
+
+    /**
      * Initiates a background process that over time will fill up cache with
      * preload photos.
      */
@@ -649,6 +657,14 @@
         mBitmapHolderCache.put(key, holder);
     }
 
+    @Override
+    public void cacheBitmap(Uri photoUri, Bitmap bitmap, byte[] photoBytes) {
+        Request request = Request.createFromUri(photoUri, true, false, DEFAULT_AVATER);
+        BitmapHolder holder = new BitmapHolder(photoBytes);
+        mBitmapHolderCache.put(request.getKey(), holder);
+        mBitmapCache.put(request, bitmap);
+    }
+
     /**
      * Populates an array of photo IDs that need to be loaded.
      */