Handle unrecognized columns and avoid SQL injection

Bug:135269669
Test: atest com.android.providers.tv
Change-Id: I6445fb22501e8ee2aeb6901b32cb03e971c14211
(cherry picked from commit d817260cae81eee3ea18fe6b8f69c32ba070ea6e)
(cherry picked from commit 7b2b1fba39aeb61b67b29cdb8d4780afc817ac2e)
(cherry picked from commit 0f626d4c9a0ff287b091c9c6caf1333b9542e8f5)
diff --git a/src/com/android/providers/tv/TvProvider.java b/src/com/android/providers/tv/TvProvider.java
index 6968196..514db50 100644
--- a/src/com/android/providers/tv/TvProvider.java
+++ b/src/com/android/providers/tv/TvProvider.java
@@ -118,7 +118,6 @@
     private static final String OP_UPDATE = "update";
     private static final String OP_DELETE = "delete";
 
-
     private static final UriMatcher sUriMatcher;
     private static final int MATCH_CHANNEL = 1;
     private static final int MATCH_CHANNEL_ID = 2;
@@ -1604,9 +1603,15 @@
         }
         Map<String, String> columnProjectionMap = new HashMap<>();
         for (String columnName : projection) {
-            // Value NULL will be provided if the requested column does not exist in the database.
-            columnProjectionMap.put(columnName,
-                    projectionMap.getOrDefault(columnName, "NULL as " + columnName));
+            String value = projectionMap.get(columnName);
+            if (value != null) {
+                columnProjectionMap.put(columnName, value);
+            } else {
+                // Value NULL will be provided if the requested column does not exist in the
+                // database.
+                value = "NULL AS " + DatabaseUtils.sqlEscapeString(columnName);
+                columnProjectionMap.put(columnName, value);
+            }
         }
         return columnProjectionMap;
     }