Merge "Refined the CardContentProvider unused operations"
diff --git a/src/com/android/settings/homepage/contextualcards/CardContentProvider.java b/src/com/android/settings/homepage/contextualcards/CardContentProvider.java
index 74e09e8..8088143 100644
--- a/src/com/android/settings/homepage/contextualcards/CardContentProvider.java
+++ b/src/com/android/settings/homepage/contextualcards/CardContentProvider.java
@@ -98,17 +98,7 @@
@Override
public int delete(Uri uri, String selection, String[] selectionArgs) {
- final StrictMode.ThreadPolicy oldPolicy = StrictMode.getThreadPolicy();
- try {
- maybeEnableStrictMode();
- final SQLiteDatabase database = mDBHelper.getWritableDatabase();
- final String table = getTableFromMatch(uri);
- final int rowsDeleted = database.delete(table, selection, selectionArgs);
- getContext().getContentResolver().notifyChange(uri, null /* observer */);
- return rowsDeleted;
- } finally {
- StrictMode.setThreadPolicy(oldPolicy);
- }
+ throw new UnsupportedOperationException("delete operation not supported currently.");
}
@Override
@@ -140,18 +130,7 @@
@Override
public int update(Uri uri, ContentValues values, String selection, String[] selectionArgs) {
- final StrictMode.ThreadPolicy oldPolicy = StrictMode.getThreadPolicy();
- try {
- maybeEnableStrictMode();
-
- final SQLiteDatabase database = mDBHelper.getWritableDatabase();
- final String table = getTableFromMatch(uri);
- final int rowsUpdated = database.update(table, values, selection, selectionArgs);
- getContext().getContentResolver().notifyChange(uri, null /* observer */);
- return rowsUpdated;
- } finally {
- StrictMode.setThreadPolicy(oldPolicy);
- }
+ throw new UnsupportedOperationException("update operation not supported currently.");
}
@VisibleForTesting
diff --git a/tests/robotests/src/com/android/settings/homepage/contextualcards/CardContentProviderTest.java b/tests/robotests/src/com/android/settings/homepage/contextualcards/CardContentProviderTest.java
index 0ffabb4..1e444bb 100644
--- a/tests/robotests/src/com/android/settings/homepage/contextualcards/CardContentProviderTest.java
+++ b/tests/robotests/src/com/android/settings/homepage/contextualcards/CardContentProviderTest.java
@@ -95,15 +95,12 @@
assertThat(count).isGreaterThan(0);
}
- @Test
+ @Test(expected = UnsupportedOperationException.class)
public void cardData_delete() {
- mResolver.insert(mUri, generateOneRow());
final int delCount = mResolver.delete(mUri, null, null);
-
- assertThat(delCount).isGreaterThan(0);
}
- @Test
+ @Test(expected = UnsupportedOperationException.class)
public void cardData_update() {
mResolver.insert(mUri, generateOneRow());
@@ -113,16 +110,6 @@
final String strWhere = CardDatabaseHelper.CardColumns.NAME + "=?";
final String[] selectionArgs = {"auto_rotate"};
final int updateCount = mResolver.update(mUri, values, strWhere, selectionArgs);
-
- assertThat(updateCount).isGreaterThan(0);
-
- final String[] columns = {CardDatabaseHelper.CardColumns.SCORE};
- final Cursor cr = mResolver.query(mUri, columns, strWhere, selectionArgs, null);
- cr.moveToFirst();
- final double qryScore = cr.getDouble(0);
-
- cr.close();
- assertThat(qryScore).isEqualTo(updatingScore);
}
@Test
@@ -146,28 +133,6 @@
}
@Test
- public void delete_isMainThread_shouldEnableStrictMode() {
- ShadowThreadUtils.setIsMainThread(true);
- ReflectionHelpers.setStaticField(Build.class, "IS_DEBUGGABLE", true);
-
- mProvider.delete(mUri, null, null);
-
- verify(mProvider).enableStrictMode();
- }
-
- @Test
- public void update_isMainThread_shouldEnableStrictMode() {
- ShadowThreadUtils.setIsMainThread(true);
- ReflectionHelpers.setStaticField(Build.class, "IS_DEBUGGABLE", true);
- final ContentValues values = new ContentValues();
- values.put(CardDatabaseHelper.CardColumns.SCORE, "0.01");
-
- mProvider.update(mUri, values, null, null);
-
- verify(mProvider).enableStrictMode();
- }
-
- @Test
public void insert_notMainThread_shouldNotEnableStrictMode() {
ShadowThreadUtils.setIsMainThread(false);
ReflectionHelpers.setStaticField(Build.class, "IS_DEBUGGABLE", true);
@@ -187,28 +152,6 @@
verify(mProvider, never()).enableStrictMode();
}
- @Test
- public void delete_notMainThread_shouldNotEnableStrictMode() {
- ShadowThreadUtils.setIsMainThread(false);
- ReflectionHelpers.setStaticField(Build.class, "IS_DEBUGGABLE", true);
-
- mProvider.delete(mUri, null, null);
-
- verify(mProvider, never()).enableStrictMode();
- }
-
- @Test
- public void update_notMainThread_shouldNotEnableStrictMode() {
- ShadowThreadUtils.setIsMainThread(false);
- ReflectionHelpers.setStaticField(Build.class, "IS_DEBUGGABLE", true);
- final ContentValues values = new ContentValues();
- values.put(CardDatabaseHelper.CardColumns.SCORE, "0.01");
-
- mProvider.update(mUri, values, null, null);
-
- verify(mProvider, never()).enableStrictMode();
- }
-
@Test(expected = UnsupportedOperationException.class)
public void getType_shouldCrash() {
mProvider.getType(null);