release-request-53526352-7b51-4ab1-a661-632ffc55dd7c-for-git_oc-mr1-release-4371241 snap-temp-L10900000107789672
Change-Id: Ic0ffc2c4dd4a4b5d04ac8f1e84675a96994118ff
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);
+ }
+
}