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

Commit 1542af35 authored by Kenny Root's avatar Kenny Root Committed by Android (Google) Code Review
Browse files

Merge "Change assets to use 64-bit API"

parents f4ade58b ddb76c46
Loading
Loading
Loading
Loading
+5 −5
Original line number Diff line number Diff line
@@ -322,12 +322,12 @@ static jobject nativeDecodeStream(JNIEnv* env, jobject clazz,
}

static ssize_t getFDSize(int fd) {
    off_t curr = ::lseek(fd, 0, SEEK_CUR);
    off64_t curr = ::lseek64(fd, 0, SEEK_CUR);
    if (curr < 0) {
        return 0;
    }
    size_t size = ::lseek(fd, 0, SEEK_END);
    ::lseek(fd, curr, SEEK_SET);
    ::lseek64(fd, curr, SEEK_SET);
    return size;
}

@@ -374,8 +374,8 @@ static jobject nativeDecodeFileDescriptor(JNIEnv* env, jobject clazz,
 */
static SkStream* copyAssetToStream(Asset* asset) {
    // if we could "ref/reopen" the asset, we may not need to copy it here
    off_t size = asset->seek(0, SEEK_SET);
    if ((off_t)-1 == size) {
    off64_t size = asset->seek(0, SEEK_SET);
    if ((off64_t)-1 == size) {
        SkDebugf("---- copyAsset: asset rewind failed\n");
        return NULL;
    }
@@ -388,7 +388,7 @@ static SkStream* copyAssetToStream(Asset* asset) {

    SkStream* stream = new SkMemoryStream(size);
    void* data = const_cast<void*>(stream->getMemoryBase());
    off_t len = asset->read(data, size);
    off64_t len = asset->read(data, size);
    if (len != size) {
        SkDebugf("---- copyAsset: asset->read(%d) returned %d\n", size, len);
        delete stream;
+4 −4
Original line number Diff line number Diff line
@@ -72,8 +72,8 @@ public:

	virtual bool rewind()
    {
        off_t pos = fAsset->seek(0, SEEK_SET);
        return pos != (off_t)-1;
        off64_t pos = fAsset->seek(0, SEEK_SET);
        return pos != (off64_t)-1;
    }
    
	virtual size_t read(void* buffer, size_t size)
@@ -88,10 +88,10 @@ public:
            // asset->seek returns new total offset
            // we want to return amount that was skipped
            
            off_t oldOffset = fAsset->seek(0, SEEK_CUR);
            off64_t oldOffset = fAsset->seek(0, SEEK_CUR);
            if (-1 == oldOffset)
                return 0;
            off_t newOffset = fAsset->seek(size, SEEK_CUR);
            off64_t newOffset = fAsset->seek(size, SEEK_CUR);
            if (-1 == newOffset)
                return 0;
            
+4 −4
Original line number Diff line number Diff line
@@ -20,8 +20,8 @@
using namespace android;

bool AssetStreamAdaptor::rewind() {
    off_t pos = fAsset->seek(0, SEEK_SET);
    if (pos == (off_t)-1) {
    off64_t pos = fAsset->seek(0, SEEK_SET);
    if (pos == (off64_t)-1) {
        SkDebugf("----- fAsset->seek(rewind) failed\n");
        return false;
    }
@@ -38,12 +38,12 @@ size_t AssetStreamAdaptor::read(void* buffer, size_t size) {
        // asset->seek returns new total offset
        // we want to return amount that was skipped

        off_t oldOffset = fAsset->seek(0, SEEK_CUR);
        off64_t oldOffset = fAsset->seek(0, SEEK_CUR);
        if (-1 == oldOffset) {
            SkDebugf("---- fAsset->seek(oldOffset) failed\n");
            return 0;
        }
        off_t newOffset = fAsset->seek(size, SEEK_CUR);
        off64_t newOffset = fAsset->seek(size, SEEK_CUR);
        if (-1 == newOffset) {
            SkDebugf("---- fAsset->seek(%d) failed\n", size);
            return 0;
+1 −1
Original line number Diff line number Diff line
@@ -51,7 +51,7 @@ public:
    }
private:
    int     fFD;
    off_t   fCurr;
    off64_t   fCurr;
};

jobject nullObjectReturn(const char msg[]);
+1 −1
Original line number Diff line number Diff line
@@ -149,7 +149,7 @@ static jint android_content_AssetManager_openAsset(JNIEnv* env, jobject clazz,

static jobject returnParcelFileDescriptor(JNIEnv* env, Asset* a, jlongArray outOffsets)
{
    off_t startOffset, length;
    off64_t startOffset, length;
    int fd = a->openFileDescriptor(&startOffset, &length);
    delete a;
    
Loading