switch ToString/Signature for TypeSpecifier

ToString() works with "Dump()" and Signature() is for "comparing" except
AidlTypeSepcifier, which makes hard to read.

For example, AidlMethod::ToString() calls GetType().Signature() while
AidlMethod::Signature() calls GetType().ToString().

Now these two stringifying methods are consistent.

Bug: n/a
Test: aidl_unittests
Change-Id: I165530d8a82ef3a95a06a48d5cbaf2ad604ccaa2
diff --git a/aidl_unittest.cpp b/aidl_unittest.cpp
index d76d449..a073c6a 100644
--- a/aidl_unittest.cpp
+++ b/aidl_unittest.cpp
@@ -1494,6 +1494,31 @@
   EXPECT_EQ(expected_stderr, GetCapturedStderr());
 }
 
+TEST_F(AidlTest, ApiDumpConstWithAnnotation) {
+  io_delegate_.SetFileContents("foo/bar/IFoo.aidl",
+                               "package foo.bar;\n"
+                               "interface IFoo {\n"
+                               "    @utf8InCpp String foo();\n"
+                               "    const @utf8InCpp String bar = \"bar\";\n"
+                               "}\n");
+
+  vector<string> args = {"aidl", "--dumpapi", "-o dump", "foo/bar/IFoo.aidl"};
+  Options options = Options::From(args);
+  CaptureStderr();
+  EXPECT_TRUE(dump_api(options, io_delegate_));
+  EXPECT_EQ("", GetCapturedStderr());
+  string actual;
+  EXPECT_TRUE(io_delegate_.GetWrittenContents("dump/foo/bar/IFoo.aidl", &actual));
+  // TODO(b/174327111) dump const with annotations
+  EXPECT_EQ(string(kPreamble).append(R"(package foo.bar;
+interface IFoo {
+  @utf8InCpp String foo();
+  const String bar = "bar";
+}
+)"),
+            actual);
+}
+
 TEST_F(AidlTest, CheckNumGenericTypeSecifier) {
   const string expected_list_stderr =
       "ERROR: p/IFoo.aidl:1.37-41: List can only have one type parameter, but got: "