Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f68c8e18 authored by Paramananda's avatar Paramananda Committed by Gerrit - the friendly Code Review server
Browse files

Gallery2 : GIF animated drm file can be visible in Gallery app

CRs-fixed : 804192

Change-Id: I0d62ebc31b54d5369e9530089e7c47088fc8d92f
parent c12b8b10
Loading
Loading
Loading
Loading
+20 −0
Original line number Diff line number Diff line
@@ -6,6 +6,7 @@ import android.content.Context;
import android.content.ContentResolver;
import android.content.res.AssetManager;
import android.database.Cursor;
import android.drm.DrmHelper;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Rect;
@@ -45,6 +46,19 @@ public class GIFView extends ImageView implements GifAction {
        }
        mUri = uri;

        // Let decode the GIF image from byte stream instead of file stream
        String filepath = DrmHelper.getFilePath(mContext, mUri);
        if (DrmHelper.isDrmFile(filepath)) {
            byte[] bytes = DrmHelper.getDrmImageBytes(filepath);
            DrmHelper.manageDrmLicense(mContext, this.getHandler(), filepath,
                    "image/gif");
            if (bytes == null) {
                return false;
            }
            startDecode(bytes);
            return true;
        }

        InputStream is = getInputStream(uri);
        if (is == null || (getFileSize (is) == 0)) {
            return false;
@@ -92,6 +106,12 @@ public class GIFView extends ImageView implements GifAction {
        mGifDecoder.start();
    }

    private void startDecode(byte[] bytes) {
        freeGifDecoder();
        mGifDecoder = new GifDecoder(bytes, this);
        mGifDecoder.start();
    }

    protected void onDraw(Canvas canvas) {
        super.onDraw(canvas);
        if (mGifDecoder == null) {