summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorYorke Lee <yorkelee@google.com>2014-09-02 10:09:59 -0700
committerYorke Lee <yorkelee@google.com>2014-09-02 12:47:28 -0700
commita5d6539589c851152bbf6665c1addfc2c7292dba (patch)
treedff3c28b17eee2577beed6e106a37b680d6accb8 /tests
parent34ea500bee5828f1dbd0e19d31d91aa1e979382a (diff)
downloadpackages_providers_ContactsProvider-a5d6539589c851152bbf6665c1addfc2c7292dba.zip
packages_providers_ContactsProvider-a5d6539589c851152bbf6665c1addfc2c7292dba.tar.gz
packages_providers_ContactsProvider-a5d6539589c851152bbf6665c1addfc2c7292dba.tar.bz2
Delete stale calls in a managed profile's call log table
Bug: 17096027 Change-Id: Ia640ef8a8f88eb5f9ff9eddc096bcaf334bba3c9
Diffstat (limited to 'tests')
-rw-r--r--tests/src/com/android/providers/contacts/ContactsProvider2Test.java37
1 files changed, 37 insertions, 0 deletions
diff --git a/tests/src/com/android/providers/contacts/ContactsProvider2Test.java b/tests/src/com/android/providers/contacts/ContactsProvider2Test.java
index 11d9b57..48b4128 100644
--- a/tests/src/com/android/providers/contacts/ContactsProvider2Test.java
+++ b/tests/src/com/android/providers/contacts/ContactsProvider2Test.java
@@ -19,6 +19,7 @@ package com.android.providers.contacts;
import static com.android.providers.contacts.TestUtils.cv;
import android.accounts.Account;
+import android.content.ContentProvider;
import android.content.ContentProviderOperation;
import android.content.ContentProviderResult;
import android.content.ContentResolver;
@@ -26,12 +27,16 @@ import android.content.ContentUris;
import android.content.ContentValues;
import android.content.Entity;
import android.content.EntityIterator;
+import android.content.pm.UserInfo;
import android.content.res.AssetFileDescriptor;
import android.database.Cursor;
import android.database.MatrixCursor;
import android.database.sqlite.SQLiteDatabase;
import android.net.Uri;
import android.os.AsyncTask;
+import android.os.UserManager;
+import android.provider.CallLog.Calls;
+import android.provider.CallLog;
import android.provider.ContactsContract;
import android.provider.ContactsContract.AggregationExceptions;
import android.provider.ContactsContract.CommonDataKinds.Callable;
@@ -71,6 +76,7 @@ import android.test.suitebuilder.annotation.LargeTest;
import android.text.TextUtils;
import com.android.internal.util.ArrayUtils;
+import com.android.providers.contacts.CallLogProviderTest.TestCallLogProvider;
import com.android.providers.contacts.ContactsActor.AlteringUserContext;
import com.android.providers.contacts.ContactsActor.MockUserManager;
import com.android.providers.contacts.ContactsDatabaseHelper.AggregationExceptionColumns;
@@ -1882,6 +1888,37 @@ public class ContactsProvider2Test extends BaseContactsProvider2Test {
}
}
+ public void testUpgradeToVersion910_CallsDeletedForCorpProfileOnly() throws Exception {
+ CallLogProvider provider =
+ (CallLogProvider) addProvider(TestCallLogProvider.class, CallLog.AUTHORITY);
+ final ContactsDatabaseHelper helper = provider.getDatabaseHelper(mContext);
+ final SQLiteDatabase db = helper.getWritableDatabase();
+
+ final ContentValues values = new ContentValues();
+ values.put(Calls.NUMBER, "123456789");
+ values.put(Calls.DATE, System.currentTimeMillis());
+ values.put(Calls.TYPE, Calls.OUTGOING_TYPE);
+ values.put(Calls.DURATION, 10000);
+
+ mResolver.insert(Calls.CONTENT_URI, values);
+ assertEquals(1, getCount(Calls.CONTENT_URI));
+
+ helper.upgradeToVersion910(db);
+ assertEquals(1, getCount(Calls.CONTENT_URI));
+
+ mActor.mockUserManager.myUser = MockUserManager.CORP_USER.id;
+ mActor.mockUserManager.setUsers(MockUserManager.CORP_USER);
+
+ helper.upgradeToVersion910(db);
+
+ // Switch back to the primary user to ensure that the calls table was really cleared, and
+ // we are not getting an empty cursor just because of the call log read/write restriction
+ // on managed profiles.
+ mActor.mockUserManager.myUser = MockUserManager.PRIMARY_USER.id;
+ mActor.mockUserManager.setUsers(MockUserManager.PRIMARY_USER);
+ assertEquals(0, getCount(Calls.CONTENT_URI));
+ }
+
public void testRewriteCorpPhoneLookup() {
// 19 columns
final MatrixCursor c = new MatrixCursor(new String[] {