summaryrefslogtreecommitdiffstats
path: root/tools/aapt
diff options
context:
space:
mode:
authorDianne Hackborn <hackbod@google.com>2012-05-18 19:41:10 -0700
committerAndroid Git Automerger <android-git-automerger@android.com>2012-05-18 19:41:10 -0700
commit72669b5f4663937b09d33f9d951f0b86a03fa98b (patch)
tree3daf749f3aa07123d471ab58c86ceaace6cee55f /tools/aapt
parent099a220cf57f00732d347cd49422c849354d2e38 (diff)
parent13a0271cb81d497edbf93f3d6ecf4b9b8da4ee69 (diff)
downloadframeworks_base-72669b5f4663937b09d33f9d951f0b86a03fa98b.zip
frameworks_base-72669b5f4663937b09d33f9d951f0b86a03fa98b.tar.gz
frameworks_base-72669b5f4663937b09d33f9d951f0b86a03fa98b.tar.bz2
am 13a0271c: Merge "Add aapt support for generating proguard rules for onClick methods." into jb-dev
* commit '13a0271cb81d497edbf93f3d6ecf4b9b8da4ee69': Add aapt support for generating proguard rules for onClick methods.
Diffstat (limited to 'tools/aapt')
-rw-r--r--tools/aapt/Resource.cpp27
1 files changed, 27 insertions, 0 deletions
diff --git a/tools/aapt/Resource.cpp b/tools/aapt/Resource.cpp
index b9ec30c..a69adc1 100644
--- a/tools/aapt/Resource.cpp
+++ b/tools/aapt/Resource.cpp
@@ -2089,6 +2089,23 @@ addProguardKeepRule(ProguardKeepSet* keep, const String8& inClassName,
keep->add(rule, location);
}
+void
+addProguardKeepMethodRule(ProguardKeepSet* keep, const String8& memberName,
+ const char* pkg, const String8& srcName, int line)
+{
+ String8 rule("-keepclassmembers class * { *** ");
+ rule += memberName;
+ rule += "(...); }";
+
+ String8 location("onClick ");
+ location += srcName;
+ char lineno[20];
+ sprintf(lineno, ":%d", line);
+ location += lineno;
+
+ keep->add(rule, location);
+}
+
status_t
writeProguardForAndroidManifest(ProguardKeepSet* keep, const sp<AaptAssets>& assets)
{
@@ -2251,6 +2268,13 @@ writeProguardForXml(ProguardKeepSet* keep, const sp<AaptFile>& layoutFile,
}
}
}
+ ssize_t attrIndex = tree.indexOfAttribute(RESOURCES_ANDROID_NAMESPACE, "onClick");
+ if (attrIndex >= 0) {
+ size_t len;
+ addProguardKeepMethodRule(keep,
+ String8(tree.getAttributeStringValue(attrIndex, &len)), NULL,
+ layoutFile->getPrintableSource(), tree.getLineNumber());
+ }
}
return NO_ERROR;
@@ -2289,6 +2313,9 @@ writeProguardForLayouts(ProguardKeepSet* keep, const sp<AaptAssets>& assets)
} else if ((dirName == String8("xml")) || (strncmp(dirName.string(), "xml-", 4) == 0)) {
startTag = "PreferenceScreen";
tagAttrPairs = &kXmlTagAttrPairs;
+ } else if ((dirName == String8("menu")) || (strncmp(dirName.string(), "menu-", 5) == 0)) {
+ startTag = "menu";
+ tagAttrPairs = NULL;
} else {
continue;
}