Fixing some StrictMode violations, making it softer for others which the Android runtime itself triggers.

This commit is contained in:
Rodrigo Damazio
2010-12-10 16:40:22 -02:00
parent 6b4ea71404
commit 607b174c5f
4 changed files with 15 additions and 10 deletions
@@ -316,6 +316,8 @@ public class TrackWriter {
isLastValid = isValid;
} while (locationsCursor.moveToNext());
locationsCursor.close();
if (segmentOpen) {
writer.writeCloseSegment();
segmentOpen = false;
@@ -19,7 +19,6 @@ public class GingerbreadPlatformAdapter extends EclairPlatformAdapter {
.detectDiskWrites()
.detectNetwork()
.penaltyLog()
.penaltyDeath()
.build());
StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder()
.detectAll()
@@ -820,18 +820,22 @@ public class MyTracksProviderUtilsImpl implements MyTracksProviderUtils {
String select = TracksColumns._ID + "=" + id;
return findTrackBy(select);
}
@Override
public List<Track> getAllTracks() {
Cursor cursor = getTracksCursor(null);
if (cursor == null || !cursor.moveToFirst()) {
return new ArrayList<Track>();
}
ArrayList<Track> tracks = new ArrayList<Track>();
if (cursor != null) {
tracks.ensureCapacity(cursor.getCount());
List<Track> tracks = new ArrayList<Track>(cursor.getCount());
do {
tracks.add(createTrack(cursor));
} while(cursor.moveToNext());
if (cursor.moveToFirst()) {
do {
tracks.add(createTrack(cursor));
} while(cursor.moveToNext());
}
cursor.close();
}
return tracks;
}
@@ -499,7 +499,7 @@ public class TrackRecordingServiceTest
public void testDeleteAllTracks_trackInProgress() throws Exception {
createDummyTrack(123, -1, true);
assertEquals(1, providerUtils.getAllTracks().size());
ITrackRecordingService service = bindAndGetService(createStartIntent());
assertTrue(service.isRecording());