Remove restricted white-listing

Bug:4974334
Change-Id: I4dd95089774373d2b67d7e14dc6b7fc40a92d094
diff --git a/res/values/unrestricted_packages.xml b/res/values/unrestricted_packages.xml
deleted file mode 100644
index 94011c8..0000000
--- a/res/values/unrestricted_packages.xml
+++ /dev/null
@@ -1,27 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!-- Copyright (C) 2009 The Android Open Source Project
-
-     Licensed under the Apache License, Version 2.0 (the "License");
-     you may not use this file except in compliance with the License.
-     You may obtain a copy of the License at
-
-          http://www.apache.org/licenses/LICENSE-2.0
-
-     Unless required by applicable law or agreed to in writing, software
-     distributed under the License is distributed on an "AS IS" BASIS,
-     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-     See the License for the specific language governing permissions and
-     limitations under the License.
--->
-
-<resources xmlns:android="http://schemas.android.com/apk/res/android"
-           xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
-
-    <!-- The list of packages that have access to data that is marked as being restricted -->
-    <string-array name="unrestricted_packages" translatable="false">
-
-        <item>com.android.contacts</item>
-
-    </string-array>
-
-</resources>
diff --git a/src/com/android/providers/contacts/ContactAggregator.java b/src/com/android/providers/contacts/ContactAggregator.java
index 2260cb6..c6d5493 100644
--- a/src/com/android/providers/contacts/ContactAggregator.java
+++ b/src/com/android/providers/contacts/ContactAggregator.java
@@ -1531,7 +1531,6 @@
                         + RawContacts.LAST_TIME_CONTACTED + ","
                         + RawContacts.TIMES_CONTACTED + ","
                         + RawContacts.STARRED + ","
-                        + RawContacts.IS_RESTRICTED + ","
                         + RawContacts.NAME_VERIFIED + ","
                         + DataColumns.CONCRETE_ID + ","
                         + DataColumns.CONCRETE_MIMETYPE_ID + ","
@@ -1562,11 +1561,10 @@
         int LAST_TIME_CONTACTED = 8;
         int TIMES_CONTACTED = 9;
         int STARRED = 10;
-        int IS_RESTRICTED = 11;
-        int NAME_VERIFIED = 12;
-        int DATA_ID = 13;
-        int MIMETYPE_ID = 14;
-        int IS_SUPER_PRIMARY = 15;
+        int NAME_VERIFIED = 11;
+        int DATA_ID = 12;
+        int MIMETYPE_ID = 13;
+        int IS_SUPER_PRIMARY = 14;
     }
 
     private interface ContactReplaceSqlStatement {
@@ -1581,7 +1579,6 @@
                         + Contacts.TIMES_CONTACTED + "=?, "
                         + Contacts.STARRED + "=?, "
                         + Contacts.HAS_PHONE_NUMBER + "=?, "
-                        + ContactsColumns.SINGLE_IS_RESTRICTED + "=?, "
                         + Contacts.LOOKUP_KEY + "=? " +
                 " WHERE " + Contacts._ID + "=?";
 
@@ -1595,9 +1592,8 @@
                         + Contacts.TIMES_CONTACTED + ", "
                         + Contacts.STARRED + ", "
                         + Contacts.HAS_PHONE_NUMBER + ", "
-                        + ContactsColumns.SINGLE_IS_RESTRICTED + ", "
                         + Contacts.LOOKUP_KEY + ") " +
-                " VALUES (?,?,?,?,?,?,?,?,?,?)";
+                " VALUES (?,?,?,?,?,?,?,?,?)";
 
         int NAME_RAW_CONTACT_ID = 1;
         int PHOTO_ID = 2;
@@ -1607,9 +1603,8 @@
         int TIMES_CONTACTED = 6;
         int STARRED = 7;
         int HAS_PHONE_NUMBER = 8;
-        int SINGLE_IS_RESTRICTED = 9;
-        int LOOKUP_KEY = 10;
-        int CONTACT_ID = 11;
+        int LOOKUP_KEY = 9;
+        int CONTACT_ID = 10;
     }
 
     /**
@@ -1636,7 +1631,6 @@
         long contactLastTimeContacted = 0;
         int contactTimesContacted = 0;
         int contactStarred = 0;
-        int singleIsRestricted = 1;
         int hasPhoneNumber = 0;
 
         mDisplayNameCandidate.clear();
@@ -1687,19 +1681,6 @@
                         contactStarred = 1;
                     }
 
-                    // Single restricted
-                    if (totalRowCount > 1) {
-                        // Not single
-                        singleIsRestricted = 0;
-                    } else {
-                        int isRestricted = c.getInt(RawContactsQuery.IS_RESTRICTED);
-
-                        if (isRestricted == 0) {
-                            // Not restricted
-                            singleIsRestricted = 0;
-                        }
-                    }
-
                     ContactLookupKey.appendToLookupKey(mSb,
                             c.getString(RawContactsQuery.ACCOUNT_TYPE),
                             c.getString(RawContactsQuery.ACCOUNT_NAME),
@@ -1752,8 +1733,6 @@
                 contactStarred);
         statement.bindLong(ContactReplaceSqlStatement.HAS_PHONE_NUMBER,
                 hasPhoneNumber);
-        statement.bindLong(ContactReplaceSqlStatement.SINGLE_IS_RESTRICTED,
-                singleIsRestricted);
         statement.bindString(ContactReplaceSqlStatement.LOOKUP_KEY,
                 Uri.encode(mSb.toString()));
     }
diff --git a/src/com/android/providers/contacts/ContactsDatabaseHelper.java b/src/com/android/providers/contacts/ContactsDatabaseHelper.java
index a8d4752..0ce588b 100644
--- a/src/com/android/providers/contacts/ContactsDatabaseHelper.java
+++ b/src/com/android/providers/contacts/ContactsDatabaseHelper.java
@@ -64,8 +64,8 @@
 import android.provider.ContactsContract.RawContacts;
 import android.provider.ContactsContract.Settings;
 import android.provider.ContactsContract.StatusUpdates;
-import android.provider.ContactsContract.StreamItems;
 import android.provider.ContactsContract.StreamItemPhotos;
+import android.provider.ContactsContract.StreamItems;
 import android.provider.SocialContract.Activities;
 import android.provider.VoicemailContract;
 import android.provider.VoicemailContract.Voicemails;
@@ -100,7 +100,7 @@
      *   600-699 Ice Cream Sandwich
      * </pre>
      */
-    static final int DATABASE_VERSION = 605;
+    static final int DATABASE_VERSION = 606;
 
     private static final String DATABASE_NAME = "contacts2.db";
     private static final String DATABASE_PRESENCE = "presence_db";
@@ -201,26 +201,13 @@
     }
 
     public interface Views {
-        public static final String DATA_ALL = "view_data";
-        public static final String DATA_RESTRICTED = "view_data_restricted";
-
-        public static final String RAW_CONTACTS_ALL = "view_raw_contacts";
-        public static final String RAW_CONTACTS_RESTRICTED = "view_raw_contacts_restricted";
-
-        public static final String CONTACTS_ALL = "view_contacts";
-        public static final String CONTACTS_RESTRICTED = "view_contacts_restricted";
-
+        public static final String DATA = "view_data";
+        public static final String RAW_CONTACTS = "view_raw_contacts";
+        public static final String CONTACTS = "view_contacts";
         public static final String ENTITIES = "view_entities";
-        public static final String ENTITIES_RESTRICTED = "view_entities_restricted";
-
         public static final String RAW_ENTITIES = "view_raw_entities";
-        public static final String RAW_ENTITIES_RESTRICTED = "view_raw_entities_restricted";
-
-        public static final String GROUPS_ALL = "view_groups";
-
-        public static final String DATA_USAGE_STAT_ALL = "view_data_usage_stat";
-        public static final String DATA_USAGE_STAT_RESTRICTED =
-                "view_data_usage_stat_restricted";
+        public static final String GROUPS = "view_groups";
+        public static final String DATA_USAGE_STAT = "view_data_usage_stat";
     }
 
     public interface Clauses {
@@ -269,12 +256,6 @@
     }
 
     public interface ContactsColumns {
-        /**
-         * This flag is set for a contact if it has only one constituent raw contact and
-         * it is restricted.
-         */
-        public static final String SINGLE_IS_RESTRICTED = "single_is_restricted";
-
         public static final String LAST_STATUS_UPDATE_ID = "status_update_id";
 
         public static final String CONCRETE_ID = Tables.CONTACTS + "." + BaseColumns._ID;
@@ -325,8 +306,6 @@
                 Tables.RAW_CONTACTS + "." + RawContacts.TIMES_CONTACTED;
         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 = RawContacts.DISPLAY_NAME_PRIMARY;
         public static final String DISPLAY_NAME_SOURCE = RawContacts.DISPLAY_NAME_SOURCE;
@@ -638,11 +617,6 @@
 
     private boolean mUseStrictPhoneNumberComparison;
 
-    /**
-     * List of package names with access to {@link RawContacts#IS_RESTRICTED} data.
-     */
-    private String[] mUnrestrictedPackages;
-
     private String[] mSelectionArgs1 = new String[1];
     private NameSplitter.Name mName = new NameSplitter.Name();
     private CharArrayBuffer mCharArrayBuffer = new CharArrayBuffer(128);
@@ -675,13 +649,6 @@
         mUseStrictPhoneNumberComparison =
                 resources.getBoolean(
                         com.android.internal.R.bool.config_use_strict_phone_number_comparation);
-        int resourceId = resources.getIdentifier("unrestricted_packages", "array",
-                context.getPackageName());
-        if (resourceId != 0) {
-            mUnrestrictedPackages = resources.getStringArray(resourceId);
-        } else {
-            mUnrestrictedPackages = new String[0];
-        }
     }
 
     private void refreshDatabaseCaches(SQLiteDatabase db) {
@@ -837,18 +804,13 @@
                 Contacts.STARRED + " INTEGER NOT NULL DEFAULT 0," +
                 Contacts.HAS_PHONE_NUMBER + " INTEGER NOT NULL DEFAULT 0," +
                 Contacts.LOOKUP_KEY + " TEXT," +
-                ContactsColumns.LAST_STATUS_UPDATE_ID + " INTEGER REFERENCES data(_id)," +
-                ContactsColumns.SINGLE_IS_RESTRICTED + " INTEGER NOT NULL DEFAULT 0" +
+                ContactsColumns.LAST_STATUS_UPDATE_ID + " INTEGER REFERENCES data(_id)" +
         ");");
 
         db.execSQL("CREATE INDEX contacts_has_phone_index ON " + Tables.CONTACTS + " (" +
                 Contacts.HAS_PHONE_NUMBER +
         ");");
 
-        db.execSQL("CREATE INDEX contacts_restricted_index ON " + Tables.CONTACTS + " (" +
-                ContactsColumns.SINGLE_IS_RESTRICTED +
-        ");");
-
         db.execSQL("CREATE INDEX contacts_name_raw_contact_id_index ON " + Tables.CONTACTS + " (" +
                 Contacts.NAME_RAW_CONTACT_ID +
         ");");
@@ -856,7 +818,6 @@
         // Contacts table
         db.execSQL("CREATE TABLE " + Tables.RAW_CONTACTS + " (" +
                 RawContacts._ID + " INTEGER PRIMARY KEY AUTOINCREMENT," +
-                RawContacts.IS_RESTRICTED + " INTEGER DEFAULT 0," +
                 RawContacts.ACCOUNT_NAME + " STRING DEFAULT NULL, " +
                 RawContacts.ACCOUNT_TYPE + " STRING DEFAULT NULL, " +
                 RawContacts.SOURCE_ID + " TEXT," +
@@ -1381,18 +1342,12 @@
     }
 
     private static void createContactsViews(SQLiteDatabase db) {
-        db.execSQL("DROP VIEW IF EXISTS " + Views.CONTACTS_ALL + ";");
-        db.execSQL("DROP VIEW IF EXISTS " + Views.CONTACTS_RESTRICTED + ";");
-        db.execSQL("DROP VIEW IF EXISTS " + Views.DATA_ALL + ";");
-        db.execSQL("DROP VIEW IF EXISTS " + Views.DATA_RESTRICTED + ";");
-        db.execSQL("DROP VIEW IF EXISTS " + Views.RAW_CONTACTS_ALL + ";");
-        db.execSQL("DROP VIEW IF EXISTS " + Views.RAW_CONTACTS_RESTRICTED + ";");
+        db.execSQL("DROP VIEW IF EXISTS " + Views.CONTACTS + ";");
+        db.execSQL("DROP VIEW IF EXISTS " + Views.DATA + ";");
+        db.execSQL("DROP VIEW IF EXISTS " + Views.RAW_CONTACTS + ";");
         db.execSQL("DROP VIEW IF EXISTS " + Views.RAW_ENTITIES + ";");
-        db.execSQL("DROP VIEW IF EXISTS " + Views.RAW_ENTITIES_RESTRICTED + ";");
         db.execSQL("DROP VIEW IF EXISTS " + Views.ENTITIES + ";");
-        db.execSQL("DROP VIEW IF EXISTS " + Views.ENTITIES_RESTRICTED + ";");
-        db.execSQL("DROP VIEW IF EXISTS " + Views.DATA_USAGE_STAT_ALL + ";");
-        db.execSQL("DROP VIEW IF EXISTS " + Views.DATA_USAGE_STAT_RESTRICTED + ";");
+        db.execSQL("DROP VIEW IF EXISTS " + Views.DATA_USAGE_STAT + ";");
 
         String dataColumns =
                 Data.IS_PRIMARY + ", "
@@ -1503,9 +1458,7 @@
                 +   "' AND " + GroupsColumns.CONCRETE_ID + "="
                         + Tables.DATA + "." + GroupMembership.GROUP_ROW_ID + ")";
 
-        db.execSQL("CREATE VIEW " + Views.DATA_ALL + " AS " + dataSelect);
-        db.execSQL("CREATE VIEW " + Views.DATA_RESTRICTED + " AS " + dataSelect + " WHERE "
-                + RawContactsColumns.CONCRETE_IS_RESTRICTED + "=0");
+        db.execSQL("CREATE VIEW " + Views.DATA + " AS " + dataSelect);
 
         String rawContactOptionColumns =
                 RawContacts.CUSTOM_RINGTONE + ","
@@ -1535,9 +1488,7 @@
                 + syncColumns
                 + " FROM " + Tables.RAW_CONTACTS;
 
-        db.execSQL("CREATE VIEW " + Views.RAW_CONTACTS_ALL + " AS " + rawContactsSelect);
-        db.execSQL("CREATE VIEW " + Views.RAW_CONTACTS_RESTRICTED + " AS " + rawContactsSelect
-                + " WHERE " + RawContacts.IS_RESTRICTED + "=0");
+        db.execSQL("CREATE VIEW " + Views.RAW_CONTACTS + " AS " + rawContactsSelect);
 
         String contactsColumns =
                 ContactsColumns.CONCRETE_CUSTOM_RINGTONE
@@ -1569,9 +1520,7 @@
                 + " JOIN " + Tables.RAW_CONTACTS + " AS name_raw_contact ON("
                 +   Contacts.NAME_RAW_CONTACT_ID + "=name_raw_contact." + RawContacts._ID + ")";
 
-        db.execSQL("CREATE VIEW " + Views.CONTACTS_ALL + " AS " + contactsSelect);
-        db.execSQL("CREATE VIEW " + Views.CONTACTS_RESTRICTED + " AS " + contactsSelect
-                + " WHERE " + ContactsColumns.SINGLE_IS_RESTRICTED + "=0");
+        db.execSQL("CREATE VIEW " + Views.CONTACTS + " AS " + contactsSelect);
 
         String rawEntitiesSelect = "SELECT "
                 + RawContacts.CONTACT_ID + ", "
@@ -1585,8 +1534,6 @@
                 + RawContactsColumns.CONCRETE_ID + " AS " + RawContacts._ID + ", "
                 + DataColumns.CONCRETE_ID + " AS " + RawContacts.Entity.DATA_ID + ","
                 + RawContactsColumns.CONCRETE_STARRED + " AS " + RawContacts.STARRED + ","
-                + RawContactsColumns.CONCRETE_IS_RESTRICTED + " AS "
-                        + RawContacts.IS_RESTRICTED + ","
                 + "EXISTS (SELECT 1 FROM " + Tables.ACCOUNTS +
                     " WHERE " + RawContactsColumns.CONCRETE_ID +
                     "=" + AccountsColumns.PROFILE_RAW_CONTACT_ID + ") AS " +
@@ -1606,15 +1553,11 @@
 
         db.execSQL("CREATE VIEW " + Views.RAW_ENTITIES + " AS "
                 + rawEntitiesSelect);
-        db.execSQL("CREATE VIEW " + Views.RAW_ENTITIES_RESTRICTED + " AS "
-                + rawEntitiesSelect + " WHERE " + RawContacts.IS_RESTRICTED + "=0");
 
         String entitiesSelect = "SELECT "
                 + RawContactsColumns.CONCRETE_CONTACT_ID + " AS " + Contacts._ID + ", "
                 + RawContactsColumns.CONCRETE_CONTACT_ID + " AS " + RawContacts.CONTACT_ID + ", "
                 + RawContactsColumns.CONCRETE_DELETED + " AS " + RawContacts.DELETED + ","
-                + RawContactsColumns.CONCRETE_IS_RESTRICTED
-                        + " AS " + RawContacts.IS_RESTRICTED + ","
                 + dataColumns + ", "
                 + syncColumns + ", "
                 + contactsColumns + ", "
@@ -1653,8 +1596,6 @@
 
         db.execSQL("CREATE VIEW " + Views.ENTITIES + " AS "
                 + entitiesSelect);
-        db.execSQL("CREATE VIEW " + Views.ENTITIES_RESTRICTED + " AS "
-                + entitiesSelect + " WHERE " + RawContactsColumns.CONCRETE_IS_RESTRICTED + "=0");
 
         String dataUsageStatSelect = "SELECT "
                 + DataUsageStatColumns.CONCRETE_ID + " AS " + DataUsageStatColumns._ID + ", "
@@ -1673,10 +1614,7 @@
                 + " JOIN " + Tables.MIMETYPES + " ON ("
                 +   MimetypesColumns.CONCRETE_ID + "=" + DataColumns.CONCRETE_MIMETYPE_ID + ")";
 
-        db.execSQL("CREATE VIEW " + Views.DATA_USAGE_STAT_ALL + " AS " + dataUsageStatSelect);
-        db.execSQL("CREATE VIEW " + Views.DATA_USAGE_STAT_RESTRICTED + " AS "
-                + dataUsageStatSelect + " WHERE "
-                + RawContactsColumns.CONCRETE_IS_RESTRICTED + "=0");
+        db.execSQL("CREATE VIEW " + Views.DATA_USAGE_STAT + " AS " + dataUsageStatSelect);
     }
 
     private static String buildPhotoUriAlias(String contactIdColumn, String alias) {
@@ -1690,7 +1628,7 @@
     }
 
     private static void createGroupsView(SQLiteDatabase db) {
-        db.execSQL("DROP VIEW IF EXISTS " + Views.GROUPS_ALL + ";");
+        db.execSQL("DROP VIEW IF EXISTS " + Views.GROUPS + ";");
         String groupsColumns =
                 Groups.ACCOUNT_NAME + ","
                 + Groups.ACCOUNT_TYPE + ","
@@ -1718,7 +1656,7 @@
                 + groupsColumns
                 + " FROM " + Tables.GROUPS_JOIN_PACKAGES;
 
-        db.execSQL("CREATE VIEW " + Views.GROUPS_ALL + " AS " + groupsSelect);
+        db.execSQL("CREATE VIEW " + Views.GROUPS + " AS " + groupsSelect);
     }
 
     @Override
@@ -2043,6 +1981,13 @@
             oldVersion = 605;
         }
 
+        if (oldVersion < 606) {
+            upgradeViewsAndTriggers = true;
+            upgradeLegacyApiSupport = true;
+            upgradeToVersion606(db);
+            oldVersion = 606;
+        }
+
         if (upgradeViewsAndTriggers) {
             createContactsViews(db);
             createGroupsView(db);
@@ -3153,6 +3098,19 @@
                 "FOREIGN KEY(stream_item_id) REFERENCES stream_items(_id));");
     }
 
+    private void upgradeToVersion606(SQLiteDatabase db) {
+        db.execSQL("DROP VIEW IF EXISTS view_contacts_restricted;");
+        db.execSQL("DROP VIEW IF EXISTS view_data_restricted;");
+        db.execSQL("DROP VIEW IF EXISTS view_raw_contacts_restricted;");
+        db.execSQL("DROP VIEW IF EXISTS view_raw_entities_restricted;");
+        db.execSQL("DROP VIEW IF EXISTS view_entities_restricted;");
+        db.execSQL("DROP VIEW IF EXISTS view_data_usage_stat_restricted;");
+        db.execSQL("DROP INDEX IF EXISTS contacts_restricted_index");
+
+        // We should remove the restricted columns here as well, but unfortunately SQLite doesn't
+        // provide ALTER TABLE DROP COLUMN. As they have DEFAULT 0, we can keep but ignore them
+    }
+
     public String extractHandleFromEmailAddress(String email) {
         Rfc822Token[] tokens = Rfc822Tokenizer.tokenize(email);
         if (tokens.length == 0) {
@@ -3213,8 +3171,6 @@
         // Specific stats strings are based on an actual large database after running ANALYZE
         try {
             updateIndexStats(db, Tables.CONTACTS,
-                    "contacts_restricted_index", "10000 9000");
-            updateIndexStats(db, Tables.CONTACTS,
                     "contacts_has_phone_index", "10000 500");
 
             updateIndexStats(db, Tables.RAW_CONTACTS,
@@ -3661,7 +3617,7 @@
             boolean joinContacts) {
         sb.append(Tables.RAW_CONTACTS);
         if (joinContacts) {
-            sb.append(" JOIN " + getContactView() + " contacts_view"
+            sb.append(" JOIN " + Views.CONTACTS + " contacts_view"
                     + " ON (contacts_view._id = raw_contacts.contact_id)");
         }
         sb.append(", (SELECT data_id, normalized_number, length(normalized_number) as len "
@@ -3829,98 +3785,6 @@
     }
 
     /**
-     * Check if {@link Binder#getCallingUid()} should be allowed access to
-     * {@link RawContacts#IS_RESTRICTED} data.
-     */
-    boolean hasAccessToRestrictedData() {
-        final PackageManager pm = mContext.getPackageManager();
-        int caller = Binder.getCallingUid();
-        if (caller == 0) return true; // root can do anything
-        final String[] callerPackages = pm.getPackagesForUid(caller);
-
-        // Has restricted access if caller matches any packages
-        for (String callerPackage : callerPackages) {
-            if (hasAccessToRestrictedData(callerPackage)) {
-                return true;
-            }
-        }
-        return false;
-    }
-
-    /**
-     * Check if requestingPackage should be allowed access to
-     * {@link RawContacts#IS_RESTRICTED} data.
-     */
-    boolean hasAccessToRestrictedData(String requestingPackage) {
-        if (mUnrestrictedPackages != null) {
-            for (String allowedPackage : mUnrestrictedPackages) {
-                if (allowedPackage.equals(requestingPackage)) {
-                    return true;
-                }
-            }
-        }
-        return false;
-    }
-
-    public String getDataView() {
-        return getDataView(false);
-    }
-
-    public String getDataView(boolean requireRestrictedView) {
-        return (hasAccessToRestrictedData() && !requireRestrictedView) ?
-                Views.DATA_ALL : Views.DATA_RESTRICTED;
-    }
-
-    public String getRawContactView() {
-        return getRawContactView(false);
-    }
-
-    public String getRawContactView(boolean requireRestrictedView) {
-        return (hasAccessToRestrictedData() && !requireRestrictedView) ?
-                Views.RAW_CONTACTS_ALL : Views.RAW_CONTACTS_RESTRICTED;
-    }
-
-    public String getContactView() {
-        return getContactView(false);
-    }
-
-    public String getContactView(boolean requireRestrictedView) {
-        return (hasAccessToRestrictedData() && !requireRestrictedView) ?
-                Views.CONTACTS_ALL : Views.CONTACTS_RESTRICTED;
-    }
-
-    public String getGroupView() {
-        return Views.GROUPS_ALL;
-    }
-
-    public String getRawEntitiesView() {
-        return getRawEntitiesView(false);
-    }
-
-    public String getRawEntitiesView(boolean requireRestrictedView) {
-        return (hasAccessToRestrictedData() && !requireRestrictedView) ?
-                Views.RAW_ENTITIES : Views.RAW_ENTITIES_RESTRICTED;
-    }
-
-    public String getEntitiesView() {
-        return getEntitiesView(false);
-    }
-
-    public String getEntitiesView(boolean requireRestrictedView) {
-        return (hasAccessToRestrictedData() && !requireRestrictedView) ?
-                Views.ENTITIES : Views.ENTITIES_RESTRICTED;
-    }
-
-    public String getDataUsageStatView() {
-        return getDataUsageStatView(false);
-    }
-
-    public String getDataUsageStatView(boolean requireRestrictedView) {
-        return (hasAccessToRestrictedData() && !requireRestrictedView) ?
-                Views.DATA_USAGE_STAT_ALL : Views.DATA_USAGE_STAT_RESTRICTED;
-    }
-
-    /**
      * Test if any of the columns appear in the given projection.
      */
     public boolean isInProjection(String[] projection, String... columns) {
diff --git a/src/com/android/providers/contacts/ContactsProvider2.java b/src/com/android/providers/contacts/ContactsProvider2.java
index 6a409b4..3fe5f79 100644
--- a/src/com/android/providers/contacts/ContactsProvider2.java
+++ b/src/com/android/providers/contacts/ContactsProvider2.java
@@ -42,6 +42,7 @@
 import com.android.providers.contacts.ContactsDatabaseHelper.StreamItemsColumns;
 import com.android.providers.contacts.ContactsDatabaseHelper.StreamItemPhotosColumns;
 import com.android.providers.contacts.ContactsDatabaseHelper.Tables;
+import com.android.providers.contacts.ContactsDatabaseHelper.Views;
 import com.android.providers.contacts.util.DbQueryUtils;
 import com.android.vcard.VCardComposer;
 import com.android.vcard.VCardConfig;
@@ -669,7 +670,6 @@
             .add(RawContacts._ID)
             .add(RawContacts.CONTACT_ID)
             .add(RawContacts.Entity.DATA_ID)
-            .add(RawContacts.IS_RESTRICTED)
             .add(RawContacts.DELETED)
             .add(RawContacts.STARRED)
             .add(RawContacts.RAW_CONTACT_IS_USER_PROFILE)
@@ -686,7 +686,6 @@
             .add(Contacts.Entity.DATA_ID)
             .add(Contacts.Entity.NAME_RAW_CONTACT_ID)
             .add(Contacts.Entity.DELETED)
-            .add(Contacts.Entity.IS_RESTRICTED)
             .add(Contacts.IS_USER_PROFILE)
             .addAll(sContactsColumns)
             .addAll(sContactPresenceColumns)
@@ -2628,7 +2627,6 @@
                 mSelectionArgs.add(values.getAsString(StatusUpdates.DATA_ID));
             }
         }
-        mSb.append(" AND ").append(getContactsRestrictions());
 
         Cursor cursor = null;
         try {
@@ -3383,7 +3381,7 @@
         }
 
         int count = 0;
-        Cursor cursor = mDb.query(mDbHelper.getRawContactView(),
+        Cursor cursor = mDb.query(Views.RAW_CONTACTS,
                 new String[] { RawContacts._ID }, selection,
                 selectionArgs, null, null, null);
         try {
@@ -3541,7 +3539,7 @@
     private int updateContactOptions(ContentValues values, String selection,
             String[] selectionArgs, boolean callerIsSyncAdapter) {
         int count = 0;
-        Cursor cursor = mDb.query(mDbHelper.getContactView(),
+        Cursor cursor = mDb.query(Views.CONTACTS,
                 new String[] { Contacts._ID, Contacts.IS_USER_PROFILE }, selection,
                 selectionArgs, null, null, null);
         try {
@@ -3597,7 +3595,7 @@
                 + " AND " + RawContacts.RAW_CONTACT_IS_READ_ONLY + "=0", mSelectionArgs1);
 
         if (mValues.containsKey(RawContacts.STARRED) && !callerIsSyncAdapter) {
-            Cursor cursor = mDb.query(mDbHelper.getRawContactView(),
+            Cursor cursor = mDb.query(Views.RAW_CONTACTS,
                     new String[] { RawContacts._ID }, RawContacts.CONTACT_ID + "=?",
                     mSelectionArgs1, null, null, null);
             try {
@@ -4011,8 +4009,6 @@
         String groupBy = null;
         String limit = getLimit(uri);
 
-        // TODO: Consider writing a test case for RestrictionExceptions when you
-        // write a new query() block to make sure it protects restricted data.
         final int match = sUriMatcher.match(uri);
         switch (match) {
             case SYNCSTATE:
@@ -4141,11 +4137,10 @@
             }
 
             case CONTACTS_AS_VCARD: {
-                // When reading as vCard always use restricted view
                 final String lookupKey = Uri.encode(uri.getPathSegments().get(2));
                 long contactId = lookupContactIdByLookupKey(db, lookupKey);
                 enforceProfilePermissionForContact(contactId, false);
-                qb.setTables(mDbHelper.getContactView(true /* require restricted */));
+                qb.setTables(Views.CONTACTS);
                 qb.setProjectionMap(sContactsVCardProjectionMap);
                 selectionArgs = insertSelectionArg(selectionArgs,
                         String.valueOf(contactId));
@@ -4292,8 +4287,7 @@
 
             case PROFILE_AS_VCARD: {
                 enforceProfilePermission(false);
-                // When reading as vCard always use restricted view
-                qb.setTables(mDbHelper.getContactView(true /* require restricted */));
+                qb.setTables(Views.CONTACTS);
                 qb.setProjectionMap(sContactsVCardProjectionMap);
                 qb.appendWhere(Contacts.IS_USER_PROFILE + "=1");
                 break;
@@ -4689,14 +4683,14 @@
             }
 
             case GROUPS: {
-                qb.setTables(mDbHelper.getGroupView());
+                qb.setTables(Views.GROUPS);
                 qb.setProjectionMap(sGroupsProjectionMap);
                 appendAccountFromParameter(qb, uri);
                 break;
             }
 
             case GROUPS_ID: {
-                qb.setTables(mDbHelper.getGroupView());
+                qb.setTables(Views.GROUPS);
                 qb.setProjectionMap(sGroupsProjectionMap);
                 selectionArgs = insertSelectionArg(selectionArgs, uri.getLastPathSegment());
                 qb.appendWhere(Groups._ID + "=?");
@@ -4704,7 +4698,7 @@
             }
 
             case GROUPS_SUMMARY: {
-                qb.setTables(mDbHelper.getGroupView() + " AS groups");
+                qb.setTables(Views.GROUPS + " AS groups");
                 qb.setProjectionMap(sGroupsSummaryProjectionMap);
                 appendAccountFromParameter(qb, uri);
                 groupBy = Groups._ID;
@@ -4799,24 +4793,24 @@
             }
 
             case LIVE_FOLDERS_CONTACTS:
-                qb.setTables(mDbHelper.getContactView());
+                qb.setTables(Views.CONTACTS);
                 qb.setProjectionMap(sLiveFoldersProjectionMap);
                 break;
 
             case LIVE_FOLDERS_CONTACTS_WITH_PHONES:
-                qb.setTables(mDbHelper.getContactView());
+                qb.setTables(Views.CONTACTS);
                 qb.setProjectionMap(sLiveFoldersProjectionMap);
                 qb.appendWhere(Contacts.HAS_PHONE_NUMBER + "=1");
                 break;
 
             case LIVE_FOLDERS_CONTACTS_FAVORITES:
-                qb.setTables(mDbHelper.getContactView());
+                qb.setTables(Views.CONTACTS);
                 qb.setProjectionMap(sLiveFoldersProjectionMap);
                 qb.appendWhere(Contacts.STARRED + "=1");
                 break;
 
             case LIVE_FOLDERS_CONTACTS_GROUP_NAME:
-                qb.setTables(mDbHelper.getContactView());
+                qb.setTables(Views.CONTACTS);
                 qb.setProjectionMap(sLiveFoldersProjectionMap);
                 qb.appendWhere(CONTACTS_IN_GROUP_SELECT);
                 selectionArgs = insertSelectionArg(selectionArgs, uri.getLastPathSegment());
@@ -5002,7 +4996,7 @@
         HashMap<String, String> projectionMap = Maps.newHashMap();
 
         // The user profile column varies depending on the view.
-        String profileColumn = qb.getTables().contains(mDbHelper.getContactView())
+        String profileColumn = qb.getTables().contains(Views.CONTACTS)
                 ? Contacts.IS_USER_PROFILE
                 : RawContacts.RAW_CONTACT_IS_USER_PROFILE;
         String sectionHeading = String.format(
@@ -5338,8 +5332,7 @@
     private void setTablesAndProjectionMapForContacts(SQLiteQueryBuilder qb, Uri uri,
             String[] projection, boolean forStrequentFrequent, boolean strequentPhoneCallOnly) {
         StringBuilder sb = new StringBuilder();
-        String viewName = mDbHelper.getContactView(shouldExcludeRestrictedData(uri));
-        sb.append(viewName);
+        sb.append(Views.CONTACTS);
 
         // Just for frequently contacted contacts in Strequent Uri handling.
         if (forStrequentFrequent) {
@@ -5352,11 +5345,11 @@
             // Use INNER JOIN for maximum performance, ommiting unnecessary rows as much as
             // possible.
             sb.append(" INNER JOIN " +
-                    mDbHelper.getDataUsageStatView() + " AS " + Tables.DATA_USAGE_STAT +
+                    Views.DATA_USAGE_STAT + " AS " + Tables.DATA_USAGE_STAT +
                     " ON (" +
                     DbQueryUtils.concatenateClauses(
                             DataUsageStatColumns.CONCRETE_TIMES_USED + " > 0",
-                            RawContacts.CONTACT_ID + "=" + viewName + "." + Contacts._ID,
+                            RawContacts.CONTACT_ID + "=" + Views.CONTACTS + "." + Contacts._ID,
                             strequentPhoneCallOnlyClause) +
                     ")");
         }
@@ -5375,7 +5368,7 @@
             String[] projection, String filter, long directoryId) {
 
         StringBuilder sb = new StringBuilder();
-        sb.append(mDbHelper.getContactView(shouldExcludeRestrictedData(uri)));
+        sb.append(Views.CONTACTS);
 
         if (filter != null) {
             filter = filter.trim();
@@ -5560,14 +5553,14 @@
 
     private void setTablesAndProjectionMapForRawContacts(SQLiteQueryBuilder qb, Uri uri) {
         StringBuilder sb = new StringBuilder();
-        sb.append(mDbHelper.getRawContactView(shouldExcludeRestrictedData(uri)));
+        sb.append(Views.RAW_CONTACTS);
         qb.setTables(sb.toString());
         qb.setProjectionMap(sRawContactsProjectionMap);
         appendAccountFromParameter(qb, uri);
     }
 
     private void setTablesAndProjectionMapForRawEntities(SQLiteQueryBuilder qb, Uri uri) {
-        qb.setTables(mDbHelper.getRawEntitiesView(shouldExcludeRestrictedData(uri)));
+        qb.setTables(Views.RAW_ENTITIES);
         qb.setProjectionMap(sRawEntityProjectionMap);
         appendAccountFromParameter(qb, uri);
     }
@@ -5584,7 +5577,7 @@
     private void setTablesAndProjectionMapForData(SQLiteQueryBuilder qb, Uri uri,
             String[] projection, boolean distinct, Integer usageType) {
         StringBuilder sb = new StringBuilder();
-        sb.append(mDbHelper.getDataView(shouldExcludeRestrictedData(uri)));
+        sb.append(Views.DATA);
         sb.append(" data");
 
         appendContactPresenceJoin(sb, projection, RawContacts.CONTACT_ID);
@@ -5608,7 +5601,7 @@
     private void setTableAndProjectionMapForStatusUpdates(SQLiteQueryBuilder qb,
             String[] projection) {
         StringBuilder sb = new StringBuilder();
-        sb.append(mDbHelper.getDataView());
+        sb.append(Views.DATA);
         sb.append(" data");
         appendDataPresenceJoin(sb, projection, DataColumns.CONCRETE_ID);
         appendDataStatusUpdateJoin(sb, projection, DataColumns.CONCRETE_ID);
@@ -5641,7 +5634,7 @@
     private void setTablesAndProjectionMapForEntities(SQLiteQueryBuilder qb, Uri uri,
             String[] projection) {
         StringBuilder sb = new StringBuilder();
-        sb.append(mDbHelper.getEntitiesView(shouldExcludeRestrictedData(uri)));
+        sb.append(Views.ENTITIES);
         sb.append(" data");
 
         appendContactPresenceJoin(sb, projection, Contacts.Entity.CONTACT_ID);
@@ -5750,23 +5743,6 @@
         return profileRequested;
     }
 
-    private boolean shouldExcludeRestrictedData(Uri uri) {
-        // Note: currently, "export only" equals to "restricted", but may not in the future.
-        boolean excludeRestrictedData = readBooleanQueryParameter(uri,
-                Data.FOR_EXPORT_ONLY, false);
-        if (excludeRestrictedData) {
-            return true;
-        }
-
-        String requestingPackage = getQueryParameter(uri,
-                ContactsContract.REQUESTING_PACKAGE_PARAM_KEY);
-        if (requestingPackage != null) {
-            return !mDbHelper.hasAccessToRestrictedData(requestingPackage);
-        }
-
-        return false;
-    }
-
     private void appendAccountFromParameter(SQLiteQueryBuilder qb, Uri uri) {
         final String accountName = getQueryParameter(uri, RawContacts.ACCOUNT_NAME);
         final String accountType = getQueryParameter(uri, RawContacts.ACCOUNT_TYPE);
@@ -5846,23 +5822,6 @@
         }
     }
 
-    String getContactsRestrictions() {
-        if (mDbHelper.hasAccessToRestrictedData()) {
-            return "1";
-        } else {
-            return RawContactsColumns.CONCRETE_IS_RESTRICTED + "=0";
-        }
-    }
-
-    public String getContactsRestrictionExceptionAsNestedQuery(String contactIdColumn) {
-        if (mDbHelper.hasAccessToRestrictedData()) {
-            return "1";
-        } else {
-            return "(SELECT " + RawContacts.IS_RESTRICTED + " FROM " + Tables.RAW_CONTACTS
-                    + " WHERE " + RawContactsColumns.CONCRETE_ID + "=" + contactIdColumn + ")=0";
-        }
-    }
-
     @Override
     public AssetFileDescriptor openAssetFile(Uri uri, String mode) throws FileNotFoundException {
 
@@ -5958,7 +5917,7 @@
         }
 
         String sql =
-                "SELECT " + Photo.PHOTO + " FROM " + mDbHelper.getDataView() +
+                "SELECT " + Photo.PHOTO + " FROM " + Views.DATA +
                 " WHERE " + selection;
         SQLiteDatabase db = mDbHelper.getReadableDatabase();
         try {
@@ -6016,7 +5975,6 @@
                 new VCardComposer(context, vcardconfig, false);
         Writer writer = null;
         try {
-            // No extra checks since composer always uses restricted views.
             writer = new BufferedWriter(new OutputStreamWriter(stream));
             if (!composer.init(uri, selection, selectionArgs, null)) {
                 Log.w(TAG, "Failed to init VCardComposer");
@@ -6490,7 +6448,7 @@
         Arrays.fill(questionMarks, "?");
         final String where = Data._ID + " IN (" + TextUtils.join(",", questionMarks) + ")";
         final Cursor cursor = mDb.query(
-                mDbHelper.getDataView(shouldExcludeRestrictedData(uri)),
+                Views.DATA,
                 new String[] { Data.CONTACT_ID },
                 where, ids, null, null, null);
         try {
diff --git a/src/com/android/providers/contacts/GlobalSearchSupport.java b/src/com/android/providers/contacts/GlobalSearchSupport.java
index 38132e2..b5739bd 100644
--- a/src/com/android/providers/contacts/GlobalSearchSupport.java
+++ b/src/com/android/providers/contacts/GlobalSearchSupport.java
@@ -19,6 +19,7 @@
 import com.android.providers.contacts.ContactsDatabaseHelper.AggregatedPresenceColumns;
 import com.android.providers.contacts.ContactsDatabaseHelper.ContactsColumns;
 import com.android.providers.contacts.ContactsDatabaseHelper.Tables;
+import com.android.providers.contacts.ContactsDatabaseHelper.Views;
 
 import android.app.SearchManager;
 import android.content.res.Resources;
@@ -291,7 +292,7 @@
             sb.append(", " + SearchSnippetColumns.SNIPPET);
         }
         sb.append(" FROM ");
-        sb.append(getDatabaseHelper().getContactView(false));
+        sb.append(Views.CONTACTS);
         sb.append(" AS contacts");
         if (haveFilter) {
             mContactsProvider.appendSearchIndexJoin(sb, filter, true,
diff --git a/src/com/android/providers/contacts/LegacyApiSupport.java b/src/com/android/providers/contacts/LegacyApiSupport.java
index a51728e..501e074 100644
--- a/src/com/android/providers/contacts/LegacyApiSupport.java
+++ b/src/com/android/providers/contacts/LegacyApiSupport.java
@@ -596,8 +596,7 @@
                         + " AS " + android.provider.Contacts.People._ID + ", " +
                 peopleColumns +
                 " FROM " + Tables.RAW_CONTACTS + PEOPLE_JOINS +
-                " WHERE " + Tables.RAW_CONTACTS + "." + RawContacts.DELETED + "=0" +
-                " AND " + RawContacts.IS_RESTRICTED + "=0" + ";");
+                " WHERE " + Tables.RAW_CONTACTS + "." + RawContacts.DELETED + "=0;");
 
         db.execSQL("DROP VIEW IF EXISTS " + LegacyTables.ORGANIZATIONS + ";");
         db.execSQL("CREATE VIEW " + LegacyTables.ORGANIZATIONS + " AS SELECT " +
@@ -620,8 +619,7 @@
                 " FROM " + Tables.DATA_JOIN_MIMETYPE_RAW_CONTACTS +
                 " WHERE " + MimetypesColumns.CONCRETE_MIMETYPE + "='"
                         + Organization.CONTENT_ITEM_TYPE + "'"
-                        + " AND " + Tables.RAW_CONTACTS + "." + RawContacts.DELETED + "=0"
-                        + " AND " + RawContacts.IS_RESTRICTED + "=0" +
+                        + " AND " + Tables.RAW_CONTACTS + "." + RawContacts.DELETED + "=0" +
         ";");
 
         db.execSQL("DROP VIEW IF EXISTS " + LegacyTables.CONTACT_METHODS + ";");
@@ -645,8 +643,7 @@
                 peopleColumns +
                 " FROM " + Tables.DATA + DATA_JOINS +
                 " WHERE " + ContactMethods.KIND + " IS NOT NULL"
-                    + " AND " + Tables.RAW_CONTACTS + "." + RawContacts.DELETED + "=0"
-                    + " AND " + RawContacts.IS_RESTRICTED + "=0" +
+                    + " AND " + Tables.RAW_CONTACTS + "." + RawContacts.DELETED + "=0" +
         ";");
 
 
@@ -674,8 +671,7 @@
                         + DATA_JOINS +
                 " WHERE " + MimetypesColumns.CONCRETE_MIMETYPE + "='"
                         + Phone.CONTENT_ITEM_TYPE + "'"
-                        + " AND " + Tables.RAW_CONTACTS + "." + RawContacts.DELETED + "=0"
-                        + " AND " + RawContacts.IS_RESTRICTED + "=0" +
+                        + " AND " + Tables.RAW_CONTACTS + "." + RawContacts.DELETED + "=0" +
         ";");
 
         db.execSQL("DROP VIEW IF EXISTS " + LegacyTables.EXTENSIONS + ";");
@@ -693,8 +689,7 @@
                 " FROM " + Tables.DATA_JOIN_MIMETYPE_RAW_CONTACTS +
                 " WHERE " + MimetypesColumns.CONCRETE_MIMETYPE + "='"
                         + android.provider.Contacts.Extensions.CONTENT_ITEM_TYPE + "'"
-                        + " AND " + Tables.RAW_CONTACTS + "." + RawContacts.DELETED + "=0"
-                        + " AND " + RawContacts.IS_RESTRICTED + "=0" +
+                        + " AND " + Tables.RAW_CONTACTS + "." + RawContacts.DELETED + "=0" +
         ";");
 
         db.execSQL("DROP VIEW IF EXISTS " + LegacyTables.GROUPS + ";");
@@ -762,8 +757,7 @@
                 " FROM " + Tables.DATA + DATA_JOINS + LEGACY_PHOTO_JOIN +
                 " WHERE " + MimetypesColumns.CONCRETE_MIMETYPE + "='"
                         + Photo.CONTENT_ITEM_TYPE + "'"
-                        + " AND " + Tables.RAW_CONTACTS + "." + RawContacts.DELETED + "=0"
-                        + " AND " + RawContacts.IS_RESTRICTED + "=0" +
+                        + " AND " + Tables.RAW_CONTACTS + "." + RawContacts.DELETED + "=0" +
         ";");
 
     }
diff --git a/tests/src/com/android/providers/contacts/ContactsActor.java b/tests/src/com/android/providers/contacts/ContactsActor.java
index 1865904..f22943e 100644
--- a/tests/src/com/android/providers/contacts/ContactsActor.java
+++ b/tests/src/com/android/providers/contacts/ContactsActor.java
@@ -63,7 +63,6 @@
 import java.util.Arrays;
 import java.util.Locale;
 import java.util.Set;
-import java.util.concurrent.TimeUnit;
 
 /**
  * Helper class that encapsulates an "actor" which is owned by a specific
@@ -228,7 +227,7 @@
             Configuration configuration = new Configuration(resources.getConfiguration());
             configuration.locale = Locale.US;
             resources.updateConfiguration(configuration, resources.getDisplayMetrics());
-            mRes = new RestrictionMockResources(resources);
+            mRes = resources;
         }
 
         @Override
@@ -297,97 +296,30 @@
         }
     }
 
-    private static class RestrictionMockResources extends MockResources {
-        private static final String UNRESTRICTED = "unrestricted_packages";
-        private static final int UNRESTRICTED_ID = 1024;
-
-        private static final String[] UNRESTRICTED_LIST = new String[] {
-            PACKAGE_GREY
-        };
-
-        private final Resources mRes;
-
-        public RestrictionMockResources(Resources res) {
-            mRes = res;
-        }
-
-        @Override
-        public int getIdentifier(String name, String defType, String defPackage) {
-            if (UNRESTRICTED.equals(name)) {
-                return UNRESTRICTED_ID;
-            } else {
-                return mRes.getIdentifier(name, defType, defPackage);
-            }
-        }
-
-        @Override
-        public String[] getStringArray(int id) throws NotFoundException {
-            if (id == UNRESTRICTED_ID) {
-                return UNRESTRICTED_LIST;
-            } else {
-                return mRes.getStringArray(id);
-            }
-        }
-
-        @Override
-        public void getValue(int id, TypedValue outValue, boolean resolveRefs)
-                throws NotFoundException {
-            mRes.getValue(id, outValue, resolveRefs);
-        }
-
-        @Override
-        public String getString(int id) throws NotFoundException {
-            return mRes.getString(id);
-        }
-
-        @Override
-        public String getString(int id, Object... formatArgs) throws NotFoundException {
-            return mRes.getString(id, formatArgs);
-        }
-
-        @Override
-        public CharSequence getText(int id) throws NotFoundException {
-            return mRes.getText(id);
-        }
-
-        @Override
-        public String getResourceName(int resid) throws NotFoundException {
-            return String.valueOf(resid);
-        }
-
-        @Override
-        public int getInteger(int id) throws NotFoundException {
-            return mRes.getInteger(id);
-        }
-    }
-
     static String sCallingPackage = null;
 
     void ensureCallingPackage() {
         sCallingPackage = this.packageName;
     }
 
-    public long createRawContact(boolean isRestricted, String name) {
+    public long createRawContact(String name) {
         ensureCallingPackage();
-        long rawContactId = createRawContact(isRestricted);
+        long rawContactId = createRawContact();
         createName(rawContactId, name);
         return rawContactId;
     }
 
-    public long createRawContact(boolean isRestricted) {
+    public long createRawContact() {
         ensureCallingPackage();
         final ContentValues values = new ContentValues();
-        if (isRestricted) {
-            values.put(RawContacts.IS_RESTRICTED, 1);
-        }
 
         Uri rawContactUri = resolver.insert(RawContacts.CONTENT_URI, values);
         return ContentUris.parseId(rawContactUri);
     }
 
-    public long createRawContactWithStatus(boolean isRestricted, String name, String address,
+    public long createRawContactWithStatus(String name, String address,
             String status) {
-        final long rawContactId = createRawContact(isRestricted, name);
+        final long rawContactId = createRawContact(name);
         final long dataId = createEmail(rawContactId, address);
         createStatus(dataId, status);
         return rawContactId;
diff --git a/tests/src/com/android/providers/contacts/ContactsProvider2Test.java b/tests/src/com/android/providers/contacts/ContactsProvider2Test.java
index 475a57d..ab43158 100644
--- a/tests/src/com/android/providers/contacts/ContactsProvider2Test.java
+++ b/tests/src/com/android/providers/contacts/ContactsProvider2Test.java
@@ -382,7 +382,6 @@
                 RawContacts.SYNC2,
                 RawContacts.SYNC3,
                 RawContacts.SYNC4,
-                RawContacts.IS_RESTRICTED,
                 Contacts._ID,
                 Contacts.DISPLAY_NAME_PRIMARY,
                 Contacts.DISPLAY_NAME_ALTERNATIVE,
@@ -427,7 +426,6 @@
                 RawContacts.DIRTY,
                 RawContacts.NAME_VERIFIED,
                 RawContacts.DELETED,
-                RawContacts.IS_RESTRICTED,
                 RawContacts.SYNC1,
                 RawContacts.SYNC2,
                 RawContacts.SYNC3,
diff --git a/tests/src/com/android/providers/contacts/GroupsTest.java b/tests/src/com/android/providers/contacts/GroupsTest.java
index 1846321..56b7100 100644
--- a/tests/src/com/android/providers/contacts/GroupsTest.java
+++ b/tests/src/com/android/providers/contacts/GroupsTest.java
@@ -28,10 +28,10 @@
 import android.os.RemoteException;
 import android.provider.ContactsContract;
 import android.provider.ContactsContract.AggregationExceptions;
+import android.provider.ContactsContract.CommonDataKinds.GroupMembership;
 import android.provider.ContactsContract.Contacts;
 import android.provider.ContactsContract.Groups;
 import android.provider.ContactsContract.Settings;
-import android.provider.ContactsContract.CommonDataKinds.GroupMembership;
 import android.test.suitebuilder.annotation.LargeTest;
 import android.test.suitebuilder.annotation.MediumTest;
 
@@ -78,13 +78,13 @@
         long groupBlue = mActor.createGroup(GROUP_BLUE);
 
         // Create a handful of contacts
-        long contactAlpha = mActor.createRawContact(false, PERSON_ALPHA);
-        long contactBravo = mActor.createRawContact(false, PERSON_BRAVO);
-        long contactCharlie = mActor.createRawContact(false, PERSON_CHARLIE);
-        long contactCharlieDupe = mActor.createRawContact(false, PERSON_CHARLIE);
+        long contactAlpha = mActor.createRawContact(PERSON_ALPHA);
+        long contactBravo = mActor.createRawContact(PERSON_BRAVO);
+        long contactCharlie = mActor.createRawContact(PERSON_CHARLIE);
+        long contactCharlieDupe = mActor.createRawContact(PERSON_CHARLIE);
         setAggregationException(
                 AggregationExceptions.TYPE_KEEP_TOGETHER, contactCharlie, contactCharlieDupe);
-        long contactDelta = mActor.createRawContact(false, PERSON_DELTA);
+        long contactDelta = mActor.createRawContact(PERSON_DELTA);
 
         assertAggregated(contactCharlie, contactCharlieDupe);
 
diff --git a/tests/src/com/android/providers/contacts/RestrictionExceptionsTest.java b/tests/src/com/android/providers/contacts/RestrictionExceptionsTest.java
deleted file mode 100644
index 053f6e6..0000000
--- a/tests/src/com/android/providers/contacts/RestrictionExceptionsTest.java
+++ /dev/null
@@ -1,358 +0,0 @@
-/*
- * Copyright (C) 2009 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.providers.contacts;
-
-import static com.android.providers.contacts.ContactsActor.PACKAGE_GREY;
-import static com.android.providers.contacts.ContactsActor.PACKAGE_RED;
-
-import android.content.ContentUris;
-import android.content.ContentValues;
-import android.content.Context;
-import android.content.Entity;
-import android.content.EntityIterator;
-import android.content.res.AssetFileDescriptor;
-import android.database.Cursor;
-import android.net.Uri;
-import android.provider.ContactsContract;
-import android.provider.ContactsContract.AggregationExceptions;
-import android.provider.LiveFolders;
-import android.provider.ContactsContract.Contacts;
-import android.provider.ContactsContract.Data;
-import android.provider.ContactsContract.RawContacts;
-import android.provider.ContactsContract.CommonDataKinds.Email;
-import android.test.AndroidTestCase;
-import android.test.suitebuilder.annotation.LargeTest;
-
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-
-/**
- * Unit tests for {@link RawContacts#IS_RESTRICTED}.
- */
-@LargeTest
-public class RestrictionExceptionsTest extends AndroidTestCase {
-    private ContactsActor mGrey;
-    private ContactsActor mRed;
-
-    private static final String PHONE_GREY = "555-1111";
-    private static final String PHONE_RED = "555-2222";
-
-    private static final String EMAIL_GREY = "user@example.com";
-    private static final String EMAIL_RED = "user@example.org";
-
-    private static final String GENERIC_STATUS = "Status update";
-    private static final String GENERIC_NAME = "Smith";
-
-    public RestrictionExceptionsTest() {
-    }
-
-    @Override
-    protected void setUp() throws Exception {
-        super.setUp();
-
-        final Context overallContext = this.getContext();
-
-        // Build each of our specific actors in their own Contexts
-        mGrey = new ContactsActor(overallContext, PACKAGE_GREY,
-                SynchronousContactsProvider2.class, ContactsContract.AUTHORITY);
-        mRed = new ContactsActor(overallContext, PACKAGE_RED,
-                SynchronousContactsProvider2.class, ContactsContract.AUTHORITY);
-
-        // TODO make the provider wipe data automatically
-        ((SynchronousContactsProvider2)mGrey.provider).wipeData();
-    }
-
-    /**
-     * Assert that {@link Contacts#CONTACT_STATUS} matches the given value, or
-     * that no rows are returned when null.
-     */
-    void assertStatus(ContactsActor actor, long aggId, String status) {
-        final Uri aggUri = ContentUris.withAppendedId(Contacts.CONTENT_URI, aggId);
-
-        actor.ensureCallingPackage();
-        final Cursor cursor = actor.resolver.query(aggUri,
-                new String[] { Contacts.CONTACT_STATUS }, null, null, null);
-        try {
-            if (status == null) {
-                assertEquals(0, cursor.getCount());
-            } else {
-                while (cursor.moveToNext()) {
-                    final String foundStatus = cursor.getString(0);
-                    assertEquals(status, foundStatus);
-                }
-            }
-        } finally {
-            cursor.close();
-        }
-    }
-
-    public void testRestrictedInsertRestrictedQuery() {
-        // Restricted query can read restricted data
-        final long rawContact = mGrey.createRawContact(true, GENERIC_NAME);
-        final int count = mGrey.getDataCountForRawContact(rawContact);
-        assertEquals(1, count);
-    }
-
-    public void testRestrictedInsertGenericQuery() {
-        // Generic query is denied restricted data
-        final long rawContact = mGrey.createRawContact(true, GENERIC_NAME);
-        final int count = mRed.getDataCountForRawContact(rawContact);
-        assertEquals(0, count);
-    }
-
-    public void testGenericInsertRestrictedQuery() {
-        // Restricted query can read generic data
-        final long rawContact = mRed.createRawContact(false, GENERIC_NAME);
-        final int count = mGrey.getDataCountForRawContact(rawContact);
-        assertEquals(1, count);
-    }
-
-    public void testGenericInsertGenericQuery() {
-        // Generic query can read generic data
-        final long rawContact = mRed.createRawContact(false, GENERIC_NAME);
-        final int count = mRed.getDataCountForRawContact(rawContact);
-        assertEquals(1, count);
-    }
-
-    public void testMixedAggregateRestrictedQuery() {
-        // Create mixed aggregate with a restricted phone number
-        final long greyRawContactId = mGrey.createRawContact(true, GENERIC_NAME);
-        mGrey.createPhone(greyRawContactId, PHONE_GREY);
-        final long redRawContactId = mRed.createRawContact(false, GENERIC_NAME);
-        mRed.createPhone(redRawContactId, PHONE_RED);
-        mGrey.setAggregationException(
-                AggregationExceptions.TYPE_KEEP_TOGETHER, greyRawContactId, redRawContactId);
-
-        // Make sure both aggregates were joined
-        final long greyAgg = mGrey.getContactForRawContact(greyRawContactId);
-        final long redAgg = mRed.getContactForRawContact(redRawContactId);
-        assertEquals(greyAgg, redAgg);
-
-        // Restricted reader should have access to both numbers
-        final int greyCount = mGrey.getDataCountForContact(greyAgg);
-        assertEquals(4, greyCount);
-
-        // Generic reader should have limited access
-        final int redCount = mRed.getDataCountForContact(redAgg);
-        assertEquals(2, redCount);
-    }
-
-    public void testUpdateRestricted() {
-        // Assert that we can't un-restrict something
-        final long greyContact = mGrey.createRawContact(true, GENERIC_NAME);
-        final long greyPhone = mGrey.createPhone(greyContact, PHONE_GREY);
-
-        int count = mRed.getDataCountForRawContact(greyContact);
-        assertEquals(0, count);
-
-        // Try un-restricting that contact
-        final Uri greyUri = ContentUris.withAppendedId(RawContacts.CONTENT_URI, greyContact);
-        final ContentValues values = new ContentValues();
-        values.put(RawContacts.IS_RESTRICTED, 0);
-        mRed.ensureCallingPackage();
-        mRed.provider.update(greyUri, values, null, null);
-
-        count = mRed.getDataCountForRawContact(greyContact);
-        assertEquals(0, count);
-    }
-
-    public void testExportVCard() throws Exception {
-        // Create mixed aggregate with a restricted phone number
-        final long greyRawContactId = mGrey.createRawContact(true, GENERIC_NAME);
-        mGrey.createPhone(greyRawContactId, PHONE_GREY);
-        final long redRawContactId = mRed.createRawContact(false, GENERIC_NAME);
-        mRed.createPhone(redRawContactId, PHONE_RED);
-        mGrey.setAggregationException(
-                AggregationExceptions.TYPE_KEEP_TOGETHER, greyRawContactId, redRawContactId);
-
-        // Make sure both aggregates were joined
-        final long greyAgg = mGrey.getContactForRawContact(greyRawContactId);
-        final long redAgg = mRed.getContactForRawContact(redRawContactId);
-        assertEquals(greyAgg, redAgg);
-
-        // Exported vCard shouldn't contain restricted phone
-        mRed.ensureCallingPackage();
-        final Uri aggUri = ContentUris.withAppendedId(Contacts.CONTENT_URI, greyAgg);
-        final Cursor cursor = mRed.resolver.query(aggUri,
-                new String[] { Contacts.LOOKUP_KEY }, null, null, null);
-        assertTrue(cursor.moveToFirst());
-        final String lookupKey = cursor.getString(0);
-        cursor.close();
-
-        // Read vCard into buffer
-        final Uri shareUri = Uri.withAppendedPath(Contacts.CONTENT_VCARD_URI, lookupKey);
-        final AssetFileDescriptor file = mRed.resolver.openAssetFileDescriptor(shareUri, "r");
-        final InputStream in = file.createInputStream();
-        final byte[] buf = readInputStream(in);
-        final String card = new String(buf);
-        assertNotSame(0, card.length());
-
-        // Make sure that only unrestricted phones appear
-        assertTrue(card.indexOf(PHONE_RED) != -1);
-        assertTrue(card.indexOf(PHONE_GREY) == -1);
-    }
-
-    private static byte[] readInputStream(InputStream in) throws IOException {
-        try {
-            ByteArrayOutputStream out = new ByteArrayOutputStream();
-            byte[] buf = new byte[4096];
-            int count;
-            while ((count = in.read(buf)) != -1) {
-                out.write(buf, 0, count);
-            }
-            return out.toByteArray();
-        } finally {
-            in.close();
-        }
-    }
-
-    public void testContactsLiveFolder() {
-        final long greyContact = mGrey.createRawContact(true, GENERIC_NAME);
-        final long greyPhone = mGrey.createPhone(greyContact, PHONE_GREY);
-
-        // Protected contact should be omitted from live folder
-        mRed.ensureCallingPackage();
-        final Uri folderUri = Uri.withAppendedPath(ContactsContract.AUTHORITY_URI,
-                "live_folders/contacts_with_phones");
-        final Cursor cursor = mRed.resolver.query(folderUri,
-                new String[] { LiveFolders._ID }, null, null, null);
-        try {
-            while (cursor.moveToNext()) {
-                final long id = cursor.getLong(0);
-                assertFalse(id == greyContact);
-            }
-        } finally {
-            cursor.close();
-        }
-    }
-
-    public void testRestrictedQueryParam() throws Exception {
-        final long greyContact = mGrey.createRawContact(true, GENERIC_NAME);
-        final long greyPhone = mGrey.createPhone(greyContact, PHONE_GREY);
-
-        Uri greyUri = ContentUris.withAppendedId(RawContacts.CONTENT_URI, greyContact);
-        greyUri = Uri.withAppendedPath(greyUri, RawContacts.Entity.CONTENT_DIRECTORY);
-        Uri redUri = greyUri.buildUpon().appendQueryParameter(
-                ContactsContract.REQUESTING_PACKAGE_PARAM_KEY, mRed.packageName).build();
-
-        // When calling normally, we have access to protected
-        mGrey.ensureCallingPackage();
-        EntityIterator iterator = RawContacts.newEntityIterator(
-                mGrey.resolver.query(greyUri, null, null, null, null));
-        while (iterator.hasNext()) {
-            final Entity entity = iterator.next();
-            final long rawContactId = entity.getEntityValues().getAsLong(RawContacts._ID);
-            assertTrue(rawContactId == greyContact);
-        }
-        iterator.close();
-
-        // When calling on behalf of another package, protected is omitted
-        mGrey.ensureCallingPackage();
-        iterator = RawContacts.newEntityIterator(
-                mGrey.resolver.query(redUri, null, null, null, null));
-        while (iterator.hasNext()) {
-            final Entity entity = iterator.next();
-            final long rawContactId = entity.getEntityValues().getAsLong(RawContacts._ID);
-            assertTrue(rawContactId != greyContact);
-        }
-        iterator.close();
-    }
-
-    public void testRestrictedEmailLookupRestricted() {
-        final long greyContact = mGrey.createRawContact(true, GENERIC_NAME);
-        final long greyEmail = mGrey.createEmail(greyContact, EMAIL_GREY);
-
-        // Restricted caller should see protected data
-        mGrey.ensureCallingPackage();
-        final Uri lookupUri = Uri.withAppendedPath(Email.CONTENT_LOOKUP_URI, EMAIL_GREY);
-        final Cursor cursor = mGrey.resolver.query(lookupUri,
-                new String[] { Data._ID }, null, null, null);
-        try {
-            while (cursor.moveToNext()) {
-                final long dataId = cursor.getLong(0);
-                assertTrue(dataId == greyEmail);
-            }
-        } finally {
-            cursor.close();
-        }
-    }
-
-    public void testRestrictedEmailLookupGeneric() {
-        final long greyContact = mGrey.createRawContact(true, GENERIC_NAME);
-        final long greyEmail = mGrey.createEmail(greyContact, EMAIL_GREY);
-
-        // Generic caller should never see protected data
-        mRed.ensureCallingPackage();
-        final Uri lookupUri = Uri.withAppendedPath(Email.CONTENT_LOOKUP_URI, EMAIL_GREY);
-        final Cursor cursor = mRed.resolver.query(lookupUri,
-                new String[] { Data._ID }, null, null, null);
-        try {
-            while (cursor.moveToNext()) {
-                final long dataId = cursor.getLong(0);
-                assertFalse(dataId == greyEmail);
-            }
-        } finally {
-            cursor.close();
-        }
-    }
-
-    public void testStatusRestrictedInsertRestrictedQuery() {
-        final long rawContactId = mGrey.createRawContactWithStatus(true,
-                GENERIC_NAME, EMAIL_GREY, GENERIC_STATUS);
-        final long aggId = mGrey.getContactForRawContact(rawContactId);
-
-        // Restricted query can read restricted status
-        assertStatus(mGrey, aggId, GENERIC_STATUS);
-    }
-
-    public void testStatusRestrictedInsertGenericQuery() {
-        final long rawContactId = mGrey.createRawContactWithStatus(true,
-                GENERIC_NAME, EMAIL_GREY, GENERIC_STATUS);
-        final long aggId = mGrey.getContactForRawContact(rawContactId);
-
-        // Generic query is denied restricted status
-        assertStatus(mRed, aggId, null);
-    }
-
-    public void testStatusGenericInsertRestrictedQuery() {
-        final long rawContactId = mRed.createRawContactWithStatus(false,
-                GENERIC_NAME, EMAIL_RED, GENERIC_STATUS);
-        final long aggId = mRed.getContactForRawContact(rawContactId);
-
-        // Restricted query can read generic status
-        assertStatus(mGrey, aggId, GENERIC_STATUS);
-    }
-
-    public void testStatusGenericInsertGenericQuery() {
-        final long rawContactId = mRed.createRawContactWithStatus(false,
-                GENERIC_NAME, EMAIL_RED, GENERIC_STATUS);
-        final long aggId = mRed.getContactForRawContact(rawContactId);
-
-        // Generic query can read generic status
-        assertStatus(mRed, aggId, GENERIC_STATUS);
-    }
-
-    public void testStrictProjectionMap() {
-        try {
-            mGrey.provider.query(ContactsContract.Contacts.CONTENT_URI,
-                    new String[] { "_id as noname, * FROM contacts--" }, null, null, null);
-            fail();
-        } catch (Exception e) {
-        }
-    }
-}