Don't use anonymous literal structures for RS object types.

Bug: 22926131

Using an anonymous structure type prevents us from being able to use
LLVM to determine the actual typename. This is problematic, because
there are some cases where bcc needs to be able to detect/act on RS
object types. Giving each of these structures a legitimate name has no
impact on the generated code (since we are already using typedefs).
This change is also safe for targeting prior Android releases with our
toolchain.

This change also adjusts the API generator to ensure that we can
generate relevant code/docs/tests for handling RS objects. A new
TypeKind is added for RS_OBJECT, instead of using SIMPLE.

Change-Id: Iaff928f5821af66cfc9b3aea2ff5549d0c8a9408
diff --git a/api/GenerateDocumentation.cpp b/api/GenerateDocumentation.cpp
index 9d399d4..41f85cb 100644
--- a/api/GenerateDocumentation.cpp
+++ b/api/GenerateDocumentation.cpp
@@ -306,7 +306,8 @@
     writeSummaryTable(file, &functionStream, "Functions", deprecatedSelector, labelAsHeader);
 }
 
-static void writeHtmlVersionTag(GeneratedFile* file, VersionInfo info) {
+static void writeHtmlVersionTag(GeneratedFile* file, VersionInfo info,
+                                bool addSpacing) {
     ostringstream stream;
     if (info.intSize == 32) {
         stream << "When compiling for 32 bits. ";
@@ -334,9 +335,13 @@
         }
         stream << "</a>";
     }
-    const string s = stream.str();
+    string s = stream.str();
+    // Remove any trailing whitespace
+    while (s.back() == ' ') {
+        s.pop_back();
+    }
     if (!s.empty()) {
-        *file << "    " << s << "\n";
+        *file << (addSpacing ? "    " : "") << s << "\n";
     }
 }
 
@@ -345,16 +350,22 @@
         case SIMPLE: {
             Type* type = spec->getType();
             *file << "<p>A typedef of: " << spec->getSimpleType()
-                  << makeAttributeTag(spec->getAttribute(), "", type->deprecated(),
+                  << makeAttributeTag(spec->getAttribute(), "", type->getDeprecatedApiLevel(),
                                       type->getDeprecatedMessage())
                   << "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
-            writeHtmlVersionTag(file, spec->getVersionInfo());
+            writeHtmlVersionTag(file, spec->getVersionInfo(), false);
+            *file << "</p>\n";
+            break;
+        }
+        case RS_OBJECT: {
+            *file << "<p>";
+            writeHtmlVersionTag(file, spec->getVersionInfo(), false);
             *file << "</p>\n";
             break;
         }
         case ENUM: {
             *file << "<p>An enum with the following values:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\n";
-            writeHtmlVersionTag(file, spec->getVersionInfo());
+            writeHtmlVersionTag(file, spec->getVersionInfo(), false);
             *file << "</p>\n";
 
             *file << "  <table class='jd-tagtable'><tbody>\n";
@@ -372,7 +383,7 @@
         }
         case STRUCT: {
             *file << "<p>A structure with the following fields:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
-            writeHtmlVersionTag(file, spec->getVersionInfo());
+            writeHtmlVersionTag(file, spec->getVersionInfo(), false);
             *file << "</p>\n";
 
             *file << "  <table class='jd-tagtable'><tbody>\n";
@@ -394,7 +405,7 @@
 static void writeDetailedConstantSpecification(GeneratedFile* file, ConstantSpecification* c) {
     *file << "      <tr><td>";
     *file << "Value: " << c->getValue() << "\n";
-    writeHtmlVersionTag(file, c->getVersionInfo());
+    writeHtmlVersionTag(file, c->getVersionInfo(), true);
     *file << "      </td></tr>\n";
     *file << "<br/>\n";
 }
@@ -557,7 +568,7 @@
         *file << "      <tr>\n";
         *file << "        <td>" << i.second.htmlDeclaration << "</td>\n";
         *file << "        <td>";
-        writeHtmlVersionTag(file, i.second.info);
+        writeHtmlVersionTag(file, i.second.info, true);
         *file << "        </td>\n";
         *file << "      </tr>\n";
     }