diff options
Diffstat (limited to 'libs')
57 files changed, 703 insertions, 494 deletions
diff --git a/libs/androidfw/Android.mk b/libs/androidfw/Android.mk index 20d5470..461160a 100644 --- a/libs/androidfw/Android.mk +++ b/libs/androidfw/Android.mk @@ -40,10 +40,12 @@ hostSources := $(commonSources) # For the host # ===================================================== include $(CLEAR_VARS) +LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk LOCAL_MODULE:= libandroidfw LOCAL_MODULE_TAGS := optional LOCAL_CFLAGS += -DSTATIC_ANDROIDFW_FOR_TOOLS +LOCAL_CFLAGS += -Wall -Werror -Wunused -Wunreachable-code LOCAL_SRC_FILES:= $(hostSources) LOCAL_C_INCLUDES := external/zlib @@ -54,6 +56,7 @@ include $(BUILD_HOST_STATIC_LIBRARY) # ===================================================== include $(CLEAR_VARS) +LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk LOCAL_MODULE:= libandroidfw LOCAL_MODULE_TAGS := optional @@ -63,11 +66,13 @@ LOCAL_C_INCLUDES := \ system/core/include LOCAL_STATIC_LIBRARIES := libziparchive LOCAL_SHARED_LIBRARIES := \ - libbinder \ - liblog \ - libcutils \ - libutils \ - libz + libbinder \ + liblog \ + libcutils \ + libutils \ + libz + +LOCAL_CFLAGS += -Wall -Werror -Wunused -Wunreachable-code include $(BUILD_SHARED_LIBRARY) diff --git a/libs/androidfw/Asset.cpp b/libs/androidfw/Asset.cpp index 589211f..4b3382e 100644 --- a/libs/androidfw/Asset.cpp +++ b/libs/androidfw/Asset.cpp @@ -45,6 +45,8 @@ using namespace android; # define O_BINARY 0 #endif +static const bool kIsDebug = false; + static Mutex gAssetLock; static int32_t gCount = 0; static Asset* gHead = NULL; @@ -89,7 +91,9 @@ Asset::Asset(void) gTail->mNext = this; gTail = this; } - //ALOGI("Creating Asset %p #%d\n", this, gCount); + if (kIsDebug) { + ALOGI("Creating Asset %p #%d\n", this, gCount); + } } Asset::~Asset(void) @@ -109,7 +113,9 @@ Asset::~Asset(void) mPrev->mNext = mNext; } mNext = mPrev = NULL; - //ALOGI("Destroying Asset in %p #%d\n", this, gCount); + if (kIsDebug) { + ALOGI("Destroying Asset in %p #%d\n", this, gCount); + } } /* diff --git a/libs/androidfw/AssetManager.cpp b/libs/androidfw/AssetManager.cpp index de6a33c..25cd363 100644 --- a/libs/androidfw/AssetManager.cpp +++ b/libs/androidfw/AssetManager.cpp @@ -64,6 +64,8 @@ using namespace android; +static const bool kIsDebug = false; + /* * 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. @@ -152,15 +154,19 @@ AssetManager::AssetManager(CacheMode cacheMode) mResources(NULL), mConfig(new ResTable_config), mCacheMode(cacheMode), mCacheValid(false) { - int count = android_atomic_inc(&gCount)+1; - //ALOGI("Creating AssetManager %p #%d\n", this, count); + int count = android_atomic_inc(&gCount) + 1; + if (kIsDebug) { + ALOGI("Creating AssetManager %p #%d\n", this, count); + } memset(mConfig, 0, sizeof(ResTable_config)); } AssetManager::~AssetManager(void) { 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 mResources; @@ -296,6 +302,10 @@ bool AssetManager::addOverlayPath(const String8& packagePath, int32_t* cookie) mAssetPaths.add(oap); *cookie = static_cast<int32_t>(mAssetPaths.size()); + if (mResources != NULL) { + appendPathToResTable(oap); + } + return true; } @@ -601,6 +611,11 @@ FileType AssetManager::getFileType(const char* fileName) } bool AssetManager::appendPathToResTable(const asset_path& ap) const { + // skip those ap's that correspond to system overlays + if (ap.isSystemOverlay) { + return true; + } + Asset* ass = NULL; ResTable* sharedRes = NULL; bool shared = true; @@ -786,6 +801,7 @@ void AssetManager::addSystemOverlays(const char* pathOverlaysList, oap.path = String8(buf, space - buf); oap.type = kFileTypeRegular; oap.idmap = String8(space + 1, newline - space - 1); + oap.isSystemOverlay = true; Asset* oass = const_cast<AssetManager*>(this)-> openNonAssetInPathLocked("resources.arsc", @@ -1864,7 +1880,9 @@ AssetManager::SharedZip::SharedZip(const String8& path, time_t modWhen) : mPath(path), mZipFile(NULL), mModWhen(modWhen), 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()); mZipFile = ZipFileRO::open(mPath.string()); if (mZipFile == NULL) { @@ -1958,7 +1976,9 @@ bool AssetManager::SharedZip::getOverlay(size_t idx, asset_path* out) const 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) { delete mResourceTable; } diff --git a/libs/androidfw/BackupData.cpp b/libs/androidfw/BackupData.cpp index d16d5498..ba4a4ff 100644 --- a/libs/androidfw/BackupData.cpp +++ b/libs/androidfw/BackupData.cpp @@ -27,7 +27,7 @@ namespace android { -static const bool DEBUG = false; +static const bool kIsDebug = false; /* * File Format (v1): @@ -45,12 +45,6 @@ static const bool DEBUG = false; const static int ROUND_UP[4] = { 0, 3, 2, 1 }; static inline size_t -round_up(size_t n) -{ - return n + ROUND_UP[n % 4]; -} - -static inline size_t padding_extra(size_t n) { return ROUND_UP[n % 4]; @@ -62,7 +56,7 @@ BackupDataWriter::BackupDataWriter(int fd) m_entityCount(0) { 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() @@ -79,7 +73,7 @@ BackupDataWriter::write_padding_for(int n) paddingSize = padding_extra(n); if (paddingSize > 0) { 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); if (amt != paddingSize) { m_status = errno; @@ -112,7 +106,7 @@ BackupDataWriter::WriteEntityHeader(const String8& key, size_t dataSize) } else { k = key; } - if (DEBUG) { + if (kIsDebug) { ALOGD("Writing header: prefix='%s' key='%s' dataSize=%zu", m_keyPrefix.string(), key.string(), dataSize); } @@ -126,7 +120,7 @@ BackupDataWriter::WriteEntityHeader(const String8& key, size_t dataSize) header.keyLen = tolel(keyLen); 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)); if (amt != sizeof(entity_header_v1)) { m_status = errno; @@ -134,7 +128,7 @@ BackupDataWriter::WriteEntityHeader(const String8& key, size_t dataSize) } 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); if (amt != keyLen+1) { m_status = errno; @@ -152,10 +146,10 @@ BackupDataWriter::WriteEntityHeader(const String8& key, size_t dataSize) status_t 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 (DEBUG) { + if (kIsDebug) { ALOGD("Not writing data - stream in error state %d (%s)", m_status, strerror(m_status)); } return m_status; @@ -167,7 +161,7 @@ BackupDataWriter::WriteEntityData(const void* data, size_t size) ssize_t amt = write(m_fd, data, size); if (amt != (ssize_t)size) { 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; } m_pos += amt; @@ -189,7 +183,7 @@ BackupDataReader::BackupDataReader(int fd) { memset(&m_header, 0, sizeof(m_header)); 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() @@ -342,15 +336,19 @@ BackupDataReader::ReadEntityData(void* data, size_t size) return -1; } int remaining = m_dataEndPos - m_pos; - //ALOGD("ReadEntityData size=%d m_pos=0x%x m_dataEndPos=0x%x remaining=%d\n", - // size, m_pos, m_dataEndPos, remaining); + if (kIsDebug) { + ALOGD("ReadEntityData size=%zu m_pos=0x%zx m_dataEndPos=0x%zx remaining=%d\n", + size, m_pos, m_dataEndPos, remaining); + } if (remaining <= 0) { return 0; } if (((int)size) > remaining) { size = remaining; } - //ALOGD(" reading %d bytes", size); + if (kIsDebug) { + ALOGD(" reading %zu bytes", size); + } int amt = read(m_fd, data, size); if (amt < 0) { m_status = errno; diff --git a/libs/androidfw/BackupHelpers.cpp b/libs/androidfw/BackupHelpers.cpp index 52dce9f..3f82830 100644 --- a/libs/androidfw/BackupHelpers.cpp +++ b/libs/androidfw/BackupHelpers.cpp @@ -68,14 +68,11 @@ struct file_metadata_v1 { const static int CURRENT_METADATA_VERSION = 1; -#if 1 -#define LOGP(f, x...) -#else +static const bool kIsDebug = false; #if TEST_BACKUP_HELPERS -#define LOGP(f, x...) printf(f "\n", x) +#define LOGP(f, x...) if (kIsDebug) printf(f "\n", x) #else -#define LOGP(x...) ALOGD(x) -#endif +#define LOGP(x...) if (kIsDebug) ALOGD(x) #endif const static int ROUND_UP[4] = { 0, 3, 2, 1 }; @@ -205,13 +202,6 @@ write_snapshot_file(int fd, const KeyedVector<String8,FileRec>& snapshot) } 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 write_update_file(BackupDataWriter* dataStream, int fd, int mode, const String8& key, char const* realFilename) { @@ -225,8 +215,6 @@ write_update_file(BackupDataWriter* dataStream, int fd, int mode, const String8& file_metadata_v1 metadata; char* buf = (char*)malloc(bufsize); - int crc = crc32(0L, Z_NULL, 0); - fileSize = lseek(fd, 0, SEEK_END); lseek(fd, 0, SEEK_SET); @@ -442,18 +430,6 @@ back_up_files(int oldSnapshotFD, BackupDataWriter* dataStream, int newSnapshotFD 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) { // [ 148 : 8 ] checksum -- to be calculated with this field as space chars memset(buf + 148, ' ', 8); @@ -579,7 +555,7 @@ int write_tarfile(const String8& packageName, const String8& domain, snprintf(buf + 124, 12, "%011llo", (isdir) ? 0LL : s.st_size); // [ 136 : 12 ] last mod time as a UTC time_t - snprintf(buf + 136, 12, "%0lo", s.st_mtime); + snprintf(buf + 136, 12, "%0lo", (unsigned long)s.st_mtime); // [ 156 : 1 ] link/file type uint8_t type; @@ -635,7 +611,6 @@ int write_tarfile(const String8& packageName, const String8& domain, // construct the pax extended header data block memset(paxData, 0, BUFSIZE - (paxData - buf)); - int len; // size header -- calc len in digits by actually rendering the number // 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; char* buf = (char*)malloc(bufSize); String8 string; - int cookie = 0x11111111; size_t actualSize; bool done; int type; @@ -1333,23 +1307,12 @@ get_mod_time(const char* filename, struct timeval times[2]) fprintf(stderr, "stat '%s' failed: %s\n", filename, strerror(errno)); return errno; } - times[0].tv_sec = st.st_atime; - times[1].tv_sec = st.st_mtime; - // If st_atime is a macro then struct stat64 uses struct timespec - // to store the access and modif time values and typically - // st_*time_nsec is not defined. In glibc, this is controlled by - // __USE_MISC. -#ifdef __USE_MISC -#if !defined(st_atime) || defined(st_atime_nsec) -#error "Check if this __USE_MISC conditional is still needed." -#endif + times[0].tv_sec = st.st_atim.tv_sec; times[0].tv_usec = st.st_atim.tv_nsec / 1000; + + times[1].tv_sec = st.st_mtim.tv_sec; times[1].tv_usec = st.st_mtim.tv_nsec / 1000; -#else - times[0].tv_usec = st.st_atime_nsec / 1000; - times[1].tv_usec = st.st_mtime_nsec / 1000; -#endif return 0; } @@ -1490,7 +1453,6 @@ int backup_helper_test_null_base() { int err; - int oldSnapshotFD; int dataStreamFD; int newSnapshotFD; @@ -1539,7 +1501,6 @@ int backup_helper_test_missing_file() { int err; - int oldSnapshotFD; int dataStreamFD; int newSnapshotFD; diff --git a/libs/androidfw/ObbFile.cpp b/libs/androidfw/ObbFile.cpp index ec59f06..195fa9a 100644 --- a/libs/androidfw/ObbFile.cpp +++ b/libs/androidfw/ObbFile.cpp @@ -122,7 +122,7 @@ bool ObbFile::parseObbFile(int fd) if (fileLength < 0) { ALOGW("error seeking in ObbFile: %s\n", strerror(errno)); } 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; } @@ -150,8 +150,8 @@ bool ObbFile::parseObbFile(int fd) footerSize = get4LE((unsigned char*)footer); if (footerSize > (size_t)fileLength - kFooterTagSize || footerSize > kMaxBufSize) { - ALOGW("claimed footer size is too large (0x%08zx; file size is 0x%08llx)\n", - footerSize, fileLength); + ALOGW("claimed footer size is too large (0x%08zx; file size is 0x%08lld)\n", + footerSize, (long long int)fileLength); return false; } @@ -164,7 +164,7 @@ bool ObbFile::parseObbFile(int fd) off64_t fileOffset = fileLength - footerSize - kFooterTagSize; 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; } diff --git a/libs/androidfw/ResourceTypes.cpp b/libs/androidfw/ResourceTypes.cpp index d7b9765..e78e4fe 100644 --- a/libs/androidfw/ResourceTypes.cpp +++ b/libs/androidfw/ResourceTypes.cpp @@ -27,6 +27,10 @@ #include <utils/String16.h> #include <utils/String8.h> +#ifdef HAVE_ANDROID_OS +#include <binder/TextOutput.h> +#endif + #include <stdlib.h> #include <string.h> #include <memory.h> @@ -38,32 +42,15 @@ #define INT32_MAX ((int32_t)(2147483647)) #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 { #ifdef HAVE_WINSOCK #undef nhtol #undef htonl - -#ifdef HAVE_LITTLE_ENDIAN #define ntohl(x) ( ((x) << 24) | (((x) >> 24) & 255) | (((x) << 8) & 0xff0000) | (((x) >> 8) & 0xff00) ) #define htonl(x) ntohl(x) #define ntohs(x) ( (((x) << 8) & 0xff00) | (((x) >> 8) & 255) ) #define htons(x) ntohs(x) -#else -#define ntohl(x) (x) -#define htonl(x) (x) -#define ntohs(x) (x) -#define htons(x) (x) -#endif #endif #define IDMAP_MAGIC 0x504D4449 @@ -72,6 +59,19 @@ namespace android { #define APP_PACKAGE_ID 0x7f #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 // produces incorrect results for UTF-16 characters. For safety's sake, assume that // any high-byte UTF-16 code point is not whitespace. @@ -719,12 +719,14 @@ const char16_t* ResStringPool::stringAt(size_t idx, size_t* u16len) const if (mCache == NULL) { #ifndef HAVE_ANDROID_OS - STRING_POOL_NOISY(ALOGI("CREATING STRING CACHE OF %d bytes", - mHeader->stringCount*sizeof(char16_t**))); + if (kDebugStringPoolNoisy) { + ALOGI("CREATING STRING CACHE OF %zu bytes", + mHeader->stringCount*sizeof(char16_t**)); + } #else // We do not want to be in this case when actually running Android. - ALOGW("CREATING STRING CACHE OF %d bytes", - mHeader->stringCount*sizeof(char16_t**)); + ALOGW("CREATING STRING CACHE OF %zu bytes", + static_cast<size_t>(mHeader->stringCount*sizeof(char16_t**))); #endif mCache = (char16_t**)calloc(mHeader->stringCount, sizeof(char16_t**)); if (mCache == NULL) { @@ -753,7 +755,9 @@ const char16_t* ResStringPool::stringAt(size_t idx, size_t* u16len) const 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); mCache[idx] = u16str; return u16str; @@ -843,7 +847,9 @@ ssize_t ResStringPool::indexOfString(const char16_t* str, size_t strLen) const size_t len; 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 // temporary UTF-16 strings to be created as we search. @@ -869,10 +875,14 @@ ssize_t ResStringPool::indexOfString(const char16_t* str, size_t strLen) const } else { c = -1; } - STRING_POOL_NOISY(ALOGI("Looking at %s, cmp=%d, l/mid/h=%d/%d/%d\n", - (const char*)s, c, (int)l, (int)mid, (int)h)); + if (kDebugStringPoolNoisy) { + 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) { - STRING_POOL_NOISY(ALOGI("MATCH!")); + if (kDebugStringPoolNoisy) { + ALOGI("MATCH!"); + } free(convBuffer); return mid; } else if (c < 0) { @@ -891,18 +901,22 @@ ssize_t ResStringPool::indexOfString(const char16_t* str, size_t strLen) const const size_t str8Len = str8.size(); for (int i=mHeader->stringCount-1; i>=0; i--) { const char* s = string8At(i, &len); - STRING_POOL_NOISY(ALOGI("Looking at %s, i=%d\n", - String8(s).string(), - i)); + if (kDebugStringPoolNoisy) { + ALOGI("Looking at %s, i=%d\n", String8(s).string(), i); + } if (s && str8Len == len && memcmp(s, str8.string(), str8Len) == 0) { - STRING_POOL_NOISY(ALOGI("MATCH!")); + if (kDebugStringPoolNoisy) { + ALOGI("MATCH!"); + } return i; } } } } 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) { // Do a binary search for the string... @@ -914,11 +928,14 @@ ssize_t ResStringPool::indexOfString(const char16_t* str, size_t strLen) const mid = l + (h - l)/2; const char16_t* s = stringAt(mid, &len); 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", - String8(s).string(), - c, (int)l, (int)mid, (int)h)); + if (kDebugStringPoolNoisy) { + ALOGI("Looking at %s, cmp=%d, l/mid/h=%d/%d/%d\n", + String8(s).string(), c, (int)l, (int)mid, (int)h); + } if (c == 0) { - STRING_POOL_NOISY(ALOGI("MATCH!")); + if (kDebugStringPoolNoisy) { + ALOGI("MATCH!"); + } return mid; } else if (c < 0) { l = mid + 1; @@ -933,11 +950,13 @@ ssize_t ResStringPool::indexOfString(const char16_t* str, size_t strLen) const // block, start searching at the back. for (int i=mHeader->stringCount-1; i>=0; i--) { const char16_t* s = stringAt(i, &len); - STRING_POOL_NOISY(ALOGI("Looking at %s, i=%d\n", - String8(s).string(), - i)); + if (kDebugStringPoolNoisy) { + ALOGI("Looking at %s, i=%d\n", String8(s).string(), i); + } if (s && strLen == len && strzcmp16(s, len, str, strLen) == 0) { - STRING_POOL_NOISY(ALOGI("MATCH!")); + if (kDebugStringPoolNoisy) { + ALOGI("MATCH!"); + } return i; } } @@ -1138,7 +1157,9 @@ const char16_t* ResXMLParser::getAttributeNamespace(size_t idx, size_t* outLen) { int32_t id = getAttributeNamespaceID(idx); //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; } @@ -1146,7 +1167,9 @@ const char* ResXMLParser::getAttributeNamespace8(size_t idx, size_t* outLen) con { int32_t id = getAttributeNamespaceID(idx); //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; } @@ -1169,7 +1192,9 @@ const char16_t* ResXMLParser::getAttributeName(size_t idx, size_t* outLen) const { int32_t id = getAttributeNameID(idx); //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; } @@ -1177,7 +1202,9 @@ const char* ResXMLParser::getAttributeName8(size_t idx, size_t* outLen) const { int32_t id = getAttributeNameID(idx); //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; } @@ -1212,7 +1239,9 @@ int32_t ResXMLParser::getAttributeValueStringID(size_t idx) const const char16_t* ResXMLParser::getAttributeStringValue(size_t idx, size_t* outLen) const { 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; } @@ -1303,54 +1332,69 @@ ssize_t ResXMLParser::indexOfAttribute(const char16_t* ns, size_t nsLen, ns8 = String8(ns, nsLen); } attr8 = String8(attr, attrLen); - STRING_POOL_NOISY(ALOGI("indexOfAttribute UTF8 %s (%d) / %s (%d)", ns8.string(), nsLen, - attr8.string(), attrLen)); + if (kDebugStringPoolNoisy) { + ALOGI("indexOfAttribute UTF8 %s (%zu) / %s (%zu)", ns8.string(), nsLen, + attr8.string(), attrLen); + } for (size_t i=0; i<N; i++) { size_t curNsLen = 0, curAttrLen = 0; const char* curNs = getAttributeNamespace8(i, &curNsLen); const char* curAttr = getAttributeName8(i, &curAttrLen); - STRING_POOL_NOISY(ALOGI(" curNs=%s (%d), curAttr=%s (%d)", curNs, curNsLen, - curAttr, curAttrLen)); + if (kDebugStringPoolNoisy) { + ALOGI(" curNs=%s (%zu), curAttr=%s (%zu)", curNs, curNsLen, curAttr, curAttrLen); + } if (curAttr != NULL && curNsLen == nsLen && curAttrLen == attrLen && memcmp(attr8.string(), curAttr, attrLen) == 0) { if (ns == NULL) { if (curNs == NULL) { - STRING_POOL_NOISY(ALOGI(" FOUND!")); + if (kDebugStringPoolNoisy) { + ALOGI(" FOUND!"); + } return i; } } else if (curNs != NULL) { //printf(" --> ns=%s, curNs=%s\n", // String8(ns).string(), String8(curNs).string()); if (memcmp(ns8.string(), curNs, nsLen) == 0) { - STRING_POOL_NOISY(ALOGI(" FOUND!")); + if (kDebugStringPoolNoisy) { + ALOGI(" FOUND!"); + } return i; } } } } } else { - STRING_POOL_NOISY(ALOGI("indexOfAttribute UTF16 %s (%d) / %s (%d)", - String8(ns, nsLen).string(), nsLen, - String8(attr, attrLen).string(), attrLen)); + if (kDebugStringPoolNoisy) { + ALOGI("indexOfAttribute UTF16 %s (%zu) / %s (%zu)", + String8(ns, nsLen).string(), nsLen, + String8(attr, attrLen).string(), attrLen); + } for (size_t i=0; i<N; i++) { size_t curNsLen = 0, curAttrLen = 0; const char16_t* curNs = getAttributeNamespace(i, &curNsLen); const char16_t* curAttr = getAttributeName(i, &curAttrLen); - STRING_POOL_NOISY(ALOGI(" curNs=%s (%d), curAttr=%s (%d)", - String8(curNs, curNsLen).string(), curNsLen, - String8(curAttr, curAttrLen).string(), curAttrLen)); + if (kDebugStringPoolNoisy) { + ALOGI(" curNs=%s (%zu), curAttr=%s (%zu)", + String8(curNs, curNsLen).string(), curNsLen, + String8(curAttr, curAttrLen).string(), curAttrLen); + } if (curAttr != NULL && curNsLen == nsLen && curAttrLen == attrLen && (memcmp(attr, curAttr, attrLen*sizeof(char16_t)) == 0)) { if (ns == NULL) { if (curNs == NULL) { - STRING_POOL_NOISY(ALOGI(" FOUND!")); + if (kDebugStringPoolNoisy) { + ALOGI(" FOUND!"); + } return i; } } else if (curNs != NULL) { //printf(" --> ns=%s, curNs=%s\n", // String8(ns).string(), String8(curNs).string()); if (memcmp(ns, curNs, nsLen*sizeof(char16_t)) == 0) { - STRING_POOL_NOISY(ALOGI(" FOUND!")); + if (kDebugStringPoolNoisy) { + ALOGI(" FOUND!"); + } return i; } } @@ -1398,7 +1442,9 @@ ResXMLParser::event_code_t ResXMLParser::nextNode() do { const ResXMLTree_node* next = (const ResXMLTree_node*) (((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) { mCurNode = NULL; @@ -1475,7 +1521,9 @@ ResXMLTree::ResXMLTree(const DynamicRefTable* dynamicRefTable) , mDynamicRefTable(dynamicRefTable) , 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(); } @@ -1484,13 +1532,17 @@ ResXMLTree::ResXMLTree() , mDynamicRefTable(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(); } 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(); } @@ -1543,8 +1595,10 @@ status_t ResXMLTree::setTo(const void* data, size_t size, bool copyData) } const uint16_t type = dtohs(chunk->type); const size_t size = dtohl(chunk->size); - XML_NOISY(printf("Scanning @ %p: type=0x%x, size=0x%x\n", - (void*)(((uint32_t)chunk)-((uint32_t)mHeader)), type, size)); + if (kDebugXMLNoisy) { + 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) { mStrings.setTo(chunk, size); } else if (type == RES_XML_RESOURCE_MAP_TYPE) { @@ -1567,7 +1621,9 @@ status_t ResXMLTree::setTo(const void* data, size_t size, bool copyData) mRootCode = mEventCode; break; } else { - XML_NOISY(printf("Skipping unknown chunk!\n")); + if (kDebugXMLNoisy) { + printf("Skipping unknown chunk!\n"); + } } lastChunk = chunk; chunk = (const ResChunk_header*) @@ -2151,9 +2207,11 @@ bool ResTable_config::isBetterThan(const ResTable_config& o, myDelta += requested->screenHeightDp - screenHeightDp; otherDelta += requested->screenHeightDp - o.screenHeightDp; } - //ALOGI("Comparing this %dx%d to other %dx%d in %dx%d: myDelta=%d otherDelta=%d", - // screenWidthDp, screenHeightDp, o.screenWidthDp, o.screenHeightDp, - // requested->screenWidthDp, requested->screenHeightDp, myDelta, otherDelta); + if (kDebugTableSuperNoisy) { + ALOGI("Comparing this %dx%d to other %dx%d in %dx%d: myDelta=%d otherDelta=%d", + screenWidthDp, screenHeightDp, o.screenWidthDp, o.screenHeightDp, + requested->screenWidthDp, requested->screenHeightDp, myDelta, otherDelta); + } if (myDelta != otherDelta) { return myDelta < otherDelta; } @@ -2408,11 +2466,17 @@ bool ResTable_config::match(const ResTable_config& settings) const { } if (screenSizeDp != 0) { 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; } 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; } } @@ -2432,9 +2496,13 @@ bool ResTable_config::match(const ResTable_config& settings) const { // For compatibility, we count a request for KEYSHIDDEN_NO as also // matching the more recent KEYSHIDDEN_SOFT. Basically // 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) { - //ALOGI("No match!"); + if (kDebugTableSuperNoisy) { + ALOGI("No match!"); + } return false; } } @@ -2939,17 +3007,25 @@ struct ResTable::PackageGroup void clearBagCache() { 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++) { - TABLE_NOISY(printf("type=%d\n", i)); + if (kDebugTableNoisy) { + printf("type=%zu\n", i); + } const TypeList& typeList = types[i]; if (!typeList.isEmpty()) { bag_set** typeBags = bags->get(i); - TABLE_NOISY(printf("typeBags=%p\n", typeBags)); + if (kDebugTableNoisy) { + printf("typeBags=%p\n", typeBags); + } if (typeBags) { const size_t N = typeList[0]->entryCount; - TABLE_NOISY(printf("type->entryCount=%x\n", N)); - for (size_t j=0; j<N; j++) { + if (kDebugTableNoisy) { + printf("type->entryCount=%zu\n", N); + } + for (size_t j = 0; j < N; j++) { if (typeBags[j] && typeBags[j] != (bag_set*)0xFFFFFFFF) free(typeBags[j]); } @@ -3057,7 +3133,9 @@ status_t ResTable::Theme::applyStyle(uint32_t resID, bool force) uint32_t bagTypeSpecFlags = 0; mTable.lock(); 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) { mTable.unlock(); return N; @@ -3088,7 +3166,6 @@ status_t ResTable::Theme::applyStyle(uint32_t resID, bool force) curPackageIndex = pidx; curPI = mPackages[pidx]; if (curPI == NULL) { - PackageGroup* const grp = mTable.mPackageGroups[pidx]; curPI = (package_info*)malloc(sizeof(package_info)); memset(curPI, 0, sizeof(*curPI)); mPackages[pidx] = curPI; @@ -3120,9 +3197,11 @@ status_t ResTable::Theme::applyStyle(uint32_t resID, bool force) continue; } theme_entry* curEntry = curEntries + e; - TABLE_NOISY(ALOGV("Attr 0x%08x: type=0x%x, data=0x%08x; curType=0x%x", - attrRes, bag->map.value.dataType, bag->map.value.data, - curEntry->value.dataType)); + if (kDebugTableNoisy) { + ALOGV("Attr 0x%08x: type=0x%x, data=0x%08x; curType=0x%x", + attrRes, bag->map.value.dataType, bag->map.value.data, + curEntry->value.dataType); + } if (force || curEntry->value.dataType == Res_value::TYPE_NULL) { curEntry->stringBlock = bag->stringBlock; curEntry->typeSpecFlags |= bagTypeSpecFlags; @@ -3134,17 +3213,21 @@ status_t ResTable::Theme::applyStyle(uint32_t resID, bool force) mTable.unlock(); - //ALOGI("Applying style 0x%08x (force=%d) theme %p...\n", resID, force, this); - //dumpToLog(); + if (kDebugTableTheme) { + ALOGI("Applying style 0x%08x (force=%d) theme %p...\n", resID, force, this); + dumpToLog(); + } return NO_ERROR; } status_t ResTable::Theme::setTo(const Theme& other) { - //ALOGI("Setting theme %p from theme %p...\n", this, &other); - //dumpToLog(); - //other.dumpToLog(); + if (kDebugTableTheme) { + ALOGI("Setting theme %p from theme %p...\n", this, &other); + dumpToLog(); + other.dumpToLog(); + } if (&mTable == &other.mTable) { for (size_t i=0; i<Res_MAXPACKAGE; i++) { @@ -3173,8 +3256,10 @@ status_t ResTable::Theme::setTo(const Theme& other) } } - //ALOGI("Final theme:"); - //dumpToLog(); + if (kDebugTableTheme) { + ALOGI("Final theme:"); + dumpToLog(); + } return NO_ERROR; } @@ -3191,23 +3276,33 @@ ssize_t ResTable::Theme::getAttribute(uint32_t resID, Res_value* outValue, const uint32_t t = Res_GETTYPE(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) { const package_info* const pi = mPackages[p]; - TABLE_THEME(ALOGI("Found package: %p", pi)); + if (kDebugTableTheme) { + ALOGI("Found package: %p", pi); + } 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) { 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) { const theme_entry& te = ti.entries[e]; if (outTypeSpecFlags != NULL) { *outTypeSpecFlags |= te.typeSpecFlags; } - TABLE_THEME(ALOGI("Theme value: type=0x%x, data=0x%08x", - te.value.dataType, te.value.data)); + if (kDebugTableTheme) { + ALOGI("Theme value: type=0x%x, data=0x%08x", + te.value.dataType, te.value.data); + } const uint8_t type = te.value.dataType; if (type == Res_value::TYPE_ATTRIBUTE) { if (cnt > 0) { @@ -3241,8 +3336,10 @@ ssize_t ResTable::Theme::resolveAttributeReference(Res_value* inOutValue, if (inOutValue->dataType == Res_value::TYPE_ATTRIBUTE) { uint32_t newTypeSpecFlags; blockIndex = getAttribute(inOutValue->data, inOutValue, &newTypeSpecFlags); - TABLE_THEME(ALOGI("Resolving attr reference: blockIndex=%d, type=0x%x, data=%p\n", - (int)blockIndex, (int)inOutValue->dataType, (void*)inOutValue->data)); + if (kDebugTableTheme) { + 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; //printf("Retrieved attribute new type=0x%x\n", inOutValue->dataType); if (blockIndex < 0) { @@ -3281,7 +3378,9 @@ ResTable::ResTable() { memset(&mParams, 0, sizeof(mParams)); 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) @@ -3291,12 +3390,16 @@ ResTable::ResTable(const void* data, size_t size, const int32_t cookie, bool cop memset(mPackageMap, 0, sizeof(mPackageMap)); addInternal(data, size, NULL, 0, cookie, copyData); 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() { - //ALOGI("Destroying ResTable in %p\n", this); + if (kDebugTableSuperNoisy) { + ALOGI("Destroying ResTable in %p\n", this); + } uninit(); } @@ -3425,9 +3528,10 @@ status_t ResTable::addInternal(const void* data, size_t dataSize, const void* id const bool notDeviceEndian = htods(0xf0) != 0xf0; - LOAD_TABLE_NOISY( - ALOGV("Adding resources to ResTable: data=%p, size=0x%x, cookie=%d, copy=%d " - "idmap=%p\n", data, dataSize, cookie, copyData, idmap)); + if (kDebugLoadTableNoisy) { + ALOGV("Adding resources to ResTable: data=%p, size=%zu, cookie=%d, copy=%d " + "idmap=%p\n", data, dataSize, cookie, copyData, idmapData); + } if (copyData || notDeviceEndian) { header->ownedData = malloc(dataSize); @@ -3440,9 +3544,13 @@ status_t ResTable::addInternal(const void* data, size_t dataSize, const void* id header->header = (const ResTable_header*)data; header->size = dtohl(header->header->header.size); - //ALOGI("Got size 0x%x, again size 0x%x, raw size 0x%x\n", header->size, - // dtohl(header->header->header.size), header->header->header.size); - LOAD_TABLE_NOISY(ALOGV("Loading ResTable @%p:\n", header->header)); + if (kDebugLoadTableSuperNoisy) { + ALOGI("Got size %zu, again size 0x%x, raw size 0x%x\n", header->size, + 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 || header->size > dataSize) { ALOGW("Bad resource table: header size 0x%x or total size 0x%x is larger than data size 0x%x\n", @@ -3470,9 +3578,11 @@ status_t ResTable::addInternal(const void* data, size_t dataSize, const void* id if (err != NO_ERROR) { return (mError=err); } - TABLE_NOISY(ALOGV("Chunk: type=0x%x, headerSize=0x%x, size=0x%x, pos=%p\n", - dtohs(chunk->type), dtohs(chunk->headerSize), dtohl(chunk->size), - (void*)(((const uint8_t*)chunk) - ((const uint8_t*)header->header)))); + 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), + (void*)(((const uint8_t*)chunk) - ((const uint8_t*)header->header))); + } const size_t csize = dtohl(chunk->size); const uint16_t ctype = dtohs(chunk->type); if (ctype == RES_STRING_POOL_TYPE) { @@ -3516,7 +3626,9 @@ status_t ResTable::addInternal(const void* data, size_t dataSize, const void* id 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; } @@ -3682,15 +3794,16 @@ ssize_t ResTable::getResource(uint32_t resID, Res_value* outValue, bool mayBeBag return BAD_VALUE; } - TABLE_NOISY(size_t len; - printf("Found value: pkg=%d, type=%d, str=%s, int=%d\n", - entry.package->header->index, - outValue->dataType, - outValue->dataType == Res_value::TYPE_STRING - ? String8(entry.package->header->values.stringAt( - outValue->data, &len)).string() - : "", - outValue->data)); + if (kDebugTableNoisy) { + size_t len; + printf("Found value: pkg=%zu, type=%d, str=%s, int=%d\n", + entry.package->header->index, + outValue->dataType, + outValue->dataType == Res_value::TYPE_STRING ? + String8(entry.package->header->values.stringAt(outValue->data, &len)).string() : + "", + outValue->data); + } if (outSpecFlags != NULL) { *outSpecFlags = entry.specFlags; @@ -3711,15 +3824,16 @@ ssize_t ResTable::resolveReference(Res_value* value, ssize_t blockIndex, while (blockIndex >= 0 && value->dataType == Res_value::TYPE_REFERENCE && value->data != 0 && count < 20) { if (outLastRef) *outLastRef = value->data; - uint32_t lastRef = value->data; uint32_t newFlags = 0; const ssize_t newIndex = getResource(value->data, value, true, 0, &newFlags, outConfig); if (newIndex == BAD_INDEX) { return BAD_INDEX; } - TABLE_THEME(ALOGI("Resolving reference %p: newIndex=%d, type=0x%x, data=%p\n", - (void*)lastRef, (int)newIndex, (int)value->dataType, (void*)value->data)); + if (kDebugTableTheme) { + 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); if (inoutTypeSpecFlags != NULL) *inoutTypeSpecFlags |= newFlags; if (newIndex < 0) { @@ -3826,7 +3940,9 @@ ssize_t ResTable::getBagLocked(uint32_t resID, const bag_entry** outBag, *outTypeSpecFlags = set->typeSpecFlags; } *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; } ALOGW("Attempt to retrieve bag 0x%08x which is invalid or in a cycle.", @@ -3852,7 +3968,9 @@ ssize_t ResTable::getBagLocked(uint32_t resID, const bag_entry** outBag, // Mark that we are currently working on this one. 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 Entry entry; @@ -3869,13 +3987,13 @@ ssize_t ResTable::getBagLocked(uint32_t resID, const bag_entry** outBag, size_t N = count; - TABLE_NOISY(ALOGI("Found map: size=%p parent=%p count=%d\n", - entrySize, parent, count)); + if (kDebugTableNoisy) { + ALOGI("Found map: size=%x parent=%x count=%d\n", entrySize, parent, count); // If this map inherits from another, we need to start // with its parent's values. Otherwise start out empty. - TABLE_NOISY(printf("Creating new bag, entrySize=0x%08x, parent=0x%08x\n", - entrySize, parent)); + ALOGI("Creating new bag, entrySize=0x%08x, parent=0x%08x\n", entrySize, parent); + } // This is what we are building. bag_set* set = NULL; @@ -3904,9 +4022,13 @@ ssize_t ResTable::getBagLocked(uint32_t resID, const bag_entry** outBag, if (NP > 0) { memcpy(set+1, parentBag, NP*sizeof(bag_entry)); 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 { - 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->availAttrs = NT; @@ -3930,10 +4052,13 @@ ssize_t ResTable::getBagLocked(uint32_t resID, const bag_entry** outBag, bag_entry* entries = (bag_entry*)(set+1); size_t curEntry = 0; uint32_t pos = 0; - TABLE_NOISY(ALOGI("Starting with set %p, entries=%p, avail=%d\n", - set, entries, set->availAttrs)); + if (kDebugTableNoisy) { + ALOGI("Starting with set %p, entries=%p, avail=%zu\n", set, entries, set->availAttrs); + } 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))) { ALOGW("ResTable_map at %d is beyond type chunk data %d", @@ -3958,8 +4083,10 @@ ssize_t ResTable::getBagLocked(uint32_t resID, const bag_entry** outBag, uint32_t oldName = 0; while ((isInside=(curEntry < set->numAttrs)) && (oldName=entries[curEntry].map.name.ident) < newName) { - TABLE_NOISY(printf("#%d: Keeping existing attribute: 0x%08x\n", - curEntry, entries[curEntry].map.name.ident)); + if (kDebugTableNoisy) { + ALOGI("#%zu: Keeping existing attribute: 0x%08x\n", + curEntry, entries[curEntry].map.name.ident); + } curEntry++; } @@ -3976,8 +4103,10 @@ ssize_t ResTable::getBagLocked(uint32_t resID, const bag_entry** outBag, } set->availAttrs = newAvail; entries = (bag_entry*)(set+1); - TABLE_NOISY(printf("Reallocated set %p, entries=%p, avail=%d\n", - set, entries, set->availAttrs)); + if (kDebugTableNoisy) { + ALOGI("Reallocated set %p, entries=%p, avail=%zu\n", + set, entries, set->availAttrs); + } } if (isInside) { // Going in the middle, need to make space. @@ -3985,11 +4114,13 @@ ssize_t ResTable::getBagLocked(uint32_t resID, const bag_entry** outBag, sizeof(bag_entry)*(set->numAttrs-curEntry)); set->numAttrs++; } - TABLE_NOISY(printf("#%d: Inserting new attribute: 0x%08x\n", - curEntry, newName)); + if (kDebugTableNoisy) { + ALOGI("#%zu: Inserting new attribute: 0x%08x\n", curEntry, newName); + } } else { - TABLE_NOISY(printf("#%d: Replacing existing attribute: 0x%08x\n", - curEntry, oldName)); + if (kDebugTableNoisy) { + ALOGI("#%zu: Replacing existing attribute: 0x%08x\n", curEntry, oldName); + } } bag_entry* cur = entries+curEntry; @@ -4003,9 +4134,11 @@ ssize_t ResTable::getBagLocked(uint32_t resID, const bag_entry** outBag, return UNKNOWN_ERROR; } - TABLE_NOISY(printf("Setting entry #%d %p: block=%d, name=0x%08x, type=%d, data=0x%08x\n", - curEntry, cur, cur->stringBlock, cur->map.name.ident, - cur->map.value.dataType, cur->map.value.data)); + 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, + cur->map.value.dataType, cur->map.value.data); + } // On to the next! curEntry++; @@ -4025,7 +4158,9 @@ ssize_t ResTable::getBagLocked(uint32_t resID, const bag_entry** outBag, *outTypeSpecFlags = set->typeSpecFlags; } *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 BAD_INDEX; @@ -4034,10 +4169,14 @@ ssize_t ResTable::getBagLocked(uint32_t resID, const bag_entry** outBag, void ResTable::setParameters(const ResTable_config* params) { mLock.lock(); - TABLE_GETENTRY(ALOGI("Setting parameters: %s\n", params->toString().string())); + if (kDebugTableGetEntry) { + ALOGI("Setting parameters: %s\n", params->toString().string()); + } mParams = *params; 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(); } mLock.unlock(); @@ -4075,7 +4214,9 @@ uint32_t ResTable::identifierForName(const char16_t* name, size_t nameLen, size_t packageLen, 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 // that we will always find them even when there are no resources. @@ -4168,10 +4309,12 @@ nope: } nameLen = nameEnd-name; - TABLE_NOISY(printf("Looking for identifier: type=%s, name=%s, package=%s\n", - String8(type, typeLen).string(), - String8(name, nameLen).string(), - String8(package, packageLen).string())); + if (kDebugTableNoisy) { + printf("Looking for identifier: type=%s, name=%s, package=%s\n", + String8(type, typeLen).string(), + String8(name, nameLen).string(), + String8(package, packageLen).string()); + } const String16 attr("attr"); const String16 attrPrivate("^attr-private"); @@ -4182,7 +4325,9 @@ nope: if (strzcmp16(package, packageLen, 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; } @@ -4712,9 +4857,11 @@ bool ResTable::stringToValue(Res_value* outValue, String16* outString, rid = Res_MAKEID( accessor->getRemappedPackage(Res_GETPACKAGE(rid)), Res_GETTYPE(rid), Res_GETENTRY(rid)); - TABLE_NOISY(printf("Incl %s:%s/%s: 0x%08x\n", - String8(package).string(), String8(type).string(), - String8(name).string(), rid)); + if (kDebugTableNoisy) { + ALOGI("Incl %s:%s/%s: 0x%08x\n", + String8(package).string(), String8(type).string(), + String8(name).string(), rid); + } } uint32_t packageId = Res_GETPACKAGE(rid) + 1; @@ -4729,9 +4876,11 @@ bool ResTable::stringToValue(Res_value* outValue, String16* outString, uint32_t rid = accessor->getCustomResourceWithCreation(package, type, name, createIfNotFound); if (rid != 0) { - TABLE_NOISY(printf("Pckg %s:%s/%s: 0x%08x\n", - String8(package).string(), String8(type).string(), - String8(name).string(), rid)); + if (kDebugTableNoisy) { + ALOGI("Pckg %s:%s/%s: 0x%08x\n", + String8(package).string(), String8(type).string(), + String8(name).string(), rid); + } uint32_t packageId = Res_GETPACKAGE(rid) + 1; if (packageId == 0x00) { outValue->data = rid; @@ -5534,8 +5683,6 @@ status_t ResTable::getEntry( } // 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*>( reinterpret_cast<const uint8_t*>(thisType) + dtohs(thisType->header.headerSize)); @@ -5724,9 +5871,11 @@ status_t ResTable::parsePackage(const ResTable_package* const pkg, const uint8_t* endPos = ((const uint8_t*)pkg) + dtohs(pkg->header.size); while (((const uint8_t*)chunk) <= (endPos-sizeof(ResChunk_header)) && ((const uint8_t*)chunk) <= (endPos-dtohl(chunk->size))) { - TABLE_NOISY(ALOGV("PackageChunk: type=0x%x, headerSize=0x%x, size=0x%x, pos=%p\n", - dtohs(chunk->type), dtohs(chunk->headerSize), dtohl(chunk->size), - (void*)(((const uint8_t*)chunk) - ((const uint8_t*)header->header)))); + 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), + (void*)(((const uint8_t*)chunk) - ((const uint8_t*)header->header))); + } const size_t csize = dtohl(chunk->size); const uint16_t ctype = dtohs(chunk->type); if (ctype == RES_TABLE_TYPE_SPEC_TYPE) { @@ -5740,11 +5889,13 @@ status_t ResTable::parsePackage(const ResTable_package* const pkg, const size_t typeSpecSize = dtohl(typeSpec->header.size); const size_t newEntryCount = dtohl(typeSpec->entryCount); - LOAD_TABLE_NOISY(printf("TypeSpec off %p: type=0x%x, headerSize=0x%x, size=%p\n", - (void*)(base-(const uint8_t*)chunk), - dtohs(typeSpec->header.type), - dtohs(typeSpec->header.headerSize), - (void*)typeSpecSize)); + if (kDebugLoadTableNoisy) { + ALOGI("TypeSpec off %p: type=0x%x, headerSize=0x%x, size=%p\n", + (void*)(base-(const uint8_t*)chunk), + dtohs(typeSpec->header.type), + dtohs(typeSpec->header.headerSize), + (void*)typeSpecSize); + } // look for block overrun or int overflow when multiplying by 4 if ((dtohl(typeSpec->entryCount) > (INT32_MAX/sizeof(uint32_t)) || dtohs(typeSpec->header.headerSize)+(sizeof(uint32_t)*newEntryCount) @@ -5802,13 +5953,14 @@ status_t ResTable::parsePackage(const ResTable_package* const pkg, const uint32_t typeSize = dtohl(type->header.size); const size_t newEntryCount = dtohl(type->entryCount); - LOAD_TABLE_NOISY(printf("Type off %p: type=0x%x, headerSize=0x%x, size=%p\n", - (void*)(base-(const uint8_t*)chunk), - dtohs(type->header.type), - dtohs(type->header.headerSize), - (void*)typeSize)); - if (dtohs(type->header.headerSize)+(sizeof(uint32_t)*newEntryCount) - > typeSize) { + if (kDebugLoadTableNoisy) { + printf("Type off %p: type=0x%x, headerSize=0x%x, size=%u\n", + (void*)(base-(const uint8_t*)chunk), + dtohs(type->header.type), + dtohs(type->header.headerSize), + typeSize); + } + if (dtohs(type->header.headerSize)+(sizeof(uint32_t)*newEntryCount) > typeSize) { ALOGW("ResTable_type entry index to %p extends beyond chunk end 0x%x.", (void*)(dtohs(type->header.headerSize) + (sizeof(uint32_t)*newEntryCount)), typeSize); @@ -5854,11 +6006,12 @@ status_t ResTable::parsePackage(const ResTable_package* const pkg, t->configs.add(type); - TABLE_GETENTRY( + if (kDebugTableGetEntry) { ResTable_config thisConfig; thisConfig.copyFromDtoH(type->config); - ALOGI("Adding config to type %d: %s\n", - type->id, thisConfig.toString().string())); + ALOGI("Adding config to type %d: %s\n", type->id, + thisConfig.toString().string()); + } } else { ALOGV("Skipping empty ResTable_type for type %d", type->id); } @@ -5919,8 +6072,10 @@ status_t DynamicRefTable::load(const ResTable_lib_header* const header) uint32_t packageId = dtohl(entry->packageId); char16_t tmpName[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(), - dtohl(entry->packageId))); + if (kDebugLibNoisy) { + ALOGV("Found lib entry %s with id %d\n", String8(tmpName).string(), + dtohl(entry->packageId)); + } if (packageId >= 256) { ALOGE("Bad package id 0x%08x", packageId); return UNKNOWN_ERROR; @@ -6103,20 +6258,20 @@ status_t ResTable::createIdmap(const ResTable& overlay, 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" - " but entries should map to resources of type %02x", + " but entries should map to resources of type %02zx", resID, overlayResID, typeMap.overlayTypeId); return BAD_TYPE; } if (typeMap.entryOffset + typeMap.entryMap.size() < entryIndex) { - // Resize to accomodate this entry and the 0's in between. - if (typeMap.entryMap.resize((entryIndex - typeMap.entryOffset) + 1) < 0) { + // pad with 0xffffffff's (indicating non-existing entries) before adding this entry + size_t index = typeMap.entryMap.size(); + size_t numItems = entryIndex - (typeMap.entryOffset + index); + if (typeMap.entryMap.insertAt(0xffffffff, index, numItems) < 0) { return NO_MEMORY; } - typeMap.entryMap.editTop() = Res_GETENTRY(overlayResID); - } else { - typeMap.entryMap.add(Res_GETENTRY(overlayResID)); } + typeMap.entryMap.add(Res_GETENTRY(overlayResID)); } if (!typeMap.entryMap.isEmpty()) { @@ -6439,9 +6594,6 @@ void ResTable::print(bool inclValues) const continue; } 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 uint8_t*)type) + dtohs(type->header.headerSize)); diff --git a/libs/androidfw/StreamingZipInflater.cpp b/libs/androidfw/StreamingZipInflater.cpp index 1dfec23..b39b5f0 100644 --- a/libs/androidfw/StreamingZipInflater.cpp +++ b/libs/androidfw/StreamingZipInflater.cpp @@ -41,6 +41,8 @@ _rc; }) #endif +static const bool kIsDebug = false; + static inline size_t min_of(size_t a, size_t b) { return (a < b) ? a : b; } using namespace android; @@ -209,7 +211,9 @@ int StreamingZipInflater::readNextChunk() { size_t toRead = min_of(mInBufSize, mInTotalSize - mInNextChunkOffset); if (toRead > 0) { 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) { ALOGE("Error reading asset data: %s", strerror(errno)); return didRead; diff --git a/libs/androidfw/ZipFileRO.cpp b/libs/androidfw/ZipFileRO.cpp index 1ab18ad..ef0d072 100644 --- a/libs/androidfw/ZipFileRO.cpp +++ b/libs/androidfw/ZipFileRO.cpp @@ -34,14 +34,6 @@ #include <assert.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; class _ZipEntryRO { @@ -50,7 +42,10 @@ public: ZipEntryName name; void *cookie; - _ZipEntryRO() : cookie(NULL) { + _ZipEntryRO() : cookie(NULL) {} + + ~_ZipEntryRO() { + EndIteration(cookie); } private: @@ -83,15 +78,15 @@ ZipFileRO::~ZipFileRO() { ZipEntryRO ZipFileRO::findEntryByName(const char* entryName) const { _ZipEntryRO* data = new _ZipEntryRO; - const int32_t error = FindEntry(mHandle, entryName, &(data->entry)); + + data->name = ZipEntryName(entryName); + + const int32_t error = FindEntry(mHandle, data->name, &(data->entry)); if (error) { delete data; return NULL; } - data->name.name = entryName; - data->name.name_length = strlen(entryName); - return (ZipEntryRO) data; } diff --git a/libs/androidfw/tests/Android.mk b/libs/androidfw/tests/Android.mk index c1014be..58b78b5 100644 --- a/libs/androidfw/tests/Android.mk +++ b/libs/androidfw/tests/Android.mk @@ -38,12 +38,17 @@ testFiles := \ include $(CLEAR_VARS) 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_STATIC_LIBRARIES := \ libandroidfw \ libutils \ libcutils \ - liblog + liblog include $(BUILD_HOST_NATIVE_TEST) @@ -55,6 +60,11 @@ ifneq ($(SDK_ONLY),true) include $(CLEAR_VARS) 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) \ BackupData_test.cpp \ ObbFile_test.cpp @@ -63,7 +73,6 @@ LOCAL_SHARED_LIBRARIES := \ libcutils \ libutils \ libui \ - libstlport include $(BUILD_NATIVE_TEST) endif # Not SDK_ONLY diff --git a/libs/common_time/Android.mk b/libs/common_time/Android.mk index 75eb528..1fec504 100644 --- a/libs/common_time/Android.mk +++ b/libs/common_time/Android.mk @@ -33,4 +33,6 @@ LOCAL_SHARED_LIBRARIES := \ LOCAL_MODULE_TAGS := optional LOCAL_MODULE := common_time +LOCAL_CFLAGS += -Wall -Werror -Wunused -Wunreachable-code + include $(BUILD_EXECUTABLE) diff --git a/libs/common_time/clock_recovery.cpp b/libs/common_time/clock_recovery.cpp index 3a7c70c..392caa0 100644 --- a/libs/common_time/clock_recovery.cpp +++ b/libs/common_time/clock_recovery.cpp @@ -22,6 +22,7 @@ #define __STDC_LIMIT_MACROS #define LOG_TAG "common_time" #include <utils/Log.h> +#include <inttypes.h> #include <stdint.h> #include <common_time/local_clock.h> @@ -280,7 +281,7 @@ bool ClockRecoveryLoop::pushDisciplineEvent(int64_t local_time, // system. setTargetCorrection_l(tgt_correction); - LOG_TS("clock_loop %lld %f %f %f %d\n", raw_delta, delta_f, CO, CObias, tgt_correction); + LOG_TS("clock_loop %" PRId64 " %f %f %f %d\n", raw_delta, delta_f, CO, CObias, tgt_correction); #ifdef TIME_SERVICE_DEBUG diag_thread_->pushDisciplineEvent( @@ -335,7 +336,6 @@ void ClockRecoveryLoop::setTargetCorrection_l(int32_t tgt) { // 300mSec. if (tgt_correction_ != tgt) { int64_t now = local_clock_->getLocalTime(); - status_t res; tgt_correction_ = tgt; diff --git a/libs/common_time/clock_recovery.h b/libs/common_time/clock_recovery.h index b6c87ff..278a75e 100644 --- a/libs/common_time/clock_recovery.h +++ b/libs/common_time/clock_recovery.h @@ -111,7 +111,6 @@ class ClockRecoveryLoop { bool last_error_est_valid_; int32_t last_error_est_usec_; float last_delta_f_; - int32_t integrated_error_; int32_t tgt_correction_; int32_t cur_correction_; LinearTransform time_to_cur_slew_; diff --git a/libs/common_time/common_clock.cpp b/libs/common_time/common_clock.cpp index c9eb388..ee326e1 100644 --- a/libs/common_time/common_clock.cpp +++ b/libs/common_time/common_clock.cpp @@ -19,6 +19,7 @@ #define LOG_TAG "common_time" #include <utils/Log.h> +#include <inttypes.h> #include <stdint.h> #include <utils/Errors.h> @@ -50,7 +51,7 @@ bool CommonClock::init(uint64_t local_freq) { LinearTransform::reduce(&numer, &denom); if ((numer > UINT32_MAX) || (denom > UINT32_MAX)) { - ALOGE("Overflow in CommonClock::init while trying to reduce %lld/%lld", + ALOGE("Overflow in CommonClock::init while trying to reduce %" PRIu64 "/%" PRIu64, kCommonFreq, local_freq); return false; } diff --git a/libs/common_time/common_clock_service.cpp b/libs/common_time/common_clock_service.cpp index 9ca6f35..592ab1d 100644 --- a/libs/common_time/common_clock_service.cpp +++ b/libs/common_time/common_clock_service.cpp @@ -99,14 +99,14 @@ status_t CommonClockService::registerListener( Mutex::Autolock lock(mCallbackLock); // check whether this is a duplicate for (size_t i = 0; i < mListeners.size(); i++) { - if (mListeners[i]->asBinder() == listener->asBinder()) + if (IInterface::asBinder(mListeners[i]) == IInterface::asBinder(listener)) return ALREADY_EXISTS; } } mListeners.add(listener); mTimeServer.reevaluateAutoDisableState(0 != mListeners.size()); - return listener->asBinder()->linkToDeath(this); + return IInterface::asBinder(listener)->linkToDeath(this); } status_t CommonClockService::unregisterListener( @@ -117,8 +117,8 @@ status_t CommonClockService::unregisterListener( { // scoping for autolock pattern Mutex::Autolock lock(mCallbackLock); for (size_t i = 0; i < mListeners.size(); i++) { - if (mListeners[i]->asBinder() == listener->asBinder()) { - mListeners[i]->asBinder()->unlinkToDeath(this); + if (IInterface::asBinder(mListeners[i]) == IInterface::asBinder(listener)) { + IInterface::asBinder(mListeners[i])->unlinkToDeath(this); mListeners.removeAt(i); ret_val = OK; break; @@ -136,7 +136,7 @@ void CommonClockService::binderDied(const wp<IBinder>& who) { { // scoping for autolock pattern Mutex::Autolock lock(mCallbackLock); for (size_t i = 0; i < mListeners.size(); i++) { - if (mListeners[i]->asBinder() == who) { + if (IInterface::asBinder(mListeners[i]) == who) { mListeners.removeAt(i); break; } diff --git a/libs/common_time/common_time_server.cpp b/libs/common_time/common_time_server.cpp index 3e11987..01372e0 100644 --- a/libs/common_time/common_time_server.cpp +++ b/libs/common_time/common_time_server.cpp @@ -25,6 +25,7 @@ #include <arpa/inet.h> #include <assert.h> #include <fcntl.h> +#include <inttypes.h> #include <linux/if_ether.h> #include <net/if.h> #include <net/if_arp.h> @@ -969,13 +970,14 @@ bool CommonTimeServer::handleSyncResponse( // if the RTT of the packet is significantly larger than the panic // threshold, we should simply discard it. Its better to do nothing // than to take cues from a packet like that. - int rttCommon = mCommonClock.localDurationToCommonDuration(rtt); + int64_t rttCommon = mCommonClock.localDurationToCommonDuration(rtt); if (rttCommon > (static_cast<int64_t>(mPanicThresholdUsec) * kRTTDiscardPanicThreshMultiplier)) { - ALOGV("Dropping sync response with RTT of %lld uSec", rttCommon); + ALOGV("Dropping sync response with RTT of %" PRId64 " uSec", rttCommon); mClient_ExpiredSyncRespsRXedFromCurMaster++; if (shouldPanicNotGettingGoodData()) return becomeInitial("RX panic, no good data"); + return true; } else { result = mClockRecovery.pushDisciplineEvent(avgLocal, avgCommon, rttCommon); mClient_LastGoodSyncRX = clientRxLocalTime; diff --git a/libs/common_time/common_time_server_api.cpp b/libs/common_time/common_time_server_api.cpp index e157071..e0f35a9 100644 --- a/libs/common_time/common_time_server_api.cpp +++ b/libs/common_time/common_time_server_api.cpp @@ -27,6 +27,8 @@ #include "common_time_server.h" +#include <inttypes.h> + namespace android { // @@ -286,7 +288,7 @@ void CommonTimeServer::reevaluateAutoDisableState(bool commonClockHasClients) { #define checked_percentage(a, b) ((0 == b) ? 0.0f : ((100.0f * a) / b)) status_t CommonTimeServer::dumpClockInterface(int fd, - const Vector<String16>& args, + const Vector<String16>& /* args */, size_t activeClients) { AutoMutex _lock(&mLock); const size_t SIZE = 256; @@ -308,15 +310,15 @@ status_t CommonTimeServer::dumpClockInterface(int fd, synced = (OK == mCommonClock.localToCommon(localTime, &commonTime)); sockaddrToString(mMasterEP, mMasterEPValid, maStr, sizeof(maStr)); - dump_printf("Common Clock Service Status\nLocal time : %lld\n", + dump_printf("Common Clock Service Status\nLocal time : %" PRId64 "\n", localTime); if (synced) - dump_printf("Common time : %lld\n", commonTime); + dump_printf("Common time : %" PRId64 "\n", commonTime); else dump_printf("Common time : %s\n", "not synced"); - dump_printf("Timeline ID : %016llx\n", mTimelineID); + dump_printf("Timeline ID : %016" PRIu64 "\n", mTimelineID); dump_printf("State : %s\n", stateToString(mState)); dump_printf("Master Addr : %s\n", maStr); @@ -349,10 +351,10 @@ status_t CommonTimeServer::dumpClockInterface(int fd, int64_t localDelta, usecDelta; localDelta = localTime - mClient_LastGoodSyncRX; usecDelta = mCommonClock.localDurationToCommonDuration(localDelta); - dump_printf("Last Good RX : %lld uSec ago\n", usecDelta); + dump_printf("Last Good RX : %" PRId64 " uSec ago\n", usecDelta); } - dump_printf("Active Clients : %u\n", activeClients); + dump_printf("Active Clients : %zu\n", activeClients); mClient_PacketRTTLog.dumpLog(fd, mCommonClock); mStateChangeLog.dumpLog(fd); mElectionLog.dumpLog(fd); @@ -363,7 +365,7 @@ status_t CommonTimeServer::dumpClockInterface(int fd, } status_t CommonTimeServer::dumpConfigInterface(int fd, - const Vector<String16>& args) { + const Vector<String16>& /* args */) { AutoMutex _lock(&mLock); const size_t SIZE = 256; char buffer[SIZE]; @@ -383,7 +385,7 @@ status_t CommonTimeServer::dumpConfigInterface(int fd, "Bound Interface : %s\n", mBindIfaceValid ? mBindIface.string() : "<unbound>"); dump_printf("Master Election Endpoint : %s\n", meStr); - dump_printf("Master Election Group ID : %016llx\n", mSyncGroupID); + dump_printf("Master Election Group ID : %016" PRIu64 "\n", mSyncGroupID); dump_printf("Master Announce Interval : %d mSec\n", mMasterAnnounceIntervalMs); dump_printf("Client Sync Interval : %d mSec\n", @@ -419,12 +421,12 @@ void CommonTimeServer::PacketRTTLog::dumpLog(int fd, const CommonClock& cclk) { if (rxTimes[i]) { int64_t delta = rxTimes[i] - txTimes[i]; int64_t deltaUsec = cclk.localDurationToCommonDuration(delta); - dump_printf("pkt[%2d] : localTX %12lld localRX %12lld " + dump_printf("pkt[%2d] : localTX %12" PRId64 " localRX %12" PRId64 " " "(%.3f msec RTT)\n", ndx, txTimes[i], rxTimes[i], static_cast<float>(deltaUsec) / 1000.0); } else { - dump_printf("pkt[%2d] : localTX %12lld localRX never\n", + dump_printf("pkt[%2d] : localTX %12" PRId64 " localRX never\n", ndx, txTimes[i]); } i = (i + 1) % RTT_LOG_SIZE; diff --git a/libs/common_time/main.cpp b/libs/common_time/main.cpp index 49eb30a..ac52c85 100644 --- a/libs/common_time/main.cpp +++ b/libs/common_time/main.cpp @@ -27,7 +27,7 @@ #include "common_time_server.h" -int main(int argc, char *argv[]) { +int main() { using namespace android; sp<CommonTimeServer> service = new CommonTimeServer(); diff --git a/libs/hwui/AmbientShadow.cpp b/libs/hwui/AmbientShadow.cpp index b2dba00..5840107 100644 --- a/libs/hwui/AmbientShadow.cpp +++ b/libs/hwui/AmbientShadow.cpp @@ -121,14 +121,14 @@ inline void computeBufferSize(int* totalVertexCount, int* totalIndexCount, *totalUmbraCount = 0; if (!isCasterOpaque) { // Add the centroid if occluder is translucent. - *totalVertexCount++; + (*totalVertexCount)++; *totalIndexCount += 2 * innerVertexCount + 1; *totalUmbraCount = innerVertexCount; } } inline bool needsExtraForEdge(float firstAlpha, float secondAlpha) { - return abs(firstAlpha - secondAlpha) > ALPHA_THRESHOLD; + return fabsf(firstAlpha - secondAlpha) > ALPHA_THRESHOLD; } /** diff --git a/libs/hwui/Android.mk b/libs/hwui/Android.mk index 49560ff..d0b9d82 100644 --- a/libs/hwui/Android.mk +++ b/libs/hwui/Android.mk @@ -1,110 +1,119 @@ LOCAL_PATH:= $(call my-dir) include $(CLEAR_VARS) +LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk + +# Too many unused parameters in external/skia/include and this directory. +# getConfig in external/skia/include/core/SkBitmap.h is deprecated. +# Allow Gnu extension: in-class initializer of static 'const float' member. +LOCAL_CLANG_CFLAGS += \ + -Wno-gnu-static-float-init # Only build libhwui when USE_OPENGL_RENDERER is # defined in the current device/board configuration ifeq ($(USE_OPENGL_RENDERER),true) - LOCAL_SRC_FILES := \ - utils/Blur.cpp \ - utils/GLUtils.cpp \ - utils/SortedListImpl.cpp \ - thread/TaskManager.cpp \ - font/CacheTexture.cpp \ - font/Font.cpp \ - AmbientShadow.cpp \ - AnimationContext.cpp \ - Animator.cpp \ - AnimatorManager.cpp \ - AssetAtlas.cpp \ - DamageAccumulator.cpp \ - FontRenderer.cpp \ - GammaFontRenderer.cpp \ - Caches.cpp \ - DisplayList.cpp \ - DeferredDisplayList.cpp \ - DeferredLayerUpdater.cpp \ - DisplayListLogBuffer.cpp \ - DisplayListRenderer.cpp \ - Dither.cpp \ - DrawProfiler.cpp \ - Extensions.cpp \ - FboCache.cpp \ - GradientCache.cpp \ - Image.cpp \ - Interpolator.cpp \ - Layer.cpp \ - LayerCache.cpp \ - LayerRenderer.cpp \ - Matrix.cpp \ - OpenGLRenderer.cpp \ - Patch.cpp \ - PatchCache.cpp \ - PathCache.cpp \ - PathTessellator.cpp \ - PixelBuffer.cpp \ - Program.cpp \ - ProgramCache.cpp \ - RenderBufferCache.cpp \ - RenderNode.cpp \ - RenderProperties.cpp \ - RenderState.cpp \ - ResourceCache.cpp \ - ShadowTessellator.cpp \ - SkiaShader.cpp \ - Snapshot.cpp \ - SpotShadow.cpp \ - StatefulBaseRenderer.cpp \ - Stencil.cpp \ - TessellationCache.cpp \ - Texture.cpp \ - TextureCache.cpp \ - TextDropShadowCache.cpp + LOCAL_SRC_FILES := \ + utils/Blur.cpp \ + utils/GLUtils.cpp \ + utils/SortedListImpl.cpp \ + thread/TaskManager.cpp \ + font/CacheTexture.cpp \ + font/Font.cpp \ + AmbientShadow.cpp \ + AnimationContext.cpp \ + Animator.cpp \ + AnimatorManager.cpp \ + AssetAtlas.cpp \ + DamageAccumulator.cpp \ + FontRenderer.cpp \ + GammaFontRenderer.cpp \ + Caches.cpp \ + DisplayList.cpp \ + DeferredDisplayList.cpp \ + DeferredLayerUpdater.cpp \ + DisplayListLogBuffer.cpp \ + DisplayListRenderer.cpp \ + Dither.cpp \ + DrawProfiler.cpp \ + Extensions.cpp \ + FboCache.cpp \ + GradientCache.cpp \ + Image.cpp \ + Interpolator.cpp \ + Layer.cpp \ + LayerCache.cpp \ + LayerRenderer.cpp \ + Matrix.cpp \ + OpenGLRenderer.cpp \ + Patch.cpp \ + PatchCache.cpp \ + PathCache.cpp \ + PathTessellator.cpp \ + PixelBuffer.cpp \ + Program.cpp \ + ProgramCache.cpp \ + RenderBufferCache.cpp \ + RenderNode.cpp \ + RenderProperties.cpp \ + RenderState.cpp \ + ResourceCache.cpp \ + ShadowTessellator.cpp \ + SkiaShader.cpp \ + Snapshot.cpp \ + SpotShadow.cpp \ + StatefulBaseRenderer.cpp \ + Stencil.cpp \ + TessellationCache.cpp \ + Texture.cpp \ + TextureCache.cpp \ + TextDropShadowCache.cpp # RenderThread stuff - LOCAL_SRC_FILES += \ - renderthread/CanvasContext.cpp \ - renderthread/DrawFrameTask.cpp \ - renderthread/EglManager.cpp \ - renderthread/RenderProxy.cpp \ - renderthread/RenderTask.cpp \ - renderthread/RenderThread.cpp \ - renderthread/TimeLord.cpp + LOCAL_SRC_FILES += \ + renderthread/CanvasContext.cpp \ + renderthread/DrawFrameTask.cpp \ + renderthread/EglManager.cpp \ + renderthread/RenderProxy.cpp \ + renderthread/RenderTask.cpp \ + renderthread/RenderThread.cpp \ + renderthread/TimeLord.cpp + + intermediates := $(call intermediates-dir-for,STATIC_LIBRARIES,libRS,TARGET,) - intermediates := $(call intermediates-dir-for,STATIC_LIBRARIES,libRS,TARGET,) + LOCAL_C_INCLUDES += \ + external/skia/src/core - LOCAL_C_INCLUDES += \ - external/skia/src/core + LOCAL_CFLAGS += -DUSE_OPENGL_RENDERER -DEGL_EGLEXT_PROTOTYPES -DGL_GLEXT_PROTOTYPES + LOCAL_CFLAGS += -Wno-unused-parameter + LOCAL_MODULE_CLASS := SHARED_LIBRARIES + LOCAL_SHARED_LIBRARIES := liblog libcutils libutils libEGL libGLESv2 libskia libui libgui + LOCAL_MODULE := libhwui + LOCAL_MODULE_TAGS := optional - LOCAL_CFLAGS += -DUSE_OPENGL_RENDERER -DEGL_EGLEXT_PROTOTYPES -DGL_GLEXT_PROTOTYPES - LOCAL_CFLAGS += -Wno-unused-parameter - LOCAL_MODULE_CLASS := SHARED_LIBRARIES - LOCAL_SHARED_LIBRARIES := liblog libcutils libutils libEGL libGLESv2 libskia libui libgui - LOCAL_MODULE := libhwui - LOCAL_MODULE_TAGS := optional + ifneq (false,$(ANDROID_ENABLE_RENDERSCRIPT)) + LOCAL_CFLAGS += -DANDROID_ENABLE_RENDERSCRIPT + LOCAL_SHARED_LIBRARIES += libRS libRScpp + LOCAL_C_INCLUDES += \ + $(intermediates) \ + frameworks/rs/cpp \ + frameworks/rs \ - include external/stlport/libstlport.mk + endif - ifneq (false,$(ANDROID_ENABLE_RENDERSCRIPT)) - LOCAL_CFLAGS += -DANDROID_ENABLE_RENDERSCRIPT - LOCAL_SHARED_LIBRARIES += libRS libRScpp - LOCAL_C_INCLUDES += \ - $(intermediates) \ - frameworks/rs/cpp \ - frameworks/rs - endif + ifndef HWUI_COMPILE_SYMBOLS + LOCAL_CFLAGS += -fvisibility=hidden + endif - ifndef HWUI_COMPILE_SYMBOLS - LOCAL_CFLAGS += -fvisibility=hidden - endif + ifdef HWUI_COMPILE_FOR_PERF + # TODO: Non-arm? + LOCAL_CFLAGS += -fno-omit-frame-pointer -marm -mapcs + endif - ifdef HWUI_COMPILE_FOR_PERF - LOCAL_CFLAGS += -fno-omit-frame-pointer -marm -mapcs - endif + # Defaults for ATRACE_TAG and LOG_TAG for libhwui + LOCAL_CFLAGS += -DATRACE_TAG=ATRACE_TAG_VIEW -DLOG_TAG=\"OpenGLRenderer\" - # Defaults for ATRACE_TAG and LOG_TAG for libhwui - LOCAL_CFLAGS += -DATRACE_TAG=ATRACE_TAG_VIEW -DLOG_TAG=\"OpenGLRenderer\" + LOCAL_CFLAGS += -Wall -Werror -Wunused -Wunreachable-code - include $(BUILD_SHARED_LIBRARY) + include $(BUILD_SHARED_LIBRARY) - include $(call all-makefiles-under,$(LOCAL_PATH)) + include $(call all-makefiles-under,$(LOCAL_PATH)) endif diff --git a/libs/hwui/DeferredDisplayList.cpp b/libs/hwui/DeferredDisplayList.cpp index a998594..6fd0151 100644 --- a/libs/hwui/DeferredDisplayList.cpp +++ b/libs/hwui/DeferredDisplayList.cpp @@ -332,8 +332,8 @@ private: class RestoreToCountBatch : public Batch { public: - RestoreToCountBatch(const StateOp* op, const DeferredDisplayState* state, int restoreCount) : - mOp(op), mState(state), mRestoreCount(restoreCount) {} + RestoreToCountBatch(const StateOp* op, const DeferredDisplayState* state, + int restoreCount) : mState(state), mRestoreCount(restoreCount) {} virtual status_t replay(OpenGLRenderer& renderer, Rect& dirty, int index) { DEFER_LOGD("batch %p restoring to count %d", this, mRestoreCount); @@ -345,7 +345,6 @@ public: private: // we use the state storage for the RestoreToCountOp, but don't replay the op itself - const StateOp* mOp; const DeferredDisplayState* mState; /* @@ -700,7 +699,6 @@ void DeferredDisplayList::discardDrawingBatches(const unsigned int maxIndex) { for (unsigned int i = mEarliestUnclearedIndex; i <= maxIndex; i++) { // leave deferred state ops alone for simplicity (empty save restore pairs may now exist) if (mBatches[i] && mBatches[i]->purelyDrawBatch()) { - DrawBatch* b = (DrawBatch*) mBatches[i]; delete mBatches[i]; mBatches.replaceAt(NULL, i); } diff --git a/libs/hwui/DeferredDisplayList.h b/libs/hwui/DeferredDisplayList.h index 8a015b2..f7f30b1 100644 --- a/libs/hwui/DeferredDisplayList.h +++ b/libs/hwui/DeferredDisplayList.h @@ -79,7 +79,7 @@ public: }; class DeferredDisplayList { - friend class DeferStateStruct; // used to give access to allocator + friend struct DeferStateStruct; // used to give access to allocator public: DeferredDisplayList(const Rect& bounds, bool avoidOverdraw = true) : mBounds(bounds), mAvoidOverdraw(avoidOverdraw) { diff --git a/libs/hwui/DisplayList.h b/libs/hwui/DisplayList.h index 7a43a2a..a9a9148 100644 --- a/libs/hwui/DisplayList.h +++ b/libs/hwui/DisplayList.h @@ -87,8 +87,7 @@ public: } }; -class DeferStateStruct : public PlaybackStateStruct { -public: +struct DeferStateStruct : public PlaybackStateStruct { DeferStateStruct(DeferredDisplayList& deferredList, OpenGLRenderer& renderer, int replayFlags) : PlaybackStateStruct(renderer, replayFlags, &(deferredList.mAllocator)), mDeferredList(deferredList) {} diff --git a/libs/hwui/DisplayListLogBuffer.cpp b/libs/hwui/DisplayListLogBuffer.cpp index 45aacca..bc9e7bd 100644 --- a/libs/hwui/DisplayListLogBuffer.cpp +++ b/libs/hwui/DisplayListLogBuffer.cpp @@ -80,7 +80,7 @@ void DisplayListLogBuffer::outputCommands(FILE *file) fprintf(file, "%*s%s\n", 2 * tmpBufferPtr->level, "", tmpBufferPtr->label); - OpLog* nextOp = tmpBufferPtr++; + tmpBufferPtr++; if (tmpBufferPtr > mBufferLast) { tmpBufferPtr = mBufferFirst; } diff --git a/libs/hwui/DisplayListRenderer.cpp b/libs/hwui/DisplayListRenderer.cpp index c2cb76e..42ac07e 100644 --- a/libs/hwui/DisplayListRenderer.cpp +++ b/libs/hwui/DisplayListRenderer.cpp @@ -178,7 +178,8 @@ bool DisplayListRenderer::clipRegion(const SkRegion* region, SkRegion::Op op) { return StatefulBaseRenderer::clipRegion(region, op); } -status_t DisplayListRenderer::drawRenderNode(RenderNode* renderNode, Rect& dirty, int32_t flags) { +status_t DisplayListRenderer::drawRenderNode(RenderNode* renderNode, Rect& dirty, + int32_t flags) { LOG_ALWAYS_FATAL_IF(!renderNode, "missing rendernode"); // dirty is an out parameter and should not be recorded, diff --git a/libs/hwui/FontRenderer.cpp b/libs/hwui/FontRenderer.cpp index 3910381..5b5b098 100644 --- a/libs/hwui/FontRenderer.cpp +++ b/libs/hwui/FontRenderer.cpp @@ -358,7 +358,7 @@ void FontRenderer::cacheBitmap(const SkGlyph& glyph, CachedGlyphInfo* cachedGlyp break; } case SkMask::kBW_Format: { - uint32_t cacheX = 0, bX = 0, cacheY = 0, bY = 0; + uint32_t cacheX = 0, cacheY = 0; uint32_t row = (startY - TEXTURE_BORDER_SIZE) * cacheWidth + startX - TEXTURE_BORDER_SIZE; static const uint8_t COLORS[2] = { 0, 255 }; diff --git a/libs/hwui/Interpolator.cpp b/libs/hwui/Interpolator.cpp index ff8ff73..0e62d77 100644 --- a/libs/hwui/Interpolator.cpp +++ b/libs/hwui/Interpolator.cpp @@ -14,6 +14,10 @@ * limitations under the License. */ +// LOG_TAG is being provided by the Makefile, reset. +#ifdef LOG_TAG +#undef LOG_TAG +#endif #define LOG_TAG "Interpolator" #include "Interpolator.h" diff --git a/libs/hwui/Layer.h b/libs/hwui/Layer.h index 64d1d12..2d6a727 100644 --- a/libs/hwui/Layer.h +++ b/libs/hwui/Layer.h @@ -47,7 +47,7 @@ class RenderState; class OpenGLRenderer; class RenderNode; class DeferredDisplayList; -class DeferStateStruct; +struct DeferStateStruct; /** * A layer has dimensions and is backed by an OpenGL texture or FBO. diff --git a/libs/hwui/LayerCache.cpp b/libs/hwui/LayerCache.cpp index 3033dc6..3216cd2 100644 --- a/libs/hwui/LayerCache.cpp +++ b/libs/hwui/LayerCache.cpp @@ -80,8 +80,10 @@ int LayerCache::LayerEntry::compare(const LayerCache::LayerEntry& lhs, void LayerCache::deleteLayer(Layer* layer) { if (layer) { - LAYER_LOGD("Destroying layer %dx%d, fbo %d", layer->getWidth(), layer->getHeight(), - layer->getFbo()); + if (kDebugLayers) { + ALOGD("Destroying layer %dx%d, fbo %d", layer->getWidth(), layer->getHeight(), + layer->getFbo()); + } mSize -= layer->getWidth() * layer->getHeight() * 4; layer->state = Layer::kState_DeletedFromCache; layer->decStrong(0); @@ -110,9 +112,13 @@ Layer* LayerCache::get(RenderState& renderState, const uint32_t width, const uin layer->state = Layer::kState_RemovedFromCache; mSize -= layer->getWidth() * layer->getHeight() * 4; - LAYER_LOGD("Reusing layer %dx%d", layer->getWidth(), layer->getHeight()); + if (kDebugLayers) { + ALOGD("Reusing layer %dx%d", layer->getWidth(), layer->getHeight()); + } } else { - LAYER_LOGD("Creating new layer %dx%d", entry.mWidth, entry.mHeight); + if (kDebugLayers) { + ALOGD("Creating new layer %dx%d", entry.mWidth, entry.mHeight); + } layer = new Layer(Layer::kType_DisplayList, renderState, entry.mWidth, entry.mHeight); layer->setBlend(true); @@ -137,7 +143,9 @@ void LayerCache::dump() { size_t size = mCache.size(); for (size_t i = 0; i < size; i++) { const LayerEntry& entry = mCache.itemAt(i); - LAYER_LOGD(" Layer size %dx%d", entry.mWidth, entry.mHeight); + if (kDebugLayers) { + ALOGD(" Layer size %dx%d", entry.mWidth, entry.mHeight); + } } } @@ -157,8 +165,10 @@ bool LayerCache::put(Layer* layer) { deleteLayer(victim); mCache.removeAt(position); - LAYER_LOGD(" Deleting layer %.2fx%.2f", victim->layer.getWidth(), - victim->layer.getHeight()); + if (kDebugLayers) { + ALOGD(" Deleting layer %.2fx%.2f", victim->layer.getWidth(), + victim->layer.getHeight()); + } } layer->cancelDefer(); diff --git a/libs/hwui/LayerCache.h b/libs/hwui/LayerCache.h index 6b93e8f..81810ac 100644 --- a/libs/hwui/LayerCache.h +++ b/libs/hwui/LayerCache.h @@ -26,15 +26,11 @@ namespace uirenderer { class RenderState; -/////////////////////////////////////////////////////////////////////////////// -// Defines -/////////////////////////////////////////////////////////////////////////////// - // Debug #if DEBUG_LAYERS - #define LAYER_LOGD(...) ALOGD(__VA_ARGS__) +static const bool kDebugLayers = true; #else - #define LAYER_LOGD(...) +static const bool kDebugLayers = false; #endif /////////////////////////////////////////////////////////////////////////////// diff --git a/libs/hwui/OpenGLRenderer.cpp b/libs/hwui/OpenGLRenderer.cpp index 6f1e8a2..355a31f 100755 --- a/libs/hwui/OpenGLRenderer.cpp +++ b/libs/hwui/OpenGLRenderer.cpp @@ -402,6 +402,8 @@ void OpenGLRenderer::eventMarkDEBUG(const char* fmt, ...) const { va_end(ap); eventMark(buf); +#else + (void)fmt; #endif } @@ -457,7 +459,6 @@ void OpenGLRenderer::renderOverdraw() { bool OpenGLRenderer::updateLayer(Layer* layer, bool inFrame) { if (layer->deferredUpdateScheduled && layer->renderer && layer->renderNode.get() && layer->renderNode->isRenderable()) { - Rect& dirty = layer->dirtyRect; if (inFrame) { endTiling(); @@ -736,8 +737,10 @@ int OpenGLRenderer::saveLayerDeferred(float left, float top, float right, float */ bool OpenGLRenderer::createLayer(float left, float top, float right, float bottom, const SkPaint* paint, int flags, const SkPath* convexMask) { - LAYER_LOGD("Requesting layer %.2fx%.2f", right - left, bottom - top); - LAYER_LOGD("Layer cache size = %d", mCaches.layerCache.getSize()); + if (kDebugLayers) { + ALOGD("Requesting layer %.2fx%.2f", right - left, bottom - top); + ALOGD("Layer cache size = %d", mCaches.layerCache.getSize()); + } const bool fboLayer = flags & SkCanvas::kClipToLayer_SaveFlag; @@ -915,7 +918,9 @@ void OpenGLRenderer::composeLayer(const Snapshot& removed, const Snapshot& resto // Failing to add the layer to the cache should happen only if the layer is too large layer->setConvexMask(NULL); if (!mCaches.layerCache.put(layer)) { - LAYER_LOGD("Deleting layer"); + if (kDebugLayers) { + ALOGD("Deleting layer"); + } layer->decStrong(0); } } @@ -1931,8 +1936,6 @@ status_t OpenGLRenderer::drawRenderNode(RenderNode* renderNode, Rect& dirty, int } void OpenGLRenderer::drawAlphaBitmap(Texture* texture, float left, float top, const SkPaint* paint) { - int color = paint != NULL ? paint->getColor() : 0; - float x = left; float y = top; @@ -2354,7 +2357,7 @@ status_t OpenGLRenderer::drawVertexBuffer(float translateX, float translateY, setupDrawShaderUniforms(getShader(paint)); const void* vertices = vertexBuffer.getBuffer(); - bool force = mCaches.unbindMeshBuffer(); + mCaches.unbindMeshBuffer(); mCaches.bindPositionVertexPointer(true, vertices, isAA ? gAlphaVertexStride : gVertexStride); mCaches.resetTexCoordsVertexPointer(); @@ -3129,14 +3132,6 @@ status_t OpenGLRenderer::drawRects(const float* rects, int count, const SkPaint* return drawColorRects(rects, count, paint, false, true, true); } -static void mapPointFakeZ(Vector3& point, const mat4& transformXY, const mat4& transformZ) { - // map z coordinate with true 3d matrix - point.z = transformZ.mapZ(point); - - // map x,y coordinates with draw/Skia matrix - transformXY.mapPoint(point.x, point.y); -} - status_t OpenGLRenderer::drawShadow(float casterAlpha, const VertexBuffer* ambientShadowVertexBuffer, const VertexBuffer* spotShadowVertexBuffer) { if (currentSnapshot()->isIgnored()) return DrawGlInfo::kStatusDone; diff --git a/libs/hwui/PathCache.cpp b/libs/hwui/PathCache.cpp index 6f48e4d..80f9c2f 100644 --- a/libs/hwui/PathCache.cpp +++ b/libs/hwui/PathCache.cpp @@ -212,7 +212,7 @@ void PathCache::removeTexture(PathTexture* texture) { // before attempting our cleanup const sp<Task<SkBitmap*> >& task = texture->task(); if (task != NULL) { - SkBitmap* bitmap = task->getResult(); + task->getResult(); texture->clearTask(); } else { // If there is a pending task, the path was not added diff --git a/libs/hwui/PathTessellator.cpp b/libs/hwui/PathTessellator.cpp index 27ef06f..9f7dd50 100644 --- a/libs/hwui/PathTessellator.cpp +++ b/libs/hwui/PathTessellator.cpp @@ -279,7 +279,6 @@ void getStrokeVerticesFromUnclosedVertices(const PaintInfo& paintInfo, - (vertices[lastIndex].x - vertices[lastIndex - 1].x), vertices[lastIndex].y - vertices[lastIndex - 1].y); const float dTheta = PI / (extra + 1); - const float radialScale = 2.0f / (1 + cos(dTheta)); int capOffset; for (int i = 0; i < extra; i++) { @@ -290,14 +289,14 @@ void getStrokeVerticesFromUnclosedVertices(const PaintInfo& paintInfo, } beginTheta += dTheta; - Vector2 beginRadialOffset = {cos(beginTheta), sin(beginTheta)}; + Vector2 beginRadialOffset = {cosf(beginTheta), sinf(beginTheta)}; paintInfo.scaleOffsetForStrokeWidth(beginRadialOffset); Vertex::set(&buffer[capOffset], vertices[0].x + beginRadialOffset.x, vertices[0].y + beginRadialOffset.y); endTheta += dTheta; - Vector2 endRadialOffset = {cos(endTheta), sin(endTheta)}; + Vector2 endRadialOffset = {cosf(endTheta), sinf(endTheta)}; paintInfo.scaleOffsetForStrokeWidth(endRadialOffset); Vertex::set(&buffer[allocSize - 1 - capOffset], vertices[lastIndex].x + endRadialOffset.x, @@ -468,7 +467,7 @@ inline static void storeCapAA(const PaintInfo& paintInfo, const Vector<Vertex>& for (int i = 0; i < extra; i++) { theta += dTheta; - Vector2 radialOffset = {cos(theta), sin(theta)}; + Vector2 radialOffset = {cosf(theta), sinf(theta)}; // scale to compensate for pinching at sharp angles, see totalOffsetFromNormals() radialOffset *= radialScale; @@ -831,7 +830,6 @@ void PathTessellator::tessellatePoints(const float* points, int count, const SkP Rect bounds; // tessellate, then duplicate outline across points - int numPoints = count / 2; VertexBuffer tempBuffer; if (!paintInfo.isAA) { getFillVerticesFromPerimeter(outlineVertices, tempBuffer); diff --git a/libs/hwui/Program.h b/libs/hwui/Program.h index d05b331..fc7d134 100644 --- a/libs/hwui/Program.h +++ b/libs/hwui/Program.h @@ -281,6 +281,8 @@ struct ProgramDescription { programid k = key(); PROGRAM_LOGD("%s (key = 0x%.8x%.8x)", message, uint32_t(k >> 32), uint32_t(k & 0xffffffff)); +#else + (void)message; #endif } diff --git a/libs/hwui/Properties.h b/libs/hwui/Properties.h index befed16..7b9459a 100644 --- a/libs/hwui/Properties.h +++ b/libs/hwui/Properties.h @@ -253,7 +253,7 @@ enum DebugLevel { // Converts a number of kilo-bytes into bytes #define KB(s) s * 1024 -static DebugLevel readDebugLevel() { +static inline DebugLevel readDebugLevel() { char property[PROPERTY_VALUE_MAX]; if (property_get(PROPERTY_DEBUG, property, NULL) > 0) { return (DebugLevel) atoi(property); diff --git a/libs/hwui/RenderNode.cpp b/libs/hwui/RenderNode.cpp index 787ee62..c993556 100644 --- a/libs/hwui/RenderNode.cpp +++ b/libs/hwui/RenderNode.cpp @@ -777,7 +777,6 @@ void RenderNode::issueOperationsOf3dChildren(ChildrenSelectMode mode, int restoreTo = renderer.save(SkCanvas::kMatrix_SaveFlag); DrawRenderNodeOp* childOp = zTranslatedNodes[drawIndex].value; - RenderNode* child = childOp->mRenderNode; renderer.concatMatrix(childOp->mTransformFromParent); childOp->mSkipInOrderDraw = false; // this is horrible, I'm so sorry everyone @@ -926,7 +925,7 @@ void RenderNode::issueOperations(OpenGLRenderer& renderer, T& handler) { initialTransform, zTranslatedNodes, renderer, handler); - for (int opIndex = chunk.beginOpIndex; opIndex < chunk.endOpIndex; opIndex++) { + for (size_t opIndex = chunk.beginOpIndex; opIndex < chunk.endOpIndex; opIndex++) { DisplayListOp *op = mDisplayListData->displayListOps[opIndex]; #if DEBUG_DISPLAY_LIST op->output(level + 1); @@ -934,7 +933,8 @@ void RenderNode::issueOperations(OpenGLRenderer& renderer, T& handler) { logBuffer.writeCommand(level, op->name()); handler(op, saveCountOffset, properties().getClipToBounds()); - if (CC_UNLIKELY(!mProjectedNodes.isEmpty() && opIndex == projectionReceiveIndex)) { + if (CC_UNLIKELY(!mProjectedNodes.isEmpty() && projectionReceiveIndex >= 0 && + opIndex == static_cast<size_t>(projectionReceiveIndex))) { issueOperationsOfProjectedChildren(renderer, handler); } } diff --git a/libs/hwui/ShadowTessellator.cpp b/libs/hwui/ShadowTessellator.cpp index c1ffa0a..93d4b31 100644 --- a/libs/hwui/ShadowTessellator.cpp +++ b/libs/hwui/ShadowTessellator.cpp @@ -87,7 +87,6 @@ void ShadowTessellator::tessellateSpotShadow(bool isCasterOpaque, reverseReceiverTransform.loadInverse(receiverTransform); reverseReceiverTransform.mapPoint3d(adjustedLightCenter); - const int lightVertexCount = 8; if (CC_UNLIKELY(caches.propertyLightDiameter > 0)) { lightRadius = caches.propertyLightDiameter; } diff --git a/libs/hwui/SkiaShader.h b/libs/hwui/SkiaShader.h index 034c3f6..631305f 100644 --- a/libs/hwui/SkiaShader.h +++ b/libs/hwui/SkiaShader.h @@ -62,7 +62,8 @@ public: // This shader is unsupported. Skip it. } static void setupProgram(Caches* caches, const mat4& modelViewMatrix, - GLuint* textureUnit, const Extensions& extensions, const SkShader& shader) { + GLuint* textureUnit, const Extensions& extensions, + const SkShader& shader) { // This shader is unsupported. Skip it. } diff --git a/libs/hwui/SpotShadow.cpp b/libs/hwui/SpotShadow.cpp index b2dd899..3046fd5 100644 --- a/libs/hwui/SpotShadow.cpp +++ b/libs/hwui/SpotShadow.cpp @@ -797,11 +797,15 @@ inline void genNewPenumbraAndPairWithUmbra(const Vector2* penumbra, int penumbra previousPenumbra * weightForPreviousPenumbra; int skippedUmbraIndex = (previousClosestUmbraIndex + k + 1) % umbraLength; - verticesPair[verticesPairIndex++] = {newPenumbraIndex, skippedUmbraIndex}; + verticesPair[verticesPairIndex].outerIndex = newPenumbraIndex; + verticesPair[verticesPairIndex].innerIndex = skippedUmbraIndex; + verticesPairIndex++; newPenumbra[newPenumbraIndex++] = interpolatedPenumbra; } } - verticesPair[verticesPairIndex++] = {newPenumbraIndex, currentClosestUmbraIndex}; + verticesPair[verticesPairIndex].outerIndex = newPenumbraIndex; + verticesPair[verticesPairIndex].innerIndex = currentClosestUmbraIndex; + verticesPairIndex++; newPenumbra[newPenumbraIndex++] = currentPenumbraVertex; previousClosestUmbraIndex = currentClosestUmbraIndex; diff --git a/libs/hwui/StatefulBaseRenderer.h b/libs/hwui/StatefulBaseRenderer.h index 745e48a..fcd6060 100644 --- a/libs/hwui/StatefulBaseRenderer.h +++ b/libs/hwui/StatefulBaseRenderer.h @@ -129,7 +129,8 @@ protected: * * Subclasses can override this method to handle layer restoration */ - virtual void onSnapshotRestored(const Snapshot& removed, const Snapshot& restored) {}; + virtual void onSnapshotRestored(const Snapshot& removed, + const Snapshot& restored) {}; virtual void onViewportInitialized() {}; diff --git a/libs/hwui/TessellationCache.h b/libs/hwui/TessellationCache.h index 688a699..7eca681 100644 --- a/libs/hwui/TessellationCache.h +++ b/libs/hwui/TessellationCache.h @@ -178,7 +178,8 @@ private: // holds a pointer, and implicit strong ref to each shadow task of the frame LruCache<ShadowDescription, Task<vertexBuffer_pair_t*>*> mShadowCache; class BufferPairRemovedListener : public OnEntryRemoved<ShadowDescription, Task<vertexBuffer_pair_t*>*> { - void operator()(ShadowDescription& description, Task<vertexBuffer_pair_t*>*& bufferPairTask) { + void operator()(ShadowDescription& description, + Task<vertexBuffer_pair_t*>*& bufferPairTask) { bufferPairTask->decStrong(NULL); } }; diff --git a/libs/hwui/TextDropShadowCache.cpp b/libs/hwui/TextDropShadowCache.cpp index 4eec462..96c09e6 100644 --- a/libs/hwui/TextDropShadowCache.cpp +++ b/libs/hwui/TextDropShadowCache.cpp @@ -40,7 +40,8 @@ hash_t ShadowText::hash() const { hash = JenkinsHashMix(hash, android::hash_type(italicStyle)); hash = JenkinsHashMix(hash, android::hash_type(scaleX)); if (text) { - hash = JenkinsHashMixShorts(hash, text, charCount); + hash = JenkinsHashMixShorts( + hash, reinterpret_cast<const uint16_t*>(text), charCount); } if (positions) { for (uint32_t i = 0; i < charCount * 2; i++) { diff --git a/libs/hwui/font/Font.cpp b/libs/hwui/font/Font.cpp index af39f16..e1a38dd 100644 --- a/libs/hwui/font/Font.cpp +++ b/libs/hwui/font/Font.cpp @@ -139,7 +139,8 @@ void Font::invalidateTextureCache(CacheTexture* cacheTexture) { } void Font::measureCachedGlyph(CachedGlyphInfo *glyph, int x, int y, - uint8_t* bitmap, uint32_t bitmapW, uint32_t bitmapH, Rect* bounds, const float* pos) { + uint8_t* bitmap, uint32_t bitmapW, uint32_t bitmapH, Rect* bounds, + const float* pos) { int width = (int) glyph->mBitmapWidth; int height = (int) glyph->mBitmapHeight; @@ -161,7 +162,8 @@ void Font::measureCachedGlyph(CachedGlyphInfo *glyph, int x, int y, } void Font::drawCachedGlyph(CachedGlyphInfo* glyph, int x, int y, - uint8_t* bitmap, uint32_t bitmapW, uint32_t bitmapH, Rect* bounds, const float* pos) { + uint8_t* bitmap, uint32_t bitmapW, uint32_t bitmapH, Rect* bounds, + const float* pos) { float width = (float) glyph->mBitmapWidth; float height = (float) glyph->mBitmapHeight; @@ -180,7 +182,8 @@ void Font::drawCachedGlyph(CachedGlyphInfo* glyph, int x, int y, } void Font::drawCachedGlyphTransformed(CachedGlyphInfo* glyph, int x, int y, - uint8_t* bitmap, uint32_t bitmapW, uint32_t bitmapH, Rect* bounds, const float* pos) { + uint8_t* bitmap, uint32_t bitmapW, uint32_t bitmapH, Rect* bounds, + const float* pos) { float width = (float) glyph->mBitmapWidth; float height = (float) glyph->mBitmapHeight; @@ -210,7 +213,8 @@ void Font::drawCachedGlyphTransformed(CachedGlyphInfo* glyph, int x, int y, } void Font::drawCachedGlyphBitmap(CachedGlyphInfo* glyph, int x, int y, uint8_t* bitmap, - uint32_t bitmapWidth, uint32_t bitmapHeight, Rect* bounds, const float* pos) { + uint32_t bitmapWidth, uint32_t bitmapHeight, Rect* bounds, + const float* pos) { int dstX = x + glyph->mBitmapLeft; int dstY = y + glyph->mBitmapTop; @@ -378,7 +382,7 @@ void Font::precache(const SkPaint* paint, const char* text, int numGlyphs) { break; } - CachedGlyphInfo* cachedGlyph = getCachedGlyph(paint, glyph, true); + getCachedGlyph(paint, glyph, true); glyphsCount++; } } @@ -403,8 +407,6 @@ void Font::render(const SkPaint* paint, const char* text, uint32_t start, uint32 text += start; int glyphsCount = 0; - const SkPaint::Align align = paint->getTextAlign(); - while (glyphsCount < numGlyphs) { glyph_t glyph = GET_GLYPH(text); diff --git a/libs/hwui/font/FontUtil.h b/libs/hwui/font/FontUtil.h index c2fd5f5..4e5debe 100644 --- a/libs/hwui/font/FontUtil.h +++ b/libs/hwui/font/FontUtil.h @@ -30,9 +30,12 @@ #define DEFAULT_TEXT_LARGE_CACHE_WIDTH 2048 #define DEFAULT_TEXT_LARGE_CACHE_HEIGHT 512 -#define TEXTURE_BORDER_SIZE 1 -#if TEXTURE_BORDER_SIZE != 1 -# error TEXTURE_BORDER_SIZE other than 1 is not currently supported +#ifdef TEXTURE_BORDER_SIZE + #if TEXTURE_BORDER_SIZE != 1 + #error TEXTURE_BORDER_SIZE other than 1 is not currently supported + #endif +#else + #define TEXTURE_BORDER_SIZE 1 #endif #define CACHE_BLOCK_ROUNDING_SIZE 4 @@ -44,7 +47,7 @@ #define GET_GLYPH(text) nextGlyph((const uint16_t**) &text) #define IS_END_OF_STRING(glyph) false - static glyph_t nextGlyph(const uint16_t** srcPtr) { + static inline glyph_t nextGlyph(const uint16_t** srcPtr) { const uint16_t* src = *srcPtr; glyph_t g = *src++; *srcPtr = src; diff --git a/libs/hwui/renderthread/CanvasContext.cpp b/libs/hwui/renderthread/CanvasContext.cpp index 75bd067..b7e1752 100644 --- a/libs/hwui/renderthread/CanvasContext.cpp +++ b/libs/hwui/renderthread/CanvasContext.cpp @@ -128,8 +128,8 @@ bool CanvasContext::pauseSurface(ANativeWindow* window) { } // TODO: don't pass viewport size, it's automatic via EGL -void CanvasContext::setup(int width, int height, const Vector3& lightCenter, float lightRadius, - uint8_t ambientShadowAlpha, uint8_t spotShadowAlpha) { +void CanvasContext::setup(int width, int height, const Vector3& lightCenter, + float lightRadius, uint8_t ambientShadowAlpha, uint8_t spotShadowAlpha) { if (!mCanvas) return; mCanvas->initLight(lightCenter, lightRadius, ambientShadowAlpha, spotShadowAlpha); } diff --git a/libs/hwui/renderthread/RenderProxy.cpp b/libs/hwui/renderthread/RenderProxy.cpp index 6d063a4..36ba3a9 100644 --- a/libs/hwui/renderthread/RenderProxy.cpp +++ b/libs/hwui/renderthread/RenderProxy.cpp @@ -339,13 +339,19 @@ void RenderProxy::trimMemory(int level) { } } +template <typename T> +void UNUSED(T) {} + + CREATE_BRIDGE0(fence) { // Intentionally empty + UNUSED(args); return NULL; } void RenderProxy::fence() { SETUP_TASK(fence); + UNUSED(args); postAndWait(task); } diff --git a/libs/hwui/renderthread/RenderTask.cpp b/libs/hwui/renderthread/RenderTask.cpp index 7ca61e4..13970ba 100644 --- a/libs/hwui/renderthread/RenderTask.cpp +++ b/libs/hwui/renderthread/RenderTask.cpp @@ -14,6 +14,10 @@ * limitations under the License. */ +// LOG_TAG is being provided by the Makefile, reset. +#ifdef LOG_TAG +#undef LOG_TAG +#endif #define LOG_TAG "RenderTask" #include "RenderTask.h" diff --git a/libs/hwui/tests/main.cpp b/libs/hwui/tests/main.cpp index 2d99e9f..d847d13 100644 --- a/libs/hwui/tests/main.cpp +++ b/libs/hwui/tests/main.cpp @@ -66,7 +66,7 @@ sp<RenderNode> createCard(int x, int y, int width, int height) { return node; } -int main(int argc, char* argv[]) { +int main() { createTestEnvironment(); // create the native surface @@ -111,7 +111,7 @@ int main(int argc, char* argv[]) { for (int i = 0; i < 150; i++) { ATRACE_NAME("UI-Draw Frame"); - for (int ci = 0; ci < cards.size(); ci++) { + for (size_t ci = 0; ci < cards.size(); ci++) { cards[ci]->mutateStagingProperties().setTranslationX(i); cards[ci]->mutateStagingProperties().setTranslationY(i); cards[ci]->setPropertyFieldsDirty(RenderNode::X | RenderNode::Y); diff --git a/libs/input/Android.mk b/libs/input/Android.mk index a7fb0e2..2bbfdcc 100644 --- a/libs/input/Android.mk +++ b/libs/input/Android.mk @@ -27,14 +27,14 @@ LOCAL_SHARED_LIBRARIES := \ libskia \ libgui \ libui \ - libinput \ - libinputflinger + libinput \ + libinputflinger LOCAL_C_INCLUDES := \ frameworks/native/services -LOCAL_CFLAGS += -Wno-unused-parameter +LOCAL_CFLAGS += -Wall -Werror -Wunused -Wunreachable-code LOCAL_MODULE:= libinputservice diff --git a/libs/input/PointerController.cpp b/libs/input/PointerController.cpp index 9af521b..1152737 100644 --- a/libs/input/PointerController.cpp +++ b/libs/input/PointerController.cpp @@ -25,11 +25,14 @@ #include <cutils/log.h> +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" #include <SkBitmap.h> #include <SkCanvas.h> #include <SkColor.h> #include <SkPaint.h> #include <SkXfermode.h> +#pragma GCC diagnostic pop namespace android { diff --git a/libs/input/SpriteController.cpp b/libs/input/SpriteController.cpp index 5391393..0bc832a 100644 --- a/libs/input/SpriteController.cpp +++ b/libs/input/SpriteController.cpp @@ -24,11 +24,15 @@ #include <utils/String8.h> #include <gui/Surface.h> +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" #include <SkBitmap.h> #include <SkCanvas.h> #include <SkColor.h> #include <SkPaint.h> #include <SkXfermode.h> +#pragma GCC diagnostic pop + #include <android/native_window.h> namespace android { diff --git a/libs/storage/Android.mk b/libs/storage/Android.mk index 7a9dd6c..fae2bf7 100644 --- a/libs/storage/Android.mk +++ b/libs/storage/Android.mk @@ -9,4 +9,6 @@ LOCAL_SRC_FILES:= \ LOCAL_MODULE:= libstorage +LOCAL_CFLAGS += -Wall -Werror + include $(BUILD_STATIC_LIBRARY) diff --git a/libs/storage/IMountService.cpp b/libs/storage/IMountService.cpp index 621de18..c643ed0 100644 --- a/libs/storage/IMountService.cpp +++ b/libs/storage/IMountService.cpp @@ -64,7 +64,7 @@ public: { Parcel data, reply; data.writeInterfaceToken(IMountService::getInterfaceDescriptor()); - data.writeStrongBinder(listener->asBinder()); + data.writeStrongBinder(IInterface::asBinder(listener)); if (remote()->transact(TRANSACTION_registerListener, data, &reply) != NO_ERROR) { ALOGD("registerListener could not contact remote\n"); return; @@ -80,7 +80,7 @@ public: { Parcel data, reply; data.writeInterfaceToken(IMountService::getInterfaceDescriptor()); - data.writeStrongBinder(listener->asBinder()); + data.writeStrongBinder(IInterface::asBinder(listener)); if (remote()->transact(TRANSACTION_unregisterListener, data, &reply) != NO_ERROR) { ALOGD("unregisterListener could not contact remote\n"); return; @@ -207,12 +207,19 @@ public: ALOGD("getStorageUsers caught exception %d\n", err); return err; } - const int32_t numUsers = reply.readInt32(); + int32_t numUsersI = reply.readInt32(); + uint32_t numUsers; + if (numUsersI < 0) { + ALOGW("Number of users is negative: %d\n", numUsersI); + numUsers = 0; + } else { + numUsers = static_cast<uint32_t>(numUsersI); + } *users = (int32_t*)malloc(sizeof(int32_t)*numUsers); - for (int i = 0; i < numUsers; i++) { + for (size_t i = 0; i < numUsers; i++) { **users++ = reply.readInt32(); } - return numUsers; + return static_cast<int32_t>(numUsers); } int32_t getVolumeState(const String16& mountPoint) @@ -406,7 +413,7 @@ public: { Parcel data, reply; data.writeInterfaceToken(IMountService::getInterfaceDescriptor()); - data.writeStrongBinder(observer->asBinder()); + data.writeStrongBinder(IInterface::asBinder(observer)); if (remote()->transact(TRANSACTION_shutdown, data, &reply) != NO_ERROR) { ALOGD("shutdown could not contact remote\n"); return; @@ -443,7 +450,7 @@ public: data.writeString16(rawPath); data.writeString16(canonicalPath); data.writeString16(key); - data.writeStrongBinder(token->asBinder()); + data.writeStrongBinder(IInterface::asBinder(token)); data.writeInt32(nonce); if (remote()->transact(TRANSACTION_mountObb, data, &reply) != NO_ERROR) { ALOGD("mountObb could not contact remote\n"); @@ -463,7 +470,7 @@ public: data.writeInterfaceToken(IMountService::getInterfaceDescriptor()); data.writeString16(filename); data.writeInt32(force ? 1 : 0); - data.writeStrongBinder(token->asBinder()); + data.writeStrongBinder(IInterface::asBinder(token)); data.writeInt32(nonce); if (remote()->transact(TRANSACTION_unmountObb, data, &reply) != NO_ERROR) { ALOGD("unmountObb could not contact remote\n"); @@ -546,8 +553,8 @@ public: } }; -IMPLEMENT_META_INTERFACE(MountService, "IMountService"); +IMPLEMENT_META_INTERFACE(MountService, "IMountService") // ---------------------------------------------------------------------- -}; +} diff --git a/libs/storage/IMountServiceListener.cpp b/libs/storage/IMountServiceListener.cpp index c98a424..11b53fd 100644 --- a/libs/storage/IMountServiceListener.cpp +++ b/libs/storage/IMountServiceListener.cpp @@ -34,7 +34,7 @@ status_t BnMountServiceListener::onTransact( onUsbMassStorageConnectionChanged(connected); reply->writeNoException(); return NO_ERROR; - } break; + } case TRANSACTION_onStorageStateChanged: { CHECK_INTERFACE(IMountServiceListener, data, reply); String16 path = data.readString16(); @@ -50,4 +50,4 @@ status_t BnMountServiceListener::onTransact( } // ---------------------------------------------------------------------- -}; +} diff --git a/libs/storage/IMountShutdownObserver.cpp b/libs/storage/IMountShutdownObserver.cpp index 1a6fdee..a74a768 100644 --- a/libs/storage/IMountShutdownObserver.cpp +++ b/libs/storage/IMountShutdownObserver.cpp @@ -33,11 +33,11 @@ status_t BnMountShutdownObserver::onTransact( onShutDownComplete(statusCode); reply->writeNoException(); return NO_ERROR; - } break; + } default: return BBinder::onTransact(code, data, reply, flags); } } // ---------------------------------------------------------------------- -}; +} diff --git a/libs/storage/IObbActionListener.cpp b/libs/storage/IObbActionListener.cpp index eaa211e..9656e65 100644 --- a/libs/storage/IObbActionListener.cpp +++ b/libs/storage/IObbActionListener.cpp @@ -30,10 +30,11 @@ public: : BpInterface<IObbActionListener>(impl) { } - virtual void onObbResult(const String16& filename, const int32_t nonce, const int32_t state) { } + virtual void onObbResult(const String16& /* filename */, const int32_t /* nonce */, + const int32_t /* state */) { } }; -IMPLEMENT_META_INTERFACE(ObbActionListener, "IObbActionListener"); +IMPLEMENT_META_INTERFACE(ObbActionListener, "IObbActionListener") // ---------------------------------------------------------------------- @@ -49,7 +50,7 @@ status_t BnObbActionListener::onTransact( onObbResult(filename, nonce, state); reply->writeNoException(); return NO_ERROR; - } break; + } default: return BBinder::onTransact(code, data, reply, flags); } @@ -57,4 +58,4 @@ status_t BnObbActionListener::onTransact( // ---------------------------------------------------------------------- -}; +} diff --git a/libs/usb/tests/AccessoryChat/accessorychat/Android.mk b/libs/usb/tests/AccessoryChat/accessorychat/Android.mk index 3e07155..51f2111 100644 --- a/libs/usb/tests/AccessoryChat/accessorychat/Android.mk +++ b/libs/usb/tests/AccessoryChat/accessorychat/Android.mk @@ -4,6 +4,7 @@ LOCAL_PATH:= $(call my-dir) ifeq ($(HOST_OS),linux) include $(CLEAR_VARS) +LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk LOCAL_MODULE_TAGS := optional @@ -21,6 +22,7 @@ endif # Build for device include $(CLEAR_VARS) +LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk LOCAL_MODULE_TAGS := optional |