Merge cherrypicks of [2604297, 2604299, 2604519, 2606195, 2605695, 2604520, 2606196, 2604521, 2604522, 2606197, 2604523, 2605696, 2605697, 2605698, 2606198, 2604524, 2604525, 2604526, 2604300, 2604527, 2606199, 2604528, 2604529, 2604301, 2606200, 2604302, 2606410, 2606201, 2606411, 2606202, 2606413, 2606203, 2606414, 2604303, 2604304, 2606204, 2604305, 2606206, 2606207, 2604306, 2606415, 2606208, 2606209, 2606416] into nyc-mr1-volantis-release

Change-Id: Ia58c6ef001afbf6a4320dff56923cde5d0a90c78
diff --git a/src/com/android/messaging/datamodel/media/GifImageResource.java b/src/com/android/messaging/datamodel/media/GifImageResource.java
index d50cf47..6801165 100644
--- a/src/com/android/messaging/datamodel/media/GifImageResource.java
+++ b/src/com/android/messaging/datamodel/media/GifImageResource.java
@@ -23,6 +23,7 @@
 import android.support.rastermill.FrameSequenceDrawable;
 
 import com.android.messaging.util.Assert;
+import com.android.messaging.util.LogUtil;
 
 import java.io.IOException;
 import java.io.InputStream;
@@ -55,7 +56,14 @@
 
     @Override
     public Drawable getDrawable(Resources resources) {
-        return new FrameSequenceDrawable(mFrameSequence);
+        try {
+            return new FrameSequenceDrawable(mFrameSequence);
+        } catch (final Exception e) {
+            // Malicious gif images can make platform throw different kind of exceptions. Catch
+            // them all.
+            LogUtil.e(LogUtil.BUGLE_TAG, "Error getting drawable for GIF", e);
+            return null;
+        }
     }
 
     @Override