Expose IS_RESTRICTED field through queryEntities() views.

Part of fixing http://b/2223256
diff --git a/src/com/android/providers/contacts/ContactsDatabaseHelper.java b/src/com/android/providers/contacts/ContactsDatabaseHelper.java
index 6b22e20..efef61b 100644
--- a/src/com/android/providers/contacts/ContactsDatabaseHelper.java
+++ b/src/com/android/providers/contacts/ContactsDatabaseHelper.java
@@ -61,7 +61,7 @@
 /* package */ class ContactsDatabaseHelper extends SQLiteOpenHelper {
     private static final String TAG = "ContactsDatabaseHelper";
 
-    private static final int DATABASE_VERSION = 103;
+    private static final int DATABASE_VERSION = 104;
 
     private static final String DATABASE_NAME = "contacts2.db";
     private static final String DATABASE_PRESENCE = "presence_db";
@@ -290,6 +290,8 @@
                 Tables.RAW_CONTACTS + "." + RawContacts.SYNC4;
         public static final String CONCRETE_STARRED =
                 Tables.RAW_CONTACTS + "." + RawContacts.STARRED;
+        public static final String CONCRETE_IS_RESTRICTED =
+                Tables.RAW_CONTACTS + "." + RawContacts.IS_RESTRICTED;
 
         public static final String DISPLAY_NAME = "display_name";
         public static final String DISPLAY_NAME_SOURCE = "display_name_source";
@@ -1250,6 +1252,8 @@
                 + Data.DATA_VERSION + ", "
                 + DataColumns.CONCRETE_ID + " AS " + RawContacts.Entity.DATA_ID + ","
                 + RawContactsColumns.CONCRETE_STARRED + " AS " + RawContacts.STARRED + ","
+                + RawContactsColumns.CONCRETE_IS_RESTRICTED + " AS "
+                        + RawContacts.IS_RESTRICTED + ","
                 + Tables.GROUPS + "." + Groups.SOURCE_ID + " AS " + GroupMembership.GROUP_SOURCE_ID
                 + " FROM " + Tables.RAW_CONTACTS
                 + " LEFT OUTER JOIN " + Tables.DATA + " ON ("
@@ -1327,6 +1331,11 @@
             oldVersion++;
         }
 
+        if (oldVersion == 103) {
+            createContactEntitiesView(db);
+            oldVersion++;
+        }
+
         if (oldVersion != newVersion) {
             throw new IllegalStateException(
                     "error upgrading the database to version " + newVersion);
diff --git a/src/com/android/providers/contacts/ContactsProvider2.java b/src/com/android/providers/contacts/ContactsProvider2.java
index 03d6293..69ac2f2 100644
--- a/src/com/android/providers/contacts/ContactsProvider2.java
+++ b/src/com/android/providers/contacts/ContactsProvider2.java
@@ -599,6 +599,7 @@
         columns.put(RawContacts.VERSION, RawContacts.VERSION);
         columns.put(RawContacts.DIRTY, RawContacts.DIRTY);
         columns.put(RawContacts.DELETED, RawContacts.DELETED);
+        columns.put(RawContacts.IS_RESTRICTED, RawContacts.IS_RESTRICTED);
         columns.put(RawContacts.SYNC1, RawContacts.SYNC1);
         columns.put(RawContacts.SYNC2, RawContacts.SYNC2);
         columns.put(RawContacts.SYNC3, RawContacts.SYNC3);
@@ -4423,7 +4424,8 @@
                 RawContacts.SYNC4,
                 RawContacts.DELETED,
                 RawContacts.CONTACT_ID,
-                RawContacts.STARRED};
+                RawContacts.STARRED,
+                RawContacts.IS_RESTRICTED};
 
         private static final int COLUMN_ACCOUNT_NAME = 0;
         private static final int COLUMN_ACCOUNT_TYPE = 1;
@@ -4446,6 +4448,7 @@
         private static final int COLUMN_DELETED = 36;
         private static final int COLUMN_CONTACT_ID = 37;
         private static final int COLUMN_STARRED = 38;
+        private static final int COLUMN_IS_RESTRICTED = 39;
 
         public RawContactsEntityIterator(ContactsProvider2 provider, Uri entityUri,
                 String contactsIdString,
@@ -4516,6 +4519,7 @@
             contactValues.put(RawContacts.DELETED, c.getLong(COLUMN_DELETED));
             contactValues.put(RawContacts.CONTACT_ID, c.getLong(COLUMN_CONTACT_ID));
             contactValues.put(RawContacts.STARRED, c.getLong(COLUMN_STARRED));
+            contactValues.put(RawContacts.IS_RESTRICTED, c.getInt(COLUMN_IS_RESTRICTED));
             Entity contact = new Entity(contactValues);
 
             // read data rows until the contact id changes