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

Commit c377bac8 authored by Josh Guilfoyle's avatar Josh Guilfoyle
Browse files

Rolled back a legacy hack that is believed to be unnecessary.

This hack regarded opening assets from the PackageResourcesProvider.

Change-Id: Ibe0390e775c2a91ecb1f27c361802c7302a625c2
parent a92d3bf3
Loading
Loading
Loading
Loading
+0 −31
Original line number Original line Diff line number Diff line
@@ -299,17 +299,6 @@ public abstract class ContentResolver {
            // with sufficient testing.
            // with sufficient testing.
            return new FileInputStream(uri.getPath());
            return new FileInputStream(uri.getPath());
        } else {
        } else {
            // This is a work around for the following bug.
            // If an asset is stored in a separate file, then AssetFileDescriptor.createInputStream
            // works. However, if an asset is stored in .apk or .zip file, then
            // AssetFileDescriptor.createInputStream returns a stream which does not
            // contain valid data (I can repro the bug using SDK 1.1 and "regular" apk).
            // To work around the bug, we try to get the input stream from AssetManager
            // first and only if that failed, fall back to the "standard" approach.
            InputStream stream = openInputStreamEx(uri);
            if (stream != null) {
                return stream;
            }
            AssetFileDescriptor fd = openAssetFileDescriptor(uri, "r");
            AssetFileDescriptor fd = openAssetFileDescriptor(uri, "r");
            try {
            try {
                return fd != null ? fd.createInputStream() : null;
                return fd != null ? fd.createInputStream() : null;
@@ -319,26 +308,6 @@ public abstract class ContentResolver {
        }
        }
    }
    }


    private InputStream openInputStreamEx(Uri uri) {
        IContentProvider provider = acquireProvider(uri);
        ContentProvider cp = null;
        if (provider == null) {
            return null;
        }
        if (provider instanceof ContentProvider.Transport) {
            cp = ((ContentProvider.Transport)provider).getContentProvider();
        } else if (provider instanceof ContentProvider) {
            cp = (ContentProvider)provider;
        }
        if (cp == null) {
            return null;
        }
        if (cp instanceof IExtendedContentProvider) {
            return ((IExtendedContentProvider)cp).openInputStream(uri);
        }
        return null;
    }

    /**
    /**
     * Synonym for {@link #openOutputStream(Uri, String)
     * Synonym for {@link #openOutputStream(Uri, String)
     * openOutputStream(uri, "w")}.
     * openOutputStream(uri, "w")}.
+0 −22
Original line number Original line Diff line number Diff line
package android.content;

import java.io.InputStream;

import android.net.Uri;

/**
 * The interface which "extends" IContentProvider.
 * ContentProviders may implement the interface
 * to work around the following bug.
 * If an image asset is stored in a separate file,
 * then AssetFileDescriptor.createInputStream returns stream with valid data.
 * However, if an image asset is stored in .apk or .zip file, then
 * AssetFileDescriptor.createInputStream returns a stream which does not
 * contain valid data (the bug repro with SDK 1.1 and "regular" apk).
 * To address this issue, ContentProviders may want to implement this interface.
 * 
 * @hide
 */
public interface IExtendedContentProvider {
	public InputStream openInputStream(Uri uri);
}