diff options
Diffstat (limited to 'tools')
32 files changed, 763 insertions, 271 deletions
diff --git a/tools/aapt/AaptAssets.cpp b/tools/aapt/AaptAssets.cpp index 46b8a27..5b71adc 100644 --- a/tools/aapt/AaptAssets.cpp +++ b/tools/aapt/AaptAssets.cpp @@ -183,6 +183,13 @@ AaptGroupEntry::parseNamePart(const String8& part, int* axis, uint32_t* value) return 0; } + // layout direction + if (getLayoutDirectionName(part.string(), &config)) { + *axis = AXIS_LAYOUTDIR; + *value = (config.screenLayout&ResTable_config::MASK_LAYOUTDIR); + return 0; + } + // smallest screen dp width if (getSmallestScreenWidthDpName(part.string(), &config)) { *axis = AXIS_SMALLESTSCREENWIDTHDP; @@ -309,6 +316,8 @@ AaptGroupEntry::getConfigValueForAxis(const ResTable_config& config, int axis) case AXIS_LANGUAGE: return (((uint32_t)config.country[1]) << 24) | (((uint32_t)config.country[0]) << 16) | (((uint32_t)config.language[1]) << 8) | (config.language[0]); + case AXIS_LAYOUTDIR: + return config.screenLayout&ResTable_config::MASK_LAYOUTDIR; case AXIS_SCREENLAYOUTSIZE: return config.screenLayout&ResTable_config::MASK_SCREENSIZE; case AXIS_ORIENTATION: @@ -364,7 +373,7 @@ AaptGroupEntry::initFromDirName(const char* dir, String8* resType) Vector<String8> parts; String8 mcc, mnc, loc, layoutsize, layoutlong, orient, den; - String8 touch, key, keysHidden, nav, navHidden, size, vers; + String8 touch, key, keysHidden, nav, navHidden, size, layoutDir, vers; String8 uiModeType, uiModeNight, smallestwidthdp, widthdp, heightdp; const char *p = dir; @@ -452,6 +461,18 @@ AaptGroupEntry::initFromDirName(const char* dir, String8* resType) //printf("not region: %s\n", part.string()); } + if (getLayoutDirectionName(part.string())) { + layoutDir = part; + + index++; + if (index == N) { + goto success; + } + part = parts[index]; + } else { + //printf("not layout direction: %s\n", part.string()); + } + if (getSmallestScreenWidthDpName(part.string())) { smallestwidthdp = part; @@ -674,6 +695,7 @@ success: this->navHidden = navHidden; this->navigation = nav; this->screenSize = size; + this->layoutDirection = layoutDir; this->version = vers; // what is this anyway? @@ -691,6 +713,8 @@ AaptGroupEntry::toString() const s += ","; s += this->locale; s += ","; + s += layoutDirection; + s += ","; s += smallestScreenWidthDp; s += ","; s += screenWidthDp; @@ -747,6 +771,12 @@ AaptGroupEntry::toDirName(const String8& resType) const } s += locale; } + if (this->layoutDirection != "") { + if (s.length() > 0) { + s += "-"; + } + s += layoutDirection; + } if (this->smallestScreenWidthDp != "") { if (s.length() > 0) { s += "-"; @@ -958,6 +988,28 @@ bool AaptGroupEntry::getLocaleName(const char* fileName, return false; } +bool AaptGroupEntry::getLayoutDirectionName(const char* name, ResTable_config* out) +{ + if (strcmp(name, kWildcardName) == 0) { + if (out) out->screenLayout = + (out->screenLayout&~ResTable_config::MASK_LAYOUTDIR) + | ResTable_config::LAYOUTDIR_ANY; + return true; + } else if (strcmp(name, "ldltr") == 0) { + if (out) out->screenLayout = + (out->screenLayout&~ResTable_config::MASK_LAYOUTDIR) + | ResTable_config::LAYOUTDIR_LTR; + return true; + } else if (strcmp(name, "ldrtl") == 0) { + if (out) out->screenLayout = + (out->screenLayout&~ResTable_config::MASK_LAYOUTDIR) + | ResTable_config::LAYOUTDIR_RTL; + return true; + } + + return false; +} + bool AaptGroupEntry::getScreenLayoutSizeName(const char* name, ResTable_config* out) { @@ -1415,6 +1467,7 @@ int AaptGroupEntry::compare(const AaptGroupEntry& o) const int v = mcc.compare(o.mcc); if (v == 0) v = mnc.compare(o.mnc); if (v == 0) v = locale.compare(o.locale); + if (v == 0) v = layoutDirection.compare(o.layoutDirection); if (v == 0) v = vendor.compare(o.vendor); if (v == 0) v = smallestScreenWidthDp.compare(o.smallestScreenWidthDp); if (v == 0) v = screenWidthDp.compare(o.screenWidthDp); @@ -1447,6 +1500,7 @@ const ResTable_config& AaptGroupEntry::toParams() const getMccName(mcc.string(), ¶ms); getMncName(mnc.string(), ¶ms); getLocaleName(locale.string(), ¶ms); + getLayoutDirectionName(layoutDirection.string(), ¶ms); getSmallestScreenWidthDpName(smallestScreenWidthDp.string(), ¶ms); getScreenWidthDpName(screenWidthDp.string(), ¶ms); getScreenHeightDpName(screenHeightDp.string(), ¶ms); diff --git a/tools/aapt/AaptAssets.h b/tools/aapt/AaptAssets.h index d5f296c..5cfa913 100644 --- a/tools/aapt/AaptAssets.h +++ b/tools/aapt/AaptAssets.h @@ -51,6 +51,7 @@ enum { AXIS_SMALLESTSCREENWIDTHDP, AXIS_SCREENWIDTHDP, AXIS_SCREENHEIGHTDP, + AXIS_LAYOUTDIR, AXIS_VERSION, AXIS_START = AXIS_MCC, @@ -95,6 +96,7 @@ public: static bool getSmallestScreenWidthDpName(const char* name, ResTable_config* out = NULL); static bool getScreenWidthDpName(const char* name, ResTable_config* out = NULL); static bool getScreenHeightDpName(const char* name, ResTable_config* out = NULL); + static bool getLayoutDirectionName(const char* name, ResTable_config* out = NULL); static bool getVersionName(const char* name, ResTable_config* out = NULL); int compare(const AaptGroupEntry& o) const; @@ -133,6 +135,7 @@ private: String8 navHidden; String8 navigation; String8 screenSize; + String8 layoutDirection; String8 version; mutable bool mParamsChanged; diff --git a/tools/aapt/Android.mk b/tools/aapt/Android.mk index d9b0681..5b88669 100644 --- a/tools/aapt/Android.mk +++ b/tools/aapt/Android.mk @@ -20,6 +20,7 @@ LOCAL_SRC_FILES := \ StringPool.cpp \ XMLNode.cpp \ ResourceFilter.cpp \ + ResourceIdCache.cpp \ ResourceTable.cpp \ Images.cpp \ Resource.cpp \ diff --git a/tools/aapt/Bundle.h b/tools/aapt/Bundle.h index fde3bd6..5089b9d 100644 --- a/tools/aapt/Bundle.h +++ b/tools/aapt/Bundle.h @@ -38,6 +38,7 @@ typedef enum Command { kCommandRemove, kCommandPackage, kCommandCrunch, + kCommandSingleCrunch, } Command; /* @@ -62,6 +63,7 @@ public: mVersionCode(NULL), mVersionName(NULL), mCustomPackage(NULL), mExtraPackages(NULL), mMaxResVersion(NULL), mDebugMode(false), mNonConstantId(false), mProduct(NULL), mUseCrunchCache(false), mErrorOnFailedInsert(false), mOutputTextSymbols(NULL), + mSingleCrunchInputFile(NULL), mSingleCrunchOutputFile(NULL), mArgc(0), mArgv(NULL) {} ~Bundle(void) {} @@ -176,6 +178,10 @@ public: bool getUseCrunchCache() const { return mUseCrunchCache; } const char* getOutputTextSymbols() const { return mOutputTextSymbols; } void setOutputTextSymbols(const char* val) { mOutputTextSymbols = val; } + const char* getSingleCrunchInputFile() const { return mSingleCrunchInputFile; } + void setSingleCrunchInputFile(const char* val) { mSingleCrunchInputFile = val; } + const char* getSingleCrunchOutputFile() const { return mSingleCrunchOutputFile; } + void setSingleCrunchOutputFile(const char* val) { mSingleCrunchOutputFile = val; } /* * Set and get the file specification. @@ -283,6 +289,8 @@ private: bool mUseCrunchCache; bool mErrorOnFailedInsert; const char* mOutputTextSymbols; + const char* mSingleCrunchInputFile; + const char* mSingleCrunchOutputFile; /* file specification */ int mArgc; diff --git a/tools/aapt/Command.cpp b/tools/aapt/Command.cpp index 0a5e590..c3a0930 100644 --- a/tools/aapt/Command.cpp +++ b/tools/aapt/Command.cpp @@ -7,6 +7,7 @@ #include "Bundle.h" #include "ResourceFilter.h" #include "ResourceTable.h" +#include "Images.h" #include "XMLNode.h" #include <utils/Log.h> @@ -1839,6 +1840,25 @@ int doCrunch(Bundle* bundle) return NO_ERROR; } +/* + * Do PNG Crunching on a single flag + * -i points to a single png file + * -o points to a single png output file + */ +int doSingleCrunch(Bundle* bundle) +{ + fprintf(stdout, "Crunching single PNG file: %s\n", bundle->getSingleCrunchInputFile()); + fprintf(stdout, "\tOutput file: %s\n", bundle->getSingleCrunchOutputFile()); + + String8 input(bundle->getSingleCrunchInputFile()); + String8 output(bundle->getSingleCrunchOutputFile()); + if (preProcessImageToCache(bundle, input, output) != NO_ERROR) { + // we can't return the status_t as it gets truncate to the lower 8 bits. + return 42; + } + return NO_ERROR; +} + char CONSOLE_DATA[2925] = { 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 95, 46, 32, 32, 32, 32, 32, 32, 32, 32, 32, diff --git a/tools/aapt/Main.cpp b/tools/aapt/Main.cpp index f398de0..32fecb2 100644 --- a/tools/aapt/Main.cpp +++ b/tools/aapt/Main.cpp @@ -85,7 +85,11 @@ void usage(void) " Add specified files to Zip-compatible archive.\n\n", gProgName); fprintf(stderr, " %s c[runch] [-v] -S resource-sources ... -C output-folder ...\n" - " Do PNG preprocessing and store the results in output folder.\n\n", gProgName); + " Do PNG preprocessing on one or several resource folders\n" + " and store the results in the output folder.\n\n", gProgName); + fprintf(stderr, + " %s s[ingleCrunch] [-v] -i input-file -o outputfile\n" + " Do PNG preprocessing on a single file.\n\n", gProgName); fprintf(stderr, " %s v[ersion]\n" " Print program version.\n\n", gProgName); @@ -203,13 +207,14 @@ int handleCommand(Bundle* bundle) // printf(" %d: '%s'\n", i, bundle->getFileSpecEntry(i)); switch (bundle->getCommand()) { - case kCommandVersion: return doVersion(bundle); - case kCommandList: return doList(bundle); - case kCommandDump: return doDump(bundle); - case kCommandAdd: return doAdd(bundle); - case kCommandRemove: return doRemove(bundle); - case kCommandPackage: return doPackage(bundle); - case kCommandCrunch: return doCrunch(bundle); + case kCommandVersion: return doVersion(bundle); + case kCommandList: return doList(bundle); + case kCommandDump: return doDump(bundle); + case kCommandAdd: return doAdd(bundle); + case kCommandRemove: return doRemove(bundle); + case kCommandPackage: return doPackage(bundle); + case kCommandCrunch: return doCrunch(bundle); + case kCommandSingleCrunch: return doSingleCrunch(bundle); default: fprintf(stderr, "%s: requested command not yet supported\n", gProgName); return 1; @@ -249,6 +254,8 @@ int main(int argc, char* const argv[]) bundle.setCommand(kCommandPackage); else if (argv[1][0] == 'c') bundle.setCommand(kCommandCrunch); + else if (argv[1][0] == 's') + bundle.setCommand(kCommandSingleCrunch); else { fprintf(stderr, "ERROR: Unknown command '%s'\n", argv[1]); wantUsage = true; @@ -427,6 +434,28 @@ int main(int argc, char* const argv[]) convertPath(argv[0]); bundle.setCrunchedOutputDir(argv[0]); break; + case 'i': + argc--; + argv++; + if (!argc) { + fprintf(stderr, "ERROR: No argument supplied for '-i' option\n"); + wantUsage = true; + goto bail; + } + convertPath(argv[0]); + bundle.setSingleCrunchInputFile(argv[0]); + break; + case 'o': + argc--; + argv++; + if (!argc) { + fprintf(stderr, "ERROR: No argument supplied for '-o' option\n"); + wantUsage = true; + goto bail; + } + convertPath(argv[0]); + bundle.setSingleCrunchOutputFile(argv[0]); + break; case '0': argc--; argv++; diff --git a/tools/aapt/Main.h b/tools/aapt/Main.h index d20c601..a6b39ac 100644 --- a/tools/aapt/Main.h +++ b/tools/aapt/Main.h @@ -29,6 +29,7 @@ extern int doAdd(Bundle* bundle); extern int doRemove(Bundle* bundle); extern int doPackage(Bundle* bundle); extern int doCrunch(Bundle* bundle); +extern int doSingleCrunch(Bundle* bundle); extern int calcPercent(long uncompressedLen, long compressedLen); diff --git a/tools/aapt/ResourceIdCache.cpp b/tools/aapt/ResourceIdCache.cpp new file mode 100644 index 0000000..e03f4f6 --- /dev/null +++ b/tools/aapt/ResourceIdCache.cpp @@ -0,0 +1,107 @@ +// +// Copyright 2012 The Android Open Source Project +// +// Manage a resource ID cache. + +#define LOG_TAG "ResourceIdCache" + +#include <utils/String16.h> +#include <utils/Log.h> +#include "ResourceIdCache.h" +#include <map> +using namespace std; + + +static size_t mHits = 0; +static size_t mMisses = 0; +static size_t mCollisions = 0; + +static const size_t MAX_CACHE_ENTRIES = 2048; +static const android::String16 TRUE16("1"); +static const android::String16 FALSE16("0"); + +struct CacheEntry { + // concatenation of the relevant strings into a single instance + android::String16 hashedName; + uint32_t id; + + CacheEntry() {} + CacheEntry(const android::String16& name, uint32_t resId) : hashedName(name), id(resId) { } +}; + +static map< uint32_t, CacheEntry > mIdMap; + + +// djb2; reasonable choice for strings when collisions aren't particularly important +static inline uint32_t hashround(uint32_t hash, int c) { + return ((hash << 5) + hash) + c; /* hash * 33 + c */ +} + +static uint32_t hash(const android::String16& hashableString) { + uint32_t hash = 5381; + const char16_t* str = hashableString.string(); + while (int c = *str++) hash = hashround(hash, c); + return hash; +} + +namespace android { + +static inline String16 makeHashableName(const android::String16& package, + const android::String16& type, + const android::String16& name, + bool onlyPublic) { + String16 hashable = String16(name); + hashable += type; + hashable += package; + hashable += (onlyPublic ? TRUE16 : FALSE16); + return hashable; +} + +uint32_t ResourceIdCache::lookup(const android::String16& package, + const android::String16& type, + const android::String16& name, + bool onlyPublic) { + const String16 hashedName = makeHashableName(package, type, name, onlyPublic); + const uint32_t hashcode = hash(hashedName); + map<uint32_t, CacheEntry>::iterator item = mIdMap.find(hashcode); + if (item == mIdMap.end()) { + // cache miss + mMisses++; + return 0; + } + + // legit match? + if (hashedName == (*item).second.hashedName) { + mHits++; + return (*item).second.id; + } + + // collision + mCollisions++; + mIdMap.erase(hashcode); + return 0; +} + +// returns the resource ID being stored, for callsite convenience +uint32_t ResourceIdCache::store(const android::String16& package, + const android::String16& type, + const android::String16& name, + bool onlyPublic, + uint32_t resId) { + if (mIdMap.size() < MAX_CACHE_ENTRIES) { + const String16 hashedName = makeHashableName(package, type, name, onlyPublic); + const uint32_t hashcode = hash(hashedName); + mIdMap[hashcode] = CacheEntry(hashedName, resId); + } + return resId; +} + +void ResourceIdCache::dump() { + printf("ResourceIdCache dump:\n"); + printf("Size: %ld\n", mIdMap.size()); + printf("Hits: %ld\n", mHits); + printf("Misses: %ld\n", mMisses); + printf("(Collisions: %ld)\n", mCollisions); +} + +} diff --git a/tools/aapt/ResourceIdCache.h b/tools/aapt/ResourceIdCache.h new file mode 100644 index 0000000..65f7781 --- /dev/null +++ b/tools/aapt/ResourceIdCache.h @@ -0,0 +1,30 @@ +// +// Copyright 2012 The Android Open Source Project +// +// Manage a resource ID cache. + +#ifndef RESOURCE_ID_CACHE_H +#define RESOURCE_ID_CACHE_H + +namespace android { +class android::String16; + +class ResourceIdCache { +public: + static uint32_t lookup(const android::String16& package, + const android::String16& type, + const android::String16& name, + bool onlyPublic); + + static uint32_t store(const android::String16& package, + const android::String16& type, + const android::String16& name, + bool onlyPublic, + uint32_t resId); + + static void dump(void); +}; + +} + +#endif diff --git a/tools/aapt/ResourceTable.cpp b/tools/aapt/ResourceTable.cpp index d98fe65..52ebaf0 100644 --- a/tools/aapt/ResourceTable.cpp +++ b/tools/aapt/ResourceTable.cpp @@ -8,6 +8,7 @@ #include "XMLNode.h" #include "ResourceFilter.h" +#include "ResourceIdCache.h" #include <androidfw/ResourceTypes.h> #include <utils/ByteOrder.h> @@ -1998,6 +1999,9 @@ uint32_t ResourceTable::getResId(const String16& package, const String16& name, bool onlyPublic) const { + uint32_t id = ResourceIdCache::lookup(package, type, name, onlyPublic); + if (id != 0) return id; // cache hit + sp<Package> p = mPackages.valueFor(package); if (p == NULL) return 0; @@ -2016,11 +2020,10 @@ uint32_t ResourceTable::getResId(const String16& package, } if (Res_INTERNALID(rid)) { - return rid; + return ResourceIdCache::store(package, type, name, onlyPublic, rid); } - return Res_MAKEID(p->getAssignedId()-1, - Res_GETTYPE(rid), - Res_GETENTRY(rid)); + return ResourceIdCache::store(package, type, name, onlyPublic, + Res_MAKEID(p->getAssignedId()-1, Res_GETTYPE(rid), Res_GETENTRY(rid))); } sp<Type> t = p->getTypes().valueFor(type); @@ -2029,7 +2032,9 @@ uint32_t ResourceTable::getResId(const String16& package, if (c == NULL) return 0; int32_t ei = c->getEntryIndex(); if (ei < 0) return 0; - return getResId(p, t, ei); + + return ResourceIdCache::store(package, type, name, onlyPublic, + getResId(p, t, ei)); } uint32_t ResourceTable::getResId(const String16& ref, @@ -2811,7 +2816,7 @@ status_t ResourceTable::flatten(Bundle* bundle, const sp<AaptFile>& dest) NOISY(printf("Writing config %d config: imsi:%d/%d lang:%c%c cnt:%c%c " "orien:%d ui:%d touch:%d density:%d key:%d inp:%d nav:%d sz:%dx%d " - "sw%ddp w%ddp h%ddp\n", + "sw%ddp w%ddp h%ddp dir:%d\n", ti+1, config.mcc, config.mnc, config.language[0] ? config.language[0] : '-', @@ -2829,7 +2834,8 @@ status_t ResourceTable::flatten(Bundle* bundle, const sp<AaptFile>& dest) config.screenHeight, config.smallestScreenWidthDp, config.screenWidthDp, - config.screenHeightDp)); + config.screenHeightDp, + config.layoutDirection)); if (filterable && !filter.match(config)) { continue; @@ -2853,7 +2859,7 @@ status_t ResourceTable::flatten(Bundle* bundle, const sp<AaptFile>& dest) tHeader->config = config; NOISY(printf("Writing type %d config: imsi:%d/%d lang:%c%c cnt:%c%c " "orien:%d ui:%d touch:%d density:%d key:%d inp:%d nav:%d sz:%dx%d " - "sw%ddp w%ddp h%ddp\n", + "sw%ddp w%ddp h%ddp dir:%d\n", ti+1, tHeader->config.mcc, tHeader->config.mnc, tHeader->config.language[0] ? tHeader->config.language[0] : '-', @@ -2871,7 +2877,8 @@ status_t ResourceTable::flatten(Bundle* bundle, const sp<AaptFile>& dest) tHeader->config.screenHeight, tHeader->config.smallestScreenWidthDp, tHeader->config.screenWidthDp, - tHeader->config.screenHeightDp)); + tHeader->config.screenHeightDp, + tHeader->config.layoutDirection)); tHeader->config.swapHtoD(); // Build the entries inside of this type. @@ -3489,7 +3496,7 @@ sp<ResourceTable::Entry> ResourceTable::Type::getEntry(const String16& entry, if (config != NULL) { NOISY(printf("New entry at %s:%d: imsi:%d/%d lang:%c%c cnt:%c%c " "orien:%d touch:%d density:%d key:%d inp:%d nav:%d sz:%dx%d " - "sw%ddp w%ddp h%ddp\n", + "sw%ddp w%ddp h%ddp dir:%d\n", sourcePos.file.string(), sourcePos.line, config->mcc, config->mnc, config->language[0] ? config->language[0] : '-', @@ -3506,7 +3513,8 @@ sp<ResourceTable::Entry> ResourceTable::Type::getEntry(const String16& entry, config->screenHeight, config->smallestScreenWidthDp, config->screenWidthDp, - config->screenHeightDp)); + config->screenHeightDp, + config->layoutDirection)); } else { NOISY(printf("New entry at %s:%d: NULL config\n", sourcePos.file.string(), sourcePos.line)); diff --git a/tools/aidl/aidl.cpp b/tools/aidl/aidl.cpp index 8dbbf50..0728246 100644 --- a/tools/aidl/aidl.cpp +++ b/tools/aidl/aidl.cpp @@ -590,7 +590,8 @@ exactly_one_interface(const char* filename, const document_item_type* items, con } const document_item_type* next = items->next; - if (items->next != NULL) { + // Allow parcelables to skip the "one-only" rule. + if (items->next != NULL && next->item_type != USER_DATA_TYPE) { int lineno = -1; if (next->item_type == INTERFACE_TYPE_BINDER) { lineno = ((interface_type*)next)->interface_token.lineno; @@ -598,9 +599,6 @@ exactly_one_interface(const char* filename, const document_item_type* items, con else if (next->item_type == INTERFACE_TYPE_RPC) { lineno = ((interface_type*)next)->interface_token.lineno; } - else if (next->item_type == USER_DATA_TYPE) { - lineno = ((user_data_type*)next)->keyword_token.lineno; - } fprintf(stderr, "%s:%d aidl can only handle one interface per file\n", filename, lineno); return 1; diff --git a/tools/aidl/generate_java_rpc.cpp b/tools/aidl/generate_java_rpc.cpp index e5fa076..5e4dacc 100644 --- a/tools/aidl/generate_java_rpc.cpp +++ b/tools/aidl/generate_java_rpc.cpp @@ -786,7 +786,10 @@ generate_result_dispatcher_method(const method_type* method, } // Call the callback method - dispatchMethod->statements->Add(realCall); + IfStatement* ifst = new IfStatement; + ifst->expression = new Comparison(new FieldVariable(THIS_VALUE, "callback"), "!=", NULL_VALUE); + dispatchMethod->statements->Add(ifst); + ifst->statements->Add(realCall); } static void diff --git a/tools/layoutlib/bridge/.classpath b/tools/layoutlib/bridge/.classpath index a5db7b1..3c124d9 100644 --- a/tools/layoutlib/bridge/.classpath +++ b/tools/layoutlib/bridge/.classpath @@ -2,10 +2,10 @@ <classpath> <classpathentry excluding="org/kxml2/io/" kind="src" path="src"/> <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> - <classpathentry kind="var" path="ANDROID_PLAT_SRC/prebuilt/common/layoutlib_api/layoutlib_api-prebuilt.jar"/> + <classpathentry kind="var" path="ANDROID_PLAT_SRC/prebuilts/misc/common/layoutlib_api/layoutlib_api-prebuilt.jar"/> <classpathentry kind="var" path="ANDROID_PLAT_SRC/prebuilts/misc/common/kxml2/kxml2-2.3.0.jar" sourcepath="/ANDROID_PLAT_SRC/dalvik/libcore/xml/src/main/java"/> <classpathentry kind="var" path="ANDROID_PLAT_SRC/out/host/common/obj/JAVA_LIBRARIES/temp_layoutlib_intermediates/javalib.jar" sourcepath="/ANDROID_PLAT_SRC/frameworks/base"/> - <classpathentry kind="var" path="ANDROID_PLAT_SRC/prebuilt/common/ninepatch/ninepatch-prebuilt.jar"/> - <classpathentry kind="var" path="ANDROID_PLAT_SRC/prebuilt/common/tools-common/tools-common-prebuilt.jar"/> + <classpathentry kind="var" path="ANDROID_PLAT_SRC/prebuilts/misc/common/ninepatch/ninepatch-prebuilt.jar"/> + <classpathentry kind="var" path="ANDROID_PLAT_SRC/prebuilts/misc/common/tools-common/tools-common-prebuilt.jar"/> <classpathentry kind="output" path="bin"/> </classpath> diff --git a/tools/layoutlib/bridge/resources/bars/tablet_system_bar.xml b/tools/layoutlib/bridge/resources/bars/tablet_system_bar.xml deleted file mode 100644 index c5acddb..0000000 --- a/tools/layoutlib/bridge/resources/bars/tablet_system_bar.xml +++ /dev/null @@ -1,24 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<merge xmlns:android="http://schemas.android.com/apk/res/android"> - <ImageView - android:layout_height="wrap_content" - android:layout_width="wrap_content"/> - <ImageView - android:layout_height="wrap_content" - android:layout_width="wrap_content"/> - <ImageView - android:layout_height="wrap_content" - android:layout_width="wrap_content"/> - <TextView - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_weight="1"/> - <ImageView - android:layout_height="wrap_content" - android:layout_width="wrap_content"/> - <ImageView - android:layout_height="wrap_content" - android:layout_width="wrap_content" - android:layout_marginLeft="3dip" - android:layout_marginRight="15dip"/> -</merge> diff --git a/tools/layoutlib/bridge/src/android/os/SystemClock_Delegate.java b/tools/layoutlib/bridge/src/android/os/SystemClock_Delegate.java index bd332a6..fd594f7 100644 --- a/tools/layoutlib/bridge/src/android/os/SystemClock_Delegate.java +++ b/tools/layoutlib/bridge/src/android/os/SystemClock_Delegate.java @@ -31,6 +31,7 @@ import com.android.tools.layoutlib.annotations.LayoutlibDelegate; */ public class SystemClock_Delegate { private static long sBootTime = System.currentTimeMillis(); + private static long sBootTimeNano = System.nanoTime(); @LayoutlibDelegate /*package*/ static boolean setCurrentTimeMillis(long millis) { @@ -60,6 +61,16 @@ public class SystemClock_Delegate { } /** + * Returns nanoseconds since boot, including time spent in sleep. + * + * @return elapsed nanoseconds since boot. + */ + @LayoutlibDelegate + /*package*/ static long elapsedRealtimeNanos() { + return System.nanoTime() - sBootTimeNano; + } + + /** * Returns milliseconds running in the current thread. * * @return elapsed milliseconds in the thread diff --git a/tools/layoutlib/bridge/src/android/util/FloatMath_Delegate.java b/tools/layoutlib/bridge/src/android/util/FloatMath_Delegate.java index 1df78c2..8b4c60b 100644 --- a/tools/layoutlib/bridge/src/android/util/FloatMath_Delegate.java +++ b/tools/layoutlib/bridge/src/android/util/FloatMath_Delegate.java @@ -91,4 +91,42 @@ import com.android.tools.layoutlib.annotations.LayoutlibDelegate; /*package*/ static float sqrt(float value) { return (float)Math.sqrt(value); } + + /** + * Returns the closest float approximation of the raising "e" to the power + * of the argument. + * + * @param value to compute the exponential of + * @return the exponential of value + */ + @LayoutlibDelegate + /*package*/ static float exp(float value) { + return (float)Math.exp(value); + } + + /** + * Returns the closest float approximation of the result of raising {@code + * x} to the power of {@code y}. + * + * @param x the base of the operation. + * @param y the exponent of the operation. + * @return {@code x} to the power of {@code y}. + */ + @LayoutlibDelegate + /*package*/ static float pow(float x, float y) { + return (float)Math.pow(x, y); + } + + /** + * Returns {@code sqrt(}<i>{@code x}</i><sup>{@code 2}</sup>{@code +} <i> + * {@code y}</i><sup>{@code 2}</sup>{@code )}. + * + * @param x a float number + * @param y a float number + * @return the hypotenuse + */ + @LayoutlibDelegate + /*package*/ static float hypot(float x, float y) { + return (float)Math.sqrt(x*x + y*y); + } } diff --git a/tools/layoutlib/bridge/src/android/view/AttachInfo_Accessor.java b/tools/layoutlib/bridge/src/android/view/AttachInfo_Accessor.java index 97d9969..4901f72 100644 --- a/tools/layoutlib/bridge/src/android/view/AttachInfo_Accessor.java +++ b/tools/layoutlib/bridge/src/android/view/AttachInfo_Accessor.java @@ -19,6 +19,7 @@ package android.view; import com.android.layoutlib.bridge.android.BridgeWindow; import com.android.layoutlib.bridge.android.BridgeWindowSession; +import android.content.Context; import android.os.Handler; import android.view.View.AttachInfo; @@ -28,8 +29,12 @@ import android.view.View.AttachInfo; public class AttachInfo_Accessor { public static void setAttachInfo(View view) { + Context context = view.getContext(); + WindowManager wm = (WindowManager)context.getSystemService(Context.WINDOW_SERVICE); + Display display = wm.getDefaultDisplay(); + ViewRootImpl root = new ViewRootImpl(context, display); AttachInfo info = new AttachInfo(new BridgeWindowSession(), new BridgeWindow(), - new ViewRootImpl(view.getContext()), new Handler(), null); + display, root, new Handler(), null); info.mHasWindowFocus = true; info.mWindowVisibility = View.VISIBLE; info.mInTouchMode = false; // this is so that we can display selections. diff --git a/tools/layoutlib/bridge/src/android/view/Choreographer_Delegate.java b/tools/layoutlib/bridge/src/android/view/Choreographer_Delegate.java new file mode 100644 index 0000000..f75ee50 --- /dev/null +++ b/tools/layoutlib/bridge/src/android/view/Choreographer_Delegate.java @@ -0,0 +1,33 @@ +/* + * 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. + */ +package android.view; + +import com.android.tools.layoutlib.annotations.LayoutlibDelegate; + +/** + * Delegate used to provide new implementation of a select few methods of {@link Choreographer} + * + * Through the layoutlib_create tool, the original methods of Choreographer have been + * replaced by calls to methods of the same name in this delegate class. + * + */ +public class Choreographer_Delegate { + + @LayoutlibDelegate + public static float getRefreshRate() { + return 60.f; + } +} diff --git a/tools/layoutlib/bridge/src/android/view/Display_Delegate.java b/tools/layoutlib/bridge/src/android/view/Display_Delegate.java index 8868c65..53dc821 100644 --- a/tools/layoutlib/bridge/src/android/view/Display_Delegate.java +++ b/tools/layoutlib/bridge/src/android/view/Display_Delegate.java @@ -16,11 +16,8 @@ package android.view; -import com.android.layoutlib.bridge.android.BridgeWindowManager; -import com.android.layoutlib.bridge.impl.RenderAction; import com.android.tools.layoutlib.annotations.LayoutlibDelegate; -import android.os.RemoteException; /** * Delegate used to provide new implementation of a select few methods of {@link Display} @@ -31,57 +28,9 @@ import android.os.RemoteException; */ public class Display_Delegate { - // ---- Overridden methods ---- - - @LayoutlibDelegate - public static IWindowManager getWindowManager() { - return RenderAction.getCurrentContext().getIWindowManager(); - } - - // ---- Native methods ---- - - @LayoutlibDelegate - /*package*/ static int getDisplayCount() { - return 1; - } - - @LayoutlibDelegate - /** @hide special for when we are faking the screen size. */ - /*package*/ static int getRawWidthNative(Display theDisplay) { - // same as real since we're not faking compatibility mode. - return RenderAction.getCurrentContext().getIWindowManager().getMetrics().widthPixels; - } - - @LayoutlibDelegate - /** @hide special for when we are faking the screen size. */ - /*package*/ static int getRawHeightNative(Display theDisplay) { - // same as real since we're not faking compatibility mode. - return RenderAction.getCurrentContext().getIWindowManager().getMetrics().heightPixels; - } - - @LayoutlibDelegate - /*package*/ static int getOrientation(Display theDisplay) { - try { - // always dynamically query for the current window manager - return getWindowManager().getRotation(); - } catch (RemoteException e) { - // this will never been thrown since this is not a true RPC. - } - - return Surface.ROTATION_0; - } - @LayoutlibDelegate - /*package*/ static void nativeClassInit() { - // not needed for now. + static void updateDisplayInfoLocked(Display theDisplay) { + // do nothing } - @LayoutlibDelegate - /*package*/ static void init(Display theDisplay, int display) { - // always dynamically query for the current window manager - BridgeWindowManager wm = RenderAction.getCurrentContext().getIWindowManager(); - theDisplay.mDensity = wm.getMetrics().density; - theDisplay.mDpiX = wm.getMetrics().xdpi; - theDisplay.mDpiY = wm.getMetrics().ydpi; - } } diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeWindowManager.java b/tools/layoutlib/bridge/src/android/view/IWindowManagerImpl.java index 6f41f90..3e625f9 100644 --- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeWindowManager.java +++ b/tools/layoutlib/bridge/src/android/view/IWindowManagerImpl.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.android.layoutlib.bridge.android; +package android.view; import com.android.internal.view.IInputContext; import com.android.internal.view.IInputMethodClient; @@ -22,19 +22,21 @@ import com.android.internal.view.IInputMethodClient; import android.content.res.CompatibilityInfo; import android.content.res.Configuration; import android.graphics.Bitmap; -import android.graphics.Point; +import android.os.Bundle; import android.os.IBinder; import android.os.IRemoteCallback; import android.os.RemoteException; import android.util.DisplayMetrics; import android.view.Display; -import android.view.Display_Delegate; import android.view.Gravity; import android.view.IApplicationToken; +import android.view.IDisplayContentChangeListener; +import android.view.IInputFilter; import android.view.IOnKeyguardExitResult; import android.view.IRotationWatcher; import android.view.IWindowManager; import android.view.IWindowSession; +import android.view.WindowInfo; import java.util.List; @@ -42,17 +44,21 @@ import java.util.List; * Basic implementation of {@link IWindowManager} so that {@link Display} (and * {@link Display_Delegate}) can return a valid instance. */ -public class BridgeWindowManager implements IWindowManager { +public class IWindowManagerImpl implements IWindowManager { private final Configuration mConfig; private final DisplayMetrics mMetrics; private final int mRotation; - private boolean mHasNavBar; + private final boolean mHasSystemNavBar; + private final boolean mHasNavigationBar; - public BridgeWindowManager(Configuration config, DisplayMetrics metrics, int rotation) { + public IWindowManagerImpl(Configuration config, DisplayMetrics metrics, int rotation, + boolean hasSystemNavBar, boolean hasNavigationBar) { mConfig = config; mMetrics = metrics; mRotation = rotation; + mHasSystemNavBar = hasSystemNavBar; + mHasNavigationBar = hasNavigationBar; } // custom API. @@ -60,10 +66,6 @@ public class BridgeWindowManager implements IWindowManager { public DisplayMetrics getMetrics() { return mMetrics; } - - public void setHasNavBar(boolean hasNavBar) { - mHasNavBar = hasNavBar; - } // ---- implementation of IWindowManager that we care about ---- @@ -73,53 +75,55 @@ public class BridgeWindowManager implements IWindowManager { } @Override - public int getMaximumSizeDimension() throws RemoteException { - return 0; + public boolean hasNavigationBar() { + return mHasNavigationBar; } @Override - public void getCurrentSizeRange(Point smallestSize, Point largestSize) { + public boolean hasSystemNavBar() throws RemoteException { + return mHasSystemNavBar; } + // ---- unused implementation of IWindowManager ---- + @Override - public void getDisplaySize(Point arg0) throws RemoteException { + public void addAppToken(int arg0, IApplicationToken arg1, int arg2, int arg3, boolean arg4, + boolean arg5) + throws RemoteException { + // TODO Auto-generated method stub + } @Override - public void getRealDisplaySize(Point arg0) throws RemoteException { - } + public void addWindowToken(IBinder arg0, int arg1) throws RemoteException { + // TODO Auto-generated method stub - // ---- unused implementation of IWindowManager ---- + } @Override - public boolean hasSystemNavBar() throws RemoteException { + public void clearForcedDisplaySize(int displayId) throws RemoteException { // TODO Auto-generated method stub - return false; } @Override - public void addAppToken(int arg0, IApplicationToken arg1, int arg2, int arg3, boolean arg4) - throws RemoteException { + public void clearForcedDisplayDensity(int displayId) throws RemoteException { // TODO Auto-generated method stub - } @Override - public void addWindowToken(IBinder arg0, int arg1) throws RemoteException { + public void closeSystemDialogs(String arg0) throws RemoteException { // TODO Auto-generated method stub } @Override - public void clearForcedDisplaySize() throws RemoteException { + public void startFreezingScreen(int exitAnim, int enterAnim) { // TODO Auto-generated method stub - } @Override - public void closeSystemDialogs(String arg0) throws RemoteException { + public void stopFreezingScreen() { // TODO Auto-generated method stub - } @Override @@ -240,7 +244,7 @@ public class BridgeWindowManager implements IWindowManager { @Override public void overridePendingAppTransitionThumb(Bitmap srcThumb, int startX, int startY, - IRemoteCallback startedCallback, boolean delayed) throws RemoteException { + IRemoteCallback startedCallback, boolean scaleUp) throws RemoteException { // TODO Auto-generated method stub } @@ -281,7 +285,8 @@ public class BridgeWindowManager implements IWindowManager { } @Override - public Bitmap screenshotApplications(IBinder arg0, int arg1, int arg2) throws RemoteException { + public Bitmap screenshotApplications(IBinder arg0, int displayId, int arg1, int arg2) + throws RemoteException { // TODO Auto-generated method stub return null; } @@ -307,7 +312,6 @@ public class BridgeWindowManager implements IWindowManager { @Override public void setAppOrientation(IApplicationToken arg0, int arg1) throws RemoteException { // TODO Auto-generated method stub - } @Override @@ -315,7 +319,6 @@ public class BridgeWindowManager implements IWindowManager { CharSequence arg4, int arg5, int arg6, int arg7, IBinder arg8, boolean arg9) throws RemoteException { // TODO Auto-generated method stub - } @Override @@ -327,37 +330,36 @@ public class BridgeWindowManager implements IWindowManager { @Override public void setAppWillBeHidden(IBinder arg0) throws RemoteException { // TODO Auto-generated method stub - } @Override public void setEventDispatching(boolean arg0) throws RemoteException { // TODO Auto-generated method stub - } @Override public void setFocusedApp(IBinder arg0, boolean arg1) throws RemoteException { // TODO Auto-generated method stub - } @Override - public void setForcedDisplaySize(int arg0, int arg1) throws RemoteException { + public void setForcedDisplaySize(int displayId, int arg0, int arg1) throws RemoteException { // TODO Auto-generated method stub + } + @Override + public void setForcedDisplayDensity(int displayId, int density) throws RemoteException { + // TODO Auto-generated method stub } @Override public void setInTouchMode(boolean arg0) throws RemoteException { // TODO Auto-generated method stub - } @Override public void setNewConfiguration(Configuration arg0) throws RemoteException { // TODO Auto-generated method stub - } @Override @@ -368,19 +370,16 @@ public class BridgeWindowManager implements IWindowManager { @Override public void setStrictModeVisualIndicatorPreference(String arg0) throws RemoteException { // TODO Auto-generated method stub - } @Override public void showStrictModeViolation(boolean arg0) throws RemoteException { // TODO Auto-generated method stub - } @Override public void startAppFreezingScreen(IBinder arg0, int arg1) throws RemoteException { // TODO Auto-generated method stub - } @Override @@ -392,13 +391,11 @@ public class BridgeWindowManager implements IWindowManager { @Override public void statusBarVisibilityChanged(int arg0) throws RemoteException { // TODO Auto-generated method stub - } @Override public void stopAppFreezingScreen(IBinder arg0, boolean arg1) throws RemoteException { // TODO Auto-generated method stub - } @Override @@ -410,7 +407,6 @@ public class BridgeWindowManager implements IWindowManager { @Override public void thawRotation() throws RemoteException { // TODO Auto-generated method stub - } @Override @@ -427,8 +423,8 @@ public class BridgeWindowManager implements IWindowManager { } @Override - public void waitForWindowDrawn(IBinder token, IRemoteCallback callback) { - // TODO Auto-generated method stub + public boolean waitForWindowDrawn(IBinder token, IRemoteCallback callback) { + return false; } @Override @@ -447,12 +443,64 @@ public class BridgeWindowManager implements IWindowManager { } @Override - public boolean hasNavigationBar() { - return mHasNavBar; + public void lockNow(Bundle options) { + // TODO Auto-generated method stub + } + + @Override + public boolean isSafeModeEnabled() { + return false; + } + + @Override + public void showAssistant() { + + } + + @Override + public IBinder getFocusedWindowToken() { + // TODO Auto-generated method stub + return null; } @Override - public void lockNow() { + public float getWindowCompatibilityScale(IBinder windowToken) throws RemoteException { + // TODO Auto-generated method stub + return 0; + } + + @Override + public void setInputFilter(IInputFilter filter) throws RemoteException { + // TODO Auto-generated method stub + } + + @Override + public void magnifyDisplay(int dipslayId, float scale, float offsetX, float offsetY) + throws RemoteException { + // TODO Auto-generated method stub + } + + @Override + public void addDisplayContentChangeListener(int displayId, + IDisplayContentChangeListener listener) throws RemoteException { + // TODO Auto-generated method stub + } + + @Override + public void removeDisplayContentChangeListener(int displayId, + IDisplayContentChangeListener listener) throws RemoteException { + // TODO Auto-generated method stub + } + + @Override + public WindowInfo getWindowInfo(IBinder token) throws RemoteException { + // TODO Auto-generated method stub + return null; + } + + @Override + public void getVisibleWindowsForDisplay(int displayId, List<WindowInfo> outInfos) + throws RemoteException { // TODO Auto-generated method stub } } diff --git a/tools/layoutlib/bridge/src/android/view/WindowManagerGlobal_Delegate.java b/tools/layoutlib/bridge/src/android/view/WindowManagerGlobal_Delegate.java new file mode 100644 index 0000000..2606e55 --- /dev/null +++ b/tools/layoutlib/bridge/src/android/view/WindowManagerGlobal_Delegate.java @@ -0,0 +1,43 @@ +/* + * 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. + */ + +package android.view; + +import com.android.tools.layoutlib.annotations.LayoutlibDelegate; + +/** + * Delegate used to provide new implementation of a select few methods of + * {@link WindowManagerGlobal} + * + * Through the layoutlib_create tool, the original methods of WindowManagerGlobal have been + * replaced by calls to methods of the same name in this delegate class. + * + */ +public class WindowManagerGlobal_Delegate { + + private static IWindowManager sService; + + @LayoutlibDelegate + public static IWindowManager getWindowManagerService() { + return sService; + } + + // ---- internal implementation stuff ---- + + public static void setWindowManagerService(IWindowManager service) { + sService = service; + } +} diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeContext.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeContext.java index 78ae102..f0c2145 100644 --- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeContext.java +++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeContext.java @@ -26,6 +26,7 @@ import com.android.ide.common.rendering.api.ResourceValue; import com.android.ide.common.rendering.api.StyleResourceValue; import com.android.layoutlib.bridge.Bridge; import com.android.layoutlib.bridge.BridgeConstants; +import com.android.layoutlib.bridge.android.view.WindowManagerImpl; import com.android.layoutlib.bridge.impl.ParserFactory; import com.android.layoutlib.bridge.impl.Stack; import com.android.resources.ResourceType; @@ -62,13 +63,16 @@ import android.os.Bundle; import android.os.Handler; import android.os.Looper; import android.os.PowerManager; +import android.os.UserHandle; import android.util.AttributeSet; import android.util.DisplayMetrics; import android.util.TypedValue; import android.view.BridgeInflater; -import android.view.Surface; +import android.view.CompatibilityInfoHolder; +import android.view.Display; import android.view.View; import android.view.ViewGroup; +import android.view.WindowManager; import android.view.textservice.TextServicesManager; import java.io.File; @@ -96,7 +100,7 @@ public final class BridgeContext extends Context { private final Configuration mConfig; private final ApplicationInfo mApplicationInfo; private final IProjectCallback mProjectCallback; - private final BridgeWindowManager mIWindowManager; + private final WindowManager mWindowManager; private Resources.Theme mTheme; @@ -137,10 +141,10 @@ public final class BridgeContext extends Context { mRenderResources = renderResources; mConfig = config; - mIWindowManager = new BridgeWindowManager(mConfig, metrics, Surface.ROTATION_0); - mApplicationInfo = new ApplicationInfo(); mApplicationInfo.targetSdkVersion = targetSdkVersion; + + mWindowManager = new WindowManagerImpl(mMetrics); } /** @@ -196,14 +200,14 @@ public final class BridgeContext extends Context { return mRenderResources; } - public BridgeWindowManager getIWindowManager() { - return mIWindowManager; - } - public Map<String, String> getDefaultPropMap(Object key) { return mDefaultPropMaps.get(key); } + public Configuration getConfiguration() { + return mConfig; + } + /** * Adds a parser to the stack. * @param parser the parser to add. @@ -434,10 +438,8 @@ public final class BridgeContext extends Context { return TextServicesManager.getInstance(); } - // AutoCompleteTextView and MultiAutoCompleteTextView want a window - // service. We don't have any but it's not worth an exception. if (WINDOW_SERVICE.equals(service)) { - return null; + return mWindowManager; } // needed by SearchView @@ -446,7 +448,7 @@ public final class BridgeContext extends Context { } if (POWER_SERVICE.equals(service)) { - return new PowerManager(new BridgePowerManager(), new Handler()); + return new PowerManager(this, new BridgePowerManager(), new Handler()); } throw new UnsupportedOperationException("Unsupported Service: " + service); @@ -934,6 +936,24 @@ public final class BridgeContext extends Context { } @Override + public Context createPackageContextAsUser(String arg0, int arg1, UserHandle user) { + // pass + return null; + } + + @Override + public Context createConfigurationContext(Configuration overrideConfiguration) { + // pass + return null; + } + + @Override + public Context createDisplayContext(Display display) { + // pass + return null; + } + + @Override public String[] databaseList() { // pass return null; @@ -1166,6 +1186,13 @@ public final class BridgeContext extends Context { } @Override + public Intent registerReceiverAsUser(BroadcastReceiver arg0, UserHandle arg0p5, + IntentFilter arg1, String arg2, Handler arg3) { + // pass + return null; + } + + @Override public void removeStickyBroadcast(Intent arg0) { // pass @@ -1204,6 +1231,24 @@ public final class BridgeContext extends Context { } @Override + public void sendBroadcastAsUser(Intent intent, UserHandle user) { + // pass + } + + @Override + public void sendBroadcastAsUser(Intent intent, UserHandle user, + String receiverPermission) { + // pass + } + + @Override + public void sendOrderedBroadcastAsUser(Intent intent, UserHandle user, + String receiverPermission, BroadcastReceiver resultReceiver, Handler scheduler, + int initialCode, String initialData, Bundle initialExtras) { + // pass + } + + @Override public void sendStickyBroadcast(Intent arg0) { // pass @@ -1217,6 +1262,24 @@ public final class BridgeContext extends Context { } @Override + public void sendStickyBroadcastAsUser(Intent intent, UserHandle user) { + // pass + } + + @Override + public void sendStickyOrderedBroadcastAsUser(Intent intent, + UserHandle user, BroadcastReceiver resultReceiver, + Handler scheduler, int initialCode, String initialData, + Bundle initialExtras) { + // pass + } + + @Override + public void removeStickyBroadcastAsUser(Intent intent, UserHandle user) { + // pass + } + + @Override public void setTheme(int arg0) { // pass @@ -1278,6 +1341,18 @@ public final class BridgeContext extends Context { } @Override + public ComponentName startServiceAsUser(Intent arg0, UserHandle arg1) { + // pass + return null; + } + + @Override + public boolean stopServiceAsUser(Intent arg0, UserHandle arg1) { + // pass + return false; + } + + @Override public void unbindService(ServiceConnection arg0) { // pass @@ -1316,4 +1391,10 @@ public final class BridgeContext extends Context { Bridge.getLog().error(LayoutLog.TAG_UNSUPPORTED, "OBB not supported", null); return null; } + + @Override + public CompatibilityInfoHolder getCompatibilityInfo(int displayId) { + // pass + return null; + } } 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 6071a6b..1ccbc40 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,44 +39,33 @@ public class BridgePowerManager implements IPowerManager { } @Override - public void acquireWakeLock(int arg0, IBinder arg1, String arg2, WorkSource arg3) + public void acquireWakeLock(IBinder arg0, int arg1, String arg2, WorkSource arg3) throws RemoteException { // pass for now. } @Override - public void clearUserActivityTimeout(long arg0, long arg1) throws RemoteException { - // pass for now. - } - - @Override public void crash(String arg0) throws RemoteException { // pass for now. } @Override - public int getSupportedWakeLockFlags() throws RemoteException { + public void goToSleep(long arg0, int arg1) throws RemoteException { // pass for now. - return 0; } @Override - public void goToSleep(long arg0) throws RemoteException { + public void nap(long arg0) throws RemoteException { // pass for now. } @Override - public void goToSleepWithReason(long arg0, int arg1) throws RemoteException { + public void reboot(boolean confirm, String reason, boolean wait) { // pass for now. } @Override - public void preventScreenOn(boolean arg0) throws RemoteException { - // pass for now. - } - - @Override - public void reboot(String arg0) throws RemoteException { + public void shutdown(boolean confirm, boolean wait) { // pass for now. } @@ -91,42 +80,43 @@ public class BridgePowerManager implements IPowerManager { } @Override - public void setAutoBrightnessAdjustment(float arg0) throws RemoteException { + public void setTemporaryScreenAutoBrightnessAdjustmentSettingOverride(float arg0) throws RemoteException { // pass for now. } @Override - public void setBacklightBrightness(int arg0) throws RemoteException { + public void setTemporaryScreenBrightnessSettingOverride(int arg0) throws RemoteException { // pass for now. } @Override - public void setMaximumScreenOffTimeount(int arg0) throws RemoteException { + public void setMaximumScreenOffTimeoutFromDeviceAdmin(int arg0) throws RemoteException { // pass for now. } @Override - public void setPokeLock(int arg0, IBinder arg1, String arg2) throws RemoteException { + public void setStayOnSetting(int arg0) throws RemoteException { // pass for now. } @Override - public void setStayOnSetting(int arg0) throws RemoteException { + public void updateWakeLockWorkSource(IBinder arg0, WorkSource arg1) throws RemoteException { // pass for now. } @Override - public void updateWakeLockWorkSource(IBinder arg0, WorkSource arg1) throws RemoteException { + public boolean isWakeLockLevelSupported(int level) throws RemoteException { // pass for now. + return true; } @Override - public void userActivity(long arg0, boolean arg1) throws RemoteException { + public void userActivity(long time, int event, int flags) throws RemoteException { // pass for now. } @Override - public void userActivityWithForce(long arg0, boolean arg1, boolean arg2) throws RemoteException { + public void wakeUp(long time) throws RemoteException { // pass for now. } } diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeWindow.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeWindow.java index 379fb81..fa660e6 100644 --- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeWindow.java +++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeWindow.java @@ -47,12 +47,17 @@ public final class BridgeWindow implements IWindow { } @Override - public void resized(int arg0, int arg1, Rect arg2, Rect arg3, + public void resized(Rect arg1, Rect arg2, Rect arg3, boolean arg4, Configuration arg5) throws RemoteException { // pass for now. } @Override + public void moved(int arg0, int arg1) throws RemoteException { + // pass for now. + } + + @Override public void dispatchScreenState(boolean on) throws RemoteException { // pass for now. } diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeWindowSession.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeWindowSession.java index 6fb599d..67b0a9c 100644 --- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeWindowSession.java +++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeWindowSession.java @@ -45,7 +45,24 @@ public final class BridgeWindowSession implements IWindowSession { } @Override - public int addWithoutInputChannel(IWindow arg0, int seq, LayoutParams arg1, int arg2, Rect arg3) + public int addToDisplay(IWindow arg0, int seq, LayoutParams arg1, int arg2, int displayId, + Rect arg3, InputChannel outInputchannel) + throws RemoteException { + // pass for now. + return 0; + } + + @Override + public int addWithoutInputChannel(IWindow arg0, int seq, LayoutParams arg1, int arg2, + Rect arg3) + throws RemoteException { + // pass for now. + return 0; + } + + @Override + public int addToDisplayWithoutInputChannel(IWindow arg0, int seq, LayoutParams arg1, int arg2, + int displayId, Rect arg3) throws RemoteException { // pass for now. return 0; @@ -167,8 +184,19 @@ public final class BridgeWindowSession implements IWindowSession { } @Override + public void setUniverseTransform(IBinder window, float alpha, float offx, float offy, + float dsdx, float dtdx, float dsdy, float dtdy) { + // pass for now. + } + + @Override public IBinder asBinder() { // pass for now. return null; } + + @Override + public void onRectangleOnScreenRequested(IBinder window, Rect rectangle, boolean immediate) { + // pass for now. + } } diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/view/WindowManagerImpl.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/view/WindowManagerImpl.java new file mode 100644 index 0000000..9a633bf --- /dev/null +++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/view/WindowManagerImpl.java @@ -0,0 +1,64 @@ +/* + * 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. + */ +package com.android.layoutlib.bridge.android.view; + +import android.util.DisplayMetrics; +import android.view.Display; +import android.view.DisplayInfo; +import android.view.View; +import android.view.WindowManager; + +public class WindowManagerImpl implements WindowManager { + + private final DisplayMetrics mMetrics; + private final Display mDisplay; + + public WindowManagerImpl(DisplayMetrics metrics) { + mMetrics = metrics; + + DisplayInfo info = new DisplayInfo(); + info.logicalHeight = mMetrics.heightPixels; + info.logicalWidth = mMetrics.widthPixels; + mDisplay = new Display(null, Display.DEFAULT_DISPLAY, info, null); + } + + @Override + public Display getDefaultDisplay() { + return mDisplay; + } + + + @Override + public void addView(View arg0, android.view.ViewGroup.LayoutParams arg1) { + // pass + } + + @Override + public void removeView(View arg0) { + // pass + } + + @Override + public void updateViewLayout(View arg0, android.view.ViewGroup.LayoutParams arg1) { + // pass + } + + + @Override + public void removeViewImmediate(View arg0) { + // pass + } +} diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/bars/CustomBar.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/bars/CustomBar.java index 11fd697..99dc5ad 100644 --- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/bars/CustomBar.java +++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/bars/CustomBar.java @@ -56,7 +56,7 @@ import java.io.InputStream; * * It also provides a few utility methods to configure the content of the layout. */ -public abstract class CustomBar extends LinearLayout { +abstract class CustomBar extends LinearLayout { protected abstract TextView getStyleableTextView(); diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/bars/TabletSystemBar.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/bars/TabletSystemBar.java deleted file mode 100644 index 5ddb34e..0000000 --- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/bars/TabletSystemBar.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (C) 2011 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. - */ - -package com.android.layoutlib.bridge.bars; - -import com.android.resources.Density; -import com.android.resources.ResourceType; - -import org.xmlpull.v1.XmlPullParserException; - -import android.content.Context; -import android.graphics.drawable.Drawable; -import android.graphics.drawable.LevelListDrawable; -import android.widget.LinearLayout; -import android.widget.TextView; - -public class TabletSystemBar extends CustomBar { - - public TabletSystemBar(Context context, Density density) throws XmlPullParserException { - super(context, density, LinearLayout.HORIZONTAL, - "/bars/tablet_system_bar.xml", "tablet_system_bar.xml"); - - setBackgroundColor(0xFF000000); - - // Cannot access the inside items through id because no R.id values have been - // created for them. - // We do know the order though. - loadIcon(0, "ic_sysbar_back.png", density); - loadIcon(1, "ic_sysbar_home.png", density); - loadIcon(2, "ic_sysbar_recent.png", density); - // 3 is the spacer - loadIcon(4, "stat_sys_wifi_signal_4_fully.png", density); - Drawable drawable = loadIcon(5, ResourceType.DRAWABLE, "stat_sys_battery_charge"); - if (drawable instanceof LevelListDrawable) { - ((LevelListDrawable) drawable).setLevel(100); - } - } - - @Override - protected TextView getStyleableTextView() { - return null; - } -} diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/RenderAction.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/RenderAction.java index b7d0c47..fb04d99 100644 --- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/RenderAction.java +++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/RenderAction.java @@ -104,7 +104,8 @@ public abstract class RenderAction<T extends RenderParams> extends FrameworkReso // setup the display Metrics. DisplayMetrics metrics = new DisplayMetrics(); - metrics.densityDpi = hardwareConfig.getDensity().getDpiValue(); + metrics.densityDpi = metrics.noncompatDensityDpi = + hardwareConfig.getDensity().getDpiValue(); metrics.density = metrics.noncompatDensity = metrics.densityDpi / (float) DisplayMetrics.DENSITY_DEFAULT; @@ -349,6 +350,7 @@ public abstract class RenderAction<T extends RenderParams> extends FrameworkReso } else { config.smallestScreenWidthDp = config.screenWidthDp; } + config.densityDpi = density.getDpiValue(); // never run in compat mode: config.compatScreenWidthDp = config.screenWidthDp; 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 1d1c73f..4329f5f 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 @@ -52,14 +52,12 @@ import com.android.layoutlib.bridge.bars.ActionBarLayout; import com.android.layoutlib.bridge.bars.CustomBar; import com.android.layoutlib.bridge.bars.NavigationBar; import com.android.layoutlib.bridge.bars.StatusBar; -import com.android.layoutlib.bridge.bars.TabletSystemBar; import com.android.layoutlib.bridge.bars.TitleBar; import com.android.layoutlib.bridge.impl.binding.FakeAdapter; import com.android.layoutlib.bridge.impl.binding.FakeExpandableAdapter; import com.android.resources.Density; import com.android.resources.ResourceType; import com.android.resources.ScreenOrientation; -import com.android.resources.ScreenSize; import com.android.util.Pair; import org.xmlpull.v1.XmlPullParserException; @@ -78,11 +76,15 @@ import android.util.DisplayMetrics; import android.util.TypedValue; import android.view.AttachInfo_Accessor; import android.view.BridgeInflater; +import android.view.IWindowManager; +import android.view.IWindowManagerImpl; +import android.view.Surface; import android.view.View; import android.view.View.MeasureSpec; import android.view.ViewGroup; import android.view.ViewGroup.LayoutParams; import android.view.ViewGroup.MarginLayoutParams; +import android.view.WindowManagerGlobal_Delegate; import android.widget.AbsListView; import android.widget.AbsSpinner; import android.widget.AdapterView; @@ -199,6 +201,14 @@ public class RenderSessionImpl extends RenderAction<SessionParams> { findActionBar(resources, metrics); 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); + WindowManagerGlobal_Delegate.setWindowManagerService(iwm); + // build the inflater and parser. mInflater = new BridgeInflater(context, params.getProjectCallback()); context.setBridgeInflater(mInflater); @@ -268,7 +278,7 @@ public class RenderSessionImpl extends RenderAction<SessionParams> { * we're creating the following layout * +-------------------------------------------------+ - | Status bar (except for xlarge tablets) | + | Status bar (always) | +-------------------------------------------------+ | (Layout with background drawable) | | +---------------------------------------------+ | @@ -1017,27 +1027,23 @@ public class RenderSessionImpl extends RenderAction<SessionParams> { } private void findStatusBar(RenderResources resources, DisplayMetrics metrics) { - // status bar is on for all but x-large device - HardwareConfig hardwareConfig = getParams().getHardwareConfig(); - if (hardwareConfig.getScreenSize() != ScreenSize.XLARGE) { - boolean windowFullscreen = getBooleanThemeValue(resources, - "windowFullscreen", false /*defaultValue*/); + boolean windowFullscreen = getBooleanThemeValue(resources, + "windowFullscreen", false /*defaultValue*/); - if (!windowFullscreen && !mWindowIsFloating) { - // default value - mStatusBarSize = DEFAULT_STATUS_BAR_HEIGHT; + if (!windowFullscreen && !mWindowIsFloating) { + // default value + mStatusBarSize = DEFAULT_STATUS_BAR_HEIGHT; - // get the real value - ResourceValue value = resources.getFrameworkResource(ResourceType.DIMEN, - "status_bar_height"); + // get the real value + ResourceValue value = resources.getFrameworkResource(ResourceType.DIMEN, + "status_bar_height"); - if (value != null) { - TypedValue typedValue = ResourceHelper.getValue("status_bar_height", - value.getValue(), true /*requireUnit*/); - if (typedValue != null) { - // compute the pixel value based on the display metrics - mStatusBarSize = (int)typedValue.getDimension(metrics); - } + if (value != null) { + TypedValue typedValue = ResourceHelper.getValue("status_bar_height", + value.getValue(), true /*requireUnit*/); + if (typedValue != null) { + // compute the pixel value based on the display metrics + mStatusBarSize = (int)typedValue.getDimension(metrics); } } } diff --git a/tools/layoutlib/create/src/com/android/tools/layoutlib/create/CreateInfo.java b/tools/layoutlib/create/src/com/android/tools/layoutlib/create/CreateInfo.java index b65137c..a4a36e3 100644 --- a/tools/layoutlib/create/src/com/android/tools/layoutlib/create/CreateInfo.java +++ b/tools/layoutlib/create/src/com/android/tools/layoutlib/create/CreateInfo.java @@ -133,11 +133,14 @@ public final class CreateInfo implements ICreateInfo { "android.os.Handler#sendMessageAtTime", "android.os.HandlerThread#run", "android.os.Build#getString", + "android.view.Choreographer#getRefreshRate", + "android.view.Display#updateDisplayInfoLocked", "android.view.Display#getWindowManager", "android.view.LayoutInflater#rInflate", "android.view.LayoutInflater#parseInclude", "android.view.View#isInEditMode", "android.view.ViewRootImpl#isInTouchMode", + "android.view.WindowManagerGlobal#getWindowManagerService", "android.view.inputmethod.InputMethodManager#getInstance", "android.view.MenuInflater#registerMenu", "com.android.internal.view.menu.MenuBuilder#createNewMenuItem", diff --git a/tools/preload/Record.java b/tools/preload/Record.java index ac99f1c..14e9201 100644 --- a/tools/preload/Record.java +++ b/tools/preload/Record.java @@ -28,12 +28,16 @@ class Record { "com.google.android.apps.maps\\u003AFriendService", "com.google.android.apps.maps:driveabout", "com.google.android.apps.maps\\u003Adriveabout", + "com.google.android.apps.maps:GoogleLocationService", + "com.google.android.apps.maps\\u003AGoogleLocationService", "com.google.android.apps.maps:LocationFriendService", "com.google.android.apps.maps\\u003ALocationFriendService", "com.google.android.apps.maps:MapsBackgroundService", "com.google.android.apps.maps\\u003AMapsBackgroundService", "com.google.android.apps.maps:NetworkLocationService", "com.google.android.apps.maps\\u003ANetworkLocationService", + "com.android.chrome:sandboxed_process", + "com.android.chrome\\u003Asandboxed_process", "com.android.fakeoemfeatures:background", "com.android.fakeoemfeatures\\u003Abackground", "com.android.fakeoemfeatures:core", |