Clean-up of issues found by static analysis.

This commit is contained in:
Rodrigo Damazio
2011-06-01 05:23:25 -03:00
parent aed28fe503
commit eee6a713fa
15 changed files with 80 additions and 74 deletions
+4 -4
View File
@@ -61,10 +61,10 @@ public class AntInterface {
private static Object INSTANCE_LOCK = new Object(); private static Object INSTANCE_LOCK = new Object();
/** The context to use. */ /** The context to use. */
private static Context sContext = null; private Context sContext = null;
/** Listens to changes to service connection status. */ /** Listens to changes to service connection status. */
private static ServiceListener sServiceListener; private ServiceListener sServiceListener;
/** Is the ANT Radio Proxy Service connected. */ /** Is the ANT Radio Proxy Service connected. */
private static boolean sServiceConnected = false; private static boolean sServiceConnected = false;
@@ -210,7 +210,7 @@ public class AntInterface {
/** /**
* Class for interacting with the ANT interface. * Class for interacting with the ANT interface.
*/ */
private static ServiceConnection sIAntConnection = new ServiceConnection() { private final ServiceConnection sIAntConnection = new ServiceConnection() {
public void onServiceConnected(ComponentName pClassName, IBinder pService) { public void onServiceConnected(ComponentName pClassName, IBinder pService) {
// This is called when the connection with the service has been // This is called when the connection with the service has been
// established, giving us the service object we can use to // established, giving us the service object we can use to
@@ -1223,7 +1223,7 @@ public class AntInterface {
*/ */
public boolean requestForceClaimInterface(String appName) throws AntInterfaceException public boolean requestForceClaimInterface(String appName) throws AntInterfaceException
{ {
if((null == appName) || ("" == appName)) if((null == appName) || ("".equals(appName)))
{ {
throw new IllegalArgumentException(); throw new IllegalArgumentException();
} }
@@ -19,9 +19,9 @@ import java.util.List;
/** /**
* Activity for viewing the combined statistics for all the recorded tracks. * Activity for viewing the combined statistics for all the recorded tracks.
* *
* Other features to add - menu items to change setings. * Other features to add - menu items to change setings.
* *
* @author Fergus Nelson * @author Fergus Nelson
*/ */
public class AggregatedStatsActivity extends Activity implements public class AggregatedStatsActivity extends Activity implements
@@ -43,7 +43,7 @@ public class AggregatedStatsActivity extends Activity implements
Log.d(Constants.TAG, "StatsActivity: onSharedPreferences changed " Log.d(Constants.TAG, "StatsActivity: onSharedPreferences changed "
+ key); + key);
if (key != null) { if (key != null) {
if (key.equals(R.string.metric_units_key)) { if (key.equals(getString(R.string.metric_units_key))) {
metricUnits = sharedPreferences.getBoolean( metricUnits = sharedPreferences.getBoolean(
getString(R.string.metric_units_key), true); getString(R.string.metric_units_key), true);
utils.setMetricUnits(metricUnits); utils.setMetricUnits(metricUnits);
@@ -86,8 +86,8 @@ public class AggregatedStatsActivity extends Activity implements
} }
/** /**
* 1. Reads tracks from the db * 1. Reads tracks from the db
* 2. Merges the trip stats from the tracks * 2. Merges the trip stats from the tracks
* 3. Updates the view * 3. Updates the view
*/ */
private void loadAggregatedStats() { private void loadAggregatedStats() {
@@ -49,6 +49,7 @@ import java.util.ArrayList;
* @author Leif Hendrik Wilden * @author Leif Hendrik Wilden
*/ */
public class ChartView extends View { public class ChartView extends View {
private static final int MIN_ZOOM_LEVEL = 1;
/* /*
* Scrolling logic: * Scrolling logic:
@@ -62,7 +63,6 @@ public class ChartView extends View {
* Zoom logic: * Zoom logic:
*/ */
private int zoomLevel = 1; private int zoomLevel = 1;
private final int minZoomLevel = 1;
private int maxZoomLevel = 10; private int maxZoomLevel = 10;
private static final int MAX_INTERVALS = 5; private static final int MAX_INTERVALS = 5;
@@ -333,7 +333,7 @@ public class ChartView extends View {
* @return true if the chart can be zoomed out * @return true if the chart can be zoomed out
*/ */
public boolean canZoomOut() { public boolean canZoomOut() {
return zoomLevel > minZoomLevel; return zoomLevel > MIN_ZOOM_LEVEL;
} }
/** /**
@@ -49,6 +49,7 @@ import android.util.Log;
import java.io.ByteArrayInputStream; import java.io.ByteArrayInputStream;
import java.io.IOException; import java.io.IOException;
import java.net.URLEncoder; import java.net.URLEncoder;
import java.nio.charset.Charset;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Locale; import java.util.Locale;
@@ -420,10 +421,10 @@ public class SendToFusionTables implements Runnable {
* @return the kml. * @return the kml.
*/ */
private String getKmlPoint(Location location) { private String getKmlPoint(Location location) {
StringBuilder builder = new StringBuilder("<Point><coordinates>"); StringBuilder builder = new StringBuilder("<Point><coordinates>");
appendCoordinate(location, builder); appendCoordinate(location, builder);
builder.append("</coordinates></Point>"); builder.append("</coordinates></Point>");
return builder.toString(); return builder.toString();
} }
/** /**
@@ -599,7 +600,7 @@ public class SendToFusionTables implements Runnable {
// I am leaving the number of waypoints very high which should not be a // I am leaving the number of waypoints very high which should not be a
// problem because we don't try to load them into objects all at the // problem because we don't try to load them into objects all at the
// same time. // same time.
boolean success = true; boolean success = true;
Cursor c = null; Cursor c = null;
try { try {
c = providerUtils.getWaypointsCursor( c = providerUtils.getWaypointsCursor(
@@ -613,9 +614,9 @@ public class SendToFusionTables implements Runnable {
Waypoint wpt = providerUtils.createWaypoint(c); Waypoint wpt = providerUtils.createWaypoint(c);
Log.d(Constants.TAG, "SendToFusionTables: Creating waypoint."); Log.d(Constants.TAG, "SendToFusionTables: Creating waypoint.");
success = createNewPoint(wpt.getName(), wpt.getDescription(), wpt.getLocation(), success = createNewPoint(wpt.getName(), wpt.getDescription(), wpt.getLocation(),
MARKER_TYPE_WAYPOINT); MARKER_TYPE_WAYPOINT);
if (!success) { if (!success) {
break; break;
} }
} }
} }
@@ -681,8 +682,8 @@ public class SendToFusionTables implements Runnable {
boolean success = response.isSuccessStatusCode; boolean success = response.isSuccessStatusCode;
if (success) { if (success) {
byte[] result = new byte[1024]; byte[] result = new byte[1024];
response.getContent().read(result); int read = response.getContent().read(result);
String s = Strings.fromBytesUtf8(result); String s = new String(result, 0, read, Charset.forName("UTF8"));
String[] lines = s.split(Strings.LINE_SEPARATOR); String[] lines = s.split(Strings.LINE_SEPARATOR);
if (lines[0].equals("tableid")) { if (lines[0].equals("tableid")) {
tableId = lines[1]; tableId = lines[1];
@@ -195,7 +195,7 @@ class TrackWriterImpl implements TrackWriter {
directory, track.getName(), writer.getExtension()); directory, track.getName(), writer.getExtension());
if (fileName == null) { if (fileName == null) {
Log.e(Constants.TAG, Log.e(Constants.TAG,
"Unable to get a unique filename for " + fileName); "Unable to get a unique filename for " + track.getName());
return false; return false;
} }
@@ -1,12 +1,12 @@
/* /*
* Copyright 2010 Google Inc. * Copyright 2010 Google Inc.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); you may not * Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of * use this file except in compliance with the License. You may obtain a copy of
* the License at * the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
@@ -137,7 +137,7 @@ public class AndroidGDataClient implements GDataClient {
/* /*
* (non-Javadoc) * (non-Javadoc)
* *
* @see GDataClient#encodeUri(java.lang.String) * @see GDataClient#encodeUri(java.lang.String)
*/ */
public String encodeUri(String uri) { public String encodeUri(String uri) {
@@ -155,7 +155,7 @@ public class AndroidGDataClient implements GDataClient {
/* /*
* (non-Javadoc) * (non-Javadoc)
* *
* @see com.google.wireless.gdata.client.GDataClient#createQueryParams() * @see com.google.wireless.gdata.client.GDataClient#createQueryParams()
*/ */
public QueryParams createQueryParams() { public QueryParams createQueryParams() {
@@ -273,7 +273,7 @@ public class AndroidGDataClient implements GDataClient {
String errorMessage = null; String errorMessage = null;
HttpEntity entity = response.getEntity(); HttpEntity entity = response.getEntity();
try { try {
if (response != null && entity != null) { if (entity != null) {
InputStream in = entity.getContent(); InputStream in = entity.getContent();
ByteArrayOutputStream baos = new ByteArrayOutputStream(); ByteArrayOutputStream baos = new ByteArrayOutputStream();
byte[] buf = new byte[8192]; byte[] buf = new byte[8192];
@@ -329,7 +329,7 @@ public class AndroidGDataClient implements GDataClient {
/* /*
* (non-Javadoc) * (non-Javadoc)
* *
* @see GDataClient#getFeedAsStream(java.lang.String, java.lang.String) * @see GDataClient#getFeedAsStream(java.lang.String, java.lang.String)
*/ */
public InputStream getFeedAsStream(String feedUrl, String authToken) public InputStream getFeedAsStream(String feedUrl, String authToken)
@@ -358,7 +358,7 @@ public class AndroidGDataClient implements GDataClient {
/* /*
* (non-Javadoc) * (non-Javadoc)
* *
* @see GDataClient#createEntry * @see GDataClient#createEntry
*/ */
public InputStream createEntry(String feedUrl, String authToken, public InputStream createEntry(String feedUrl, String authToken,
@@ -377,7 +377,7 @@ public class AndroidGDataClient implements GDataClient {
/* /*
* (non-Javadoc) * (non-Javadoc)
* *
* @see GDataClient#updateEntry * @see GDataClient#updateEntry
*/ */
public InputStream updateEntry(String editUri, String authToken, public InputStream updateEntry(String editUri, String authToken,
@@ -395,7 +395,7 @@ public class AndroidGDataClient implements GDataClient {
/* /*
* (non-Javadoc) * (non-Javadoc)
* *
* @see GDataClient#deleteEntry * @see GDataClient#deleteEntry
*/ */
public void deleteEntry(String editUri, String authToken) public void deleteEntry(String editUri, String authToken)
@@ -3,7 +3,6 @@ package com.google.android.apps.mytracks.io.mymaps;
import com.google.android.maps.GeoPoint; import com.google.android.maps.GeoPoint;
import java.io.Serializable;
import java.util.Vector; import java.util.Vector;
/** /**
@@ -12,7 +11,7 @@ import java.util.Vector;
* {@link MyMapsFeatureMetadata} object so that it can be more efficiently * {@link MyMapsFeatureMetadata} object so that it can be more efficiently
* transmitted to other activities. * transmitted to other activities.
*/ */
class MyMapsFeature implements Serializable { class MyMapsFeature {
private static final long serialVersionUID = 8439035544430497236L; private static final long serialVersionUID = 8439035544430497236L;
@@ -102,7 +101,7 @@ class MyMapsFeature implements Serializable {
* *
* @param description The new description of this feature * @param description The new description of this feature
*/ */
public synchronized void setDescription(String description) { public void setDescription(String description) {
featureInfo.setDescription(description); featureInfo.setDescription(description);
} }
@@ -196,7 +195,7 @@ class MyMapsFeature implements Serializable {
* *
* @param title The new title of this feature * @param title The new title of this feature
*/ */
public synchronized void setTitle(String title) { public void setTitle(String title) {
featureInfo.setTitle(title); featureInfo.setTitle(title);
} }
@@ -207,7 +206,7 @@ class MyMapsFeature implements Serializable {
* @param type The new type of the feature. That type must be one of * @param type The new type of the feature. That type must be one of
* {@link #MARKER}, {@link #LINE}, or {@link #SHAPE} * {@link #MARKER}, {@link #LINE}, or {@link #SHAPE}
*/ */
public synchronized void setType(int type) { public void setType(int type) {
featureInfo.setType(type); featureInfo.setType(type);
} }
@@ -217,7 +216,7 @@ class MyMapsFeature implements Serializable {
* *
* @param color The new ARGB color of this feature * @param color The new ARGB color of this feature
*/ */
public synchronized void setColor(int color) { public void setColor(int color) {
featureInfo.setColor(color); featureInfo.setColor(color);
} }
@@ -227,7 +226,7 @@ class MyMapsFeature implements Serializable {
* *
* @param url The new icon url of the feature * @param url The new icon url of the feature
*/ */
public synchronized void setIconUrl(String url) { public void setIconUrl(String url) {
featureInfo.setIconUrl(url); featureInfo.setIconUrl(url);
} }
} }
@@ -82,6 +82,6 @@ class MyMapsFeatureMetadata {
} }
public void setIconUrl(String url) { public void setIconUrl(String url) {
iconUrl = new String(url); iconUrl = url;
} }
} }
@@ -23,7 +23,7 @@ class MyMapsMapMetadata {
} }
public void setTitle(String title) { public void setTitle(String title) {
this.title = new String(title); this.title = title;
} }
public String getDescription() { public String getDescription() {
@@ -31,7 +31,7 @@ class MyMapsMapMetadata {
} }
public void setDescription(String description) { public void setDescription(String description) {
this.description = new String(description); this.description = description;
} }
public boolean getSearchable() { public boolean getSearchable() {
@@ -47,6 +47,6 @@ class MyMapsMapMetadata {
} }
public void setGDataEditUri(String editUri) { public void setGDataEditUri(String editUri) {
this.gdataEditUri = new String(editUri); this.gdataEditUri = editUri;
} }
} }
@@ -85,8 +85,8 @@ class XmlMapsGDataParserFactory implements GDataParserFactory {
@Override @Override
public GDataSerializer createSerializer(Entry en) { public GDataSerializer createSerializer(Entry en) {
if (en.getClass() == MapFeatureEntry.class) { if (en instanceof MapFeatureEntry) {
return new XmlMapsGDataSerializer(xmlFactory, en); return new XmlMapsGDataSerializer(xmlFactory, (MapFeatureEntry) en);
} else { } else {
return new XmlEntryGDataSerializer(xmlFactory, en); return new XmlEntryGDataSerializer(xmlFactory, en);
} }
@@ -1,7 +1,6 @@
// Copyright 2010 Google Inc. All Rights Reserved. // Copyright 2010 Google Inc. All Rights Reserved.
package com.google.android.apps.mytracks.io.mymaps; package com.google.android.apps.mytracks.io.mymaps;
import com.google.wireless.gdata.data.Entry;
import com.google.wireless.gdata.data.StringUtils; import com.google.wireless.gdata.data.StringUtils;
import com.google.wireless.gdata.parser.ParseException; import com.google.wireless.gdata.parser.ParseException;
import com.google.wireless.gdata.parser.xml.XmlGDataParser; import com.google.wireless.gdata.parser.xml.XmlGDataParser;
@@ -10,14 +9,14 @@ import com.google.wireless.gdata.serializer.xml.XmlEntryGDataSerializer;
import android.util.Log; import android.util.Log;
import org.xmlpull.v1.XmlPullParserException;
import org.xmlpull.v1.XmlSerializer;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
import java.io.IOException; import java.io.IOException;
import java.io.OutputStream; import java.io.OutputStream;
import java.util.Map; import java.util.Map;
import org.xmlpull.v1.XmlPullParserException;
import org.xmlpull.v1.XmlSerializer;
/** /**
* Serializer of maps data for GData. * Serializer of maps data for GData.
*/ */
@@ -29,11 +28,11 @@ class XmlMapsGDataSerializer extends XmlEntryGDataSerializer {
private XmlParserFactory factory; private XmlParserFactory factory;
private OutputStream stream; private OutputStream stream;
public XmlMapsGDataSerializer(XmlParserFactory factory, Entry entry) { public XmlMapsGDataSerializer(XmlParserFactory factory, MapFeatureEntry entry) {
super(factory, entry); super(factory, entry);
this.factory = factory; this.factory = factory;
this.entry = (MapFeatureEntry) entry; this.entry = entry;
} }
@Override @Override
@@ -15,20 +15,20 @@
*/ */
package com.google.android.apps.mytracks.services; package com.google.android.apps.mytracks.services;
import static com.google.android.apps.mytracks.Constants.TAG;
import static com.google.android.apps.mytracks.Constants.RESUME_TRACK_EXTRA_NAME; import static com.google.android.apps.mytracks.Constants.RESUME_TRACK_EXTRA_NAME;
import static com.google.android.apps.mytracks.Constants.TAG;
import com.google.android.apps.mytracks.MyTracks;
import com.google.android.apps.mytracks.Constants; import com.google.android.apps.mytracks.Constants;
import com.google.android.apps.mytracks.MyTracks;
import com.google.android.apps.mytracks.content.MyTracksLocation; import com.google.android.apps.mytracks.content.MyTracksLocation;
import com.google.android.apps.mytracks.content.MyTracksProviderUtils; import com.google.android.apps.mytracks.content.MyTracksProviderUtils;
import com.google.android.apps.mytracks.content.Sensor; import com.google.android.apps.mytracks.content.Sensor;
import com.google.android.apps.mytracks.content.Sensor.SensorDataSet;
import com.google.android.apps.mytracks.content.Track; import com.google.android.apps.mytracks.content.Track;
import com.google.android.apps.mytracks.content.TracksColumns; import com.google.android.apps.mytracks.content.TracksColumns;
import com.google.android.apps.mytracks.content.Waypoint; import com.google.android.apps.mytracks.content.Waypoint;
import com.google.android.apps.mytracks.content.WaypointCreationRequest; import com.google.android.apps.mytracks.content.WaypointCreationRequest;
import com.google.android.apps.mytracks.content.WaypointsColumns; import com.google.android.apps.mytracks.content.WaypointsColumns;
import com.google.android.apps.mytracks.content.Sensor.SensorDataSet;
import com.google.android.apps.mytracks.services.sensors.SensorManager; import com.google.android.apps.mytracks.services.sensors.SensorManager;
import com.google.android.apps.mytracks.services.sensors.SensorManagerFactory; import com.google.android.apps.mytracks.services.sensors.SensorManagerFactory;
import com.google.android.apps.mytracks.services.tasks.PeriodicTaskExecutor; import com.google.android.apps.mytracks.services.tasks.PeriodicTaskExecutor;
@@ -56,7 +56,6 @@ import android.location.Location;
import android.location.LocationListener; import android.location.LocationListener;
import android.location.LocationManager; import android.location.LocationManager;
import android.net.Uri; import android.net.Uri;
import android.os.Binder;
import android.os.Bundle; import android.os.Bundle;
import android.os.Handler; import android.os.Handler;
import android.os.IBinder; import android.os.IBinder;
@@ -570,7 +569,6 @@ public class TrackRecordingService extends Service implements LocationListener {
recordingTrackId)) { recordingTrackId)) {
return; return;
} }
lastRecordedLocationId++;
} }
} else { } else {
Log.d(TAG, Log.d(TAG,
@@ -845,7 +843,7 @@ public class TrackRecordingService extends Service implements LocationListener {
"shouldResumeTrack: lastModified = " + lastModified "shouldResumeTrack: lastModified = " + lastModified
+ ", autoResumeTrackTimeout: " + autoResumeTrackTimeout); + ", autoResumeTrackTimeout: " + autoResumeTrackTimeout);
return lastModified > 0 && System.currentTimeMillis() - lastModified <= return lastModified > 0 && System.currentTimeMillis() - lastModified <=
autoResumeTrackTimeout * 60 * 1000; autoResumeTrackTimeout * 60L * 1000L;
} }
public boolean isRecording() { public boolean isRecording() {
@@ -1,12 +1,12 @@
/* /*
* Copyright 2010 Google Inc. * Copyright 2010 Google Inc.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); you may not * Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of * use this file except in compliance with the License. You may obtain a copy of
* the License at * the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
@@ -67,7 +67,7 @@ public class PeriodicTaskExecutor {
if (!service.isRecording()) { if (!service.isRecording()) {
return; return;
} }
if (!isTimeFrequency()) { if (!isTimeFrequency()) {
if (timerExecutor != null) { if (timerExecutor != null) {
timerExecutor.shutdown(); timerExecutor.shutdown();
@@ -77,7 +77,7 @@ public class PeriodicTaskExecutor {
if (taskFrequency == 0) { if (taskFrequency == 0) {
return; return;
} }
// Try to make the task. // Try to make the task.
task = factory.create(service); task = factory.create(service);
// Returning null is ok. // Returning null is ok.
@@ -90,7 +90,7 @@ public class PeriodicTaskExecutor {
if (timerExecutor == null) { if (timerExecutor == null) {
timerExecutor = new TimerTaskExecutor(task, service); timerExecutor = new TimerTaskExecutor(task, service);
} }
timerExecutor.scheduleTask(taskFrequency * 60000); timerExecutor.scheduleTask(taskFrequency * 60000L);
} else { } else {
// For distance based splits. // For distance based splits.
calculateNextTaskDistance(); calculateNextTaskDistance();
@@ -119,7 +119,7 @@ public class PeriodicTaskExecutor {
if (!service.isRecording() || task == null) { if (!service.isRecording() || task == null) {
return; return;
} }
if (!isDistanceFrequency()) { if (!isDistanceFrequency()) {
nextTaskDistance = Double.MAX_VALUE; nextTaskDistance = Double.MAX_VALUE;
Log.d(TAG, "SplitManager: Distance splits disabled."); Log.d(TAG, "SplitManager: Distance splits disabled.");
@@ -1,12 +1,12 @@
/* /*
* Copyright 2008 Google Inc. * Copyright 2008 Google Inc.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); you may not * Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of * use this file except in compliance with the License. You may obtain a copy of
* the License at * the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
@@ -57,10 +57,11 @@ public class ResourceUtils {
public static void readBinaryFileToOutputStream( public static void readBinaryFileToOutputStream(
Context activity, int id, OutputStream os) { Context activity, int id, OutputStream os) {
BufferedInputStream in = null; BufferedInputStream in = null;
BufferedOutputStream out = null;
try { try {
in = new BufferedInputStream( in = new BufferedInputStream(
activity.getResources().openRawResource(id)); activity.getResources().openRawResource(id));
BufferedOutputStream out = new BufferedOutputStream(os); out = new BufferedOutputStream(os);
int b; int b;
while ((b = in.read()) != -1) { while ((b = in.read()) != -1) {
out.write(b); out.write(b);
@@ -76,6 +77,14 @@ public class ResourceUtils {
// Ignore // Ignore
} }
} }
if (out != null) {
try {
out.close();
} catch (IOException e) {
// Ignore
}
}
} }
} }
@@ -1,12 +1,12 @@
/* /*
* Copyright 2010 Google Inc. * Copyright 2010 Google Inc.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); you may not * Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of * use this file except in compliance with the License. You may obtain a copy of
* the License at * the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
@@ -15,10 +15,10 @@
*/ */
package com.google.android.apps.mytracks.signalstrength; package com.google.android.apps.mytracks.signalstrength;
import static com.google.android.apps.mytracks.signalstrength.SignalStrengthConstants.*; import static com.google.android.apps.mytracks.signalstrength.SignalStrengthConstants.START_SAMPLING;
import static com.google.android.apps.mytracks.signalstrength.SignalStrengthConstants.STOP_SAMPLING;
import static com.google.android.apps.mytracks.signalstrength.SignalStrengthConstants.TAG;
import com.google.android.apps.mytracks.content.MyTracksProviderUtils;
import com.google.android.apps.mytracks.content.MyTracksProviderUtilsImpl;
import com.google.android.apps.mytracks.content.WaypointCreationRequest; import com.google.android.apps.mytracks.content.WaypointCreationRequest;
import com.google.android.apps.mytracks.services.ITrackRecordingService; import com.google.android.apps.mytracks.services.ITrackRecordingService;
import com.google.android.apps.mytracks.signalstrength.SignalStrengthListener.SignalStrengthCallback; import com.google.android.apps.mytracks.signalstrength.SignalStrengthListener.SignalStrengthCallback;
@@ -206,7 +206,7 @@ public class SignalStrengthService extends Service
// Tell the user we've stopped // Tell the user we've stopped
Toast.makeText(this, R.string.stopped_sampling, Toast.LENGTH_SHORT).show(); Toast.makeText(this, R.string.stopped_sampling, Toast.LENGTH_SHORT).show();
// Stop // Stop
stopSelf(); stopSelf();
} }