Loading core/java/com/android/internal/net/ConnectivityBlobStore.java +20 −0 Original line number Diff line number Diff line Loading @@ -139,6 +139,26 @@ public class ConnectivityBlobStore { } } /** * Remove all blobs that are stored in the database. * * @return True if the operation was successful, false otherwise. * @hide */ public boolean removeAll() { final int ownerUid = Binder.getCallingUid(); try { final int numRowsRemoved = mDb.delete(TABLENAME, "owner=?" /* whereClause */, new String[] {Integer.toString(ownerUid)} /* whereArgs */); Log.i(TAG, "Removed " + numRowsRemoved + " rows during the removeAll operation " + "for uid " + ownerUid); return true; } catch (SQLException e) { Log.e(TAG, "Error while removing all blobs: " + e); return false; } } /** * Lists the name suffixes stored in the database matching the given prefix, sorted in * ascending order. Loading core/tests/coretests/src/com/android/internal/net/ConnectivityBlobStoreTest.java +18 −0 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ package com.android.internal.net; import static org.junit.Assert.assertArrayEquals; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; Loading Loading @@ -99,6 +100,23 @@ public class ConnectivityBlobStoreTest { assertFalse(connectivityBlobStore.remove(TEST_NAME)); } @Test public void testRemoveAll() throws Exception { final ConnectivityBlobStore connectivityBlobStore = createConnectivityBlobStore(); final int numEntries = 5; for (int i = 0; i < numEntries; i++) { assertTrue(connectivityBlobStore.put(TEST_NAME + i, TEST_BLOB)); } assertEquals(numEntries, connectivityBlobStore.list("").length); // Remove all blobs and check that the blob store is empty. assertTrue(connectivityBlobStore.removeAll()); assertEquals(0, connectivityBlobStore.list("").length); // Removing all blobs from an empty database should also succeed. assertTrue(connectivityBlobStore.removeAll()); } @Test public void testMultipleNames() throws Exception { final String name1 = TEST_NAME + "1"; Loading Loading
core/java/com/android/internal/net/ConnectivityBlobStore.java +20 −0 Original line number Diff line number Diff line Loading @@ -139,6 +139,26 @@ public class ConnectivityBlobStore { } } /** * Remove all blobs that are stored in the database. * * @return True if the operation was successful, false otherwise. * @hide */ public boolean removeAll() { final int ownerUid = Binder.getCallingUid(); try { final int numRowsRemoved = mDb.delete(TABLENAME, "owner=?" /* whereClause */, new String[] {Integer.toString(ownerUid)} /* whereArgs */); Log.i(TAG, "Removed " + numRowsRemoved + " rows during the removeAll operation " + "for uid " + ownerUid); return true; } catch (SQLException e) { Log.e(TAG, "Error while removing all blobs: " + e); return false; } } /** * Lists the name suffixes stored in the database matching the given prefix, sorted in * ascending order. Loading
core/tests/coretests/src/com/android/internal/net/ConnectivityBlobStoreTest.java +18 −0 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ package com.android.internal.net; import static org.junit.Assert.assertArrayEquals; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; Loading Loading @@ -99,6 +100,23 @@ public class ConnectivityBlobStoreTest { assertFalse(connectivityBlobStore.remove(TEST_NAME)); } @Test public void testRemoveAll() throws Exception { final ConnectivityBlobStore connectivityBlobStore = createConnectivityBlobStore(); final int numEntries = 5; for (int i = 0; i < numEntries; i++) { assertTrue(connectivityBlobStore.put(TEST_NAME + i, TEST_BLOB)); } assertEquals(numEntries, connectivityBlobStore.list("").length); // Remove all blobs and check that the blob store is empty. assertTrue(connectivityBlobStore.removeAll()); assertEquals(0, connectivityBlobStore.list("").length); // Removing all blobs from an empty database should also succeed. assertTrue(connectivityBlobStore.removeAll()); } @Test public void testMultipleNames() throws Exception { final String name1 = TEST_NAME + "1"; Loading