Snap for 4384531 from 1900872942cc046483b8ad4b235b87228531713b to oc-m2-release
Change-Id: I190b6142db65d4a036452673f04a948269df82dd
diff --git a/src/com/android/providers/telephony/CarrierProvider.java b/src/com/android/providers/telephony/CarrierProvider.java
index a13c7e3..a4b6ea0 100644
--- a/src/com/android/providers/telephony/CarrierProvider.java
+++ b/src/com/android/providers/telephony/CarrierProvider.java
@@ -90,7 +90,17 @@
@Override
public int delete(Uri uri, String selection, String[] selectionArgs) {
- throw new UnsupportedOperationException("Cannot delete URL: " + uri);
+ if (VDBG) {
+ Log.d(TAG, "delete:"
+ + " uri=" + uri
+ + " selection={" + selection + "}"
+ + " selection=" + selection
+ + " selectionArgs=" + Arrays.toString(selectionArgs));
+ }
+ final int count = getWritableDatabase().delete(CarrierDatabaseHelper.CARRIER_KEY_TABLE,
+ selection, selectionArgs);
+ Log.d(TAG, " delete.count=" + count);
+ return count;
}
@Override
diff --git a/tests/src/com/android/providers/telephony/CarrierProviderTest.java b/tests/src/com/android/providers/telephony/CarrierProviderTest.java
index b0b9b09..5146aa9 100644
--- a/tests/src/com/android/providers/telephony/CarrierProviderTest.java
+++ b/tests/src/com/android/providers/telephony/CarrierProviderTest.java
@@ -288,4 +288,38 @@
Log.d(TAG, "Error inserting certificates:: " + e);
}
}
+
+ /**
+ * Test delete.
+ */
+ @Test
+ @SmallTest
+ public void testDelete() {
+ int numRowsDeleted = -1;
+ ContentValues contentValues = new ContentValues();
+ contentValues.put(CarrierDatabaseHelper.KEY_TYPE, dummy_type);
+ contentValues.put(CarrierDatabaseHelper.MCC, dummy_mcc);
+ contentValues.put(CarrierDatabaseHelper.MNC, dummy_mnc);
+ contentValues.put(CarrierDatabaseHelper.MVNO_TYPE, dummy_mvno_type);
+ contentValues.put(CarrierDatabaseHelper.MVNO_MATCH_DATA, dummy_mvno_match_data);
+ contentValues.put(CarrierDatabaseHelper.KEY_IDENTIFIER, dummy_key_identifier_data);
+ contentValues.put(CarrierDatabaseHelper.PUBLIC_KEY, dummy_key1.getBytes());
+ contentValues.put(CarrierDatabaseHelper.EXPIRATION_TIME, dummy_key_expiration);
+
+ try {
+ mContentResolver.insert(CarrierProvider.CONTENT_URI, contentValues);
+ } catch (Exception e) {
+ Log.d(TAG, "Error inserting certificates:" + e);
+ }
+
+ try {
+ String whereClause = "mcc=? and mnc=?";
+ String[] whereArgs = new String[] { dummy_mcc, dummy_mnc };
+ numRowsDeleted = mContentResolver.delete(CarrierProvider.CONTENT_URI, whereClause, whereArgs);
+ } catch (Exception e) {
+ Log.d(TAG, "Error updating values:" + e);
+ }
+ assertEquals(numRowsDeleted, 1);
+ }
+
}