From bccfbaa03b4adc078a7b5b8a22dc242c39fc39e9 Mon Sep 17 00:00:00 2001 From: Rodrigo Damazio Date: Tue, 12 Jul 2011 20:42:25 -0300 Subject: [PATCH] Style and warning fixes. --- .../android/apps/mytracks/ChartActivity.java | 1 + .../apps/mytracks/DeleteAllTracks.java | 14 ++-- .../android/apps/mytracks/MyTracks.java | 8 +-- .../apps/mytracks/SettingsActivity.java | 2 +- .../android/apps/mytracks/WaypointsList.java | 18 ++--- .../apps/mytracks/content/TrackDataHub.java | 45 ++++++------- .../apps/mytracks/io/SendToFusionTables.java | 4 +- .../io/backup/BackupActivityHelper.java | 2 +- .../mytracks/io/backup/DatabaseDumper.java | 4 +- .../apps/mytracks/io/docs/DocsHelper.java | 66 +++++++++---------- .../apps/mytracks/io/file/CsvTrackWriter.java | 9 +-- .../apps/mytracks/io/file/GpxTrackWriter.java | 1 + .../apps/mytracks/io/file/KmlTrackWriter.java | 7 +- .../apps/mytracks/io/file/SaveActivity.java | 1 + .../apps/mytracks/io/file/TcxTrackWriter.java | 1 + .../mytracks/io/file/TrackWriterImpl.java | 4 +- .../io/file/WriteProgressController.java | 2 +- .../mytracks/services/PreferenceManager.java | 24 +++---- .../services/TrackRecordingService.java | 41 ++++-------- .../sensors/ant/AntSensorManager.java | 4 +- .../services/tasks/StatusAnnouncerTask.java | 10 +-- .../apps/mytracks/util/ApiFeatures.java | 7 +- .../apps/mytracks/util/LocationUtils.java | 26 ++++---- .../mytracks/widgets/TrackWidgetProvider.java | 4 +- .../gdata/docs/XmlDocsGDataParserFactory.java | 13 ++-- .../mytracks/io/file/GpxImporterTest.java | 26 +++----- .../mytracks/io/file/KmlTrackWriterTest.java | 4 +- .../sendtogoogle/ResultListAdapterTest.java | 1 + .../services/TrackRecordingServiceTest.java | 2 +- .../sensors/ant/AntSensorManagerTest.java | 1 + .../SignalStrengthListenerCupcake.java | 11 ++-- .../SignalStrengthListenerEclair.java | 9 +-- .../signalstrength/SignalStrengthService.java | 6 +- 33 files changed, 185 insertions(+), 193 deletions(-) diff --git a/MyTracks/src/com/google/android/apps/mytracks/ChartActivity.java b/MyTracks/src/com/google/android/apps/mytracks/ChartActivity.java index 57ed2233b..ca4ac742f 100644 --- a/MyTracks/src/com/google/android/apps/mytracks/ChartActivity.java +++ b/MyTracks/src/com/google/android/apps/mytracks/ChartActivity.java @@ -463,6 +463,7 @@ public class ChartActivity extends Activity implements TrackDataListener { return true; // Reload data } + @SuppressWarnings("hiding") @Override public boolean onReportSpeedChanged(boolean reportSpeed) { boolean changed = reportSpeed != this.reportSpeed; diff --git a/MyTracks/src/com/google/android/apps/mytracks/DeleteAllTracks.java b/MyTracks/src/com/google/android/apps/mytracks/DeleteAllTracks.java index 13c1598ed..55516eb36 100644 --- a/MyTracks/src/com/google/android/apps/mytracks/DeleteAllTracks.java +++ b/MyTracks/src/com/google/android/apps/mytracks/DeleteAllTracks.java @@ -1,12 +1,12 @@ /* * Copyright 2008 Google Inc. - * + * * 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 * the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the @@ -56,8 +56,8 @@ public class DeleteAllTracks extends Handler { builder.setIcon(android.R.drawable.ic_dialog_alert); builder.setPositiveButton(context.getString(R.string.yes), new DialogInterface.OnClickListener() { - public void onClick(DialogInterface dialog, int i) { - dialog.dismiss(); + public void onClick(DialogInterface dialogInterface, int i) { + dialogInterface.dismiss(); Log.w(Constants.TAG, "deleting all!"); MyTracksProviderUtils.Factory.get(context).deleteAllTracks(); SharedPreferences prefs = @@ -74,8 +74,8 @@ public class DeleteAllTracks extends Handler { }); builder.setNegativeButton(context.getString(R.string.no), new DialogInterface.OnClickListener() { - public void onClick(DialogInterface dialog, int i) { - dialog.dismiss(); + public void onClick(DialogInterface dialogInterface, int i) { + dialogInterface.dismiss(); } }); dialog = builder.create(); diff --git a/MyTracks/src/com/google/android/apps/mytracks/MyTracks.java b/MyTracks/src/com/google/android/apps/mytracks/MyTracks.java index ed3914120..2a72052cb 100644 --- a/MyTracks/src/com/google/android/apps/mytracks/MyTracks.java +++ b/MyTracks/src/com/google/android/apps/mytracks/MyTracks.java @@ -386,8 +386,8 @@ public class MyTracks extends TabActivity implements OnTouchListener { builder.setIcon(android.R.drawable.ic_dialog_alert); builder.setPositiveButton(getString(R.string.yes), new DialogInterface.OnClickListener() { - public void onClick(DialogInterface dialog, int i) { - dialog.dismiss(); + public void onClick(DialogInterface dialogInterface, int i) { + dialogInterface.dismiss(); providerUtils.deleteTrack(trackId); if (trackId == dataHub.getSelectedTrackId()) { dataHub.unloadCurrentTrack(); @@ -395,8 +395,8 @@ public class MyTracks extends TabActivity implements OnTouchListener { }}); builder.setNegativeButton(getString(R.string.no), new DialogInterface.OnClickListener() { - public void onClick(DialogInterface dialog, int i) { - dialog.dismiss(); + public void onClick(DialogInterface dialogInterface, int i) { + dialogInterface.dismiss(); } }); dialog = builder.create(); diff --git a/MyTracks/src/com/google/android/apps/mytracks/SettingsActivity.java b/MyTracks/src/com/google/android/apps/mytracks/SettingsActivity.java index 45822ddb7..b2316ab29 100644 --- a/MyTracks/src/com/google/android/apps/mytracks/SettingsActivity.java +++ b/MyTracks/src/com/google/android/apps/mytracks/SettingsActivity.java @@ -340,7 +340,7 @@ public class SettingsActivity extends PreferenceActivity { .setPositiveButton(android.R.string.ok, new OnClickListener() { @Override - public void onClick(DialogInterface dialog, int button) { + public void onClick(DialogInterface dialogInterface, int button) { onResetPreferencesConfirmed(); } }) diff --git a/MyTracks/src/com/google/android/apps/mytracks/WaypointsList.java b/MyTracks/src/com/google/android/apps/mytracks/WaypointsList.java index 8c96698f1..f3f713902 100644 --- a/MyTracks/src/com/google/android/apps/mytracks/WaypointsList.java +++ b/MyTracks/src/com/google/android/apps/mytracks/WaypointsList.java @@ -59,7 +59,7 @@ public class WaypointsList extends ListActivity private int contextPosition = -1; private long trackId = -1; - private long waypointId = -1; + private long selectedWaypointId = -1; private ListView listView = null; private Button insertWaypointButton = null; private Button insertStatisticsButton = null; @@ -77,7 +77,7 @@ public class WaypointsList extends ListActivity AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) menuInfo; contextPosition = info.position; - waypointId = WaypointsList.this.listView.getAdapter() + selectedWaypointId = WaypointsList.this.listView.getAdapter() .getItemId(contextPosition); Waypoint waypoint = providerUtils.getWaypoint(info.id); if (waypoint != null) { @@ -108,18 +108,18 @@ public class WaypointsList extends ListActivity if (!super.onMenuItemSelected(featureId, item)) { switch (item.getItemId()) { case Constants.MENU_SHOW: { - onListItemClick(null, null, 0, waypointId); + onListItemClick(null, null, 0, selectedWaypointId); return true; } case Constants.MENU_EDIT: { Intent intent = new Intent(this, WaypointDetails.class); intent.putExtra("trackid", trackId); - intent.putExtra(WaypointDetails.WAYPOINT_ID_EXTRA, waypointId); + intent.putExtra(WaypointDetails.WAYPOINT_ID_EXTRA, selectedWaypointId); startActivity(intent); return true; } case Constants.MENU_DELETE: { - deleteWaypoint(waypointId); + deleteWaypoint(selectedWaypointId); } } } @@ -297,8 +297,8 @@ public class WaypointsList extends ListActivity builder.setPositiveButton(getString(R.string.yes), new DialogInterface.OnClickListener() { @Override - public void onClick(DialogInterface dialog, int i) { - dialog.dismiss(); + public void onClick(DialogInterface dialogInterface, int i) { + dialogInterface.dismiss(); providerUtils.deleteWaypoint(waypointId, new StringUtils(WaypointsList.this)); } @@ -306,8 +306,8 @@ public class WaypointsList extends ListActivity builder.setNegativeButton(getString(R.string.no), new DialogInterface.OnClickListener() { @Override - public void onClick(DialogInterface dialog, int i) { - dialog.dismiss(); + public void onClick(DialogInterface dialogInterface, int i) { + dialogInterface.dismiss(); } }); dialog = builder.create(); diff --git a/MyTracks/src/com/google/android/apps/mytracks/content/TrackDataHub.java b/MyTracks/src/com/google/android/apps/mytracks/content/TrackDataHub.java index 47f57fafb..f80e0662b 100644 --- a/MyTracks/src/com/google/android/apps/mytracks/content/TrackDataHub.java +++ b/MyTracks/src/com/google/android/apps/mytracks/content/TrackDataHub.java @@ -154,7 +154,7 @@ public class TrackDataHub { private Handler listenerHandler; /** Manager for external listeners (those from activities). */ - private final TrackDataListeners listeners; + private final TrackDataListeners dataListeners; /** Wrapper for interacting with system data managers. */ private DataSourcesWrapper dataSources; @@ -213,7 +213,7 @@ public class TrackDataHub { TrackDataHub(Context ctx, TrackDataListeners listeners, SharedPreferences preferences, MyTracksProviderUtils providerUtils, int targetNumPoints) { this.context = ctx; - this.listeners = listeners; + this.dataListeners = listeners; this.preferences = preferences; this.providerUtils = providerUtils; this.targetNumPoints = targetNumPoints; @@ -437,8 +437,9 @@ public class TrackDataHub { public void registerTrackDataListener( TrackDataListener listener, EnumSet dataTypes) { - synchronized (listeners) { - ListenerRegistration registration = listeners.registerTrackDataListener(listener, dataTypes); + synchronized (dataListeners) { + ListenerRegistration registration = + dataListeners.registerTrackDataListener(listener, dataTypes); // Don't load any data or start internal listeners if start() hasn't been // called. When it is called, we'll do both things. @@ -451,8 +452,8 @@ public class TrackDataHub { } public void unregisterTrackDataListener(TrackDataListener listener) { - synchronized (listeners) { - listeners.unregisterTrackDataListener(listener); + synchronized (dataListeners) { + dataListeners.unregisterTrackDataListener(listener); // Don't load any data or start internal listeners if start() hasn't been // called. When it is called, we'll do both things. @@ -467,8 +468,8 @@ public class TrackDataHub { */ public void reloadDataForListener(TrackDataListener listener) { ListenerRegistration registration; - synchronized (listeners) { - registration = listeners.getRegistration(listener); + synchronized (dataListeners) { + registration = dataListeners.getRegistration(listener); registration.resetState(); loadNewDataForListener(registration); } @@ -477,7 +478,7 @@ public class TrackDataHub { /** * Reloads all track data received so far into the specified listeners. * - * Assumes it's called from a block that synchronizes on {@link #listeners}. + * Assumes it's called from a block that synchronizes on {@link #dataListeners}. */ private void loadNewDataForListener(final ListenerRegistration registration) { if (!isStarted()) { @@ -492,7 +493,7 @@ public class TrackDataHub { // If a listener happens to be added after this method but before the Runnable below is // executed, it will have triggered a separate call to load data only up to the point this // listener got to. This is ensured by being synchronized on listeners. - final boolean isOnlyListener = (listeners.getNumListeners() == 1); + final boolean isOnlyListener = (dataListeners.getNumListeners() == 1); runInListenerThread(new Runnable() { @SuppressWarnings("unchecked") @@ -577,8 +578,8 @@ public class TrackDataHub { Log.w(TAG, "Not started, not reloading"); return; } - synchronized (listeners) { - if (!listeners.hasListeners()) { + synchronized (dataListeners) { + if (!dataListeners.hasListeners()) { Log.d(TAG, "No listeners, not reloading"); return; } @@ -651,7 +652,7 @@ public class TrackDataHub { for (TrackDataListener listener : displayListeners) { // TODO: Do the reloading just once for all interested listeners if (listener.onReportSpeedChanged(reportSpeed)) { - synchronized (listeners) { + synchronized (dataListeners) { reloadDataForListener(listener); } } @@ -671,7 +672,7 @@ public class TrackDataHub { for (TrackDataListener listener : displayListeners) { if (listener.onUnitsChanged(useMetricUnits)) { - synchronized (listeners) { + synchronized (dataListeners) { reloadDataForListener(listener); } } @@ -739,7 +740,7 @@ public class TrackDataHub { if (isGpsLocation) { // We consider a good fix to be a recent one with reasonable accuracy. hasFix = !isLocationOld(location, now, MAX_LOCATION_AGE_MS); - hasGoodFix = (location != null && location.getAccuracy() <= minRequiredAccuracy); + hasGoodFix = (location.getAccuracy() <= minRequiredAccuracy); } else { if (!isLocationOld(lastSeenLocation, now, MAX_LOCATION_AGE_MS)) { // This is a network location, but we have a recent/valid GPS location, just ignore this. @@ -961,7 +962,7 @@ public class TrackDataHub { Log.i(TAG, "Resampling point set after " + numLoadedPoints + " points."); resetState(); - synchronized (listeners) { + synchronized (dataListeners) { sampledListeners = getListenersFor(ListenerDataType.POINT_UPDATES); sampledOutListeners = getListenersFor(ListenerDataType.SAMPLED_OUT_POINT_UPDATES); } @@ -1046,7 +1047,7 @@ public class TrackDataHub { listener.onNewTrackPointsDone(); // Update the listener state - ListenerRegistration registration = listeners.getRegistration(listener); + ListenerRegistration registration = dataListeners.getRegistration(listener); if (registration != null) { registration.lastTrackId = currentSelectedTrackId; registration.lastPointId = localLastSeenLocationId; @@ -1059,7 +1060,7 @@ public class TrackDataHub { private void notifyNewPoint(Location location, long locationId, long lastStoredLocationId, - int numLoadedPoints, + int loadedPoints, int pointSamplingFrequency, Set sampledListeners, Set sampledOutListeners) { @@ -1078,7 +1079,7 @@ public class TrackDataHub { // - Is the last point and we are not recording this track. boolean recordingSelected = isRecordingSelected(); boolean includeInSample = - (numLoadedPoints % pointSamplingFrequency == 0 || + (loadedPoints % pointSamplingFrequency == 0 || (!recordingSelected && locationId == lastStoredLocationId)); if (!includeInSample) { @@ -1106,13 +1107,13 @@ public class TrackDataHub { } private Set getListenersFor(ListenerDataType type) { - synchronized (listeners) { - return listeners.getListenersFor(type); + synchronized (dataListeners) { + return dataListeners.getListenersFor(type); } } private EnumSet getNeededListenerTypes() { - EnumSet neededTypes = listeners.getAllRegisteredTypes(); + EnumSet neededTypes = dataListeners.getAllRegisteredTypes(); // We always want preference updates. neededTypes.add(ListenerDataType.DISPLAY_PREFERENCES); diff --git a/MyTracks/src/com/google/android/apps/mytracks/io/SendToFusionTables.java b/MyTracks/src/com/google/android/apps/mytracks/io/SendToFusionTables.java index 5e7ae4977..c08269ffe 100644 --- a/MyTracks/src/com/google/android/apps/mytracks/io/SendToFusionTables.java +++ b/MyTracks/src/com/google/android/apps/mytracks/io/SendToFusionTables.java @@ -196,7 +196,7 @@ public class SendToFusionTables implements Runnable { // Create a new table: progressIndicator.setProgressValue(PROGRESS_FUSION_TABLE_CREATE); progressIndicator.setProgressMessage(R.string.progress_message_creating_fusiontable); - if (!createNewTable(track) || !makeTableUnlisted(tableId)) { + if (!createNewTable(track) || !makeTableUnlisted()) { return; } @@ -245,7 +245,7 @@ public class SendToFusionTables implements Runnable { return runUpdate(query); } - private boolean makeTableUnlisted(String tableId) { + private boolean makeTableUnlisted() { Log.d(Constants.TAG, "Setting visibility to unlisted."); String query = "UPDATE TABLE " + tableId + " SET VISIBILITY = UNLISTED"; return runUpdate(query); diff --git a/MyTracks/src/com/google/android/apps/mytracks/io/backup/BackupActivityHelper.java b/MyTracks/src/com/google/android/apps/mytracks/io/backup/BackupActivityHelper.java index 6d80c8153..9db785705 100644 --- a/MyTracks/src/com/google/android/apps/mytracks/io/backup/BackupActivityHelper.java +++ b/MyTracks/src/com/google/android/apps/mytracks/io/backup/BackupActivityHelper.java @@ -185,7 +185,7 @@ public class BackupActivityHelper { */ private void restoreFromDateAsync(final Date date) { // Show a progress dialog - final ProgressDialog progressDialog = ProgressDialog.show( + ProgressDialog.show( activity, activity.getString(R.string.progress_title), activity.getString(R.string.backup_import_progress_message), diff --git a/MyTracks/src/com/google/android/apps/mytracks/io/backup/DatabaseDumper.java b/MyTracks/src/com/google/android/apps/mytracks/io/backup/DatabaseDumper.java index 59f35317f..64f2a0625 100644 --- a/MyTracks/src/com/google/android/apps/mytracks/io/backup/DatabaseDumper.java +++ b/MyTracks/src/com/google/android/apps/mytracks/io/backup/DatabaseDumper.java @@ -85,7 +85,7 @@ class DatabaseDumper { public void writeHeaders(Cursor cursor, int numRows, DataOutputStream writer) throws IOException { initializeCachedValues(cursor); - writeQueryMetadata(cursor, numRows, writer); + writeQueryMetadata(numRows, writer); } /** @@ -151,7 +151,7 @@ class DatabaseDumper { * @throws IOException if there are any errors while writing */ private void writeQueryMetadata( - Cursor cursor, int numRows, DataOutputStream writer) throws IOException { + int numRows, DataOutputStream writer) throws IOException { // Write column data writer.writeInt(columnNames.length); for (int i = 0; i < columnNames.length; i++) { diff --git a/MyTracks/src/com/google/android/apps/mytracks/io/docs/DocsHelper.java b/MyTracks/src/com/google/android/apps/mytracks/io/docs/DocsHelper.java index abb052dc8..560246ba5 100644 --- a/MyTracks/src/com/google/android/apps/mytracks/io/docs/DocsHelper.java +++ b/MyTracks/src/com/google/android/apps/mytracks/io/docs/DocsHelper.java @@ -69,22 +69,22 @@ public class DocsHelper { private static final String OPENDOCUMENT_SPREADSHEET_MIME_TYPE = "application/x-vnd.oasis.opendocument.spreadsheet"; private static final String ATOM_FEED_MIME_TYPE = "application/atom+xml"; - + /** * Creates a new MyTracks spreadsheet with the given name. - * + * * @param context The context associated with this request. * @param docListWrapper The GData handle for the Document List service. * @param name The name for the newly-created spreadsheet. * @return The spreadsheet ID, if one is created. {@code null} will be * returned if a GData error didn't occur, but no spreadsheet ID was - * returned. + * returned. */ - public String createSpreadsheet(final Context context, + public String createSpreadsheet(final Context context, final GDataWrapper docListWrapper, final String name) throws IOException { final AtomicReference idSaver = new AtomicReference(); - boolean result = docListWrapper.runQuery(new QueryFunction() { + boolean success = docListWrapper.runQuery(new QueryFunction() { @Override public void query(GDataServiceClient client) throws IOException, GDataWrapper.AuthenticationException { @@ -95,7 +95,7 @@ public class DocsHelper { OPENDOCUMENT_SPREADSHEET_MIME_TYPE); conn.addRequestProperty("Slug", name); conn.addRequestProperty("Authorization", - "GoogleLogin auth=" + + "GoogleLogin auth=" + docListWrapper.getAuthManager().getAuthToken()); conn.setDoOutput(true); OutputStream os = conn.getOutputStream(); @@ -141,24 +141,24 @@ public class DocsHelper { if (idStringStart == -1) { return; } - + String id = result.substring( idStringStart + DOCS_SPREADSHEET_URL.length(), idTagCloseIndex); Log.i(Constants.TAG, "Created new spreadsheet: " + id); idSaver.set(id); }}); - - if (!result) { - throw newIOException(docListWrapper, + + if (!success) { + throw newIOException(docListWrapper, "Failed to create new spreadsheet."); } - + return idSaver.get(); } /** * Retrieve the ID of a spreadsheet with the given name. - * + * * @param docListWrapper The GData handle for the Document List service. * @param title The name of the spreadsheet whose ID is to be retrieved. * @return The spreadsheet ID, if it can be retrieved. {@code null} will @@ -177,7 +177,7 @@ public class DocsHelper { GDataParser listParser; try { listParser = client.getParserForFeed(Entry.class, - DOCS_MY_SPREADSHEETS_FEED_URL, + DOCS_MY_SPREADSHEETS_FEED_URL, docListWrapper.getAuthManager().getAuthToken()); listParser.init(); @@ -201,22 +201,22 @@ public class DocsHelper { }); if (!result) { - throw newIOException(docListWrapper, + throw newIOException(docListWrapper, "Failed to retrieve spreadsheet list."); } - + return idSaver.get(); } /** * Retrieve the ID of the first worksheet in the named spreadsheet. - * + * * @param trixWrapper The GData handle for the spreadsheet service. * @param spreadsheetId The GData ID for the given spreadsheet. * @return The worksheet ID, if it can be retrieved. {@code null} will be * returned if the GData request returns without error, but without an * ID. - * @throws IOException If an error occurs during the GData request. + * @throws IOException If an error occurs during the GData request. */ public String getWorksheetId(final GDataWrapper trixWrapper, final String spreadsheetId) throws IOException { @@ -250,17 +250,17 @@ public class DocsHelper { } } }); - + if (!result) { throw newIOException(trixWrapper, "Failed to retrieve worksheet ID."); } - + return idSaver.get(); } - + /** * Add a row to a worksheet containing the stats for a given track. - * + * * @param context The context associated with this request. * @param trixAuth The GData authorization for the spreadsheet service. * @param spreadsheetId The spreadsheet to be modified. @@ -270,17 +270,17 @@ public class DocsHelper { * imperial units will be used. * @throws IOException If an error occurs while updating the worksheet. */ - public void addTrackRow(Context context, AuthManager trixAuth, - String spreadsheetId, String worksheetId, Track track, + public void addTrackRow(Context context, AuthManager trixAuth, + String spreadsheetId, String worksheetId, Track track, boolean metricUnits) throws IOException { - + String worksheetUri = String.format(DOCS_SPREADSHEET_URL_FORMAT, spreadsheetId, worksheetId); TripStatistics stats = track.getStatistics(); - - String distanceUnit = context.getString(metricUnits ? + + String distanceUnit = context.getString(metricUnits ? R.string.kilometer : R.string.mile); - String speedUnit = context.getString(metricUnits ? + String speedUnit = context.getString(metricUnits ? R.string.kilometer_per_hour : R.string.mile_per_hour); String elevationUnit = context.getString(metricUnits ? R.string.meter : R.string.feet); @@ -310,7 +310,7 @@ public class DocsHelper { tagBuilder.append("map", String.format("%s?msa=0&msid=%s", Constants.MAPSHOP_BASE_URL, track.getMapId())); } - + String postText = new StringBuilder() .append(" 0) { service.setRecordingTrackId(recordingTrackId); @@ -167,7 +167,7 @@ public class PreferenceManager implements OnSharedPreferenceChangeListener { sharedPreferences.getBoolean(metricUnitsKey, true)); } } - + public void setAutoResumeTrackCurrentRetry(int retryAttempts) { sharedPreferences .edit() @@ -181,14 +181,14 @@ public class PreferenceManager implements OnSharedPreferenceChangeListener { .putLong(recordingTrackKey, id) .commit(); } - + public void setSelectedTrack(long id) { sharedPreferences .edit() .putLong(selectedTrackKey, id) .commit(); } - + public void shutdown() { sharedPreferences.unregisterOnSharedPreferenceChangeListener(this); service = null; diff --git a/MyTracks/src/com/google/android/apps/mytracks/services/TrackRecordingService.java b/MyTracks/src/com/google/android/apps/mytracks/services/TrackRecordingService.java index 4984ce340..117ce50ba 100644 --- a/MyTracks/src/com/google/android/apps/mytracks/services/TrackRecordingService.java +++ b/MyTracks/src/com/google/android/apps/mytracks/services/TrackRecordingService.java @@ -301,7 +301,7 @@ public class TrackRecordingService extends Service { private void resumeTrack(int startId) { Log.d(TAG, "TrackRecordingService: requested resume"); - + // Make sure that the current track exists and is fresh enough. if (recordingTrack == null || !shouldResumeTrack(recordingTrack)) { Log.i(TAG, @@ -312,7 +312,7 @@ public class TrackRecordingService extends Service { stopSelfResult(startId); return; } - + Log.i(TAG, "TrackRecordingService: resuming"); } @@ -361,7 +361,7 @@ public class TrackRecordingService extends Service { super.onDestroy(); } - private void setAutoResumeTrackRetries(SharedPreferences sharedPreferences, int retryAttempts) { + private void setAutoResumeTrackRetries(int retryAttempts) { Log.d(TAG, "Updating auto-resume retry attempts to: " + retryAttempts); prefManager.setAutoResumeTrackCurrentRetry(retryAttempts); } @@ -386,7 +386,7 @@ public class TrackRecordingService extends Service { } // Increase number of retry attempts. - setAutoResumeTrackRetries(sharedPreferences, retries + 1); + setAutoResumeTrackRetries(retries + 1); // Check for special cases. if (autoResumeTrackTimeout == 0) { @@ -579,8 +579,7 @@ public class TrackRecordingService extends Service { } // Reset the number of auto-resume retries. - setAutoResumeTrackRetries( - getSharedPreferences(Constants.SETTINGS_NAME, 0), 0); + setAutoResumeTrackRetries(0); // Persist the current recording track. prefManager.setRecordingTrack(recordingTrackId); @@ -695,8 +694,6 @@ public class TrackRecordingService extends Service { } Location lastRecordedLocation = providerUtils.getLastLocation(); - long lastRecordedLocationId = - providerUtils.getLastLocationId(recordingTrackId); double distanceToLastRecorded = Double.POSITIVE_INFINITY; if (lastRecordedLocation != null) { distanceToLastRecorded = location.distanceTo(lastRecordedLocation); @@ -722,9 +719,7 @@ public class TrackRecordingService extends Service { // Need to write the last location. This will happen when // lastRecordedLocation.distance(lastLocation) < // minRecordingDistance - if (!insertLocation(recordingTrack, lastLocation, - lastRecordedLocation, lastRecordedLocationId, - recordingTrackId)) { + if (!insertLocation(lastLocation, lastRecordedLocation, recordingTrackId)) { return; } } @@ -737,11 +732,9 @@ public class TrackRecordingService extends Service { if (lastLocation != null && !isMoving) { // Last location was the last stationary location. Need to go back and // add it. - if (!insertLocation(recordingTrack, lastLocation, - lastRecordedLocation, lastRecordedLocationId, recordingTrackId)) { + if (!insertLocation(lastLocation, lastRecordedLocation, recordingTrackId)) { return; } - lastRecordedLocationId++; isMoving = true; } @@ -762,8 +755,7 @@ public class TrackRecordingService extends Service { providerUtils.insertTrackPoint(separator, recordingTrackId); } - if (!insertLocation(recordingTrack, location, lastRecordedLocation, - lastRecordedLocationId, recordingTrackId)) { + if (!insertLocation(location, lastRecordedLocation, recordingTrackId)) { return; } } else { @@ -790,18 +782,13 @@ public class TrackRecordingService extends Service { * Inserts a new location in the track points db and updates the corresponding * track in the track db. * - * @param recordingTrack the track that is currently being recorded * @param location the location to be inserted * @param lastRecordedLocation the last recorded location before this one (or * null if none) - * @param lastRecordedLocationId the id of the last recorded location (or -1 - * if none) * @param trackId the id of the track * @return true if successful. False if SQLite3 threw an exception. */ - private boolean insertLocation(Track recordingTrack, Location location, - Location lastRecordedLocation, long lastRecordedLocationId, - long trackId) { + private boolean insertLocation(Location location, Location lastRecordedLocation, long trackId) { // Keep track of length along recorded track (needed when a waypoint is // inserted): @@ -1003,22 +990,22 @@ public class TrackRecordingService extends Service { announcementExecutor.shutdown(); splitExecutor.shutdown(); isRecording = false; - Track recordingTrack = providerUtils.getTrack(recordingTrackId); - if (recordingTrack != null) { - TripStatistics stats = recordingTrack.getStatistics(); + Track recordedTrack = providerUtils.getTrack(recordingTrackId); + if (recordedTrack != null) { + TripStatistics stats = recordedTrack.getStatistics(); stats.setStopTime(System.currentTimeMillis()); stats.setTotalTime(stats.getStopTime() - stats.getStartTime()); long lastRecordedLocationId = providerUtils.getLastLocationId(recordingTrackId); ContentValues values = new ContentValues(); if (lastRecordedLocationId >= 0 - && recordingTrack.getStopId() >= 0) { + && recordedTrack.getStopId() >= 0) { values.put(TracksColumns.STOPID, lastRecordedLocationId); } values.put(TracksColumns.STOPTIME, stats.getStopTime()); values.put(TracksColumns.TOTALTIME, stats.getTotalTime()); getContentResolver().update(TracksColumns.CONTENT_URI, values, - "_id=" + recordingTrack.getId(), null); + "_id=" + recordedTrack.getId(), null); } showNotification(); long recordedTrackId = recordingTrackId; diff --git a/MyTracks/src/com/google/android/apps/mytracks/services/sensors/ant/AntSensorManager.java b/MyTracks/src/com/google/android/apps/mytracks/services/sensors/ant/AntSensorManager.java index 1f8e04f67..d8a37a55d 100644 --- a/MyTracks/src/com/google/android/apps/mytracks/services/sensors/ant/AntSensorManager.java +++ b/MyTracks/src/com/google/android/apps/mytracks/services/sensors/ant/AntSensorManager.java @@ -82,7 +82,7 @@ public abstract class AntSensorManager extends SensorManager { /** Receives and logs all status ANT intents. */ private final BroadcastReceiver statusReceiver = new BroadcastReceiver() { @Override - public void onReceive(Context context, Intent intent) { + public void onReceive(Context ctx, Intent intent) { String antAction = intent.getAction(); Log.i(TAG, "enter status onReceive" + antAction); } @@ -91,7 +91,7 @@ public abstract class AntSensorManager extends SensorManager { /** Receives all data ANT intents. */ private final BroadcastReceiver dataReceiver = new BroadcastReceiver() { @Override - public void onReceive(Context context, Intent intent) { + public void onReceive(Context ctx, Intent intent) { String antAction = intent.getAction(); Log.i(TAG, "enter data onReceive" + antAction); diff --git a/MyTracks/src/com/google/android/apps/mytracks/services/tasks/StatusAnnouncerTask.java b/MyTracks/src/com/google/android/apps/mytracks/services/tasks/StatusAnnouncerTask.java index 637f97c46..389130423 100644 --- a/MyTracks/src/com/google/android/apps/mytracks/services/tasks/StatusAnnouncerTask.java +++ b/MyTracks/src/com/google/android/apps/mytracks/services/tasks/StatusAnnouncerTask.java @@ -130,10 +130,12 @@ public class StatusAnnouncerTask implements PeriodicTask { return; } - checkReady(); - if (!ready) { - Log.e(TAG, "StatusAnnouncer Tts not ready."); - return; + synchronized (this) { + checkReady(); + if (!ready) { + Log.e(TAG, "StatusAnnouncer Tts not ready."); + return; + } } if (!speechAllowed) { diff --git a/MyTracks/src/com/google/android/apps/mytracks/util/ApiFeatures.java b/MyTracks/src/com/google/android/apps/mytracks/util/ApiFeatures.java index 26fb3a31c..04e88baa4 100644 --- a/MyTracks/src/com/google/android/apps/mytracks/util/ApiFeatures.java +++ b/MyTracks/src/com/google/android/apps/mytracks/util/ApiFeatures.java @@ -35,7 +35,7 @@ public class ApiFeatures { Build.VERSION.SDK); private static ApiFeatures instance; - + /** * The API platform adapter supported by this system. */ @@ -54,6 +54,7 @@ public class ApiFeatures { /** * Injects a specific singleton instance, to be used for unit tests. */ + @SuppressWarnings("hiding") public static void injectInstance(ApiFeatures instance) { ApiFeatures.instance = instance; } @@ -106,11 +107,11 @@ public class ApiFeatures { public boolean hasStrictMode() { return getApiLevel() >= 9; } - + public boolean isAudioFocusSupported() { return getApiLevel() >= 8; } - + /** * There's a bug (#1587) in Cupcake and Donut which prevents you from * using a SQLiteQueryBuilder twice. That is, if you call buildQuery diff --git a/MyTracks/src/com/google/android/apps/mytracks/util/LocationUtils.java b/MyTracks/src/com/google/android/apps/mytracks/util/LocationUtils.java index 1786cf3a6..ca879526b 100644 --- a/MyTracks/src/com/google/android/apps/mytracks/util/LocationUtils.java +++ b/MyTracks/src/com/google/android/apps/mytracks/util/LocationUtils.java @@ -1,12 +1,12 @@ /* * Copyright 2008 Google Inc. - * + * * 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 * the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the @@ -30,14 +30,14 @@ import java.util.Stack; /** * Utility class for decimating tracks at a given level of precision. - * + * * @author Leif Hendrik Wilden */ public class LocationUtils { /** * Computes the distance on the two sphere between the point c0 and the line * segment c1 to c2. - * + * * @param c0 the first coordinate * @param c1 the beginning of the line segment * @param c2 the end of the lone segment @@ -79,7 +79,7 @@ public class LocationUtils { /** * Decimates the given locations for a given zoom level. This uses a * Douglas-Peucker decimation algorithm. - * + * * @param tolerance in meters * @param locations input * @param decimated output @@ -142,7 +142,7 @@ public class LocationUtils { /** * Decimates the given track for the given precision. - * + * * @param track a track * @param precision desired precision in meters */ @@ -155,7 +155,7 @@ public class LocationUtils { /** * Limits number of points by dropping any points beyond the given number of * points. Note: That'll actually discard points. - * + * * @param track a track * @param numberOfPoints maximum number of points */ @@ -169,7 +169,7 @@ public class LocationUtils { /** * Splits a track in multiple tracks where each piece has less or equal than * maxPoints. - * + * * @param track the track to split * @param maxPoints maximum number of points for each piece * @return a list of one or more track pieces @@ -197,14 +197,14 @@ public class LocationUtils { result.add(piece); } n += (pieceLocations.size() - 1); - } while (n < nTotal && piece != null && piece.getLocations().size() > 1); + } while (n < nTotal && piece.getLocations().size() > 1); return result; } /** * Test if a given GeoPoint is valid, i.e. within physical bounds. - * + * * @param geoPoint the point to be tested * @return true, if it is a physical location on earth. */ @@ -218,7 +218,7 @@ public class LocationUtils { * on Earth. Note: The special separator locations (which have latitude = * 100) will not qualify as valid. Neither will locations with lat=0 and lng=0 * as these are most likely "bad" measurements which often cause trouble. - * + * * @param location the location to test * @return true if the location is a valid location. */ @@ -229,7 +229,7 @@ public class LocationUtils { /** * Gets a location from a GeoPoint. - * + * * @param p a GeoPoint * @return the corresponding location */ diff --git a/MyTracks/src/com/google/android/apps/mytracks/widgets/TrackWidgetProvider.java b/MyTracks/src/com/google/android/apps/mytracks/widgets/TrackWidgetProvider.java index 6177e99a9..5ee51fdc0 100644 --- a/MyTracks/src/com/google/android/apps/mytracks/widgets/TrackWidgetProvider.java +++ b/MyTracks/src/com/google/android/apps/mytracks/widgets/TrackWidgetProvider.java @@ -58,12 +58,12 @@ public class TrackWidgetProvider public TrackObserver() { super(contentHandler); } - + public void onChange(boolean selfChange) { updateTrack(null); } } - + private final Handler contentHandler; private MyTracksProviderUtils providerUtils; private Context context; diff --git a/MyTracks/src/com/google/wireless/gdata/docs/XmlDocsGDataParserFactory.java b/MyTracks/src/com/google/wireless/gdata/docs/XmlDocsGDataParserFactory.java index f350dc0dd..5e9a7d913 100644 --- a/MyTracks/src/com/google/wireless/gdata/docs/XmlDocsGDataParserFactory.java +++ b/MyTracks/src/com/google/wireless/gdata/docs/XmlDocsGDataParserFactory.java @@ -1,12 +1,12 @@ /* * Copyright 2010 Google Inc. - * + * * 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 * the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the @@ -48,20 +48,19 @@ public class XmlDocsGDataParserFactory implements GDataParserFactory { } } - @SuppressWarnings({ "unchecked", "rawtypes" }) + @SuppressWarnings("rawtypes") @Override public GDataParser createParser(Class cls, InputStream is) throws ParseException { try { - return createParserForClass(cls, is); + return createParserForClass(is); } catch (XmlPullParserException e) { e.printStackTrace(); return null; } } - private GDataParser createParserForClass( - Class cls, InputStream is) + private GDataParser createParserForClass(InputStream is) throws ParseException, XmlPullParserException { return new XmlGDataParser(is, xmlFactory.createParser()); } diff --git a/MyTracksTest/src/com/google/android/apps/mytracks/io/file/GpxImporterTest.java b/MyTracksTest/src/com/google/android/apps/mytracks/io/file/GpxImporterTest.java index e676aae88..7b9b0398e 100644 --- a/MyTracksTest/src/com/google/android/apps/mytracks/io/file/GpxImporterTest.java +++ b/MyTracksTest/src/com/google/android/apps/mytracks/io/file/GpxImporterTest.java @@ -48,7 +48,7 @@ import org.xml.sax.SAXException; /** * Tests for the GPX importer. - * + * * @author Steffen Horlacher */ public class GpxImporterTest extends AndroidTestCase { @@ -180,51 +180,45 @@ public class GpxImporterTest extends AndroidTestCase { /** * Test with invalid location - track should be deleted. */ - public void testImportLocationFailure() throws ParserConfigurationException, - SAXException, IOException { + public void testImportLocationFailure() throws ParserConfigurationException, IOException { testInvalidXML(INVALID_LOCATION_TEST_GPX); } /** * Test with invalid time - track should be deleted. */ - public void testImportTimeFailure() throws ParserConfigurationException, - SAXException, IOException { + public void testImportTimeFailure() throws ParserConfigurationException, IOException { testInvalidXML(INVALID_TIME_TEST_GPX); } /** * Test with invalid xml - track should be deleted. */ - public void testImportXMLFailure() throws ParserConfigurationException, - SAXException, IOException { + public void testImportXMLFailure() throws ParserConfigurationException, IOException { testInvalidXML(INVALID_XML_TEST_GPX); } - + /** * Test with invalid altitude - track should be deleted. */ - public void testImportInvalidAltitude() throws ParserConfigurationException, - SAXException, IOException { + public void testImportInvalidAltitude() throws ParserConfigurationException, IOException { testInvalidXML(INVALID_ALTITUDE_TEST_GPX); } /** * Test with invalid latitude - track should be deleted. */ - public void testImportInvalidLatitude() throws ParserConfigurationException, - SAXException, IOException { + public void testImportInvalidLatitude() throws ParserConfigurationException, IOException { testInvalidXML(INVALID_LATITUDE_TEST_GPX); } - + /** * Test with invalid longitude - track should be deleted. */ - public void testImportInvalidLongitude() throws ParserConfigurationException, - SAXException, IOException { + public void testImportInvalidLongitude() throws ParserConfigurationException, IOException { testInvalidXML(INVALID_LONGITUDE_TEST_GPX); } - + private void testInvalidXML(String xml) throws ParserConfigurationException, IOException { expect(providerUtils.insertTrack((Track) AndroidMock.anyObject())) diff --git a/MyTracksTest/src/com/google/android/apps/mytracks/io/file/KmlTrackWriterTest.java b/MyTracksTest/src/com/google/android/apps/mytracks/io/file/KmlTrackWriterTest.java index 1a3deee16..559867f2b 100644 --- a/MyTracksTest/src/com/google/android/apps/mytracks/io/file/KmlTrackWriterTest.java +++ b/MyTracksTest/src/com/google/android/apps/mytracks/io/file/KmlTrackWriterTest.java @@ -31,9 +31,9 @@ public class KmlTrackWriterTest extends TrackFormatWriterTest { } @Override - public String generateTrackDescription(Track track, + public String generateTrackDescription(Track trackToDescribe, Vector distances, Vector elevations) { - assertSame(KmlTrackWriterTest.super.track, track); + assertSame(KmlTrackWriterTest.super.track, trackToDescribe); assertTrue(distances.isEmpty()); assertTrue(elevations.isEmpty()); return FULL_TRACK_DESCRIPTION; diff --git a/MyTracksTest/src/com/google/android/apps/mytracks/io/sendtogoogle/ResultListAdapterTest.java b/MyTracksTest/src/com/google/android/apps/mytracks/io/sendtogoogle/ResultListAdapterTest.java index eb0dcb5f2..3adea385b 100644 --- a/MyTracksTest/src/com/google/android/apps/mytracks/io/sendtogoogle/ResultListAdapterTest.java +++ b/MyTracksTest/src/com/google/android/apps/mytracks/io/sendtogoogle/ResultListAdapterTest.java @@ -59,6 +59,7 @@ public class ResultListAdapterTest extends AndroidTestCase { this.urlId = urlId; } + @SuppressWarnings("hiding") private void saveContentView(View contentView) { if (this.contentView == null) { this.contentView = contentView; diff --git a/MyTracksTest/src/com/google/android/apps/mytracks/services/TrackRecordingServiceTest.java b/MyTracksTest/src/com/google/android/apps/mytracks/services/TrackRecordingServiceTest.java index 64444be9f..87c2a35a5 100644 --- a/MyTracksTest/src/com/google/android/apps/mytracks/services/TrackRecordingServiceTest.java +++ b/MyTracksTest/src/com/google/android/apps/mytracks/services/TrackRecordingServiceTest.java @@ -331,7 +331,7 @@ public class TrackRecordingServiceTest } @Override - public void onReceive(Context context, Intent intent) { + public void onReceive(Context ctx, Intent intent) { Log.d("MyTracksTest", "Got broadcast: " + intent); synchronized (receivedIntents) { receivedIntents.add(intent); diff --git a/MyTracksTest/src/com/google/android/apps/mytracks/services/sensors/ant/AntSensorManagerTest.java b/MyTracksTest/src/com/google/android/apps/mytracks/services/sensors/ant/AntSensorManagerTest.java index 7f57b9ba4..540eab2f3 100644 --- a/MyTracksTest/src/com/google/android/apps/mytracks/services/sensors/ant/AntSensorManagerTest.java +++ b/MyTracksTest/src/com/google/android/apps/mytracks/services/sensors/ant/AntSensorManagerTest.java @@ -38,6 +38,7 @@ public class AntSensorManagerTest extends AndroidTestCase { super.handleMessage(rawMessage); } + @SuppressWarnings("hiding") @Override public boolean handleMessage(byte messageId, byte[] messageData) { this.messageId = messageId; diff --git a/SignalStrengthSampler/src/com/google/android/apps/mytracks/signalstrength/SignalStrengthListenerCupcake.java b/SignalStrengthSampler/src/com/google/android/apps/mytracks/signalstrength/SignalStrengthListenerCupcake.java index 4fdb68a80..b519d3d2e 100644 --- a/SignalStrengthSampler/src/com/google/android/apps/mytracks/signalstrength/SignalStrengthListenerCupcake.java +++ b/SignalStrengthSampler/src/com/google/android/apps/mytracks/signalstrength/SignalStrengthListenerCupcake.java @@ -1,12 +1,12 @@ /* * Copyright 2010 Google Inc. - * + * * 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 * the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the @@ -28,7 +28,7 @@ import java.util.List; /** * A class to monitor the network signal strength. - * + * * TODO: i18n * * @author Sandor Dornbush @@ -60,6 +60,7 @@ public class SignalStrengthListenerCupcake extends PhoneStateListener return PhoneStateListener.LISTEN_SIGNAL_STRENGTH; } + @SuppressWarnings("hiding") @Override public void onSignalStrengthChanged(int signalStrength) { Log.d(TAG, "Signal Strength: " + signalStrength); @@ -95,7 +96,7 @@ public class SignalStrengthListenerCupcake extends PhoneStateListener /** * Builds a description for the current signal strength. - * + * * @return A human readable description of the network state */ private String getDescription() { diff --git a/SignalStrengthSampler/src/com/google/android/apps/mytracks/signalstrength/SignalStrengthListenerEclair.java b/SignalStrengthSampler/src/com/google/android/apps/mytracks/signalstrength/SignalStrengthListenerEclair.java index f5f0e2d00..c5be86a39 100644 --- a/SignalStrengthSampler/src/com/google/android/apps/mytracks/signalstrength/SignalStrengthListenerEclair.java +++ b/SignalStrengthSampler/src/com/google/android/apps/mytracks/signalstrength/SignalStrengthListenerEclair.java @@ -1,12 +1,12 @@ /* * Copyright 2010 Google Inc. - * + * * 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 * the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the @@ -26,7 +26,7 @@ import android.util.Log; /** * A class to monitor the network signal strength. - * + * * TODO: i18n * * @author Sandor Dornbush @@ -44,6 +44,7 @@ public class SignalStrengthListenerEclair extends SignalStrengthListenerCupcake return PhoneStateListener.LISTEN_SIGNAL_STRENGTHS; } + @SuppressWarnings("hiding") @Override public void onSignalStrengthsChanged(SignalStrength signalStrength) { Log.d(TAG, "Signal Strength Modern: " + signalStrength); diff --git a/SignalStrengthSampler/src/com/google/android/apps/mytracks/signalstrength/SignalStrengthService.java b/SignalStrengthSampler/src/com/google/android/apps/mytracks/signalstrength/SignalStrengthService.java index 70d417368..f90b11e45 100644 --- a/SignalStrengthSampler/src/com/google/android/apps/mytracks/signalstrength/SignalStrengthService.java +++ b/SignalStrengthSampler/src/com/google/android/apps/mytracks/signalstrength/SignalStrengthService.java @@ -69,16 +69,16 @@ public class SignalStrengthService extends Service @Override public void onStart(Intent intent, int startId) { - handleCommand(intent, startId); + handleCommand(intent); } @Override public int onStartCommand(Intent intent, int flags, int startId) { - handleCommand(intent, startId); + handleCommand(intent); return START_STICKY; } - private void handleCommand(Intent intent, int startId) { + private void handleCommand(Intent intent) { String action = intent.getAction(); if (START_SAMPLING.equals(action)) { startSampling();