forked from upstream-mirrors/OpenTracks
Addressed comments.
Merge from head.
This commit is contained in:
@@ -119,6 +119,9 @@ limitations under the License.
|
|||||||
<uses-permission android:name="android.permission.BLUETOOTH" />
|
<uses-permission android:name="android.permission.BLUETOOTH" />
|
||||||
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
|
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
|
||||||
|
|
||||||
|
<uses-permission android:name="com.dsi.ant.permission.ANT" />
|
||||||
|
<uses-permission android:name="com.dsi.ant.permission.ANT_ADMIN" />
|
||||||
|
|
||||||
<!-- Permissions for uploading tracks -->
|
<!-- Permissions for uploading tracks -->
|
||||||
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
|
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
|
||||||
<uses-permission android:name="android.permission.MANAGE_ACCOUNTS" />
|
<uses-permission android:name="android.permission.MANAGE_ACCOUNTS" />
|
||||||
|
|||||||
@@ -213,18 +213,15 @@ limitations under the License.
|
|||||||
|
|
||||||
<string name="eclair_required">Only supported in Android 2.0 or above</string>
|
<string name="eclair_required">Only supported in Android 2.0 or above</string>
|
||||||
<string name="settings_sensor_type">Sensor Type</string>
|
<string name="settings_sensor_type">Sensor Type</string>
|
||||||
<string name="settings_sensor_type_summary">The type of sensor to connect to.</string>
|
<string name="settings_sensor_type_summary">The type of sensor to connect to</string>
|
||||||
<string name="settings_heart_rate_ant_sensor_id">Clear ant heart rate sensor pairing.</string>
|
<string name="settings_heart_rate_ant_sensor_id">Clear ANT heart rate sensor pairing</string>
|
||||||
<string name="settings_power_ant_sensor_id">Clear ant power sensor pairing.</string>
|
<string name="settings_power_ant_sensor_id">Clear ANT power sensor pairing</string>
|
||||||
<string name="settings_srm_bridge_ant_sensor_id">Clear ant srm bridge sensor pairing.</string>
|
<string name="settings_srm_bridge_ant_sensor_id">Clear ANT srm bridge sensor pairing</string>
|
||||||
<string name="settings_ant_not_paired">Ant sensor not paired.</string>
|
<string name="settings_ant_not_paired">ANT sensor not paired</string>
|
||||||
<string name="settings_ant_paired">Ant sensor paired with: %d</string>
|
<string name="settings_ant_paired">ANT sensor paired with: %d</string>
|
||||||
<string name="sensor_id_malformed">The Id must be an integer value.</string>
|
|
||||||
<string name="bluetooth_sensor_title">Bluetooth sensor</string>
|
<string name="bluetooth_sensor_title">Bluetooth sensor</string>
|
||||||
<string name="bluetooth_sensor_summary">The bluetooth sensor to connect to.</string>
|
<string name="bluetooth_sensor_summary">The bluetooth sensor to connect to</string>
|
||||||
<string name="settings_modular_stats_display_title">Modular Stats Display</string>
|
<string name="settings_modular_stats_display_title">Modular Stats Display</string>
|
||||||
<string name="settings_modular_stats_display_summary_on">The stats screen is split in various modes.</string>
|
|
||||||
<string name="settings_modular_stats_display_summary_off">Display all stats on one screen</string>
|
|
||||||
|
|
||||||
<string name="settings_backup">Backup (BETA)</string>
|
<string name="settings_backup">Backup (BETA)</string>
|
||||||
<string name="settings_sd_backup">SD Card Backup</string>
|
<string name="settings_sd_backup">SD Card Backup</string>
|
||||||
|
|||||||
@@ -22,8 +22,8 @@ import android.preference.Preference;
|
|||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A preference for a ANT device pairing.
|
* A preference for an ANT device pairing.
|
||||||
* Currently this shows the id and lets the user clear that id for future pairing.
|
* Currently this shows the ID and lets the user clear that ID for future pairing.
|
||||||
* TODO: Support pairing from this preference.
|
* TODO: Support pairing from this preference.
|
||||||
*
|
*
|
||||||
* @author Sandor Dornbush
|
* @author Sandor Dornbush
|
||||||
@@ -45,9 +45,7 @@ public class AntPreference extends Preference {
|
|||||||
if (sensorId == 0) {
|
if (sensorId == 0) {
|
||||||
setSummary(R.string.settings_ant_not_paired);
|
setSummary(R.string.settings_ant_not_paired);
|
||||||
} else {
|
} else {
|
||||||
setSummary(
|
setSummary(String.format(getContext().getString(R.string.settings_ant_paired), sensorId));
|
||||||
String.format(
|
|
||||||
getContext().getString(R.string.settings_ant_paired), sensorId));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add actions to allow repairing.
|
// Add actions to allow repairing.
|
||||||
|
|||||||
@@ -136,17 +136,24 @@ public class MyTracksProvider extends ContentProvider {
|
|||||||
@Override
|
@Override
|
||||||
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
|
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
|
||||||
if (oldVersion < 17) {
|
if (oldVersion < 17) {
|
||||||
|
// Wipe the old data.
|
||||||
Log.w(TAG, "Upgrading database from version " + oldVersion + " to "
|
Log.w(TAG, "Upgrading database from version " + oldVersion + " to "
|
||||||
+ newVersion + ", which will destroy all old data");
|
+ newVersion + ", which will destroy all old data");
|
||||||
db.execSQL("DROP TABLE IF EXISTS " + TRACKPOINTS_TABLE);
|
db.execSQL("DROP TABLE IF EXISTS " + TRACKPOINTS_TABLE);
|
||||||
db.execSQL("DROP TABLE IF EXISTS " + TRACKS_TABLE);
|
db.execSQL("DROP TABLE IF EXISTS " + TRACKS_TABLE);
|
||||||
db.execSQL("DROP TABLE IF EXISTS " + WAYPOINTS_TABLE);
|
db.execSQL("DROP TABLE IF EXISTS " + WAYPOINTS_TABLE);
|
||||||
onCreate(db);
|
onCreate(db);
|
||||||
} else if (oldVersion >= 17) {
|
} else {
|
||||||
Log.w(TAG, "Upgrading database from version " + oldVersion + " to "
|
// Incremental updates go here.
|
||||||
+ newVersion + ", adding sensor column.");
|
// Each time you increase the DB version, add a corresponding if clause.
|
||||||
db.execSQL("ALTER TABLE " + TRACKPOINTS_TABLE
|
|
||||||
+ " ADD " + TrackPointsColumns.SENSOR + " BLOB");
|
// Sensor data.
|
||||||
|
if (oldVersion <= 17) {
|
||||||
|
Log.w(TAG, "Upgrading database from version " + oldVersion + " to "
|
||||||
|
+ newVersion + ", adding sensor column.");
|
||||||
|
db.execSQL("ALTER TABLE " + TRACKPOINTS_TABLE
|
||||||
|
+ " ADD " + TrackPointsColumns.SENSOR + " BLOB");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -644,7 +644,6 @@ public class TrackRecordingService extends Service implements LocationListener {
|
|||||||
locationManager = (LocationManager) getSystemService(LOCATION_SERVICE);
|
locationManager = (LocationManager) getSystemService(LOCATION_SERVICE);
|
||||||
splitManager = new SplitManager(this);
|
splitManager = new SplitManager(this);
|
||||||
|
|
||||||
sensorManager = SensorManagerFactory.getSensorManager(this);
|
|
||||||
prefManager = new PreferenceManager(this);
|
prefManager = new PreferenceManager(this);
|
||||||
registerLocationListener();
|
registerLocationListener();
|
||||||
|
|
||||||
@@ -731,7 +730,7 @@ public class TrackRecordingService extends Service implements LocationListener {
|
|||||||
splitManager.shutdown();
|
splitManager.shutdown();
|
||||||
splitManager = null;
|
splitManager = null;
|
||||||
if (sensorManager != null) {
|
if (sensorManager != null) {
|
||||||
sensorManager.onDestroy();
|
sensorManager.shutdown();
|
||||||
sensorManager = null;
|
sensorManager = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1080,6 +1079,7 @@ public class TrackRecordingService extends Service implements LocationListener {
|
|||||||
showNotification();
|
showNotification();
|
||||||
registerLocationListener();
|
registerLocationListener();
|
||||||
splitManager.restore();
|
splitManager.restore();
|
||||||
|
sensorManager = SensorManagerFactory.getSensorManager(this);
|
||||||
if (sensorManager != null) {
|
if (sensorManager != null) {
|
||||||
sensorManager.onStartTrack();
|
sensorManager.onStartTrack();
|
||||||
}
|
}
|
||||||
@@ -1128,6 +1128,7 @@ public class TrackRecordingService extends Service implements LocationListener {
|
|||||||
|
|
||||||
if (sensorManager != null) {
|
if (sensorManager != null) {
|
||||||
sensorManager.shutdown();
|
sensorManager.shutdown();
|
||||||
|
sensorManager = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
releaseWakeLock();
|
releaseWakeLock();
|
||||||
|
|||||||
+17
-20
@@ -15,7 +15,7 @@
|
|||||||
*/
|
*/
|
||||||
package com.google.android.apps.mytracks.services.sensors;
|
package com.google.android.apps.mytracks.services.sensors;
|
||||||
|
|
||||||
import com.google.android.apps.mytracks.MyTracksConstants;
|
import static com.google.android.apps.mytracks.MyTracksConstants.TAG;
|
||||||
import com.google.android.apps.mytracks.MyTracksSettings;
|
import com.google.android.apps.mytracks.MyTracksSettings;
|
||||||
import com.google.android.apps.mytracks.content.Sensor;
|
import com.google.android.apps.mytracks.content.Sensor;
|
||||||
import com.google.android.maps.mytracks.R;
|
import com.google.android.maps.mytracks.R;
|
||||||
@@ -37,13 +37,13 @@ public class AntDirectSensorManager extends AntSensorManager {
|
|||||||
/*
|
/*
|
||||||
* These constants are defined by the ANT+ heart rate monitor spec.
|
* These constants are defined by the ANT+ heart rate monitor spec.
|
||||||
*/
|
*/
|
||||||
public static final byte HRM_CHANNEL = (byte) 0;
|
public static final byte HRM_CHANNEL = 0;
|
||||||
public static final byte NETWORK_NUMBER = (byte) 1;
|
public static final byte NETWORK_NUMBER = 1;
|
||||||
public static final byte HEART_RATE_DEVICE_TYPE = (byte) 120;
|
public static final byte HEART_RATE_DEVICE_TYPE = 120;
|
||||||
public static final byte POWER_DEVICE_TYPE = (byte) 11;
|
public static final byte POWER_DEVICE_TYPE = 11;
|
||||||
public static final byte MANUFACTURER_ID = (byte) 1;
|
public static final byte MANUFACTURER_ID = 1;
|
||||||
public static final short CHANNEL_PERIOD = (short) 8070;
|
public static final short CHANNEL_PERIOD = 8070;
|
||||||
public static final byte RF_FREQUENCY = (byte) 57;
|
public static final byte RF_FREQUENCY = 57;
|
||||||
|
|
||||||
private short deviceNumberHRM;
|
private short deviceNumberHRM;
|
||||||
|
|
||||||
@@ -59,8 +59,7 @@ public class AntDirectSensorManager extends AntSensorManager {
|
|||||||
deviceNumberHRM =
|
deviceNumberHRM =
|
||||||
(short) prefs.getInt(context.getString(R.string.ant_heart_rate_sensor_id_key), 0);
|
(short) prefs.getInt(context.getString(R.string.ant_heart_rate_sensor_id_key), 0);
|
||||||
}
|
}
|
||||||
Log.i(MyTracksConstants.TAG,
|
Log.i(TAG, "Pairing with heart rate monitor: " + deviceNumberHRM);
|
||||||
"Pairing with heart rate monitor: " + deviceNumberHRM);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -72,7 +71,7 @@ public class AntDirectSensorManager extends AntSensorManager {
|
|||||||
antDecodeHRM(antMessage);
|
antDecodeHRM(antMessage);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
Log.d(MyTracksConstants.TAG, "Unhandled message: " + channel);
|
Log.d(TAG, "Unhandled message: " + channel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -93,8 +92,7 @@ public class AntDirectSensorManager extends AntSensorManager {
|
|||||||
handleChannelId(antMessage);
|
handleChannelId(antMessage);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
Log.e(MyTracksConstants.TAG,
|
Log.e(TAG, "Unexpected message id: " + antMessage[3]);
|
||||||
"Unexpected message id: " + antMessage[3]);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -102,7 +100,7 @@ public class AntDirectSensorManager extends AntSensorManager {
|
|||||||
if (deviceNumberHRM == WILDCARD) {
|
if (deviceNumberHRM == WILDCARD) {
|
||||||
getAntReceiver().ANTRequestMessage(HRM_CHANNEL,
|
getAntReceiver().ANTRequestMessage(HRM_CHANNEL,
|
||||||
AntMesg.MESG_CHANNEL_ID_ID);
|
AntMesg.MESG_CHANNEL_ID_ID);
|
||||||
Log.d(MyTracksConstants.TAG, "Requesting channel id id.");
|
Log.d(TAG, "Requesting channel id id.");
|
||||||
}
|
}
|
||||||
|
|
||||||
setSensorState(Sensor.SensorState.CONNECTED);
|
setSensorState(Sensor.SensorState.CONNECTED);
|
||||||
@@ -122,7 +120,7 @@ public class AntDirectSensorManager extends AntSensorManager {
|
|||||||
deviceNumberHRM =
|
deviceNumberHRM =
|
||||||
(short) (((int) antMessage[3] & 0xFF |
|
(short) (((int) antMessage[3] & 0xFF |
|
||||||
((int) (antMessage[4] & 0xFF) << 8)) & 0xFFFF);
|
((int) (antMessage[4] & 0xFF) << 8)) & 0xFFFF);
|
||||||
Log.i(MyTracksConstants.TAG, "Found device id: " + deviceNumberHRM);
|
Log.i(TAG, "Found device id: " + deviceNumberHRM);
|
||||||
|
|
||||||
SharedPreferences prefs = context.getSharedPreferences(
|
SharedPreferences prefs = context.getSharedPreferences(
|
||||||
MyTracksSettings.SETTINGS_NAME, Context.MODE_PRIVATE);
|
MyTracksSettings.SETTINGS_NAME, Context.MODE_PRIVATE);
|
||||||
@@ -132,16 +130,15 @@ public class AntDirectSensorManager extends AntSensorManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void handleMessageResponse(byte[] antMessage) {
|
private void handleMessageResponse(byte[] antMessage) {
|
||||||
if (antMessage[3] == AntMesg.MESG_EVENT_ID
|
if (antMessage[3] == AntMesg.MESG_EVENT_ID &&
|
||||||
&& antMessage[4] == AntDefine.EVENT_RX_SEARCH_TIMEOUT) {
|
antMessage[4] == AntDefine.EVENT_RX_SEARCH_TIMEOUT) {
|
||||||
// Search timeout
|
// Search timeout
|
||||||
Log.w(MyTracksConstants.TAG, "Search timed out. Unassigning channel.");
|
Log.w(TAG, "Search timed out. Unassigning channel.");
|
||||||
getAntReceiver().ANTUnassignChannel((byte) 0);
|
getAntReceiver().ANTUnassignChannel((byte) 0);
|
||||||
setSensorState(Sensor.SensorState.DISCONNECTED);
|
setSensorState(Sensor.SensorState.DISCONNECTED);
|
||||||
} else if (antMessage[3] == AntMesg.MESG_UNASSIGN_CHANNEL_ID) {
|
} else if (antMessage[3] == AntMesg.MESG_UNASSIGN_CHANNEL_ID) {
|
||||||
setSensorState(Sensor.SensorState.DISCONNECTED);
|
setSensorState(Sensor.SensorState.DISCONNECTED);
|
||||||
Log.i(MyTracksConstants.TAG,
|
Log.i(TAG, "Disconnected from the sensor: " + getSensorState());
|
||||||
"Disconnected from the sensor: " + getSensorState());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+6
-7
@@ -48,15 +48,15 @@ public abstract class AntSensorManager extends SensorManager {
|
|||||||
private boolean status;
|
private boolean status;
|
||||||
|
|
||||||
// Flag to know if the ANT App was interrupted
|
// Flag to know if the ANT App was interrupted
|
||||||
// TODO this code path is not used but probably should be.
|
// TODO: This code path is not used but probably should be.
|
||||||
private boolean antInterrupted = false;
|
private boolean antInterrupted;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The data from the sensors.
|
* The data from the sensors.
|
||||||
*/
|
*/
|
||||||
protected SensorDataSet sensorData = null;
|
protected SensorDataSet sensorData;
|
||||||
|
|
||||||
protected Context context = null;
|
protected Context context;
|
||||||
|
|
||||||
private static final boolean DEBUGGING = false;
|
private static final boolean DEBUGGING = false;
|
||||||
|
|
||||||
@@ -133,7 +133,7 @@ public abstract class AntSensorManager extends SensorManager {
|
|||||||
// already called before
|
// already called before
|
||||||
if (antInterrupted == false) {
|
if (antInterrupted == false) {
|
||||||
status = antReceiver.enable();
|
status = antReceiver.enable();
|
||||||
if (status == false) {
|
if (!status) {
|
||||||
Log.e(MyTracksConstants.TAG, "Can not enable ANT interface");
|
Log.e(MyTracksConstants.TAG, "Can not enable ANT interface");
|
||||||
} else {
|
} else {
|
||||||
Log.i(MyTracksConstants.TAG, "Powering on Radio");
|
Log.i(MyTracksConstants.TAG, "Powering on Radio");
|
||||||
@@ -208,8 +208,7 @@ public abstract class AntSensorManager extends SensorManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Set search timeout to 30 seconds (low priority search))
|
// Set search timeout to 30 seconds (low priority search))
|
||||||
if (!antReceiver.ANTSetLowPriorityChannelSearchTimeout(channelNumber,
|
if (!antReceiver.ANTSetLowPriorityChannelSearchTimeout(channelNumber, (byte) 12)) {
|
||||||
(byte) 12)) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+3
-5
@@ -45,21 +45,19 @@ public class SensorManagerFactory {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
String sensor = prefs.getString(context.getString(R.string.sensor_type_key),
|
String sensor = prefs.getString(context.getString(R.string.sensor_type_key), null);
|
||||||
null);
|
|
||||||
Log.i(MyTracksConstants.TAG, "Creating sensor of type: " + sensor);
|
Log.i(MyTracksConstants.TAG, "Creating sensor of type: " + sensor);
|
||||||
|
|
||||||
if (sensor == null) {
|
if (sensor == null) {
|
||||||
return null;
|
return null;
|
||||||
} else if (sensor.equals(context.getString(R.string.ant_sensor_type))) {
|
} else if (sensor.equals(context.getString(R.string.ant_sensor_type))) {
|
||||||
return new AntDirectSensorManager(context);
|
return new AntDirectSensorManager(context);
|
||||||
} else if (sensor.equals(
|
} else if (sensor.equals(context.getString(R.string.srm_ant_bridge_sensor_type))) {
|
||||||
context.getString(R.string.srm_ant_bridge_sensor_type))) {
|
|
||||||
return new AntSRMSensorManager(context);
|
return new AntSRMSensorManager(context);
|
||||||
} else if (sensor.equals(context.getString(R.string.zephyr_sensor_type))) {
|
} else if (sensor.equals(context.getString(R.string.zephyr_sensor_type))) {
|
||||||
return new ZephyrSensorManager(context);
|
return new ZephyrSensorManager(context);
|
||||||
} else {
|
} else {
|
||||||
Log.w(MyTracksConstants.TAG, "Unable to find sensor type: " + sensor);
|
Log.w(MyTracksConstants.TAG, "Unable to find sensor type: " + sensor);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+1
@@ -35,6 +35,7 @@ public class ZephyrMessageParser implements MessageParser {
|
|||||||
}
|
}
|
||||||
Log.w(MyTracksConstants.TAG, "Got zephyr data: " + sb);
|
Log.w(MyTracksConstants.TAG, "Got zephyr data: " + sb);
|
||||||
// The provided units are 1/16 strides per minute.
|
// The provided units are 1/16 strides per minute.
|
||||||
|
// TODO: Fix the cadence calculation.
|
||||||
// int cadence = SensorUtils.unsignedShortToInt(buffer, 56);
|
// int cadence = SensorUtils.unsignedShortToInt(buffer, 56);
|
||||||
// Heart Rate
|
// Heart Rate
|
||||||
Sensor.SensorData.Builder b = Sensor.SensorData.newBuilder()
|
Sensor.SensorData.Builder b = Sensor.SensorData.newBuilder()
|
||||||
|
|||||||
+6
-15
@@ -180,8 +180,9 @@ public interface MyTracksProviderUtils {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Finds a track by given unique track id.
|
* Finds a track by given unique track id.
|
||||||
* Note that the returned track object does not have any track points
|
* Note that the returned track object does not have any track points attached.
|
||||||
* attached. Use {@link #getTrackPoints(Track, int)} to load the track points.
|
* Use {@link #getLocationIterator(long, long, boolean, LocationFactory)} to load
|
||||||
|
* the track points.
|
||||||
*
|
*
|
||||||
* @param id desired unique track id
|
* @param id desired unique track id
|
||||||
* @return a Track object, or null if not found
|
* @return a Track object, or null if not found
|
||||||
@@ -189,24 +190,14 @@ public interface MyTracksProviderUtils {
|
|||||||
Track getTrack(long id);
|
Track getTrack(long id);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves all tracks without track points. If no tracks exist an empty
|
* Retrieves all tracks without track points. If no tracks exist, an empty
|
||||||
* list will be returned. Use {@link #getTrackPoints(Track, int)} to load
|
* list will be returned. Use {@link #getLocationIterator(long, long, boolean, LocationFactory)}
|
||||||
* the track points.
|
* to load the track points.
|
||||||
*
|
*
|
||||||
* @return a list of all the recorded tracks
|
* @return a list of all the recorded tracks
|
||||||
*/
|
*/
|
||||||
List<Track> getAllTracks();
|
List<Track> getAllTracks();
|
||||||
|
|
||||||
/**
|
|
||||||
* Loads the track points for a given track.
|
|
||||||
*
|
|
||||||
* @param track assumes that startId and stopId are filled in correctly
|
|
||||||
* @param maxPoints maximum number of points to load, or -1 for no limit
|
|
||||||
* (oldest ones will be discarded)
|
|
||||||
* @return the id of the last location in the track
|
|
||||||
*/
|
|
||||||
long getTrackPoints(Track track, int maxPoints);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a cursor over the tracks provider with a given selection.
|
* Creates a cursor over the tracks provider with a given selection.
|
||||||
* Caller gets to own the returned cursor. Don't forget to close it.
|
* Caller gets to own the returned cursor. Don't forget to close it.
|
||||||
|
|||||||
-29
@@ -877,35 +877,6 @@ public class MyTracksProviderUtilsImpl implements MyTracksProviderUtils {
|
|||||||
return tracks;
|
return tracks;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public long getTrackPoints(Track track, int maxPoints) {
|
|
||||||
long lastId = -1;
|
|
||||||
Cursor cursor = getLocationsCursor(track.getId(), -1, maxPoints, true);
|
|
||||||
if (cursor == null) {
|
|
||||||
Log.w(TAG, "Cannot get a locations cursor!");
|
|
||||||
return lastId;
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
final int idColumnIdx =
|
|
||||||
cursor.getColumnIndexOrThrow(TrackPointsColumns._ID);
|
|
||||||
if (cursor.moveToLast()) {
|
|
||||||
do {
|
|
||||||
Location location = createLocation(cursor);
|
|
||||||
if (location == null) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
track.addLocation(location);
|
|
||||||
lastId = cursor.getLong(idColumnIdx);
|
|
||||||
} while (cursor.moveToPrevious());
|
|
||||||
}
|
|
||||||
} catch (RuntimeException e) {
|
|
||||||
Log.w(TAG, "Caught unexpected exception.", e);
|
|
||||||
} finally {
|
|
||||||
cursor.close();
|
|
||||||
}
|
|
||||||
return lastId;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Cursor getTracksCursor(String selection) {
|
public Cursor getTracksCursor(String selection) {
|
||||||
Cursor cursor = contentResolver.query(
|
Cursor cursor = contentResolver.query(
|
||||||
|
|||||||
+4
-7
@@ -28,23 +28,20 @@ public class SensorManagerFactoryTest extends AndroidTestCase {
|
|||||||
|
|
||||||
@SmallTest
|
@SmallTest
|
||||||
public void testCreateZephyr() throws Exception {
|
public void testCreateZephyr() throws Exception {
|
||||||
assertClassForName(
|
assertClassForName(ZephyrSensorManager.class, R.string.zephyr_sensor_type);
|
||||||
ZephyrSensorManager.class, R.string.zephyr_sensor_type);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@SmallTest
|
@SmallTest
|
||||||
public void testCreateAnt() throws Exception {
|
public void testCreateAnt() throws Exception {
|
||||||
assertClassForName(
|
assertClassForName(AntDirectSensorManager.class, R.string.ant_sensor_type);
|
||||||
AntDirectSensorManager.class, R.string.ant_sensor_type);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@SmallTest
|
@SmallTest
|
||||||
public void testCreateAntSRM() throws Exception {
|
public void testCreateAntSRM() throws Exception {
|
||||||
assertClassForName(
|
assertClassForName(AntSRMSensorManager.class, R.string.srm_ant_bridge_sensor_type);
|
||||||
AntSRMSensorManager.class, R.string.srm_ant_bridge_sensor_type);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void assertClassForName(Class c, int i) {
|
private void assertClassForName(Class<?> c, int i) {
|
||||||
sharedPreferences.edit()
|
sharedPreferences.edit()
|
||||||
.putString(getContext().getString(R.string.sensor_type_key),
|
.putString(getContext().getString(R.string.sensor_type_key),
|
||||||
getContext().getString(i))
|
getContext().getString(i))
|
||||||
|
|||||||
Reference in New Issue
Block a user