+void
+addProguardKeepRule(ProguardKeepSet* keep, const String8& inClassName,
+ const char* pkg, const String8& srcName, int line)
+{
+ String8 className(inClassName);
+ if (pkg != NULL) {
+ // asdf --> package.asdf
+ // .asdf .a.b --> package.asdf package.a.b
+ // asdf.adsf --> asdf.asdf
+ const char* p = className.string();
+ const char* q = strchr(p, '.');
+ if (p == q) {
+ className = pkg;
+ className.append(inClassName);
+ } else if (q == NULL) {
+ className = pkg;
+ className.append(".");
+ className.append(inClassName);
+ }
+ }
+
+ String8 rule("-keep class ");
+ rule += className;
+ rule += " { <init>(...); }";
+
+ String8 location("view ");
+ location += srcName;
+ char lineno[20];
+ sprintf(lineno, ":%d", line);
+ location += lineno;
+
+ keep->add(rule, location);
+}
+