diff options
Diffstat (limited to 'tools')
| -rw-r--r-- | tools/aapt/Android.mk | 47 | ||||
| -rw-r--r-- | tools/aapt/Package.cpp | 3 | ||||
| -rw-r--r-- | tools/aapt/Resource.cpp | 53 | ||||
| -rw-r--r-- | tools/aapt/StringPool.cpp | 2 | ||||
| -rw-r--r-- | tools/aapt/StringPool.h | 1 | ||||
| -rw-r--r-- | tools/aapt/WorkQueue.cpp | 171 | ||||
| -rw-r--r-- | tools/aapt/WorkQueue.h | 119 | ||||
| -rw-r--r-- | tools/aapt/XMLNode.cpp | 2 | ||||
| -rw-r--r-- | tools/aapt/ZipFile.cpp | 2 | ||||
| -rw-r--r-- | tools/aapt/pseudolocalize.cpp | 119 | ||||
| -rw-r--r-- | tools/aapt/pseudolocalize.h | 9 | ||||
| -rw-r--r-- | tools/aapt/qsort_r_compat.c | 90 | ||||
| -rw-r--r-- | tools/aapt/qsort_r_compat.h | 39 | ||||
| -rw-r--r-- | tools/layoutlib/bridge/src/android/view/IWindowManagerImpl.java | 33 | ||||
| -rw-r--r-- | tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgePowerManager.java | 2 | ||||
| -rw-r--r-- | tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/RenderSessionImpl.java | 3 | ||||
| -rw-r--r-- | tools/obbtool/Android.mk | 2 |
17 files changed, 653 insertions, 44 deletions
diff --git a/tools/aapt/Android.mk b/tools/aapt/Android.mk index 9b1658ac6de9..61180a0e634f 100644 --- a/tools/aapt/Android.mk +++ b/tools/aapt/Android.mk @@ -7,10 +7,8 @@ # This tool is prebuilt if we're doing an app-only build. ifeq ($(TARGET_BUILD_APPS),) -LOCAL_PATH:= $(call my-dir) -include $(CLEAR_VARS) -LOCAL_SRC_FILES := \ +aapt_src_files := \ AaptAssets.cpp \ Command.cpp \ CrunchCache.cpp \ @@ -24,23 +22,29 @@ LOCAL_SRC_FILES := \ ResourceTable.cpp \ Images.cpp \ Resource.cpp \ + pseudolocalize.cpp \ SourcePos.cpp \ + WorkQueue.cpp \ ZipEntry.cpp \ - ZipFile.cpp + ZipFile.cpp \ + qsort_r_compat.c + +LOCAL_PATH:= $(call my-dir) +include $(CLEAR_VARS) +LOCAL_SRC_FILES := $(aapt_src_files) LOCAL_CFLAGS += -Wno-format-y2k ifeq (darwin,$(HOST_OS)) LOCAL_CFLAGS += -D_DARWIN_UNLIMITED_STREAMS endif +LOCAL_CFLAGS += -DSTATIC_ANDROIDFW_FOR_TOOLS LOCAL_C_INCLUDES += external/libpng LOCAL_C_INCLUDES += external/zlib -LOCAL_C_INCLUDES += build/libs/host/include LOCAL_STATIC_LIBRARIES := \ - libhost \ libandroidfw \ libutils \ libcutils \ @@ -64,4 +68,35 @@ LOCAL_MODULE := aapt include $(BUILD_HOST_EXECUTABLE) +# aapt for running on the device +# ========================================================= +ifneq ($(SDK_ONLY),true) +include $(CLEAR_VARS) + +LOCAL_SRC_FILES := $(aapt_src_files) + +LOCAL_MODULE := aapt + +LOCAL_C_INCLUDES += bionic +LOCAL_C_INCLUDES += bionic/libstdc++/include +LOCAL_C_INCLUDES += external/stlport/stlport +LOCAL_C_INCLUDES += external/libpng +LOCAL_C_INCLUDES += external/zlib + +LOCAL_CFLAGS += -DSTATIC_ANDROIDFW_FOR_TOOLS +LOCAL_CFLAGS += -Wno-non-virtual-dtor + +LOCAL_STATIC_LIBRARIES := \ + libstlport_static \ + libandroidfw \ + libutils \ + libcutils \ + libexpat_static \ + libpng \ + liblog \ + libz + +include $(BUILD_EXECUTABLE) +endif + endif # TARGET_BUILD_APPS diff --git a/tools/aapt/Package.cpp b/tools/aapt/Package.cpp index 3930117b67a2..872d95c509f7 100644 --- a/tools/aapt/Package.cpp +++ b/tools/aapt/Package.cpp @@ -8,10 +8,13 @@ #include "ResourceTable.h" #include "ResourceFilter.h" +#include <androidfw/misc.h> + #include <utils/Log.h> #include <utils/threads.h> #include <utils/List.h> #include <utils/Errors.h> +#include <utils/misc.h> #include <sys/types.h> #include <dirent.h> diff --git a/tools/aapt/Resource.cpp b/tools/aapt/Resource.cpp index 6168bbdc0655..d61792828d7c 100644 --- a/tools/aapt/Resource.cpp +++ b/tools/aapt/Resource.cpp @@ -14,7 +14,7 @@ #include "FileFinder.h" #include "CacheUpdater.h" -#include <utils/WorkQueue.h> +#include "WorkQueue.h" #if HAVE_PRINTF_ZD # define ZD "%zd" @@ -172,6 +172,7 @@ private: bool isValidResourceType(const String8& type) { return type == "anim" || type == "animator" || type == "interpolator" + || type == "transition" || type == "scene" || type == "drawable" || type == "layout" || type == "values" || type == "xml" || type == "raw" || type == "color" || type == "menu" || type == "mipmap"; @@ -932,6 +933,8 @@ status_t buildResources(Bundle* bundle, const sp<AaptAssets>& assets) sp<ResourceTypeSet> anims; sp<ResourceTypeSet> animators; sp<ResourceTypeSet> interpolators; + sp<ResourceTypeSet> transitions; + sp<ResourceTypeSet> scenes; sp<ResourceTypeSet> xmls; sp<ResourceTypeSet> raws; sp<ResourceTypeSet> colors; @@ -943,6 +946,8 @@ status_t buildResources(Bundle* bundle, const sp<AaptAssets>& assets) ASSIGN_IT(anim); ASSIGN_IT(animator); ASSIGN_IT(interpolator); + ASSIGN_IT(transition); + ASSIGN_IT(scene); ASSIGN_IT(xml); ASSIGN_IT(raw); ASSIGN_IT(color); @@ -965,6 +970,8 @@ status_t buildResources(Bundle* bundle, const sp<AaptAssets>& assets) !applyFileOverlay(bundle, assets, &anims, "anim") || !applyFileOverlay(bundle, assets, &animators, "animator") || !applyFileOverlay(bundle, assets, &interpolators, "interpolator") || + !applyFileOverlay(bundle, assets, &transitions, "transition") || + !applyFileOverlay(bundle, assets, &scenes, "scene") || !applyFileOverlay(bundle, assets, &xmls, "xml") || !applyFileOverlay(bundle, assets, &raws, "raw") || !applyFileOverlay(bundle, assets, &colors, "color") || @@ -1024,6 +1031,20 @@ status_t buildResources(Bundle* bundle, const sp<AaptAssets>& assets) } } + if (transitions != NULL) { + err = makeFileResources(bundle, assets, &table, transitions, "transition"); + if (err != NO_ERROR) { + hasErrors = true; + } + } + + if (scenes != NULL) { + err = makeFileResources(bundle, assets, &table, scenes, "scene"); + if (err != NO_ERROR) { + hasErrors = true; + } + } + if (interpolators != NULL) { err = makeFileResources(bundle, assets, &table, interpolators, "interpolator"); if (err != NO_ERROR) { @@ -1168,6 +1189,36 @@ status_t buildResources(Bundle* bundle, const sp<AaptAssets>& assets) err = NO_ERROR; } + if (transitions != NULL) { + ResourceDirIterator it(transitions, String8("transition")); + while ((err=it.next()) == NO_ERROR) { + err = compileXmlFile(assets, it.getFile(), &table, xmlFlags); + if (err != NO_ERROR) { + hasErrors = true; + } + } + + if (err < NO_ERROR) { + hasErrors = true; + } + err = NO_ERROR; + } + + if (scenes != NULL) { + ResourceDirIterator it(scenes, String8("scene")); + while ((err=it.next()) == NO_ERROR) { + err = compileXmlFile(assets, it.getFile(), &table, xmlFlags); + if (err != NO_ERROR) { + hasErrors = true; + } + } + + if (err < NO_ERROR) { + hasErrors = true; + } + err = NO_ERROR; + } + if (xmls != NULL) { ResourceDirIterator it(xmls, String8("xml")); while ((err=it.next()) == NO_ERROR) { diff --git a/tools/aapt/StringPool.cpp b/tools/aapt/StringPool.cpp index 839eda5151b0..158b39196cb3 100644 --- a/tools/aapt/StringPool.cpp +++ b/tools/aapt/StringPool.cpp @@ -9,7 +9,7 @@ #include <utils/ByteOrder.h> #include <utils/SortedVector.h> -#include <cutils/qsort_r_compat.h> +#include "qsort_r_compat.h" #if HAVE_PRINTF_ZD # define ZD "%zd" diff --git a/tools/aapt/StringPool.h b/tools/aapt/StringPool.h index 16050b2711c3..1b3abfd9b4c6 100644 --- a/tools/aapt/StringPool.h +++ b/tools/aapt/StringPool.h @@ -12,7 +12,6 @@ #include <androidfw/ResourceTypes.h> #include <utils/String16.h> -#include <utils/TextOutput.h> #include <utils/TypeHelpers.h> #include <sys/types.h> diff --git a/tools/aapt/WorkQueue.cpp b/tools/aapt/WorkQueue.cpp new file mode 100644 index 000000000000..24a962fcfdb6 --- /dev/null +++ b/tools/aapt/WorkQueue.cpp @@ -0,0 +1,171 @@ +/* + * Copyright (C) 2012 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// #define LOG_NDEBUG 0 +#define LOG_TAG "WorkQueue" + +#include <utils/Log.h> +#include "WorkQueue.h" + +namespace android { + +// --- WorkQueue --- + +WorkQueue::WorkQueue(size_t maxThreads, bool canCallJava) : + mMaxThreads(maxThreads), mCanCallJava(canCallJava), + mCanceled(false), mFinished(false), mIdleThreads(0) { +} + +WorkQueue::~WorkQueue() { + if (!cancel()) { + finish(); + } +} + +status_t WorkQueue::schedule(WorkUnit* workUnit, size_t backlog) { + AutoMutex _l(mLock); + + if (mFinished || mCanceled) { + return INVALID_OPERATION; + } + + if (mWorkThreads.size() < mMaxThreads + && mIdleThreads < mWorkUnits.size() + 1) { + sp<WorkThread> workThread = new WorkThread(this, mCanCallJava); + status_t status = workThread->run("WorkQueue::WorkThread"); + if (status) { + return status; + } + mWorkThreads.add(workThread); + mIdleThreads += 1; + } else if (backlog) { + while (mWorkUnits.size() >= mMaxThreads * backlog) { + mWorkDequeuedCondition.wait(mLock); + if (mFinished || mCanceled) { + return INVALID_OPERATION; + } + } + } + + mWorkUnits.add(workUnit); + mWorkChangedCondition.broadcast(); + return OK; +} + +status_t WorkQueue::cancel() { + AutoMutex _l(mLock); + + return cancelLocked(); +} + +status_t WorkQueue::cancelLocked() { + if (mFinished) { + return INVALID_OPERATION; + } + + if (!mCanceled) { + mCanceled = true; + + size_t count = mWorkUnits.size(); + for (size_t i = 0; i < count; i++) { + delete mWorkUnits.itemAt(i); + } + mWorkUnits.clear(); + mWorkChangedCondition.broadcast(); + mWorkDequeuedCondition.broadcast(); + } + return OK; +} + +status_t WorkQueue::finish() { + { // acquire lock + AutoMutex _l(mLock); + + if (mFinished) { + return INVALID_OPERATION; + } + + mFinished = true; + mWorkChangedCondition.broadcast(); + } // release lock + + // It is not possible for the list of work threads to change once the mFinished + // flag has been set, so we can access mWorkThreads outside of the lock here. + size_t count = mWorkThreads.size(); + for (size_t i = 0; i < count; i++) { + mWorkThreads.itemAt(i)->join(); + } + mWorkThreads.clear(); + return OK; +} + +bool WorkQueue::threadLoop() { + WorkUnit* workUnit; + { // acquire lock + AutoMutex _l(mLock); + + for (;;) { + if (mCanceled) { + return false; + } + + if (!mWorkUnits.isEmpty()) { + workUnit = mWorkUnits.itemAt(0); + mWorkUnits.removeAt(0); + mIdleThreads -= 1; + mWorkDequeuedCondition.broadcast(); + break; + } + + if (mFinished) { + return false; + } + + mWorkChangedCondition.wait(mLock); + } + } // release lock + + bool shouldContinue = workUnit->run(); + delete workUnit; + + { // acquire lock + AutoMutex _l(mLock); + + mIdleThreads += 1; + + if (!shouldContinue) { + cancelLocked(); + return false; + } + } // release lock + + return true; +} + +// --- WorkQueue::WorkThread --- + +WorkQueue::WorkThread::WorkThread(WorkQueue* workQueue, bool canCallJava) : + Thread(canCallJava), mWorkQueue(workQueue) { +} + +WorkQueue::WorkThread::~WorkThread() { +} + +bool WorkQueue::WorkThread::threadLoop() { + return mWorkQueue->threadLoop(); +} + +}; // namespace android diff --git a/tools/aapt/WorkQueue.h b/tools/aapt/WorkQueue.h new file mode 100644 index 000000000000..d38f05d034e9 --- /dev/null +++ b/tools/aapt/WorkQueue.h @@ -0,0 +1,119 @@ +/*] + * Copyright (C) 2012 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef AAPT_WORK_QUEUE_H +#define AAPT_WORK_QUEUE_H + +#include <utils/Errors.h> +#include <utils/Vector.h> +#include <utils/threads.h> + +namespace android { + +/* + * A threaded work queue. + * + * This class is designed to make it easy to run a bunch of isolated work + * units in parallel, using up to the specified number of threads. + * To use it, write a loop to post work units to the work queue, then synchronize + * on the queue at the end. + */ +class WorkQueue { +public: + class WorkUnit { + public: + WorkUnit() { } + virtual ~WorkUnit() { } + + /* + * Runs the work unit. + * If the result is 'true' then the work queue continues scheduling work as usual. + * If the result is 'false' then the work queue is canceled. + */ + virtual bool run() = 0; + }; + + /* Creates a work queue with the specified maximum number of work threads. */ + WorkQueue(size_t maxThreads, bool canCallJava = true); + + /* Destroys the work queue. + * Cancels pending work and waits for all remaining threads to complete. + */ + ~WorkQueue(); + + /* Posts a work unit to run later. + * If the work queue has been canceled or is already finished, returns INVALID_OPERATION + * and does not take ownership of the work unit (caller must destroy it itself). + * Otherwise, returns OK and takes ownership of the work unit (the work queue will + * destroy it automatically). + * + * For flow control, this method blocks when the size of the pending work queue is more + * 'backlog' times the number of threads. This condition reduces the rate of entry into + * the pending work queue and prevents it from growing much more rapidly than the + * work threads can actually handle. + * + * If 'backlog' is 0, then no throttle is applied. + */ + status_t schedule(WorkUnit* workUnit, size_t backlog = 2); + + /* Cancels all pending work. + * If the work queue is already finished, returns INVALID_OPERATION. + * If the work queue is already canceled, returns OK and does nothing else. + * Otherwise, returns OK, discards all pending work units and prevents additional + * work units from being scheduled. + * + * Call finish() after cancel() to wait for all remaining work to complete. + */ + status_t cancel(); + + /* Waits for all work to complete. + * If the work queue is already finished, returns INVALID_OPERATION. + * Otherwise, waits for all work to complete and returns OK. + */ + status_t finish(); + +private: + class WorkThread : public Thread { + public: + WorkThread(WorkQueue* workQueue, bool canCallJava); + virtual ~WorkThread(); + + private: + virtual bool threadLoop(); + + WorkQueue* const mWorkQueue; + }; + + status_t cancelLocked(); + bool threadLoop(); // called from each work thread + + const size_t mMaxThreads; + const bool mCanCallJava; + + Mutex mLock; + Condition mWorkChangedCondition; + Condition mWorkDequeuedCondition; + + bool mCanceled; + bool mFinished; + size_t mIdleThreads; + Vector<sp<WorkThread> > mWorkThreads; + Vector<WorkUnit*> mWorkUnits; +}; + +}; // namespace android + +#endif // AAPT_WORK_QUEUE_H diff --git a/tools/aapt/XMLNode.cpp b/tools/aapt/XMLNode.cpp index dcbe7db7c54c..a663ad58fc55 100644 --- a/tools/aapt/XMLNode.cpp +++ b/tools/aapt/XMLNode.cpp @@ -6,8 +6,8 @@ #include "XMLNode.h" #include "ResourceTable.h" +#include "pseudolocalize.h" -#include <host/pseudolocalize.h> #include <utils/ByteOrder.h> #include <errno.h> #include <string.h> diff --git a/tools/aapt/ZipFile.cpp b/tools/aapt/ZipFile.cpp index 3994c3190a74..8057068dd685 100644 --- a/tools/aapt/ZipFile.cpp +++ b/tools/aapt/ZipFile.cpp @@ -20,8 +20,8 @@ #define LOG_TAG "zip" +#include <androidfw/ZipUtils.h> #include <utils/Log.h> -#include <utils/ZipUtils.h> #include "ZipFile.h" diff --git a/tools/aapt/pseudolocalize.cpp b/tools/aapt/pseudolocalize.cpp new file mode 100644 index 000000000000..9e50c5ac5eb1 --- /dev/null +++ b/tools/aapt/pseudolocalize.cpp @@ -0,0 +1,119 @@ +#include "pseudolocalize.h" + +using namespace std; + +static const char* +pseudolocalize_char(char c) +{ + switch (c) { + case 'a': return "\xc4\x83"; + case 'b': return "\xcf\x84"; + case 'c': return "\xc4\x8b"; + case 'd': return "\xc4\x8f"; + case 'e': return "\xc4\x99"; + case 'f': return "\xc6\x92"; + case 'g': return "\xc4\x9d"; + case 'h': return "\xd1\x9b"; + case 'i': return "\xcf\x8a"; + case 'j': return "\xc4\xb5"; + case 'k': return "\xc4\xb8"; + case 'l': return "\xc4\xba"; + case 'm': return "\xe1\xb8\xbf"; + case 'n': return "\xd0\xb8"; + case 'o': return "\xcf\x8c"; + case 'p': return "\xcf\x81"; + case 'q': return "\x51"; + case 'r': return "\xd2\x91"; + case 's': return "\xc5\xa1"; + case 't': return "\xd1\x82"; + case 'u': return "\xce\xb0"; + case 'v': return "\x56"; + case 'w': return "\xe1\xba\x85"; + case 'x': return "\xd1\x85"; + case 'y': return "\xe1\xbb\xb3"; + case 'z': return "\xc5\xba"; + case 'A': return "\xc3\x85"; + case 'B': return "\xce\xb2"; + case 'C': return "\xc4\x88"; + case 'D': return "\xc4\x90"; + case 'E': return "\xd0\x84"; + case 'F': return "\xce\x93"; + case 'G': return "\xc4\x9e"; + case 'H': return "\xc4\xa6"; + case 'I': return "\xd0\x87"; + case 'J': return "\xc4\xb5"; + case 'K': return "\xc4\xb6"; + case 'L': return "\xc5\x81"; + case 'M': return "\xe1\xb8\xbe"; + case 'N': return "\xc5\x83"; + case 'O': return "\xce\x98"; + case 'P': return "\xcf\x81"; + case 'Q': return "\x71"; + case 'R': return "\xd0\xaf"; + case 'S': return "\xc8\x98"; + case 'T': return "\xc5\xa6"; + case 'U': return "\xc5\xa8"; + case 'V': return "\xce\xbd"; + case 'W': return "\xe1\xba\x84"; + case 'X': return "\xc3\x97"; + case 'Y': return "\xc2\xa5"; + case 'Z': return "\xc5\xbd"; + default: return NULL; + } +} + +/** + * Converts characters so they look like they've been localized. + * + * Note: This leaves escape sequences untouched so they can later be + * processed by ResTable::collectString in the normal way. + */ +string +pseudolocalize_string(const string& source) +{ + const char* s = source.c_str(); + string result; + const size_t I = source.length(); + for (size_t i=0; i<I; i++) { + char c = s[i]; + if (c == '\\') { + if (i<I-1) { + result += '\\'; + i++; + c = s[i]; + switch (c) { + case 'u': + // this one takes up 5 chars + result += string(s+i, 5); + i += 4; + break; + case 't': + case 'n': + case '#': + case '@': + case '?': + case '"': + case '\'': + case '\\': + default: + result += c; + break; + } + } else { + result += c; + } + } else { + const char* p = pseudolocalize_char(c); + if (p != NULL) { + result += p; + } else { + result += c; + } + } + } + + //printf("result=\'%s\'\n", result.c_str()); + return result; +} + + diff --git a/tools/aapt/pseudolocalize.h b/tools/aapt/pseudolocalize.h new file mode 100644 index 000000000000..94cb034ac5ea --- /dev/null +++ b/tools/aapt/pseudolocalize.h @@ -0,0 +1,9 @@ +#ifndef HOST_PSEUDOLOCALIZE_H +#define HOST_PSEUDOLOCALIZE_H + +#include <string> + +std::string pseudolocalize_string(const std::string& source); + +#endif // HOST_PSEUDOLOCALIZE_H + diff --git a/tools/aapt/qsort_r_compat.c b/tools/aapt/qsort_r_compat.c new file mode 100644 index 000000000000..2a8dbe85f4c9 --- /dev/null +++ b/tools/aapt/qsort_r_compat.c @@ -0,0 +1,90 @@ +/* + * Copyright (C) 2012 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include <stdlib.h> +#include "qsort_r_compat.h" + +/* + * Note: This code is only used on the host, and is primarily here for + * Mac OS compatibility. Apparently, glibc and Apple's libc disagree on + * the parameter order for qsort_r. + */ + +#if HAVE_BSD_QSORT_R + +/* + * BSD qsort_r parameter order is as we have defined here. + */ + +void qsort_r_compat(void* base, size_t nel, size_t width, void* thunk, + int (*compar)(void*, const void* , const void*)) { + qsort_r(base, nel, width, thunk, compar); +} + +#elif HAVE_GNU_QSORT_R + +/* + * GNU qsort_r parameter order places the thunk parameter last. + */ + +struct compar_data { + void* thunk; + int (*compar)(void*, const void* , const void*); +}; + +static int compar_wrapper(const void* a, const void* b, void* data) { + struct compar_data* compar_data = (struct compar_data*)data; + return compar_data->compar(compar_data->thunk, a, b); +} + +void qsort_r_compat(void* base, size_t nel, size_t width, void* thunk, + int (*compar)(void*, const void* , const void*)) { + struct compar_data compar_data; + compar_data.thunk = thunk; + compar_data.compar = compar; + qsort_r(base, nel, width, compar_wrapper, &compar_data); +} + +#else + +/* + * Emulate qsort_r using thread local storage to access the thunk data. + */ + +#include <cutils/threads.h> + +static thread_store_t compar_data_key = THREAD_STORE_INITIALIZER; + +struct compar_data { + void* thunk; + int (*compar)(void*, const void* , const void*); +}; + +static int compar_wrapper(const void* a, const void* b) { + struct compar_data* compar_data = (struct compar_data*)thread_store_get(&compar_data_key); + return compar_data->compar(compar_data->thunk, a, b); +} + +void qsort_r_compat(void* base, size_t nel, size_t width, void* thunk, + int (*compar)(void*, const void* , const void*)) { + struct compar_data compar_data; + compar_data.thunk = thunk; + compar_data.compar = compar; + thread_store_set(&compar_data_key, &compar_data, NULL); + qsort(base, nel, width, compar_wrapper); +} + +#endif diff --git a/tools/aapt/qsort_r_compat.h b/tools/aapt/qsort_r_compat.h new file mode 100644 index 000000000000..e14f999f736a --- /dev/null +++ b/tools/aapt/qsort_r_compat.h @@ -0,0 +1,39 @@ +/* + * Copyright (C) 2012 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * Provides a portable version of qsort_r, called qsort_r_compat, which is a + * reentrant variant of qsort that passes a user data pointer to its comparator. + * This implementation follows the BSD parameter convention. + */ + +#ifndef ___QSORT_R_COMPAT_H +#define ___QSORT_R_COMPAT_H + +#include <stdlib.h> + +#ifdef __cplusplus +extern "C" { +#endif + +void qsort_r_compat(void* base, size_t nel, size_t width, void* thunk, + int (*compar)(void*, const void* , const void* )); + +#ifdef __cplusplus +} +#endif + +#endif // ___QSORT_R_COMPAT_H diff --git a/tools/layoutlib/bridge/src/android/view/IWindowManagerImpl.java b/tools/layoutlib/bridge/src/android/view/IWindowManagerImpl.java index 434b13132451..6343049cb89b 100644 --- a/tools/layoutlib/bridge/src/android/view/IWindowManagerImpl.java +++ b/tools/layoutlib/bridge/src/android/view/IWindowManagerImpl.java @@ -49,15 +49,13 @@ public class IWindowManagerImpl implements IWindowManager { private final Configuration mConfig; private final DisplayMetrics mMetrics; private final int mRotation; - private final boolean mHasSystemNavBar; private final boolean mHasNavigationBar; public IWindowManagerImpl(Configuration config, DisplayMetrics metrics, int rotation, - boolean hasSystemNavBar, boolean hasNavigationBar) { + boolean hasNavigationBar) { mConfig = config; mMetrics = metrics; mRotation = rotation; - mHasSystemNavBar = hasSystemNavBar; mHasNavigationBar = hasNavigationBar; } @@ -79,16 +77,11 @@ public class IWindowManagerImpl implements IWindowManager { return mHasNavigationBar; } - @Override - public boolean hasSystemNavBar() throws RemoteException { - return mHasSystemNavBar; - } - // ---- unused implementation of IWindowManager ---- @Override - public void addAppToken(int arg0, IApplicationToken arg1, int arg2, int arg3, boolean arg4, - boolean arg5) + public void addAppToken(int arg0, IApplicationToken arg1, int arg2, int arg3, int arg4, + boolean arg5, boolean arg6) throws RemoteException { // TODO Auto-generated method stub @@ -211,24 +204,6 @@ public class IWindowManagerImpl implements IWindowManager { } @Override - public void moveAppToken(int arg0, IBinder arg1) throws RemoteException { - // TODO Auto-generated method stub - - } - - @Override - public void moveAppTokensToBottom(List<IBinder> arg0) throws RemoteException { - // TODO Auto-generated method stub - - } - - @Override - public void moveAppTokensToTop(List<IBinder> arg0) throws RemoteException { - // TODO Auto-generated method stub - - } - - @Override public IWindowSession openSession(IInputMethodClient arg0, IInputContext arg1) throws RemoteException { // TODO Auto-generated method stub @@ -322,7 +297,7 @@ public class IWindowManagerImpl implements IWindowManager { @Override public void setAppStartingWindow(IBinder arg0, String arg1, int arg2, CompatibilityInfo arg3, - CharSequence arg4, int arg5, int arg6, int arg7, IBinder arg8, boolean arg9) + CharSequence arg4, int arg5, int arg6, int arg7, int arg8, IBinder arg9, boolean arg10) throws RemoteException { // TODO Auto-generated method stub } diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgePowerManager.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgePowerManager.java index 1ccbc40752dd..6fd5acc4e04b 100644 --- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgePowerManager.java +++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgePowerManager.java @@ -39,7 +39,7 @@ public class BridgePowerManager implements IPowerManager { } @Override - public void acquireWakeLock(IBinder arg0, int arg1, String arg2, WorkSource arg3) + public void acquireWakeLock(IBinder arg0, int arg1, String arg2, String arg2_5, WorkSource arg3) throws RemoteException { // pass for now. } diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/RenderSessionImpl.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/RenderSessionImpl.java index c14af4add019..6011fdbabcdd 100644 --- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/RenderSessionImpl.java +++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/RenderSessionImpl.java @@ -192,11 +192,10 @@ public class RenderSessionImpl extends RenderAction<SessionParams> { findNavigationBar(resources, metrics); // FIXME: find those out, and possibly add them to the render params - boolean hasSystemNavBar = true; boolean hasNavigationBar = true; IWindowManager iwm = new IWindowManagerImpl(getContext().getConfiguration(), metrics, Surface.ROTATION_0, - hasSystemNavBar, hasNavigationBar); + hasNavigationBar); WindowManagerGlobal_Delegate.setWindowManagerService(iwm); // build the inflater and parser. diff --git a/tools/obbtool/Android.mk b/tools/obbtool/Android.mk index ad8de6943043..9ff56d634c21 100644 --- a/tools/obbtool/Android.mk +++ b/tools/obbtool/Android.mk @@ -18,8 +18,8 @@ LOCAL_CFLAGS := -Wall -Werror #LOCAL_C_INCLUDES += LOCAL_STATIC_LIBRARIES := \ - libutils \ libandroidfw \ + libutils \ libcutils \ liblog |