Revert "REALLY remove string literal checks."

Bug: 215037384
Test: N/A

This reverts commit 140609759da2f0e5949878a99c8cf0045f0eb10a.

Change-Id: I009a34b9461b8fd58eb9f49185c70d995471bc14
diff --git a/aidl_const_expressions.cpp b/aidl_const_expressions.cpp
index 47fff32..244ec4b 100644
--- a/aidl_const_expressions.cpp
+++ b/aidl_const_expressions.cpp
@@ -242,6 +242,12 @@
   return false;
 }
 
+static bool isValidLiteralChar(char c) {
+  return !(c <= 0x1f ||  // control characters are < 0x20
+           c >= 0x7f ||  // DEL is 0x7f
+           c == '\\');   // Disallow backslashes for future proofing.
+}
+
 bool ParseFloating(std::string_view sv, double* parsed) {
   // float literal should be parsed successfully.
   android::base::ConsumeSuffix(&sv, "f");
@@ -471,6 +477,14 @@
 }
 
 AidlConstantValue* AidlConstantValue::String(const AidlLocation& location, const string& value) {
+  for (size_t i = 0; i < value.length(); ++i) {
+    if (!isValidLiteralChar(value[i])) {
+      AIDL_ERROR(location) << "Found invalid character at index " << i << " in string constant '"
+                           << value << "'";
+      return new AidlConstantValue(location, Type::ERROR, value);
+    }
+  }
+
   return new AidlConstantValue(location, Type::STRING, value);
 }