diff options
Diffstat (limited to 'libs')
-rw-r--r-- | libs/androidfw/ResourceTypes.cpp | 36 | ||||
-rw-r--r-- | libs/hwui/FontRenderer.cpp | 5 |
2 files changed, 28 insertions, 13 deletions
diff --git a/libs/androidfw/ResourceTypes.cpp b/libs/androidfw/ResourceTypes.cpp index f3a1d9a..8cce191 100644 --- a/libs/androidfw/ResourceTypes.cpp +++ b/libs/androidfw/ResourceTypes.cpp @@ -5159,7 +5159,8 @@ status_t ResTable::createIdmap(const ResTable& overlay, uint32_t originalCrc, ui const uint32_t pkg_id = pkg->package->id << 24; for (size_t typeIndex = 0; typeIndex < typeCount; ++typeIndex) { - ssize_t offset = -1; + ssize_t first = -1; + ssize_t last = -1; const Type* typeConfigs = pkg->getType(typeIndex); ssize_t mapIndex = map.add(); if (mapIndex < 0) { @@ -5167,12 +5168,14 @@ status_t ResTable::createIdmap(const ResTable& overlay, uint32_t originalCrc, ui } Vector<uint32_t>& vector = map.editItemAt(mapIndex); for (size_t entryIndex = 0; entryIndex < typeConfigs->entryCount; ++entryIndex) { - uint32_t resID = (0xff000000 & ((pkg->package->id)<<24)) + uint32_t resID = pkg_id | (0x00ff0000 & ((typeIndex+1)<<16)) | (0x0000ffff & (entryIndex)); resource_name resName; if (!this->getResourceName(resID, &resName)) { ALOGW("idmap: resource 0x%08x has spec but lacks values, skipping\n", resID); + // add dummy value, or trimming leading/trailing zeroes later will fail + vector.push(0); continue; } @@ -5185,13 +5188,13 @@ status_t ResTable::createIdmap(const ResTable& overlay, uint32_t originalCrc, ui overlayPackage.string(), overlayPackage.size()); if (overlayResID != 0) { - // overlay package has package ID == 0, use original package's ID instead - overlayResID |= pkg_id; + overlayResID = pkg_id | (0x00ffffff & overlayResID); + last = Res_GETENTRY(resID); + if (first == -1) { + first = Res_GETENTRY(resID); + } } vector.push(overlayResID); - if (overlayResID != 0 && offset == -1) { - offset = Res_GETENTRY(resID); - } #if 0 if (overlayResID != 0) { ALOGD("%s/%s 0x%08x -> 0x%08x\n", @@ -5202,13 +5205,16 @@ status_t ResTable::createIdmap(const ResTable& overlay, uint32_t originalCrc, ui #endif } - if (offset != -1) { - // shave off leading and trailing entries which lack overlay values - vector.removeItemsAt(0, offset); - vector.insertAt((uint32_t)offset, 0, 1); - while (vector.top() == 0) { - vector.pop(); + if (first != -1) { + // shave off trailing entries which lack overlay values + const size_t last_past_one = last + 1; + if (last_past_one < vector.size()) { + vector.removeItemsAt(last_past_one, vector.size() - last_past_one); } + // shave off leading entries which lack overlay values + vector.removeItemsAt(0, first); + // store offset to first overlaid resource ID of this type + vector.insertAt((uint32_t)first, 0, 1); // reserve space for number and offset of entries, and the actual entries *outSize += (2 + vector.size()) * sizeof(uint32_t); } else { @@ -5246,6 +5252,10 @@ status_t ResTable::createIdmap(const ResTable& overlay, uint32_t originalCrc, ui if (N == 0) { continue; } + if (N == 1) { // vector expected to hold (offset) + (N > 0 entries) + ALOGW("idmap: type %d supposedly has entries, but no entries found\n", i); + return UNKNOWN_ERROR; + } *data++ = htodl(N - 1); // do not count the offset (which is vector's first element) for (size_t j = 0; j < N; ++j) { const uint32_t& overlayResID = vector.itemAt(j); diff --git a/libs/hwui/FontRenderer.cpp b/libs/hwui/FontRenderer.cpp index 0d6e62a..5fdbc11 100644 --- a/libs/hwui/FontRenderer.cpp +++ b/libs/hwui/FontRenderer.cpp @@ -946,6 +946,11 @@ void FontRenderer::appendRotatedMeshQuad(float x1, float y1, float u1, float v1, uint32_t FontRenderer::getRemainingCacheCapacity() { uint32_t remainingCapacity = 0; float totalPixels = 0; + + //avoid divide by zero if the size is 0 + if (mCacheLines.size() == 0) { + return 0; + } for(uint32_t i = 0; i < mCacheLines.size(); i ++) { remainingCapacity += (mCacheLines[i]->mMaxWidth - mCacheLines[i]->mCurrentCol); totalPixels += mCacheLines[i]->mMaxWidth; |