Merge "Frameworks/base: Wall Werror in libs/androidfw"
This commit is contained in:
@@ -236,8 +236,8 @@ enum {
|
|||||||
#define Res_MAKEINTERNAL(entry) (0x01000000 | (entry&0xFFFF))
|
#define Res_MAKEINTERNAL(entry) (0x01000000 | (entry&0xFFFF))
|
||||||
#define Res_MAKEARRAY(entry) (0x02000000 | (entry&0xFFFF))
|
#define Res_MAKEARRAY(entry) (0x02000000 | (entry&0xFFFF))
|
||||||
|
|
||||||
#define Res_MAXPACKAGE 255
|
static const size_t Res_MAXPACKAGE = 255;
|
||||||
#define Res_MAXTYPE 255
|
static const size_t Res_MAXTYPE = 255;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Representation of a value in a resource, supplying type
|
* Representation of a value in a resource, supplying type
|
||||||
|
|||||||
@@ -52,6 +52,8 @@ LOCAL_MODULE_TAGS := optional
|
|||||||
|
|
||||||
LOCAL_CFLAGS += -DSTATIC_ANDROIDFW_FOR_TOOLS
|
LOCAL_CFLAGS += -DSTATIC_ANDROIDFW_FOR_TOOLS
|
||||||
|
|
||||||
|
LOCAL_CFLAGS += -Wall -Werror -Wunused -Wunreachable-code
|
||||||
|
|
||||||
LOCAL_C_INCLUDES := \
|
LOCAL_C_INCLUDES := \
|
||||||
external/zlib
|
external/zlib
|
||||||
|
|
||||||
@@ -85,6 +87,8 @@ LOCAL_MODULE:= libandroidfw
|
|||||||
|
|
||||||
LOCAL_MODULE_TAGS := optional
|
LOCAL_MODULE_TAGS := optional
|
||||||
|
|
||||||
|
LOCAL_CFLAGS += -Wall -Werror -Wunused -Wunreachable-code
|
||||||
|
|
||||||
include $(BUILD_SHARED_LIBRARY)
|
include $(BUILD_SHARED_LIBRARY)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -45,6 +45,8 @@ using namespace android;
|
|||||||
# define O_BINARY 0
|
# define O_BINARY 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
static const bool kIsDebug = false;
|
||||||
|
|
||||||
static Mutex gAssetLock;
|
static Mutex gAssetLock;
|
||||||
static int32_t gCount = 0;
|
static int32_t gCount = 0;
|
||||||
static Asset* gHead = NULL;
|
static Asset* gHead = NULL;
|
||||||
@@ -89,7 +91,9 @@ Asset::Asset(void)
|
|||||||
gTail->mNext = this;
|
gTail->mNext = this;
|
||||||
gTail = this;
|
gTail = this;
|
||||||
}
|
}
|
||||||
//ALOGI("Creating Asset %p #%d\n", this, gCount);
|
if (kIsDebug) {
|
||||||
|
ALOGI("Creating Asset %p #%d\n", this, gCount);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Asset::~Asset(void)
|
Asset::~Asset(void)
|
||||||
@@ -109,7 +113,9 @@ Asset::~Asset(void)
|
|||||||
mPrev->mNext = mNext;
|
mPrev->mNext = mNext;
|
||||||
}
|
}
|
||||||
mNext = mPrev = NULL;
|
mNext = mPrev = NULL;
|
||||||
//ALOGI("Destroying Asset in %p #%d\n", this, gCount);
|
if (kIsDebug) {
|
||||||
|
ALOGI("Destroying Asset in %p #%d\n", this, gCount);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
@@ -64,6 +64,8 @@
|
|||||||
|
|
||||||
using namespace android;
|
using namespace android;
|
||||||
|
|
||||||
|
static const bool kIsDebug = false;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Names for default app, locale, and vendor. We might want to change
|
* Names for default app, locale, and vendor. We might want to change
|
||||||
* these to be an actual locale, e.g. always use en-US as the default.
|
* these to be an actual locale, e.g. always use en-US as the default.
|
||||||
@@ -153,14 +155,18 @@ AssetManager::AssetManager(CacheMode cacheMode)
|
|||||||
mCacheMode(cacheMode), mCacheValid(false)
|
mCacheMode(cacheMode), mCacheValid(false)
|
||||||
{
|
{
|
||||||
int count = android_atomic_inc(&gCount) + 1;
|
int count = android_atomic_inc(&gCount) + 1;
|
||||||
//ALOGI("Creating AssetManager %p #%d\n", this, count);
|
if (kIsDebug) {
|
||||||
|
ALOGI("Creating AssetManager %p #%d\n", this, count);
|
||||||
|
}
|
||||||
memset(mConfig, 0, sizeof(ResTable_config));
|
memset(mConfig, 0, sizeof(ResTable_config));
|
||||||
}
|
}
|
||||||
|
|
||||||
AssetManager::~AssetManager(void)
|
AssetManager::~AssetManager(void)
|
||||||
{
|
{
|
||||||
int count = android_atomic_dec(&gCount);
|
int count = android_atomic_dec(&gCount);
|
||||||
//ALOGI("Destroying AssetManager in %p #%d\n", this, count);
|
if (kIsDebug) {
|
||||||
|
ALOGI("Destroying AssetManager in %p #%d\n", this, count);
|
||||||
|
}
|
||||||
|
|
||||||
delete mConfig;
|
delete mConfig;
|
||||||
delete mResources;
|
delete mResources;
|
||||||
@@ -1864,7 +1870,9 @@ AssetManager::SharedZip::SharedZip(const String8& path, time_t modWhen)
|
|||||||
: mPath(path), mZipFile(NULL), mModWhen(modWhen),
|
: mPath(path), mZipFile(NULL), mModWhen(modWhen),
|
||||||
mResourceTableAsset(NULL), mResourceTable(NULL)
|
mResourceTableAsset(NULL), mResourceTable(NULL)
|
||||||
{
|
{
|
||||||
//ALOGI("Creating SharedZip %p %s\n", this, (const char*)mPath);
|
if (kIsDebug) {
|
||||||
|
ALOGI("Creating SharedZip %p %s\n", this, (const char*)mPath);
|
||||||
|
}
|
||||||
ALOGV("+++ opening zip '%s'\n", mPath.string());
|
ALOGV("+++ opening zip '%s'\n", mPath.string());
|
||||||
mZipFile = ZipFileRO::open(mPath.string());
|
mZipFile = ZipFileRO::open(mPath.string());
|
||||||
if (mZipFile == NULL) {
|
if (mZipFile == NULL) {
|
||||||
@@ -1958,7 +1966,9 @@ bool AssetManager::SharedZip::getOverlay(size_t idx, asset_path* out) const
|
|||||||
|
|
||||||
AssetManager::SharedZip::~SharedZip()
|
AssetManager::SharedZip::~SharedZip()
|
||||||
{
|
{
|
||||||
//ALOGI("Destroying SharedZip %p %s\n", this, (const char*)mPath);
|
if (kIsDebug) {
|
||||||
|
ALOGI("Destroying SharedZip %p %s\n", this, (const char*)mPath);
|
||||||
|
}
|
||||||
if (mResourceTable != NULL) {
|
if (mResourceTable != NULL) {
|
||||||
delete mResourceTable;
|
delete mResourceTable;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,7 +27,7 @@
|
|||||||
|
|
||||||
namespace android {
|
namespace android {
|
||||||
|
|
||||||
static const bool DEBUG = false;
|
static const bool kIsDebug = false;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* File Format (v1):
|
* File Format (v1):
|
||||||
@@ -62,7 +62,7 @@ BackupDataWriter::BackupDataWriter(int fd)
|
|||||||
m_entityCount(0)
|
m_entityCount(0)
|
||||||
{
|
{
|
||||||
m_pos = (ssize_t) lseek(fd, 0, SEEK_CUR);
|
m_pos = (ssize_t) lseek(fd, 0, SEEK_CUR);
|
||||||
if (DEBUG) ALOGI("BackupDataWriter(%d) @ %ld", fd, (long)m_pos);
|
if (kIsDebug) ALOGI("BackupDataWriter(%d) @ %ld", fd, (long)m_pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
BackupDataWriter::~BackupDataWriter()
|
BackupDataWriter::~BackupDataWriter()
|
||||||
@@ -79,7 +79,7 @@ BackupDataWriter::write_padding_for(int n)
|
|||||||
paddingSize = padding_extra(n);
|
paddingSize = padding_extra(n);
|
||||||
if (paddingSize > 0) {
|
if (paddingSize > 0) {
|
||||||
uint32_t padding = 0xbcbcbcbc;
|
uint32_t padding = 0xbcbcbcbc;
|
||||||
if (DEBUG) ALOGI("writing %zd padding bytes for %d", paddingSize, n);
|
if (kIsDebug) ALOGI("writing %zd padding bytes for %d", paddingSize, n);
|
||||||
amt = write(m_fd, &padding, paddingSize);
|
amt = write(m_fd, &padding, paddingSize);
|
||||||
if (amt != paddingSize) {
|
if (amt != paddingSize) {
|
||||||
m_status = errno;
|
m_status = errno;
|
||||||
@@ -112,7 +112,7 @@ BackupDataWriter::WriteEntityHeader(const String8& key, size_t dataSize)
|
|||||||
} else {
|
} else {
|
||||||
k = key;
|
k = key;
|
||||||
}
|
}
|
||||||
if (DEBUG) {
|
if (kIsDebug) {
|
||||||
ALOGD("Writing header: prefix='%s' key='%s' dataSize=%zu", m_keyPrefix.string(),
|
ALOGD("Writing header: prefix='%s' key='%s' dataSize=%zu", m_keyPrefix.string(),
|
||||||
key.string(), dataSize);
|
key.string(), dataSize);
|
||||||
}
|
}
|
||||||
@@ -126,7 +126,7 @@ BackupDataWriter::WriteEntityHeader(const String8& key, size_t dataSize)
|
|||||||
header.keyLen = tolel(keyLen);
|
header.keyLen = tolel(keyLen);
|
||||||
header.dataSize = tolel(dataSize);
|
header.dataSize = tolel(dataSize);
|
||||||
|
|
||||||
if (DEBUG) ALOGI("writing entity header, %zu bytes", sizeof(entity_header_v1));
|
if (kIsDebug) ALOGI("writing entity header, %zu bytes", sizeof(entity_header_v1));
|
||||||
amt = write(m_fd, &header, sizeof(entity_header_v1));
|
amt = write(m_fd, &header, sizeof(entity_header_v1));
|
||||||
if (amt != sizeof(entity_header_v1)) {
|
if (amt != sizeof(entity_header_v1)) {
|
||||||
m_status = errno;
|
m_status = errno;
|
||||||
@@ -134,7 +134,7 @@ BackupDataWriter::WriteEntityHeader(const String8& key, size_t dataSize)
|
|||||||
}
|
}
|
||||||
m_pos += amt;
|
m_pos += amt;
|
||||||
|
|
||||||
if (DEBUG) ALOGI("writing entity header key, %zd bytes", keyLen+1);
|
if (kIsDebug) ALOGI("writing entity header key, %zd bytes", keyLen+1);
|
||||||
amt = write(m_fd, k.string(), keyLen+1);
|
amt = write(m_fd, k.string(), keyLen+1);
|
||||||
if (amt != keyLen+1) {
|
if (amt != keyLen+1) {
|
||||||
m_status = errno;
|
m_status = errno;
|
||||||
@@ -152,10 +152,10 @@ BackupDataWriter::WriteEntityHeader(const String8& key, size_t dataSize)
|
|||||||
status_t
|
status_t
|
||||||
BackupDataWriter::WriteEntityData(const void* data, size_t size)
|
BackupDataWriter::WriteEntityData(const void* data, size_t size)
|
||||||
{
|
{
|
||||||
if (DEBUG) ALOGD("Writing data: size=%lu", (unsigned long) size);
|
if (kIsDebug) ALOGD("Writing data: size=%lu", (unsigned long) size);
|
||||||
|
|
||||||
if (m_status != NO_ERROR) {
|
if (m_status != NO_ERROR) {
|
||||||
if (DEBUG) {
|
if (kIsDebug) {
|
||||||
ALOGD("Not writing data - stream in error state %d (%s)", m_status, strerror(m_status));
|
ALOGD("Not writing data - stream in error state %d (%s)", m_status, strerror(m_status));
|
||||||
}
|
}
|
||||||
return m_status;
|
return m_status;
|
||||||
@@ -167,7 +167,7 @@ BackupDataWriter::WriteEntityData(const void* data, size_t size)
|
|||||||
ssize_t amt = write(m_fd, data, size);
|
ssize_t amt = write(m_fd, data, size);
|
||||||
if (amt != (ssize_t)size) {
|
if (amt != (ssize_t)size) {
|
||||||
m_status = errno;
|
m_status = errno;
|
||||||
if (DEBUG) ALOGD("write returned error %d (%s)", m_status, strerror(m_status));
|
if (kIsDebug) ALOGD("write returned error %d (%s)", m_status, strerror(m_status));
|
||||||
return m_status;
|
return m_status;
|
||||||
}
|
}
|
||||||
m_pos += amt;
|
m_pos += amt;
|
||||||
@@ -189,7 +189,7 @@ BackupDataReader::BackupDataReader(int fd)
|
|||||||
{
|
{
|
||||||
memset(&m_header, 0, sizeof(m_header));
|
memset(&m_header, 0, sizeof(m_header));
|
||||||
m_pos = (ssize_t) lseek(fd, 0, SEEK_CUR);
|
m_pos = (ssize_t) lseek(fd, 0, SEEK_CUR);
|
||||||
if (DEBUG) ALOGI("BackupDataReader(%d) @ %ld", fd, (long)m_pos);
|
if (kIsDebug) ALOGI("BackupDataReader(%d) @ %ld", fd, (long)m_pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
BackupDataReader::~BackupDataReader()
|
BackupDataReader::~BackupDataReader()
|
||||||
@@ -342,15 +342,19 @@ BackupDataReader::ReadEntityData(void* data, size_t size)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
int remaining = m_dataEndPos - m_pos;
|
int remaining = m_dataEndPos - m_pos;
|
||||||
//ALOGD("ReadEntityData size=%d m_pos=0x%x m_dataEndPos=0x%x remaining=%d\n",
|
if (kIsDebug) {
|
||||||
// size, m_pos, m_dataEndPos, remaining);
|
ALOGD("ReadEntityData size=%d m_pos=0x%x m_dataEndPos=0x%x remaining=%d\n",
|
||||||
|
size, m_pos, m_dataEndPos, remaining);
|
||||||
|
}
|
||||||
if (remaining <= 0) {
|
if (remaining <= 0) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if (((int)size) > remaining) {
|
if (((int)size) > remaining) {
|
||||||
size = remaining;
|
size = remaining;
|
||||||
}
|
}
|
||||||
//ALOGD(" reading %d bytes", size);
|
if (kIsDebug) {
|
||||||
|
ALOGD(" reading %d bytes", size);
|
||||||
|
}
|
||||||
int amt = read(m_fd, data, size);
|
int amt = read(m_fd, data, size);
|
||||||
if (amt < 0) {
|
if (amt < 0) {
|
||||||
m_status = errno;
|
m_status = errno;
|
||||||
|
|||||||
@@ -68,14 +68,11 @@ struct file_metadata_v1 {
|
|||||||
|
|
||||||
const static int CURRENT_METADATA_VERSION = 1;
|
const static int CURRENT_METADATA_VERSION = 1;
|
||||||
|
|
||||||
#if 1
|
static const bool kIsDebug = false;
|
||||||
#define LOGP(f, x...)
|
|
||||||
#else
|
|
||||||
#if TEST_BACKUP_HELPERS
|
#if TEST_BACKUP_HELPERS
|
||||||
#define LOGP(f, x...) printf(f "\n", x)
|
#define LOGP(f, x...) if (kIsDebug) printf(f "\n", x)
|
||||||
#else
|
#else
|
||||||
#define LOGP(x...) ALOGD(x)
|
#define LOGP(x...) if (kIsDebug) ALOGD(x)
|
||||||
#endif
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
const static int ROUND_UP[4] = { 0, 3, 2, 1 };
|
const static int ROUND_UP[4] = { 0, 3, 2, 1 };
|
||||||
@@ -204,13 +201,6 @@ write_snapshot_file(int fd, const KeyedVector<String8,FileRec>& snapshot)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
|
||||||
write_delete_file(BackupDataWriter* dataStream, const String8& key)
|
|
||||||
{
|
|
||||||
LOGP("write_delete_file %s\n", key.string());
|
|
||||||
return dataStream->WriteEntityHeader(key, -1);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
write_update_file(BackupDataWriter* dataStream, int fd, int mode, const String8& key,
|
write_update_file(BackupDataWriter* dataStream, int fd, int mode, const String8& key,
|
||||||
char const* realFilename)
|
char const* realFilename)
|
||||||
@@ -225,8 +215,6 @@ write_update_file(BackupDataWriter* dataStream, int fd, int mode, const String8&
|
|||||||
file_metadata_v1 metadata;
|
file_metadata_v1 metadata;
|
||||||
|
|
||||||
char* buf = (char*)malloc(bufsize);
|
char* buf = (char*)malloc(bufsize);
|
||||||
int crc = crc32(0L, Z_NULL, 0);
|
|
||||||
|
|
||||||
|
|
||||||
fileSize = lseek(fd, 0, SEEK_END);
|
fileSize = lseek(fd, 0, SEEK_END);
|
||||||
lseek(fd, 0, SEEK_SET);
|
lseek(fd, 0, SEEK_SET);
|
||||||
@@ -442,18 +430,6 @@ back_up_files(int oldSnapshotFD, BackupDataWriter* dataStream, int newSnapshotFD
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Utility function, equivalent to stpcpy(): perform a strcpy, but instead of
|
|
||||||
// returning the initial dest, return a pointer to the trailing NUL.
|
|
||||||
static char* strcpy_ptr(char* dest, const char* str) {
|
|
||||||
if (dest && str) {
|
|
||||||
while ((*dest = *str) != 0) {
|
|
||||||
dest++;
|
|
||||||
str++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return dest;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void calc_tar_checksum(char* buf) {
|
static void calc_tar_checksum(char* buf) {
|
||||||
// [ 148 : 8 ] checksum -- to be calculated with this field as space chars
|
// [ 148 : 8 ] checksum -- to be calculated with this field as space chars
|
||||||
memset(buf + 148, ' ', 8);
|
memset(buf + 148, ' ', 8);
|
||||||
@@ -635,7 +611,6 @@ int write_tarfile(const String8& packageName, const String8& domain,
|
|||||||
|
|
||||||
// construct the pax extended header data block
|
// construct the pax extended header data block
|
||||||
memset(paxData, 0, BUFSIZE - (paxData - buf));
|
memset(paxData, 0, BUFSIZE - (paxData - buf));
|
||||||
int len;
|
|
||||||
|
|
||||||
// size header -- calc len in digits by actually rendering the number
|
// size header -- calc len in digits by actually rendering the number
|
||||||
// to a string - brute force but simple
|
// to a string - brute force but simple
|
||||||
@@ -1200,7 +1175,6 @@ test_read_header_and_entity(BackupDataReader& reader, const char* str)
|
|||||||
size_t bufSize = strlen(str)+1;
|
size_t bufSize = strlen(str)+1;
|
||||||
char* buf = (char*)malloc(bufSize);
|
char* buf = (char*)malloc(bufSize);
|
||||||
String8 string;
|
String8 string;
|
||||||
int cookie = 0x11111111;
|
|
||||||
size_t actualSize;
|
size_t actualSize;
|
||||||
bool done;
|
bool done;
|
||||||
int type;
|
int type;
|
||||||
@@ -1490,7 +1464,6 @@ int
|
|||||||
backup_helper_test_null_base()
|
backup_helper_test_null_base()
|
||||||
{
|
{
|
||||||
int err;
|
int err;
|
||||||
int oldSnapshotFD;
|
|
||||||
int dataStreamFD;
|
int dataStreamFD;
|
||||||
int newSnapshotFD;
|
int newSnapshotFD;
|
||||||
|
|
||||||
@@ -1539,7 +1512,6 @@ int
|
|||||||
backup_helper_test_missing_file()
|
backup_helper_test_missing_file()
|
||||||
{
|
{
|
||||||
int err;
|
int err;
|
||||||
int oldSnapshotFD;
|
|
||||||
int dataStreamFD;
|
int dataStreamFD;
|
||||||
int newSnapshotFD;
|
int newSnapshotFD;
|
||||||
|
|
||||||
|
|||||||
@@ -122,7 +122,7 @@ bool ObbFile::parseObbFile(int fd)
|
|||||||
if (fileLength < 0) {
|
if (fileLength < 0) {
|
||||||
ALOGW("error seeking in ObbFile: %s\n", strerror(errno));
|
ALOGW("error seeking in ObbFile: %s\n", strerror(errno));
|
||||||
} else {
|
} else {
|
||||||
ALOGW("file is only %lld (less than %d minimum)\n", fileLength, kFooterMinSize);
|
ALOGW("file is only %lld (less than %d minimum)\n", (long long int)fileLength, kFooterMinSize);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -150,8 +150,8 @@ bool ObbFile::parseObbFile(int fd)
|
|||||||
footerSize = get4LE((unsigned char*)footer);
|
footerSize = get4LE((unsigned char*)footer);
|
||||||
if (footerSize > (size_t)fileLength - kFooterTagSize
|
if (footerSize > (size_t)fileLength - kFooterTagSize
|
||||||
|| footerSize > kMaxBufSize) {
|
|| footerSize > kMaxBufSize) {
|
||||||
ALOGW("claimed footer size is too large (0x%08zx; file size is 0x%08llx)\n",
|
ALOGW("claimed footer size is too large (0x%08zx; file size is 0x%08lld)\n",
|
||||||
footerSize, fileLength);
|
footerSize, (long long int)fileLength);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -164,7 +164,7 @@ bool ObbFile::parseObbFile(int fd)
|
|||||||
|
|
||||||
off64_t fileOffset = fileLength - footerSize - kFooterTagSize;
|
off64_t fileOffset = fileLength - footerSize - kFooterTagSize;
|
||||||
if (lseek64(fd, fileOffset, SEEK_SET) != fileOffset) {
|
if (lseek64(fd, fileOffset, SEEK_SET) != fileOffset) {
|
||||||
ALOGW("seek %lld failed: %s\n", fileOffset, strerror(errno));
|
ALOGW("seek %lld failed: %s\n", (long long int)fileOffset, strerror(errno));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -27,6 +27,10 @@
|
|||||||
#include <utils/String16.h>
|
#include <utils/String16.h>
|
||||||
#include <utils/String8.h>
|
#include <utils/String8.h>
|
||||||
|
|
||||||
|
#ifdef HAVE_ANDROID_OS
|
||||||
|
#include <binder/TextOutput.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <memory.h>
|
#include <memory.h>
|
||||||
@@ -38,15 +42,6 @@
|
|||||||
#define INT32_MAX ((int32_t)(2147483647))
|
#define INT32_MAX ((int32_t)(2147483647))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define STRING_POOL_NOISY(x) //x
|
|
||||||
#define XML_NOISY(x) //x
|
|
||||||
#define TABLE_NOISY(x) //x
|
|
||||||
#define TABLE_GETENTRY(x) //x
|
|
||||||
#define TABLE_SUPER_NOISY(x) //x
|
|
||||||
#define LOAD_TABLE_NOISY(x) //x
|
|
||||||
#define TABLE_THEME(x) //x
|
|
||||||
#define LIB_NOISY(x) //x
|
|
||||||
|
|
||||||
namespace android {
|
namespace android {
|
||||||
|
|
||||||
#ifdef HAVE_WINSOCK
|
#ifdef HAVE_WINSOCK
|
||||||
@@ -72,6 +67,19 @@ namespace android {
|
|||||||
#define APP_PACKAGE_ID 0x7f
|
#define APP_PACKAGE_ID 0x7f
|
||||||
#define SYS_PACKAGE_ID 0x01
|
#define SYS_PACKAGE_ID 0x01
|
||||||
|
|
||||||
|
static const bool kDebugStringPoolNoisy = false;
|
||||||
|
static const bool kDebugXMLNoisy = false;
|
||||||
|
static const bool kDebugTableNoisy = false;
|
||||||
|
static const bool kDebugTableGetEntry = false;
|
||||||
|
static const bool kDebugTableSuperNoisy = false;
|
||||||
|
static const bool kDebugLoadTableNoisy = false;
|
||||||
|
static const bool kDebugLoadTableSuperNoisy = false;
|
||||||
|
static const bool kDebugTableTheme = false;
|
||||||
|
static const bool kDebugResXMLTree = false;
|
||||||
|
static const bool kDebugLibNoisy = false;
|
||||||
|
|
||||||
|
// TODO: This code uses 0xFFFFFFFF converted to bag_set* as a sentinel value. This is bad practice.
|
||||||
|
|
||||||
// Standard C isspace() is only required to look at the low byte of its input, so
|
// Standard C isspace() is only required to look at the low byte of its input, so
|
||||||
// produces incorrect results for UTF-16 characters. For safety's sake, assume that
|
// produces incorrect results for UTF-16 characters. For safety's sake, assume that
|
||||||
// any high-byte UTF-16 code point is not whitespace.
|
// any high-byte UTF-16 code point is not whitespace.
|
||||||
@@ -719,8 +727,10 @@ const char16_t* ResStringPool::stringAt(size_t idx, size_t* u16len) const
|
|||||||
|
|
||||||
if (mCache == NULL) {
|
if (mCache == NULL) {
|
||||||
#ifndef HAVE_ANDROID_OS
|
#ifndef HAVE_ANDROID_OS
|
||||||
STRING_POOL_NOISY(ALOGI("CREATING STRING CACHE OF %d bytes",
|
if (kDebugStringPoolNoisy) {
|
||||||
mHeader->stringCount*sizeof(char16_t**)));
|
ALOGI("CREATING STRING CACHE OF %zu bytes",
|
||||||
|
mHeader->stringCount*sizeof(char16_t**));
|
||||||
|
}
|
||||||
#else
|
#else
|
||||||
// We do not want to be in this case when actually running Android.
|
// We do not want to be in this case when actually running Android.
|
||||||
ALOGW("CREATING STRING CACHE OF %d bytes",
|
ALOGW("CREATING STRING CACHE OF %d bytes",
|
||||||
@@ -753,7 +763,9 @@ const char16_t* ResStringPool::stringAt(size_t idx, size_t* u16len) const
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
STRING_POOL_NOISY(ALOGI("Caching UTF8 string: %s", u8str));
|
if (kDebugStringPoolNoisy) {
|
||||||
|
ALOGI("Caching UTF8 string: %s", u8str);
|
||||||
|
}
|
||||||
utf8_to_utf16(u8str, u8len, u16str);
|
utf8_to_utf16(u8str, u8len, u16str);
|
||||||
mCache[idx] = u16str;
|
mCache[idx] = u16str;
|
||||||
return u16str;
|
return u16str;
|
||||||
@@ -843,7 +855,9 @@ ssize_t ResStringPool::indexOfString(const char16_t* str, size_t strLen) const
|
|||||||
size_t len;
|
size_t len;
|
||||||
|
|
||||||
if ((mHeader->flags&ResStringPool_header::UTF8_FLAG) != 0) {
|
if ((mHeader->flags&ResStringPool_header::UTF8_FLAG) != 0) {
|
||||||
STRING_POOL_NOISY(ALOGI("indexOfString UTF-8: %s", String8(str, strLen).string()));
|
if (kDebugStringPoolNoisy) {
|
||||||
|
ALOGI("indexOfString UTF-8: %s", String8(str, strLen).string());
|
||||||
|
}
|
||||||
|
|
||||||
// The string pool contains UTF 8 strings; we don't want to cause
|
// The string pool contains UTF 8 strings; we don't want to cause
|
||||||
// temporary UTF-16 strings to be created as we search.
|
// temporary UTF-16 strings to be created as we search.
|
||||||
@@ -869,10 +883,14 @@ ssize_t ResStringPool::indexOfString(const char16_t* str, size_t strLen) const
|
|||||||
} else {
|
} else {
|
||||||
c = -1;
|
c = -1;
|
||||||
}
|
}
|
||||||
STRING_POOL_NOISY(ALOGI("Looking at %s, cmp=%d, l/mid/h=%d/%d/%d\n",
|
if (kDebugStringPoolNoisy) {
|
||||||
(const char*)s, c, (int)l, (int)mid, (int)h));
|
ALOGI("Looking at %s, cmp=%d, l/mid/h=%d/%d/%d\n",
|
||||||
|
(const char*)s, c, (int)l, (int)mid, (int)h);
|
||||||
|
}
|
||||||
if (c == 0) {
|
if (c == 0) {
|
||||||
STRING_POOL_NOISY(ALOGI("MATCH!"));
|
if (kDebugStringPoolNoisy) {
|
||||||
|
ALOGI("MATCH!");
|
||||||
|
}
|
||||||
free(convBuffer);
|
free(convBuffer);
|
||||||
return mid;
|
return mid;
|
||||||
} else if (c < 0) {
|
} else if (c < 0) {
|
||||||
@@ -891,18 +909,22 @@ ssize_t ResStringPool::indexOfString(const char16_t* str, size_t strLen) const
|
|||||||
const size_t str8Len = str8.size();
|
const size_t str8Len = str8.size();
|
||||||
for (int i=mHeader->stringCount-1; i>=0; i--) {
|
for (int i=mHeader->stringCount-1; i>=0; i--) {
|
||||||
const char* s = string8At(i, &len);
|
const char* s = string8At(i, &len);
|
||||||
STRING_POOL_NOISY(ALOGI("Looking at %s, i=%d\n",
|
if (kDebugStringPoolNoisy) {
|
||||||
String8(s).string(),
|
ALOGI("Looking at %s, i=%d\n", String8(s).string(), i);
|
||||||
i));
|
}
|
||||||
if (s && str8Len == len && memcmp(s, str8.string(), str8Len) == 0) {
|
if (s && str8Len == len && memcmp(s, str8.string(), str8Len) == 0) {
|
||||||
STRING_POOL_NOISY(ALOGI("MATCH!"));
|
if (kDebugStringPoolNoisy) {
|
||||||
|
ALOGI("MATCH!");
|
||||||
|
}
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
STRING_POOL_NOISY(ALOGI("indexOfString UTF-16: %s", String8(str, strLen).string()));
|
if (kDebugStringPoolNoisy) {
|
||||||
|
ALOGI("indexOfString UTF-16: %s", String8(str, strLen).string());
|
||||||
|
}
|
||||||
|
|
||||||
if (mHeader->flags&ResStringPool_header::SORTED_FLAG) {
|
if (mHeader->flags&ResStringPool_header::SORTED_FLAG) {
|
||||||
// Do a binary search for the string...
|
// Do a binary search for the string...
|
||||||
@@ -914,11 +936,14 @@ ssize_t ResStringPool::indexOfString(const char16_t* str, size_t strLen) const
|
|||||||
mid = l + (h - l)/2;
|
mid = l + (h - l)/2;
|
||||||
const char16_t* s = stringAt(mid, &len);
|
const char16_t* s = stringAt(mid, &len);
|
||||||
int c = s ? strzcmp16(s, len, str, strLen) : -1;
|
int c = s ? strzcmp16(s, len, str, strLen) : -1;
|
||||||
STRING_POOL_NOISY(ALOGI("Looking at %s, cmp=%d, l/mid/h=%d/%d/%d\n",
|
if (kDebugStringPoolNoisy) {
|
||||||
String8(s).string(),
|
ALOGI("Looking at %s, cmp=%d, l/mid/h=%d/%d/%d\n",
|
||||||
c, (int)l, (int)mid, (int)h));
|
String8(s).string(), c, (int)l, (int)mid, (int)h);
|
||||||
|
}
|
||||||
if (c == 0) {
|
if (c == 0) {
|
||||||
STRING_POOL_NOISY(ALOGI("MATCH!"));
|
if (kDebugStringPoolNoisy) {
|
||||||
|
ALOGI("MATCH!");
|
||||||
|
}
|
||||||
return mid;
|
return mid;
|
||||||
} else if (c < 0) {
|
} else if (c < 0) {
|
||||||
l = mid + 1;
|
l = mid + 1;
|
||||||
@@ -933,11 +958,13 @@ ssize_t ResStringPool::indexOfString(const char16_t* str, size_t strLen) const
|
|||||||
// block, start searching at the back.
|
// block, start searching at the back.
|
||||||
for (int i=mHeader->stringCount-1; i>=0; i--) {
|
for (int i=mHeader->stringCount-1; i>=0; i--) {
|
||||||
const char16_t* s = stringAt(i, &len);
|
const char16_t* s = stringAt(i, &len);
|
||||||
STRING_POOL_NOISY(ALOGI("Looking at %s, i=%d\n",
|
if (kDebugStringPoolNoisy) {
|
||||||
String8(s).string(),
|
ALOGI("Looking at %s, i=%d\n", String8(s).string(), i);
|
||||||
i));
|
}
|
||||||
if (s && strLen == len && strzcmp16(s, len, str, strLen) == 0) {
|
if (s && strLen == len && strzcmp16(s, len, str, strLen) == 0) {
|
||||||
STRING_POOL_NOISY(ALOGI("MATCH!"));
|
if (kDebugStringPoolNoisy) {
|
||||||
|
ALOGI("MATCH!");
|
||||||
|
}
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1138,7 +1165,9 @@ const char16_t* ResXMLParser::getAttributeNamespace(size_t idx, size_t* outLen)
|
|||||||
{
|
{
|
||||||
int32_t id = getAttributeNamespaceID(idx);
|
int32_t id = getAttributeNamespaceID(idx);
|
||||||
//printf("attribute namespace=%d idx=%d event=%p\n", id, idx, mEventCode);
|
//printf("attribute namespace=%d idx=%d event=%p\n", id, idx, mEventCode);
|
||||||
//XML_NOISY(printf("getAttributeNamespace 0x%x=0x%x\n", idx, id));
|
if (kDebugXMLNoisy) {
|
||||||
|
printf("getAttributeNamespace 0x%zx=0x%x\n", idx, id);
|
||||||
|
}
|
||||||
return id >= 0 ? mTree.mStrings.stringAt(id, outLen) : NULL;
|
return id >= 0 ? mTree.mStrings.stringAt(id, outLen) : NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1146,7 +1175,9 @@ const char* ResXMLParser::getAttributeNamespace8(size_t idx, size_t* outLen) con
|
|||||||
{
|
{
|
||||||
int32_t id = getAttributeNamespaceID(idx);
|
int32_t id = getAttributeNamespaceID(idx);
|
||||||
//printf("attribute namespace=%d idx=%d event=%p\n", id, idx, mEventCode);
|
//printf("attribute namespace=%d idx=%d event=%p\n", id, idx, mEventCode);
|
||||||
//XML_NOISY(printf("getAttributeNamespace 0x%x=0x%x\n", idx, id));
|
if (kDebugXMLNoisy) {
|
||||||
|
printf("getAttributeNamespace 0x%zx=0x%x\n", idx, id);
|
||||||
|
}
|
||||||
return id >= 0 ? mTree.mStrings.string8At(id, outLen) : NULL;
|
return id >= 0 ? mTree.mStrings.string8At(id, outLen) : NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1169,7 +1200,9 @@ const char16_t* ResXMLParser::getAttributeName(size_t idx, size_t* outLen) const
|
|||||||
{
|
{
|
||||||
int32_t id = getAttributeNameID(idx);
|
int32_t id = getAttributeNameID(idx);
|
||||||
//printf("attribute name=%d idx=%d event=%p\n", id, idx, mEventCode);
|
//printf("attribute name=%d idx=%d event=%p\n", id, idx, mEventCode);
|
||||||
//XML_NOISY(printf("getAttributeName 0x%x=0x%x\n", idx, id));
|
if (kDebugXMLNoisy) {
|
||||||
|
printf("getAttributeName 0x%zx=0x%x\n", idx, id);
|
||||||
|
}
|
||||||
return id >= 0 ? mTree.mStrings.stringAt(id, outLen) : NULL;
|
return id >= 0 ? mTree.mStrings.stringAt(id, outLen) : NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1177,7 +1210,9 @@ const char* ResXMLParser::getAttributeName8(size_t idx, size_t* outLen) const
|
|||||||
{
|
{
|
||||||
int32_t id = getAttributeNameID(idx);
|
int32_t id = getAttributeNameID(idx);
|
||||||
//printf("attribute name=%d idx=%d event=%p\n", id, idx, mEventCode);
|
//printf("attribute name=%d idx=%d event=%p\n", id, idx, mEventCode);
|
||||||
//XML_NOISY(printf("getAttributeName 0x%x=0x%x\n", idx, id));
|
if (kDebugXMLNoisy) {
|
||||||
|
printf("getAttributeName 0x%zx=0x%x\n", idx, id);
|
||||||
|
}
|
||||||
return id >= 0 ? mTree.mStrings.string8At(id, outLen) : NULL;
|
return id >= 0 ? mTree.mStrings.string8At(id, outLen) : NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1208,7 +1243,9 @@ int32_t ResXMLParser::getAttributeValueStringID(size_t idx) const
|
|||||||
const char16_t* ResXMLParser::getAttributeStringValue(size_t idx, size_t* outLen) const
|
const char16_t* ResXMLParser::getAttributeStringValue(size_t idx, size_t* outLen) const
|
||||||
{
|
{
|
||||||
int32_t id = getAttributeValueStringID(idx);
|
int32_t id = getAttributeValueStringID(idx);
|
||||||
//XML_NOISY(printf("getAttributeValue 0x%x=0x%x\n", idx, id));
|
if (kDebugXMLNoisy) {
|
||||||
|
printf("getAttributeValue 0x%zx=0x%x\n", idx, id);
|
||||||
|
}
|
||||||
return id >= 0 ? mTree.mStrings.stringAt(id, outLen) : NULL;
|
return id >= 0 ? mTree.mStrings.stringAt(id, outLen) : NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1299,54 +1336,69 @@ ssize_t ResXMLParser::indexOfAttribute(const char16_t* ns, size_t nsLen,
|
|||||||
ns8 = String8(ns, nsLen);
|
ns8 = String8(ns, nsLen);
|
||||||
}
|
}
|
||||||
attr8 = String8(attr, attrLen);
|
attr8 = String8(attr, attrLen);
|
||||||
STRING_POOL_NOISY(ALOGI("indexOfAttribute UTF8 %s (%d) / %s (%d)", ns8.string(), nsLen,
|
if (kDebugStringPoolNoisy) {
|
||||||
attr8.string(), attrLen));
|
ALOGI("indexOfAttribute UTF8 %s (%zu) / %s (%zu)", ns8.string(), nsLen,
|
||||||
|
attr8.string(), attrLen);
|
||||||
|
}
|
||||||
for (size_t i=0; i<N; i++) {
|
for (size_t i=0; i<N; i++) {
|
||||||
size_t curNsLen = 0, curAttrLen = 0;
|
size_t curNsLen = 0, curAttrLen = 0;
|
||||||
const char* curNs = getAttributeNamespace8(i, &curNsLen);
|
const char* curNs = getAttributeNamespace8(i, &curNsLen);
|
||||||
const char* curAttr = getAttributeName8(i, &curAttrLen);
|
const char* curAttr = getAttributeName8(i, &curAttrLen);
|
||||||
STRING_POOL_NOISY(ALOGI(" curNs=%s (%d), curAttr=%s (%d)", curNs, curNsLen,
|
if (kDebugStringPoolNoisy) {
|
||||||
curAttr, curAttrLen));
|
ALOGI(" curNs=%s (%zu), curAttr=%s (%zu)", curNs, curNsLen, curAttr, curAttrLen);
|
||||||
|
}
|
||||||
if (curAttr != NULL && curNsLen == nsLen && curAttrLen == attrLen
|
if (curAttr != NULL && curNsLen == nsLen && curAttrLen == attrLen
|
||||||
&& memcmp(attr8.string(), curAttr, attrLen) == 0) {
|
&& memcmp(attr8.string(), curAttr, attrLen) == 0) {
|
||||||
if (ns == NULL) {
|
if (ns == NULL) {
|
||||||
if (curNs == NULL) {
|
if (curNs == NULL) {
|
||||||
STRING_POOL_NOISY(ALOGI(" FOUND!"));
|
if (kDebugStringPoolNoisy) {
|
||||||
|
ALOGI(" FOUND!");
|
||||||
|
}
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
} else if (curNs != NULL) {
|
} else if (curNs != NULL) {
|
||||||
//printf(" --> ns=%s, curNs=%s\n",
|
//printf(" --> ns=%s, curNs=%s\n",
|
||||||
// String8(ns).string(), String8(curNs).string());
|
// String8(ns).string(), String8(curNs).string());
|
||||||
if (memcmp(ns8.string(), curNs, nsLen) == 0) {
|
if (memcmp(ns8.string(), curNs, nsLen) == 0) {
|
||||||
STRING_POOL_NOISY(ALOGI(" FOUND!"));
|
if (kDebugStringPoolNoisy) {
|
||||||
|
ALOGI(" FOUND!");
|
||||||
|
}
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
STRING_POOL_NOISY(ALOGI("indexOfAttribute UTF16 %s (%d) / %s (%d)",
|
if (kDebugStringPoolNoisy) {
|
||||||
|
ALOGI("indexOfAttribute UTF16 %s (%zu) / %s (%zu)",
|
||||||
String8(ns, nsLen).string(), nsLen,
|
String8(ns, nsLen).string(), nsLen,
|
||||||
String8(attr, attrLen).string(), attrLen));
|
String8(attr, attrLen).string(), attrLen);
|
||||||
|
}
|
||||||
for (size_t i=0; i<N; i++) {
|
for (size_t i=0; i<N; i++) {
|
||||||
size_t curNsLen = 0, curAttrLen = 0;
|
size_t curNsLen = 0, curAttrLen = 0;
|
||||||
const char16_t* curNs = getAttributeNamespace(i, &curNsLen);
|
const char16_t* curNs = getAttributeNamespace(i, &curNsLen);
|
||||||
const char16_t* curAttr = getAttributeName(i, &curAttrLen);
|
const char16_t* curAttr = getAttributeName(i, &curAttrLen);
|
||||||
STRING_POOL_NOISY(ALOGI(" curNs=%s (%d), curAttr=%s (%d)",
|
if (kDebugStringPoolNoisy) {
|
||||||
|
ALOGI(" curNs=%s (%zu), curAttr=%s (%zu)",
|
||||||
String8(curNs, curNsLen).string(), curNsLen,
|
String8(curNs, curNsLen).string(), curNsLen,
|
||||||
String8(curAttr, curAttrLen).string(), curAttrLen));
|
String8(curAttr, curAttrLen).string(), curAttrLen);
|
||||||
|
}
|
||||||
if (curAttr != NULL && curNsLen == nsLen && curAttrLen == attrLen
|
if (curAttr != NULL && curNsLen == nsLen && curAttrLen == attrLen
|
||||||
&& (memcmp(attr, curAttr, attrLen*sizeof(char16_t)) == 0)) {
|
&& (memcmp(attr, curAttr, attrLen*sizeof(char16_t)) == 0)) {
|
||||||
if (ns == NULL) {
|
if (ns == NULL) {
|
||||||
if (curNs == NULL) {
|
if (curNs == NULL) {
|
||||||
STRING_POOL_NOISY(ALOGI(" FOUND!"));
|
if (kDebugStringPoolNoisy) {
|
||||||
|
ALOGI(" FOUND!");
|
||||||
|
}
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
} else if (curNs != NULL) {
|
} else if (curNs != NULL) {
|
||||||
//printf(" --> ns=%s, curNs=%s\n",
|
//printf(" --> ns=%s, curNs=%s\n",
|
||||||
// String8(ns).string(), String8(curNs).string());
|
// String8(ns).string(), String8(curNs).string());
|
||||||
if (memcmp(ns, curNs, nsLen*sizeof(char16_t)) == 0) {
|
if (memcmp(ns, curNs, nsLen*sizeof(char16_t)) == 0) {
|
||||||
STRING_POOL_NOISY(ALOGI(" FOUND!"));
|
if (kDebugStringPoolNoisy) {
|
||||||
|
ALOGI(" FOUND!");
|
||||||
|
}
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1394,7 +1446,9 @@ ResXMLParser::event_code_t ResXMLParser::nextNode()
|
|||||||
do {
|
do {
|
||||||
const ResXMLTree_node* next = (const ResXMLTree_node*)
|
const ResXMLTree_node* next = (const ResXMLTree_node*)
|
||||||
(((const uint8_t*)mCurNode) + dtohl(mCurNode->header.size));
|
(((const uint8_t*)mCurNode) + dtohl(mCurNode->header.size));
|
||||||
//ALOGW("Next node: prev=%p, next=%p\n", mCurNode, next);
|
if (kDebugXMLNoisy) {
|
||||||
|
ALOGI("Next node: prev=%p, next=%p\n", mCurNode, next);
|
||||||
|
}
|
||||||
|
|
||||||
if (((const uint8_t*)next) >= mTree.mDataEnd) {
|
if (((const uint8_t*)next) >= mTree.mDataEnd) {
|
||||||
mCurNode = NULL;
|
mCurNode = NULL;
|
||||||
@@ -1471,7 +1525,9 @@ ResXMLTree::ResXMLTree(const DynamicRefTable* dynamicRefTable)
|
|||||||
, mDynamicRefTable(dynamicRefTable)
|
, mDynamicRefTable(dynamicRefTable)
|
||||||
, mError(NO_INIT), mOwnedData(NULL)
|
, mError(NO_INIT), mOwnedData(NULL)
|
||||||
{
|
{
|
||||||
//ALOGI("Creating ResXMLTree %p #%d\n", this, android_atomic_inc(&gCount)+1);
|
if (kDebugResXMLTree) {
|
||||||
|
ALOGI("Creating ResXMLTree %p #%d\n", this, android_atomic_inc(&gCount)+1);
|
||||||
|
}
|
||||||
restart();
|
restart();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1480,13 +1536,17 @@ ResXMLTree::ResXMLTree()
|
|||||||
, mDynamicRefTable(NULL)
|
, mDynamicRefTable(NULL)
|
||||||
, mError(NO_INIT), mOwnedData(NULL)
|
, mError(NO_INIT), mOwnedData(NULL)
|
||||||
{
|
{
|
||||||
//ALOGI("Creating ResXMLTree %p #%d\n", this, android_atomic_inc(&gCount)+1);
|
if (kDebugResXMLTree) {
|
||||||
|
ALOGI("Creating ResXMLTree %p #%d\n", this, android_atomic_inc(&gCount)+1);
|
||||||
|
}
|
||||||
restart();
|
restart();
|
||||||
}
|
}
|
||||||
|
|
||||||
ResXMLTree::~ResXMLTree()
|
ResXMLTree::~ResXMLTree()
|
||||||
{
|
{
|
||||||
//ALOGI("Destroying ResXMLTree in %p #%d\n", this, android_atomic_dec(&gCount)-1);
|
if (kDebugResXMLTree) {
|
||||||
|
ALOGI("Destroying ResXMLTree in %p #%d\n", this, android_atomic_dec(&gCount)-1);
|
||||||
|
}
|
||||||
uninit();
|
uninit();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1539,8 +1599,10 @@ status_t ResXMLTree::setTo(const void* data, size_t size, bool copyData)
|
|||||||
}
|
}
|
||||||
const uint16_t type = dtohs(chunk->type);
|
const uint16_t type = dtohs(chunk->type);
|
||||||
const size_t size = dtohl(chunk->size);
|
const size_t size = dtohl(chunk->size);
|
||||||
XML_NOISY(printf("Scanning @ %p: type=0x%x, size=0x%x\n",
|
if (kDebugXMLNoisy) {
|
||||||
(void*)(((uint32_t)chunk)-((uint32_t)mHeader)), type, size));
|
printf("Scanning @ %p: type=0x%x, size=0x%zx\n",
|
||||||
|
(void*)(((uintptr_t)chunk)-((uintptr_t)mHeader)), type, size);
|
||||||
|
}
|
||||||
if (type == RES_STRING_POOL_TYPE) {
|
if (type == RES_STRING_POOL_TYPE) {
|
||||||
mStrings.setTo(chunk, size);
|
mStrings.setTo(chunk, size);
|
||||||
} else if (type == RES_XML_RESOURCE_MAP_TYPE) {
|
} else if (type == RES_XML_RESOURCE_MAP_TYPE) {
|
||||||
@@ -1563,7 +1625,9 @@ status_t ResXMLTree::setTo(const void* data, size_t size, bool copyData)
|
|||||||
mRootCode = mEventCode;
|
mRootCode = mEventCode;
|
||||||
break;
|
break;
|
||||||
} else {
|
} else {
|
||||||
XML_NOISY(printf("Skipping unknown chunk!\n"));
|
if (kDebugXMLNoisy) {
|
||||||
|
printf("Skipping unknown chunk!\n");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
lastChunk = chunk;
|
lastChunk = chunk;
|
||||||
chunk = (const ResChunk_header*)
|
chunk = (const ResChunk_header*)
|
||||||
@@ -2147,9 +2211,11 @@ bool ResTable_config::isBetterThan(const ResTable_config& o,
|
|||||||
myDelta += requested->screenHeightDp - screenHeightDp;
|
myDelta += requested->screenHeightDp - screenHeightDp;
|
||||||
otherDelta += requested->screenHeightDp - o.screenHeightDp;
|
otherDelta += requested->screenHeightDp - o.screenHeightDp;
|
||||||
}
|
}
|
||||||
//ALOGI("Comparing this %dx%d to other %dx%d in %dx%d: myDelta=%d otherDelta=%d",
|
if (kDebugTableSuperNoisy) {
|
||||||
// screenWidthDp, screenHeightDp, o.screenWidthDp, o.screenHeightDp,
|
ALOGI("Comparing this %dx%d to other %dx%d in %dx%d: myDelta=%d otherDelta=%d",
|
||||||
// requested->screenWidthDp, requested->screenHeightDp, myDelta, otherDelta);
|
screenWidthDp, screenHeightDp, o.screenWidthDp, o.screenHeightDp,
|
||||||
|
requested->screenWidthDp, requested->screenHeightDp, myDelta, otherDelta);
|
||||||
|
}
|
||||||
if (myDelta != otherDelta) {
|
if (myDelta != otherDelta) {
|
||||||
return myDelta < otherDelta;
|
return myDelta < otherDelta;
|
||||||
}
|
}
|
||||||
@@ -2404,11 +2470,17 @@ bool ResTable_config::match(const ResTable_config& settings) const {
|
|||||||
}
|
}
|
||||||
if (screenSizeDp != 0) {
|
if (screenSizeDp != 0) {
|
||||||
if (screenWidthDp != 0 && screenWidthDp > settings.screenWidthDp) {
|
if (screenWidthDp != 0 && screenWidthDp > settings.screenWidthDp) {
|
||||||
//ALOGI("Filtering out width %d in requested %d", screenWidthDp, settings.screenWidthDp);
|
if (kDebugTableSuperNoisy) {
|
||||||
|
ALOGI("Filtering out width %d in requested %d", screenWidthDp,
|
||||||
|
settings.screenWidthDp);
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (screenHeightDp != 0 && screenHeightDp > settings.screenHeightDp) {
|
if (screenHeightDp != 0 && screenHeightDp > settings.screenHeightDp) {
|
||||||
//ALOGI("Filtering out height %d in requested %d", screenHeightDp, settings.screenHeightDp);
|
if (kDebugTableSuperNoisy) {
|
||||||
|
ALOGI("Filtering out height %d in requested %d", screenHeightDp,
|
||||||
|
settings.screenHeightDp);
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2428,9 +2500,13 @@ bool ResTable_config::match(const ResTable_config& settings) const {
|
|||||||
// For compatibility, we count a request for KEYSHIDDEN_NO as also
|
// For compatibility, we count a request for KEYSHIDDEN_NO as also
|
||||||
// matching the more recent KEYSHIDDEN_SOFT. Basically
|
// matching the more recent KEYSHIDDEN_SOFT. Basically
|
||||||
// KEYSHIDDEN_NO means there is some kind of keyboard available.
|
// KEYSHIDDEN_NO means there is some kind of keyboard available.
|
||||||
//ALOGI("Matching keysHidden: have=%d, config=%d\n", keysHidden, setKeysHidden);
|
if (kDebugTableSuperNoisy) {
|
||||||
|
ALOGI("Matching keysHidden: have=%d, config=%d\n", keysHidden, setKeysHidden);
|
||||||
|
}
|
||||||
if (keysHidden != KEYSHIDDEN_NO || setKeysHidden != KEYSHIDDEN_SOFT) {
|
if (keysHidden != KEYSHIDDEN_NO || setKeysHidden != KEYSHIDDEN_SOFT) {
|
||||||
//ALOGI("No match!");
|
if (kDebugTableSuperNoisy) {
|
||||||
|
ALOGI("No match!");
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2935,16 +3011,24 @@ struct ResTable::PackageGroup
|
|||||||
|
|
||||||
void clearBagCache() {
|
void clearBagCache() {
|
||||||
if (bags) {
|
if (bags) {
|
||||||
TABLE_NOISY(printf("bags=%p\n", bags));
|
if (kDebugTableNoisy) {
|
||||||
|
printf("bags=%p\n", bags);
|
||||||
|
}
|
||||||
for (size_t i = 0; i < bags->size(); i++) {
|
for (size_t i = 0; i < bags->size(); i++) {
|
||||||
TABLE_NOISY(printf("type=%d\n", i));
|
if (kDebugTableNoisy) {
|
||||||
|
printf("type=%zu\n", i);
|
||||||
|
}
|
||||||
const TypeList& typeList = types[i];
|
const TypeList& typeList = types[i];
|
||||||
if (!typeList.isEmpty()) {
|
if (!typeList.isEmpty()) {
|
||||||
bag_set** typeBags = bags->get(i);
|
bag_set** typeBags = bags->get(i);
|
||||||
TABLE_NOISY(printf("typeBags=%p\n", typeBags));
|
if (kDebugTableNoisy) {
|
||||||
|
printf("typeBags=%p\n", typeBags);
|
||||||
|
}
|
||||||
if (typeBags) {
|
if (typeBags) {
|
||||||
const size_t N = typeList[0]->entryCount;
|
const size_t N = typeList[0]->entryCount;
|
||||||
TABLE_NOISY(printf("type->entryCount=%x\n", N));
|
if (kDebugTableNoisy) {
|
||||||
|
printf("type->entryCount=%zu\n", N);
|
||||||
|
}
|
||||||
for (size_t j = 0; j < N; j++) {
|
for (size_t j = 0; j < N; j++) {
|
||||||
if (typeBags[j] && typeBags[j] != (bag_set*)0xFFFFFFFF)
|
if (typeBags[j] && typeBags[j] != (bag_set*)0xFFFFFFFF)
|
||||||
free(typeBags[j]);
|
free(typeBags[j]);
|
||||||
@@ -3053,7 +3137,9 @@ status_t ResTable::Theme::applyStyle(uint32_t resID, bool force)
|
|||||||
uint32_t bagTypeSpecFlags = 0;
|
uint32_t bagTypeSpecFlags = 0;
|
||||||
mTable.lock();
|
mTable.lock();
|
||||||
const ssize_t N = mTable.getBagLocked(resID, &bag, &bagTypeSpecFlags);
|
const ssize_t N = mTable.getBagLocked(resID, &bag, &bagTypeSpecFlags);
|
||||||
TABLE_NOISY(ALOGV("Applying style 0x%08x to theme %p, count=%d", resID, this, N));
|
if (kDebugTableNoisy) {
|
||||||
|
ALOGV("Applying style 0x%08x to theme %p, count=%zu", resID, this, N);
|
||||||
|
}
|
||||||
if (N < 0) {
|
if (N < 0) {
|
||||||
mTable.unlock();
|
mTable.unlock();
|
||||||
return N;
|
return N;
|
||||||
@@ -3084,7 +3170,6 @@ status_t ResTable::Theme::applyStyle(uint32_t resID, bool force)
|
|||||||
curPackageIndex = pidx;
|
curPackageIndex = pidx;
|
||||||
curPI = mPackages[pidx];
|
curPI = mPackages[pidx];
|
||||||
if (curPI == NULL) {
|
if (curPI == NULL) {
|
||||||
PackageGroup* const grp = mTable.mPackageGroups[pidx];
|
|
||||||
curPI = (package_info*)malloc(sizeof(package_info));
|
curPI = (package_info*)malloc(sizeof(package_info));
|
||||||
memset(curPI, 0, sizeof(*curPI));
|
memset(curPI, 0, sizeof(*curPI));
|
||||||
mPackages[pidx] = curPI;
|
mPackages[pidx] = curPI;
|
||||||
@@ -3116,9 +3201,11 @@ status_t ResTable::Theme::applyStyle(uint32_t resID, bool force)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
theme_entry* curEntry = curEntries + e;
|
theme_entry* curEntry = curEntries + e;
|
||||||
TABLE_NOISY(ALOGV("Attr 0x%08x: type=0x%x, data=0x%08x; curType=0x%x",
|
if (kDebugTableNoisy) {
|
||||||
|
ALOGV("Attr 0x%08x: type=0x%x, data=0x%08x; curType=0x%x",
|
||||||
attrRes, bag->map.value.dataType, bag->map.value.data,
|
attrRes, bag->map.value.dataType, bag->map.value.data,
|
||||||
curEntry->value.dataType));
|
curEntry->value.dataType);
|
||||||
|
}
|
||||||
if (force || curEntry->value.dataType == Res_value::TYPE_NULL) {
|
if (force || curEntry->value.dataType == Res_value::TYPE_NULL) {
|
||||||
curEntry->stringBlock = bag->stringBlock;
|
curEntry->stringBlock = bag->stringBlock;
|
||||||
curEntry->typeSpecFlags |= bagTypeSpecFlags;
|
curEntry->typeSpecFlags |= bagTypeSpecFlags;
|
||||||
@@ -3130,17 +3217,21 @@ status_t ResTable::Theme::applyStyle(uint32_t resID, bool force)
|
|||||||
|
|
||||||
mTable.unlock();
|
mTable.unlock();
|
||||||
|
|
||||||
//ALOGI("Applying style 0x%08x (force=%d) theme %p...\n", resID, force, this);
|
if (kDebugTableTheme) {
|
||||||
//dumpToLog();
|
ALOGI("Applying style 0x%08x (force=%d) theme %p...\n", resID, force, this);
|
||||||
|
dumpToLog();
|
||||||
|
}
|
||||||
|
|
||||||
return NO_ERROR;
|
return NO_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
status_t ResTable::Theme::setTo(const Theme& other)
|
status_t ResTable::Theme::setTo(const Theme& other)
|
||||||
{
|
{
|
||||||
//ALOGI("Setting theme %p from theme %p...\n", this, &other);
|
if (kDebugTableTheme) {
|
||||||
//dumpToLog();
|
ALOGI("Setting theme %p from theme %p...\n", this, &other);
|
||||||
//other.dumpToLog();
|
dumpToLog();
|
||||||
|
other.dumpToLog();
|
||||||
|
}
|
||||||
|
|
||||||
if (&mTable == &other.mTable) {
|
if (&mTable == &other.mTable) {
|
||||||
for (size_t i=0; i<Res_MAXPACKAGE; i++) {
|
for (size_t i=0; i<Res_MAXPACKAGE; i++) {
|
||||||
@@ -3169,8 +3260,10 @@ status_t ResTable::Theme::setTo(const Theme& other)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//ALOGI("Final theme:");
|
if (kDebugTableTheme) {
|
||||||
//dumpToLog();
|
ALOGI("Final theme:");
|
||||||
|
dumpToLog();
|
||||||
|
}
|
||||||
|
|
||||||
return NO_ERROR;
|
return NO_ERROR;
|
||||||
}
|
}
|
||||||
@@ -3187,23 +3280,33 @@ ssize_t ResTable::Theme::getAttribute(uint32_t resID, Res_value* outValue,
|
|||||||
const uint32_t t = Res_GETTYPE(resID);
|
const uint32_t t = Res_GETTYPE(resID);
|
||||||
const uint32_t e = Res_GETENTRY(resID);
|
const uint32_t e = Res_GETENTRY(resID);
|
||||||
|
|
||||||
TABLE_THEME(ALOGI("Looking up attr 0x%08x in theme %p", resID, this));
|
if (kDebugTableTheme) {
|
||||||
|
ALOGI("Looking up attr 0x%08x in theme %p", resID, this);
|
||||||
|
}
|
||||||
|
|
||||||
if (p >= 0) {
|
if (p >= 0) {
|
||||||
const package_info* const pi = mPackages[p];
|
const package_info* const pi = mPackages[p];
|
||||||
TABLE_THEME(ALOGI("Found package: %p", pi));
|
if (kDebugTableTheme) {
|
||||||
|
ALOGI("Found package: %p", pi);
|
||||||
|
}
|
||||||
if (pi != NULL) {
|
if (pi != NULL) {
|
||||||
TABLE_THEME(ALOGI("Desired type index is %ld in avail %d", t, Res_MAXTYPE + 1));
|
if (kDebugTableTheme) {
|
||||||
|
ALOGI("Desired type index is %zd in avail %zu", t, Res_MAXTYPE + 1);
|
||||||
|
}
|
||||||
if (t <= Res_MAXTYPE) {
|
if (t <= Res_MAXTYPE) {
|
||||||
const type_info& ti = pi->types[t];
|
const type_info& ti = pi->types[t];
|
||||||
TABLE_THEME(ALOGI("Desired entry index is %ld in avail %d", e, ti.numEntries));
|
if (kDebugTableTheme) {
|
||||||
|
ALOGI("Desired entry index is %u in avail %zu", e, ti.numEntries);
|
||||||
|
}
|
||||||
if (e < ti.numEntries) {
|
if (e < ti.numEntries) {
|
||||||
const theme_entry& te = ti.entries[e];
|
const theme_entry& te = ti.entries[e];
|
||||||
if (outTypeSpecFlags != NULL) {
|
if (outTypeSpecFlags != NULL) {
|
||||||
*outTypeSpecFlags |= te.typeSpecFlags;
|
*outTypeSpecFlags |= te.typeSpecFlags;
|
||||||
}
|
}
|
||||||
TABLE_THEME(ALOGI("Theme value: type=0x%x, data=0x%08x",
|
if (kDebugTableTheme) {
|
||||||
te.value.dataType, te.value.data));
|
ALOGI("Theme value: type=0x%x, data=0x%08x",
|
||||||
|
te.value.dataType, te.value.data);
|
||||||
|
}
|
||||||
const uint8_t type = te.value.dataType;
|
const uint8_t type = te.value.dataType;
|
||||||
if (type == Res_value::TYPE_ATTRIBUTE) {
|
if (type == Res_value::TYPE_ATTRIBUTE) {
|
||||||
if (cnt > 0) {
|
if (cnt > 0) {
|
||||||
@@ -3237,8 +3340,10 @@ ssize_t ResTable::Theme::resolveAttributeReference(Res_value* inOutValue,
|
|||||||
if (inOutValue->dataType == Res_value::TYPE_ATTRIBUTE) {
|
if (inOutValue->dataType == Res_value::TYPE_ATTRIBUTE) {
|
||||||
uint32_t newTypeSpecFlags;
|
uint32_t newTypeSpecFlags;
|
||||||
blockIndex = getAttribute(inOutValue->data, inOutValue, &newTypeSpecFlags);
|
blockIndex = getAttribute(inOutValue->data, inOutValue, &newTypeSpecFlags);
|
||||||
TABLE_THEME(ALOGI("Resolving attr reference: blockIndex=%d, type=0x%x, data=%p\n",
|
if (kDebugTableTheme) {
|
||||||
(int)blockIndex, (int)inOutValue->dataType, (void*)inOutValue->data));
|
ALOGI("Resolving attr reference: blockIndex=%d, type=0x%x, data=0x%x\n",
|
||||||
|
(int)blockIndex, (int)inOutValue->dataType, inOutValue->data);
|
||||||
|
}
|
||||||
if (inoutTypeSpecFlags != NULL) *inoutTypeSpecFlags |= newTypeSpecFlags;
|
if (inoutTypeSpecFlags != NULL) *inoutTypeSpecFlags |= newTypeSpecFlags;
|
||||||
//printf("Retrieved attribute new type=0x%x\n", inOutValue->dataType);
|
//printf("Retrieved attribute new type=0x%x\n", inOutValue->dataType);
|
||||||
if (blockIndex < 0) {
|
if (blockIndex < 0) {
|
||||||
@@ -3277,7 +3382,9 @@ ResTable::ResTable()
|
|||||||
{
|
{
|
||||||
memset(&mParams, 0, sizeof(mParams));
|
memset(&mParams, 0, sizeof(mParams));
|
||||||
memset(mPackageMap, 0, sizeof(mPackageMap));
|
memset(mPackageMap, 0, sizeof(mPackageMap));
|
||||||
//ALOGI("Creating ResTable %p\n", this);
|
if (kDebugTableSuperNoisy) {
|
||||||
|
ALOGI("Creating ResTable %p\n", this);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ResTable::ResTable(const void* data, size_t size, const int32_t cookie, bool copyData)
|
ResTable::ResTable(const void* data, size_t size, const int32_t cookie, bool copyData)
|
||||||
@@ -3287,12 +3394,16 @@ ResTable::ResTable(const void* data, size_t size, const int32_t cookie, bool cop
|
|||||||
memset(mPackageMap, 0, sizeof(mPackageMap));
|
memset(mPackageMap, 0, sizeof(mPackageMap));
|
||||||
addInternal(data, size, NULL, 0, cookie, copyData);
|
addInternal(data, size, NULL, 0, cookie, copyData);
|
||||||
LOG_FATAL_IF(mError != NO_ERROR, "Error parsing resource table");
|
LOG_FATAL_IF(mError != NO_ERROR, "Error parsing resource table");
|
||||||
//ALOGI("Creating ResTable %p\n", this);
|
if (kDebugTableSuperNoisy) {
|
||||||
|
ALOGI("Creating ResTable %p\n", this);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ResTable::~ResTable()
|
ResTable::~ResTable()
|
||||||
{
|
{
|
||||||
//ALOGI("Destroying ResTable in %p\n", this);
|
if (kDebugTableSuperNoisy) {
|
||||||
|
ALOGI("Destroying ResTable in %p\n", this);
|
||||||
|
}
|
||||||
uninit();
|
uninit();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3421,9 +3532,10 @@ status_t ResTable::addInternal(const void* data, size_t dataSize, const void* id
|
|||||||
|
|
||||||
const bool notDeviceEndian = htods(0xf0) != 0xf0;
|
const bool notDeviceEndian = htods(0xf0) != 0xf0;
|
||||||
|
|
||||||
LOAD_TABLE_NOISY(
|
if (kDebugLoadTableNoisy) {
|
||||||
ALOGV("Adding resources to ResTable: data=%p, size=0x%x, cookie=%d, copy=%d "
|
ALOGV("Adding resources to ResTable: data=%p, size=%zu, cookie=%d, copy=%d "
|
||||||
"idmap=%p\n", data, dataSize, cookie, copyData, idmap));
|
"idmap=%p\n", data, dataSize, cookie, copyData, idmapData);
|
||||||
|
}
|
||||||
|
|
||||||
if (copyData || notDeviceEndian) {
|
if (copyData || notDeviceEndian) {
|
||||||
header->ownedData = malloc(dataSize);
|
header->ownedData = malloc(dataSize);
|
||||||
@@ -3436,9 +3548,13 @@ status_t ResTable::addInternal(const void* data, size_t dataSize, const void* id
|
|||||||
|
|
||||||
header->header = (const ResTable_header*)data;
|
header->header = (const ResTable_header*)data;
|
||||||
header->size = dtohl(header->header->header.size);
|
header->size = dtohl(header->header->header.size);
|
||||||
//ALOGI("Got size 0x%x, again size 0x%x, raw size 0x%x\n", header->size,
|
if (kDebugLoadTableSuperNoisy) {
|
||||||
// dtohl(header->header->header.size), header->header->header.size);
|
ALOGI("Got size %zu, again size 0x%x, raw size 0x%x\n", header->size,
|
||||||
LOAD_TABLE_NOISY(ALOGV("Loading ResTable @%p:\n", header->header));
|
dtohl(header->header->header.size), header->header->header.size);
|
||||||
|
}
|
||||||
|
if (kDebugLoadTableNoisy) {
|
||||||
|
ALOGV("Loading ResTable @%p:\n", header->header);
|
||||||
|
}
|
||||||
if (dtohs(header->header->header.headerSize) > header->size
|
if (dtohs(header->header->header.headerSize) > header->size
|
||||||
|| header->size > dataSize) {
|
|| header->size > dataSize) {
|
||||||
ALOGW("Bad resource table: header size 0x%x or total size 0x%x is larger than data size 0x%x\n",
|
ALOGW("Bad resource table: header size 0x%x or total size 0x%x is larger than data size 0x%x\n",
|
||||||
@@ -3466,9 +3582,11 @@ status_t ResTable::addInternal(const void* data, size_t dataSize, const void* id
|
|||||||
if (err != NO_ERROR) {
|
if (err != NO_ERROR) {
|
||||||
return (mError=err);
|
return (mError=err);
|
||||||
}
|
}
|
||||||
TABLE_NOISY(ALOGV("Chunk: type=0x%x, headerSize=0x%x, size=0x%x, pos=%p\n",
|
if (kDebugTableNoisy) {
|
||||||
|
ALOGV("Chunk: type=0x%x, headerSize=0x%x, size=0x%x, pos=%p\n",
|
||||||
dtohs(chunk->type), dtohs(chunk->headerSize), dtohl(chunk->size),
|
dtohs(chunk->type), dtohs(chunk->headerSize), dtohl(chunk->size),
|
||||||
(void*)(((const uint8_t*)chunk) - ((const uint8_t*)header->header))));
|
(void*)(((const uint8_t*)chunk) - ((const uint8_t*)header->header)));
|
||||||
|
}
|
||||||
const size_t csize = dtohl(chunk->size);
|
const size_t csize = dtohl(chunk->size);
|
||||||
const uint16_t ctype = dtohs(chunk->type);
|
const uint16_t ctype = dtohs(chunk->type);
|
||||||
if (ctype == RES_STRING_POOL_TYPE) {
|
if (ctype == RES_STRING_POOL_TYPE) {
|
||||||
@@ -3512,7 +3630,9 @@ status_t ResTable::addInternal(const void* data, size_t dataSize, const void* id
|
|||||||
ALOGW("No string values found in resource table!");
|
ALOGW("No string values found in resource table!");
|
||||||
}
|
}
|
||||||
|
|
||||||
TABLE_NOISY(ALOGV("Returning from add with mError=%d\n", mError));
|
if (kDebugTableNoisy) {
|
||||||
|
ALOGV("Returning from add with mError=%d\n", mError);
|
||||||
|
}
|
||||||
return mError;
|
return mError;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3674,15 +3794,16 @@ ssize_t ResTable::getResource(uint32_t resID, Res_value* outValue, bool mayBeBag
|
|||||||
return BAD_VALUE;
|
return BAD_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
TABLE_NOISY(size_t len;
|
if (kDebugTableNoisy) {
|
||||||
printf("Found value: pkg=%d, type=%d, str=%s, int=%d\n",
|
size_t len;
|
||||||
|
printf("Found value: pkg=%zu, type=%d, str=%s, int=%d\n",
|
||||||
entry.package->header->index,
|
entry.package->header->index,
|
||||||
outValue->dataType,
|
outValue->dataType,
|
||||||
outValue->dataType == Res_value::TYPE_STRING
|
outValue->dataType == Res_value::TYPE_STRING ?
|
||||||
? String8(entry.package->header->values.stringAt(
|
String8(entry.package->header->values.stringAt(outValue->data, &len)).string() :
|
||||||
outValue->data, &len)).string()
|
"",
|
||||||
: "",
|
outValue->data);
|
||||||
outValue->data));
|
}
|
||||||
|
|
||||||
if (outSpecFlags != NULL) {
|
if (outSpecFlags != NULL) {
|
||||||
*outSpecFlags = entry.specFlags;
|
*outSpecFlags = entry.specFlags;
|
||||||
@@ -3703,15 +3824,16 @@ ssize_t ResTable::resolveReference(Res_value* value, ssize_t blockIndex,
|
|||||||
while (blockIndex >= 0 && value->dataType == Res_value::TYPE_REFERENCE
|
while (blockIndex >= 0 && value->dataType == Res_value::TYPE_REFERENCE
|
||||||
&& value->data != 0 && count < 20) {
|
&& value->data != 0 && count < 20) {
|
||||||
if (outLastRef) *outLastRef = value->data;
|
if (outLastRef) *outLastRef = value->data;
|
||||||
uint32_t lastRef = value->data;
|
|
||||||
uint32_t newFlags = 0;
|
uint32_t newFlags = 0;
|
||||||
const ssize_t newIndex = getResource(value->data, value, true, 0, &newFlags,
|
const ssize_t newIndex = getResource(value->data, value, true, 0, &newFlags,
|
||||||
outConfig);
|
outConfig);
|
||||||
if (newIndex == BAD_INDEX) {
|
if (newIndex == BAD_INDEX) {
|
||||||
return BAD_INDEX;
|
return BAD_INDEX;
|
||||||
}
|
}
|
||||||
TABLE_THEME(ALOGI("Resolving reference %p: newIndex=%d, type=0x%x, data=%p\n",
|
if (kDebugTableTheme) {
|
||||||
(void*)lastRef, (int)newIndex, (int)value->dataType, (void*)value->data));
|
ALOGI("Resolving reference 0x%x: newIndex=%d, type=0x%x, data=0x%x\n",
|
||||||
|
value->data, (int)newIndex, (int)value->dataType, value->data);
|
||||||
|
}
|
||||||
//printf("Getting reference 0x%08x: newIndex=%d\n", value->data, newIndex);
|
//printf("Getting reference 0x%08x: newIndex=%d\n", value->data, newIndex);
|
||||||
if (inoutTypeSpecFlags != NULL) *inoutTypeSpecFlags |= newFlags;
|
if (inoutTypeSpecFlags != NULL) *inoutTypeSpecFlags |= newFlags;
|
||||||
if (newIndex < 0) {
|
if (newIndex < 0) {
|
||||||
@@ -3818,7 +3940,9 @@ ssize_t ResTable::getBagLocked(uint32_t resID, const bag_entry** outBag,
|
|||||||
*outTypeSpecFlags = set->typeSpecFlags;
|
*outTypeSpecFlags = set->typeSpecFlags;
|
||||||
}
|
}
|
||||||
*outBag = (bag_entry*)(set+1);
|
*outBag = (bag_entry*)(set+1);
|
||||||
//ALOGI("Found existing bag for: %p\n", (void*)resID);
|
if (kDebugTableSuperNoisy) {
|
||||||
|
ALOGI("Found existing bag for: 0x%x\n", resID);
|
||||||
|
}
|
||||||
return set->numAttrs;
|
return set->numAttrs;
|
||||||
}
|
}
|
||||||
ALOGW("Attempt to retrieve bag 0x%08x which is invalid or in a cycle.",
|
ALOGW("Attempt to retrieve bag 0x%08x which is invalid or in a cycle.",
|
||||||
@@ -3844,7 +3968,9 @@ ssize_t ResTable::getBagLocked(uint32_t resID, const bag_entry** outBag,
|
|||||||
// Mark that we are currently working on this one.
|
// Mark that we are currently working on this one.
|
||||||
typeSet[e] = (bag_set*)0xFFFFFFFF;
|
typeSet[e] = (bag_set*)0xFFFFFFFF;
|
||||||
|
|
||||||
TABLE_NOISY(ALOGI("Building bag: %p\n", (void*)resID));
|
if (kDebugTableNoisy) {
|
||||||
|
ALOGI("Building bag: %x\n", resID);
|
||||||
|
}
|
||||||
|
|
||||||
// Now collect all bag attributes
|
// Now collect all bag attributes
|
||||||
Entry entry;
|
Entry entry;
|
||||||
@@ -3861,13 +3987,13 @@ ssize_t ResTable::getBagLocked(uint32_t resID, const bag_entry** outBag,
|
|||||||
|
|
||||||
size_t N = count;
|
size_t N = count;
|
||||||
|
|
||||||
TABLE_NOISY(ALOGI("Found map: size=%p parent=%p count=%d\n",
|
if (kDebugTableNoisy) {
|
||||||
entrySize, parent, count));
|
ALOGI("Found map: size=%x parent=%x count=%d\n", entrySize, parent, count);
|
||||||
|
|
||||||
// If this map inherits from another, we need to start
|
// If this map inherits from another, we need to start
|
||||||
// with its parent's values. Otherwise start out empty.
|
// with its parent's values. Otherwise start out empty.
|
||||||
TABLE_NOISY(printf("Creating new bag, entrySize=0x%08x, parent=0x%08x\n",
|
ALOGI("Creating new bag, entrySize=0x%08x, parent=0x%08x\n", entrySize, parent);
|
||||||
entrySize, parent));
|
}
|
||||||
|
|
||||||
// This is what we are building.
|
// This is what we are building.
|
||||||
bag_set* set = NULL;
|
bag_set* set = NULL;
|
||||||
@@ -3896,9 +4022,13 @@ ssize_t ResTable::getBagLocked(uint32_t resID, const bag_entry** outBag,
|
|||||||
if (NP > 0) {
|
if (NP > 0) {
|
||||||
memcpy(set+1, parentBag, NP*sizeof(bag_entry));
|
memcpy(set+1, parentBag, NP*sizeof(bag_entry));
|
||||||
set->numAttrs = NP;
|
set->numAttrs = NP;
|
||||||
TABLE_NOISY(ALOGI("Initialized new bag with %d inherited attributes.\n", NP));
|
if (kDebugTableNoisy) {
|
||||||
|
ALOGI("Initialized new bag with %zd inherited attributes.\n", NP);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
TABLE_NOISY(ALOGI("Initialized new bag with no inherited attributes.\n"));
|
if (kDebugTableNoisy) {
|
||||||
|
ALOGI("Initialized new bag with no inherited attributes.\n");
|
||||||
|
}
|
||||||
set->numAttrs = 0;
|
set->numAttrs = 0;
|
||||||
}
|
}
|
||||||
set->availAttrs = NT;
|
set->availAttrs = NT;
|
||||||
@@ -3922,10 +4052,13 @@ ssize_t ResTable::getBagLocked(uint32_t resID, const bag_entry** outBag,
|
|||||||
bag_entry* entries = (bag_entry*)(set+1);
|
bag_entry* entries = (bag_entry*)(set+1);
|
||||||
size_t curEntry = 0;
|
size_t curEntry = 0;
|
||||||
uint32_t pos = 0;
|
uint32_t pos = 0;
|
||||||
TABLE_NOISY(ALOGI("Starting with set %p, entries=%p, avail=%d\n",
|
if (kDebugTableNoisy) {
|
||||||
set, entries, set->availAttrs));
|
ALOGI("Starting with set %p, entries=%p, avail=%zu\n", set, entries, set->availAttrs);
|
||||||
|
}
|
||||||
while (pos < count) {
|
while (pos < count) {
|
||||||
TABLE_NOISY(printf("Now at %p\n", (void*)curOff));
|
if (kDebugTableNoisy) {
|
||||||
|
ALOGI("Now at %p\n", (void*)curOff);
|
||||||
|
}
|
||||||
|
|
||||||
if (curOff > (dtohl(entry.type->header.size)-sizeof(ResTable_map))) {
|
if (curOff > (dtohl(entry.type->header.size)-sizeof(ResTable_map))) {
|
||||||
ALOGW("ResTable_map at %d is beyond type chunk data %d",
|
ALOGW("ResTable_map at %d is beyond type chunk data %d",
|
||||||
@@ -3950,8 +4083,10 @@ ssize_t ResTable::getBagLocked(uint32_t resID, const bag_entry** outBag,
|
|||||||
uint32_t oldName = 0;
|
uint32_t oldName = 0;
|
||||||
while ((isInside=(curEntry < set->numAttrs))
|
while ((isInside=(curEntry < set->numAttrs))
|
||||||
&& (oldName=entries[curEntry].map.name.ident) < newName) {
|
&& (oldName=entries[curEntry].map.name.ident) < newName) {
|
||||||
TABLE_NOISY(printf("#%d: Keeping existing attribute: 0x%08x\n",
|
if (kDebugTableNoisy) {
|
||||||
curEntry, entries[curEntry].map.name.ident));
|
ALOGI("#%zu: Keeping existing attribute: 0x%08x\n",
|
||||||
|
curEntry, entries[curEntry].map.name.ident);
|
||||||
|
}
|
||||||
curEntry++;
|
curEntry++;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3968,8 +4103,10 @@ ssize_t ResTable::getBagLocked(uint32_t resID, const bag_entry** outBag,
|
|||||||
}
|
}
|
||||||
set->availAttrs = newAvail;
|
set->availAttrs = newAvail;
|
||||||
entries = (bag_entry*)(set+1);
|
entries = (bag_entry*)(set+1);
|
||||||
TABLE_NOISY(printf("Reallocated set %p, entries=%p, avail=%d\n",
|
if (kDebugTableNoisy) {
|
||||||
set, entries, set->availAttrs));
|
ALOGI("Reallocated set %p, entries=%p, avail=%zu\n",
|
||||||
|
set, entries, set->availAttrs);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (isInside) {
|
if (isInside) {
|
||||||
// Going in the middle, need to make space.
|
// Going in the middle, need to make space.
|
||||||
@@ -3977,11 +4114,13 @@ ssize_t ResTable::getBagLocked(uint32_t resID, const bag_entry** outBag,
|
|||||||
sizeof(bag_entry)*(set->numAttrs-curEntry));
|
sizeof(bag_entry)*(set->numAttrs-curEntry));
|
||||||
set->numAttrs++;
|
set->numAttrs++;
|
||||||
}
|
}
|
||||||
TABLE_NOISY(printf("#%d: Inserting new attribute: 0x%08x\n",
|
if (kDebugTableNoisy) {
|
||||||
curEntry, newName));
|
ALOGI("#%zu: Inserting new attribute: 0x%08x\n", curEntry, newName);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
TABLE_NOISY(printf("#%d: Replacing existing attribute: 0x%08x\n",
|
if (kDebugTableNoisy) {
|
||||||
curEntry, oldName));
|
ALOGI("#%zu: Replacing existing attribute: 0x%08x\n", curEntry, oldName);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bag_entry* cur = entries+curEntry;
|
bag_entry* cur = entries+curEntry;
|
||||||
@@ -3995,9 +4134,11 @@ ssize_t ResTable::getBagLocked(uint32_t resID, const bag_entry** outBag,
|
|||||||
return UNKNOWN_ERROR;
|
return UNKNOWN_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
TABLE_NOISY(printf("Setting entry #%d %p: block=%d, name=0x%08x, type=%d, data=0x%08x\n",
|
if (kDebugTableNoisy) {
|
||||||
|
ALOGI("Setting entry #%zu %p: block=%zd, name=0x%08d, type=%d, data=0x%08x\n",
|
||||||
curEntry, cur, cur->stringBlock, cur->map.name.ident,
|
curEntry, cur, cur->stringBlock, cur->map.name.ident,
|
||||||
cur->map.value.dataType, cur->map.value.data));
|
cur->map.value.dataType, cur->map.value.data);
|
||||||
|
}
|
||||||
|
|
||||||
// On to the next!
|
// On to the next!
|
||||||
curEntry++;
|
curEntry++;
|
||||||
@@ -4017,7 +4158,9 @@ ssize_t ResTable::getBagLocked(uint32_t resID, const bag_entry** outBag,
|
|||||||
*outTypeSpecFlags = set->typeSpecFlags;
|
*outTypeSpecFlags = set->typeSpecFlags;
|
||||||
}
|
}
|
||||||
*outBag = (bag_entry*)(set+1);
|
*outBag = (bag_entry*)(set+1);
|
||||||
TABLE_NOISY(ALOGI("Returning %d attrs\n", set->numAttrs));
|
if (kDebugTableNoisy) {
|
||||||
|
ALOGI("Returning %zu attrs\n", set->numAttrs);
|
||||||
|
}
|
||||||
return set->numAttrs;
|
return set->numAttrs;
|
||||||
}
|
}
|
||||||
return BAD_INDEX;
|
return BAD_INDEX;
|
||||||
@@ -4026,10 +4169,14 @@ ssize_t ResTable::getBagLocked(uint32_t resID, const bag_entry** outBag,
|
|||||||
void ResTable::setParameters(const ResTable_config* params)
|
void ResTable::setParameters(const ResTable_config* params)
|
||||||
{
|
{
|
||||||
mLock.lock();
|
mLock.lock();
|
||||||
TABLE_GETENTRY(ALOGI("Setting parameters: %s\n", params->toString().string()));
|
if (kDebugTableGetEntry) {
|
||||||
|
ALOGI("Setting parameters: %s\n", params->toString().string());
|
||||||
|
}
|
||||||
mParams = *params;
|
mParams = *params;
|
||||||
for (size_t i=0; i<mPackageGroups.size(); i++) {
|
for (size_t i=0; i<mPackageGroups.size(); i++) {
|
||||||
TABLE_NOISY(ALOGI("CLEARING BAGS FOR GROUP %d!", i));
|
if (kDebugTableNoisy) {
|
||||||
|
ALOGI("CLEARING BAGS FOR GROUP %zu!", i);
|
||||||
|
}
|
||||||
mPackageGroups[i]->clearBagCache();
|
mPackageGroups[i]->clearBagCache();
|
||||||
}
|
}
|
||||||
mLock.unlock();
|
mLock.unlock();
|
||||||
@@ -4067,7 +4214,9 @@ uint32_t ResTable::identifierForName(const char16_t* name, size_t nameLen,
|
|||||||
size_t packageLen,
|
size_t packageLen,
|
||||||
uint32_t* outTypeSpecFlags) const
|
uint32_t* outTypeSpecFlags) const
|
||||||
{
|
{
|
||||||
TABLE_SUPER_NOISY(printf("Identifier for name: error=%d\n", mError));
|
if (kDebugTableSuperNoisy) {
|
||||||
|
printf("Identifier for name: error=%d\n", mError);
|
||||||
|
}
|
||||||
|
|
||||||
// Check for internal resource identifier as the very first thing, so
|
// Check for internal resource identifier as the very first thing, so
|
||||||
// that we will always find them even when there are no resources.
|
// that we will always find them even when there are no resources.
|
||||||
@@ -4160,10 +4309,12 @@ nope:
|
|||||||
}
|
}
|
||||||
nameLen = nameEnd-name;
|
nameLen = nameEnd-name;
|
||||||
|
|
||||||
TABLE_NOISY(printf("Looking for identifier: type=%s, name=%s, package=%s\n",
|
if (kDebugTableNoisy) {
|
||||||
|
printf("Looking for identifier: type=%s, name=%s, package=%s\n",
|
||||||
String8(type, typeLen).string(),
|
String8(type, typeLen).string(),
|
||||||
String8(name, nameLen).string(),
|
String8(name, nameLen).string(),
|
||||||
String8(package, packageLen).string()));
|
String8(package, packageLen).string());
|
||||||
|
}
|
||||||
|
|
||||||
const size_t NG = mPackageGroups.size();
|
const size_t NG = mPackageGroups.size();
|
||||||
for (size_t ig=0; ig<NG; ig++) {
|
for (size_t ig=0; ig<NG; ig++) {
|
||||||
@@ -4171,7 +4322,9 @@ nope:
|
|||||||
|
|
||||||
if (strzcmp16(package, packageLen,
|
if (strzcmp16(package, packageLen,
|
||||||
group->name.string(), group->name.size())) {
|
group->name.string(), group->name.size())) {
|
||||||
TABLE_NOISY(printf("Skipping package group: %s\n", String8(group->name).string()));
|
if (kDebugTableNoisy) {
|
||||||
|
printf("Skipping package group: %s\n", String8(group->name).string());
|
||||||
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -4186,8 +4339,10 @@ nope:
|
|||||||
|
|
||||||
const TypeList& typeList = group->types[ti];
|
const TypeList& typeList = group->types[ti];
|
||||||
if (typeList.isEmpty()) {
|
if (typeList.isEmpty()) {
|
||||||
TABLE_NOISY(printf("Expected type structure not found in package %s for index %d\n",
|
if (kDebugTableNoisy) {
|
||||||
String8(group->name).string(), ti));
|
ALOGI("Expected type structure not found in package %s for index %zd\n",
|
||||||
|
String8(group->name).string(), ti);
|
||||||
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -4686,9 +4841,11 @@ bool ResTable::stringToValue(Res_value* outValue, String16* outString,
|
|||||||
rid = Res_MAKEID(
|
rid = Res_MAKEID(
|
||||||
accessor->getRemappedPackage(Res_GETPACKAGE(rid)),
|
accessor->getRemappedPackage(Res_GETPACKAGE(rid)),
|
||||||
Res_GETTYPE(rid), Res_GETENTRY(rid));
|
Res_GETTYPE(rid), Res_GETENTRY(rid));
|
||||||
TABLE_NOISY(printf("Incl %s:%s/%s: 0x%08x\n",
|
if (kDebugTableNoisy) {
|
||||||
|
ALOGI("Incl %s:%s/%s: 0x%08x\n",
|
||||||
String8(package).string(), String8(type).string(),
|
String8(package).string(), String8(type).string(),
|
||||||
String8(name).string(), rid));
|
String8(name).string(), rid);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t packageId = Res_GETPACKAGE(rid) + 1;
|
uint32_t packageId = Res_GETPACKAGE(rid) + 1;
|
||||||
@@ -4703,9 +4860,11 @@ bool ResTable::stringToValue(Res_value* outValue, String16* outString,
|
|||||||
uint32_t rid = accessor->getCustomResourceWithCreation(package, type, name,
|
uint32_t rid = accessor->getCustomResourceWithCreation(package, type, name,
|
||||||
createIfNotFound);
|
createIfNotFound);
|
||||||
if (rid != 0) {
|
if (rid != 0) {
|
||||||
TABLE_NOISY(printf("Pckg %s:%s/%s: 0x%08x\n",
|
if (kDebugTableNoisy) {
|
||||||
|
ALOGI("Pckg %s:%s/%s: 0x%08x\n",
|
||||||
String8(package).string(), String8(type).string(),
|
String8(package).string(), String8(type).string(),
|
||||||
String8(name).string(), rid));
|
String8(name).string(), rid);
|
||||||
|
}
|
||||||
uint32_t packageId = Res_GETPACKAGE(rid) + 1;
|
uint32_t packageId = Res_GETPACKAGE(rid) + 1;
|
||||||
if (packageId == 0x00) {
|
if (packageId == 0x00) {
|
||||||
outValue->data = rid;
|
outValue->data = rid;
|
||||||
@@ -5508,8 +5667,6 @@ status_t ResTable::getEntry(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Check if there is the desired entry in this type.
|
// Check if there is the desired entry in this type.
|
||||||
const uint8_t* const end = reinterpret_cast<const uint8_t*>(thisType)
|
|
||||||
+ dtohl(thisType->header.size);
|
|
||||||
const uint32_t* const eindex = reinterpret_cast<const uint32_t*>(
|
const uint32_t* const eindex = reinterpret_cast<const uint32_t*>(
|
||||||
reinterpret_cast<const uint8_t*>(thisType) + dtohs(thisType->header.headerSize));
|
reinterpret_cast<const uint8_t*>(thisType) + dtohs(thisType->header.headerSize));
|
||||||
|
|
||||||
@@ -5698,9 +5855,11 @@ status_t ResTable::parsePackage(const ResTable_package* const pkg,
|
|||||||
const uint8_t* endPos = ((const uint8_t*)pkg) + dtohs(pkg->header.size);
|
const uint8_t* endPos = ((const uint8_t*)pkg) + dtohs(pkg->header.size);
|
||||||
while (((const uint8_t*)chunk) <= (endPos-sizeof(ResChunk_header)) &&
|
while (((const uint8_t*)chunk) <= (endPos-sizeof(ResChunk_header)) &&
|
||||||
((const uint8_t*)chunk) <= (endPos-dtohl(chunk->size))) {
|
((const uint8_t*)chunk) <= (endPos-dtohl(chunk->size))) {
|
||||||
TABLE_NOISY(ALOGV("PackageChunk: type=0x%x, headerSize=0x%x, size=0x%x, pos=%p\n",
|
if (kDebugTableNoisy) {
|
||||||
|
ALOGV("PackageChunk: type=0x%x, headerSize=0x%x, size=0x%x, pos=%p\n",
|
||||||
dtohs(chunk->type), dtohs(chunk->headerSize), dtohl(chunk->size),
|
dtohs(chunk->type), dtohs(chunk->headerSize), dtohl(chunk->size),
|
||||||
(void*)(((const uint8_t*)chunk) - ((const uint8_t*)header->header))));
|
(void*)(((const uint8_t*)chunk) - ((const uint8_t*)header->header)));
|
||||||
|
}
|
||||||
const size_t csize = dtohl(chunk->size);
|
const size_t csize = dtohl(chunk->size);
|
||||||
const uint16_t ctype = dtohs(chunk->type);
|
const uint16_t ctype = dtohs(chunk->type);
|
||||||
if (ctype == RES_TABLE_TYPE_SPEC_TYPE) {
|
if (ctype == RES_TABLE_TYPE_SPEC_TYPE) {
|
||||||
@@ -5714,11 +5873,13 @@ status_t ResTable::parsePackage(const ResTable_package* const pkg,
|
|||||||
const size_t typeSpecSize = dtohl(typeSpec->header.size);
|
const size_t typeSpecSize = dtohl(typeSpec->header.size);
|
||||||
const size_t newEntryCount = dtohl(typeSpec->entryCount);
|
const size_t newEntryCount = dtohl(typeSpec->entryCount);
|
||||||
|
|
||||||
LOAD_TABLE_NOISY(printf("TypeSpec off %p: type=0x%x, headerSize=0x%x, size=%p\n",
|
if (kDebugLoadTableNoisy) {
|
||||||
|
ALOGI("TypeSpec off %p: type=0x%x, headerSize=0x%x, size=%p\n",
|
||||||
(void*)(base-(const uint8_t*)chunk),
|
(void*)(base-(const uint8_t*)chunk),
|
||||||
dtohs(typeSpec->header.type),
|
dtohs(typeSpec->header.type),
|
||||||
dtohs(typeSpec->header.headerSize),
|
dtohs(typeSpec->header.headerSize),
|
||||||
(void*)typeSpecSize));
|
(void*)typeSpecSize);
|
||||||
|
}
|
||||||
// look for block overrun or int overflow when multiplying by 4
|
// look for block overrun or int overflow when multiplying by 4
|
||||||
if ((dtohl(typeSpec->entryCount) > (INT32_MAX/sizeof(uint32_t))
|
if ((dtohl(typeSpec->entryCount) > (INT32_MAX/sizeof(uint32_t))
|
||||||
|| dtohs(typeSpec->header.headerSize)+(sizeof(uint32_t)*newEntryCount)
|
|| dtohs(typeSpec->header.headerSize)+(sizeof(uint32_t)*newEntryCount)
|
||||||
@@ -5776,13 +5937,14 @@ status_t ResTable::parsePackage(const ResTable_package* const pkg,
|
|||||||
const uint32_t typeSize = dtohl(type->header.size);
|
const uint32_t typeSize = dtohl(type->header.size);
|
||||||
const size_t newEntryCount = dtohl(type->entryCount);
|
const size_t newEntryCount = dtohl(type->entryCount);
|
||||||
|
|
||||||
LOAD_TABLE_NOISY(printf("Type off %p: type=0x%x, headerSize=0x%x, size=%p\n",
|
if (kDebugLoadTableNoisy) {
|
||||||
|
printf("Type off %p: type=0x%x, headerSize=0x%x, size=%u\n",
|
||||||
(void*)(base-(const uint8_t*)chunk),
|
(void*)(base-(const uint8_t*)chunk),
|
||||||
dtohs(type->header.type),
|
dtohs(type->header.type),
|
||||||
dtohs(type->header.headerSize),
|
dtohs(type->header.headerSize),
|
||||||
(void*)typeSize));
|
typeSize);
|
||||||
if (dtohs(type->header.headerSize)+(sizeof(uint32_t)*newEntryCount)
|
}
|
||||||
> typeSize) {
|
if (dtohs(type->header.headerSize)+(sizeof(uint32_t)*newEntryCount) > typeSize) {
|
||||||
ALOGW("ResTable_type entry index to %p extends beyond chunk end 0x%x.",
|
ALOGW("ResTable_type entry index to %p extends beyond chunk end 0x%x.",
|
||||||
(void*)(dtohs(type->header.headerSize) + (sizeof(uint32_t)*newEntryCount)),
|
(void*)(dtohs(type->header.headerSize) + (sizeof(uint32_t)*newEntryCount)),
|
||||||
typeSize);
|
typeSize);
|
||||||
@@ -5828,11 +5990,12 @@ status_t ResTable::parsePackage(const ResTable_package* const pkg,
|
|||||||
|
|
||||||
t->configs.add(type);
|
t->configs.add(type);
|
||||||
|
|
||||||
TABLE_GETENTRY(
|
if (kDebugTableGetEntry) {
|
||||||
ResTable_config thisConfig;
|
ResTable_config thisConfig;
|
||||||
thisConfig.copyFromDtoH(type->config);
|
thisConfig.copyFromDtoH(type->config);
|
||||||
ALOGI("Adding config to type %d: %s\n",
|
ALOGI("Adding config to type %d: %s\n", type->id,
|
||||||
type->id, thisConfig.toString().string()));
|
thisConfig.toString().string());
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
ALOGV("Skipping empty ResTable_type for type %d", type->id);
|
ALOGV("Skipping empty ResTable_type for type %d", type->id);
|
||||||
}
|
}
|
||||||
@@ -5893,8 +6056,10 @@ status_t DynamicRefTable::load(const ResTable_lib_header* const header)
|
|||||||
uint32_t packageId = dtohl(entry->packageId);
|
uint32_t packageId = dtohl(entry->packageId);
|
||||||
char16_t tmpName[sizeof(entry->packageName) / sizeof(char16_t)];
|
char16_t tmpName[sizeof(entry->packageName) / sizeof(char16_t)];
|
||||||
strcpy16_dtoh(tmpName, entry->packageName, sizeof(entry->packageName) / sizeof(char16_t));
|
strcpy16_dtoh(tmpName, entry->packageName, sizeof(entry->packageName) / sizeof(char16_t));
|
||||||
LIB_NOISY(ALOGV("Found lib entry %s with id %d\n", String8(tmpName).string(),
|
if (kDebugLibNoisy) {
|
||||||
dtohl(entry->packageId)));
|
ALOGV("Found lib entry %s with id %d\n", String8(tmpName).string(),
|
||||||
|
dtohl(entry->packageId));
|
||||||
|
}
|
||||||
if (packageId >= 256) {
|
if (packageId >= 256) {
|
||||||
ALOGE("Bad package id 0x%08x", packageId);
|
ALOGE("Bad package id 0x%08x", packageId);
|
||||||
return UNKNOWN_ERROR;
|
return UNKNOWN_ERROR;
|
||||||
@@ -6074,7 +6239,7 @@ status_t ResTable::createIdmap(const ResTable& overlay,
|
|||||||
|
|
||||||
if (Res_GETTYPE(overlayResID) + 1 != static_cast<size_t>(typeMap.overlayTypeId)) {
|
if (Res_GETTYPE(overlayResID) + 1 != static_cast<size_t>(typeMap.overlayTypeId)) {
|
||||||
ALOGE("idmap: can't mix type ids in entry map. Resource 0x%08x maps to 0x%08x"
|
ALOGE("idmap: can't mix type ids in entry map. Resource 0x%08x maps to 0x%08x"
|
||||||
" but entries should map to resources of type %02x",
|
" but entries should map to resources of type %02zx",
|
||||||
resID, overlayResID, typeMap.overlayTypeId);
|
resID, overlayResID, typeMap.overlayTypeId);
|
||||||
return BAD_TYPE;
|
return BAD_TYPE;
|
||||||
}
|
}
|
||||||
@@ -6401,9 +6566,6 @@ void ResTable::print(bool inclValues) const
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
for (size_t entryIndex=0; entryIndex<entryCount; entryIndex++) {
|
for (size_t entryIndex=0; entryIndex<entryCount; entryIndex++) {
|
||||||
|
|
||||||
const uint8_t* const end = ((const uint8_t*)type)
|
|
||||||
+ dtohl(type->header.size);
|
|
||||||
const uint32_t* const eindex = (const uint32_t*)
|
const uint32_t* const eindex = (const uint32_t*)
|
||||||
(((const uint8_t*)type) + dtohs(type->header.headerSize));
|
(((const uint8_t*)type) + dtohs(type->header.headerSize));
|
||||||
|
|
||||||
|
|||||||
@@ -41,6 +41,8 @@
|
|||||||
_rc; })
|
_rc; })
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
static const bool kIsDebug = false;
|
||||||
|
|
||||||
static inline size_t min_of(size_t a, size_t b) { return (a < b) ? a : b; }
|
static inline size_t min_of(size_t a, size_t b) { return (a < b) ? a : b; }
|
||||||
|
|
||||||
using namespace android;
|
using namespace android;
|
||||||
@@ -209,7 +211,9 @@ int StreamingZipInflater::readNextChunk() {
|
|||||||
size_t toRead = min_of(mInBufSize, mInTotalSize - mInNextChunkOffset);
|
size_t toRead = min_of(mInBufSize, mInTotalSize - mInNextChunkOffset);
|
||||||
if (toRead > 0) {
|
if (toRead > 0) {
|
||||||
ssize_t didRead = TEMP_FAILURE_RETRY(::read(mFd, mInBuf, toRead));
|
ssize_t didRead = TEMP_FAILURE_RETRY(::read(mFd, mInBuf, toRead));
|
||||||
//ALOGV("Reading input chunk, size %08x didread %08x", toRead, didRead);
|
if (kIsDebug) {
|
||||||
|
ALOGV("Reading input chunk, size %08zx didread %08zx", toRead, didRead);
|
||||||
|
}
|
||||||
if (didRead < 0) {
|
if (didRead < 0) {
|
||||||
ALOGE("Error reading asset data: %s", strerror(errno));
|
ALOGE("Error reading asset data: %s", strerror(errno));
|
||||||
return didRead;
|
return didRead;
|
||||||
|
|||||||
@@ -34,14 +34,6 @@
|
|||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
/*
|
|
||||||
* We must open binary files using open(path, ... | O_BINARY) under Windows.
|
|
||||||
* Otherwise strange read errors will happen.
|
|
||||||
*/
|
|
||||||
#ifndef O_BINARY
|
|
||||||
# define O_BINARY 0
|
|
||||||
#endif
|
|
||||||
|
|
||||||
using namespace android;
|
using namespace android;
|
||||||
|
|
||||||
class _ZipEntryRO {
|
class _ZipEntryRO {
|
||||||
|
|||||||
@@ -37,6 +37,10 @@ include $(CLEAR_VARS)
|
|||||||
|
|
||||||
LOCAL_MODULE := libandroidfw_tests
|
LOCAL_MODULE := libandroidfw_tests
|
||||||
|
|
||||||
|
LOCAL_CFLAGS += -Wall -Werror -Wunused -Wunreachable-code
|
||||||
|
# gtest is broken.
|
||||||
|
LOCAL_CFLAGS += -Wno-unnamed-type-template-args
|
||||||
|
|
||||||
LOCAL_SRC_FILES := $(testFiles)
|
LOCAL_SRC_FILES := $(testFiles)
|
||||||
LOCAL_STATIC_LIBRARIES := \
|
LOCAL_STATIC_LIBRARIES := \
|
||||||
libandroidfw \
|
libandroidfw \
|
||||||
@@ -54,6 +58,10 @@ include $(CLEAR_VARS)
|
|||||||
|
|
||||||
LOCAL_MODULE := libandroidfw_tests
|
LOCAL_MODULE := libandroidfw_tests
|
||||||
|
|
||||||
|
LOCAL_CFLAGS += -Wall -Werror -Wunused -Wunreachable-code
|
||||||
|
# gtest is broken.
|
||||||
|
LOCAL_CFLAGS += -Wno-unnamed-type-template-args
|
||||||
|
|
||||||
LOCAL_SRC_FILES := $(testFiles) \
|
LOCAL_SRC_FILES := $(testFiles) \
|
||||||
BackupData_test.cpp \
|
BackupData_test.cpp \
|
||||||
ObbFile_test.cpp
|
ObbFile_test.cpp
|
||||||
|
|||||||
Reference in New Issue
Block a user