summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
Diffstat (limited to 'tools')
-rw-r--r--tools/aapt/AaptAssets.cpp96
-rw-r--r--tools/aapt/AaptAssets.h61
-rw-r--r--tools/aapt/Android.mk1
-rw-r--r--tools/aapt/Bundle.h25
-rw-r--r--tools/aapt/Command.cpp294
-rw-r--r--tools/aapt/Images.cpp200
-rw-r--r--tools/aapt/Images.h4
-rw-r--r--tools/aapt/Resource.cpp58
-rw-r--r--tools/aapt/ResourceTable.cpp150
-rw-r--r--tools/aapt/ResourceTable.h71
-rw-r--r--tools/aapt/StringPool.cpp315
-rw-r--r--tools/aapt/StringPool.h90
-rw-r--r--tools/aapt/XMLNode.cpp2
-rw-r--r--tools/aapt/ZipEntry.cpp68
-rw-r--r--tools/aapt/ZipFile.cpp96
-rwxr-xr-xtools/aidl/Type.cpp3
-rw-r--r--tools/aidl/aidl.cpp5
-rw-r--r--tools/aidl/aidl_language_y.y2
-rw-r--r--tools/aidl/generate_java_rpc.cpp6
-rw-r--r--tools/layoutlib/bridge/.settings/README.txt2
-rw-r--r--tools/layoutlib/bridge/.settings/org.eclipse.jdt.core.prefs93
-rw-r--r--tools/layoutlib/bridge/src/android/animation/AnimationThread.java12
-rw-r--r--tools/layoutlib/bridge/src/android/content/res/BridgeResources.java6
-rw-r--r--tools/layoutlib/bridge/src/android/content/res/BridgeTypedArray.java38
-rw-r--r--tools/layoutlib/bridge/src/android/graphics/BitmapFactory_Delegate.java18
-rw-r--r--tools/layoutlib/bridge/src/android/graphics/BitmapShader_Delegate.java5
-rw-r--r--tools/layoutlib/bridge/src/android/graphics/Bitmap_Delegate.java3
-rw-r--r--tools/layoutlib/bridge/src/android/graphics/Canvas_Delegate.java14
-rw-r--r--tools/layoutlib/bridge/src/android/graphics/Gradient_Delegate.java1
-rw-r--r--tools/layoutlib/bridge/src/android/graphics/LinearGradient_Delegate.java4
-rw-r--r--tools/layoutlib/bridge/src/android/graphics/NinePatch_Delegate.java1
-rw-r--r--tools/layoutlib/bridge/src/android/graphics/Paint_Delegate.java11
-rw-r--r--tools/layoutlib/bridge/src/android/graphics/RadialGradient_Delegate.java4
-rw-r--r--tools/layoutlib/bridge/src/android/graphics/SweepGradient_Delegate.java4
-rw-r--r--tools/layoutlib/bridge/src/android/view/AttachInfo_Accessor.java2
-rw-r--r--tools/layoutlib/bridge/src/android/view/SurfaceView.java25
-rw-r--r--tools/layoutlib/bridge/src/android/view/ViewRootImpl_Delegate.java34
-rw-r--r--tools/layoutlib/bridge/src/com/android/internal/policy/PolicyManager.java72
-rw-r--r--tools/layoutlib/bridge/src/com/android/internal/textservice/ITextServicesManager_Stub_Delegate.java10
-rw-r--r--tools/layoutlib/bridge/src/com/android/layoutlib/bridge/Bridge.java37
-rw-r--r--tools/layoutlib/bridge/src/com/android/layoutlib/bridge/BridgeRenderSession.java4
-rw-r--r--tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeContentProvider.java10
-rw-r--r--tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeContext.java351
-rw-r--r--tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeIInputMethodManager.java34
-rw-r--r--tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeLayoutParamsMapAttributes.java22
-rw-r--r--tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgePowerManager.java132
-rw-r--r--tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeWindow.java31
-rw-r--r--tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeWindowManager.java184
-rw-r--r--tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeWindowSession.java49
-rw-r--r--tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeXmlBlockParser.java55
-rw-r--r--tools/layoutlib/bridge/src/com/android/layoutlib/bridge/bars/CustomBar.java2
-rw-r--r--tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/RenderSessionImpl.java11
-rw-r--r--tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/binding/FakeAdapter.java8
-rw-r--r--tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/binding/FakeExpandableAdapter.java17
-rw-r--r--tools/layoutlib/bridge/src/com/android/layoutlib/bridge/util/DynamicIdMap.java76
-rw-r--r--tools/layoutlib/create/.classpath2
-rw-r--r--tools/layoutlib/create/.settings/README.txt2
-rw-r--r--tools/layoutlib/create/.settings/org.eclipse.jdt.core.prefs93
-rw-r--r--tools/layoutlib/create/Android.mk2
-rw-r--r--tools/layoutlib/create/src/com/android/tools/layoutlib/create/AsmAnalyzer.java492
-rw-r--r--tools/layoutlib/create/src/com/android/tools/layoutlib/create/ClassHasNativeVisitor.java14
-rw-r--r--tools/layoutlib/create/src/com/android/tools/layoutlib/create/CreateInfo.java14
-rw-r--r--tools/layoutlib/create/src/com/android/tools/layoutlib/create/DelegateClassAdapter.java5
-rw-r--r--tools/layoutlib/create/src/com/android/tools/layoutlib/create/DelegateMethodAdapter2.java27
-rw-r--r--tools/layoutlib/create/src/com/android/tools/layoutlib/create/MethodAdapter.java8
-rw-r--r--tools/layoutlib/create/src/com/android/tools/layoutlib/create/RenameClassAdapter.java81
-rw-r--r--tools/layoutlib/create/src/com/android/tools/layoutlib/create/StubMethodAdapter.java27
-rw-r--r--tools/layoutlib/create/src/com/android/tools/layoutlib/create/TransformClassAdapter.java5
-rw-r--r--tools/layoutlib/create/tests/com/android/tools/layoutlib/create/AsmGeneratorTest.java6
-rw-r--r--tools/makekeycodes/makekeycodes.cpp18
-rw-r--r--tools/obbtool/Android.mk1
-rw-r--r--tools/obbtool/Main.cpp2
-rwxr-xr-xtools/orientationplot/orientationplot.py116
-rw-r--r--tools/validatekeymaps/Android.mk2
-rw-r--r--tools/validatekeymaps/Main.cpp15
75 files changed, 2857 insertions, 1004 deletions
diff --git a/tools/aapt/AaptAssets.cpp b/tools/aapt/AaptAssets.cpp
index f0c215e..ec61403 100644
--- a/tools/aapt/AaptAssets.cpp
+++ b/tools/aapt/AaptAssets.cpp
@@ -1084,12 +1084,17 @@ bool AaptGroupEntry::getDensityName(const char* name,
if (out) out->density = ResTable_config::DENSITY_HIGH;
return true;
}
-
+
if (strcmp(name, "xhdpi") == 0) {
- if (out) out->density = ResTable_config::DENSITY_MEDIUM*2;
+ if (out) out->density = ResTable_config::DENSITY_XHIGH;
return true;
}
-
+
+ if (strcmp(name, "xxhdpi") == 0) {
+ if (out) out->density = ResTable_config::DENSITY_XXHIGH;
+ return true;
+ }
+
char* c = (char*)name;
while (*c >= '0' && *c <= '9') {
c++;
@@ -1832,6 +1837,49 @@ String8 AaptDir::getPrintableSource() const
// =========================================================================
// =========================================================================
+status_t AaptSymbols::applyJavaSymbols(const sp<AaptSymbols>& javaSymbols)
+{
+ status_t err = NO_ERROR;
+ size_t N = javaSymbols->mSymbols.size();
+ for (size_t i=0; i<N; i++) {
+ const String8& name = javaSymbols->mSymbols.keyAt(i);
+ const AaptSymbolEntry& entry = javaSymbols->mSymbols.valueAt(i);
+ ssize_t pos = mSymbols.indexOfKey(name);
+ if (pos < 0) {
+ entry.sourcePos.error("Symbol '%s' declared with <java-symbol> not defined\n", name.string());
+ err = UNKNOWN_ERROR;
+ continue;
+ }
+ //printf("**** setting symbol #%d/%d %s to isJavaSymbol=%d\n",
+ // i, N, name.string(), entry.isJavaSymbol ? 1 : 0);
+ mSymbols.editValueAt(pos).isJavaSymbol = entry.isJavaSymbol;
+ }
+
+ N = javaSymbols->mNestedSymbols.size();
+ for (size_t i=0; i<N; i++) {
+ const String8& name = javaSymbols->mNestedSymbols.keyAt(i);
+ const sp<AaptSymbols>& symbols = javaSymbols->mNestedSymbols.valueAt(i);
+ ssize_t pos = mNestedSymbols.indexOfKey(name);
+ if (pos < 0) {
+ SourcePos pos;
+ pos.error("Java symbol dir %s not defined\n", name.string());
+ err = UNKNOWN_ERROR;
+ continue;
+ }
+ //printf("**** applying java symbols in dir %s\n", name.string());
+ status_t myerr = mNestedSymbols.valueAt(pos)->applyJavaSymbols(symbols);
+ if (myerr != NO_ERROR) {
+ err = myerr;
+ }
+ }
+
+ return err;
+}
+
+// =========================================================================
+// =========================================================================
+// =========================================================================
+
AaptAssets::AaptAssets()
: AaptDir(String8(), String8()),
mChanged(false), mHaveIncludedAssets(false), mRes(NULL)
@@ -2399,6 +2447,48 @@ sp<AaptSymbols> AaptAssets::getSymbolsFor(const String8& name)
return sym;
}
+sp<AaptSymbols> AaptAssets::getJavaSymbolsFor(const String8& name)
+{
+ sp<AaptSymbols> sym = mJavaSymbols.valueFor(name);
+ if (sym == NULL) {
+ sym = new AaptSymbols();
+ mJavaSymbols.add(name, sym);
+ }
+ return sym;
+}
+
+status_t AaptAssets::applyJavaSymbols()
+{
+ size_t N = mJavaSymbols.size();
+ for (size_t i=0; i<N; i++) {
+ const String8& name = mJavaSymbols.keyAt(i);
+ const sp<AaptSymbols>& symbols = mJavaSymbols.valueAt(i);
+ ssize_t pos = mSymbols.indexOfKey(name);
+ if (pos < 0) {
+ SourcePos pos;
+ pos.error("Java symbol dir %s not defined\n", name.string());
+ return UNKNOWN_ERROR;
+ }
+ //printf("**** applying java symbols in dir %s\n", name.string());
+ status_t err = mSymbols.valueAt(pos)->applyJavaSymbols(symbols);
+ if (err != NO_ERROR) {
+ return err;
+ }
+ }
+
+ return NO_ERROR;
+}
+
+bool AaptAssets::isJavaSymbol(const AaptSymbolEntry& sym, bool includePrivate) const {
+ //printf("isJavaSymbol %s: public=%d, includePrivate=%d, isJavaSymbol=%d\n",
+ // sym.name.string(), sym.isPublic ? 1 : 0, includePrivate ? 1 : 0,
+ // sym.isJavaSymbol ? 1 : 0);
+ if (!mHavePrivateSymbols) return true;
+ if (sym.isPublic) return true;
+ if (includePrivate && sym.isJavaSymbol) return true;
+ return false;
+}
+
status_t AaptAssets::buildIncludedResources(Bundle* bundle)
{
if (!mHaveIncludedAssets) {
diff --git a/tools/aapt/AaptAssets.h b/tools/aapt/AaptAssets.h
index d5345b2..5924952 100644
--- a/tools/aapt/AaptAssets.h
+++ b/tools/aapt/AaptAssets.h
@@ -7,14 +7,14 @@
#define __AAPT_ASSETS_H
#include <stdlib.h>
-#include <utils/AssetManager.h>
+#include <androidfw/AssetManager.h>
+#include <androidfw/ResourceTypes.h>
#include <utils/KeyedVector.h>
-#include <utils/String8.h>
-#include <utils/ResourceTypes.h>
+#include <utils/RefBase.h>
#include <utils/SortedVector.h>
#include <utils/String8.h>
+#include <utils/String8.h>
#include <utils/Vector.h>
-#include <utils/RefBase.h>
#include "ZipFile.h"
#include "Bundle.h"
@@ -53,17 +53,6 @@ enum {
AXIS_END = AXIS_VERSION,
};
-enum {
- SDK_CUPCAKE = 3,
- SDK_DONUT = 4,
- SDK_ECLAIR = 5,
- SDK_ECLAIR_0_1 = 6,
- SDK_MR1 = 7,
- SDK_FROYO = 8,
- SDK_HONEYCOMB_MR2 = 13,
- SDK_ICE_CREAM_SANDWICH = 14,
-};
-
/**
* This structure contains a specific variation of a single file out
* of all the variations it can have that we can have.
@@ -326,16 +315,16 @@ class AaptSymbolEntry
{
public:
AaptSymbolEntry()
- : isPublic(false), typeCode(TYPE_UNKNOWN)
+ : isPublic(false), isJavaSymbol(false), typeCode(TYPE_UNKNOWN)
{
}
AaptSymbolEntry(const String8& _name)
- : name(_name), isPublic(false), typeCode(TYPE_UNKNOWN)
+ : name(_name), isPublic(false), isJavaSymbol(false), typeCode(TYPE_UNKNOWN)
{
}
AaptSymbolEntry(const AaptSymbolEntry& o)
: name(o.name), sourcePos(o.sourcePos), isPublic(o.isPublic)
- , comment(o.comment), typeComment(o.typeComment)
+ , isJavaSymbol(o.isJavaSymbol), comment(o.comment), typeComment(o.typeComment)
, typeCode(o.typeCode), int32Val(o.int32Val), stringVal(o.stringVal)
{
}
@@ -343,6 +332,7 @@ public:
{
sourcePos = o.sourcePos;
isPublic = o.isPublic;
+ isJavaSymbol = o.isJavaSymbol;
comment = o.comment;
typeComment = o.typeComment;
typeCode = o.typeCode;
@@ -355,6 +345,7 @@ public:
SourcePos sourcePos;
bool isPublic;
+ bool isJavaSymbol;
String16 comment;
String16 typeComment;
@@ -412,6 +403,15 @@ public:
return NO_ERROR;
}
+ status_t makeSymbolJavaSymbol(const String8& name, const SourcePos& pos) {
+ if (!check_valid_symbol_name(name, pos, "symbol")) {
+ return BAD_VALUE;
+ }
+ AaptSymbolEntry& sym = edit_symbol(name, &pos);
+ sym.isJavaSymbol = true;
+ return NO_ERROR;
+ }
+
void appendComment(const String8& name, const String16& comment, const SourcePos& pos) {
if (comment.size() <= 0) {
return;
@@ -452,6 +452,8 @@ public:
return sym;
}
+ status_t applyJavaSymbols(const sp<AaptSymbols>& javaSymbols);
+
const KeyedVector<String8, AaptSymbolEntry>& getSymbols() const
{ return mSymbols; }
const DefaultKeyedVector<String8, sp<AaptSymbols> >& getNestedSymbols() const
@@ -520,7 +522,11 @@ public:
virtual ~AaptAssets() { delete mRes; }
const String8& getPackage() const { return mPackage; }
- void setPackage(const String8& package) { mPackage = package; mSymbolsPrivatePackage = package; }
+ void setPackage(const String8& package) {
+ mPackage = package;
+ mSymbolsPrivatePackage = package;
+ mHavePrivateSymbols = false;
+ }
const SortedVector<AaptGroupEntry>& getGroupEntries() const;
@@ -543,11 +549,22 @@ public:
sp<AaptSymbols> getSymbolsFor(const String8& name);
+ sp<AaptSymbols> getJavaSymbolsFor(const String8& name);
+
+ status_t applyJavaSymbols();
+
const DefaultKeyedVector<String8, sp<AaptSymbols> >& getSymbols() const { return mSymbols; }
String8 getSymbolsPrivatePackage() const { return mSymbolsPrivatePackage; }
- void setSymbolsPrivatePackage(const String8& pkg) { mSymbolsPrivatePackage = pkg; }
-
+ void setSymbolsPrivatePackage(const String8& pkg) {
+ mSymbolsPrivatePackage = pkg;
+ mHavePrivateSymbols = mSymbolsPrivatePackage != mPackage;
+ }
+
+ bool havePrivateSymbols() const { return mHavePrivateSymbols; }
+
+ bool isJavaSymbol(const AaptSymbolEntry& sym, bool includePrivate) const;
+
status_t buildIncludedResources(Bundle* bundle);
status_t addIncludedResources(const sp<AaptFile>& file);
const ResTable& getIncludedResources() const;
@@ -587,7 +604,9 @@ private:
String8 mPackage;
SortedVector<AaptGroupEntry> mGroupEntries;
DefaultKeyedVector<String8, sp<AaptSymbols> > mSymbols;
+ DefaultKeyedVector<String8, sp<AaptSymbols> > mJavaSymbols;
String8 mSymbolsPrivatePackage;
+ bool mHavePrivateSymbols;
Vector<sp<AaptDir> > mResDirs;
diff --git a/tools/aapt/Android.mk b/tools/aapt/Android.mk
index cb55a9c..d0a81dc 100644
--- a/tools/aapt/Android.mk
+++ b/tools/aapt/Android.mk
@@ -38,6 +38,7 @@ LOCAL_C_INCLUDES += build/libs/host/include
#LOCAL_WHOLE_STATIC_LIBRARIES :=
LOCAL_STATIC_LIBRARIES := \
libhost \
+ libandroidfw \
libutils \
libcutils \
libexpat \
diff --git a/tools/aapt/Bundle.h b/tools/aapt/Bundle.h
index 2d1060b..daeadc0 100644
--- a/tools/aapt/Bundle.h
+++ b/tools/aapt/Bundle.h
@@ -14,6 +14,18 @@
#include <utils/String8.h>
#include <utils/Vector.h>
+enum {
+ SDK_CUPCAKE = 3,
+ SDK_DONUT = 4,
+ SDK_ECLAIR = 5,
+ SDK_ECLAIR_0_1 = 6,
+ SDK_MR1 = 7,
+ SDK_FROYO = 8,
+ SDK_HONEYCOMB_MR2 = 13,
+ SDK_ICE_CREAM_SANDWICH = 14,
+ SDK_ICE_CREAM_SANDWICH_MR1 = 15,
+};
+
/*
* Things we can do.
*/
@@ -71,7 +83,7 @@ public:
bool getForce(void) const { return mForce; }
void setForce(bool val) { mForce = val; }
void setGrayscaleTolerance(int val) { mGrayscaleTolerance = val; }
- int getGrayscaleTolerance() { return mGrayscaleTolerance; }
+ int getGrayscaleTolerance() const { return mGrayscaleTolerance; }
bool getMakePackageDirs(void) const { return mMakePackageDirs; }
void setMakePackageDirs(bool val) { mMakePackageDirs = val; }
bool getUpdate(void) const { return mUpdate; }
@@ -82,7 +94,6 @@ public:
void setRequireLocalization(bool val) { mRequireLocalization = val; }
bool getPseudolocalize(void) const { return mPseudolocalize; }
void setPseudolocalize(bool val) { mPseudolocalize = val; }
- bool getWantUTF16(void) const { return mWantUTF16; }
void setWantUTF16(bool val) { mWantUTF16 = val; }
bool getValues(void) const { return mValues; }
void setValues(bool val) { mValues = val; }
@@ -103,6 +114,10 @@ public:
bool getGenDependencies() { return mGenDependencies; }
void setGenDependencies(bool val) { mGenDependencies = val; }
+ bool getUTF16StringsOption() {
+ return mWantUTF16 || !isMinSdkAtLeast(SDK_FROYO);
+ }
+
/*
* Input options.
*/
@@ -151,14 +166,14 @@ public:
void setExtraPackages(const char* val) { mExtraPackages = val; }
const char* getMaxResVersion() const { return mMaxResVersion; }
void setMaxResVersion(const char * val) { mMaxResVersion = val; }
- bool getDebugMode() { return mDebugMode; }
+ bool getDebugMode() const { return mDebugMode; }
void setDebugMode(bool val) { mDebugMode = val; }
- bool getNonConstantId() { return mNonConstantId; }
+ bool getNonConstantId() const { return mNonConstantId; }
void setNonConstantId(bool val) { mNonConstantId = val; }
const char* getProduct() const { return mProduct; }
void setProduct(const char * val) { mProduct = val; }
void setUseCrunchCache(bool val) { mUseCrunchCache = val; }
- bool getUseCrunchCache() { return mUseCrunchCache; }
+ bool getUseCrunchCache() const { return mUseCrunchCache; }
/*
* Set and get the file specification.
diff --git a/tools/aapt/Command.cpp b/tools/aapt/Command.cpp
index 637c27d..a4473c8 100644
--- a/tools/aapt/Command.cpp
+++ b/tools/aapt/Command.cpp
@@ -345,6 +345,7 @@ enum {
LABEL_ATTR = 0x01010001,
ICON_ATTR = 0x01010002,
NAME_ATTR = 0x01010003,
+ DEBUGGABLE_ATTR = 0x0101000f,
VERSION_CODE_ATTR = 0x0101021b,
VERSION_NAME_ATTR = 0x0101021c,
SCREEN_ORIENTATION_ATTR = 0x0101001e,
@@ -425,6 +426,7 @@ static void printCompatibleScreens(ResXMLTree& tree) {
/*
* Handle the "dump" command, to extract select data from an archive.
*/
+extern char CONSOLE_DATA[2925]; // see EOF
int doDump(Bundle* bundle)
{
status_t result = UNKNOWN_ERROR;
@@ -478,6 +480,11 @@ int doDump(Bundle* bundle)
#ifndef HAVE_ANDROID_OS
res.print(bundle->getValues());
#endif
+
+ } else if (strcmp("strings", option) == 0) {
+ const ResStringPool* pool = res.getTableStringBlock(0);
+ printStringPool(pool);
+
} else if (strcmp("xmltree", option) == 0) {
if (bundle->getFileSpecCount() < 3) {
fprintf(stderr, "ERROR: no dump xmltree resource file specified\n");
@@ -625,6 +632,20 @@ int doDump(Bundle* bundle)
bool actImeService = false;
bool actWallpaperService = false;
+ // These two implement the implicit permissions that are granted
+ // to pre-1.6 applications.
+ bool hasWriteExternalStoragePermission = false;
+ bool hasReadPhoneStatePermission = false;
+
+ // If an app requests write storage, they will also get read storage.
+ bool hasReadExternalStoragePermission = false;
+
+ // Implement transition to read and write call log.
+ bool hasReadContactsPermission = false;
+ bool hasWriteContactsPermission = false;
+ bool hasReadCallLogPermission = false;
+ bool hasWriteCallLogPermission = false;
+
// This next group of variables is used to implement a group of
// backward-compatibility heuristics necessitated by the addition of
// some new uses-feature constants in 2.1 and 2.2. In most cases, the
@@ -810,6 +831,15 @@ int doDump(Bundle* bundle)
if (testOnly != 0) {
printf("testOnly='%d'\n", testOnly);
}
+
+ int32_t debuggable = getResolvedIntegerAttribute(&res, tree, DEBUGGABLE_ATTR, &error, 0);
+ if (error != "") {
+ fprintf(stderr, "ERROR getting 'android:debuggable' attribute: %s\n", error.string());
+ goto bail;
+ }
+ if (debuggable != 0) {
+ printf("application-debuggable\n");
+ }
} else if (tag == "uses-sdk") {
int32_t code = getIntegerAttribute(tree, MIN_SDK_VERSION_ATTR, &error);
if (error != "") {
@@ -986,6 +1016,20 @@ int doDump(Bundle* bundle)
name == "android.permission.WRITE_APN_SETTINGS" ||
name == "android.permission.WRITE_SMS") {
hasTelephonyPermission = true;
+ } else if (name == "android.permission.WRITE_EXTERNAL_STORAGE") {
+ hasWriteExternalStoragePermission = true;
+ } else if (name == "android.permission.READ_EXTERNAL_STORAGE") {
+ hasReadExternalStoragePermission = true;
+ } else if (name == "android.permission.READ_PHONE_STATE") {
+ hasReadPhoneStatePermission = true;
+ } else if (name == "android.permission.READ_CONTACTS") {
+ hasReadContactsPermission = true;
+ } else if (name == "android.permission.WRITE_CONTACTS") {
+ hasWriteContactsPermission = true;
+ } else if (name == "android.permission.READ_CALL_LOG") {
+ hasReadCallLogPermission = true;
+ } else if (name == "android.permission.WRITE_CALL_LOG") {
+ hasWriteCallLogPermission = true;
}
printf("uses-permission:'%s'\n", name.string());
} else {
@@ -1144,6 +1188,43 @@ int doDump(Bundle* bundle)
}
}
+ // Pre-1.6 implicitly granted permission compatibility logic
+ if (targetSdk < 4) {
+ if (!hasWriteExternalStoragePermission) {
+ printf("uses-permission:'android.permission.WRITE_EXTERNAL_STORAGE'\n");
+ printf("uses-implied-permission:'android.permission.WRITE_EXTERNAL_STORAGE'," \
+ "'targetSdkVersion < 4'\n");
+ hasWriteExternalStoragePermission = true;
+ }
+ if (!hasReadPhoneStatePermission) {
+ printf("uses-permission:'android.permission.READ_PHONE_STATE'\n");
+ printf("uses-implied-permission:'android.permission.READ_PHONE_STATE'," \
+ "'targetSdkVersion < 4'\n");
+ }
+ }
+
+ // If the application has requested WRITE_EXTERNAL_STORAGE, we will
+ // force them to always take READ_EXTERNAL_STORAGE as well.
+ if (!hasReadExternalStoragePermission && hasWriteExternalStoragePermission) {
+ printf("uses-permission:'android.permission.READ_EXTERNAL_STORAGE'\n");
+ printf("uses-implied-permission:'android.permission.READ_EXTERNAL_STORAGE'," \
+ "'requested WRITE_EXTERNAL_STORAGE'\n");
+ }
+
+ // Pre-JellyBean call log permission compatibility.
+ if (targetSdk < 16) {
+ if (!hasReadCallLogPermission && hasReadContactsPermission) {
+ printf("uses-permission:'android.permission.READ_CALL_LOG'\n");
+ printf("uses-implied-permission:'android.permission.READ_CALL_LOG'," \
+ "'targetSdkVersion < 16 and requested READ_CONTACTS'\n");
+ }
+ if (!hasWriteCallLogPermission && hasWriteContactsPermission) {
+ printf("uses-permission:'android.permission.WRITE_CALL_LOG'\n");
+ printf("uses-implied-permission:'android.permission.WRITE_CALL_LOG'," \
+ "'targetSdkVersion < 16 and requested WRITE_CONTACTS'\n");
+ }
+ }
+
/* The following blocks handle printing "inferred" uses-features, based
* on whether related features or permissions are used by the app.
* Note that the various spec*Feature variables denote whether the
@@ -1152,10 +1233,18 @@ int doDump(Bundle* bundle)
*/
// Camera-related back-compatibility logic
if (!specCameraFeature) {
- if (reqCameraFlashFeature || reqCameraAutofocusFeature) {
+ if (reqCameraFlashFeature) {
+ // if app requested a sub-feature (autofocus or flash) and didn't
+ // request the base camera feature, we infer that it meant to
+ printf("uses-feature:'android.hardware.camera'\n");
+ printf("uses-implied-feature:'android.hardware.camera'," \
+ "'requested android.hardware.camera.flash feature'\n");
+ } else if (reqCameraAutofocusFeature) {
// if app requested a sub-feature (autofocus or flash) and didn't
// request the base camera feature, we infer that it meant to
printf("uses-feature:'android.hardware.camera'\n");
+ printf("uses-implied-feature:'android.hardware.camera'," \
+ "'requested android.hardware.camera.autofocus feature'\n");
} else if (hasCameraPermission) {
// if app wants to use camera but didn't request the feature, we infer
// that it meant to, and further that it wants autofocus
@@ -1163,6 +1252,8 @@ int doDump(Bundle* bundle)
printf("uses-feature:'android.hardware.camera'\n");
if (!specCameraAutofocusFeature) {
printf("uses-feature:'android.hardware.camera.autofocus'\n");
+ printf("uses-implied-feature:'android.hardware.camera.autofocus'," \
+ "'requested android.permission.CAMERA permission'\n");
}
}
}
@@ -1174,16 +1265,22 @@ int doDump(Bundle* bundle)
// if app either takes a location-related permission or requests one of the
// sub-features, we infer that it also meant to request the base location feature
printf("uses-feature:'android.hardware.location'\n");
+ printf("uses-implied-feature:'android.hardware.location'," \
+ "'requested a location access permission'\n");
}
if (!specGpsFeature && hasGpsPermission) {
// if app takes GPS (FINE location) perm but does not request the GPS
// feature, we infer that it meant to
printf("uses-feature:'android.hardware.location.gps'\n");
+ printf("uses-implied-feature:'android.hardware.location.gps'," \
+ "'requested android.permission.ACCESS_FINE_LOCATION permission'\n");
}
if (!specNetworkLocFeature && hasCoarseLocPermission) {
// if app takes Network location (COARSE location) perm but does not request the
// network location feature, we infer that it meant to
printf("uses-feature:'android.hardware.location.network'\n");
+ printf("uses-implied-feature:'android.hardware.location.network'," \
+ "'requested android.permission.ACCESS_COURSE_LOCATION permission'\n");
}
// Bluetooth-related compatibility logic
@@ -1191,6 +1288,9 @@ int doDump(Bundle* bundle)
// if app takes a Bluetooth permission but does not request the Bluetooth
// feature, we infer that it meant to
printf("uses-feature:'android.hardware.bluetooth'\n");
+ printf("uses-implied-feature:'android.hardware.bluetooth'," \
+ "'requested android.permission.BLUETOOTH or android.permission.BLUETOOTH_ADMIN " \
+ "permission and targetSdkVersion > 4'\n");
}
// Microphone-related compatibility logic
@@ -1198,6 +1298,8 @@ int doDump(Bundle* bundle)
// if app takes the record-audio permission but does not request the microphone
// feature, we infer that it meant to
printf("uses-feature:'android.hardware.microphone'\n");
+ printf("uses-implied-feature:'android.hardware.microphone'," \
+ "'requested android.permission.RECORD_AUDIO permission'\n");
}
// WiFi-related compatibility logic
@@ -1205,6 +1307,10 @@ int doDump(Bundle* bundle)
// if app takes one of the WiFi permissions but does not request the WiFi
// feature, we infer that it meant to
printf("uses-feature:'android.hardware.wifi'\n");
+ printf("uses-implied-feature:'android.hardware.wifi'," \
+ "'requested android.permission.ACCESS_WIFI_STATE, " \
+ "android.permission.CHANGE_WIFI_STATE, or " \
+ "android.permission.CHANGE_WIFI_MULTICAST_STATE permission'\n");
}
// Telephony-related compatibility logic
@@ -1212,6 +1318,8 @@ int doDump(Bundle* bundle)
// if app takes one of the telephony permissions or requests a sub-feature but
// does not request the base telephony feature, we infer that it meant to
printf("uses-feature:'android.hardware.telephony'\n");
+ printf("uses-implied-feature:'android.hardware.telephony'," \
+ "'requested a telephony-related permission or feature'\n");
}
// Touchscreen-related back-compatibility logic
@@ -1221,11 +1329,15 @@ int doDump(Bundle* bundle)
// Note that specTouchscreenFeature is true if the tag is present, regardless
// of whether its value is true or false, so this is safe
printf("uses-feature:'android.hardware.touchscreen'\n");
+ printf("uses-implied-feature:'android.hardware.touchscreen'," \
+ "'assumed you require a touch screen unless explicitly made optional'\n");
}
if (!specMultitouchFeature && reqDistinctMultitouchFeature) {
// if app takes one of the telephony permissions or requests a sub-feature but
// does not request the base telephony feature, we infer that it meant to
printf("uses-feature:'android.hardware.touchscreen.multitouch'\n");
+ printf("uses-implied-feature:'android.hardware.touchscreen.multitouch'," \
+ "'requested android.hardware.touchscreen.multitouch.distinct feature'\n");
}
// Landscape/portrait-related compatibility logic
@@ -1235,9 +1347,13 @@ int doDump(Bundle* bundle)
// orientation is required.
if (reqScreenLandscapeFeature) {
printf("uses-feature:'android.hardware.screen.landscape'\n");
+ printf("uses-implied-feature:'android.hardware.screen.landscape'," \
+ "'one or more activities have specified a landscape orientation'\n");
}
if (reqScreenPortraitFeature) {
printf("uses-feature:'android.hardware.screen.portrait'\n");
+ printf("uses-implied-feature:'android.hardware.screen.portrait'," \
+ "'one or more activities have specified a portrait orientation'\n");
}
}
@@ -1361,6 +1477,8 @@ int doDump(Bundle* bundle)
}
delete dir;
}
+ } else if (strcmp("badger", option) == 0) {
+ printf("%s", CONSOLE_DATA);
} else if (strcmp("configurations", option) == 0) {
Vector<ResTable_config> configs;
res.getConfigurations(&configs);
@@ -1590,6 +1708,12 @@ int doPackage(Bundle* bundle)
goto bail;
}
+ // Update symbols with information about which ones are needed as Java symbols.
+ assets->applyJavaSymbols();
+ if (SourcePos::hasErrors()) {
+ goto bail;
+ }
+
// If we've been asked to generate a dependency file, do that here
if (bundle->getGenDependencies()) {
// If this is the packaging step, generate the dependency file next to
@@ -1611,7 +1735,7 @@ int doPackage(Bundle* bundle)
}
// Write out R.java constants
- if (assets->getPackage() == assets->getSymbolsPrivatePackage()) {
+ if (!assets->havePrivateSymbols()) {
if (bundle->getCustomPackage() == NULL) {
// Write the R.java file into the appropriate class directory
// e.g. gen/com/foo/app/R.java
@@ -1709,3 +1833,169 @@ int doCrunch(Bundle* bundle)
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,
+ 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, 32, 32, 32, 10, 32, 32, 32, 32, 32, 32, 32,
+ 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 61, 63,
+ 86, 35, 40, 46, 46, 95, 95, 95, 95, 97, 97, 44, 32, 46, 124, 42, 33, 83,
+ 62, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+ 32, 32, 32, 10, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+ 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 58, 46, 58, 59, 61, 59, 61, 81,
+ 81, 81, 81, 66, 96, 61, 61, 58, 46, 46, 46, 58, 32, 32, 32, 32, 32, 32,
+ 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 10, 32, 32, 32,
+ 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+ 32, 32, 32, 46, 61, 59, 59, 59, 58, 106, 81, 81, 81, 81, 102, 59, 61, 59,
+ 59, 61, 61, 61, 58, 46, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+ 32, 32, 32, 32, 32, 32, 32, 10, 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, 61, 59, 59,
+ 59, 58, 109, 81, 81, 81, 81, 61, 59, 59, 59, 59, 59, 58, 59, 59, 46, 32,
+ 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+ 10, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+ 32, 32, 32, 32, 32, 32, 32, 46, 61, 59, 59, 59, 60, 81, 81, 81, 81, 87,
+ 58, 59, 59, 59, 59, 59, 59, 61, 119, 44, 32, 32, 32, 32, 32, 32, 32, 32,
+ 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 10, 32, 32, 32, 32, 32, 32,
+ 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 46,
+ 47, 61, 59, 59, 58, 100, 81, 81, 81, 81, 35, 58, 59, 59, 59, 59, 59, 58,
+ 121, 81, 91, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+ 32, 32, 32, 32, 10, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+ 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 46, 109, 58, 59, 59, 61, 81, 81,
+ 81, 81, 81, 109, 58, 59, 59, 59, 59, 61, 109, 81, 81, 76, 46, 32, 32, 32,
+ 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 10, 32, 32,
+ 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+ 32, 32, 32, 41, 87, 59, 61, 59, 41, 81, 81, 81, 81, 81, 81, 59, 61, 59,
+ 59, 58, 109, 81, 81, 87, 39, 46, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+ 32, 32, 32, 32, 32, 32, 32, 32, 10, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+ 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 60, 81, 91, 59,
+ 59, 61, 81, 81, 81, 81, 81, 87, 43, 59, 58, 59, 60, 81, 81, 81, 76, 32,
+ 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+ 32, 10, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+ 32, 32, 32, 32, 32, 32, 32, 32, 52, 91, 58, 45, 59, 87, 81, 81, 81, 81,
+ 70, 58, 58, 58, 59, 106, 81, 81, 81, 91, 32, 32, 32, 32, 32, 32, 32, 32,
+ 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 10, 32, 32, 32, 32, 32,
+ 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+ 32, 93, 40, 32, 46, 59, 100, 81, 81, 81, 81, 40, 58, 46, 46, 58, 100, 81,
+ 81, 68, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+ 32, 32, 32, 32, 32, 10, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+ 32, 46, 46, 46, 32, 46, 46, 46, 32, 46, 32, 46, 45, 91, 59, 61, 58, 109,
+ 81, 81, 81, 87, 46, 58, 61, 59, 60, 81, 81, 80, 32, 32, 32, 32, 32, 32,
+ 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 10, 32,
+ 32, 32, 32, 32, 32, 32, 32, 46, 46, 61, 59, 61, 61, 61, 59, 61, 61, 59,
+ 59, 59, 58, 58, 46, 46, 41, 58, 59, 58, 81, 81, 81, 81, 69, 58, 59, 59,
+ 60, 81, 81, 68, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+ 32, 32, 32, 32, 32, 32, 32, 32, 32, 10, 32, 32, 32, 32, 32, 32, 58, 59,
+ 61, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 61, 61, 46,
+ 61, 59, 93, 81, 81, 81, 81, 107, 58, 59, 58, 109, 87, 68, 96, 32, 32, 32,
+ 46, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+ 32, 32, 10, 32, 32, 32, 46, 60, 61, 61, 59, 59, 59, 59, 59, 59, 59, 59,
+ 59, 59, 59, 59, 59, 59, 59, 59, 59, 58, 58, 58, 115, 109, 68, 41, 36, 81,
+ 109, 46, 61, 61, 81, 69, 96, 46, 58, 58, 46, 58, 46, 46, 32, 32, 32, 32,
+ 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 10, 46, 32, 95, 81,
+ 67, 61, 61, 58, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59,
+ 59, 59, 59, 59, 58, 68, 39, 61, 105, 61, 63, 81, 119, 58, 106, 80, 32, 58,
+ 61, 59, 59, 61, 59, 61, 59, 61, 46, 95, 32, 32, 32, 32, 32, 32, 32, 32,
+ 32, 32, 32, 32, 32, 32, 10, 32, 32, 36, 81, 109, 105, 59, 61, 59, 59, 59,
+ 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 46, 58, 37,
+ 73, 108, 108, 62, 52, 81, 109, 34, 32, 61, 59, 59, 59, 59, 59, 59, 59, 59,
+ 59, 61, 59, 61, 61, 46, 46, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 10,
+ 32, 46, 45, 57, 101, 43, 43, 61, 61, 59, 59, 59, 59, 59, 59, 61, 59, 59,
+ 59, 59, 59, 59, 59, 59, 59, 58, 97, 46, 61, 108, 62, 126, 58, 106, 80, 96,
+ 46, 61, 61, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 61, 61,
+ 97, 103, 97, 32, 32, 32, 32, 32, 32, 32, 10, 32, 32, 32, 32, 45, 46, 32,
+ 46, 32, 32, 32, 32, 32, 32, 32, 32, 45, 45, 45, 58, 59, 59, 59, 59, 61,
+ 119, 81, 97, 124, 105, 124, 124, 39, 126, 95, 119, 58, 61, 58, 59, 59, 59,
+ 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 61, 119, 81, 81, 99, 32, 32,
+ 32, 32, 32, 32, 10, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+ 32, 32, 32, 32, 32, 32, 32, 58, 59, 59, 58, 106, 81, 81, 81, 109, 119,
+ 119, 119, 109, 109, 81, 81, 122, 58, 59, 59, 59, 59, 59, 59, 59, 59, 59,
+ 59, 59, 59, 59, 59, 58, 115, 81, 87, 81, 102, 32, 32, 32, 32, 32, 32, 10,
+ 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+ 32, 32, 61, 58, 59, 61, 81, 81, 81, 81, 81, 81, 87, 87, 81, 81, 81, 81,
+ 81, 58, 59, 59, 59, 59, 59, 59, 59, 59, 58, 45, 45, 45, 59, 59, 59, 41,
+ 87, 66, 33, 32, 32, 32, 32, 32, 32, 32, 10, 32, 32, 32, 32, 32, 32, 32,
+ 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 58, 59, 59, 93, 81,
+ 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 40, 58, 59, 59, 59, 58,
+ 45, 32, 46, 32, 32, 32, 32, 32, 46, 32, 126, 96, 32, 32, 32, 32, 32, 32,
+ 32, 32, 32, 10, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+ 32, 32, 32, 32, 32, 32, 58, 61, 59, 58, 81, 81, 81, 81, 81, 81, 81, 81,
+ 81, 81, 81, 81, 81, 40, 58, 59, 59, 59, 58, 32, 32, 32, 32, 32, 32, 32,
+ 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 10, 32, 32, 32,
+ 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 58,
+ 59, 59, 58, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 40, 58,
+ 59, 59, 59, 46, 46, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+ 32, 32, 32, 32, 32, 32, 32, 10, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+ 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 58, 61, 59, 60, 81, 81, 81, 81,
+ 81, 81, 81, 81, 81, 81, 81, 81, 81, 59, 61, 59, 59, 61, 32, 32, 32, 32,
+ 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+ 10, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+ 32, 32, 32, 58, 59, 59, 93, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81,
+ 81, 81, 40, 59, 59, 59, 59, 32, 46, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+ 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 10, 32, 32, 32, 32, 32, 32,
+ 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 58, 61, 58, 106,
+ 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 76, 58, 59, 59, 59,
+ 32, 46, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+ 32, 32, 32, 32, 10, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+ 32, 32, 32, 32, 32, 32, 32, 61, 58, 58, 81, 81, 81, 81, 81, 81, 81, 81,
+ 81, 81, 81, 81, 81, 87, 58, 59, 59, 59, 59, 32, 46, 32, 32, 32, 32, 32,
+ 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 10, 32, 32,
+ 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+ 58, 59, 61, 41, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 87, 59,
+ 61, 58, 59, 59, 46, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+ 32, 32, 32, 32, 32, 32, 32, 32, 10, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+ 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 58, 61, 58, 61, 81, 81, 81,
+ 81, 81, 81, 81, 81, 81, 81, 81, 81, 107, 58, 59, 59, 59, 59, 58, 32, 32,
+ 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+ 32, 10, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+ 32, 32, 32, 32, 58, 59, 59, 58, 51, 81, 81, 81, 81, 81, 81, 81, 81, 81,
+ 81, 102, 94, 59, 59, 59, 59, 59, 61, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+ 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 10, 32, 32, 32, 32, 32,
+ 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 58, 61, 59,
+ 59, 59, 43, 63, 36, 81, 81, 81, 87, 64, 86, 102, 58, 59, 59, 59, 59, 59,
+ 59, 59, 46, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+ 32, 32, 32, 32, 32, 10, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+ 32, 32, 32, 32, 32, 32, 32, 46, 61, 59, 59, 59, 59, 59, 59, 59, 43, 33,
+ 58, 126, 126, 58, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 32, 46, 32, 32,
+ 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 10, 32,
+ 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 46,
+ 61, 59, 59, 59, 58, 45, 58, 61, 59, 58, 58, 58, 61, 59, 59, 59, 59, 59,
+ 59, 59, 59, 59, 59, 59, 59, 58, 32, 46, 32, 32, 32, 32, 32, 32, 32, 32,
+ 32, 32, 32, 32, 32, 32, 32, 32, 32, 10, 32, 32, 32, 32, 32, 32, 32, 32,
+ 32, 32, 32, 32, 32, 32, 32, 32, 32, 46, 61, 59, 59, 59, 59, 59, 58, 95,
+ 32, 45, 61, 59, 61, 59, 59, 59, 59, 59, 59, 59, 45, 58, 59, 59, 59, 59,
+ 61, 58, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+ 32, 32, 10, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+ 32, 32, 58, 61, 59, 59, 59, 59, 59, 61, 59, 61, 46, 46, 32, 45, 45, 45,
+ 59, 58, 45, 45, 46, 58, 59, 59, 59, 59, 59, 59, 61, 46, 32, 32, 32, 32,
+ 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 10, 32, 32, 32, 32,
+ 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 46, 58, 59, 59, 59, 59,
+ 59, 59, 59, 59, 59, 61, 59, 46, 32, 32, 46, 32, 46, 32, 58, 61, 59, 59,
+ 59, 59, 59, 59, 59, 59, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+ 32, 32, 32, 32, 32, 32, 10, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+ 32, 32, 32, 32, 32, 32, 32, 45, 59, 59, 59, 59, 59, 59, 59, 59, 58, 32,
+ 32, 32, 32, 32, 32, 32, 32, 32, 61, 59, 59, 59, 59, 59, 59, 59, 58, 32,
+ 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 10,
+ 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+ 46, 61, 59, 59, 59, 59, 59, 59, 59, 32, 46, 32, 32, 32, 32, 32, 32, 61,
+ 46, 61, 59, 59, 59, 59, 59, 59, 58, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+ 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 10, 32, 32, 32, 32, 32, 32, 32,
+ 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 61, 59, 59, 59, 59, 59, 59,
+ 59, 59, 32, 46, 32, 32, 32, 32, 32, 32, 32, 46, 61, 58, 59, 59, 59, 59,
+ 59, 58, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+ 32, 32, 32, 10, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+ 32, 32, 32, 32, 58, 59, 59, 59, 59, 59, 59, 59, 59, 46, 46, 32, 32, 32,
+ 32, 32, 32, 32, 61, 59, 59, 59, 59, 59, 59, 59, 45, 32, 32, 32, 32, 32,
+ 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 10, 32, 32, 32,
+ 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 46, 32, 45, 61,
+ 59, 59, 59, 59, 59, 58, 32, 46, 32, 32, 32, 32, 32, 32, 32, 58, 59, 59,
+ 59, 59, 59, 58, 45, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+ 32, 32, 32, 32, 32, 32, 32, 10, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+ 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 45, 45, 45, 45, 32, 46, 32,
+ 32, 32, 32, 32, 32, 32, 32, 32, 32, 45, 61, 59, 58, 45, 45, 32, 32, 32,
+ 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+ 10, 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, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+ 32, 32, 46, 32, 32, 46, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+ 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 10
+ };
diff --git a/tools/aapt/Images.cpp b/tools/aapt/Images.cpp
index ffbe875..9de685a 100644
--- a/tools/aapt/Images.cpp
+++ b/tools/aapt/Images.cpp
@@ -8,7 +8,7 @@
#include "Images.h"
-#include <utils/ResourceTypes.h>
+#include <androidfw/ResourceTypes.h>
#include <utils/ByteOrder.h>
#include <png.h>
@@ -57,6 +57,13 @@ struct image_info
bool is9Patch;
Res_png_9patch info9Patch;
+ // Layout padding, if relevant
+ bool haveLayoutBounds;
+ int32_t layoutBoundsLeft;
+ int32_t layoutBoundsTop;
+ int32_t layoutBoundsRight;
+ int32_t layoutBoundsBottom;
+
png_uint_32 allocHeight;
png_bytepp allocRows;
};
@@ -129,33 +136,62 @@ static void read_png(const char* imageName,
&interlace_type, &compression_type, NULL);
}
-static bool is_tick(png_bytep p, bool transparent, const char** outError)
+#define COLOR_TRANSPARENT 0
+#define COLOR_WHITE 0xFFFFFFFF
+#define COLOR_TICK 0xFF000000
+#define COLOR_LAYOUT_BOUNDS_TICK 0xFF0000FF
+
+enum {
+ TICK_TYPE_NONE,
+ TICK_TYPE_TICK,
+ TICK_TYPE_LAYOUT_BOUNDS,
+ TICK_TYPE_BOTH
+};
+
+static int tick_type(png_bytep p, bool transparent, const char** outError)
{
+ png_uint_32 color = p[0] | (p[1] << 8) | (p[2] << 16) | (p[3] << 24);
+
if (transparent) {
if (p[3] == 0) {
- return false;
+ return TICK_TYPE_NONE;
+ }
+ if (color == COLOR_LAYOUT_BOUNDS_TICK) {
+ return TICK_TYPE_LAYOUT_BOUNDS;
}
+ if (color == COLOR_TICK) {
+ return TICK_TYPE_TICK;
+ }
+
+ // Error cases
if (p[3] != 0xff) {
*outError = "Frame pixels must be either solid or transparent (not intermediate alphas)";
- return false;
+ return TICK_TYPE_NONE;
}
if (p[0] != 0 || p[1] != 0 || p[2] != 0) {
- *outError = "Ticks in transparent frame must be black";
+ *outError = "Ticks in transparent frame must be black or red";
}
- return true;
+ return TICK_TYPE_TICK;
}
if (p[3] != 0xFF) {
*outError = "White frame must be a solid color (no alpha)";
}
- if (p[0] == 0xFF && p[1] == 0xFF && p[2] == 0xFF) {
- return false;
+ if (color == COLOR_WHITE) {
+ return TICK_TYPE_NONE;
+ }
+ if (color == COLOR_TICK) {
+ return TICK_TYPE_TICK;
}
+ if (color == COLOR_LAYOUT_BOUNDS_TICK) {
+ return TICK_TYPE_LAYOUT_BOUNDS;
+ }
+
if (p[0] != 0 || p[1] != 0 || p[2] != 0) {
- *outError = "Ticks in white frame must be black";
- return false;
+ *outError = "Ticks in white frame must be black or red";
+ return TICK_TYPE_NONE;
}
- return true;
+ return TICK_TYPE_TICK;
}
enum {
@@ -175,7 +211,7 @@ static status_t get_horizontal_ticks(
bool found = false;
for (i=1; i<width-1; i++) {
- if (is_tick(row+i*4, transparent, outError)) {
+ if (TICK_TYPE_TICK == tick_type(row+i*4, transparent, outError)) {
if (state == TICK_START ||
(state == TICK_OUTSIDE_1 && multipleAllowed)) {
*outLeft = i-1;
@@ -224,7 +260,7 @@ static status_t get_vertical_ticks(
bool found = false;
for (i=1; i<height-1; i++) {
- if (is_tick(rows[i]+offset, transparent, outError)) {
+ if (TICK_TYPE_TICK == tick_type(rows[i]+offset, transparent, outError)) {
if (state == TICK_START ||
(state == TICK_OUTSIDE_1 && multipleAllowed)) {
*outTop = i-1;
@@ -262,6 +298,83 @@ static status_t get_vertical_ticks(
return NO_ERROR;
}
+static status_t get_horizontal_layout_bounds_ticks(
+ png_bytep row, int width, bool transparent, bool required,
+ int32_t* outLeft, int32_t* outRight, const char** outError)
+{
+ int i;
+ *outLeft = *outRight = 0;
+
+ // Look for left tick
+ if (TICK_TYPE_LAYOUT_BOUNDS == tick_type(row + 4, transparent, outError)) {
+ // Starting with a layout padding tick
+ i = 1;
+ while (i < width - 1) {
+ (*outLeft)++;
+ i++;
+ int tick = tick_type(row + i * 4, transparent, outError);
+ if (tick != TICK_TYPE_LAYOUT_BOUNDS) {
+ break;
+ }
+ }
+ }
+
+ // Look for right tick
+ if (TICK_TYPE_LAYOUT_BOUNDS == tick_type(row + (width - 2) * 4, transparent, outError)) {
+ // Ending with a layout padding tick
+ i = width - 2;
+ while (i > 1) {
+ (*outRight)++;
+ i--;
+ int tick = tick_type(row+i*4, transparent, outError);
+ if (tick != TICK_TYPE_LAYOUT_BOUNDS) {
+ break;
+ }
+ }
+ }
+
+ return NO_ERROR;
+}
+
+static status_t get_vertical_layout_bounds_ticks(
+ png_bytepp rows, int offset, int height, bool transparent, bool required,
+ int32_t* outTop, int32_t* outBottom, const char** outError)
+{
+ int i;
+ *outTop = *outBottom = 0;
+
+ // Look for top tick
+ if (TICK_TYPE_LAYOUT_BOUNDS == tick_type(rows[1] + offset, transparent, outError)) {
+ // Starting with a layout padding tick
+ i = 1;
+ while (i < height - 1) {
+ (*outTop)++;
+ i++;
+ int tick = tick_type(rows[i] + offset, transparent, outError);
+ if (tick != TICK_TYPE_LAYOUT_BOUNDS) {
+ break;
+ }
+ }
+ }
+
+ // Look for bottom tick
+ if (TICK_TYPE_LAYOUT_BOUNDS == tick_type(rows[height - 2] + offset, transparent, outError)) {
+ // Ending with a layout padding tick
+ i = height - 2;
+ while (i > 1) {
+ (*outBottom)++;
+ i--;
+ int tick = tick_type(rows[i] + offset, transparent, outError);
+ if (tick != TICK_TYPE_LAYOUT_BOUNDS) {
+ break;
+ }
+ }
+ }
+
+ return NO_ERROR;
+}
+
+
static uint32_t get_color(
png_bytepp rows, int left, int top, int right, int bottom)
{
@@ -353,6 +466,9 @@ static status_t do_9patch(const char* imageName, image_info* image)
image->info9Patch.paddingLeft = image->info9Patch.paddingRight =
image->info9Patch.paddingTop = image->info9Patch.paddingBottom = -1;
+ image->layoutBoundsLeft = image->layoutBoundsRight =
+ image->layoutBoundsTop = image->layoutBoundsBottom = 0;
+
png_bytep p = image->rows[0];
bool transparent = p[3] == 0;
bool hasColor = false;
@@ -408,6 +524,25 @@ static status_t do_9patch(const char* imageName, image_info* image)
goto getout;
}
+ // Find left and right of layout padding...
+ get_horizontal_layout_bounds_ticks(image->rows[H-1], W, transparent, false,
+ &image->layoutBoundsLeft,
+ &image->layoutBoundsRight, &errorMsg);
+
+ get_vertical_layout_bounds_ticks(image->rows, (W-1)*4, H, transparent, false,
+ &image->layoutBoundsTop,
+ &image->layoutBoundsBottom, &errorMsg);
+
+ image->haveLayoutBounds = image->layoutBoundsLeft != 0
+ || image->layoutBoundsRight != 0
+ || image->layoutBoundsTop != 0
+ || image->layoutBoundsBottom != 0;
+
+ if (image->haveLayoutBounds) {
+ NOISY(printf("layoutBounds=%d %d %d %d\n", image->layoutBoundsLeft, image->layoutBoundsTop,
+ image->layoutBoundsRight, image->layoutBoundsBottom));
+ }
+
// Copy patch data into image
image->info9Patch.numXDivs = numXDivs;
image->info9Patch.numYDivs = numYDivs;
@@ -845,8 +980,9 @@ static void write_png(const char* imageName,
int bit_depth, interlace_type, compression_type;
int i;
- png_unknown_chunk unknowns[1];
+ png_unknown_chunk unknowns[2];
unknowns[0].data = NULL;
+ unknowns[1].data = NULL;
png_bytepp outRows = (png_bytepp) malloc((int) imageInfo.height * png_sizeof(png_bytep));
if (outRows == (png_bytepp) 0) {
@@ -916,23 +1052,42 @@ static void write_png(const char* imageName,
}
if (imageInfo.is9Patch) {
+ int chunk_count = 1 + (imageInfo.haveLayoutBounds ? 1 : 0);
+ int p_index = imageInfo.haveLayoutBounds ? 1 : 0;
+ int b_index = 0;
+ png_byte *chunk_names = imageInfo.haveLayoutBounds
+ ? (png_byte*)"npLb\0npTc\0"
+ : (png_byte*)"npTc";
NOISY(printf("Adding 9-patch info...\n"));
- strcpy((char*)unknowns[0].name, "npTc");
- unknowns[0].data = (png_byte*)imageInfo.info9Patch.serialize();
- unknowns[0].size = imageInfo.info9Patch.serializedSize();
+ strcpy((char*)unknowns[p_index].name, "npTc");
+ unknowns[p_index].data = (png_byte*)imageInfo.info9Patch.serialize();
+ unknowns[p_index].size = imageInfo.info9Patch.serializedSize();
// TODO: remove the check below when everything works
- checkNinePatchSerialization(&imageInfo.info9Patch, unknowns[0].data);
+ checkNinePatchSerialization(&imageInfo.info9Patch, unknowns[p_index].data);
+
+ if (imageInfo.haveLayoutBounds) {
+ int chunk_size = sizeof(png_uint_32) * 4;
+ strcpy((char*)unknowns[b_index].name, "npLb");
+ unknowns[b_index].data = (png_byte*) calloc(chunk_size, 1);
+ memcpy(unknowns[b_index].data, &imageInfo.layoutBoundsLeft, chunk_size);
+ unknowns[b_index].size = chunk_size;
+ }
+
png_set_keep_unknown_chunks(write_ptr, PNG_HANDLE_CHUNK_ALWAYS,
- (png_byte*)"npTc", 1);
- png_set_unknown_chunks(write_ptr, write_info, unknowns, 1);
+ chunk_names, chunk_count);
+ png_set_unknown_chunks(write_ptr, write_info, unknowns, chunk_count);
// XXX I can't get this to work without forcibly changing
// the location to what I want... which apparently is supposed
// to be a private API, but everything else I have tried results
// in the location being set to what I -last- wrote so I never
// get written. :p
png_set_unknown_chunk_location(write_ptr, write_info, 0, PNG_HAVE_PLTE);
+ if (imageInfo.haveLayoutBounds) {
+ png_set_unknown_chunk_location(write_ptr, write_info, 1, PNG_HAVE_PLTE);
+ }
}
+
png_write_info(write_ptr, write_info);
png_bytepp rows;
@@ -954,6 +1109,7 @@ static void write_png(const char* imageName,
}
free(outRows);
free(unknowns[0].data);
+ free(unknowns[1].data);
png_get_IHDR(write_ptr, write_info, &width, &height,
&bit_depth, &color_type, &interlace_type,
@@ -964,7 +1120,7 @@ static void write_png(const char* imageName,
compression_type));
}
-status_t preProcessImage(Bundle* bundle, const sp<AaptAssets>& assets,
+status_t preProcessImage(const Bundle* bundle, const sp<AaptAssets>& assets,
const sp<AaptFile>& file, String8* outNewLeafName)
{
String8 ext(file->getPath().getPathExtension());
@@ -1084,7 +1240,7 @@ bail:
return error;
}
-status_t preProcessImageToCache(Bundle* bundle, String8 source, String8 dest)
+status_t preProcessImageToCache(const Bundle* bundle, const String8& source, const String8& dest)
{
png_structp read_ptr = NULL;
png_infop read_info = NULL;
diff --git a/tools/aapt/Images.h b/tools/aapt/Images.h
index 4816905..91b6554 100644
--- a/tools/aapt/Images.h
+++ b/tools/aapt/Images.h
@@ -15,10 +15,10 @@
using android::String8;
-status_t preProcessImage(Bundle* bundle, const sp<AaptAssets>& assets,
+status_t preProcessImage(const Bundle* bundle, const sp<AaptAssets>& assets,
const sp<AaptFile>& file, String8* outNewLeafName);
-status_t preProcessImageToCache(Bundle* bundle, String8 source, String8 dest);
+status_t preProcessImageToCache(const Bundle* bundle, const String8& source, const String8& dest);
status_t postProcessImage(const sp<AaptAssets>& assets,
ResourceTable* table, const sp<AaptFile>& file);
diff --git a/tools/aapt/Resource.cpp b/tools/aapt/Resource.cpp
index 1ecf7da..b9ec30c 100644
--- a/tools/aapt/Resource.cpp
+++ b/tools/aapt/Resource.cpp
@@ -14,6 +14,8 @@
#include "FileFinder.h"
#include "CacheUpdater.h"
+#include <utils/WorkQueue.h>
+
#if HAVE_PRINTF_ZD
# define ZD "%zd"
# define ZD_TYPE ssize_t
@@ -24,6 +26,9 @@
#define NOISY(x) // x
+// Number of threads to use for preprocessing images.
+static const size_t MAX_THREADS = 4;
+
// ==========================================================================
// ==========================================================================
// ==========================================================================
@@ -302,21 +307,52 @@ static status_t makeFileResources(Bundle* bundle, const sp<AaptAssets>& assets,
return hasErrors ? UNKNOWN_ERROR : NO_ERROR;
}
-static status_t preProcessImages(Bundle* bundle, const sp<AaptAssets>& assets,
+class PreProcessImageWorkUnit : public WorkQueue::WorkUnit {
+public:
+ PreProcessImageWorkUnit(const Bundle* bundle, const sp<AaptAssets>& assets,
+ const sp<AaptFile>& file, volatile bool* hasErrors) :
+ mBundle(bundle), mAssets(assets), mFile(file), mHasErrors(hasErrors) {
+ }
+
+ virtual bool run() {
+ status_t status = preProcessImage(mBundle, mAssets, mFile, NULL);
+ if (status) {
+ *mHasErrors = true;
+ }
+ return true; // continue even if there are errors
+ }
+
+private:
+ const Bundle* mBundle;
+ sp<AaptAssets> mAssets;
+ sp<AaptFile> mFile;
+ volatile bool* mHasErrors;
+};
+
+static status_t preProcessImages(const Bundle* bundle, const sp<AaptAssets>& assets,
const sp<ResourceTypeSet>& set, const char* type)
{
- bool hasErrors = false;
+ volatile bool hasErrors = false;
ssize_t res = NO_ERROR;
if (bundle->getUseCrunchCache() == false) {
+ WorkQueue wq(MAX_THREADS, false);
ResourceDirIterator it(set, String8(type));
- Vector<sp<AaptFile> > newNameFiles;
- Vector<String8> newNamePaths;
while ((res=it.next()) == NO_ERROR) {
- res = preProcessImage(bundle, assets, it.getFile(), NULL);
- if (res < NO_ERROR) {
+ PreProcessImageWorkUnit* w = new PreProcessImageWorkUnit(
+ bundle, assets, it.getFile(), &hasErrors);
+ status_t status = wq.schedule(w);
+ if (status) {
+ fprintf(stderr, "preProcessImages failed: schedule() returned %d\n", status);
hasErrors = true;
+ delete w;
+ break;
}
}
+ status_t status = wq.finish();
+ if (status) {
+ fprintf(stderr, "preProcessImages failed: finish() returned %d\n", status);
+ hasErrors = true;
+ }
}
return (hasErrors || (res < NO_ERROR)) ? UNKNOWN_ERROR : NO_ERROR;
}
@@ -847,8 +883,7 @@ status_t buildResources(Bundle* bundle, const sp<AaptAssets>& assets)
* request UTF-16 encoding and the parameters of this package
* allow UTF-8 to be used.
*/
- if (!bundle->getWantUTF16()
- && bundle->isMinSdkAtLeast(SDK_FROYO)) {
+ if (!bundle->getUTF16StringsOption()) {
xmlFlags |= XML_COMPILE_UTF8;
}
@@ -1809,7 +1844,7 @@ static status_t writeSymbolClass(
if (sym.typeCode != AaptSymbolEntry::TYPE_INT32) {
continue;
}
- if (!includePrivate && !sym.isPublic) {
+ if (!assets->isJavaSymbol(sym, includePrivate)) {
continue;
}
String16 name(sym.name);
@@ -1865,7 +1900,7 @@ static status_t writeSymbolClass(
if (sym.typeCode != AaptSymbolEntry::TYPE_STRING) {
continue;
}
- if (!includePrivate && !sym.isPublic) {
+ if (!assets->isJavaSymbol(sym, includePrivate)) {
continue;
}
String16 name(sym.name);
@@ -1977,7 +2012,8 @@ status_t writeResourceSymbols(Bundle* bundle, const sp<AaptAssets>& assets,
"\n"
"package %s;\n\n", package.string());
- status_t err = writeSymbolClass(fp, assets, includePrivate, symbols, className, 0, bundle->getNonConstantId());
+ status_t err = writeSymbolClass(fp, assets, includePrivate, symbols,
+ className, 0, bundle->getNonConstantId());
if (err != NO_ERROR) {
return err;
}
diff --git a/tools/aapt/ResourceTable.cpp b/tools/aapt/ResourceTable.cpp
index fdb39ca..0195727 100644
--- a/tools/aapt/ResourceTable.cpp
+++ b/tools/aapt/ResourceTable.cpp
@@ -9,8 +9,8 @@
#include "XMLNode.h"
#include "ResourceFilter.h"
+#include <androidfw/ResourceTypes.h>
#include <utils/ByteOrder.h>
-#include <utils/ResourceTypes.h>
#include <stdarg.h>
#define NOISY(x) //x
@@ -753,6 +753,7 @@ status_t compileResourceFile(Bundle* bundle,
const String16 public16("public");
const String16 public_padding16("public-padding");
const String16 private_symbols16("private-symbols");
+ const String16 java_symbol16("java-symbol");
const String16 add_resource16("add-resource");
const String16 skip16("skip");
const String16 eat_comment16("eat-comment");
@@ -1058,6 +1059,49 @@ status_t compileResourceFile(Bundle* bundle,
}
continue;
+ } else if (strcmp16(block.getElementName(&len), java_symbol16.string()) == 0) {
+ SourcePos srcPos(in->getPrintableSource(), block.getLineNumber());
+
+ String16 type;
+ ssize_t typeIdx = block.indexOfAttribute(NULL, "type");
+ if (typeIdx < 0) {
+ srcPos.error("A 'type' attribute is required for <public>\n");
+ hasErrors = localHasErrors = true;
+ }
+ type = String16(block.getAttributeStringValue(typeIdx, &len));
+
+ String16 name;
+ ssize_t nameIdx = block.indexOfAttribute(NULL, "name");
+ if (nameIdx < 0) {
+ srcPos.error("A 'name' attribute is required for <public>\n");
+ hasErrors = localHasErrors = true;
+ }
+ name = String16(block.getAttributeStringValue(nameIdx, &len));
+
+ sp<AaptSymbols> symbols = assets->getJavaSymbolsFor(String8("R"));
+ if (symbols != NULL) {
+ symbols = symbols->addNestedSymbol(String8(type), srcPos);
+ }
+ if (symbols != NULL) {
+ symbols->makeSymbolJavaSymbol(String8(name), srcPos);
+ String16 comment(
+ block.getComment(&len) ? block.getComment(&len) : nulStr);
+ symbols->appendComment(String8(name), comment, srcPos);
+ } else {
+ srcPos.error("Unable to create symbols!\n");
+ hasErrors = localHasErrors = true;
+ }
+
+ while ((code=block.next()) != ResXMLTree::END_DOCUMENT && code != ResXMLTree::BAD_DOCUMENT) {
+ if (code == ResXMLTree::END_TAG) {
+ if (strcmp16(block.getElementName(&len), java_symbol16.string()) == 0) {
+ break;
+ }
+ }
+ }
+ continue;
+
+
} else if (strcmp16(block.getElementName(&len), add_resource16.string()) == 0) {
SourcePos srcPos(in->getPrintableSource(), block.getLineNumber());
@@ -2047,7 +2091,8 @@ bool ResourceTable::stringToValue(Res_value* outValue, StringPool* pool,
uint32_t attrID,
const Vector<StringPool::entry_style_span>* style,
String16* outStr, void* accessorCookie,
- uint32_t attrType)
+ uint32_t attrType, const String8* configTypeName,
+ const ConfigDescription* config)
{
String16 finalStr;
@@ -2075,10 +2120,19 @@ bool ResourceTable::stringToValue(Res_value* outValue, StringPool* pool,
if (outValue->dataType == outValue->TYPE_STRING) {
// Should do better merging styles.
if (pool) {
+ String8 configStr;
+ if (config != NULL) {
+ configStr = config->toString();
+ } else {
+ configStr = "(null)";
+ }
+ NOISY(printf("Adding to pool string style #%d config %s: %s\n",
+ style != NULL ? style->size() : 0,
+ configStr.string(), String8(finalStr).string()));
if (style != NULL && style->size() > 0) {
- outValue->data = pool->add(finalStr, *style);
+ outValue->data = pool->add(finalStr, *style, configTypeName, config);
} else {
- outValue->data = pool->add(finalStr, true);
+ outValue->data = pool->add(finalStr, true, configTypeName, config);
}
} else {
// Caller will fill this in later.
@@ -2250,10 +2304,8 @@ bool ResourceTable::getAttributeFlags(
const char16_t* end = name + nameLen;
const char16_t* pos = name;
- bool failed = false;
- while (pos < end && !failed) {
+ while (pos < end) {
const char16_t* start = pos;
- end++;
while (pos < end && *pos != '|') {
pos++;
}
@@ -2279,9 +2331,7 @@ bool ResourceTable::getAttributeFlags(
// Didn't find this flag identifier.
return false;
}
- if (pos < end) {
- pos++;
- }
+ pos++;
}
return true;
@@ -2537,16 +2587,19 @@ status_t ResourceTable::flatten(Bundle* bundle, const sp<AaptFile>& dest)
return err;
}
+ const ConfigDescription nullConfig;
+
const size_t N = mOrderedPackages.size();
size_t pi;
const static String16 mipmap16("mipmap");
- bool useUTF8 = !bundle->getWantUTF16() && bundle->isMinSdkAtLeast(SDK_FROYO);
+ bool useUTF8 = !bundle->getUTF16StringsOption();
// Iterate through all data, collecting all values (strings,
// references, etc).
- StringPool valueStrings = StringPool(false, useUTF8);
+ StringPool valueStrings(useUTF8);
+ Vector<sp<Entry> > allEntries;
for (pi=0; pi<N; pi++) {
sp<Package> p = mOrderedPackages.itemAt(pi);
if (p->getTypes().size() == 0) {
@@ -2554,8 +2607,8 @@ status_t ResourceTable::flatten(Bundle* bundle, const sp<AaptFile>& dest)
continue;
}
- StringPool typeStrings = StringPool(false, useUTF8);
- StringPool keyStrings = StringPool(false, useUTF8);
+ StringPool typeStrings(useUTF8);
+ StringPool keyStrings(useUTF8);
const size_t N = p->getOrderedTypes().size();
for (size_t ti=0; ti<N; ti++) {
@@ -2567,6 +2620,19 @@ status_t ResourceTable::flatten(Bundle* bundle, const sp<AaptFile>& dest)
const String16 typeName(t->getName());
typeStrings.add(typeName, false);
+ // This is a hack to tweak the sorting order of the final strings,
+ // to put stuff that is generally not language-specific first.
+ String8 configTypeName(typeName);
+ if (configTypeName == "drawable" || configTypeName == "layout"
+ || configTypeName == "color" || configTypeName == "anim"
+ || configTypeName == "interpolator" || configTypeName == "animator"
+ || configTypeName == "xml" || configTypeName == "menu"
+ || configTypeName == "mipmap" || configTypeName == "raw") {
+ configTypeName = "1complex";
+ } else {
+ configTypeName = "2value";
+ }
+
const bool filterable = (typeName != mipmap16);
const size_t N = t->getOrderedConfigs().size();
@@ -2586,10 +2652,21 @@ status_t ResourceTable::flatten(Bundle* bundle, const sp<AaptFile>& dest)
continue;
}
e->setNameIndex(keyStrings.add(e->getName(), true));
- status_t err = e->prepareFlatten(&valueStrings, this);
+
+ // If this entry has no values for other configs,
+ // and is the default config, then it is special. Otherwise
+ // we want to add it with the config info.
+ ConfigDescription* valueConfig = NULL;
+ if (N != 1 || config == nullConfig) {
+ valueConfig = &config;
+ }
+
+ status_t err = e->prepareFlatten(&valueStrings, this,
+ &configTypeName, &config);
if (err != NO_ERROR) {
return err;
}
+ allEntries.add(e);
}
}
}
@@ -2598,6 +2675,17 @@ status_t ResourceTable::flatten(Bundle* bundle, const sp<AaptFile>& dest)
p->setKeyStrings(keyStrings.createStringBlock());
}
+ if (bundle->getOutputAPKFile() != NULL) {
+ // Now we want to sort the value strings for better locality. This will
+ // cause the positions of the strings to change, so we need to go back
+ // through out resource entries and update them accordingly. Only need
+ // to do this if actually writing the output file.
+ valueStrings.sortByConfig();
+ for (pi=0; pi<allEntries.size(); pi++) {
+ allEntries[pi]->remapStringValue(&valueStrings);
+ }
+ }
+
ssize_t strAmt = 0;
// Now build the array of package chunks.
@@ -3137,14 +3225,16 @@ status_t ResourceTable::Entry::assignResourceIds(ResourceTable* table,
return hasErrors ? UNKNOWN_ERROR : NO_ERROR;
}
-status_t ResourceTable::Entry::prepareFlatten(StringPool* strings, ResourceTable* table)
+status_t ResourceTable::Entry::prepareFlatten(StringPool* strings, ResourceTable* table,
+ const String8* configTypeName, const ConfigDescription* config)
{
if (mType == TYPE_ITEM) {
Item& it = mItem;
AccessorCookie ac(it.sourcePos, String8(mName), String8(it.value));
if (!table->stringToValue(&it.parsedValue, strings,
it.value, false, true, 0,
- &it.style, NULL, &ac, mItemFormat)) {
+ &it.style, NULL, &ac, mItemFormat,
+ configTypeName, config)) {
return UNKNOWN_ERROR;
}
} else if (mType == TYPE_BAG) {
@@ -3155,7 +3245,8 @@ status_t ResourceTable::Entry::prepareFlatten(StringPool* strings, ResourceTable
AccessorCookie ac(it.sourcePos, String8(key), String8(it.value));
if (!table->stringToValue(&it.parsedValue, strings,
it.value, false, true, it.bagKeyId,
- &it.style, NULL, &ac, it.format)) {
+ &it.style, NULL, &ac, it.format,
+ configTypeName, config)) {
return UNKNOWN_ERROR;
}
}
@@ -3167,6 +3258,29 @@ status_t ResourceTable::Entry::prepareFlatten(StringPool* strings, ResourceTable
return NO_ERROR;
}
+status_t ResourceTable::Entry::remapStringValue(StringPool* strings)
+{
+ if (mType == TYPE_ITEM) {
+ Item& it = mItem;
+ if (it.parsedValue.dataType == Res_value::TYPE_STRING) {
+ it.parsedValue.data = strings->mapOriginalPosToNewPos(it.parsedValue.data);
+ }
+ } else if (mType == TYPE_BAG) {
+ const size_t N = mBag.size();
+ for (size_t i=0; i<N; i++) {
+ Item& it = mBag.editValueAt(i);
+ if (it.parsedValue.dataType == Res_value::TYPE_STRING) {
+ it.parsedValue.data = strings->mapOriginalPosToNewPos(it.parsedValue.data);
+ }
+ }
+ } else {
+ mPos.error("Error: entry %s is not a single item or a bag.\n",
+ String8(mName).string());
+ return UNKNOWN_ERROR;
+ }
+ return NO_ERROR;
+}
+
ssize_t ResourceTable::Entry::flatten(Bundle* bundle, const sp<AaptFile>& data, bool isPublic)
{
size_t amt = 0;
diff --git a/tools/aapt/ResourceTable.h b/tools/aapt/ResourceTable.h
index 8123bb3..a3e0666 100644
--- a/tools/aapt/ResourceTable.h
+++ b/tools/aapt/ResourceTable.h
@@ -76,6 +76,37 @@ public:
class Type;
class Entry;
+ struct ConfigDescription : public ResTable_config {
+ ConfigDescription() {
+ memset(this, 0, sizeof(*this));
+ size = sizeof(ResTable_config);
+ }
+ ConfigDescription(const ResTable_config&o) {
+ *static_cast<ResTable_config*>(this) = o;
+ size = sizeof(ResTable_config);
+ }
+ ConfigDescription(const ConfigDescription&o) {
+ *static_cast<ResTable_config*>(this) = o;
+ }
+
+ ConfigDescription& operator=(const ResTable_config& o) {
+ *static_cast<ResTable_config*>(this) = o;
+ size = sizeof(ResTable_config);
+ return *this;
+ }
+ ConfigDescription& operator=(const ConfigDescription& o) {
+ *static_cast<ResTable_config*>(this) = o;
+ return *this;
+ }
+
+ inline bool operator<(const ConfigDescription& o) const { return compare(o) < 0; }
+ inline bool operator<=(const ConfigDescription& o) const { return compare(o) <= 0; }
+ inline bool operator==(const ConfigDescription& o) const { return compare(o) == 0; }
+ inline bool operator!=(const ConfigDescription& o) const { return compare(o) != 0; }
+ inline bool operator>=(const ConfigDescription& o) const { return compare(o) >= 0; }
+ inline bool operator>(const ConfigDescription& o) const { return compare(o) > 0; }
+ };
+
ResourceTable(Bundle* bundle, const String16& assetsPackage);
status_t addIncludedResources(Bundle* bundle, const sp<AaptAssets>& assets);
@@ -183,7 +214,9 @@ public:
uint32_t attrID,
const Vector<StringPool::entry_style_span>* style = NULL,
String16* outStr = NULL, void* accessorCookie = NULL,
- uint32_t attrType = ResTable_map::TYPE_ANY);
+ uint32_t attrType = ResTable_map::TYPE_ANY,
+ const String8* configTypeName = NULL,
+ const ConfigDescription* config = NULL);
status_t assignResourceIds();
status_t addSymbols(const sp<AaptSymbols>& outSymbols = NULL);
@@ -305,7 +338,10 @@ public:
status_t assignResourceIds(ResourceTable* table,
const String16& package);
- status_t prepareFlatten(StringPool* strings, ResourceTable* table);
+ status_t prepareFlatten(StringPool* strings, ResourceTable* table,
+ const String8* configTypeName, const ConfigDescription* config);
+
+ status_t remapStringValue(StringPool* strings);
ssize_t flatten(Bundle*, const sp<AaptFile>& data, bool isPublic);
@@ -322,37 +358,6 @@ public:
uint32_t mParentId;
SourcePos mPos;
};
-
- struct ConfigDescription : public ResTable_config {
- ConfigDescription() {
- memset(this, 0, sizeof(*this));
- size = sizeof(ResTable_config);
- }
- ConfigDescription(const ResTable_config&o) {
- *static_cast<ResTable_config*>(this) = o;
- size = sizeof(ResTable_config);
- }
- ConfigDescription(const ConfigDescription&o) {
- *static_cast<ResTable_config*>(this) = o;
- }
-
- ConfigDescription& operator=(const ResTable_config& o) {
- *static_cast<ResTable_config*>(this) = o;
- size = sizeof(ResTable_config);
- return *this;
- }
- ConfigDescription& operator=(const ConfigDescription& o) {
- *static_cast<ResTable_config*>(this) = o;
- return *this;
- }
-
- inline bool operator<(const ConfigDescription& o) const { return compare(o) < 0; }
- inline bool operator<=(const ConfigDescription& o) const { return compare(o) <= 0; }
- inline bool operator==(const ConfigDescription& o) const { return compare(o) == 0; }
- inline bool operator!=(const ConfigDescription& o) const { return compare(o) != 0; }
- inline bool operator>=(const ConfigDescription& o) const { return compare(o) >= 0; }
- inline bool operator>(const ConfigDescription& o) const { return compare(o) > 0; }
- };
class ConfigList : public RefBase {
public:
diff --git a/tools/aapt/StringPool.cpp b/tools/aapt/StringPool.cpp
index 9a0a1c4..839eda5 100644
--- a/tools/aapt/StringPool.cpp
+++ b/tools/aapt/StringPool.cpp
@@ -5,8 +5,11 @@
//
#include "StringPool.h"
+#include "ResourceTable.h"
#include <utils/ByteOrder.h>
+#include <utils/SortedVector.h>
+#include <cutils/qsort_r_compat.h>
#if HAVE_PRINTF_ZD
# define ZD "%zd"
@@ -30,49 +33,92 @@ void strcpy16_htod(uint16_t* dst, const uint16_t* src)
void printStringPool(const ResStringPool* pool)
{
- const size_t NS = pool->size();
- for (size_t s=0; s<NS; s++) {
+ SortedVector<const void*> uniqueStrings;
+ const size_t N = pool->size();
+ for (size_t i=0; i<N; i++) {
size_t len;
- const char *str = (const char*)pool->string8At(s, &len);
- if (str == NULL) {
- str = String8(pool->stringAt(s, &len)).string();
+ if (pool->isUTF8()) {
+ uniqueStrings.add(pool->string8At(i, &len));
+ } else {
+ uniqueStrings.add(pool->stringAt(i, &len));
}
+ }
- printf("String #" ZD ": %s\n", (ZD_TYPE) s, str);
+ printf("String pool of " ZD " unique %s %s strings, " ZD " entries and "
+ ZD " styles using " ZD " bytes:\n",
+ (ZD_TYPE)uniqueStrings.size(), pool->isUTF8() ? "UTF-8" : "UTF-16",
+ pool->isSorted() ? "sorted" : "non-sorted",
+ (ZD_TYPE)N, (ZD_TYPE)pool->styleCount(), (ZD_TYPE)pool->bytes());
+
+ const size_t NS = pool->size();
+ for (size_t s=0; s<NS; s++) {
+ String8 str = pool->string8ObjectAt(s);
+ printf("String #" ZD ": %s\n", (ZD_TYPE) s, str.string());
}
}
-StringPool::StringPool(bool sorted, bool utf8)
- : mSorted(sorted), mUTF8(utf8), mValues(-1), mIdents(-1)
-{
+String8 StringPool::entry::makeConfigsString() const {
+ String8 configStr(configTypeName);
+ if (configStr.size() > 0) configStr.append(" ");
+ if (configs.size() > 0) {
+ for (size_t j=0; j<configs.size(); j++) {
+ if (j > 0) configStr.append(", ");
+ configStr.append(configs[j].toString());
+ }
+ } else {
+ configStr = "(none)";
+ }
+ return configStr;
}
-ssize_t StringPool::add(const String16& value, bool mergeDuplicates)
+int StringPool::entry::compare(const entry& o) const {
+ // Strings with styles go first, to reduce the size of the styles array.
+ // We don't care about the relative order of these strings.
+ if (hasStyles) {
+ return o.hasStyles ? 0 : -1;
+ }
+ if (o.hasStyles) {
+ return 1;
+ }
+
+ // Sort unstyled strings by type, then by logical configuration.
+ int comp = configTypeName.compare(o.configTypeName);
+ if (comp != 0) {
+ return comp;
+ }
+ const size_t LHN = configs.size();
+ const size_t RHN = o.configs.size();
+ size_t i=0;
+ while (i < LHN && i < RHN) {
+ comp = configs[i].compareLogical(o.configs[i]);
+ if (comp != 0) {
+ return comp;
+ }
+ i++;
+ }
+ if (LHN < RHN) return -1;
+ else if (LHN > RHN) return 1;
+ return 0;
+}
+
+StringPool::StringPool(bool utf8) :
+ mUTF8(utf8), mValues(-1)
{
- return add(String16(), value, mergeDuplicates);
}
-ssize_t StringPool::add(const String16& value, const Vector<entry_style_span>& spans)
+ssize_t StringPool::add(const String16& value, const Vector<entry_style_span>& spans,
+ const String8* configTypeName, const ResTable_config* config)
{
- ssize_t res = add(String16(), value, false);
+ ssize_t res = add(value, false, configTypeName, config);
if (res >= 0) {
addStyleSpans(res, spans);
}
return res;
}
-ssize_t StringPool::add(const String16& ident, const String16& value,
- bool mergeDuplicates)
+ssize_t StringPool::add(const String16& value,
+ bool mergeDuplicates, const String8* configTypeName, const ResTable_config* config)
{
- if (ident.size() > 0) {
- ssize_t idx = mIdents.valueFor(ident);
- if (idx >= 0) {
- fprintf(stderr, "ERROR: Duplicate string identifier %s\n",
- String8(mEntries[idx].value).string());
- return UNKNOWN_ERROR;
- }
- }
-
ssize_t vidx = mValues.indexOfKey(value);
ssize_t pos = vidx >= 0 ? mValues.valueAt(vidx) : -1;
ssize_t eidx = pos >= 0 ? mEntryArray.itemAt(pos) : -1;
@@ -84,28 +130,47 @@ ssize_t StringPool::add(const String16& ident, const String16& value,
}
}
- const bool first = vidx < 0;
- if (first || !mergeDuplicates) {
- pos = mEntryArray.add(eidx);
- if (first) {
- vidx = mValues.add(value, pos);
- const size_t N = mEntryArrayToValues.size();
- for (size_t i=0; i<N; i++) {
- size_t& e = mEntryArrayToValues.editItemAt(i);
- if ((ssize_t)e >= vidx) {
- e++;
+ if (configTypeName != NULL) {
+ entry& ent = mEntries.editItemAt(eidx);
+ NOISY(printf("*** adding config type name %s, was %s\n",
+ configTypeName->string(), ent.configTypeName.string()));
+ if (ent.configTypeName.size() <= 0) {
+ ent.configTypeName = *configTypeName;
+ } else if (ent.configTypeName != *configTypeName) {
+ ent.configTypeName = " ";
+ }
+ }
+
+ if (config != NULL) {
+ // Add this to the set of configs associated with the string.
+ entry& ent = mEntries.editItemAt(eidx);
+ size_t addPos;
+ for (addPos=0; addPos<ent.configs.size(); addPos++) {
+ int cmp = ent.configs.itemAt(addPos).compareLogical(*config);
+ if (cmp >= 0) {
+ if (cmp > 0) {
+ NOISY(printf("*** inserting config: %s\n", config->toString().string()));
+ ent.configs.insertAt(*config, addPos);
}
+ break;
}
}
- mEntryArrayToValues.add(vidx);
- if (!mSorted) {
- entry& ent = mEntries.editItemAt(eidx);
- ent.indices.add(pos);
+ if (addPos >= ent.configs.size()) {
+ NOISY(printf("*** adding config: %s\n", config->toString().string()));
+ ent.configs.add(*config);
}
}
- if (ident.size() > 0) {
- mIdents.add(ident, vidx);
+ const bool first = vidx < 0;
+ const bool styled = (pos >= 0 && (size_t)pos < mEntryStyleArray.size()) ?
+ mEntryStyleArray[pos].spans.size() : 0;
+ if (first || styled || !mergeDuplicates) {
+ pos = mEntryArray.add(eidx);
+ if (first) {
+ vidx = mValues.add(value, pos);
+ }
+ entry& ent = mEntries.editItemAt(eidx);
+ ent.indices.add(pos);
}
NOISY(printf("Adding string %s to pool: pos=%d eidx=%d vidx=%d\n",
@@ -138,8 +203,6 @@ status_t StringPool::addStyleSpans(size_t idx, const Vector<entry_style_span>& s
status_t StringPool::addStyleSpan(size_t idx, const entry_style_span& span)
{
- LOG_ALWAYS_FATAL_IF(mSorted, "Can't use styles with sorted string pools.");
-
// Place blank entries in the span array up to this index.
while (mEntryStyleArray.size() <= idx) {
mEntryStyleArray.add();
@@ -147,26 +210,136 @@ status_t StringPool::addStyleSpan(size_t idx, const entry_style_span& span)
entry_style& style = mEntryStyleArray.editItemAt(idx);
style.spans.add(span);
+ mEntries.editItemAt(mEntryArray[idx]).hasStyles = true;
return NO_ERROR;
}
-size_t StringPool::size() const
+int StringPool::config_sort(void* state, const void* lhs, const void* rhs)
{
- return mSorted ? mValues.size() : mEntryArray.size();
+ StringPool* pool = (StringPool*)state;
+ const entry& lhe = pool->mEntries[pool->mEntryArray[*static_cast<const size_t*>(lhs)]];
+ const entry& rhe = pool->mEntries[pool->mEntryArray[*static_cast<const size_t*>(rhs)]];
+ return lhe.compare(rhe);
}
-const StringPool::entry& StringPool::entryAt(size_t idx) const
+void StringPool::sortByConfig()
{
- if (!mSorted) {
- return mEntries[mEntryArray[idx]];
- } else {
- return mEntries[mEntryArray[mValues.valueAt(idx)]];
+ LOG_ALWAYS_FATAL_IF(mOriginalPosToNewPos.size() > 0, "Can't sort string pool after already sorted.");
+
+ const size_t N = mEntryArray.size();
+
+ // This is a vector that starts out with a 1:1 mapping to entries
+ // in the array, which we will sort to come up with the desired order.
+ // At that point it maps from the new position in the array to the
+ // original position the entry appeared.
+ Vector<size_t> newPosToOriginalPos;
+ newPosToOriginalPos.setCapacity(N);
+ for (size_t i=0; i < N; i++) {
+ newPosToOriginalPos.add(i);
}
-}
-size_t StringPool::countIdentifiers() const
-{
- return mIdents.size();
+ // Sort the array.
+ NOISY(printf("SORTING STRINGS BY CONFIGURATION...\n"));
+ // Vector::sort uses insertion sort, which is very slow for this data set.
+ // Use quicksort instead because we don't need a stable sort here.
+ qsort_r_compat(newPosToOriginalPos.editArray(), N, sizeof(size_t), this, config_sort);
+ //newPosToOriginalPos.sort(config_sort, this);
+ NOISY(printf("DONE SORTING STRINGS BY CONFIGURATION.\n"));
+
+ // Create the reverse mapping from the original position in the array
+ // to the new position where it appears in the sorted array. This is
+ // so that clients can re-map any positions they had previously stored.
+ mOriginalPosToNewPos = newPosToOriginalPos;
+ for (size_t i=0; i<N; i++) {
+ mOriginalPosToNewPos.editItemAt(newPosToOriginalPos[i]) = i;
+ }
+
+#if 0
+ SortedVector<entry> entries;
+
+ for (size_t i=0; i<N; i++) {
+ printf("#%d was %d: %s\n", i, newPosToOriginalPos[i],
+ mEntries[mEntryArray[newPosToOriginalPos[i]]].makeConfigsString().string());
+ entries.add(mEntries[mEntryArray[i]]);
+ }
+
+ for (size_t i=0; i<entries.size(); i++) {
+ printf("Sorted config #%d: %s\n", i,
+ entries[i].makeConfigsString().string());
+ }
+#endif
+
+ // Now we rebuild the arrays.
+ Vector<entry> newEntries;
+ Vector<size_t> newEntryArray;
+ Vector<entry_style> newEntryStyleArray;
+ DefaultKeyedVector<size_t, size_t> origOffsetToNewOffset;
+
+ for (size_t i=0; i<N; i++) {
+ // We are filling in new offset 'i'; oldI is where we can find it
+ // in the original data structure.
+ size_t oldI = newPosToOriginalPos[i];
+ // This is the actual entry associated with the old offset.
+ const entry& oldEnt = mEntries[mEntryArray[oldI]];
+ // This is the same entry the last time we added it to the
+ // new entry array, if any.
+ ssize_t newIndexOfOffset = origOffsetToNewOffset.indexOfKey(oldI);
+ size_t newOffset;
+ if (newIndexOfOffset < 0) {
+ // This is the first time we have seen the entry, so add
+ // it.
+ newOffset = newEntries.add(oldEnt);
+ newEntries.editItemAt(newOffset).indices.clear();
+ } else {
+ // We have seen this entry before, use the existing one
+ // instead of adding it again.
+ newOffset = origOffsetToNewOffset.valueAt(newIndexOfOffset);
+ }
+ // Update the indices to include this new position.
+ newEntries.editItemAt(newOffset).indices.add(i);
+ // And add the offset of the entry to the new entry array.
+ newEntryArray.add(newOffset);
+ // Add any old style to the new style array.
+ if (mEntryStyleArray.size() > 0) {
+ if (oldI < mEntryStyleArray.size()) {
+ newEntryStyleArray.add(mEntryStyleArray[oldI]);
+ } else {
+ newEntryStyleArray.add(entry_style());
+ }
+ }
+ }
+
+ // Now trim any entries at the end of the new style array that are
+ // not needed.
+ for (ssize_t i=newEntryStyleArray.size()-1; i>=0; i--) {
+ const entry_style& style = newEntryStyleArray[i];
+ if (style.spans.size() > 0) {
+ // That's it.
+ break;
+ }
+ // This one is not needed; remove.
+ newEntryStyleArray.removeAt(i);
+ }
+
+ // All done, install the new data structures and upate mValues with
+ // the new positions.
+ mEntries = newEntries;
+ mEntryArray = newEntryArray;
+ mEntryStyleArray = newEntryStyleArray;
+ mValues.clear();
+ for (size_t i=0; i<mEntries.size(); i++) {
+ const entry& ent = mEntries[i];
+ mValues.add(ent.value, ent.indices[0]);
+ }
+
+#if 0
+ printf("FINAL SORTED STRING CONFIGS:\n");
+ for (size_t i=0; i<mEntries.size(); i++) {
+ const entry& ent = mEntries[i];
+ printf("#" ZD " %s: %s\n", (ZD_TYPE)i, ent.makeConfigsString().string(),
+ String8(ent.value).string());
+ }
+#endif
}
sp<AaptFile> StringPool::createStringBlock()
@@ -222,7 +395,7 @@ status_t StringPool::writeStringBlock(const sp<AaptFile>& pool)
}
}
- const size_t ENTRIES = size();
+ const size_t ENTRIES = mEntryArray.size();
// Now build the pool of unique strings.
@@ -356,9 +529,6 @@ status_t StringPool::writeStringBlock(const sp<AaptFile>& pool)
header->header.size = htodl(pool->getSize());
header->stringCount = htodl(ENTRIES);
header->styleCount = htodl(STYLES);
- if (mSorted) {
- header->flags |= htodl(ResStringPool_header::SORTED_FLAG);
- }
if (mUTF8) {
header->flags |= htodl(ResStringPool_header::UTF8_FLAG);
}
@@ -368,33 +538,18 @@ status_t StringPool::writeStringBlock(const sp<AaptFile>& pool)
// Write string index array.
uint32_t* index = (uint32_t*)(header+1);
- if (mSorted) {
- for (i=0; i<ENTRIES; i++) {
- entry& ent = const_cast<entry&>(entryAt(i));
- ent.indices.clear();
- ent.indices.add(i);
- *index++ = htodl(ent.offset);
- }
- } else {
- for (i=0; i<ENTRIES; i++) {
- entry& ent = mEntries.editItemAt(mEntryArray[i]);
- *index++ = htodl(ent.offset);
- NOISY(printf("Writing entry #%d: \"%s\" ent=%d off=%d\n", i,
- String8(ent.value).string(),
- mEntryArray[i], ent.offset));
- }
+ for (i=0; i<ENTRIES; i++) {
+ entry& ent = mEntries.editItemAt(mEntryArray[i]);
+ *index++ = htodl(ent.offset);
+ NOISY(printf("Writing entry #%d: \"%s\" ent=%d off=%d\n", i,
+ String8(ent.value).string(),
+ mEntryArray[i], ent.offset));
}
// Write style index array.
- if (mSorted) {
- for (i=0; i<STYLES; i++) {
- LOG_ALWAYS_FATAL("Shouldn't be here!");
- }
- } else {
- for (i=0; i<STYLES; i++) {
- *index++ = htodl(mEntryStyleArray[i].offset);
- }
+ for (i=0; i<STYLES; i++) {
+ *index++ = htodl(mEntryStyleArray[i].offset);
}
return NO_ERROR;
diff --git a/tools/aapt/StringPool.h b/tools/aapt/StringPool.h
index 7275259..d501008 100644
--- a/tools/aapt/StringPool.h
+++ b/tools/aapt/StringPool.h
@@ -10,9 +10,10 @@
#include "Main.h"
#include "AaptAssets.h"
-#include <utils/ResourceTypes.h>
+#include <androidfw/ResourceTypes.h>
#include <utils/String16.h>
#include <utils/TextOutput.h>
+#include <utils/TypeHelpers.h>
#include <sys/types.h>
#include <sys/stat.h>
@@ -40,12 +41,28 @@ class StringPool
public:
struct entry {
entry() : offset(0) { }
- entry(const String16& _value) : value(_value), offset(0) { }
- entry(const entry& o) : value(o.value), offset(o.offset), indices(o.indices) { }
+ entry(const String16& _value) : value(_value), offset(0), hasStyles(false) { }
+ entry(const entry& o) : value(o.value), offset(o.offset),
+ hasStyles(o.hasStyles), indices(o.indices),
+ configTypeName(o.configTypeName), configs(o.configs) { }
String16 value;
size_t offset;
+ bool hasStyles;
Vector<size_t> indices;
+ String8 configTypeName;
+ Vector<ResTable_config> configs;
+
+ String8 makeConfigsString() const;
+
+ int compare(const entry& o) const;
+
+ inline bool operator<(const entry& o) const { return compare(o) < 0; }
+ inline bool operator<=(const entry& o) const { return compare(o) <= 0; }
+ inline bool operator==(const entry& o) const { return compare(o) == 0; }
+ inline bool operator!=(const entry& o) const { return compare(o) != 0; }
+ inline bool operator>=(const entry& o) const { return compare(o) >= 0; }
+ inline bool operator>(const entry& o) const { return compare(o) > 0; }
};
struct entry_style_span {
@@ -63,16 +80,10 @@ public:
};
/**
- * If 'sorted' is true, then the final strings in the resource data
- * structure will be generated in sorted order. This allow for fast
- * lookup with ResStringPool::indexOfString() (O(log n)), at the expense
- * of support for styled string entries (which requires the same string
- * be included multiple times in the pool).
- *
* If 'utf8' is true, strings will be encoded with UTF-8 instead of
* left in Java's native UTF-16.
*/
- explicit StringPool(bool sorted = false, bool utf8 = false);
+ explicit StringPool(bool utf8 = false);
/**
* Add a new string to the pool. If mergeDuplicates is true, thenif
@@ -80,27 +91,30 @@ public:
* otherwise, or if the value doesn't already exist, a new entry is
* created.
*
- * Returns the index in the entry array of the new string entry. Note that
- * if this string pool is sorted, the returned index will not be valid
- * when the pool is finally written.
+ * Returns the index in the entry array of the new string entry.
*/
- ssize_t add(const String16& value, bool mergeDuplicates = false);
-
- ssize_t add(const String16& value, const Vector<entry_style_span>& spans);
+ ssize_t add(const String16& value, bool mergeDuplicates = false,
+ const String8* configTypeName = NULL, const ResTable_config* config = NULL);
- ssize_t add(const String16& ident, const String16& value,
- bool mergeDuplicates = false);
+ ssize_t add(const String16& value, const Vector<entry_style_span>& spans,
+ const String8* configTypeName = NULL, const ResTable_config* config = NULL);
status_t addStyleSpan(size_t idx, const String16& name,
uint32_t start, uint32_t end);
status_t addStyleSpans(size_t idx, const Vector<entry_style_span>& spans);
status_t addStyleSpan(size_t idx, const entry_style_span& span);
- size_t size() const;
-
- const entry& entryAt(size_t idx) const;
+ // Sort the contents of the string block by the configuration associated
+ // with each item. After doing this you can use mapOriginalPosToNewPos()
+ // to find out the new position given the position originally returned by
+ // add().
+ void sortByConfig();
- size_t countIdentifiers() const;
+ // For use after sortByConfig() to map from the original position of
+ // a string to its new sorted position.
+ size_t mapOriginalPosToNewPos(size_t originalPos) const {
+ return mOriginalPosToNewPos.itemAt(originalPos);
+ }
sp<AaptFile> createStringBlock();
@@ -125,27 +139,45 @@ public:
const Vector<size_t>* offsetsForString(const String16& val) const;
private:
- const bool mSorted;
+ static int config_sort(void* state, const void* lhs, const void* rhs);
+
const bool mUTF8;
- // Raw array of unique strings, in some arbitrary order.
+
+ // The following data structures represent the actual structures
+ // that will be generated for the final string pool.
+
+ // Raw array of unique strings, in some arbitrary order. This is the
+ // actual strings that appear in the final string pool, in the order
+ // that they will be written.
Vector<entry> mEntries;
// Array of indices into mEntries, in the order they were
// added to the pool. This can be different than mEntries
// if the same string was added multiple times (it will appear
// once in mEntries, with multiple occurrences in this array).
+ // This is the lookup array that will be written for finding
+ // the string for each offset/position in the string pool.
Vector<size_t> mEntryArray;
// Optional style span information associated with each index of
// mEntryArray.
Vector<entry_style> mEntryStyleArray;
- // Mapping from indices in mEntryArray to indices in mValues.
- Vector<size_t> mEntryArrayToValues;
+
+ // The following data structures are used for book-keeping as the
+ // string pool is constructed.
+
// Unique set of all the strings added to the pool, mapped to
// the first index of mEntryArray where the value was added.
DefaultKeyedVector<String16, ssize_t> mValues;
- // Unique set of all (optional) identifiers of strings in the
- // pool, mapping to indices in mEntries.
- DefaultKeyedVector<String16, ssize_t> mIdents;
+ // This array maps from the original position a string was placed at
+ // in mEntryArray to its new position after being sorted with sortByConfig().
+ Vector<size_t> mOriginalPosToNewPos;
+};
+// The entry types are trivially movable because all fields they contain, including
+// the vectors and strings, are trivially movable.
+namespace android {
+ ANDROID_TRIVIAL_MOVE_TRAIT(StringPool::entry);
+ ANDROID_TRIVIAL_MOVE_TRAIT(StringPool::entry_style_span);
+ ANDROID_TRIVIAL_MOVE_TRAIT(StringPool::entry_style);
};
#endif
diff --git a/tools/aapt/XMLNode.cpp b/tools/aapt/XMLNode.cpp
index 8d7acee..0dba950 100644
--- a/tools/aapt/XMLNode.cpp
+++ b/tools/aapt/XMLNode.cpp
@@ -973,7 +973,7 @@ status_t XMLNode::assignResourceIds(const sp<AaptAssets>& assets,
status_t XMLNode::flatten(const sp<AaptFile>& dest,
bool stripComments, bool stripRawValues) const
{
- StringPool strings = StringPool(false, mUTF8);
+ StringPool strings(mUTF8);
Vector<uint32_t> resids;
// First collect just the strings for attribute names that have a
diff --git a/tools/aapt/ZipEntry.cpp b/tools/aapt/ZipEntry.cpp
index a0b54c2..b575988 100644
--- a/tools/aapt/ZipEntry.cpp
+++ b/tools/aapt/ZipEntry.cpp
@@ -42,12 +42,12 @@ status_t ZipEntry::initFromCDE(FILE* fp)
long posn;
bool hasDD;
- //LOGV("initFromCDE ---\n");
+ //ALOGV("initFromCDE ---\n");
/* read the CDE */
result = mCDE.read(fp);
if (result != NO_ERROR) {
- LOGD("mCDE.read failed\n");
+ ALOGD("mCDE.read failed\n");
return result;
}
@@ -56,14 +56,14 @@ status_t ZipEntry::initFromCDE(FILE* fp)
/* using the info in the CDE, go load up the LFH */
posn = ftell(fp);
if (fseek(fp, mCDE.mLocalHeaderRelOffset, SEEK_SET) != 0) {
- LOGD("local header seek failed (%ld)\n",
+ ALOGD("local header seek failed (%ld)\n",
mCDE.mLocalHeaderRelOffset);
return UNKNOWN_ERROR;
}
result = mLFH.read(fp);
if (result != NO_ERROR) {
- LOGD("mLFH.read failed\n");
+ ALOGD("mLFH.read failed\n");
return result;
}
@@ -81,7 +81,7 @@ status_t ZipEntry::initFromCDE(FILE* fp)
hasDD = (mLFH.mGPBitFlag & kUsesDataDescr) != 0;
if (hasDD) {
// do something clever
- //LOGD("+++ has data descriptor\n");
+ //ALOGD("+++ has data descriptor\n");
}
/*
@@ -90,7 +90,7 @@ status_t ZipEntry::initFromCDE(FILE* fp)
* prefer the CDE values.)
*/
if (!hasDD && !compareHeaders()) {
- LOGW("warning: header mismatch\n");
+ ALOGW("warning: header mismatch\n");
// keep going?
}
@@ -200,7 +200,7 @@ status_t ZipEntry::addPadding(int padding)
if (padding <= 0)
return INVALID_OPERATION;
- //LOGI("HEY: adding %d pad bytes to existing %d in %s\n",
+ //ALOGI("HEY: adding %d pad bytes to existing %d in %s\n",
// padding, mLFH.mExtraFieldLength, mCDE.mFileName);
if (mLFH.mExtraFieldLength > 0) {
@@ -280,50 +280,50 @@ void ZipEntry::setDataInfo(long uncompLen, long compLen, unsigned long crc32,
bool ZipEntry::compareHeaders(void) const
{
if (mCDE.mVersionToExtract != mLFH.mVersionToExtract) {
- LOGV("cmp: VersionToExtract\n");
+ ALOGV("cmp: VersionToExtract\n");
return false;
}
if (mCDE.mGPBitFlag != mLFH.mGPBitFlag) {
- LOGV("cmp: GPBitFlag\n");
+ ALOGV("cmp: GPBitFlag\n");
return false;
}
if (mCDE.mCompressionMethod != mLFH.mCompressionMethod) {
- LOGV("cmp: CompressionMethod\n");
+ ALOGV("cmp: CompressionMethod\n");
return false;
}
if (mCDE.mLastModFileTime != mLFH.mLastModFileTime) {
- LOGV("cmp: LastModFileTime\n");
+ ALOGV("cmp: LastModFileTime\n");
return false;
}
if (mCDE.mLastModFileDate != mLFH.mLastModFileDate) {
- LOGV("cmp: LastModFileDate\n");
+ ALOGV("cmp: LastModFileDate\n");
return false;
}
if (mCDE.mCRC32 != mLFH.mCRC32) {
- LOGV("cmp: CRC32\n");
+ ALOGV("cmp: CRC32\n");
return false;
}
if (mCDE.mCompressedSize != mLFH.mCompressedSize) {
- LOGV("cmp: CompressedSize\n");
+ ALOGV("cmp: CompressedSize\n");
return false;
}
if (mCDE.mUncompressedSize != mLFH.mUncompressedSize) {
- LOGV("cmp: UncompressedSize\n");
+ ALOGV("cmp: UncompressedSize\n");
return false;
}
if (mCDE.mFileNameLength != mLFH.mFileNameLength) {
- LOGV("cmp: FileNameLength\n");
+ ALOGV("cmp: FileNameLength\n");
return false;
}
#if 0 // this seems to be used for padding, not real data
if (mCDE.mExtraFieldLength != mLFH.mExtraFieldLength) {
- LOGV("cmp: ExtraFieldLength\n");
+ ALOGV("cmp: ExtraFieldLength\n");
return false;
}
#endif
if (mCDE.mFileName != NULL) {
if (strcmp((char*) mCDE.mFileName, (char*) mLFH.mFileName) != 0) {
- LOGV("cmp: FileName\n");
+ ALOGV("cmp: FileName\n");
return false;
}
}
@@ -413,7 +413,7 @@ status_t ZipEntry::LocalFileHeader::read(FILE* fp)
}
if (ZipEntry::getLongLE(&buf[0x00]) != kSignature) {
- LOGD("whoops: didn't find expected signature\n");
+ ALOGD("whoops: didn't find expected signature\n");
result = UNKNOWN_ERROR;
goto bail;
}
@@ -506,17 +506,17 @@ status_t ZipEntry::LocalFileHeader::write(FILE* fp)
*/
void ZipEntry::LocalFileHeader::dump(void) const
{
- LOGD(" LocalFileHeader contents:\n");
- LOGD(" versToExt=%u gpBits=0x%04x compression=%u\n",
+ ALOGD(" LocalFileHeader contents:\n");
+ ALOGD(" versToExt=%u gpBits=0x%04x compression=%u\n",
mVersionToExtract, mGPBitFlag, mCompressionMethod);
- LOGD(" modTime=0x%04x modDate=0x%04x crc32=0x%08lx\n",
+ ALOGD(" modTime=0x%04x modDate=0x%04x crc32=0x%08lx\n",
mLastModFileTime, mLastModFileDate, mCRC32);
- LOGD(" compressedSize=%lu uncompressedSize=%lu\n",
+ ALOGD(" compressedSize=%lu uncompressedSize=%lu\n",
mCompressedSize, mUncompressedSize);
- LOGD(" filenameLen=%u extraLen=%u\n",
+ ALOGD(" filenameLen=%u extraLen=%u\n",
mFileNameLength, mExtraFieldLength);
if (mFileName != NULL)
- LOGD(" filename: '%s'\n", mFileName);
+ ALOGD(" filename: '%s'\n", mFileName);
}
@@ -549,7 +549,7 @@ status_t ZipEntry::CentralDirEntry::read(FILE* fp)
}
if (ZipEntry::getLongLE(&buf[0x00]) != kSignature) {
- LOGD("Whoops: didn't find expected signature\n");
+ ALOGD("Whoops: didn't find expected signature\n");
result = UNKNOWN_ERROR;
goto bail;
}
@@ -675,22 +675,22 @@ status_t ZipEntry::CentralDirEntry::write(FILE* fp)
*/
void ZipEntry::CentralDirEntry::dump(void) const
{
- LOGD(" CentralDirEntry contents:\n");
- LOGD(" versMadeBy=%u versToExt=%u gpBits=0x%04x compression=%u\n",
+ ALOGD(" CentralDirEntry contents:\n");
+ ALOGD(" versMadeBy=%u versToExt=%u gpBits=0x%04x compression=%u\n",
mVersionMadeBy, mVersionToExtract, mGPBitFlag, mCompressionMethod);
- LOGD(" modTime=0x%04x modDate=0x%04x crc32=0x%08lx\n",
+ ALOGD(" modTime=0x%04x modDate=0x%04x crc32=0x%08lx\n",
mLastModFileTime, mLastModFileDate, mCRC32);
- LOGD(" compressedSize=%lu uncompressedSize=%lu\n",
+ ALOGD(" compressedSize=%lu uncompressedSize=%lu\n",
mCompressedSize, mUncompressedSize);
- LOGD(" filenameLen=%u extraLen=%u commentLen=%u\n",
+ ALOGD(" filenameLen=%u extraLen=%u commentLen=%u\n",
mFileNameLength, mExtraFieldLength, mFileCommentLength);
- LOGD(" diskNumStart=%u intAttr=0x%04x extAttr=0x%08lx relOffset=%lu\n",
+ ALOGD(" diskNumStart=%u intAttr=0x%04x extAttr=0x%08lx relOffset=%lu\n",
mDiskNumberStart, mInternalAttrs, mExternalAttrs,
mLocalHeaderRelOffset);
if (mFileName != NULL)
- LOGD(" filename: '%s'\n", mFileName);
+ ALOGD(" filename: '%s'\n", mFileName);
if (mFileComment != NULL)
- LOGD(" comment: '%s'\n", mFileComment);
+ ALOGD(" comment: '%s'\n", mFileComment);
}
diff --git a/tools/aapt/ZipFile.cpp b/tools/aapt/ZipFile.cpp
index 62c9383..3994c31 100644
--- a/tools/aapt/ZipFile.cpp
+++ b/tools/aapt/ZipFile.cpp
@@ -20,8 +20,8 @@
#define LOG_TAG "zip"
-#include <utils/ZipUtils.h>
#include <utils/Log.h>
+#include <utils/ZipUtils.h>
#include "ZipFile.h"
@@ -78,7 +78,7 @@ status_t ZipFile::open(const char* zipFileName, int flags)
newArchive = (access(zipFileName, F_OK) != 0);
if (!(flags & kOpenCreate) && newArchive) {
/* not creating, must already exist */
- LOGD("File %s does not exist", zipFileName);
+ ALOGD("File %s does not exist", zipFileName);
return NAME_NOT_FOUND;
}
}
@@ -96,7 +96,7 @@ status_t ZipFile::open(const char* zipFileName, int flags)
mZipFp = fopen(zipFileName, openflags);
if (mZipFp == NULL) {
int err = errno;
- LOGD("fopen failed: %d\n", err);
+ ALOGD("fopen failed: %d\n", err);
return errnoToStatus(err);
}
@@ -215,14 +215,14 @@ status_t ZipFile::readCentralDir(void)
/* too small to be a ZIP archive? */
if (fileLength < EndOfCentralDir::kEOCDLen) {
- LOGD("Length is %ld -- too small\n", (long)fileLength);
+ ALOGD("Length is %ld -- too small\n", (long)fileLength);
result = INVALID_OPERATION;
goto bail;
}
buf = new unsigned char[EndOfCentralDir::kMaxEOCDSearch];
if (buf == NULL) {
- LOGD("Failure allocating %d bytes for EOCD search",
+ ALOGD("Failure allocating %d bytes for EOCD search",
EndOfCentralDir::kMaxEOCDSearch);
result = NO_MEMORY;
goto bail;
@@ -236,14 +236,14 @@ status_t ZipFile::readCentralDir(void)
readAmount = (long) fileLength;
}
if (fseek(mZipFp, seekStart, SEEK_SET) != 0) {
- LOGD("Failure seeking to end of zip at %ld", (long) seekStart);
+ ALOGD("Failure seeking to end of zip at %ld", (long) seekStart);
result = UNKNOWN_ERROR;
goto bail;
}
/* read the last part of the file into the buffer */
if (fread(buf, 1, readAmount, mZipFp) != (size_t) readAmount) {
- LOGD("short file? wanted %ld\n", readAmount);
+ ALOGD("short file? wanted %ld\n", readAmount);
result = UNKNOWN_ERROR;
goto bail;
}
@@ -253,12 +253,12 @@ status_t ZipFile::readCentralDir(void)
if (buf[i] == 0x50 &&
ZipEntry::getLongLE(&buf[i]) == EndOfCentralDir::kSignature)
{
- LOGV("+++ Found EOCD at buf+%d\n", i);
+ ALOGV("+++ Found EOCD at buf+%d\n", i);
break;
}
}
if (i < 0) {
- LOGD("EOCD not found, not Zip\n");
+ ALOGD("EOCD not found, not Zip\n");
result = INVALID_OPERATION;
goto bail;
}
@@ -266,7 +266,7 @@ status_t ZipFile::readCentralDir(void)
/* extract eocd values */
result = mEOCD.readBuf(buf + i, readAmount - i);
if (result != NO_ERROR) {
- LOGD("Failure reading %ld bytes of EOCD values", readAmount - i);
+ ALOGD("Failure reading %ld bytes of EOCD values", readAmount - i);
goto bail;
}
//mEOCD.dump();
@@ -274,7 +274,7 @@ status_t ZipFile::readCentralDir(void)
if (mEOCD.mDiskNumber != 0 || mEOCD.mDiskWithCentralDir != 0 ||
mEOCD.mNumEntries != mEOCD.mTotalNumEntries)
{
- LOGD("Archive spanning not supported\n");
+ ALOGD("Archive spanning not supported\n");
result = INVALID_OPERATION;
goto bail;
}
@@ -294,7 +294,7 @@ status_t ZipFile::readCentralDir(void)
* we're hoping to preserve.
*/
if (fseek(mZipFp, mEOCD.mCentralDirOffset, SEEK_SET) != 0) {
- LOGD("Failure seeking to central dir offset %ld\n",
+ ALOGD("Failure seeking to central dir offset %ld\n",
mEOCD.mCentralDirOffset);
result = UNKNOWN_ERROR;
goto bail;
@@ -303,14 +303,14 @@ status_t ZipFile::readCentralDir(void)
/*
* Loop through and read the central dir entries.
*/
- LOGV("Scanning %d entries...\n", mEOCD.mTotalNumEntries);
+ ALOGV("Scanning %d entries...\n", mEOCD.mTotalNumEntries);
int entry;
for (entry = 0; entry < mEOCD.mTotalNumEntries; entry++) {
ZipEntry* pEntry = new ZipEntry;
result = pEntry->initFromCDE(mZipFp);
if (result != NO_ERROR) {
- LOGD("initFromCDE failed\n");
+ ALOGD("initFromCDE failed\n");
delete pEntry;
goto bail;
}
@@ -325,16 +325,16 @@ status_t ZipFile::readCentralDir(void)
{
unsigned char checkBuf[4];
if (fread(checkBuf, 1, 4, mZipFp) != 4) {
- LOGD("EOCD check read failed\n");
+ ALOGD("EOCD check read failed\n");
result = INVALID_OPERATION;
goto bail;
}
if (ZipEntry::getLongLE(checkBuf) != EndOfCentralDir::kSignature) {
- LOGD("EOCD read check failed\n");
+ ALOGD("EOCD read check failed\n");
result = UNKNOWN_ERROR;
goto bail;
}
- LOGV("+++ EOCD read check passed\n");
+ ALOGV("+++ EOCD read check passed\n");
}
bail:
@@ -416,7 +416,7 @@ status_t ZipFile::addCommon(const char* fileName, const void* data, size_t size,
bool failed = false;
result = compressFpToFp(mZipFp, inputFp, data, size, &crc);
if (result != NO_ERROR) {
- LOGD("compression failed, storing\n");
+ ALOGD("compression failed, storing\n");
failed = true;
} else {
/*
@@ -427,7 +427,7 @@ status_t ZipFile::addCommon(const char* fileName, const void* data, size_t size,
long src = inputFp ? ftell(inputFp) : size;
long dst = ftell(mZipFp) - startPosn;
if (dst + (dst / 10) > src) {
- LOGD("insufficient compression (src=%ld dst=%ld), storing\n",
+ ALOGD("insufficient compression (src=%ld dst=%ld), storing\n",
src, dst);
failed = true;
}
@@ -449,7 +449,7 @@ status_t ZipFile::addCommon(const char* fileName, const void* data, size_t size,
}
if (result != NO_ERROR) {
// don't need to truncate; happens in CDE rewrite
- LOGD("failed copying data in\n");
+ ALOGD("failed copying data in\n");
goto bail;
}
}
@@ -468,14 +468,14 @@ status_t ZipFile::addCommon(const char* fileName, const void* data, size_t size,
scanResult = ZipUtils::examineGzip(inputFp, &method, &uncompressedLen,
&compressedLen, &crc);
if (!scanResult || method != ZipEntry::kCompressDeflated) {
- LOGD("this isn't a deflated gzip file?");
+ ALOGD("this isn't a deflated gzip file?");
result = UNKNOWN_ERROR;
goto bail;
}
result = copyPartialFpToFp(mZipFp, inputFp, compressedLen, NULL);
if (result != NO_ERROR) {
- LOGD("failed copying gzip data in\n");
+ ALOGD("failed copying gzip data in\n");
goto bail;
}
} else {
@@ -603,7 +603,7 @@ status_t ZipFile::add(const ZipFile* pSourceZip, const ZipEntry* pSourceEntry,
if (copyPartialFpToFp(mZipFp, pSourceZip->mZipFp, copyLen, NULL)
!= NO_ERROR)
{
- LOGW("copy of '%s' failed\n", pEntry->mCDE.mFileName);
+ ALOGW("copy of '%s' failed\n", pEntry->mCDE.mFileName);
result = UNKNOWN_ERROR;
goto bail;
}
@@ -660,7 +660,7 @@ status_t ZipFile::copyFpToFp(FILE* dstFp, FILE* srcFp, unsigned long* pCRC32)
*pCRC32 = crc32(*pCRC32, tmpBuf, count);
if (fwrite(tmpBuf, 1, count, dstFp) != count) {
- LOGD("fwrite %d bytes failed\n", (int) count);
+ ALOGD("fwrite %d bytes failed\n", (int) count);
return UNKNOWN_ERROR;
}
}
@@ -682,7 +682,7 @@ status_t ZipFile::copyDataToFp(FILE* dstFp,
if (size > 0) {
*pCRC32 = crc32(*pCRC32, (const unsigned char*)data, size);
if (fwrite(data, 1, size, dstFp) != size) {
- LOGD("fwrite %d bytes failed\n", (int) size);
+ ALOGD("fwrite %d bytes failed\n", (int) size);
return UNKNOWN_ERROR;
}
}
@@ -716,7 +716,7 @@ status_t ZipFile::copyPartialFpToFp(FILE* dstFp, FILE* srcFp, long length,
count = fread(tmpBuf, 1, readSize, srcFp);
if ((long) count != readSize) { // error or unexpected EOF
- LOGD("fread %d bytes failed\n", (int) readSize);
+ ALOGD("fread %d bytes failed\n", (int) readSize);
return UNKNOWN_ERROR;
}
@@ -724,7 +724,7 @@ status_t ZipFile::copyPartialFpToFp(FILE* dstFp, FILE* srcFp, long length,
*pCRC32 = crc32(*pCRC32, tmpBuf, count);
if (fwrite(tmpBuf, 1, count, dstFp) != count) {
- LOGD("fwrite %d bytes failed\n", (int) count);
+ ALOGD("fwrite %d bytes failed\n", (int) count);
return UNKNOWN_ERROR;
}
@@ -780,10 +780,10 @@ status_t ZipFile::compressFpToFp(FILE* dstFp, FILE* srcFp,
if (zerr != Z_OK) {
result = UNKNOWN_ERROR;
if (zerr == Z_VERSION_ERROR) {
- LOGE("Installed zlib is not compatible with linked version (%s)\n",
+ ALOGE("Installed zlib is not compatible with linked version (%s)\n",
ZLIB_VERSION);
} else {
- LOGD("Call to deflateInit2 failed (zerr=%d)\n", zerr);
+ ALOGD("Call to deflateInit2 failed (zerr=%d)\n", zerr);
}
goto bail;
}
@@ -799,7 +799,7 @@ status_t ZipFile::compressFpToFp(FILE* dstFp, FILE* srcFp,
/* only read if the input buffer is empty */
if (zstream.avail_in == 0 && !atEof) {
- LOGV("+++ reading %d bytes\n", (int)kBufSize);
+ ALOGV("+++ reading %d bytes\n", (int)kBufSize);
if (data) {
getSize = size > kBufSize ? kBufSize : size;
memcpy(inBuf, data, getSize);
@@ -808,12 +808,12 @@ status_t ZipFile::compressFpToFp(FILE* dstFp, FILE* srcFp,
} else {
getSize = fread(inBuf, 1, kBufSize, srcFp);
if (ferror(srcFp)) {
- LOGD("deflate read failed (errno=%d)\n", errno);
+ ALOGD("deflate read failed (errno=%d)\n", errno);
goto z_bail;
}
}
if (getSize < kBufSize) {
- LOGV("+++ got %d bytes, EOF reached\n",
+ ALOGV("+++ got %d bytes, EOF reached\n",
(int)getSize);
atEof = true;
}
@@ -831,7 +831,7 @@ status_t ZipFile::compressFpToFp(FILE* dstFp, FILE* srcFp,
zerr = deflate(&zstream, flush);
if (zerr != Z_OK && zerr != Z_STREAM_END) {
- LOGD("zlib deflate call failed (zerr=%d)\n", zerr);
+ ALOGD("zlib deflate call failed (zerr=%d)\n", zerr);
result = UNKNOWN_ERROR;
goto z_bail;
}
@@ -840,11 +840,11 @@ status_t ZipFile::compressFpToFp(FILE* dstFp, FILE* srcFp,
if (zstream.avail_out == 0 ||
(zerr == Z_STREAM_END && zstream.avail_out != (uInt) kBufSize))
{
- LOGV("+++ writing %d bytes\n", (int) (zstream.next_out - outBuf));
+ ALOGV("+++ writing %d bytes\n", (int) (zstream.next_out - outBuf));
if (fwrite(outBuf, 1, zstream.next_out - outBuf, dstFp) !=
(size_t)(zstream.next_out - outBuf))
{
- LOGD("write %d failed in deflate\n",
+ ALOGD("write %d failed in deflate\n",
(int) (zstream.next_out - outBuf));
goto z_bail;
}
@@ -931,7 +931,7 @@ status_t ZipFile::flush(void)
* of wasted space at the end of the file. Remove it now.
*/
if (ftruncate(fileno(mZipFp), ftell(mZipFp)) != 0) {
- LOGW("ftruncate failed %ld: %s\n", ftell(mZipFp), strerror(errno));
+ ALOGW("ftruncate failed %ld: %s\n", ftell(mZipFp), strerror(errno));
// not fatal
}
@@ -1019,7 +1019,7 @@ status_t ZipFile::crunchArchive(void)
pEntry->getLFHOffset(), span);
if (result != NO_ERROR) {
/* this is why you use a temp file */
- LOGE("error during crunch - archive is toast\n");
+ ALOGE("error during crunch - archive is toast\n");
return result;
}
@@ -1061,23 +1061,23 @@ status_t ZipFile::filemove(FILE* fp, off_t dst, off_t src, size_t n)
getSize = n;
if (fseek(fp, (long) src, SEEK_SET) != 0) {
- LOGD("filemove src seek %ld failed\n", (long) src);
+ ALOGD("filemove src seek %ld failed\n", (long) src);
return UNKNOWN_ERROR;
}
if (fread(readBuf, 1, getSize, fp) != getSize) {
- LOGD("filemove read %ld off=%ld failed\n",
+ ALOGD("filemove read %ld off=%ld failed\n",
(long) getSize, (long) src);
return UNKNOWN_ERROR;
}
if (fseek(fp, (long) dst, SEEK_SET) != 0) {
- LOGD("filemove dst seek %ld failed\n", (long) dst);
+ ALOGD("filemove dst seek %ld failed\n", (long) dst);
return UNKNOWN_ERROR;
}
if (fwrite(readBuf, 1, getSize, fp) != getSize) {
- LOGD("filemove write %ld off=%ld failed\n",
+ ALOGD("filemove write %ld off=%ld failed\n",
(long) getSize, (long) dst);
return UNKNOWN_ERROR;
}
@@ -1104,7 +1104,7 @@ time_t ZipFile::getModTime(int fd)
struct stat sb;
if (fstat(fd, &sb) < 0) {
- LOGD("HEY: fstat on fd %d failed\n", fd);
+ ALOGD("HEY: fstat on fd %d failed\n", fd);
return (time_t) -1;
}
@@ -1129,7 +1129,7 @@ int ZipFile::getZipFd(void) const
int fd;
fd = dup(fileno(mZipFp));
if (fd < 0) {
- LOGD("didn't work, errno=%d\n", errno);
+ ALOGD("didn't work, errno=%d\n", errno);
}
return fd;
@@ -1224,7 +1224,7 @@ status_t ZipFile::EndOfCentralDir::readBuf(const unsigned char* buf, int len)
if (len < kEOCDLen) {
/* looks like ZIP file got truncated */
- LOGD(" Zip EOCD: expected >= %d bytes, found %d\n",
+ ALOGD(" Zip EOCD: expected >= %d bytes, found %d\n",
kEOCDLen, len);
return INVALID_OPERATION;
}
@@ -1245,7 +1245,7 @@ status_t ZipFile::EndOfCentralDir::readBuf(const unsigned char* buf, int len)
if (mCommentLen > 0) {
if (kEOCDLen + mCommentLen > len) {
- LOGD("EOCD(%d) + comment(%d) exceeds len (%d)\n",
+ ALOGD("EOCD(%d) + comment(%d) exceeds len (%d)\n",
kEOCDLen, mCommentLen, len);
return UNKNOWN_ERROR;
}
@@ -1288,10 +1288,10 @@ status_t ZipFile::EndOfCentralDir::write(FILE* fp)
*/
void ZipFile::EndOfCentralDir::dump(void) const
{
- LOGD(" EndOfCentralDir contents:\n");
- LOGD(" diskNum=%u diskWCD=%u numEnt=%u totalNumEnt=%u\n",
+ ALOGD(" EndOfCentralDir contents:\n");
+ ALOGD(" diskNum=%u diskWCD=%u numEnt=%u totalNumEnt=%u\n",
mDiskNumber, mDiskWithCentralDir, mNumEntries, mTotalNumEntries);
- LOGD(" centDirSize=%lu centDirOff=%lu commentLen=%u\n",
+ ALOGD(" centDirSize=%lu centDirOff=%lu commentLen=%u\n",
mCentralDirSize, mCentralDirOffset, mCommentLen);
}
diff --git a/tools/aidl/Type.cpp b/tools/aidl/Type.cpp
index 700d6ef..d572af6 100755
--- a/tools/aidl/Type.cpp
+++ b/tools/aidl/Type.cpp
@@ -905,8 +905,7 @@ ListType::CreateFromRpcData(StatementBlock* addTo, Expression* k, Variable* v, V
UserDataType::UserDataType(const string& package, const string& name,
bool builtIn, bool canWriteToParcel, bool canWriteToRpcData,
const string& declFile, int declLine)
- //:Type(package, name, builtIn ? BUILT_IN : USERDATA, canWriteToParcel, canWriteToRpcData,
- :Type(package, name, builtIn ? BUILT_IN : USERDATA, true, true,
+ :Type(package, name, builtIn ? BUILT_IN : USERDATA, canWriteToParcel, canWriteToRpcData,
true, declFile, declLine)
{
}
diff --git a/tools/aidl/aidl.cpp b/tools/aidl/aidl.cpp
index 3d314db..8dbbf50 100644
--- a/tools/aidl/aidl.cpp
+++ b/tools/aidl/aidl.cpp
@@ -424,9 +424,8 @@ check_method(const char* filename, int kind, method_type* m)
} else {
if (!(kind == INTERFACE_TYPE_BINDER ? returnType->CanWriteToParcel()
: returnType->CanWriteToRpcData())) {
- fprintf(stderr, "%s:%d return type %s can't be marshalled. kind=%d p=%d m=%d\n", filename,
- m->type.type.lineno, m->type.type.data, kind,
- returnType->CanWriteToParcel(), returnType->CanWriteToRpcData());
+ fprintf(stderr, "%s:%d return type %s can't be marshalled.\n", filename,
+ m->type.type.lineno, m->type.type.data);
err = 1;
}
}
diff --git a/tools/aidl/aidl_language_y.y b/tools/aidl/aidl_language_y.y
index 3c16e15..cc04d15 100644
--- a/tools/aidl/aidl_language_y.y
+++ b/tools/aidl/aidl_language_y.y
@@ -87,7 +87,7 @@ parcelable_decl:
b->name = $2.buffer;
b->package = g_currentPackage ? strdup(g_currentPackage) : NULL;
b->semicolon_token = $3.buffer;
- b->flattening_methods = PARCELABLE_DATA | RPC_DATA;
+ b->flattening_methods = PARCELABLE_DATA;
$$.user_data = b;
}
| PARCELABLE ';' {
diff --git a/tools/aidl/generate_java_rpc.cpp b/tools/aidl/generate_java_rpc.cpp
index 2b50b76..e5fa076 100644
--- a/tools/aidl/generate_java_rpc.cpp
+++ b/tools/aidl/generate_java_rpc.cpp
@@ -5,7 +5,7 @@
#include <stdlib.h>
#include <string.h>
-Type* ANDROID_CONTEXT_TYPE = new Type("android.content",
+Type* SERVICE_CONTEXT_TYPE = new Type("android.content",
"Context", Type::BUILT_IN, false, false, false);
Type* PRESENTER_BASE_TYPE = new Type("android.support.place.connector",
"EventListener", Type::BUILT_IN, false, false, false);
@@ -13,6 +13,8 @@ Type* PRESENTER_LISTENER_BASE_TYPE = new Type("android.support.place.connector",
"EventListener.Listener", Type::BUILT_IN, false, false, false);
Type* RPC_BROKER_TYPE = new Type("android.support.place.connector", "Broker",
Type::BUILT_IN, false, false, false);
+Type* RPC_CONTAINER_TYPE = new Type("com.android.athome.connector", "ConnectorContainer",
+ Type::BUILT_IN, false, false, false);
Type* PLACE_INFO_TYPE = new Type("android.support.place.connector", "PlaceInfo",
Type::BUILT_IN, false, false, false);
// TODO: Just use Endpoint, so this works for all endpoints.
@@ -473,7 +475,7 @@ EndpointBaseClass::~EndpointBaseClass()
void
EndpointBaseClass::generate_ctor()
{
- Variable* container = new Variable(ANDROID_CONTEXT_TYPE, "context");
+ Variable* container = new Variable(RPC_CONTAINER_TYPE, "container");
Variable* broker = new Variable(RPC_BROKER_TYPE, "broker");
Variable* place = new Variable(PLACE_INFO_TYPE, "placeInfo");
Method* ctor = new Method;
diff --git a/tools/layoutlib/bridge/.settings/README.txt b/tools/layoutlib/bridge/.settings/README.txt
new file mode 100644
index 0000000..9120b20
--- /dev/null
+++ b/tools/layoutlib/bridge/.settings/README.txt
@@ -0,0 +1,2 @@
+Copy this in eclipse project as a .settings folder at the root.
+This ensure proper compilation compliance and warning/error levels. \ No newline at end of file
diff --git a/tools/layoutlib/bridge/.settings/org.eclipse.jdt.core.prefs b/tools/layoutlib/bridge/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 0000000..5381a0e
--- /dev/null
+++ b/tools/layoutlib/bridge/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,93 @@
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.annotation.nonnull=com.android.annotations.NonNull
+org.eclipse.jdt.core.compiler.annotation.nonnullbydefault=com.android.annotations.NonNullByDefault
+org.eclipse.jdt.core.compiler.annotation.nonnullisdefault=disabled
+org.eclipse.jdt.core.compiler.annotation.nullable=com.android.annotations.Nullable
+org.eclipse.jdt.core.compiler.annotation.nullanalysis=enabled
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
+org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
+org.eclipse.jdt.core.compiler.compliance=1.6
+org.eclipse.jdt.core.compiler.debug.lineNumber=generate
+org.eclipse.jdt.core.compiler.debug.localVariable=generate
+org.eclipse.jdt.core.compiler.debug.sourceFile=generate
+org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.autoboxing=ignore
+org.eclipse.jdt.core.compiler.problem.comparingIdentical=warning
+org.eclipse.jdt.core.compiler.problem.deadCode=warning
+org.eclipse.jdt.core.compiler.problem.deprecation=warning
+org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled
+org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled
+org.eclipse.jdt.core.compiler.problem.discouragedReference=warning
+org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=ignore
+org.eclipse.jdt.core.compiler.problem.fallthroughCase=warning
+org.eclipse.jdt.core.compiler.problem.fatalOptionalError=enabled
+org.eclipse.jdt.core.compiler.problem.fieldHiding=warning
+org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning
+org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning
+org.eclipse.jdt.core.compiler.problem.forbiddenReference=error
+org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning
+org.eclipse.jdt.core.compiler.problem.includeNullInfoFromAsserts=enabled
+org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning
+org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=ignore
+org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore
+org.eclipse.jdt.core.compiler.problem.localVariableHiding=warning
+org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning
+org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=warning
+org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=warning
+org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=error
+org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=enabled
+org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning
+org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore
+org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning
+org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning
+org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore
+org.eclipse.jdt.core.compiler.problem.nullReference=error
+org.eclipse.jdt.core.compiler.problem.nullSpecInsufficientInfo=warning
+org.eclipse.jdt.core.compiler.problem.nullSpecViolation=error
+org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning
+org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore
+org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=warning
+org.eclipse.jdt.core.compiler.problem.potentialNullReference=warning
+org.eclipse.jdt.core.compiler.problem.potentialNullSpecViolation=error
+org.eclipse.jdt.core.compiler.problem.potentiallyUnclosedCloseable=warning
+org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning
+org.eclipse.jdt.core.compiler.problem.redundantNullAnnotation=warning
+org.eclipse.jdt.core.compiler.problem.redundantNullCheck=ignore
+org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=ignore
+org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=warning
+org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=ignore
+org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=ignore
+org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled
+org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning
+org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=disabled
+org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled
+org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore
+org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning
+org.eclipse.jdt.core.compiler.problem.unavoidableGenericTypeProblems=disabled
+org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning
+org.eclipse.jdt.core.compiler.problem.unclosedCloseable=error
+org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore
+org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning
+org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore
+org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=warning
+org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore
+org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=warning
+org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled
+org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled
+org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled
+org.eclipse.jdt.core.compiler.problem.unusedImport=warning
+org.eclipse.jdt.core.compiler.problem.unusedLabel=warning
+org.eclipse.jdt.core.compiler.problem.unusedLocal=warning
+org.eclipse.jdt.core.compiler.problem.unusedObjectAllocation=warning
+org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore
+org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled
+org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled
+org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled
+org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning
+org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning
+org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning
+org.eclipse.jdt.core.compiler.source=1.6
diff --git a/tools/layoutlib/bridge/src/android/animation/AnimationThread.java b/tools/layoutlib/bridge/src/android/animation/AnimationThread.java
index 2b5e4fa..b46134a 100644
--- a/tools/layoutlib/bridge/src/android/animation/AnimationThread.java
+++ b/tools/layoutlib/bridge/src/android/animation/AnimationThread.java
@@ -23,11 +23,10 @@ import com.android.ide.common.rendering.api.Result.Status;
import com.android.layoutlib.bridge.Bridge;
import com.android.layoutlib.bridge.impl.RenderSessionImpl;
-import android.animation.ValueAnimator;
import android.os.Handler;
import android.os.Handler_Delegate;
-import android.os.Message;
import android.os.Handler_Delegate.IHandlerCallback;
+import android.os.Message;
import java.util.PriorityQueue;
import java.util.Queue;
@@ -57,6 +56,7 @@ public abstract class AnimationThread extends Thread {
mUptimeMillis = uptimeMillis;
}
+ @Override
public int compareTo(MessageBundle bundle) {
if (mUptimeMillis < bundle.mUptimeMillis) {
return -1;
@@ -85,9 +85,13 @@ public abstract class AnimationThread extends Thread {
Bridge.prepareThread();
try {
Handler_Delegate.setCallback(new IHandlerCallback() {
+ @Override
public void sendMessageAtTime(Handler handler, Message msg, long uptimeMillis) {
- if (msg.what == ValueAnimator.ANIMATION_START ||
- msg.what == ValueAnimator.ANIMATION_FRAME) {
+ if (msg.what == ValueAnimator.ANIMATION_START /*||
+ FIXME: The ANIMATION_FRAME message no longer exists. Instead,
+ the animation timing loop is based on a Choreographer object
+ that schedules animation and drawing frames.
+ msg.what == ValueAnimator.ANIMATION_FRAME*/) {
mQueue.add(new MessageBundle(handler, msg, uptimeMillis));
} else {
// just ignore.
diff --git a/tools/layoutlib/bridge/src/android/content/res/BridgeResources.java b/tools/layoutlib/bridge/src/android/content/res/BridgeResources.java
index 7b672da..8794452 100644
--- a/tools/layoutlib/bridge/src/android/content/res/BridgeResources.java
+++ b/tools/layoutlib/bridge/src/android/content/res/BridgeResources.java
@@ -120,10 +120,8 @@ public final class BridgeResources extends Resources {
mProjectCallback = projectCallback;
}
- public BridgeTypedArray newTypeArray(int numEntries, boolean platformFile,
- boolean platformStyleable, String styleableName) {
- return new BridgeTypedArray(this, mContext, numEntries, platformFile,
- platformStyleable, styleableName);
+ public BridgeTypedArray newTypeArray(int numEntries, boolean platformFile) {
+ return new BridgeTypedArray(this, mContext, numEntries, platformFile);
}
private Pair<String, ResourceValue> getResourceValue(int id, boolean[] platformResFlag_out) {
diff --git a/tools/layoutlib/bridge/src/android/content/res/BridgeTypedArray.java b/tools/layoutlib/bridge/src/android/content/res/BridgeTypedArray.java
index 8fdac02..cbc199a 100644
--- a/tools/layoutlib/bridge/src/android/content/res/BridgeTypedArray.java
+++ b/tools/layoutlib/bridge/src/android/content/res/BridgeTypedArray.java
@@ -16,7 +16,7 @@
package android.content.res;
-import com.android.ide.common.rendering.api.DeclareStyleableResourceValue;
+import com.android.ide.common.rendering.api.AttrResourceValue;
import com.android.ide.common.rendering.api.LayoutLog;
import com.android.ide.common.rendering.api.RenderResources;
import com.android.ide.common.rendering.api.ResourceValue;
@@ -51,28 +51,33 @@ public final class BridgeTypedArray extends TypedArray {
private final BridgeResources mBridgeResources;
private final BridgeContext mContext;
private final boolean mPlatformFile;
- private final boolean mPlatformStyleable;
- private final String mStyleableName;
private ResourceValue[] mResourceData;
private String[] mNames;
+ private boolean[] mIsFramework;
public BridgeTypedArray(BridgeResources resources, BridgeContext context, int len,
- boolean platformFile, boolean platformStyleable, String styleableName) {
+ boolean platformFile) {
super(null, null, null, 0);
mBridgeResources = resources;
mContext = context;
mPlatformFile = platformFile;
- mPlatformStyleable = platformStyleable;
- mStyleableName = styleableName;
mResourceData = new ResourceValue[len];
mNames = new String[len];
+ mIsFramework = new boolean[len];
}
- /** A bridge-specific method that sets a value in the type array */
- public void bridgeSetValue(int index, String name, ResourceValue value) {
+ /**
+ * A bridge-specific method that sets a value in the type array
+ * @param index the index of the value in the TypedArray
+ * @param name the name of the attribute
+ * @param isFramework whether the attribute is in the android namespace.
+ * @param value the value of the attribute
+ */
+ public void bridgeSetValue(int index, String name, boolean isFramework, ResourceValue value) {
mResourceData[index] = value;
mNames[index] = name;
+ mIsFramework[index] = isFramework;
}
/**
@@ -213,8 +218,12 @@ public final class BridgeTypedArray extends TypedArray {
return defValue;
}
+ if (s == null) {
+ return defValue;
+ }
+
try {
- return (s == null) ? defValue : XmlUtils.convertValueToInt(s, defValue);
+ return XmlUtils.convertValueToInt(s, defValue);
} catch (NumberFormatException e) {
// pass
}
@@ -223,15 +232,14 @@ public final class BridgeTypedArray extends TypedArray {
// Check for possible constants and try to find them.
// Get the map of attribute-constant -> IntegerValue
Map<String, Integer> map = null;
- if (mPlatformStyleable) {
+ if (mIsFramework[index]) {
map = Bridge.getEnumValues(mNames[index]);
- } else if (mStyleableName != null) {
+ } else {
// get the styleable matching the resolved name
RenderResources res = mContext.getRenderResources();
- ResourceValue styleable = res.getProjectResource(ResourceType.DECLARE_STYLEABLE,
- mStyleableName);
- if (styleable instanceof DeclareStyleableResourceValue) {
- map = ((DeclareStyleableResourceValue) styleable).getAttributeValues(mNames[index]);
+ ResourceValue attr = res.getProjectResource(ResourceType.ATTR, mNames[index]);
+ if (attr instanceof AttrResourceValue) {
+ map = ((AttrResourceValue) attr).getAttributeValues();
}
}
diff --git a/tools/layoutlib/bridge/src/android/graphics/BitmapFactory_Delegate.java b/tools/layoutlib/bridge/src/android/graphics/BitmapFactory_Delegate.java
index 945b3cd..5256b58 100644
--- a/tools/layoutlib/bridge/src/android/graphics/BitmapFactory_Delegate.java
+++ b/tools/layoutlib/bridge/src/android/graphics/BitmapFactory_Delegate.java
@@ -85,15 +85,18 @@ import java.io.InputStream;
// ------ Native Delegates ------
@LayoutlibDelegate
- /*package*/ static void nativeSetDefaultConfig(int nativeConfig) {
- // pass
+ /*package*/ static Bitmap nativeDecodeStream(InputStream is, byte[] storage,
+ Rect padding, Options opts) {
+ return nativeDecodeStream(is, storage, padding, opts, false, 1.f);
}
@LayoutlibDelegate
- /*package*/ static Bitmap nativeDecodeStream(InputStream is, byte[] storage,
- Rect padding, Options opts) {
+ /*package*/ static Bitmap nativeDecodeStream(InputStream is, byte[] storage,
+ Rect padding, Options opts, boolean applyScale, float scale) {
Bitmap bm = null;
+ //TODO support rescaling
+
Density density = Density.MEDIUM;
if (opts != null) {
density = Density.getEnum(opts.inDensity);
@@ -147,6 +150,13 @@ import java.io.InputStream;
}
@LayoutlibDelegate
+ /*package*/ static Bitmap nativeDecodeAsset(int asset, Rect padding, Options opts,
+ boolean applyScale, float scale) {
+ opts.inBitmap = null;
+ return null;
+ }
+
+ @LayoutlibDelegate
/*package*/ static Bitmap nativeDecodeByteArray(byte[] data, int offset,
int length, Options opts) {
opts.inBitmap = null;
diff --git a/tools/layoutlib/bridge/src/android/graphics/BitmapShader_Delegate.java b/tools/layoutlib/bridge/src/android/graphics/BitmapShader_Delegate.java
index 9a8cf04..65a75b0 100644
--- a/tools/layoutlib/bridge/src/android/graphics/BitmapShader_Delegate.java
+++ b/tools/layoutlib/bridge/src/android/graphics/BitmapShader_Delegate.java
@@ -105,6 +105,7 @@ public class BitmapShader_Delegate extends Shader_Delegate {
mTileModeY = tileModeY;
}
+ @Override
public java.awt.PaintContext createContext(
java.awt.image.ColorModel colorModel,
java.awt.Rectangle deviceBounds,
@@ -148,13 +149,16 @@ public class BitmapShader_Delegate extends Shader_Delegate {
mColorModel = colorModel;
}
+ @Override
public void dispose() {
}
+ @Override
public java.awt.image.ColorModel getColorModel() {
return mColorModel;
}
+ @Override
public java.awt.image.Raster getRaster(int x, int y, int w, int h) {
java.awt.image.BufferedImage image = new java.awt.image.BufferedImage(w, h,
java.awt.image.BufferedImage.TYPE_INT_ARGB);
@@ -240,6 +244,7 @@ public class BitmapShader_Delegate extends Shader_Delegate {
}
+ @Override
public int getTransparency() {
return java.awt.Paint.TRANSLUCENT;
}
diff --git a/tools/layoutlib/bridge/src/android/graphics/Bitmap_Delegate.java b/tools/layoutlib/bridge/src/android/graphics/Bitmap_Delegate.java
index eadec02..b76b8cf 100644
--- a/tools/layoutlib/bridge/src/android/graphics/Bitmap_Delegate.java
+++ b/tools/layoutlib/bridge/src/android/graphics/Bitmap_Delegate.java
@@ -524,7 +524,8 @@ public final class Bitmap_Delegate {
int nativeInt = sManager.addNewDelegate(delegate);
// and create/return a new Bitmap with it
- return new Bitmap(nativeInt, null /* buffer */, isMutable, null /*ninePatchChunk*/, density);
+ return new Bitmap(nativeInt, null /* buffer */, isMutable, null /*ninePatchChunk*/,
+ density);
}
/**
diff --git a/tools/layoutlib/bridge/src/android/graphics/Canvas_Delegate.java b/tools/layoutlib/bridge/src/android/graphics/Canvas_Delegate.java
index 8e3ed93..16f1575 100644
--- a/tools/layoutlib/bridge/src/android/graphics/Canvas_Delegate.java
+++ b/tools/layoutlib/bridge/src/android/graphics/Canvas_Delegate.java
@@ -291,6 +291,7 @@ public final class Canvas_Delegate {
Paint paint) {
draw(thisCanvas.mNativeCanvas, paint.mNativePaint, false /*compositeOnly*/,
false /*forceSrcMode*/, new GcSnapshot.Drawable() {
+ @Override
public void draw(Graphics2D graphics, Paint_Delegate paintDelegate) {
for (int i = 0 ; i < count ; i += 4) {
graphics.drawLine((int)pts[i + offset], (int)pts[i + offset + 1],
@@ -619,6 +620,7 @@ public final class Canvas_Delegate {
final int h = canvasDelegate.mBitmap.getImage().getHeight();
draw(nativeCanvas, new GcSnapshot.Drawable() {
+ @Override
public void draw(Graphics2D graphics, Paint_Delegate paint) {
// reset its transform just in case
graphics.setTransform(new AffineTransform());
@@ -651,6 +653,7 @@ public final class Canvas_Delegate {
draw(nativeCanvas, paint, false /*compositeOnly*/, false /*forceSrcMode*/,
new GcSnapshot.Drawable() {
+ @Override
public void draw(Graphics2D graphics, Paint_Delegate paintDelegate) {
graphics.drawLine((int)startX, (int)startY, (int)stopX, (int)stopY);
}
@@ -669,6 +672,7 @@ public final class Canvas_Delegate {
draw(nativeCanvas, paint, false /*compositeOnly*/, false /*forceSrcMode*/,
new GcSnapshot.Drawable() {
+ @Override
public void draw(Graphics2D graphics, Paint_Delegate paintDelegate) {
int style = paintDelegate.getStyle();
@@ -693,6 +697,7 @@ public final class Canvas_Delegate {
if (oval.right > oval.left && oval.bottom > oval.top) {
draw(nativeCanvas, paint, false /*compositeOnly*/, false /*forceSrcMode*/,
new GcSnapshot.Drawable() {
+ @Override
public void draw(Graphics2D graphics, Paint_Delegate paintDelegate) {
int style = paintDelegate.getStyle();
@@ -717,7 +722,7 @@ public final class Canvas_Delegate {
/*package*/ static void native_drawCircle(int nativeCanvas,
float cx, float cy, float radius, int paint) {
native_drawOval(nativeCanvas,
- new RectF(cx - radius, cy - radius, radius, radius),
+ new RectF(cx - radius, cy - radius, cx + radius, cy + radius),
paint);
}
@@ -728,6 +733,7 @@ public final class Canvas_Delegate {
if (oval.right > oval.left && oval.bottom > oval.top) {
draw(nativeCanvas, paint, false /*compositeOnly*/, false /*forceSrcMode*/,
new GcSnapshot.Drawable() {
+ @Override
public void draw(Graphics2D graphics, Paint_Delegate paintDelegate) {
int style = paintDelegate.getStyle();
@@ -757,6 +763,7 @@ public final class Canvas_Delegate {
draw(nativeCanvas, paint, false /*compositeOnly*/, false /*forceSrcMode*/,
new GcSnapshot.Drawable() {
+ @Override
public void draw(Graphics2D graphics, Paint_Delegate paintDelegate) {
int style = paintDelegate.getStyle();
@@ -789,6 +796,7 @@ public final class Canvas_Delegate {
draw(nativeCanvas, paint, false /*compositeOnly*/, false /*forceSrcMode*/,
new GcSnapshot.Drawable() {
+ @Override
public void draw(Graphics2D graphics, Paint_Delegate paintDelegate) {
Shape shape = pathDelegate.getJavaShape();
int style = paintDelegate.getStyle();
@@ -892,6 +900,7 @@ public final class Canvas_Delegate {
draw(nativeCanvas, nativePaintOrZero, true /*compositeOnly*/, false /*forceSrcMode*/,
new GcSnapshot.Drawable() {
+ @Override
public void draw(Graphics2D graphics, Paint_Delegate paint) {
if (paint != null && paint.isFilterBitmap()) {
graphics.setRenderingHint(RenderingHints.KEY_INTERPOLATION,
@@ -931,6 +940,7 @@ public final class Canvas_Delegate {
final AffineTransform mtx = matrixDelegate.getAffineTransform();
canvasDelegate.getSnapshot().draw(new GcSnapshot.Drawable() {
+ @Override
public void draw(Graphics2D graphics, Paint_Delegate paint) {
if (paint != null && paint.isFilterBitmap()) {
graphics.setRenderingHint(RenderingHints.KEY_INTERPOLATION,
@@ -970,6 +980,7 @@ public final class Canvas_Delegate {
final float startX, final float startY, int flags, int paint) {
draw(nativeCanvas, paint, false /*compositeOnly*/, false /*forceSrcMode*/,
new GcSnapshot.Drawable() {
+ @Override
public void draw(Graphics2D graphics, Paint_Delegate paintDelegate) {
// WARNING: the logic in this method is similar to Paint_Delegate.measureText.
// Any change to this method should be reflected in Paint.measureText
@@ -1279,6 +1290,7 @@ public final class Canvas_Delegate {
draw(nativeCanvas, nativePaintOrZero, true /*compositeOnly*/, sBoolOut[0],
new GcSnapshot.Drawable() {
+ @Override
public void draw(Graphics2D graphics, Paint_Delegate paint) {
if (paint != null && paint.isFilterBitmap()) {
graphics.setRenderingHint(RenderingHints.KEY_INTERPOLATION,
diff --git a/tools/layoutlib/bridge/src/android/graphics/Gradient_Delegate.java b/tools/layoutlib/bridge/src/android/graphics/Gradient_Delegate.java
index 38c092d..7475c22 100644
--- a/tools/layoutlib/bridge/src/android/graphics/Gradient_Delegate.java
+++ b/tools/layoutlib/bridge/src/android/graphics/Gradient_Delegate.java
@@ -87,6 +87,7 @@ public abstract class Gradient_Delegate extends Shader_Delegate {
mTileMode = tileMode;
}
+ @Override
public int getTransparency() {
return java.awt.Paint.TRANSLUCENT;
}
diff --git a/tools/layoutlib/bridge/src/android/graphics/LinearGradient_Delegate.java b/tools/layoutlib/bridge/src/android/graphics/LinearGradient_Delegate.java
index a2ba758..f117fca 100644
--- a/tools/layoutlib/bridge/src/android/graphics/LinearGradient_Delegate.java
+++ b/tools/layoutlib/bridge/src/android/graphics/LinearGradient_Delegate.java
@@ -132,6 +132,7 @@ public final class LinearGradient_Delegate extends Gradient_Delegate {
mDSize2 = mDx * mDx + mDy * mDy;
}
+ @Override
public java.awt.PaintContext createContext(
java.awt.image.ColorModel colorModel,
java.awt.Rectangle deviceBounds,
@@ -176,13 +177,16 @@ public final class LinearGradient_Delegate extends Gradient_Delegate {
mColorModel = colorModel;
}
+ @Override
public void dispose() {
}
+ @Override
public java.awt.image.ColorModel getColorModel() {
return mColorModel;
}
+ @Override
public java.awt.image.Raster getRaster(int x, int y, int w, int h) {
java.awt.image.BufferedImage image = new java.awt.image.BufferedImage(w, h,
java.awt.image.BufferedImage.TYPE_INT_ARGB);
diff --git a/tools/layoutlib/bridge/src/android/graphics/NinePatch_Delegate.java b/tools/layoutlib/bridge/src/android/graphics/NinePatch_Delegate.java
index 5e882ce..be27b54 100644
--- a/tools/layoutlib/bridge/src/android/graphics/NinePatch_Delegate.java
+++ b/tools/layoutlib/bridge/src/android/graphics/NinePatch_Delegate.java
@@ -215,6 +215,7 @@ public final class NinePatch_Delegate {
Paint_Delegate paint_delegate = Paint_Delegate.getDelegate(paint_instance_or_null);
canvas_delegate.getSnapshot().draw(new GcSnapshot.Drawable() {
+ @Override
public void draw(Graphics2D graphics, Paint_Delegate paint) {
chunkObject.draw(bitmap_delegate.getImage(), graphics,
left, top, right - left, bottom - top, destDensity, srcDensity);
diff --git a/tools/layoutlib/bridge/src/android/graphics/Paint_Delegate.java b/tools/layoutlib/bridge/src/android/graphics/Paint_Delegate.java
index 1523823..9ebec61 100644
--- a/tools/layoutlib/bridge/src/android/graphics/Paint_Delegate.java
+++ b/tools/layoutlib/bridge/src/android/graphics/Paint_Delegate.java
@@ -904,17 +904,6 @@ public class Paint_Delegate {
}
@LayoutlibDelegate
- /*package*/ static float native_getFontMetrics(int native_paint, FontMetrics metrics) {
- // get the delegate from the native int.
- Paint_Delegate delegate = sManager.getDelegate(native_paint);
- if (delegate == null) {
- return 0.f;
- }
-
- return delegate.getFontMetrics(metrics);
- }
-
- @LayoutlibDelegate
/*package*/ static int native_getTextWidths(int native_object, char[] text, int index,
int count, float[] widths) {
// get the delegate from the native int.
diff --git a/tools/layoutlib/bridge/src/android/graphics/RadialGradient_Delegate.java b/tools/layoutlib/bridge/src/android/graphics/RadialGradient_Delegate.java
index 9bf78b4..3fe45fa 100644
--- a/tools/layoutlib/bridge/src/android/graphics/RadialGradient_Delegate.java
+++ b/tools/layoutlib/bridge/src/android/graphics/RadialGradient_Delegate.java
@@ -118,6 +118,7 @@ public class RadialGradient_Delegate extends Gradient_Delegate {
mRadius = radius;
}
+ @Override
public java.awt.PaintContext createContext(
java.awt.image.ColorModel colorModel,
java.awt.Rectangle deviceBounds,
@@ -162,13 +163,16 @@ public class RadialGradient_Delegate extends Gradient_Delegate {
mColorModel = colorModel;
}
+ @Override
public void dispose() {
}
+ @Override
public java.awt.image.ColorModel getColorModel() {
return mColorModel;
}
+ @Override
public java.awt.image.Raster getRaster(int x, int y, int w, int h) {
java.awt.image.BufferedImage image = new java.awt.image.BufferedImage(w, h,
java.awt.image.BufferedImage.TYPE_INT_ARGB);
diff --git a/tools/layoutlib/bridge/src/android/graphics/SweepGradient_Delegate.java b/tools/layoutlib/bridge/src/android/graphics/SweepGradient_Delegate.java
index 966e06e..13ae12e 100644
--- a/tools/layoutlib/bridge/src/android/graphics/SweepGradient_Delegate.java
+++ b/tools/layoutlib/bridge/src/android/graphics/SweepGradient_Delegate.java
@@ -110,6 +110,7 @@ public class SweepGradient_Delegate extends Gradient_Delegate {
mCy = cy;
}
+ @Override
public java.awt.PaintContext createContext(
java.awt.image.ColorModel colorModel,
java.awt.Rectangle deviceBounds,
@@ -154,13 +155,16 @@ public class SweepGradient_Delegate extends Gradient_Delegate {
mColorModel = colorModel;
}
+ @Override
public void dispose() {
}
+ @Override
public java.awt.image.ColorModel getColorModel() {
return mColorModel;
}
+ @Override
public java.awt.image.Raster getRaster(int x, int y, int w, int h) {
java.awt.image.BufferedImage image = new java.awt.image.BufferedImage(w, h,
java.awt.image.BufferedImage.TYPE_INT_ARGB);
diff --git a/tools/layoutlib/bridge/src/android/view/AttachInfo_Accessor.java b/tools/layoutlib/bridge/src/android/view/AttachInfo_Accessor.java
index 96de51c..97d9969 100644
--- a/tools/layoutlib/bridge/src/android/view/AttachInfo_Accessor.java
+++ b/tools/layoutlib/bridge/src/android/view/AttachInfo_Accessor.java
@@ -29,7 +29,7 @@ public class AttachInfo_Accessor {
public static void setAttachInfo(View view) {
AttachInfo info = new AttachInfo(new BridgeWindowSession(), new BridgeWindow(),
- new Handler(), null);
+ new ViewRootImpl(view.getContext()), 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/SurfaceView.java b/tools/layoutlib/bridge/src/android/view/SurfaceView.java
index ce32da9..6aa4b3b 100644
--- a/tools/layoutlib/bridge/src/android/view/SurfaceView.java
+++ b/tools/layoutlib/bridge/src/android/view/SurfaceView.java
@@ -27,7 +27,7 @@ import android.util.AttributeSet;
* Mock version of the SurfaceView.
* Only non override public methods from the real SurfaceView have been added in there.
* Methods that take an unknown class as parameter or as return object, have been removed for now.
- *
+ *
* TODO: generate automatically.
*
*/
@@ -36,7 +36,7 @@ public class SurfaceView extends MockView {
public SurfaceView(Context context) {
this(context, null);
}
-
+
public SurfaceView(Context context, AttributeSet attrs) {
this(context, attrs , 0);
}
@@ -44,53 +44,66 @@ public class SurfaceView extends MockView {
public SurfaceView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
}
-
+
public SurfaceHolder getHolder() {
return mSurfaceHolder;
}
private SurfaceHolder mSurfaceHolder = new SurfaceHolder() {
-
+
+ @Override
public boolean isCreating() {
return false;
}
+ @Override
public void addCallback(Callback callback) {
}
+ @Override
public void removeCallback(Callback callback) {
}
-
+
+ @Override
public void setFixedSize(int width, int height) {
}
+ @Override
public void setSizeFromLayout() {
}
+ @Override
public void setFormat(int format) {
}
+ @Override
public void setType(int type) {
}
+ @Override
public void setKeepScreenOn(boolean screenOn) {
}
-
+
+ @Override
public Canvas lockCanvas() {
return null;
}
+ @Override
public Canvas lockCanvas(Rect dirty) {
return null;
}
+ @Override
public void unlockCanvasAndPost(Canvas canvas) {
}
+ @Override
public Surface getSurface() {
return null;
}
+ @Override
public Rect getSurfaceFrame() {
return null;
}
diff --git a/tools/layoutlib/bridge/src/android/view/ViewRootImpl_Delegate.java b/tools/layoutlib/bridge/src/android/view/ViewRootImpl_Delegate.java
new file mode 100644
index 0000000..14b84ef
--- /dev/null
+++ b/tools/layoutlib/bridge/src/android/view/ViewRootImpl_Delegate.java
@@ -0,0 +1,34 @@
+/*
+ * 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 ViewRootImpl}
+ *
+ * Through the layoutlib_create tool, the original methods of ViewRootImpl have been replaced
+ * by calls to methods of the same name in this delegate class.
+ *
+ */
+public class ViewRootImpl_Delegate {
+
+ @LayoutlibDelegate
+ /*package*/ static boolean isInTouchMode() {
+ return false; // this allows displaying selection.
+ }
+}
diff --git a/tools/layoutlib/bridge/src/com/android/internal/policy/PolicyManager.java b/tools/layoutlib/bridge/src/com/android/internal/policy/PolicyManager.java
new file mode 100644
index 0000000..0100dc5
--- /dev/null
+++ b/tools/layoutlib/bridge/src/com/android/internal/policy/PolicyManager.java
@@ -0,0 +1,72 @@
+/*
+ * 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.internal.policy;
+
+import com.android.ide.common.rendering.api.LayoutLog;
+import com.android.layoutlib.bridge.Bridge;
+import com.android.layoutlib.bridge.impl.RenderAction;
+
+import android.content.Context;
+import android.view.BridgeInflater;
+import android.view.FallbackEventHandler;
+import android.view.KeyEvent;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.Window;
+import android.view.WindowManagerPolicy;
+
+/**
+ * Custom implementation of PolicyManager that does nothing to run in LayoutLib.
+ *
+ */
+public class PolicyManager {
+
+ public static Window makeNewWindow(Context context) {
+ // this will likely crash somewhere beyond so we log it.
+ Bridge.getLog().error(LayoutLog.TAG_UNSUPPORTED,
+ "Call to PolicyManager.makeNewWindow is not supported", null);
+ return null;
+ }
+
+ public static LayoutInflater makeNewLayoutInflater(Context context) {
+ return new BridgeInflater(context, RenderAction.getCurrentContext().getProjectCallback());
+ }
+
+ public static WindowManagerPolicy makeNewWindowManager() {
+ // this will likely crash somewhere beyond so we log it.
+ Bridge.getLog().error(LayoutLog.TAG_UNSUPPORTED,
+ "Call to PolicyManager.makeNewWindowManager is not supported", null);
+ return null;
+ }
+
+ public static FallbackEventHandler makeNewFallbackEventHandler(Context context) {
+ return new FallbackEventHandler() {
+ @Override
+ public void setView(View v) {
+ }
+
+ @Override
+ public void preDispatchKeyEvent(KeyEvent event) {
+ }
+
+ @Override
+ public boolean dispatchKeyEvent(KeyEvent event) {
+ return false;
+ }
+ };
+ }
+}
diff --git a/tools/layoutlib/bridge/src/com/android/internal/textservice/ITextServicesManager_Stub_Delegate.java b/tools/layoutlib/bridge/src/com/android/internal/textservice/ITextServicesManager_Stub_Delegate.java
index 9efdcaf..3017292 100644
--- a/tools/layoutlib/bridge/src/com/android/internal/textservice/ITextServicesManager_Stub_Delegate.java
+++ b/tools/layoutlib/bridge/src/com/android/internal/textservice/ITextServicesManager_Stub_Delegate.java
@@ -43,28 +43,33 @@ public class ITextServicesManager_Stub_Delegate {
private static class FakeTextServicesManager implements ITextServicesManager {
+ @Override
public void finishSpellCheckerService(ISpellCheckerSessionListener arg0)
throws RemoteException {
// TODO Auto-generated method stub
}
+ @Override
public SpellCheckerInfo getCurrentSpellChecker(String arg0) throws RemoteException {
// TODO Auto-generated method stub
return null;
}
+ @Override
public SpellCheckerSubtype getCurrentSpellCheckerSubtype(String arg0, boolean arg1)
throws RemoteException {
// TODO Auto-generated method stub
return null;
}
+ @Override
public SpellCheckerInfo[] getEnabledSpellCheckers() throws RemoteException {
// TODO Auto-generated method stub
return null;
}
+ @Override
public void getSpellCheckerService(String arg0, String arg1,
ITextServicesSessionListener arg2, ISpellCheckerSessionListener arg3, Bundle arg4)
throws RemoteException {
@@ -72,26 +77,31 @@ public class ITextServicesManager_Stub_Delegate {
}
+ @Override
public boolean isSpellCheckerEnabled() throws RemoteException {
// TODO Auto-generated method stub
return false;
}
+ @Override
public void setCurrentSpellChecker(String arg0, String arg1) throws RemoteException {
// TODO Auto-generated method stub
}
+ @Override
public void setCurrentSpellCheckerSubtype(String arg0, int arg1) throws RemoteException {
// TODO Auto-generated method stub
}
+ @Override
public void setSpellCheckerEnabled(boolean arg0) throws RemoteException {
// TODO Auto-generated method stub
}
+ @Override
public IBinder asBinder() {
// TODO Auto-generated method stub
return null;
diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/Bridge.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/Bridge.java
index ff88209..66481fd 100644
--- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/Bridge.java
+++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/Bridge.java
@@ -29,6 +29,7 @@ import com.android.ide.common.rendering.api.SessionParams;
import com.android.layoutlib.bridge.impl.FontLoader;
import com.android.layoutlib.bridge.impl.RenderDrawable;
import com.android.layoutlib.bridge.impl.RenderSessionImpl;
+import com.android.layoutlib.bridge.util.DynamicIdMap;
import com.android.ninepatch.NinePatchChunk;
import com.android.resources.ResourceType;
import com.android.tools.layoutlib.create.MethodAdapter;
@@ -78,7 +79,7 @@ public final class Bridge extends com.android.ide.common.rendering.api.Bridge {
private final static ReentrantLock sLock = new ReentrantLock();
/**
- * Maps from id to resource type/name. This is for android.R only.
+ * Maps from id to resource type/name. This is for com.android.internal.R
*/
private final static Map<Integer, Pair<ResourceType, String>> sRMap =
new HashMap<Integer, Pair<ResourceType, String>>();
@@ -89,11 +90,17 @@ public final class Bridge extends com.android.ide.common.rendering.api.Bridge {
private final static Map<IntArray, String> sRArrayMap = new HashMap<IntArray, String>();
/**
* Reverse map compared to sRMap, resource type -> (resource name -> id).
- * This is for android.R only.
+ * This is for com.android.internal.R.
*/
- private final static Map<ResourceType, Map<String, Integer>> sRFullMap =
+ private final static Map<ResourceType, Map<String, Integer>> sRevRMap =
new EnumMap<ResourceType, Map<String,Integer>>(ResourceType.class);
+ // framework resources are defined as 0x01XX#### where XX is the resource type (layout,
+ // drawable, etc...). Using FF as the type allows for 255 resource types before we get a
+ // collision which should be fine.
+ private final static int DYNAMIC_ID_SEED_START = 0x01ff0000;
+ private final static DynamicIdMap sDynamicIds = new DynamicIdMap(DYNAMIC_ID_SEED_START);
+
private final static Map<Object, Map<String, SoftReference<Bitmap>>> sProjectBitmapCache =
new HashMap<Object, Map<String, SoftReference<Bitmap>>>();
private final static Map<Object, Map<String, SoftReference<NinePatchChunk>>> sProject9PatchCache =
@@ -257,7 +264,7 @@ public final class Bridge extends com.android.ide.common.rendering.api.Bridge {
ResourceType resType = ResourceType.getEnum(resTypeName);
if (resType != null) {
Map<String, Integer> fullMap = new HashMap<String, Integer>();
- sRFullMap.put(resType, fullMap);
+ sRevRMap.put(resType, fullMap);
for (Field f : inner.getDeclaredFields()) {
// only process static final fields. Since the final attribute may have
@@ -459,7 +466,14 @@ public final class Bridge extends com.android.ide.common.rendering.api.Bridge {
* does not match any resource.
*/
public static Pair<ResourceType, String> resolveResourceId(int value) {
- return sRMap.get(value);
+ Pair<ResourceType, String> pair = sRMap.get(value);
+ if (pair == null) {
+ pair = sDynamicIds.resolveId(value);
+ if (pair == null) {
+ System.out.println(String.format("Missing id: %1$08X (%1$d)", value));
+ }
+ }
+ return pair;
}
/**
@@ -478,12 +492,17 @@ public final class Bridge extends com.android.ide.common.rendering.api.Bridge {
* @return an {@link Integer} containing the resource id, or null if no resource were found.
*/
public static Integer getResourceId(ResourceType type, String name) {
- Map<String, Integer> map = sRFullMap.get(type);
+ Map<String, Integer> map = sRevRMap.get(type);
+ Integer value = null;
if (map != null) {
- return map.get(name);
+ value = map.get(name);
}
- return null;
+ if (value == null) {
+ value = sDynamicIds.getId(type, name);
+ }
+
+ return value;
}
/**
@@ -598,6 +617,4 @@ public final class Bridge extends com.android.ide.common.rendering.api.Bridge {
sFramework9PatchCache.put(value, new SoftReference<NinePatchChunk>(ninePatch));
}
}
-
-
}
diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/BridgeRenderSession.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/BridgeRenderSession.java
index 529be97..f9f4b3a 100644
--- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/BridgeRenderSession.java
+++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/BridgeRenderSession.java
@@ -70,13 +70,13 @@ public class BridgeRenderSession extends RenderSession {
@Override
public Result getProperty(Object objectView, String propertyName) {
- // TODO Auto-generated method stub
+ // pass
return super.getProperty(objectView, propertyName);
}
@Override
public Result setProperty(Object objectView, String propertyName, String propertyValue) {
- // TODO Auto-generated method stub
+ // pass
return super.setProperty(objectView, propertyName, propertyValue);
}
diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeContentProvider.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeContentProvider.java
index c91a3bf..e28866e 100644
--- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeContentProvider.java
+++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeContentProvider.java
@@ -19,6 +19,7 @@ package com.android.layoutlib.bridge.android;
import android.content.ContentProviderOperation;
import android.content.ContentProviderResult;
import android.content.ContentValues;
+import android.content.ICancellationSignal;
import android.content.IContentProvider;
import android.content.OperationApplicationException;
import android.content.res.AssetFileDescriptor;
@@ -90,8 +91,8 @@ public final class BridgeContentProvider implements IContentProvider {
}
@Override
- public Cursor query(Uri arg0, String[] arg1, String arg2, String[] arg3, String arg4)
- throws RemoteException {
+ public Cursor query(Uri arg0, String[] arg1, String arg2, String[] arg3, String arg4,
+ ICancellationSignal arg5) throws RemoteException {
// TODO Auto-generated method stub
return null;
}
@@ -122,4 +123,9 @@ public final class BridgeContentProvider implements IContentProvider {
return null;
}
+ @Override
+ public ICancellationSignal createCancellationSignal() throws RemoteException {
+ // TODO Auto-generated method stub
+ return null;
+ }
}
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 9dbe82f..f9e48e2 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
@@ -60,6 +60,7 @@ import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
+import android.os.PowerManager;
import android.util.AttributeSet;
import android.util.DisplayMetrics;
import android.util.TypedValue;
@@ -75,13 +76,11 @@ import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
+import java.util.ArrayList;
import java.util.HashMap;
import java.util.IdentityHashMap;
+import java.util.List;
import java.util.Map;
-import java.util.Map.Entry;
-import java.util.TreeMap;
-import java.util.concurrent.atomic.AtomicBoolean;
-import java.util.concurrent.atomic.AtomicReference;
/**
* Custom implementation of Context/Activity to handle non compiled resources.
@@ -246,15 +245,18 @@ public final class BridgeContext extends Context {
public boolean resolveThemeAttribute(int resid, TypedValue outValue, boolean resolveRefs) {
Pair<ResourceType, String> resourceInfo = Bridge.resolveResourceId(resid);
+ boolean isFrameworkRes = true;
if (resourceInfo == null) {
resourceInfo = mProjectCallback.resolveResourceId(resid);
+ isFrameworkRes = false;
}
if (resourceInfo == null) {
return false;
}
- ResourceValue value = mRenderResources.findItemInTheme(resourceInfo.getSecond());
+ ResourceValue value = mRenderResources.findItemInTheme(resourceInfo.getSecond(),
+ isFrameworkRes);
if (resolveRefs) {
value = mRenderResources.resolveResValue(value);
}
@@ -314,12 +316,7 @@ public final class BridgeContext extends Context {
if (isPlatformLayout == false && skipCallbackParser == false) {
// check if the project callback can provide us with a custom parser.
- ILayoutPullParser parser;
- if (resource instanceof ResourceValue) {
- parser = mProjectCallback.getParser((ResourceValue) resource);
- } else {
- parser = mProjectCallback.getParser(resource.getName());
- }
+ ILayoutPullParser parser = getParser(resource);
if (parser != null) {
BridgeXmlBlockParser blockParser = new BridgeXmlBlockParser(parser,
@@ -392,6 +389,17 @@ public final class BridgeContext extends Context {
return Pair.of(null, false);
}
+ @SuppressWarnings("deprecation")
+ private ILayoutPullParser getParser(ResourceReference resource) {
+ ILayoutPullParser parser;
+ if (resource instanceof ResourceValue) {
+ parser = mProjectCallback.getParser((ResourceValue) resource);
+ } else {
+ parser = mProjectCallback.getParser(resource.getName());
+ }
+ return parser;
+ }
+
// ------------ Context methods
@Override
@@ -431,6 +439,10 @@ public final class BridgeContext extends Context {
return null;
}
+ if (POWER_SERVICE.equals(service)) {
+ return new PowerManager(new BridgePowerManager(), new Handler());
+ }
+
throw new UnsupportedOperationException("Unsupported Service: " + service);
}
@@ -519,12 +531,10 @@ public final class BridgeContext extends Context {
return null;
}
- AtomicBoolean frameworkAttributes = new AtomicBoolean();
- AtomicReference<String> attrName = new AtomicReference<String>();
- TreeMap<Integer, String> styleNameMap = searchAttrs(attrs, frameworkAttributes, attrName);
+ List<Pair<String, Boolean>> attributeList = searchAttrs(attrs);
BridgeTypedArray ta = ((BridgeResources) mSystemResources).newTypeArray(attrs.length,
- isPlatformFile, frameworkAttributes.get(), attrName.get());
+ isPlatformFile);
// look for a custom style.
String customStyle = null;
@@ -550,14 +560,19 @@ public final class BridgeContext extends Context {
if (defStyleAttr != 0) {
// get the name from the int.
- String defStyleName = searchAttr(defStyleAttr);
+ Pair<String, Boolean> defStyleAttribute = searchAttr(defStyleAttr);
if (defaultPropMap != null) {
+ String defStyleName = defStyleAttribute.getFirst();
+ if (defStyleAttribute.getSecond()) {
+ defStyleName = "android:" + defStyleName;
+ }
defaultPropMap.put("style", defStyleName);
}
// look for the style in the current theme, and its parent:
- ResourceValue item = mRenderResources.findItemInTheme(defStyleName);
+ ResourceValue item = mRenderResources.findItemInTheme(defStyleAttribute.getFirst(),
+ defStyleAttribute.getSecond());
if (item != null) {
// item is a reference to a style entry. Search for it.
@@ -568,21 +583,25 @@ public final class BridgeContext extends Context {
defStyleValues = (StyleResourceValue)item;
}
} else {
- Bridge.getLog().error(null,
+ Bridge.getLog().error(LayoutLog.TAG_RESOURCES_RESOLVE_THEME_ATTR,
String.format(
- "Failed to find style '%s' in current theme", defStyleName),
+ "Failed to find style '%s' in current theme",
+ defStyleAttribute.getFirst()),
null /*data*/);
}
} else if (defStyleRes != 0) {
+ boolean isFrameworkRes = true;
Pair<ResourceType, String> value = Bridge.resolveResourceId(defStyleRes);
if (value == null) {
value = mProjectCallback.resolveResourceId(defStyleRes);
+ isFrameworkRes = false;
}
if (value != null) {
if (value.getFirst() == ResourceType.STYLE) {
// look for the style in the current theme, and its parent:
- ResourceValue item = mRenderResources.findItemInTheme(value.getSecond());
+ ResourceValue item = mRenderResources.findItemInTheme(value.getSecond(),
+ isFrameworkRes);
if (item != null) {
if (item instanceof StyleResourceValue) {
if (defaultPropMap != null) {
@@ -614,26 +633,28 @@ public final class BridgeContext extends Context {
}
}
- String namespace = BridgeConstants.NS_RESOURCES;
- boolean useFrameworkNS = frameworkAttributes.get();
- if (useFrameworkNS == false) {
- // need to use the application namespace
- namespace = mProjectCallback.getNamespace();
- }
+ String appNamespace = mProjectCallback.getNamespace();
- if (styleNameMap != null) {
- for (Entry<Integer, String> styleAttribute : styleNameMap.entrySet()) {
- int index = styleAttribute.getKey().intValue();
+ if (attributeList != null) {
+ for (int index = 0 ; index < attributeList.size() ; index++) {
+ Pair<String, Boolean> attribute = attributeList.get(index);
- String name = styleAttribute.getValue();
+ if (attribute == null) {
+ continue;
+ }
+
+ String attrName = attribute.getFirst();
+ boolean frameworkAttr = attribute.getSecond().booleanValue();
String value = null;
if (set != null) {
- value = set.getAttributeValue(namespace, name);
+ value = set.getAttributeValue(
+ frameworkAttr ? BridgeConstants.NS_RESOURCES : appNamespace,
+ attrName);
// if this is an app attribute, and the first get fails, try with the
// new res-auto namespace as well
- if (useFrameworkNS == false && value == null) {
- value = set.getAttributeValue(BridgeConstants.NS_APP_RES_AUTO, name);
+ if (frameworkAttr == false && value == null) {
+ value = set.getAttributeValue(BridgeConstants.NS_APP_RES_AUTO, attrName);
}
}
@@ -644,18 +665,20 @@ public final class BridgeContext extends Context {
// look for the value in the custom style first (and its parent if needed)
if (customStyleValues != null) {
- resValue = mRenderResources.findItemInStyle(customStyleValues, name);
+ resValue = mRenderResources.findItemInStyle(customStyleValues,
+ attrName, frameworkAttr);
}
// then look for the value in the default Style (and its parent if needed)
if (resValue == null && defStyleValues != null) {
- resValue = mRenderResources.findItemInStyle(defStyleValues, name);
+ resValue = mRenderResources.findItemInStyle(defStyleValues,
+ attrName, frameworkAttr);
}
// if the item is not present in the defStyle, we look in the main theme (and
// its parent themes)
if (resValue == null) {
- resValue = mRenderResources.findItemInTheme(name);
+ resValue = mRenderResources.findItemInTheme(attrName, frameworkAttr);
}
// if we found a value, we make sure this doesn't reference another value.
@@ -663,18 +686,18 @@ public final class BridgeContext extends Context {
if (resValue != null) {
// put the first default value, before the resolution.
if (defaultPropMap != null) {
- defaultPropMap.put(name, resValue.getValue());
+ defaultPropMap.put(attrName, resValue.getValue());
}
resValue = mRenderResources.resolveResValue(resValue);
}
- ta.bridgeSetValue(index, name, resValue);
+ ta.bridgeSetValue(index, attrName, frameworkAttr, resValue);
} else {
// there is a value in the XML, but we need to resolve it in case it's
// referencing another resource or a theme value.
- ta.bridgeSetValue(index, name,
- mRenderResources.resolveValue(null, name, value, isPlatformFile));
+ ta.bridgeSetValue(index, attrName, frameworkAttr,
+ mRenderResources.resolveValue(null, attrName, value, isPlatformFile));
}
}
}
@@ -700,23 +723,23 @@ public final class BridgeContext extends Context {
private BridgeTypedArray createStyleBasedTypedArray(StyleResourceValue style, int[] attrs)
throws Resources.NotFoundException {
+ List<Pair<String, Boolean>> attributes = searchAttrs(attrs);
+
BridgeTypedArray ta = ((BridgeResources) mSystemResources).newTypeArray(attrs.length,
- false, true, null);
+ false);
// for each attribute, get its name so that we can search it in the style
for (int i = 0 ; i < attrs.length ; i++) {
- Pair<ResourceType, String> resolvedResource = Bridge.resolveResourceId(attrs[i]);
- if (resolvedResource != null) {
- String attrName = resolvedResource.getSecond();
- // look for the value in the given style
- ResourceValue resValue = mRenderResources.findItemInStyle(style, attrName);
+ Pair<String, Boolean> attribute = attributes.get(i);
- if (resValue != null) {
- // resolve it to make sure there are no references left.
- ta.bridgeSetValue(i, attrName, mRenderResources.resolveResValue(resValue));
+ // look for the value in the given style
+ ResourceValue resValue = mRenderResources.findItemInStyle(style, attribute.getFirst(),
+ attribute.getSecond());
- resValue = mRenderResources.resolveResValue(resValue);
- }
+ if (resValue != null) {
+ // resolve it to make sure there are no references left.
+ ta.bridgeSetValue(i, attribute.getFirst(), attribute.getSecond(),
+ mRenderResources.resolveResValue(resValue));
}
}
@@ -727,91 +750,52 @@ public final class BridgeContext extends Context {
/**
- * The input int[] attrs is one of com.android.internal.R.styleable fields where the name
- * of the field is the style being referenced and the array contains one index per attribute.
+ * The input int[] attrs is a list of attributes. The returns a list of information about
+ * each attributes. The information is (name, isFramework)
* <p/>
- * searchAttrs() finds all the names of the attributes referenced so for example if
- * attrs == com.android.internal.R.styleable.View, this returns the list of the "xyz" where
- * there's a field com.android.internal.R.styleable.View_xyz and the field value is the index
- * that is used to reference the attribute later in the TypedArray.
*
* @param attrs An attribute array reference given to obtainStyledAttributes.
- * @param outFrameworkFlag out value indicating if the attr array is a framework value
- * @param outAttrName out value for the resolved attr name.
- * @return A sorted map Attribute-Value to Attribute-Name for all attributes declared by the
- * attribute array. Returns null if nothing is found.
+ * @return List of attribute information.
*/
- private TreeMap<Integer,String> searchAttrs(int[] attrs, AtomicBoolean outFrameworkFlag,
- AtomicReference<String> outAttrName) {
- // get the name of the array from the framework resources
- String arrayName = Bridge.resolveResourceId(attrs);
- if (arrayName != null) {
- // if we found it, get the name of each of the int in the array.
- TreeMap<Integer,String> attributes = new TreeMap<Integer, String>();
- for (int i = 0 ; i < attrs.length ; i++) {
- Pair<ResourceType, String> info = Bridge.resolveResourceId(attrs[i]);
- if (info != null) {
- attributes.put(i, info.getSecond());
- } else {
- // FIXME Not sure what we should be doing here...
- attributes.put(i, null);
- }
- }
-
- if (outFrameworkFlag != null) {
- outFrameworkFlag.set(true);
- }
- if (outAttrName != null) {
- outAttrName.set(arrayName);
- }
+ private List<Pair<String, Boolean>> searchAttrs(int[] attrs) {
+ List<Pair<String, Boolean>> results = new ArrayList<Pair<String, Boolean>>(attrs.length);
- return attributes;
- }
-
- // if the name was not found in the framework resources, look in the project
- // resources
- arrayName = mProjectCallback.resolveResourceId(attrs);
- if (arrayName != null) {
- TreeMap<Integer,String> attributes = new TreeMap<Integer, String>();
- for (int i = 0 ; i < attrs.length ; i++) {
- Pair<ResourceType, String> info = mProjectCallback.resolveResourceId(attrs[i]);
- if (info != null) {
- attributes.put(i, info.getSecond());
- } else {
- // FIXME Not sure what we should be doing here...
- attributes.put(i, null);
- }
+ // for each attribute, get its name so that we can search it in the style
+ for (int i = 0 ; i < attrs.length ; i++) {
+ Pair<ResourceType, String> resolvedResource = Bridge.resolveResourceId(attrs[i]);
+ boolean isFramework = false;
+ if (resolvedResource != null) {
+ isFramework = true;
+ } else {
+ resolvedResource = mProjectCallback.resolveResourceId(attrs[i]);
}
- if (outFrameworkFlag != null) {
- outFrameworkFlag.set(false);
- }
- if (outAttrName != null) {
- outAttrName.set(arrayName);
+ if (resolvedResource != null) {
+ results.add(Pair.of(resolvedResource.getSecond(), isFramework));
+ } else {
+ results.add(null);
}
-
- return attributes;
}
- return null;
+ return results;
}
/**
* Searches for the attribute referenced by its internal id.
*
* @param attr An attribute reference given to obtainStyledAttributes such as defStyle.
- * @return The unique name of the attribute, if found, e.g. "buttonStyle". Returns null
+ * @return A (name, isFramework) pair describing the attribute if found. Returns null
* if nothing is found.
*/
- public String searchAttr(int attr) {
+ public Pair<String, Boolean> searchAttr(int attr) {
Pair<ResourceType, String> info = Bridge.resolveResourceId(attr);
if (info != null) {
- return info.getSecond();
+ return Pair.of(info.getSecond(), Boolean.TRUE);
}
info = mProjectCallback.resolveResourceId(attr);
if (info != null) {
- return info.getSecond();
+ return Pair.of(info.getSecond(), Boolean.FALSE);
}
return null;
@@ -871,149 +855,149 @@ public final class BridgeContext extends Context {
@Override
public boolean bindService(Intent arg0, ServiceConnection arg1, int arg2) {
- // TODO Auto-generated method stub
+ // pass
return false;
}
@Override
public int checkCallingOrSelfPermission(String arg0) {
- // TODO Auto-generated method stub
+ // pass
return 0;
}
@Override
public int checkCallingOrSelfUriPermission(Uri arg0, int arg1) {
- // TODO Auto-generated method stub
+ // pass
return 0;
}
@Override
public int checkCallingPermission(String arg0) {
- // TODO Auto-generated method stub
+ // pass
return 0;
}
@Override
public int checkCallingUriPermission(Uri arg0, int arg1) {
- // TODO Auto-generated method stub
+ // pass
return 0;
}
@Override
public int checkPermission(String arg0, int arg1, int arg2) {
- // TODO Auto-generated method stub
+ // pass
return 0;
}
@Override
public int checkUriPermission(Uri arg0, int arg1, int arg2, int arg3) {
- // TODO Auto-generated method stub
+ // pass
return 0;
}
@Override
public int checkUriPermission(Uri arg0, String arg1, String arg2, int arg3,
int arg4, int arg5) {
- // TODO Auto-generated method stub
+ // pass
return 0;
}
@Override
public void clearWallpaper() {
- // TODO Auto-generated method stub
+ // pass
}
@Override
public Context createPackageContext(String arg0, int arg1) {
- // TODO Auto-generated method stub
+ // pass
return null;
}
@Override
public String[] databaseList() {
- // TODO Auto-generated method stub
+ // pass
return null;
}
@Override
public boolean deleteDatabase(String arg0) {
- // TODO Auto-generated method stub
+ // pass
return false;
}
@Override
public boolean deleteFile(String arg0) {
- // TODO Auto-generated method stub
+ // pass
return false;
}
@Override
public void enforceCallingOrSelfPermission(String arg0, String arg1) {
- // TODO Auto-generated method stub
+ // pass
}
@Override
public void enforceCallingOrSelfUriPermission(Uri arg0, int arg1,
String arg2) {
- // TODO Auto-generated method stub
+ // pass
}
@Override
public void enforceCallingPermission(String arg0, String arg1) {
- // TODO Auto-generated method stub
+ // pass
}
@Override
public void enforceCallingUriPermission(Uri arg0, int arg1, String arg2) {
- // TODO Auto-generated method stub
+ // pass
}
@Override
public void enforcePermission(String arg0, int arg1, int arg2, String arg3) {
- // TODO Auto-generated method stub
+ // pass
}
@Override
public void enforceUriPermission(Uri arg0, int arg1, int arg2, int arg3,
String arg4) {
- // TODO Auto-generated method stub
+ // pass
}
@Override
public void enforceUriPermission(Uri arg0, String arg1, String arg2,
int arg3, int arg4, int arg5, String arg6) {
- // TODO Auto-generated method stub
+ // pass
}
@Override
public String[] fileList() {
- // TODO Auto-generated method stub
+ // pass
return null;
}
@Override
public AssetManager getAssets() {
- // TODO Auto-generated method stub
+ // pass
return null;
}
@Override
public File getCacheDir() {
- // TODO Auto-generated method stub
+ // pass
return null;
}
@Override
public File getExternalCacheDir() {
- // TODO Auto-generated method stub
+ // pass
return null;
}
@@ -1027,49 +1011,49 @@ public final class BridgeContext extends Context {
@Override
public File getDatabasePath(String arg0) {
- // TODO Auto-generated method stub
+ // pass
return null;
}
@Override
public File getDir(String arg0, int arg1) {
- // TODO Auto-generated method stub
+ // pass
return null;
}
@Override
public File getFileStreamPath(String arg0) {
- // TODO Auto-generated method stub
+ // pass
return null;
}
@Override
public File getFilesDir() {
- // TODO Auto-generated method stub
+ // pass
return null;
}
@Override
public File getExternalFilesDir(String type) {
- // TODO Auto-generated method stub
+ // pass
return null;
}
@Override
public String getPackageCodePath() {
- // TODO Auto-generated method stub
+ // pass
return null;
}
@Override
public PackageManager getPackageManager() {
- // TODO Auto-generated method stub
+ // pass
return null;
}
@Override
public String getPackageName() {
- // TODO Auto-generated method stub
+ // pass
return null;
}
@@ -1080,25 +1064,25 @@ public final class BridgeContext extends Context {
@Override
public String getPackageResourcePath() {
- // TODO Auto-generated method stub
+ // pass
return null;
}
@Override
public File getSharedPrefsFile(String name) {
- // TODO Auto-generated method stub
+ // pass
return null;
}
@Override
public SharedPreferences getSharedPreferences(String arg0, int arg1) {
- // TODO Auto-generated method stub
+ // pass
return null;
}
@Override
public Drawable getWallpaper() {
- // TODO Auto-generated method stub
+ // pass
return null;
}
@@ -1114,81 +1098,81 @@ public final class BridgeContext extends Context {
@Override
public void grantUriPermission(String arg0, Uri arg1, int arg2) {
- // TODO Auto-generated method stub
+ // pass
}
@Override
public FileInputStream openFileInput(String arg0) throws FileNotFoundException {
- // TODO Auto-generated method stub
+ // pass
return null;
}
@Override
public FileOutputStream openFileOutput(String arg0, int arg1) throws FileNotFoundException {
- // TODO Auto-generated method stub
+ // pass
return null;
}
@Override
public SQLiteDatabase openOrCreateDatabase(String arg0, int arg1, CursorFactory arg2) {
- // TODO Auto-generated method stub
+ // pass
return null;
}
@Override
public SQLiteDatabase openOrCreateDatabase(String arg0, int arg1,
CursorFactory arg2, DatabaseErrorHandler arg3) {
- // TODO Auto-generated method stub
+ // pass
return null;
}
@Override
public Drawable peekWallpaper() {
- // TODO Auto-generated method stub
+ // pass
return null;
}
@Override
public Intent registerReceiver(BroadcastReceiver arg0, IntentFilter arg1) {
- // TODO Auto-generated method stub
+ // pass
return null;
}
@Override
public Intent registerReceiver(BroadcastReceiver arg0, IntentFilter arg1,
String arg2, Handler arg3) {
- // TODO Auto-generated method stub
+ // pass
return null;
}
@Override
public void removeStickyBroadcast(Intent arg0) {
- // TODO Auto-generated method stub
+ // pass
}
@Override
public void revokeUriPermission(Uri arg0, int arg1) {
- // TODO Auto-generated method stub
+ // pass
}
@Override
public void sendBroadcast(Intent arg0) {
- // TODO Auto-generated method stub
+ // pass
}
@Override
public void sendBroadcast(Intent arg0, String arg1) {
- // TODO Auto-generated method stub
+ // pass
}
@Override
public void sendOrderedBroadcast(Intent arg0, String arg1) {
- // TODO Auto-generated method stub
+ // pass
}
@@ -1196,13 +1180,13 @@ public final class BridgeContext extends Context {
public void sendOrderedBroadcast(Intent arg0, String arg1,
BroadcastReceiver arg2, Handler arg3, int arg4, String arg5,
Bundle arg6) {
- // TODO Auto-generated method stub
+ // pass
}
@Override
public void sendStickyBroadcast(Intent arg0) {
- // TODO Auto-generated method stub
+ // pass
}
@@ -1210,68 +1194,79 @@ public final class BridgeContext extends Context {
public void sendStickyOrderedBroadcast(Intent intent,
BroadcastReceiver resultReceiver, Handler scheduler, int initialCode, String initialData,
Bundle initialExtras) {
- // TODO Auto-generated method stub
+ // pass
}
@Override
public void setTheme(int arg0) {
- // TODO Auto-generated method stub
+ // pass
}
@Override
public void setWallpaper(Bitmap arg0) throws IOException {
- // TODO Auto-generated method stub
+ // pass
}
@Override
public void setWallpaper(InputStream arg0) throws IOException {
- // TODO Auto-generated method stub
+ // pass
}
@Override
public void startActivity(Intent arg0) {
- // TODO Auto-generated method stub
+ // pass
+ }
+ @Override
+ public void startActivity(Intent arg0, Bundle arg1) {
+ // pass
}
@Override
public void startIntentSender(IntentSender intent,
Intent fillInIntent, int flagsMask, int flagsValues, int extraFlags)
throws IntentSender.SendIntentException {
- // TODO Auto-generated method stub
+ // pass
+ }
+
+ @Override
+ public void startIntentSender(IntentSender intent,
+ Intent fillInIntent, int flagsMask, int flagsValues, int extraFlags,
+ Bundle options) throws IntentSender.SendIntentException {
+ // pass
}
@Override
public boolean startInstrumentation(ComponentName arg0, String arg1,
Bundle arg2) {
- // TODO Auto-generated method stub
+ // pass
return false;
}
@Override
public ComponentName startService(Intent arg0) {
- // TODO Auto-generated method stub
+ // pass
return null;
}
@Override
public boolean stopService(Intent arg0) {
- // TODO Auto-generated method stub
+ // pass
return false;
}
@Override
public void unbindService(ServiceConnection arg0) {
- // TODO Auto-generated method stub
+ // pass
}
@Override
public void unregisterReceiver(BroadcastReceiver arg0) {
- // TODO Auto-generated method stub
+ // pass
}
@@ -1282,7 +1277,13 @@ public final class BridgeContext extends Context {
@Override
public void startActivities(Intent[] arg0) {
- // TODO Auto-generated method stub
+ // pass
+
+ }
+
+ @Override
+ public void startActivities(Intent[] arg0, Bundle arg1) {
+ // pass
}
diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeIInputMethodManager.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeIInputMethodManager.java
index a37a356..d6abbaa 100644
--- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeIInputMethodManager.java
+++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeIInputMethodManager.java
@@ -37,141 +37,172 @@ import java.util.List;
*/
public class BridgeIInputMethodManager implements IInputMethodManager {
+ @Override
public void addClient(IInputMethodClient arg0, IInputContext arg1, int arg2, int arg3)
throws RemoteException {
// TODO Auto-generated method stub
}
+ @Override
public void finishInput(IInputMethodClient arg0) throws RemoteException {
// TODO Auto-generated method stub
}
+ @Override
public InputMethodSubtype getCurrentInputMethodSubtype() throws RemoteException {
// TODO Auto-generated method stub
return null;
}
+ @Override
public List<InputMethodInfo> getEnabledInputMethodList() throws RemoteException {
// TODO Auto-generated method stub
return null;
}
+ @Override
public List<InputMethodSubtype> getEnabledInputMethodSubtypeList(InputMethodInfo arg0,
boolean arg1) throws RemoteException {
// TODO Auto-generated method stub
return null;
}
+ @Override
public List<InputMethodInfo> getInputMethodList() throws RemoteException {
// TODO Auto-generated method stub
return null;
}
+ @Override
public InputMethodSubtype getLastInputMethodSubtype() throws RemoteException {
// TODO Auto-generated method stub
return null;
}
+ @Override
public List getShortcutInputMethodsAndSubtypes() throws RemoteException {
// TODO Auto-generated method stub
return null;
}
+ @Override
public void hideMySoftInput(IBinder arg0, int arg1) throws RemoteException {
// TODO Auto-generated method stub
}
+ @Override
public boolean hideSoftInput(IInputMethodClient arg0, int arg1, ResultReceiver arg2)
throws RemoteException {
// TODO Auto-generated method stub
return false;
}
+ @Override
public boolean notifySuggestionPicked(SuggestionSpan arg0, String arg1, int arg2)
throws RemoteException {
// TODO Auto-generated method stub
return false;
}
+ @Override
public void registerSuggestionSpansForNotification(SuggestionSpan[] arg0)
throws RemoteException {
// TODO Auto-generated method stub
}
+ @Override
public void removeClient(IInputMethodClient arg0) throws RemoteException {
// TODO Auto-generated method stub
}
+ @Override
public void setAdditionalInputMethodSubtypes(String arg0, InputMethodSubtype[] arg1)
throws RemoteException {
// TODO Auto-generated method stub
}
+ @Override
public boolean setCurrentInputMethodSubtype(InputMethodSubtype arg0) throws RemoteException {
// TODO Auto-generated method stub
return false;
}
+ @Override
public void setImeWindowStatus(IBinder arg0, int arg1, int arg2) throws RemoteException {
// TODO Auto-generated method stub
}
+ @Override
public void setInputMethod(IBinder arg0, String arg1) throws RemoteException {
// TODO Auto-generated method stub
}
+ @Override
public void setInputMethodAndSubtype(IBinder arg0, String arg1, InputMethodSubtype arg2)
throws RemoteException {
// TODO Auto-generated method stub
}
+ @Override
public boolean setInputMethodEnabled(String arg0, boolean arg1) throws RemoteException {
// TODO Auto-generated method stub
return false;
}
+ @Override
public void showInputMethodAndSubtypeEnablerFromClient(IInputMethodClient arg0, String arg1)
throws RemoteException {
// TODO Auto-generated method stub
}
+ @Override
public void showInputMethodPickerFromClient(IInputMethodClient arg0) throws RemoteException {
// TODO Auto-generated method stub
}
+ @Override
public void showMySoftInput(IBinder arg0, int arg1) throws RemoteException {
// TODO Auto-generated method stub
}
+ @Override
public boolean showSoftInput(IInputMethodClient arg0, int arg1, ResultReceiver arg2)
throws RemoteException {
// TODO Auto-generated method stub
return false;
}
-
+ @Override
public InputBindResult startInput(IInputMethodClient client, IInputContext inputContext,
EditorInfo attribute, int controlFlags) throws RemoteException {
// TODO Auto-generated method stub
return null;
}
+ @Override
public boolean switchToLastInputMethod(IBinder arg0) throws RemoteException {
// TODO Auto-generated method stub
return false;
}
+ @Override
+ public boolean switchToNextInputMethod(IBinder arg0, boolean arg1) throws RemoteException {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
public void updateStatusIcon(IBinder arg0, String arg1, int arg2) throws RemoteException {
// TODO Auto-generated method stub
@@ -185,6 +216,7 @@ public class BridgeIInputMethodManager implements IInputMethodManager {
return null;
}
+ @Override
public IBinder asBinder() {
// TODO Auto-generated method stub
return null;
diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeLayoutParamsMapAttributes.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeLayoutParamsMapAttributes.java
index d208408..f5912e7 100644
--- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeLayoutParamsMapAttributes.java
+++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeLayoutParamsMapAttributes.java
@@ -37,6 +37,7 @@ public class BridgeLayoutParamsMapAttributes implements AttributeSet {
mAttributes = attributes;
}
+ @Override
public String getAttributeValue(String namespace, String name) {
if (BridgeConstants.NS_RESOURCES.equals(namespace)) {
return mAttributes.get(name);
@@ -49,93 +50,114 @@ public class BridgeLayoutParamsMapAttributes implements AttributeSet {
// BridgeContext#obtainStyledAttributes(AttributeSet, int[], int, int)
// Should they ever be called, we'll just implement them on a need basis.
+ @Override
public int getAttributeCount() {
throw new UnsupportedOperationException();
}
+ @Override
public String getAttributeName(int index) {
throw new UnsupportedOperationException();
}
+ @Override
public String getAttributeValue(int index) {
throw new UnsupportedOperationException();
}
+ @Override
public String getPositionDescription() {
throw new UnsupportedOperationException();
}
+ @Override
public int getAttributeNameResource(int index) {
throw new UnsupportedOperationException();
}
+ @Override
public int getAttributeListValue(String namespace, String attribute,
String[] options, int defaultValue) {
throw new UnsupportedOperationException();
}
+ @Override
public boolean getAttributeBooleanValue(String namespace, String attribute,
boolean defaultValue) {
throw new UnsupportedOperationException();
}
+ @Override
public int getAttributeResourceValue(String namespace, String attribute,
int defaultValue) {
throw new UnsupportedOperationException();
}
+ @Override
public int getAttributeIntValue(String namespace, String attribute,
int defaultValue) {
throw new UnsupportedOperationException();
}
+ @Override
public int getAttributeUnsignedIntValue(String namespace, String attribute,
int defaultValue) {
throw new UnsupportedOperationException();
}
+ @Override
public float getAttributeFloatValue(String namespace, String attribute,
float defaultValue) {
throw new UnsupportedOperationException();
}
+ @Override
public int getAttributeListValue(int index,
String[] options, int defaultValue) {
throw new UnsupportedOperationException();
}
+ @Override
public boolean getAttributeBooleanValue(int index, boolean defaultValue) {
throw new UnsupportedOperationException();
}
+ @Override
public int getAttributeResourceValue(int index, int defaultValue) {
throw new UnsupportedOperationException();
}
+ @Override
public int getAttributeIntValue(int index, int defaultValue) {
throw new UnsupportedOperationException();
}
+ @Override
public int getAttributeUnsignedIntValue(int index, int defaultValue) {
throw new UnsupportedOperationException();
}
+ @Override
public float getAttributeFloatValue(int index, float defaultValue) {
throw new UnsupportedOperationException();
}
+ @Override
public String getIdAttribute() {
throw new UnsupportedOperationException();
}
+ @Override
public String getClassAttribute() {
throw new UnsupportedOperationException();
}
+ @Override
public int getIdAttributeResourceValue(int defaultValue) {
throw new UnsupportedOperationException();
}
+ @Override
public int getStyleAttribute() {
throw new UnsupportedOperationException();
}
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
new file mode 100644
index 0000000..6071a6b
--- /dev/null
+++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgePowerManager.java
@@ -0,0 +1,132 @@
+/*
+ * 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;
+
+import android.os.IBinder;
+import android.os.IPowerManager;
+import android.os.RemoteException;
+import android.os.WorkSource;
+
+/**
+ * Fake implementation of IPowerManager.
+ *
+ */
+public class BridgePowerManager implements IPowerManager {
+
+ @Override
+ public boolean isScreenOn() throws RemoteException {
+ return true;
+ }
+
+ @Override
+ public IBinder asBinder() {
+ // pass for now.
+ return null;
+ }
+
+ @Override
+ public void acquireWakeLock(int arg0, IBinder 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 {
+ // pass for now.
+ return 0;
+ }
+
+ @Override
+ public void goToSleep(long arg0) throws RemoteException {
+ // pass for now.
+ }
+
+ @Override
+ public void goToSleepWithReason(long arg0, int arg1) throws RemoteException {
+ // pass for now.
+ }
+
+ @Override
+ public void preventScreenOn(boolean arg0) throws RemoteException {
+ // pass for now.
+ }
+
+ @Override
+ public void reboot(String arg0) throws RemoteException {
+ // pass for now.
+ }
+
+ @Override
+ public void releaseWakeLock(IBinder arg0, int arg1) throws RemoteException {
+ // pass for now.
+ }
+
+ @Override
+ public void setAttentionLight(boolean arg0, int arg1) throws RemoteException {
+ // pass for now.
+ }
+
+ @Override
+ public void setAutoBrightnessAdjustment(float arg0) throws RemoteException {
+ // pass for now.
+ }
+
+ @Override
+ public void setBacklightBrightness(int arg0) throws RemoteException {
+ // pass for now.
+ }
+
+ @Override
+ public void setMaximumScreenOffTimeount(int arg0) throws RemoteException {
+ // pass for now.
+ }
+
+ @Override
+ public void setPokeLock(int arg0, IBinder arg1, String arg2) throws RemoteException {
+ // pass for now.
+ }
+
+ @Override
+ public void setStayOnSetting(int arg0) throws RemoteException {
+ // pass for now.
+ }
+
+ @Override
+ public void updateWakeLockWorkSource(IBinder arg0, WorkSource arg1) throws RemoteException {
+ // pass for now.
+ }
+
+ @Override
+ public void userActivity(long arg0, boolean arg1) throws RemoteException {
+ // pass for now.
+ }
+
+ @Override
+ public void userActivityWithForce(long arg0, boolean arg1, boolean arg2) 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 e13380e..7c683c9 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
@@ -24,72 +24,73 @@ import android.os.ParcelFileDescriptor;
import android.os.RemoteException;
import android.view.DragEvent;
import android.view.IWindow;
-import android.view.KeyEvent;
-import android.view.MotionEvent;
/**
* Implementation of {@link IWindow} to pass to the AttachInfo.
*/
public final class BridgeWindow implements IWindow {
+ @Override
public void dispatchAppVisibility(boolean arg0) throws RemoteException {
// pass for now.
}
+ @Override
public void dispatchGetNewSurface() throws RemoteException {
// pass for now.
}
- public void dispatchKey(KeyEvent arg0) throws RemoteException {
- // pass for now.
- }
-
- public void dispatchPointer(MotionEvent arg0, long arg1, boolean arg2) throws RemoteException {
- // pass for now.
- }
-
- public void dispatchTrackball(MotionEvent arg0, long arg1, boolean arg2)
- throws RemoteException {
- // pass for now.
- }
-
+ @Override
public void executeCommand(String arg0, String arg1, ParcelFileDescriptor arg2)
throws RemoteException {
// pass for now.
}
+ @Override
public void resized(int arg0, int arg1, Rect arg2, Rect arg3, boolean arg4, Configuration arg5)
throws RemoteException {
// pass for now.
}
+ @Override
+ public void dispatchScreenState(boolean on) throws RemoteException {
+ // pass for now.
+ }
+
+ @Override
public void windowFocusChanged(boolean arg0, boolean arg1) throws RemoteException {
// pass for now.
}
+ @Override
public void dispatchWallpaperOffsets(float x, float y, float xStep, float yStep,
boolean sync) {
// pass for now.
}
+ @Override
public void dispatchWallpaperCommand(String action, int x, int y,
int z, Bundle extras, boolean sync) {
// pass for now.
}
+ @Override
public void closeSystemDialogs(String reason) {
// pass for now.
}
+ @Override
public void dispatchDragEvent(DragEvent event) {
// pass for now.
}
+ @Override
public void dispatchSystemUiVisibilityChanged(int seq, int globalUi,
int localValue, int localChanges) {
// pass for now.
}
+ @Override
public IBinder asBinder() {
// pass for now.
return null;
diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeWindowManager.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeWindowManager.java
index 516725e..85b67d5 100644
--- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeWindowManager.java
+++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeWindowManager.java
@@ -67,288 +67,250 @@ public class BridgeWindowManager implements IWindowManager {
// ---- implementation of IWindowManager that we care about ----
+ @Override
public int getRotation() throws RemoteException {
return mRotation;
}
+ @Override
public int getMaximumSizeDimension() throws RemoteException {
return 0;
}
+ @Override
+ public void getCurrentSizeRange(Point smallestSize, Point largestSize) {
+ }
+
+ @Override
public void getDisplaySize(Point arg0) throws RemoteException {
}
+ @Override
public void getRealDisplaySize(Point arg0) throws RemoteException {
}
// ---- unused implementation of IWindowManager ----
- public boolean canStatusBarHide() throws RemoteException {
+ @Override
+ public boolean hasSystemNavBar() 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 {
// TODO Auto-generated method stub
}
+ @Override
public void addWindowToken(IBinder arg0, int arg1) throws RemoteException {
// TODO Auto-generated method stub
}
+ @Override
public void clearForcedDisplaySize() throws RemoteException {
// TODO Auto-generated method stub
}
+ @Override
public void closeSystemDialogs(String arg0) throws RemoteException {
// TODO Auto-generated method stub
}
+ @Override
public void disableKeyguard(IBinder arg0, String arg1) throws RemoteException {
// TODO Auto-generated method stub
}
+ @Override
public void executeAppTransition() throws RemoteException {
// TODO Auto-generated method stub
}
+ @Override
public void exitKeyguardSecurely(IOnKeyguardExitResult arg0) throws RemoteException {
// TODO Auto-generated method stub
}
+ @Override
public void freezeRotation(int arg0) throws RemoteException {
// TODO Auto-generated method stub
}
+ @Override
public float getAnimationScale(int arg0) throws RemoteException {
// TODO Auto-generated method stub
return 0;
}
+ @Override
public float[] getAnimationScales() throws RemoteException {
// TODO Auto-generated method stub
return null;
}
+ @Override
public int getAppOrientation(IApplicationToken arg0) throws RemoteException {
// TODO Auto-generated method stub
return 0;
}
- public int getDPadKeycodeState(int arg0) throws RemoteException {
- // TODO Auto-generated method stub
- return 0;
- }
-
- public int getDPadScancodeState(int arg0) throws RemoteException {
- // TODO Auto-generated method stub
- return 0;
- }
-
-
- public InputDevice getInputDevice(int arg0) throws RemoteException {
- // TODO Auto-generated method stub
- return null;
- }
-
- public int[] getInputDeviceIds() throws RemoteException {
- // TODO Auto-generated method stub
- return null;
- }
-
- public int getKeycodeState(int arg0) throws RemoteException {
- // TODO Auto-generated method stub
- return 0;
- }
-
- public int getKeycodeStateForDevice(int arg0, int arg1) throws RemoteException {
- // TODO Auto-generated method stub
- return 0;
- }
-
-
+ @Override
public int getPendingAppTransition() throws RemoteException {
// TODO Auto-generated method stub
return 0;
}
-
- public int getScancodeState(int arg0) throws RemoteException {
- // TODO Auto-generated method stub
- return 0;
- }
-
- public int getScancodeStateForDevice(int arg0, int arg1) throws RemoteException {
- // TODO Auto-generated method stub
- return 0;
- }
-
- public int getSwitchState(int arg0) throws RemoteException {
- // TODO Auto-generated method stub
- return 0;
- }
-
- public int getSwitchStateForDevice(int arg0, int arg1) throws RemoteException {
- // TODO Auto-generated method stub
- return 0;
- }
-
- public int getTrackballKeycodeState(int arg0) throws RemoteException {
- // TODO Auto-generated method stub
- return 0;
- }
-
- public int getTrackballScancodeState(int arg0) throws RemoteException {
- // TODO Auto-generated method stub
- return 0;
- }
-
- public boolean hasKeys(int[] arg0, boolean[] arg1) throws RemoteException {
- // TODO Auto-generated method stub
- return false;
- }
-
+ @Override
public boolean inKeyguardRestrictedInputMode() throws RemoteException {
// TODO Auto-generated method stub
return false;
}
- public boolean injectInputEventNoWait(InputEvent arg0) throws RemoteException {
- // TODO Auto-generated method stub
- return false;
- }
-
- public boolean injectKeyEvent(KeyEvent arg0, boolean arg1) throws RemoteException {
- // TODO Auto-generated method stub
- return false;
- }
-
- public boolean injectPointerEvent(MotionEvent arg0, boolean arg1) throws RemoteException {
- // TODO Auto-generated method stub
- return false;
- }
-
- public boolean injectTrackballEvent(MotionEvent arg0, boolean arg1) throws RemoteException {
- // TODO Auto-generated method stub
- return false;
- }
-
+ @Override
public boolean inputMethodClientHasFocus(IInputMethodClient arg0) throws RemoteException {
// TODO Auto-generated method stub
return false;
}
+ @Override
public boolean isKeyguardLocked() throws RemoteException {
// TODO Auto-generated method stub
return false;
}
+ @Override
public boolean isKeyguardSecure() throws RemoteException {
// TODO Auto-generated method stub
return false;
}
+ @Override
public boolean isViewServerRunning() throws RemoteException {
// TODO Auto-generated method stub
return false;
}
- public InputChannel monitorInput(String arg0) throws RemoteException {
- // TODO Auto-generated method stub
- return null;
- }
-
+ @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
return null;
}
+ @Override
public void overridePendingAppTransition(String arg0, int arg1, int arg2)
throws RemoteException {
// TODO Auto-generated method stub
}
+ @Override
+ public void overridePendingAppTransitionScaleUp(int startX, int startY, int startWidth,
+ int startHeight) throws RemoteException {
+ // TODO Auto-generated method stub
+ }
+
+ @Override
+ public void overridePendingAppTransitionThumb(Bitmap srcThumb, int startX, int startY,
+ IRemoteCallback startedCallback) throws RemoteException {
+ // TODO Auto-generated method stub
+ }
+
+ @Override
public void pauseKeyDispatching(IBinder arg0) throws RemoteException {
// TODO Auto-generated method stub
}
+ @Override
public void prepareAppTransition(int arg0, boolean arg1) throws RemoteException {
// TODO Auto-generated method stub
}
+ @Override
public void reenableKeyguard(IBinder arg0) throws RemoteException {
// TODO Auto-generated method stub
}
+ @Override
public void removeAppToken(IBinder arg0) throws RemoteException {
// TODO Auto-generated method stub
}
+ @Override
public void removeWindowToken(IBinder arg0) throws RemoteException {
// TODO Auto-generated method stub
}
+ @Override
public void resumeKeyDispatching(IBinder arg0) throws RemoteException {
// TODO Auto-generated method stub
}
+ @Override
public Bitmap screenshotApplications(IBinder arg0, int arg1, int arg2) throws RemoteException {
// TODO Auto-generated method stub
return null;
}
+ @Override
public void setAnimationScale(int arg0, float arg1) throws RemoteException {
// TODO Auto-generated method stub
}
+ @Override
public void setAnimationScales(float[] arg0) throws RemoteException {
// TODO Auto-generated method stub
}
+ @Override
public void setAppGroupId(IBinder arg0, int arg1) throws RemoteException {
// TODO Auto-generated method stub
}
+ @Override
public void setAppOrientation(IApplicationToken arg0, int arg1) throws RemoteException {
// TODO Auto-generated method stub
}
+ @Override
public void setAppStartingWindow(IBinder arg0, String arg1, int arg2, CompatibilityInfo arg3,
CharSequence arg4, int arg5, int arg6, int arg7, IBinder arg8, boolean arg9)
throws RemoteException {
@@ -356,122 +318,140 @@ public class BridgeWindowManager implements IWindowManager {
}
+ @Override
public void setAppVisibility(IBinder arg0, boolean arg1) throws RemoteException {
// TODO Auto-generated method stub
}
+ @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 {
// 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
}
- public void setPointerSpeed(int arg0) throws RemoteException {
+ @Override
+ public void updateRotation(boolean arg0, boolean arg1) throws RemoteException {
// TODO Auto-generated method stub
-
- }
-
- public void updateRotation(boolean arg0) throws RemoteException {
- // TODO Auto-generated method stub
-
}
+ @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
public boolean startViewServer(int arg0) throws RemoteException {
// TODO Auto-generated method stub
return false;
}
+ @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
public boolean stopViewServer() throws RemoteException {
// TODO Auto-generated method stub
return false;
}
+ @Override
public void thawRotation() throws RemoteException {
// TODO Auto-generated method stub
}
+ @Override
public Configuration updateOrientationFromAppTokens(Configuration arg0, IBinder arg1)
throws RemoteException {
// TODO Auto-generated method stub
return null;
}
+ @Override
public int watchRotation(IRotationWatcher arg0) throws RemoteException {
// TODO Auto-generated method stub
return 0;
}
+ @Override
public void waitForWindowDrawn(IBinder token, IRemoteCallback callback) {
// TODO Auto-generated method stub
}
-
+
+ @Override
public IBinder asBinder() {
// TODO Auto-generated method stub
return null;
}
+ @Override
public int getPreferredOptionsPanelGravity() throws RemoteException {
return Gravity.CENTER_HORIZONTAL | Gravity.BOTTOM;
}
+ @Override
public void dismissKeyguard() {
}
+ @Override
public boolean hasNavigationBar() {
return false; // should this return something else?
}
+ @Override
public void lockNow() {
// TODO Auto-generated method stub
}
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 a640a91..d3721ed 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
@@ -26,7 +26,6 @@ import android.os.RemoteException;
import android.view.IWindow;
import android.view.IWindowSession;
import android.view.InputChannel;
-import android.view.MotionEvent;
import android.view.Surface;
import android.view.SurfaceView;
import android.view.WindowManager.LayoutParams;
@@ -37,6 +36,7 @@ import android.view.WindowManager.LayoutParams;
*/
public final class BridgeWindowSession implements IWindowSession {
+ @Override
public int add(IWindow arg0, int seq, LayoutParams arg1, int arg2, Rect arg3,
InputChannel outInputchannel)
throws RemoteException {
@@ -44,40 +44,30 @@ public final class BridgeWindowSession implements IWindowSession {
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 void finishDrawing(IWindow arg0) throws RemoteException {
// pass for now.
}
- public void finishKey(IWindow arg0) throws RemoteException {
- // pass for now.
- }
-
+ @Override
public boolean getInTouchMode() throws RemoteException {
// pass for now.
return false;
}
+ @Override
public boolean performHapticFeedback(IWindow window, int effectId, boolean always) {
// pass for now.
return false;
}
-
- public MotionEvent getPendingPointerMove(IWindow arg0) throws RemoteException {
- // pass for now.
- return null;
- }
-
- public MotionEvent getPendingTrackballMove(IWindow arg0) throws RemoteException {
- // pass for now.
- return null;
- }
-
+ @Override
public int relayout(IWindow arg0, int seq, LayoutParams arg1, int arg2, int arg3, int arg4,
int arg4_5, Rect arg5, Rect arg6, Rect arg7, Configuration arg7b, Surface arg8)
throws RemoteException {
@@ -85,35 +75,43 @@ public final class BridgeWindowSession implements IWindowSession {
return 0;
}
+ @Override
public void performDeferredDestroy(IWindow window) {
// pass for now.
}
+ @Override
public boolean outOfMemory(IWindow window) throws RemoteException {
return false;
}
+ @Override
public void getDisplayFrame(IWindow window, Rect outDisplayFrame) {
// pass for now.
}
+ @Override
public void remove(IWindow arg0) throws RemoteException {
// pass for now.
}
+ @Override
public void setInTouchMode(boolean arg0) throws RemoteException {
// pass for now.
}
+ @Override
public void setTransparentRegion(IWindow arg0, Region arg1) throws RemoteException {
// pass for now.
}
+ @Override
public void setInsets(IWindow window, int touchable, Rect contentInsets,
Rect visibleInsets, Region touchableRegion) {
// pass for now.
}
+ @Override
public IBinder prepareDrag(IWindow window, int flags,
int thumbnailWidth, int thumbnailHeight, Surface outSurface)
throws RemoteException {
@@ -121,6 +119,7 @@ public final class BridgeWindowSession implements IWindowSession {
return null;
}
+ @Override
public boolean performDrag(IWindow window, IBinder dragToken,
float touchX, float touchY, float thumbCenterX, float thumbCenterY,
ClipData data)
@@ -129,49 +128,47 @@ public final class BridgeWindowSession implements IWindowSession {
return false;
}
+ @Override
public void reportDropResult(IWindow window, boolean consumed) throws RemoteException {
// pass for now
}
+ @Override
public void dragRecipientEntered(IWindow window) throws RemoteException {
// pass for now
}
+ @Override
public void dragRecipientExited(IWindow window) throws RemoteException {
// pass for now
}
+ @Override
public void setWallpaperPosition(IBinder window, float x, float y,
float xStep, float yStep) {
// pass for now.
}
+ @Override
public void wallpaperOffsetsComplete(IBinder window) {
// pass for now.
}
+ @Override
public Bundle sendWallpaperCommand(IBinder window, String action, int x, int y,
int z, Bundle extras, boolean sync) {
// pass for now.
return null;
}
+ @Override
public void wallpaperCommandComplete(IBinder window, Bundle result) {
// pass for now.
}
- public void closeSystemDialogs(String reason) {
- // pass for now.
- }
-
+ @Override
public IBinder asBinder() {
// pass for now.
return null;
}
-
- public IBinder prepareDrag(IWindow arg0, boolean arg1, int arg2, int arg3, Surface arg4)
- throws RemoteException {
- // TODO Auto-generated method stub
- return null;
- }
}
diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeXmlBlockParser.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeXmlBlockParser.java
index f8ed4f7..ac8712e 100644
--- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeXmlBlockParser.java
+++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeXmlBlockParser.java
@@ -95,6 +95,7 @@ public class BridgeXmlBlockParser implements XmlResourceParser {
// ------- XmlResourceParser implementation
+ @Override
public void setFeature(String name, boolean state)
throws XmlPullParserException {
if (FEATURE_PROCESS_NAMESPACES.equals(name) && state) {
@@ -106,6 +107,7 @@ public class BridgeXmlBlockParser implements XmlResourceParser {
throw new XmlPullParserException("Unsupported feature: " + name);
}
+ @Override
public boolean getFeature(String name) {
if (FEATURE_PROCESS_NAMESPACES.equals(name)) {
return true;
@@ -116,82 +118,101 @@ public class BridgeXmlBlockParser implements XmlResourceParser {
return false;
}
+ @Override
public void setProperty(String name, Object value) throws XmlPullParserException {
throw new XmlPullParserException("setProperty() not supported");
}
+ @Override
public Object getProperty(String name) {
return null;
}
+ @Override
public void setInput(Reader in) throws XmlPullParserException {
mParser.setInput(in);
}
+ @Override
public void setInput(InputStream inputStream, String inputEncoding)
throws XmlPullParserException {
mParser.setInput(inputStream, inputEncoding);
}
+ @Override
public void defineEntityReplacementText(String entityName,
String replacementText) throws XmlPullParserException {
throw new XmlPullParserException(
"defineEntityReplacementText() not supported");
}
+ @Override
public String getNamespacePrefix(int pos) throws XmlPullParserException {
throw new XmlPullParserException("getNamespacePrefix() not supported");
}
+ @Override
public String getInputEncoding() {
return null;
}
+ @Override
public String getNamespace(String prefix) {
throw new RuntimeException("getNamespace() not supported");
}
+ @Override
public int getNamespaceCount(int depth) throws XmlPullParserException {
throw new XmlPullParserException("getNamespaceCount() not supported");
}
+ @Override
public String getPositionDescription() {
return "Binary XML file line #" + getLineNumber();
}
+ @Override
public String getNamespaceUri(int pos) throws XmlPullParserException {
throw new XmlPullParserException("getNamespaceUri() not supported");
}
+ @Override
public int getColumnNumber() {
return -1;
}
+ @Override
public int getDepth() {
return mParser.getDepth();
}
+ @Override
public String getText() {
return mParser.getText();
}
+ @Override
public int getLineNumber() {
return mParser.getLineNumber();
}
+ @Override
public int getEventType() {
return mEventType;
}
+ @Override
public boolean isWhitespace() throws XmlPullParserException {
// Original comment: whitespace was stripped by aapt.
return mParser.isWhitespace();
}
+ @Override
public String getPrefix() {
throw new RuntimeException("getPrefix not supported");
}
+ @Override
public char[] getTextCharacters(int[] holderForStartAndLength) {
String txt = getText();
char[] chars = null;
@@ -204,55 +225,68 @@ public class BridgeXmlBlockParser implements XmlResourceParser {
return chars;
}
+ @Override
public String getNamespace() {
return mParser.getNamespace();
}
+ @Override
public String getName() {
return mParser.getName();
}
+ @Override
public String getAttributeNamespace(int index) {
return mParser.getAttributeNamespace(index);
}
+ @Override
public String getAttributeName(int index) {
return mParser.getAttributeName(index);
}
+ @Override
public String getAttributePrefix(int index) {
throw new RuntimeException("getAttributePrefix not supported");
}
+ @Override
public boolean isEmptyElementTag() {
// XXX Need to detect this.
return false;
}
+ @Override
public int getAttributeCount() {
return mParser.getAttributeCount();
}
+ @Override
public String getAttributeValue(int index) {
return mParser.getAttributeValue(index);
}
+ @Override
public String getAttributeType(int index) {
return "CDATA";
}
+ @Override
public boolean isAttributeDefault(int index) {
return false;
}
+ @Override
public int nextToken() throws XmlPullParserException, IOException {
return next();
}
+ @Override
public String getAttributeValue(String namespace, String name) {
return mParser.getAttributeValue(namespace, name);
}
+ @Override
public int next() throws XmlPullParserException, IOException {
if (!mStarted) {
mStarted = true;
@@ -313,6 +347,7 @@ public class BridgeXmlBlockParser implements XmlResourceParser {
return "????";
}
+ @Override
public void require(int type, String namespace, String name)
throws XmlPullParserException {
if (type != getEventType()
@@ -322,6 +357,7 @@ public class BridgeXmlBlockParser implements XmlResourceParser {
+ getPositionDescription());
}
+ @Override
public String nextText() throws XmlPullParserException, IOException {
if (getEventType() != START_TAG) {
throw new XmlPullParserException(getPositionDescription()
@@ -348,6 +384,7 @@ public class BridgeXmlBlockParser implements XmlResourceParser {
}
}
+ @Override
public int nextTag() throws XmlPullParserException, IOException {
int eventType = next();
if (eventType == TEXT && isWhitespace()) { // skip whitespace
@@ -363,76 +400,94 @@ public class BridgeXmlBlockParser implements XmlResourceParser {
// AttributeSet implementation
+ @Override
public void close() {
// pass
}
+ @Override
public boolean getAttributeBooleanValue(int index, boolean defaultValue) {
return mAttrib.getAttributeBooleanValue(index, defaultValue);
}
+ @Override
public boolean getAttributeBooleanValue(String namespace, String attribute,
boolean defaultValue) {
return mAttrib.getAttributeBooleanValue(namespace, attribute, defaultValue);
}
+ @Override
public float getAttributeFloatValue(int index, float defaultValue) {
return mAttrib.getAttributeFloatValue(index, defaultValue);
}
+ @Override
public float getAttributeFloatValue(String namespace, String attribute, float defaultValue) {
return mAttrib.getAttributeFloatValue(namespace, attribute, defaultValue);
}
+ @Override
public int getAttributeIntValue(int index, int defaultValue) {
return mAttrib.getAttributeIntValue(index, defaultValue);
}
+ @Override
public int getAttributeIntValue(String namespace, String attribute, int defaultValue) {
return mAttrib.getAttributeIntValue(namespace, attribute, defaultValue);
}
+ @Override
public int getAttributeListValue(int index, String[] options, int defaultValue) {
return mAttrib.getAttributeListValue(index, options, defaultValue);
}
+ @Override
public int getAttributeListValue(String namespace, String attribute,
String[] options, int defaultValue) {
return mAttrib.getAttributeListValue(namespace, attribute, options, defaultValue);
}
+ @Override
public int getAttributeNameResource(int index) {
return mAttrib.getAttributeNameResource(index);
}
+ @Override
public int getAttributeResourceValue(int index, int defaultValue) {
return mAttrib.getAttributeResourceValue(index, defaultValue);
}
+ @Override
public int getAttributeResourceValue(String namespace, String attribute, int defaultValue) {
return mAttrib.getAttributeResourceValue(namespace, attribute, defaultValue);
}
+ @Override
public int getAttributeUnsignedIntValue(int index, int defaultValue) {
return mAttrib.getAttributeUnsignedIntValue(index, defaultValue);
}
+ @Override
public int getAttributeUnsignedIntValue(String namespace, String attribute, int defaultValue) {
return mAttrib.getAttributeUnsignedIntValue(namespace, attribute, defaultValue);
}
+ @Override
public String getClassAttribute() {
return mAttrib.getClassAttribute();
}
+ @Override
public String getIdAttribute() {
return mAttrib.getIdAttribute();
}
+ @Override
public int getIdAttributeResourceValue(int defaultValue) {
return mAttrib.getIdAttributeResourceValue(defaultValue);
}
+ @Override
public int getStyleAttribute() {
return mAttrib.getStyleAttribute();
}
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 cd4fbfe..1817ab5 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
@@ -132,7 +132,7 @@ abstract class CustomBar extends LinearLayout {
if (bitmap != null) {
BitmapDrawable drawable = new BitmapDrawable(getContext().getResources(),
bitmap);
- imageView.setBackgroundDrawable(drawable);
+ imageView.setImageDrawable(drawable);
}
}
}
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 d5400d7..6840f46 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
@@ -33,10 +33,10 @@ import com.android.ide.common.rendering.api.RenderSession;
import com.android.ide.common.rendering.api.ResourceReference;
import com.android.ide.common.rendering.api.ResourceValue;
import com.android.ide.common.rendering.api.Result;
-import com.android.ide.common.rendering.api.SessionParams;
-import com.android.ide.common.rendering.api.ViewInfo;
import com.android.ide.common.rendering.api.Result.Status;
+import com.android.ide.common.rendering.api.SessionParams;
import com.android.ide.common.rendering.api.SessionParams.RenderingMode;
+import com.android.ide.common.rendering.api.ViewInfo;
import com.android.internal.util.XmlUtils;
import com.android.layoutlib.bridge.Bridge;
import com.android.layoutlib.bridge.android.BridgeContext;
@@ -69,8 +69,8 @@ import android.util.TypedValue;
import android.view.AttachInfo_Accessor;
import android.view.BridgeInflater;
import android.view.View;
-import android.view.ViewGroup;
import android.view.View.MeasureSpec;
+import android.view.ViewGroup;
import android.view.ViewGroup.LayoutParams;
import android.view.ViewGroup.MarginLayoutParams;
import android.widget.AbsListView;
@@ -82,8 +82,8 @@ import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.QuickContactBadge;
import android.widget.TabHost;
-import android.widget.TabWidget;
import android.widget.TabHost.TabSpec;
+import android.widget.TabWidget;
import java.awt.AlphaComposite;
import java.awt.Color;
@@ -835,6 +835,7 @@ public class RenderSessionImpl extends RenderAction<SessionParams> {
previousTransition.addTransitionListener(new TransitionListener() {
private int mChangeDisappearingCount = 0;
+ @Override
public void startTransition(LayoutTransition transition, ViewGroup container,
View view, int transitionType) {
if (transitionType == LayoutTransition.CHANGE_DISAPPEARING) {
@@ -842,6 +843,7 @@ public class RenderSessionImpl extends RenderAction<SessionParams> {
}
}
+ @Override
public void endTransition(LayoutTransition transition, ViewGroup container,
View view, int transitionType) {
if (transitionType == LayoutTransition.CHANGE_DISAPPEARING) {
@@ -1227,6 +1229,7 @@ public class RenderSessionImpl extends RenderAction<SessionParams> {
TabSpec spec = tabHost.newTabSpec("tag").setIndicator("Tab Label",
tabHost.getResources().getDrawable(android.R.drawable.ic_menu_info_details))
.setContent(new TabHost.TabContentFactory() {
+ @Override
public View createTabContent(String tag) {
return new LinearLayout(getContext());
}
diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/binding/FakeAdapter.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/binding/FakeAdapter.java
index c9bb424..22570b9 100644
--- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/binding/FakeAdapter.java
+++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/binding/FakeAdapter.java
@@ -74,38 +74,46 @@ public class FakeAdapter extends BaseAdapter implements ListAdapter, SpinnerAdap
}
}
+ @Override
public boolean isEnabled(int position) {
return true;
}
+ @Override
public int getCount() {
return mItems.size();
}
+ @Override
public Object getItem(int position) {
return mItems.get(position);
}
+ @Override
public long getItemId(int position) {
return position;
}
+ @Override
public int getItemViewType(int position) {
return mItems.get(position).getType();
}
+ @Override
public View getView(int position, View convertView, ViewGroup parent) {
// we don't care about recycling here because we never scroll.
AdapterItem item = mItems.get(position);
return getView(item, null /*parentGroup*/, convertView, parent);
}
+ @Override
public int getViewTypeCount() {
return mTypes.size();
}
// ---- SpinnerAdapter
+ @Override
public View getDropDownView(int position, View convertView, ViewGroup parent) {
// pass
return null;
diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/binding/FakeExpandableAdapter.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/binding/FakeExpandableAdapter.java
index 2c492e3..199e040 100644
--- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/binding/FakeExpandableAdapter.java
+++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/binding/FakeExpandableAdapter.java
@@ -99,23 +99,28 @@ public class FakeExpandableAdapter extends BaseAdapter implements ExpandableList
// ---- ExpandableListAdapter
+ @Override
public int getGroupCount() {
return mItems.size();
}
+ @Override
public int getChildrenCount(int groupPosition) {
AdapterItem item = mItems.get(groupPosition);
return item.getChildren().size();
}
+ @Override
public Object getGroup(int groupPosition) {
return mItems.get(groupPosition);
}
+ @Override
public Object getChild(int groupPosition, int childPosition) {
return getChildItem(groupPosition, childPosition);
}
+ @Override
public View getGroupView(int groupPosition, boolean isExpanded, View convertView,
ViewGroup parent) {
// we don't care about recycling here because we never scroll.
@@ -123,6 +128,7 @@ public class FakeExpandableAdapter extends BaseAdapter implements ExpandableList
return getView(item, null /*parentItem*/, convertView, parent);
}
+ @Override
public View getChildView(int groupPosition, int childPosition, boolean isLastChild,
View convertView, ViewGroup parent) {
// we don't care about recycling here because we never scroll.
@@ -131,48 +137,59 @@ public class FakeExpandableAdapter extends BaseAdapter implements ExpandableList
return getView(item, parentItem, convertView, parent);
}
+ @Override
public long getGroupId(int groupPosition) {
return groupPosition;
}
+ @Override
public long getChildId(int groupPosition, int childPosition) {
return childPosition;
}
+ @Override
public long getCombinedGroupId(long groupId) {
return groupId << 16 | 0x0000FFFF;
}
+ @Override
public long getCombinedChildId(long groupId, long childId) {
return groupId << 16 | childId;
}
+ @Override
public boolean isChildSelectable(int groupPosition, int childPosition) {
return true;
}
+ @Override
public void onGroupCollapsed(int groupPosition) {
// pass
}
+ @Override
public void onGroupExpanded(int groupPosition) {
// pass
}
// ---- HeterogeneousExpandableList
+ @Override
public int getChildType(int groupPosition, int childPosition) {
return getChildItem(groupPosition, childPosition).getType();
}
+ @Override
public int getChildTypeCount() {
return mChildrenTypes.size();
}
+ @Override
public int getGroupType(int groupPosition) {
return mItems.get(groupPosition).getType();
}
+ @Override
public int getGroupTypeCount() {
return mGroupTypes.size();
}
diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/util/DynamicIdMap.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/util/DynamicIdMap.java
new file mode 100644
index 0000000..a1fae95
--- /dev/null
+++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/util/DynamicIdMap.java
@@ -0,0 +1,76 @@
+/*
+ * 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.util;
+
+import com.android.resources.ResourceType;
+import com.android.util.Pair;
+
+import android.util.SparseArray;
+
+import java.util.HashMap;
+import java.util.Map;
+
+public class DynamicIdMap {
+
+ private final Map<Pair<ResourceType, String>, Integer> mDynamicIds = new HashMap<Pair<ResourceType, String>, Integer>();
+ private final SparseArray<Pair<ResourceType, String>> mRevDynamicIds = new SparseArray<Pair<ResourceType, String>>();
+ private int mDynamicSeed;
+
+ public DynamicIdMap(int seed) {
+ mDynamicSeed = seed;
+ }
+
+ public void reset(int seed) {
+ mDynamicIds.clear();
+ mRevDynamicIds.clear();
+ mDynamicSeed = seed;
+ }
+
+ /**
+ * Returns a dynamic integer for the given resource type/name, creating it if it doesn't
+ * already exist.
+ *
+ * @param type the type of the resource
+ * @param name the name of the resource
+ * @return an integer.
+ */
+ public Integer getId(ResourceType type, String name) {
+ return getId(Pair.of(type, name));
+ }
+
+ /**
+ * Returns a dynamic integer for the given resource type/name, creating it if it doesn't
+ * already exist.
+ *
+ * @param resource the type/name of the resource
+ * @return an integer.
+ */
+ public Integer getId(Pair<ResourceType, String> resource) {
+ Integer value = mDynamicIds.get(resource);
+ if (value == null) {
+ value = Integer.valueOf(++mDynamicSeed);
+ mDynamicIds.put(resource, value);
+ mRevDynamicIds.put(value, resource);
+ }
+
+ return value;
+ }
+
+ public Pair<ResourceType, String> resolveId(int id) {
+ return mRevDynamicIds.get(id);
+ }
+}
diff --git a/tools/layoutlib/create/.classpath b/tools/layoutlib/create/.classpath
index 0c60f6a..734ebdc 100644
--- a/tools/layoutlib/create/.classpath
+++ b/tools/layoutlib/create/.classpath
@@ -4,6 +4,6 @@
<classpathentry excluding="mock_android/" kind="src" path="tests"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/>
- <classpathentry kind="var" path="ANDROID_SRC/prebuilt/common/asm/asm-3.1.jar"/>
+ <classpathentry kind="var" path="ANDROID_SRC/prebuilt/common/asm/asm-4.0.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>
diff --git a/tools/layoutlib/create/.settings/README.txt b/tools/layoutlib/create/.settings/README.txt
new file mode 100644
index 0000000..9120b20
--- /dev/null
+++ b/tools/layoutlib/create/.settings/README.txt
@@ -0,0 +1,2 @@
+Copy this in eclipse project as a .settings folder at the root.
+This ensure proper compilation compliance and warning/error levels. \ No newline at end of file
diff --git a/tools/layoutlib/create/.settings/org.eclipse.jdt.core.prefs b/tools/layoutlib/create/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 0000000..5381a0e
--- /dev/null
+++ b/tools/layoutlib/create/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,93 @@
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.annotation.nonnull=com.android.annotations.NonNull
+org.eclipse.jdt.core.compiler.annotation.nonnullbydefault=com.android.annotations.NonNullByDefault
+org.eclipse.jdt.core.compiler.annotation.nonnullisdefault=disabled
+org.eclipse.jdt.core.compiler.annotation.nullable=com.android.annotations.Nullable
+org.eclipse.jdt.core.compiler.annotation.nullanalysis=enabled
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
+org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
+org.eclipse.jdt.core.compiler.compliance=1.6
+org.eclipse.jdt.core.compiler.debug.lineNumber=generate
+org.eclipse.jdt.core.compiler.debug.localVariable=generate
+org.eclipse.jdt.core.compiler.debug.sourceFile=generate
+org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.autoboxing=ignore
+org.eclipse.jdt.core.compiler.problem.comparingIdentical=warning
+org.eclipse.jdt.core.compiler.problem.deadCode=warning
+org.eclipse.jdt.core.compiler.problem.deprecation=warning
+org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled
+org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled
+org.eclipse.jdt.core.compiler.problem.discouragedReference=warning
+org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=ignore
+org.eclipse.jdt.core.compiler.problem.fallthroughCase=warning
+org.eclipse.jdt.core.compiler.problem.fatalOptionalError=enabled
+org.eclipse.jdt.core.compiler.problem.fieldHiding=warning
+org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning
+org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning
+org.eclipse.jdt.core.compiler.problem.forbiddenReference=error
+org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning
+org.eclipse.jdt.core.compiler.problem.includeNullInfoFromAsserts=enabled
+org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning
+org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=ignore
+org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore
+org.eclipse.jdt.core.compiler.problem.localVariableHiding=warning
+org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning
+org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=warning
+org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=warning
+org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=error
+org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=enabled
+org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning
+org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore
+org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning
+org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning
+org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore
+org.eclipse.jdt.core.compiler.problem.nullReference=error
+org.eclipse.jdt.core.compiler.problem.nullSpecInsufficientInfo=warning
+org.eclipse.jdt.core.compiler.problem.nullSpecViolation=error
+org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning
+org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore
+org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=warning
+org.eclipse.jdt.core.compiler.problem.potentialNullReference=warning
+org.eclipse.jdt.core.compiler.problem.potentialNullSpecViolation=error
+org.eclipse.jdt.core.compiler.problem.potentiallyUnclosedCloseable=warning
+org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning
+org.eclipse.jdt.core.compiler.problem.redundantNullAnnotation=warning
+org.eclipse.jdt.core.compiler.problem.redundantNullCheck=ignore
+org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=ignore
+org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=warning
+org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=ignore
+org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=ignore
+org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled
+org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning
+org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=disabled
+org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled
+org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore
+org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning
+org.eclipse.jdt.core.compiler.problem.unavoidableGenericTypeProblems=disabled
+org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning
+org.eclipse.jdt.core.compiler.problem.unclosedCloseable=error
+org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore
+org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning
+org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore
+org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=warning
+org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore
+org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=warning
+org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled
+org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled
+org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled
+org.eclipse.jdt.core.compiler.problem.unusedImport=warning
+org.eclipse.jdt.core.compiler.problem.unusedLabel=warning
+org.eclipse.jdt.core.compiler.problem.unusedLocal=warning
+org.eclipse.jdt.core.compiler.problem.unusedObjectAllocation=warning
+org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore
+org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled
+org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled
+org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled
+org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning
+org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning
+org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning
+org.eclipse.jdt.core.compiler.source=1.6
diff --git a/tools/layoutlib/create/Android.mk b/tools/layoutlib/create/Android.mk
index 310fae5..9bd48ab 100644
--- a/tools/layoutlib/create/Android.mk
+++ b/tools/layoutlib/create/Android.mk
@@ -20,7 +20,7 @@ LOCAL_SRC_FILES := $(call all-java-files-under,src)
LOCAL_JAR_MANIFEST := manifest.txt
LOCAL_STATIC_JAVA_LIBRARIES := \
- asm-3.1
+ asm-4.0
LOCAL_MODULE := layoutlib_create
diff --git a/tools/layoutlib/create/src/com/android/tools/layoutlib/create/AsmAnalyzer.java b/tools/layoutlib/create/src/com/android/tools/layoutlib/create/AsmAnalyzer.java
index b197ea7..412695f 100644
--- a/tools/layoutlib/create/src/com/android/tools/layoutlib/create/AsmAnalyzer.java
+++ b/tools/layoutlib/create/src/com/android/tools/layoutlib/create/AsmAnalyzer.java
@@ -23,6 +23,7 @@ import org.objectweb.asm.ClassVisitor;
import org.objectweb.asm.FieldVisitor;
import org.objectweb.asm.Label;
import org.objectweb.asm.MethodVisitor;
+import org.objectweb.asm.Opcodes;
import org.objectweb.asm.Type;
import org.objectweb.asm.signature.SignatureReader;
import org.objectweb.asm.signature.SignatureVisitor;
@@ -32,8 +33,8 @@ import java.util.ArrayList;
import java.util.Enumeration;
import java.util.List;
import java.util.Map;
-import java.util.TreeMap;
import java.util.Map.Entry;
+import java.util.TreeMap;
import java.util.regex.Pattern;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
@@ -45,7 +46,7 @@ import java.util.zip.ZipFile;
public class AsmAnalyzer {
// Note: a bunch of stuff has package-level access for unit tests. Consider it private.
-
+
/** Output logger. */
private final Log mLog;
/** The input source JAR to parse. */
@@ -59,11 +60,11 @@ public class AsmAnalyzer {
/**
* Creates a new analyzer.
- *
+ *
* @param log The log output.
* @param osJarPath The input source JARs to parse.
* @param gen The generator to fill with the class list and dependency list.
- * @param deriveFrom Keep all classes that derive from these one (these included).
+ * @param deriveFrom Keep all classes that derive from these one (these included).
* @param includeGlobs Glob patterns of classes to keep, e.g. "com.foo.*"
* ("*" does not matches dots whilst "**" does, "." and "$" are interpreted as-is)
*/
@@ -83,14 +84,14 @@ public class AsmAnalyzer {
public void analyze() throws IOException, LogAbortException {
AsmAnalyzer visitor = this;
-
+
Map<String, ClassReader> zipClasses = parseZip(mOsSourceJar);
mLog.info("Found %d classes in input JAR%s.", zipClasses.size(),
mOsSourceJar.size() > 1 ? "s" : "");
-
+
Map<String, ClassReader> found = findIncludes(zipClasses);
Map<String, ClassReader> deps = findDeps(zipClasses, found);
-
+
if (mGen != null) {
mGen.setKeep(found);
mGen.setDeps(deps);
@@ -117,10 +118,10 @@ public class AsmAnalyzer {
}
}
}
-
+
return classes;
}
-
+
/**
* Utility that returns the fully qualified binary class name for a ClassReader.
* E.g. it returns something like android.view.View.
@@ -132,7 +133,7 @@ public class AsmAnalyzer {
return classReader.getClassName().replace('/', '.');
}
}
-
+
/**
* Utility that returns the fully qualified binary class name from a path-like FQCN.
* E.g. it returns android.view.View from android/view/View.
@@ -144,7 +145,7 @@ public class AsmAnalyzer {
return className.replace('/', '.');
}
}
-
+
/**
* Process the "includes" arrays.
* <p/>
@@ -162,11 +163,11 @@ public class AsmAnalyzer {
for (String s : mDeriveFrom) {
findClassesDerivingFrom(s, zipClasses, found);
}
-
+
return found;
}
-
+
/**
* Uses ASM to find the class reader for the given FQCN class name.
* If found, insert it in the in_out_found map.
@@ -215,7 +216,7 @@ public class AsmAnalyzer {
globPattern += "$";
Pattern regexp = Pattern.compile(globPattern);
-
+
for (Entry<String, ClassReader> entry : zipClasses.entrySet()) {
String class_name = entry.getKey();
if (regexp.matcher(class_name).matches()) {
@@ -284,7 +285,7 @@ public class AsmAnalyzer {
for (ClassReader cr : inOutKeepClasses.values()) {
cr.accept(visitor, 0 /* flags */);
}
-
+
while (new_deps.size() > 0 || new_keep.size() > 0) {
deps.putAll(new_deps);
inOutKeepClasses.putAll(new_keep);
@@ -308,15 +309,14 @@ public class AsmAnalyzer {
return deps;
}
-
+
// ----------------------------------
-
+
/**
- * Visitor to collect all the type dependencies from a class.
+ * Visitor to collect all the type dependencies from a class.
*/
- public class DependencyVisitor
- implements ClassVisitor, FieldVisitor, MethodVisitor, SignatureVisitor, AnnotationVisitor {
+ public class DependencyVisitor extends ClassVisitor {
/** All classes found in the source JAR. */
private final Map<String, ClassReader> mZipClasses;
@@ -333,7 +333,7 @@ public class AsmAnalyzer {
* Creates a new visitor that will find all the dependencies for the visited class.
* Types which are already in the zipClasses, keepClasses or inDeps are not marked.
* New dependencies are marked in outDeps.
- *
+ *
* @param zipClasses All classes found in the source JAR.
* @param inKeep Classes from which dependencies are to be found.
* @param inDeps Dependencies already known.
@@ -344,13 +344,14 @@ public class AsmAnalyzer {
Map<String, ClassReader> outKeep,
Map<String,ClassReader> inDeps,
Map<String,ClassReader> outDeps) {
+ super(Opcodes.ASM4);
mZipClasses = zipClasses;
mInKeep = inKeep;
mOutKeep = outKeep;
mInDeps = inDeps;
mOutDeps = outDeps;
}
-
+
/**
* Considers the given class name as a dependency.
* If it does, add to the mOutDeps map.
@@ -361,7 +362,7 @@ public class AsmAnalyzer {
}
className = internalToBinaryClassName(className);
-
+
// exclude classes that have already been found
if (mInKeep.containsKey(className) ||
mOutKeep.containsKey(className) ||
@@ -384,7 +385,7 @@ public class AsmAnalyzer {
} catch (ClassNotFoundException e) {
// ignore
}
-
+
// accept this class:
// - android classes are added to dependencies
// - non-android classes are added to the list of classes to keep as-is (they don't need
@@ -395,7 +396,7 @@ public class AsmAnalyzer {
mOutKeep.put(className, cr);
}
}
-
+
/**
* Considers this array of names using considerName().
*/
@@ -416,7 +417,7 @@ public class AsmAnalyzer {
SignatureReader sr = new SignatureReader(signature);
// SignatureReader.accept will call accessType so we don't really have
// to differentiate where the signature comes from.
- sr.accept(this);
+ sr.accept(new MySignatureVisitor());
}
}
@@ -450,17 +451,18 @@ public class AsmAnalyzer {
}
}
-
+
// ---------------------------------------------------
// --- ClassVisitor, FieldVisitor
// ---------------------------------------------------
// Visits a class header
+ @Override
public void visit(int version, int access, String name,
String signature, String superName, String[] interfaces) {
// signature is the signature of this class. May be null if the class is not a generic
// one, and does not extend or implement generic classes or interfaces.
-
+
if (signature != null) {
considerSignature(signature);
}
@@ -468,27 +470,57 @@ public class AsmAnalyzer {
// superName is the internal of name of the super class (see getInternalName).
// For interfaces, the super class is Object. May be null but only for the Object class.
considerName(superName);
-
+
// interfaces is the internal names of the class's interfaces (see getInternalName).
// May be null.
considerNames(interfaces);
}
+
+ @Override
public AnnotationVisitor visitAnnotation(String desc, boolean visible) {
// desc is the class descriptor of the annotation class.
considerDesc(desc);
- return this; // return this to visit annotion values
+ return new MyAnnotationVisitor();
}
+ @Override
public void visitAttribute(Attribute attr) {
// pass
}
// Visits the end of a class
+ @Override
public void visitEnd() {
// pass
}
+ private class MyFieldVisitor extends FieldVisitor {
+
+ public MyFieldVisitor() {
+ super(Opcodes.ASM4);
+ }
+
+ @Override
+ public AnnotationVisitor visitAnnotation(String desc, boolean visible) {
+ // desc is the class descriptor of the annotation class.
+ considerDesc(desc);
+ return new MyAnnotationVisitor();
+ }
+
+ @Override
+ public void visitAttribute(Attribute attr) {
+ // pass
+ }
+
+ // Visits the end of a class
+ @Override
+ public void visitEnd() {
+ // pass
+ }
+ }
+
+ @Override
public FieldVisitor visitField(int access, String name, String desc,
String signature, Object value) {
// desc is the field's descriptor (see Type).
@@ -498,14 +530,16 @@ public class AsmAnalyzer {
// generic types.
considerSignature(signature);
- return this; // a visitor to visit field annotations and attributes
+ return new MyFieldVisitor();
}
+ @Override
public void visitInnerClass(String name, String outerName, String innerName, int access) {
// name is the internal name of an inner class (see getInternalName).
considerName(name);
}
+ @Override
public MethodVisitor visitMethod(int access, String name, String desc,
String signature, String[] exceptions) {
// desc is the method's descriptor (see Type).
@@ -513,239 +547,299 @@ public class AsmAnalyzer {
// signature is the method's signature. May be null if the method parameters, return
// type and exceptions do not use generic types.
considerSignature(signature);
-
- return this; // returns this to visit the method
+
+ return new MyMethodVisitor();
}
+ @Override
public void visitOuterClass(String owner, String name, String desc) {
// pass
}
+ @Override
public void visitSource(String source, String debug) {
// pass
}
-
+
// ---------------------------------------------------
// --- MethodVisitor
// ---------------------------------------------------
- public AnnotationVisitor visitAnnotationDefault() {
- return this; // returns this to visit the default value
- }
+ private class MyMethodVisitor extends MethodVisitor {
+ public MyMethodVisitor() {
+ super(Opcodes.ASM4);
+ }
- public void visitCode() {
- // pass
- }
- // field instruction
- public void visitFieldInsn(int opcode, String owner, String name, String desc) {
- // name is the field's name.
- considerName(name);
- // desc is the field's descriptor (see Type).
- considerDesc(desc);
- }
+ @Override
+ public AnnotationVisitor visitAnnotationDefault() {
+ return new MyAnnotationVisitor();
+ }
- public void visitFrame(int type, int local, Object[] local2, int stack, Object[] stack2) {
- // pass
- }
+ @Override
+ public void visitCode() {
+ // pass
+ }
- public void visitIincInsn(int var, int increment) {
- // pass -- an IINC instruction
- }
+ // field instruction
+ @Override
+ public void visitFieldInsn(int opcode, String owner, String name, String desc) {
+ // name is the field's name.
+ considerName(name);
+ // desc is the field's descriptor (see Type).
+ considerDesc(desc);
+ }
- public void visitInsn(int opcode) {
- // pass -- a zero operand instruction
- }
+ @Override
+ public void visitFrame(int type, int local, Object[] local2, int stack, Object[] stack2) {
+ // pass
+ }
- public void visitIntInsn(int opcode, int operand) {
- // pass -- a single int operand instruction
- }
+ @Override
+ public void visitIincInsn(int var, int increment) {
+ // pass -- an IINC instruction
+ }
- public void visitJumpInsn(int opcode, Label label) {
- // pass -- a jump instruction
- }
+ @Override
+ public void visitInsn(int opcode) {
+ // pass -- a zero operand instruction
+ }
- public void visitLabel(Label label) {
- // pass -- a label target
- }
+ @Override
+ public void visitIntInsn(int opcode, int operand) {
+ // pass -- a single int operand instruction
+ }
- // instruction to load a constant from the stack
- public void visitLdcInsn(Object cst) {
- if (cst instanceof Type) {
- considerType((Type) cst);
+ @Override
+ public void visitJumpInsn(int opcode, Label label) {
+ // pass -- a jump instruction
}
- }
- public void visitLineNumber(int line, Label start) {
- // pass
- }
+ @Override
+ public void visitLabel(Label label) {
+ // pass -- a label target
+ }
- public void visitLocalVariable(String name, String desc,
- String signature, Label start, Label end, int index) {
- // desc is the type descriptor of this local variable.
- considerDesc(desc);
- // signature is the type signature of this local variable. May be null if the local
- // variable type does not use generic types.
- considerSignature(signature);
- }
+ // instruction to load a constant from the stack
+ @Override
+ public void visitLdcInsn(Object cst) {
+ if (cst instanceof Type) {
+ considerType((Type) cst);
+ }
+ }
- public void visitLookupSwitchInsn(Label dflt, int[] keys, Label[] labels) {
- // pass -- a lookup switch instruction
- }
+ @Override
+ public void visitLineNumber(int line, Label start) {
+ // pass
+ }
- public void visitMaxs(int maxStack, int maxLocals) {
- // pass
- }
+ @Override
+ public void visitLocalVariable(String name, String desc,
+ String signature, Label start, Label end, int index) {
+ // desc is the type descriptor of this local variable.
+ considerDesc(desc);
+ // signature is the type signature of this local variable. May be null if the local
+ // variable type does not use generic types.
+ considerSignature(signature);
+ }
- // instruction that invokes a method
- public void visitMethodInsn(int opcode, String owner, String name, String desc) {
-
- // owner is the internal name of the method's owner class
- considerName(owner);
- // desc is the method's descriptor (see Type).
- considerDesc(desc);
- }
+ @Override
+ public void visitLookupSwitchInsn(Label dflt, int[] keys, Label[] labels) {
+ // pass -- a lookup switch instruction
+ }
- // instruction multianewarray, whatever that is
- public void visitMultiANewArrayInsn(String desc, int dims) {
-
- // desc an array type descriptor.
- considerDesc(desc);
- }
+ @Override
+ public void visitMaxs(int maxStack, int maxLocals) {
+ // pass
+ }
- public AnnotationVisitor visitParameterAnnotation(int parameter, String desc,
- boolean visible) {
- // desc is the class descriptor of the annotation class.
- considerDesc(desc);
- return this; // return this to visit annotation values
- }
+ // instruction that invokes a method
+ @Override
+ public void visitMethodInsn(int opcode, String owner, String name, String desc) {
- public void visitTableSwitchInsn(int min, int max, Label dflt, Label[] labels) {
- // pass -- table switch instruction
-
- }
+ // owner is the internal name of the method's owner class
+ considerName(owner);
+ // desc is the method's descriptor (see Type).
+ considerDesc(desc);
+ }
- public void visitTryCatchBlock(Label start, Label end, Label handler, String type) {
- // type is the internal name of the type of exceptions handled by the handler,
- // or null to catch any exceptions (for "finally" blocks).
- considerName(type);
- }
+ // instruction multianewarray, whatever that is
+ @Override
+ public void visitMultiANewArrayInsn(String desc, int dims) {
- // type instruction
- public void visitTypeInsn(int opcode, String type) {
- // type is the operand of the instruction to be visited. This operand must be the
- // internal name of an object or array class.
- considerName(type);
- }
+ // desc an array type descriptor.
+ considerDesc(desc);
+ }
- public void visitVarInsn(int opcode, int var) {
- // pass -- local variable instruction
- }
+ @Override
+ public AnnotationVisitor visitParameterAnnotation(int parameter, String desc,
+ boolean visible) {
+ // desc is the class descriptor of the annotation class.
+ considerDesc(desc);
+ return new MyAnnotationVisitor();
+ }
-
- // ---------------------------------------------------
- // --- SignatureVisitor
- // ---------------------------------------------------
+ @Override
+ public void visitTableSwitchInsn(int min, int max, Label dflt, Label[] labels) {
+ // pass -- table switch instruction
- private String mCurrentSignatureClass = null;
+ }
- // Starts the visit of a signature corresponding to a class or interface type
- public void visitClassType(String name) {
- mCurrentSignatureClass = name;
- considerName(name);
- }
+ @Override
+ public void visitTryCatchBlock(Label start, Label end, Label handler, String type) {
+ // type is the internal name of the type of exceptions handled by the handler,
+ // or null to catch any exceptions (for "finally" blocks).
+ considerName(type);
+ }
- // Visits an inner class
- public void visitInnerClassType(String name) {
- if (mCurrentSignatureClass != null) {
- mCurrentSignatureClass += "$" + name;
- considerName(mCurrentSignatureClass);
+ // type instruction
+ @Override
+ public void visitTypeInsn(int opcode, String type) {
+ // type is the operand of the instruction to be visited. This operand must be the
+ // internal name of an object or array class.
+ considerName(type);
}
- }
- public SignatureVisitor visitArrayType() {
- return this; // returns this to visit the signature of the array element type
+ @Override
+ public void visitVarInsn(int opcode, int var) {
+ // pass -- local variable instruction
+ }
}
- public void visitBaseType(char descriptor) {
- // pass -- a primitive type, ignored
- }
+ private class MySignatureVisitor extends SignatureVisitor {
- public SignatureVisitor visitClassBound() {
- return this; // returns this to visit the signature of the class bound
- }
+ public MySignatureVisitor() {
+ super(Opcodes.ASM4);
+ }
- public SignatureVisitor visitExceptionType() {
- return this; // return this to visit the signature of the exception type.
- }
+ // ---------------------------------------------------
+ // --- SignatureVisitor
+ // ---------------------------------------------------
- public void visitFormalTypeParameter(String name) {
- // pass
- }
+ private String mCurrentSignatureClass = null;
- public SignatureVisitor visitInterface() {
- return this; // returns this to visit the signature of the interface type
- }
+ // Starts the visit of a signature corresponding to a class or interface type
+ @Override
+ public void visitClassType(String name) {
+ mCurrentSignatureClass = name;
+ considerName(name);
+ }
- public SignatureVisitor visitInterfaceBound() {
- return this; // returns this to visit the signature of the interface bound
- }
+ // Visits an inner class
+ @Override
+ public void visitInnerClassType(String name) {
+ if (mCurrentSignatureClass != null) {
+ mCurrentSignatureClass += "$" + name;
+ considerName(mCurrentSignatureClass);
+ }
+ }
- public SignatureVisitor visitParameterType() {
- return this; // returns this to visit the signature of the parameter type
- }
+ @Override
+ public SignatureVisitor visitArrayType() {
+ return new MySignatureVisitor();
+ }
- public SignatureVisitor visitReturnType() {
- return this; // returns this to visit the signature of the return type
- }
+ @Override
+ public void visitBaseType(char descriptor) {
+ // pass -- a primitive type, ignored
+ }
- public SignatureVisitor visitSuperclass() {
- return this; // returns this to visit the signature of the super class type
- }
+ @Override
+ public SignatureVisitor visitClassBound() {
+ return new MySignatureVisitor();
+ }
- public SignatureVisitor visitTypeArgument(char wildcard) {
- return this; // returns this to visit the signature of the type argument
- }
+ @Override
+ public SignatureVisitor visitExceptionType() {
+ return new MySignatureVisitor();
+ }
- public void visitTypeVariable(String name) {
- // pass
- }
+ @Override
+ public void visitFormalTypeParameter(String name) {
+ // pass
+ }
- public void visitTypeArgument() {
- // pass
+ @Override
+ public SignatureVisitor visitInterface() {
+ return new MySignatureVisitor();
+ }
+
+ @Override
+ public SignatureVisitor visitInterfaceBound() {
+ return new MySignatureVisitor();
+ }
+
+ @Override
+ public SignatureVisitor visitParameterType() {
+ return new MySignatureVisitor();
+ }
+
+ @Override
+ public SignatureVisitor visitReturnType() {
+ return new MySignatureVisitor();
+ }
+
+ @Override
+ public SignatureVisitor visitSuperclass() {
+ return new MySignatureVisitor();
+ }
+
+ @Override
+ public SignatureVisitor visitTypeArgument(char wildcard) {
+ return new MySignatureVisitor();
+ }
+
+ @Override
+ public void visitTypeVariable(String name) {
+ // pass
+ }
+
+ @Override
+ public void visitTypeArgument() {
+ // pass
+ }
}
-
-
+
+
// ---------------------------------------------------
// --- AnnotationVisitor
// ---------------------------------------------------
+ private class MyAnnotationVisitor extends AnnotationVisitor {
- // Visits a primitive value of an annotation
- public void visit(String name, Object value) {
- // value is the actual value, whose type must be Byte, Boolean, Character, Short,
- // Integer, Long, Float, Double, String or Type
- if (value instanceof Type) {
- considerType((Type) value);
+ public MyAnnotationVisitor() {
+ super(Opcodes.ASM4);
}
- }
- public AnnotationVisitor visitAnnotation(String name, String desc) {
- // desc is the class descriptor of the nested annotation class.
- considerDesc(desc);
- return this; // returns this to visit the actual nested annotation value
- }
+ // Visits a primitive value of an annotation
+ @Override
+ public void visit(String name, Object value) {
+ // value is the actual value, whose type must be Byte, Boolean, Character, Short,
+ // Integer, Long, Float, Double, String or Type
+ if (value instanceof Type) {
+ considerType((Type) value);
+ }
+ }
- public AnnotationVisitor visitArray(String name) {
- return this; // returns this to visit the actual array value elements
- }
+ @Override
+ public AnnotationVisitor visitAnnotation(String name, String desc) {
+ // desc is the class descriptor of the nested annotation class.
+ considerDesc(desc);
+ return new MyAnnotationVisitor();
+ }
- public void visitEnum(String name, String desc, String value) {
- // desc is the class descriptor of the enumeration class.
- considerDesc(desc);
+ @Override
+ public AnnotationVisitor visitArray(String name) {
+ return new MyAnnotationVisitor();
+ }
+
+ @Override
+ public void visitEnum(String name, String desc, String value) {
+ // desc is the class descriptor of the enumeration class.
+ considerDesc(desc);
+ }
}
-
}
}
diff --git a/tools/layoutlib/create/src/com/android/tools/layoutlib/create/ClassHasNativeVisitor.java b/tools/layoutlib/create/src/com/android/tools/layoutlib/create/ClassHasNativeVisitor.java
index 722dce2..2c955fd 100644
--- a/tools/layoutlib/create/src/com/android/tools/layoutlib/create/ClassHasNativeVisitor.java
+++ b/tools/layoutlib/create/src/com/android/tools/layoutlib/create/ClassHasNativeVisitor.java
@@ -29,7 +29,10 @@ import org.objectweb.asm.Opcodes;
/**
* Indicates if a class contains any native methods.
*/
-public class ClassHasNativeVisitor implements ClassVisitor {
+public class ClassHasNativeVisitor extends ClassVisitor {
+ public ClassHasNativeVisitor() {
+ super(Opcodes.ASM4);
+ }
private boolean mHasNativeMethods = false;
@@ -42,35 +45,42 @@ public class ClassHasNativeVisitor implements ClassVisitor {
mHasNativeMethods = hasNativeMethods;
}
+ @Override
public void visit(int version, int access, String name, String signature,
String superName, String[] interfaces) {
// pass
}
+ @Override
public AnnotationVisitor visitAnnotation(String desc, boolean visible) {
// pass
return null;
}
+ @Override
public void visitAttribute(Attribute attr) {
// pass
}
+ @Override
public void visitEnd() {
// pass
}
+ @Override
public FieldVisitor visitField(int access, String name, String desc,
String signature, Object value) {
// pass
return null;
}
+ @Override
public void visitInnerClass(String name, String outerName,
String innerName, int access) {
// pass
}
+ @Override
public MethodVisitor visitMethod(int access, String name, String desc,
String signature, String[] exceptions) {
if ((access & Opcodes.ACC_NATIVE) != 0) {
@@ -79,10 +89,12 @@ public class ClassHasNativeVisitor implements ClassVisitor {
return null;
}
+ @Override
public void visitOuterClass(String owner, String name, String desc) {
// pass
}
+ @Override
public void visitSource(String source, String debug) {
// pass
}
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 70c8a00..79e02c8 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
@@ -27,6 +27,7 @@ public final class CreateInfo implements ICreateInfo {
* Returns the list of class from layoutlib_create to inject in layoutlib.
* The list can be empty but must not be null.
*/
+ @Override
public Class<?>[] getInjectedClasses() {
return INJECTED_CLASSES;
}
@@ -35,6 +36,7 @@ public final class CreateInfo implements ICreateInfo {
* Returns the list of methods to rewrite as delegates.
* The list can be empty but must not be null.
*/
+ @Override
public String[] getDelegateMethods() {
return DELEGATE_METHODS;
}
@@ -43,6 +45,7 @@ public final class CreateInfo implements ICreateInfo {
* Returns the list of classes on which to delegate all native methods.
* The list can be empty but must not be null.
*/
+ @Override
public String[] getDelegateClassNatives() {
return DELEGATE_CLASS_NATIVES;
}
@@ -54,6 +57,7 @@ public final class CreateInfo implements ICreateInfo {
* <p/>
* This usage is deprecated. Please use method 'delegates' instead.
*/
+ @Override
public String[] getOverriddenMethods() {
return OVERRIDDEN_METHODS;
}
@@ -63,6 +67,7 @@ public final class CreateInfo implements ICreateInfo {
* of class to replace followed by the new FQCN.
* The list can be empty but must not be null.
*/
+ @Override
public String[] getRenamedClasses() {
return RENAMED_CLASSES;
}
@@ -74,6 +79,7 @@ public final class CreateInfo implements ICreateInfo {
* the methods to delete.
* The list can be empty but must not be null.
*/
+ @Override
public String[] getDeleteReturns() {
return DELETE_RETURNS;
}
@@ -108,6 +114,7 @@ public final class CreateInfo implements ICreateInfo {
"android.view.LayoutInflater#rInflate",
"android.view.LayoutInflater#parseInclude",
"android.view.View#isInEditMode",
+ "android.view.ViewRootImpl#isInTouchMode",
"android.view.inputmethod.InputMethodManager#getInstance",
"android.util.Log#println_native",
"com.android.internal.util.XmlUtils#convertValueToInt",
@@ -177,10 +184,11 @@ public final class CreateInfo implements ICreateInfo {
*/
private final static String[] RENAMED_CLASSES =
new String[] {
- "android.os.ServiceManager", "android.os._Original_ServiceManager",
- "android.view.SurfaceView", "android.view._Original_SurfaceView",
+ "android.os.ServiceManager", "android.os._Original_ServiceManager",
+ "android.view.SurfaceView", "android.view._Original_SurfaceView",
"android.view.accessibility.AccessibilityManager", "android.view.accessibility._Original_AccessibilityManager",
- "android.webkit.WebView", "android.webkit._Original_WebView",
+ "android.webkit.WebView", "android.webkit._Original_WebView",
+ "com.android.internal.policy.PolicyManager", "com.android.internal.policy._Original_PolicyManager",
};
/**
diff --git a/tools/layoutlib/create/src/com/android/tools/layoutlib/create/DelegateClassAdapter.java b/tools/layoutlib/create/src/com/android/tools/layoutlib/create/DelegateClassAdapter.java
index 0e24cc0..927be97 100644
--- a/tools/layoutlib/create/src/com/android/tools/layoutlib/create/DelegateClassAdapter.java
+++ b/tools/layoutlib/create/src/com/android/tools/layoutlib/create/DelegateClassAdapter.java
@@ -16,7 +16,6 @@
package com.android.tools.layoutlib.create;
-import org.objectweb.asm.ClassAdapter;
import org.objectweb.asm.ClassVisitor;
import org.objectweb.asm.MethodVisitor;
import org.objectweb.asm.Opcodes;
@@ -29,7 +28,7 @@ import java.util.Set;
* <p/>
* This is used to override specific methods and or all native methods in classes.
*/
-public class DelegateClassAdapter extends ClassAdapter {
+public class DelegateClassAdapter extends ClassVisitor {
/** Suffix added to original methods. */
private static final String ORIGINAL_SUFFIX = "_Original";
@@ -59,7 +58,7 @@ public class DelegateClassAdapter extends ClassAdapter {
ClassVisitor cv,
String className,
Set<String> delegateMethods) {
- super(cv);
+ super(Opcodes.ASM4, cv);
mLog = log;
mClassName = className;
mDelegateMethods = delegateMethods;
diff --git a/tools/layoutlib/create/src/com/android/tools/layoutlib/create/DelegateMethodAdapter2.java b/tools/layoutlib/create/src/com/android/tools/layoutlib/create/DelegateMethodAdapter2.java
index 89b53ab..0000b22 100644
--- a/tools/layoutlib/create/src/com/android/tools/layoutlib/create/DelegateMethodAdapter2.java
+++ b/tools/layoutlib/create/src/com/android/tools/layoutlib/create/DelegateMethodAdapter2.java
@@ -71,7 +71,7 @@ import java.util.ArrayList;
* Instances of this class are not re-usable.
* The class adapter creates a new instance for each method.
*/
-class DelegateMethodAdapter2 implements MethodVisitor {
+class DelegateMethodAdapter2 extends MethodVisitor {
/** Suffix added to delegate classes. */
public static final String DELEGATE_SUFFIX = "_Delegate";
@@ -121,6 +121,7 @@ class DelegateMethodAdapter2 implements MethodVisitor {
String methodName,
String desc,
boolean isStatic) {
+ super(Opcodes.ASM4);
mLog = log;
mOrgWriter = mvOriginal;
mDelWriter = mvDelegate;
@@ -265,6 +266,7 @@ class DelegateMethodAdapter2 implements MethodVisitor {
}
/* Pass down to visitor writer. In this implementation, either do nothing. */
+ @Override
public void visitCode() {
if (mOrgWriter != null) {
mOrgWriter.visitCode();
@@ -274,6 +276,7 @@ class DelegateMethodAdapter2 implements MethodVisitor {
/*
* visitMaxs is called just before visitEnd if there was any code to rewrite.
*/
+ @Override
public void visitMaxs(int maxStack, int maxLocals) {
if (mOrgWriter != null) {
mOrgWriter.visitMaxs(maxStack, maxLocals);
@@ -281,6 +284,7 @@ class DelegateMethodAdapter2 implements MethodVisitor {
}
/** End of visiting. Generate the delegating code. */
+ @Override
public void visitEnd() {
if (mOrgWriter != null) {
mOrgWriter.visitEnd();
@@ -289,6 +293,7 @@ class DelegateMethodAdapter2 implements MethodVisitor {
}
/* Writes all annotation from the original method. */
+ @Override
public AnnotationVisitor visitAnnotation(String desc, boolean visible) {
if (mOrgWriter != null) {
return mOrgWriter.visitAnnotation(desc, visible);
@@ -298,6 +303,7 @@ class DelegateMethodAdapter2 implements MethodVisitor {
}
/* Writes all annotation default values from the original method. */
+ @Override
public AnnotationVisitor visitAnnotationDefault() {
if (mOrgWriter != null) {
return mOrgWriter.visitAnnotationDefault();
@@ -306,6 +312,7 @@ class DelegateMethodAdapter2 implements MethodVisitor {
}
}
+ @Override
public AnnotationVisitor visitParameterAnnotation(int parameter, String desc,
boolean visible) {
if (mOrgWriter != null) {
@@ -316,6 +323,7 @@ class DelegateMethodAdapter2 implements MethodVisitor {
}
/* Writes all attributes from the original method. */
+ @Override
public void visitAttribute(Attribute attr) {
if (mOrgWriter != null) {
mOrgWriter.visitAttribute(attr);
@@ -326,6 +334,7 @@ class DelegateMethodAdapter2 implements MethodVisitor {
* Only writes the first line number present in the original code so that source
* viewers can direct to the correct method, even if the content doesn't match.
*/
+ @Override
public void visitLineNumber(int line, Label start) {
// Capture the first line values for the new delegate method
if (mDelegateLineNumber == null) {
@@ -336,66 +345,77 @@ class DelegateMethodAdapter2 implements MethodVisitor {
}
}
+ @Override
public void visitInsn(int opcode) {
if (mOrgWriter != null) {
mOrgWriter.visitInsn(opcode);
}
}
+ @Override
public void visitLabel(Label label) {
if (mOrgWriter != null) {
mOrgWriter.visitLabel(label);
}
}
+ @Override
public void visitTryCatchBlock(Label start, Label end, Label handler, String type) {
if (mOrgWriter != null) {
mOrgWriter.visitTryCatchBlock(start, end, handler, type);
}
}
+ @Override
public void visitMethodInsn(int opcode, String owner, String name, String desc) {
if (mOrgWriter != null) {
mOrgWriter.visitMethodInsn(opcode, owner, name, desc);
}
}
+ @Override
public void visitFieldInsn(int opcode, String owner, String name, String desc) {
if (mOrgWriter != null) {
mOrgWriter.visitFieldInsn(opcode, owner, name, desc);
}
}
+ @Override
public void visitFrame(int type, int nLocal, Object[] local, int nStack, Object[] stack) {
if (mOrgWriter != null) {
mOrgWriter.visitFrame(type, nLocal, local, nStack, stack);
}
}
+ @Override
public void visitIincInsn(int var, int increment) {
if (mOrgWriter != null) {
mOrgWriter.visitIincInsn(var, increment);
}
}
+ @Override
public void visitIntInsn(int opcode, int operand) {
if (mOrgWriter != null) {
mOrgWriter.visitIntInsn(opcode, operand);
}
}
+ @Override
public void visitJumpInsn(int opcode, Label label) {
if (mOrgWriter != null) {
mOrgWriter.visitJumpInsn(opcode, label);
}
}
+ @Override
public void visitLdcInsn(Object cst) {
if (mOrgWriter != null) {
mOrgWriter.visitLdcInsn(cst);
}
}
+ @Override
public void visitLocalVariable(String name, String desc, String signature,
Label start, Label end, int index) {
if (mOrgWriter != null) {
@@ -403,30 +423,35 @@ class DelegateMethodAdapter2 implements MethodVisitor {
}
}
+ @Override
public void visitLookupSwitchInsn(Label dflt, int[] keys, Label[] labels) {
if (mOrgWriter != null) {
mOrgWriter.visitLookupSwitchInsn(dflt, keys, labels);
}
}
+ @Override
public void visitMultiANewArrayInsn(String desc, int dims) {
if (mOrgWriter != null) {
mOrgWriter.visitMultiANewArrayInsn(desc, dims);
}
}
+ @Override
public void visitTableSwitchInsn(int min, int max, Label dflt, Label[] labels) {
if (mOrgWriter != null) {
mOrgWriter.visitTableSwitchInsn(min, max, dflt, labels);
}
}
+ @Override
public void visitTypeInsn(int opcode, String type) {
if (mOrgWriter != null) {
mOrgWriter.visitTypeInsn(opcode, type);
}
}
+ @Override
public void visitVarInsn(int opcode, int var) {
if (mOrgWriter != null) {
mOrgWriter.visitVarInsn(opcode, var);
diff --git a/tools/layoutlib/create/src/com/android/tools/layoutlib/create/MethodAdapter.java b/tools/layoutlib/create/src/com/android/tools/layoutlib/create/MethodAdapter.java
index 627ea17..7d1e4cf 100644
--- a/tools/layoutlib/create/src/com/android/tools/layoutlib/create/MethodAdapter.java
+++ b/tools/layoutlib/create/src/com/android/tools/layoutlib/create/MethodAdapter.java
@@ -28,13 +28,14 @@ public class MethodAdapter implements MethodListener {
* A stub method is being invoked.
* <p/>
* Known limitation: caller arguments are not available.
- *
+ *
* @param signature The signature of the method being invoked, composed of the
* binary class name followed by the method descriptor (aka argument
* types). Example: "com/foo/MyClass/InnerClass/printInt(I)V".
* @param isNative True if the method was a native method.
* @param caller The calling object. Null for static methods, "this" for instance methods.
*/
+ @Override
public void onInvokeV(String signature, boolean isNative, Object caller) {
}
@@ -43,6 +44,7 @@ public class MethodAdapter implements MethodListener {
* @see #onInvokeV(String, boolean, Object)
* @return an integer, or a boolean, or a short or a byte.
*/
+ @Override
public int onInvokeI(String signature, boolean isNative, Object caller) {
onInvokeV(signature, isNative, caller);
return 0;
@@ -53,6 +55,7 @@ public class MethodAdapter implements MethodListener {
* @see #onInvokeV(String, boolean, Object)
* @return a long.
*/
+ @Override
public long onInvokeL(String signature, boolean isNative, Object caller) {
onInvokeV(signature, isNative, caller);
return 0;
@@ -63,6 +66,7 @@ public class MethodAdapter implements MethodListener {
* @see #onInvokeV(String, boolean, Object)
* @return a float.
*/
+ @Override
public float onInvokeF(String signature, boolean isNative, Object caller) {
onInvokeV(signature, isNative, caller);
return 0;
@@ -73,6 +77,7 @@ public class MethodAdapter implements MethodListener {
* @see #onInvokeV(String, boolean, Object)
* @return a double.
*/
+ @Override
public double onInvokeD(String signature, boolean isNative, Object caller) {
onInvokeV(signature, isNative, caller);
return 0;
@@ -83,6 +88,7 @@ public class MethodAdapter implements MethodListener {
* @see #onInvokeV(String, boolean, Object)
* @return an object.
*/
+ @Override
public Object onInvokeA(String signature, boolean isNative, Object caller) {
onInvokeV(signature, isNative, caller);
return null;
diff --git a/tools/layoutlib/create/src/com/android/tools/layoutlib/create/RenameClassAdapter.java b/tools/layoutlib/create/src/com/android/tools/layoutlib/create/RenameClassAdapter.java
index 0956b92..383cbb8 100644
--- a/tools/layoutlib/create/src/com/android/tools/layoutlib/create/RenameClassAdapter.java
+++ b/tools/layoutlib/create/src/com/android/tools/layoutlib/create/RenameClassAdapter.java
@@ -17,12 +17,12 @@
package com.android.tools.layoutlib.create;
import org.objectweb.asm.AnnotationVisitor;
-import org.objectweb.asm.ClassAdapter;
+import org.objectweb.asm.ClassVisitor;
import org.objectweb.asm.ClassWriter;
import org.objectweb.asm.FieldVisitor;
import org.objectweb.asm.Label;
-import org.objectweb.asm.MethodAdapter;
import org.objectweb.asm.MethodVisitor;
+import org.objectweb.asm.Opcodes;
import org.objectweb.asm.Type;
import org.objectweb.asm.signature.SignatureReader;
import org.objectweb.asm.signature.SignatureVisitor;
@@ -32,13 +32,13 @@ import org.objectweb.asm.signature.SignatureWriter;
* This class visitor renames a class from a given old name to a given new name.
* The class visitor will also rename all inner classes and references in the methods.
* <p/>
- *
+ *
* For inner classes, this handles only the case where the outer class name changes.
- * The inner class name should remain the same.
+ * The inner class name should remain the same.
*/
-public class RenameClassAdapter extends ClassAdapter {
+public class RenameClassAdapter extends ClassVisitor {
+
-
private final String mOldName;
private final String mNewName;
private String mOldBase;
@@ -50,10 +50,10 @@ public class RenameClassAdapter extends ClassAdapter {
* The names must be full qualified internal ASM names (e.g. com/blah/MyClass$InnerClass).
*/
public RenameClassAdapter(ClassWriter cv, String oldName, String newName) {
- super(cv);
+ super(Opcodes.ASM4, cv);
mOldBase = mOldName = oldName;
mNewBase = mNewName = newName;
-
+
int pos = mOldName.indexOf('$');
if (pos > 0) {
mOldBase = mOldName.substring(0, pos);
@@ -62,7 +62,7 @@ public class RenameClassAdapter extends ClassAdapter {
if (pos > 0) {
mNewBase = mNewName.substring(0, pos);
}
-
+
assert (mOldBase == null && mNewBase == null) || (mOldBase != null && mNewBase != null);
}
@@ -78,7 +78,7 @@ public class RenameClassAdapter extends ClassAdapter {
return renameType(Type.getType(desc));
}
-
+
/**
* Renames an object type, e.g. "Lcom.package.MyClass;" or an array type that has an
* object element, e.g. "[Lcom.package.MyClass;"
@@ -150,7 +150,7 @@ public class RenameClassAdapter extends ClassAdapter {
if (mOldBase != mOldName && type.equals(mOldBase)) {
return mNewBase;
}
-
+
int pos = type.indexOf('$');
if (pos == mOldBase.length() && type.startsWith(mOldBase)) {
return mNewBase + type.substring(pos);
@@ -183,7 +183,7 @@ public class RenameClassAdapter extends ClassAdapter {
sb.append(name);
}
sb.append(')');
-
+
Type ret = Type.getReturnType(desc);
String name = renameType(ret);
sb.append(name);
@@ -191,9 +191,9 @@ public class RenameClassAdapter extends ClassAdapter {
return sb.toString();
}
-
+
/**
- * Renames the ClassSignature handled by ClassVisitor.visit
+ * Renames the ClassSignature handled by ClassVisitor.visit
* or the MethodTypeSignature handled by ClassVisitor.visitMethod.
*/
String renameTypeSignature(String sig) {
@@ -207,7 +207,7 @@ public class RenameClassAdapter extends ClassAdapter {
return sig;
}
-
+
/**
* Renames the FieldTypeSignature handled by ClassVisitor.visitField
* or MethodVisitor.visitLocalVariable.
@@ -223,17 +223,17 @@ public class RenameClassAdapter extends ClassAdapter {
return sig;
}
-
+
//----------------------------------
// Methods from the ClassAdapter
-
+
@Override
public void visit(int version, int access, String name, String signature,
String superName, String[] interfaces) {
name = renameInternalType(name);
superName = renameInternalType(superName);
signature = renameTypeSignature(signature);
-
+
super.visit(version, access, name, signature, superName, interfaces);
}
@@ -259,7 +259,7 @@ public class RenameClassAdapter extends ClassAdapter {
desc = renameTypeDesc(desc);
return super.visitAnnotation(desc, visible);
}
-
+
@Override
public FieldVisitor visitField(int access, String name, String desc,
String signature, Object value) {
@@ -267,14 +267,14 @@ public class RenameClassAdapter extends ClassAdapter {
signature = renameFieldSignature(signature);
return super.visitField(access, name, desc, signature, value);
}
-
-
+
+
//----------------------------------
/**
* A method visitor that renames all references from an old class name to a new class name.
*/
- public class RenameMethodAdapter extends MethodAdapter {
+ public class RenameMethodAdapter extends MethodVisitor {
/**
* Creates a method visitor that renames all references from a given old name to a given new
@@ -282,13 +282,13 @@ public class RenameClassAdapter extends ClassAdapter {
* The names must be full qualified internal ASM names (e.g. com/blah/MyClass$InnerClass).
*/
public RenameMethodAdapter(MethodVisitor mv) {
- super(mv);
+ super(Opcodes.ASM4, mv);
}
@Override
public AnnotationVisitor visitAnnotation(String desc, boolean visible) {
desc = renameTypeDesc(desc);
-
+
return super.visitAnnotation(desc, visible);
}
@@ -302,7 +302,7 @@ public class RenameClassAdapter extends ClassAdapter {
@Override
public void visitTypeInsn(int opcode, String type) {
type = renameInternalType(type);
-
+
super.visitTypeInsn(opcode, type);
}
@@ -321,7 +321,7 @@ public class RenameClassAdapter extends ClassAdapter {
super.visitMethodInsn(opcode, owner, name, desc);
}
-
+
@Override
public void visitLdcInsn(Object cst) {
// If cst is a Type, this means the code is trying to pull the .class constant
@@ -335,14 +335,14 @@ public class RenameClassAdapter extends ClassAdapter {
@Override
public void visitMultiANewArrayInsn(String desc, int dims) {
desc = renameTypeDesc(desc);
-
+
super.visitMultiANewArrayInsn(desc, dims);
}
@Override
public void visitTryCatchBlock(Label start, Label end, Label handler, String type) {
type = renameInternalType(type);
-
+
super.visitTryCatchBlock(start, end, handler, type);
}
@@ -351,96 +351,113 @@ public class RenameClassAdapter extends ClassAdapter {
Label start, Label end, int index) {
desc = renameTypeDesc(desc);
signature = renameFieldSignature(signature);
-
+
super.visitLocalVariable(name, desc, signature, start, end, index);
}
}
//----------------------------------
-
- public class RenameSignatureAdapter implements SignatureVisitor {
+
+ public class RenameSignatureAdapter extends SignatureVisitor {
private final SignatureVisitor mSv;
public RenameSignatureAdapter(SignatureVisitor sv) {
+ super(Opcodes.ASM4);
mSv = sv;
}
+ @Override
public void visitClassType(String name) {
name = renameInternalType(name);
mSv.visitClassType(name);
}
+ @Override
public void visitInnerClassType(String name) {
name = renameInternalType(name);
mSv.visitInnerClassType(name);
}
+ @Override
public SignatureVisitor visitArrayType() {
SignatureVisitor sv = mSv.visitArrayType();
return new RenameSignatureAdapter(sv);
}
+ @Override
public void visitBaseType(char descriptor) {
mSv.visitBaseType(descriptor);
}
+ @Override
public SignatureVisitor visitClassBound() {
SignatureVisitor sv = mSv.visitClassBound();
return new RenameSignatureAdapter(sv);
}
+ @Override
public void visitEnd() {
mSv.visitEnd();
}
+ @Override
public SignatureVisitor visitExceptionType() {
SignatureVisitor sv = mSv.visitExceptionType();
return new RenameSignatureAdapter(sv);
}
+ @Override
public void visitFormalTypeParameter(String name) {
mSv.visitFormalTypeParameter(name);
}
+ @Override
public SignatureVisitor visitInterface() {
SignatureVisitor sv = mSv.visitInterface();
return new RenameSignatureAdapter(sv);
}
+ @Override
public SignatureVisitor visitInterfaceBound() {
SignatureVisitor sv = mSv.visitInterfaceBound();
return new RenameSignatureAdapter(sv);
}
+ @Override
public SignatureVisitor visitParameterType() {
SignatureVisitor sv = mSv.visitParameterType();
return new RenameSignatureAdapter(sv);
}
+ @Override
public SignatureVisitor visitReturnType() {
SignatureVisitor sv = mSv.visitReturnType();
return new RenameSignatureAdapter(sv);
}
+ @Override
public SignatureVisitor visitSuperclass() {
SignatureVisitor sv = mSv.visitSuperclass();
return new RenameSignatureAdapter(sv);
}
+ @Override
public void visitTypeArgument() {
mSv.visitTypeArgument();
}
+ @Override
public SignatureVisitor visitTypeArgument(char wildcard) {
SignatureVisitor sv = mSv.visitTypeArgument(wildcard);
return new RenameSignatureAdapter(sv);
}
+ @Override
public void visitTypeVariable(String name) {
mSv.visitTypeVariable(name);
}
-
+
}
}
diff --git a/tools/layoutlib/create/src/com/android/tools/layoutlib/create/StubMethodAdapter.java b/tools/layoutlib/create/src/com/android/tools/layoutlib/create/StubMethodAdapter.java
index d70d028..51e7535 100644
--- a/tools/layoutlib/create/src/com/android/tools/layoutlib/create/StubMethodAdapter.java
+++ b/tools/layoutlib/create/src/com/android/tools/layoutlib/create/StubMethodAdapter.java
@@ -27,7 +27,7 @@ import org.objectweb.asm.Type;
* This method adapter rewrites a method by discarding the original code and generating
* a stub depending on the return type. Original annotations are passed along unchanged.
*/
-class StubMethodAdapter implements MethodVisitor {
+class StubMethodAdapter extends MethodVisitor {
private static String CONSTRUCTOR = "<init>";
private static String CLASS_INIT = "<clinit>";
@@ -50,6 +50,7 @@ class StubMethodAdapter implements MethodVisitor {
public StubMethodAdapter(MethodVisitor mv, String methodName, Type returnType,
String invokeSignature, boolean isStatic, boolean isNative) {
+ super(Opcodes.ASM4);
mParentVisitor = mv;
mReturnType = returnType;
mInvokeSignature = invokeSignature;
@@ -172,6 +173,7 @@ class StubMethodAdapter implements MethodVisitor {
}
/* Pass down to visitor writer. In this implementation, either do nothing. */
+ @Override
public void visitCode() {
mParentVisitor.visitCode();
}
@@ -181,6 +183,7 @@ class StubMethodAdapter implements MethodVisitor {
* For non-constructor, generate the messaging code and the return statement
* if it hasn't been done before.
*/
+ @Override
public void visitMaxs(int maxStack, int maxLocals) {
if (!mIsInitMethod && !mMessageGenerated) {
generateInvoke();
@@ -194,6 +197,7 @@ class StubMethodAdapter implements MethodVisitor {
* For non-constructor, generate the messaging code and the return statement
* if it hasn't been done before.
*/
+ @Override
public void visitEnd() {
if (!mIsInitMethod && !mMessageGenerated) {
generateInvoke();
@@ -204,21 +208,25 @@ class StubMethodAdapter implements MethodVisitor {
}
/* Writes all annotation from the original method. */
+ @Override
public AnnotationVisitor visitAnnotation(String desc, boolean visible) {
return mParentVisitor.visitAnnotation(desc, visible);
}
/* Writes all annotation default values from the original method. */
+ @Override
public AnnotationVisitor visitAnnotationDefault() {
return mParentVisitor.visitAnnotationDefault();
}
+ @Override
public AnnotationVisitor visitParameterAnnotation(int parameter, String desc,
boolean visible) {
return mParentVisitor.visitParameterAnnotation(parameter, desc, visible);
}
/* Writes all attributes from the original method. */
+ @Override
public void visitAttribute(Attribute attr) {
mParentVisitor.visitAttribute(attr);
}
@@ -227,6 +235,7 @@ class StubMethodAdapter implements MethodVisitor {
* Only writes the first line number present in the original code so that source
* viewers can direct to the correct method, even if the content doesn't match.
*/
+ @Override
public void visitLineNumber(int line, Label start) {
if (mIsInitMethod || mOutputFirstLineNumber) {
mParentVisitor.visitLineNumber(line, start);
@@ -237,6 +246,7 @@ class StubMethodAdapter implements MethodVisitor {
/**
* For non-constructor, rewrite existing "return" instructions to write the message.
*/
+ @Override
public void visitInsn(int opcode) {
if (mIsInitMethod) {
switch (opcode) {
@@ -257,60 +267,70 @@ class StubMethodAdapter implements MethodVisitor {
}
}
+ @Override
public void visitLabel(Label label) {
if (mIsInitMethod) {
mParentVisitor.visitLabel(label);
}
}
+ @Override
public void visitTryCatchBlock(Label start, Label end, Label handler, String type) {
if (mIsInitMethod) {
mParentVisitor.visitTryCatchBlock(start, end, handler, type);
}
}
+ @Override
public void visitMethodInsn(int opcode, String owner, String name, String desc) {
if (mIsInitMethod) {
mParentVisitor.visitMethodInsn(opcode, owner, name, desc);
}
}
+ @Override
public void visitFieldInsn(int opcode, String owner, String name, String desc) {
if (mIsInitMethod) {
mParentVisitor.visitFieldInsn(opcode, owner, name, desc);
}
}
+ @Override
public void visitFrame(int type, int nLocal, Object[] local, int nStack, Object[] stack) {
if (mIsInitMethod) {
mParentVisitor.visitFrame(type, nLocal, local, nStack, stack);
}
}
+ @Override
public void visitIincInsn(int var, int increment) {
if (mIsInitMethod) {
mParentVisitor.visitIincInsn(var, increment);
}
}
+ @Override
public void visitIntInsn(int opcode, int operand) {
if (mIsInitMethod) {
mParentVisitor.visitIntInsn(opcode, operand);
}
}
+ @Override
public void visitJumpInsn(int opcode, Label label) {
if (mIsInitMethod) {
mParentVisitor.visitJumpInsn(opcode, label);
}
}
+ @Override
public void visitLdcInsn(Object cst) {
if (mIsInitMethod) {
mParentVisitor.visitLdcInsn(cst);
}
}
+ @Override
public void visitLocalVariable(String name, String desc, String signature,
Label start, Label end, int index) {
if (mIsInitMethod) {
@@ -318,30 +338,35 @@ class StubMethodAdapter implements MethodVisitor {
}
}
+ @Override
public void visitLookupSwitchInsn(Label dflt, int[] keys, Label[] labels) {
if (mIsInitMethod) {
mParentVisitor.visitLookupSwitchInsn(dflt, keys, labels);
}
}
+ @Override
public void visitMultiANewArrayInsn(String desc, int dims) {
if (mIsInitMethod) {
mParentVisitor.visitMultiANewArrayInsn(desc, dims);
}
}
+ @Override
public void visitTableSwitchInsn(int min, int max, Label dflt, Label[] labels) {
if (mIsInitMethod) {
mParentVisitor.visitTableSwitchInsn(min, max, dflt, labels);
}
}
+ @Override
public void visitTypeInsn(int opcode, String type) {
if (mIsInitMethod) {
mParentVisitor.visitTypeInsn(opcode, type);
}
}
+ @Override
public void visitVarInsn(int opcode, int var) {
if (mIsInitMethod) {
mParentVisitor.visitVarInsn(opcode, var);
diff --git a/tools/layoutlib/create/src/com/android/tools/layoutlib/create/TransformClassAdapter.java b/tools/layoutlib/create/src/com/android/tools/layoutlib/create/TransformClassAdapter.java
index 5a0a44a..d45a183 100644
--- a/tools/layoutlib/create/src/com/android/tools/layoutlib/create/TransformClassAdapter.java
+++ b/tools/layoutlib/create/src/com/android/tools/layoutlib/create/TransformClassAdapter.java
@@ -16,7 +16,6 @@
package com.android.tools.layoutlib.create;
-import org.objectweb.asm.ClassAdapter;
import org.objectweb.asm.ClassVisitor;
import org.objectweb.asm.FieldVisitor;
import org.objectweb.asm.MethodVisitor;
@@ -28,7 +27,7 @@ import java.util.Set;
/**
* Class adapter that can stub some or all of the methods of the class.
*/
-class TransformClassAdapter extends ClassAdapter {
+class TransformClassAdapter extends ClassVisitor {
/** True if all methods should be stubbed, false if only native ones must be stubbed. */
private final boolean mStubAll;
@@ -54,7 +53,7 @@ class TransformClassAdapter extends ClassAdapter {
public TransformClassAdapter(Log logger, Set<String> stubMethods,
Set<String> deleteReturns, String className, ClassVisitor cv,
boolean stubNativesOnly, boolean hasNative) {
- super(cv);
+ super(Opcodes.ASM4, cv);
mLog = logger;
mStubMethods = stubMethods;
mClassName = className;
diff --git a/tools/layoutlib/create/tests/com/android/tools/layoutlib/create/AsmGeneratorTest.java b/tools/layoutlib/create/tests/com/android/tools/layoutlib/create/AsmGeneratorTest.java
index f4ff389..7b76a5b 100644
--- a/tools/layoutlib/create/tests/com/android/tools/layoutlib/create/AsmGeneratorTest.java
+++ b/tools/layoutlib/create/tests/com/android/tools/layoutlib/create/AsmGeneratorTest.java
@@ -65,24 +65,29 @@ public class AsmGeneratorTest {
public void testClassRenaming() throws IOException, LogAbortException {
ICreateInfo ci = new ICreateInfo() {
+ @Override
public Class<?>[] getInjectedClasses() {
// classes to inject in the final JAR
return new Class<?>[0];
}
+ @Override
public String[] getDelegateMethods() {
return new String[0];
}
+ @Override
public String[] getDelegateClassNatives() {
return new String[0];
}
+ @Override
public String[] getOverriddenMethods() {
// methods to force override
return new String[0];
}
+ @Override
public String[] getRenamedClasses() {
// classes to rename (so that we can replace them)
return new String[] {
@@ -91,6 +96,7 @@ public class AsmGeneratorTest {
};
}
+ @Override
public String[] getDeleteReturns() {
// methods deleted from their return type.
return new String[0];
diff --git a/tools/makekeycodes/makekeycodes.cpp b/tools/makekeycodes/makekeycodes.cpp
index 16df774..6ffbfb8 100644
--- a/tools/makekeycodes/makekeycodes.cpp
+++ b/tools/makekeycodes/makekeycodes.cpp
@@ -1,5 +1,21 @@
+/*
+ * 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 <stdio.h>
-#include <ui/KeycodeLabels.h>
+#include <androidfw/KeycodeLabels.h>
int
main(int argc, char** argv)
diff --git a/tools/obbtool/Android.mk b/tools/obbtool/Android.mk
index 72a9858..dd57ae6 100644
--- a/tools/obbtool/Android.mk
+++ b/tools/obbtool/Android.mk
@@ -19,6 +19,7 @@ LOCAL_CFLAGS := -Wall -Werror
LOCAL_STATIC_LIBRARIES := \
libutils \
+ libandroidfw \
libcutils
ifeq ($(HOST_OS),linux)
diff --git a/tools/obbtool/Main.cpp b/tools/obbtool/Main.cpp
index 932dbec..b2152e8 100644
--- a/tools/obbtool/Main.cpp
+++ b/tools/obbtool/Main.cpp
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-#include <utils/ObbFile.h>
+#include <androidfw/ObbFile.h>
#include <utils/String8.h>
#include <getopt.h>
diff --git a/tools/orientationplot/orientationplot.py b/tools/orientationplot/orientationplot.py
index 3a44cb2..f4e6b45 100755
--- a/tools/orientationplot/orientationplot.py
+++ b/tools/orientationplot/orientationplot.py
@@ -82,6 +82,7 @@ class Plotter:
self.raw_acceleration_x = self._make_timeseries()
self.raw_acceleration_y = self._make_timeseries()
self.raw_acceleration_z = self._make_timeseries()
+ self.raw_acceleration_magnitude = self._make_timeseries()
self.raw_acceleration_axes = self._add_timeseries_axes(
1, 'Raw Acceleration', 'm/s^2', [-20, 20],
yticks=range(-15, 16, 5))
@@ -91,6 +92,8 @@ class Plotter:
self.raw_acceleration_axes, 'y', 'green')
self.raw_acceleration_line_z = self._add_timeseries_line(
self.raw_acceleration_axes, 'z', 'blue')
+ self.raw_acceleration_line_magnitude = self._add_timeseries_line(
+ self.raw_acceleration_axes, 'magnitude', 'orange', linewidth=2)
self._add_timeseries_legend(self.raw_acceleration_axes)
shared_axis = self.raw_acceleration_axes
@@ -98,7 +101,7 @@ class Plotter:
self.filtered_acceleration_x = self._make_timeseries()
self.filtered_acceleration_y = self._make_timeseries()
self.filtered_acceleration_z = self._make_timeseries()
- self.magnitude = self._make_timeseries()
+ self.filtered_acceleration_magnitude = self._make_timeseries()
self.filtered_acceleration_axes = self._add_timeseries_axes(
2, 'Filtered Acceleration', 'm/s^2', [-20, 20],
sharex=shared_axis,
@@ -109,7 +112,7 @@ class Plotter:
self.filtered_acceleration_axes, 'y', 'green')
self.filtered_acceleration_line_z = self._add_timeseries_line(
self.filtered_acceleration_axes, 'z', 'blue')
- self.magnitude_line = self._add_timeseries_line(
+ self.filtered_acceleration_line_magnitude = self._add_timeseries_line(
self.filtered_acceleration_axes, 'magnitude', 'orange', linewidth=2)
self._add_timeseries_legend(self.filtered_acceleration_axes)
@@ -133,32 +136,46 @@ class Plotter:
self.current_rotation = self._make_timeseries()
self.proposed_rotation = self._make_timeseries()
- self.proposal_rotation = self._make_timeseries()
+ self.predicted_rotation = self._make_timeseries()
self.orientation_axes = self._add_timeseries_axes(
- 5, 'Current / Proposed Orientation and Confidence', 'rotation', [-1, 4],
+ 5, 'Current / Proposed Orientation', 'rotation', [-1, 4],
sharex=shared_axis,
yticks=range(0, 4))
self.current_rotation_line = self._add_timeseries_line(
self.orientation_axes, 'current', 'black', linewidth=2)
- self.proposal_rotation_line = self._add_timeseries_line(
- self.orientation_axes, 'proposal', 'purple', linewidth=3)
+ self.predicted_rotation_line = self._add_timeseries_line(
+ self.orientation_axes, 'predicted', 'purple', linewidth=3)
self.proposed_rotation_line = self._add_timeseries_line(
self.orientation_axes, 'proposed', 'green', linewidth=3)
self._add_timeseries_legend(self.orientation_axes)
- self.proposal_confidence = [[self._make_timeseries(), self._make_timeseries()]
- for i in range(0, 4)]
- self.proposal_confidence_polys = []
+ self.time_until_settled = self._make_timeseries()
+ self.time_until_flat_delay_expired = self._make_timeseries()
+ self.time_until_swing_delay_expired = self._make_timeseries()
+ self.stability_axes = self._add_timeseries_axes(
+ 6, 'Proposal Stability', 'ms', [-10, 600],
+ sharex=shared_axis,
+ yticks=range(0, 600, 100))
+ self.time_until_settled_line = self._add_timeseries_line(
+ self.stability_axes, 'time until settled', 'black', linewidth=2)
+ self.time_until_flat_delay_expired_line = self._add_timeseries_line(
+ self.stability_axes, 'time until flat delay expired', 'green')
+ self.time_until_swing_delay_expired_line = self._add_timeseries_line(
+ self.stability_axes, 'time until swing delay expired', 'blue')
+ self._add_timeseries_legend(self.stability_axes)
self.sample_latency = self._make_timeseries()
self.sample_latency_axes = self._add_timeseries_axes(
- 6, 'Accelerometer Sampling Latency', 'ms', [-10, 500],
+ 7, 'Accelerometer Sampling Latency', 'ms', [-10, 500],
sharex=shared_axis,
yticks=range(0, 500, 100))
self.sample_latency_line = self._add_timeseries_line(
self.sample_latency_axes, 'latency', 'black')
self._add_timeseries_legend(self.sample_latency_axes)
+ self.fig.canvas.mpl_connect('button_press_event', self._on_click)
+ self.paused = False
+
self.timer = self.fig.canvas.new_timer(interval=100)
self.timer.add_callback(lambda: self.update())
self.timer.start()
@@ -166,13 +183,22 @@ class Plotter:
self.timebase = None
self._reset_parse_state()
+ # Handle a click event to pause or restart the timer.
+ def _on_click(self, ev):
+ if not self.paused:
+ self.paused = True
+ self.timer.stop()
+ else:
+ self.paused = False
+ self.timer.start()
+
# Initialize a time series.
def _make_timeseries(self):
return [[], []]
# Add a subplot to the figure for a time series.
def _add_timeseries_axes(self, index, title, ylabel, ylim, yticks, sharex=None):
- num_graphs = 6
+ num_graphs = 7
height = 0.9 / num_graphs
top = 0.95 - height * index
axes = self.fig.add_axes([0.1, top, 0.8, height],
@@ -214,16 +240,19 @@ class Plotter:
self.parse_raw_acceleration_x = None
self.parse_raw_acceleration_y = None
self.parse_raw_acceleration_z = None
+ self.parse_raw_acceleration_magnitude = None
self.parse_filtered_acceleration_x = None
self.parse_filtered_acceleration_y = None
self.parse_filtered_acceleration_z = None
- self.parse_magnitude = None
+ self.parse_filtered_acceleration_magnitude = None
self.parse_tilt_angle = None
self.parse_orientation_angle = None
self.parse_current_rotation = None
self.parse_proposed_rotation = None
- self.parse_proposal_rotation = None
- self.parse_proposal_confidence = None
+ self.parse_predicted_rotation = None
+ self.parse_time_until_settled = None
+ self.parse_time_until_flat_delay_expired = None
+ self.parse_time_until_swing_delay_expired = None
self.parse_sample_latency = None
# Update samples.
@@ -252,14 +281,13 @@ class Plotter:
self.parse_raw_acceleration_x = self._get_following_number(line, 'x=')
self.parse_raw_acceleration_y = self._get_following_number(line, 'y=')
self.parse_raw_acceleration_z = self._get_following_number(line, 'z=')
+ self.parse_raw_acceleration_magnitude = self._get_following_number(line, 'magnitude=')
if line.find('Filtered acceleration vector:') != -1:
self.parse_filtered_acceleration_x = self._get_following_number(line, 'x=')
self.parse_filtered_acceleration_y = self._get_following_number(line, 'y=')
self.parse_filtered_acceleration_z = self._get_following_number(line, 'z=')
-
- if line.find('magnitude=') != -1:
- self.parse_magnitude = self._get_following_number(line, 'magnitude=')
+ self.parse_filtered_acceleration_magnitude = self._get_following_number(line, 'magnitude=')
if line.find('tiltAngle=') != -1:
self.parse_tilt_angle = self._get_following_number(line, 'tiltAngle=')
@@ -270,17 +298,20 @@ class Plotter:
if line.find('Result:') != -1:
self.parse_current_rotation = self._get_following_number(line, 'currentRotation=')
self.parse_proposed_rotation = self._get_following_number(line, 'proposedRotation=')
- self.parse_proposal_rotation = self._get_following_number(line, 'proposalRotation=')
- self.parse_proposal_confidence = self._get_following_number(line, 'proposalConfidence=')
+ self.parse_predicted_rotation = self._get_following_number(line, 'predictedRotation=')
self.parse_sample_latency = self._get_following_number(line, 'timeDeltaMS=')
+ self.parse_time_until_settled = self._get_following_number(line, 'timeUntilSettledMS=')
+ self.parse_time_until_flat_delay_expired = self._get_following_number(line, 'timeUntilFlatDelayExpiredMS=')
+ self.parse_time_until_swing_delay_expired = self._get_following_number(line, 'timeUntilSwingDelayExpiredMS=')
self._append(self.raw_acceleration_x, timeindex, self.parse_raw_acceleration_x)
self._append(self.raw_acceleration_y, timeindex, self.parse_raw_acceleration_y)
self._append(self.raw_acceleration_z, timeindex, self.parse_raw_acceleration_z)
+ self._append(self.raw_acceleration_magnitude, timeindex, self.parse_raw_acceleration_magnitude)
self._append(self.filtered_acceleration_x, timeindex, self.parse_filtered_acceleration_x)
self._append(self.filtered_acceleration_y, timeindex, self.parse_filtered_acceleration_y)
self._append(self.filtered_acceleration_z, timeindex, self.parse_filtered_acceleration_z)
- self._append(self.magnitude, timeindex, self.parse_magnitude)
+ self._append(self.filtered_acceleration_magnitude, timeindex, self.parse_filtered_acceleration_magnitude)
self._append(self.tilt_angle, timeindex, self.parse_tilt_angle)
self._append(self.orientation_angle, timeindex, self.parse_orientation_angle)
self._append(self.current_rotation, timeindex, self.parse_current_rotation)
@@ -288,17 +319,13 @@ class Plotter:
self._append(self.proposed_rotation, timeindex, self.parse_proposed_rotation)
else:
self._append(self.proposed_rotation, timeindex, None)
- if self.parse_proposal_rotation >= 0:
- self._append(self.proposal_rotation, timeindex, self.parse_proposal_rotation)
+ if self.parse_predicted_rotation >= 0:
+ self._append(self.predicted_rotation, timeindex, self.parse_predicted_rotation)
else:
- self._append(self.proposal_rotation, timeindex, None)
- for i in range(0, 4):
- self._append(self.proposal_confidence[i][0], timeindex, i)
- if i == self.parse_proposal_rotation:
- self._append(self.proposal_confidence[i][1], timeindex,
- i + self.parse_proposal_confidence)
- else:
- self._append(self.proposal_confidence[i][1], timeindex, i)
+ self._append(self.predicted_rotation, timeindex, None)
+ self._append(self.time_until_settled, timeindex, self.parse_time_until_settled)
+ self._append(self.time_until_flat_delay_expired, timeindex, self.parse_time_until_flat_delay_expired)
+ self._append(self.time_until_swing_delay_expired, timeindex, self.parse_time_until_swing_delay_expired)
self._append(self.sample_latency, timeindex, self.parse_sample_latency)
self._reset_parse_state()
@@ -309,45 +336,40 @@ class Plotter:
self._scroll(self.raw_acceleration_x, bottom)
self._scroll(self.raw_acceleration_y, bottom)
self._scroll(self.raw_acceleration_z, bottom)
+ self._scroll(self.raw_acceleration_magnitude, bottom)
self._scroll(self.filtered_acceleration_x, bottom)
self._scroll(self.filtered_acceleration_y, bottom)
self._scroll(self.filtered_acceleration_z, bottom)
- self._scroll(self.magnitude, bottom)
+ self._scroll(self.filtered_acceleration_magnitude, bottom)
self._scroll(self.tilt_angle, bottom)
self._scroll(self.orientation_angle, bottom)
self._scroll(self.current_rotation, bottom)
self._scroll(self.proposed_rotation, bottom)
- self._scroll(self.proposal_rotation, bottom)
- for i in range(0, 4):
- self._scroll(self.proposal_confidence[i][0], bottom)
- self._scroll(self.proposal_confidence[i][1], bottom)
+ self._scroll(self.predicted_rotation, bottom)
+ self._scroll(self.time_until_settled, bottom)
+ self._scroll(self.time_until_flat_delay_expired, bottom)
+ self._scroll(self.time_until_swing_delay_expired, bottom)
self._scroll(self.sample_latency, bottom)
# Redraw the plots.
self.raw_acceleration_line_x.set_data(self.raw_acceleration_x)
self.raw_acceleration_line_y.set_data(self.raw_acceleration_y)
self.raw_acceleration_line_z.set_data(self.raw_acceleration_z)
+ self.raw_acceleration_line_magnitude.set_data(self.raw_acceleration_magnitude)
self.filtered_acceleration_line_x.set_data(self.filtered_acceleration_x)
self.filtered_acceleration_line_y.set_data(self.filtered_acceleration_y)
self.filtered_acceleration_line_z.set_data(self.filtered_acceleration_z)
- self.magnitude_line.set_data(self.magnitude)
+ self.filtered_acceleration_line_magnitude.set_data(self.filtered_acceleration_magnitude)
self.tilt_angle_line.set_data(self.tilt_angle)
self.orientation_angle_line.set_data(self.orientation_angle)
self.current_rotation_line.set_data(self.current_rotation)
self.proposed_rotation_line.set_data(self.proposed_rotation)
- self.proposal_rotation_line.set_data(self.proposal_rotation)
+ self.predicted_rotation_line.set_data(self.predicted_rotation)
+ self.time_until_settled_line.set_data(self.time_until_settled)
+ self.time_until_flat_delay_expired_line.set_data(self.time_until_flat_delay_expired)
+ self.time_until_swing_delay_expired_line.set_data(self.time_until_swing_delay_expired)
self.sample_latency_line.set_data(self.sample_latency)
- for poly in self.proposal_confidence_polys:
- poly.remove()
- self.proposal_confidence_polys = []
- for i in range(0, 4):
- self.proposal_confidence_polys.append(self.orientation_axes.fill_between(
- self.proposal_confidence[i][0][0],
- self.proposal_confidence[i][0][1],
- self.proposal_confidence[i][1][1],
- facecolor='goldenrod', edgecolor='goldenrod'))
-
self.fig.canvas.draw_idle()
# Scroll a time series.
diff --git a/tools/validatekeymaps/Android.mk b/tools/validatekeymaps/Android.mk
index 1368a07..fce2e93 100644
--- a/tools/validatekeymaps/Android.mk
+++ b/tools/validatekeymaps/Android.mk
@@ -18,7 +18,7 @@ LOCAL_CFLAGS := -Wall -Werror
#LOCAL_C_INCLUDES +=
LOCAL_STATIC_LIBRARIES := \
- libui \
+ libandroidfw \
libutils \
libcutils
diff --git a/tools/validatekeymaps/Main.cpp b/tools/validatekeymaps/Main.cpp
index 8ab9b6a..91e4fda 100644
--- a/tools/validatekeymaps/Main.cpp
+++ b/tools/validatekeymaps/Main.cpp
@@ -14,9 +14,9 @@
* limitations under the License.
*/
-#include <ui/KeyCharacterMap.h>
-#include <ui/KeyLayoutMap.h>
-#include <ui/VirtualKeyMap.h>
+#include <androidfw/KeyCharacterMap.h>
+#include <androidfw/KeyLayoutMap.h>
+#include <androidfw/VirtualKeyMap.h>
#include <utils/PropertyMap.h>
#include <utils/String8.h>
@@ -78,7 +78,7 @@ static bool validateFile(const char* filename) {
return false;
case FILETYPE_KEYLAYOUT: {
- KeyLayoutMap* map;
+ sp<KeyLayoutMap> map;
status_t status = KeyLayoutMap::load(String8(filename), &map);
if (status) {
fprintf(stderr, "Error %d parsing key layout file.\n\n", status);
@@ -88,8 +88,9 @@ static bool validateFile(const char* filename) {
}
case FILETYPE_KEYCHARACTERMAP: {
- KeyCharacterMap* map;
- status_t status = KeyCharacterMap::load(String8(filename), &map);
+ sp<KeyCharacterMap> map;
+ status_t status = KeyCharacterMap::load(String8(filename),
+ KeyCharacterMap::FORMAT_ANY, &map);
if (status) {
fprintf(stderr, "Error %d parsing key character map file.\n\n", status);
return false;
@@ -104,6 +105,7 @@ static bool validateFile(const char* filename) {
fprintf(stderr, "Error %d parsing input device configuration file.\n\n", status);
return false;
}
+ delete map;
break;
}
@@ -114,6 +116,7 @@ static bool validateFile(const char* filename) {
fprintf(stderr, "Error %d parsing virtual key definition file.\n\n", status);
return false;
}
+ delete map;
break;
}
}