forked from upstream-mirrors/OpenTracks
Cleanup.
This commit is contained in:
+2
-2
@@ -65,7 +65,7 @@ import de.dennisguse.opentracks.data.models.TrackBuilder;
|
|||||||
import de.dennisguse.opentracks.data.models.TrackPoint;
|
import de.dennisguse.opentracks.data.models.TrackPoint;
|
||||||
import de.dennisguse.opentracks.io.file.TrackFileFormat;
|
import de.dennisguse.opentracks.io.file.TrackFileFormat;
|
||||||
import de.dennisguse.opentracks.io.file.exporter.TrackExporter;
|
import de.dennisguse.opentracks.io.file.exporter.TrackExporter;
|
||||||
import de.dennisguse.opentracks.sensors.BluetoothHandlerManagerCyclingPower;
|
import de.dennisguse.opentracks.sensors.BluetoothHandlerCyclingPower;
|
||||||
import de.dennisguse.opentracks.sensors.sensorData.Aggregator;
|
import de.dennisguse.opentracks.sensors.sensorData.Aggregator;
|
||||||
import de.dennisguse.opentracks.sensors.sensorData.AggregatorBarometer;
|
import de.dennisguse.opentracks.sensors.sensorData.AggregatorBarometer;
|
||||||
import de.dennisguse.opentracks.sensors.sensorData.AggregatorCyclingCadence;
|
import de.dennisguse.opentracks.sensors.sensorData.AggregatorCyclingCadence;
|
||||||
@@ -649,7 +649,7 @@ public class ExportImportTest {
|
|||||||
SensorDataAggregator sensorDataAggregator = trackPointCreator.getSensorManager().sensorDataAggregator;
|
SensorDataAggregator sensorDataAggregator = trackPointCreator.getSensorManager().sensorDataAggregator;
|
||||||
|
|
||||||
AggregatorCyclingPower cyclingPower = new AggregatorCyclingPower("", "");
|
AggregatorCyclingPower cyclingPower = new AggregatorCyclingPower("", "");
|
||||||
cyclingPower.add(new Raw<>(trackPointCreator.createNow(), new BluetoothHandlerManagerCyclingPower.Data(Power.of(power), null)));
|
cyclingPower.add(new Raw<>(trackPointCreator.createNow(), new BluetoothHandlerCyclingPower.Data(Power.of(power), null)));
|
||||||
sensorDataAggregator.add(cyclingPower);
|
sensorDataAggregator.add(cyclingPower);
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+4
-4
@@ -10,11 +10,11 @@ public class BluetoothHandlerCyclingPowerTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void parseCyclingPower_power() {
|
public void parseCyclingPower_power() {
|
||||||
BluetoothGattCharacteristic characteristic = new BluetoothGattCharacteristic(BluetoothHandlerManagerCyclingPower.CYCLING_POWER.serviceUUID(), 0, 0);
|
BluetoothGattCharacteristic characteristic = new BluetoothGattCharacteristic(BluetoothHandlerCyclingPower.CYCLING_POWER.serviceUUID(), 0, 0);
|
||||||
characteristic.setValue(new byte[]{0, 0, 40, 0});
|
characteristic.setValue(new byte[]{0, 0, 40, 0});
|
||||||
|
|
||||||
// when
|
// when
|
||||||
BluetoothHandlerManagerCyclingPower.Data powerCadence = BluetoothHandlerManagerCyclingPower.parseCyclingPower(characteristic);
|
BluetoothHandlerCyclingPower.Data powerCadence = BluetoothHandlerCyclingPower.parseCyclingPower(characteristic);
|
||||||
|
|
||||||
// then
|
// then
|
||||||
assertEquals(40, powerCadence.power().getW(), 0.01);
|
assertEquals(40, powerCadence.power().getW(), 0.01);
|
||||||
@@ -22,11 +22,11 @@ public class BluetoothHandlerCyclingPowerTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void parseCyclingPower_power_with_cadence() {
|
public void parseCyclingPower_power_with_cadence() {
|
||||||
BluetoothGattCharacteristic characteristic = new BluetoothGattCharacteristic(BluetoothHandlerManagerCyclingPower.CYCLING_POWER.serviceUUID(), 0, 0);
|
BluetoothGattCharacteristic characteristic = new BluetoothGattCharacteristic(BluetoothHandlerCyclingPower.CYCLING_POWER.serviceUUID(), 0, 0);
|
||||||
characteristic.setValue(new byte[]{0x2C, 0x00, 0x00, 0x00, (byte) 0x9F, 0x00, 0x0C, 0x00, (byte) 0xE5, 0x42});
|
characteristic.setValue(new byte[]{0x2C, 0x00, 0x00, 0x00, (byte) 0x9F, 0x00, 0x0C, 0x00, (byte) 0xE5, 0x42});
|
||||||
|
|
||||||
// when
|
// when
|
||||||
BluetoothHandlerManagerCyclingPower.Data powerCadence = BluetoothHandlerManagerCyclingPower.parseCyclingPower(characteristic);
|
BluetoothHandlerCyclingPower.Data powerCadence = BluetoothHandlerCyclingPower.parseCyclingPower(characteristic);
|
||||||
|
|
||||||
// then
|
// then
|
||||||
assertEquals(0, powerCadence.power().getW(), 0.01);
|
assertEquals(0, powerCadence.power().getW(), 0.01);
|
||||||
|
|||||||
+5
-5
@@ -8,16 +8,16 @@ import org.junit.Test;
|
|||||||
|
|
||||||
import de.dennisguse.opentracks.data.models.HeartRate;
|
import de.dennisguse.opentracks.data.models.HeartRate;
|
||||||
|
|
||||||
public class BluetoothHandlerManagerHeartRateTest {
|
public class BluetoothHandlerHeartRateTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void parseHeartRate_uint8() {
|
public void parseHeartRate_uint8() {
|
||||||
// given
|
// given
|
||||||
BluetoothGattCharacteristic characteristic = new BluetoothGattCharacteristic(BluetoothHandlerManagerHeartRate.HEARTRATE.serviceUUID(), 0, 0);
|
BluetoothGattCharacteristic characteristic = new BluetoothGattCharacteristic(BluetoothHandlerHeartRate.HEARTRATE.serviceUUID(), 0, 0);
|
||||||
characteristic.setValue(new byte[]{0x02, 0x3C});
|
characteristic.setValue(new byte[]{0x02, 0x3C});
|
||||||
|
|
||||||
// when
|
// when
|
||||||
HeartRate heartRate = BluetoothHandlerManagerHeartRate.parseHeartRate(characteristic);
|
HeartRate heartRate = BluetoothHandlerHeartRate.parseHeartRate(characteristic);
|
||||||
|
|
||||||
// then
|
// then
|
||||||
assertEquals(HeartRate.of(60), heartRate);
|
assertEquals(HeartRate.of(60), heartRate);
|
||||||
@@ -26,11 +26,11 @@ public class BluetoothHandlerManagerHeartRateTest {
|
|||||||
@Test
|
@Test
|
||||||
public void parseHeartRate_uint16() {
|
public void parseHeartRate_uint16() {
|
||||||
// given
|
// given
|
||||||
BluetoothGattCharacteristic characteristic = new BluetoothGattCharacteristic(BluetoothHandlerManagerHeartRate.HEARTRATE.serviceUUID(), 0, 0);
|
BluetoothGattCharacteristic characteristic = new BluetoothGattCharacteristic(BluetoothHandlerHeartRate.HEARTRATE.serviceUUID(), 0, 0);
|
||||||
characteristic.setValue(new byte[]{0x01, 0x01, 0x01});
|
characteristic.setValue(new byte[]{0x01, 0x01, 0x01});
|
||||||
|
|
||||||
// when
|
// when
|
||||||
HeartRate heartRate = BluetoothHandlerManagerHeartRate.parseHeartRate(characteristic);
|
HeartRate heartRate = BluetoothHandlerHeartRate.parseHeartRate(characteristic);
|
||||||
|
|
||||||
// then
|
// then
|
||||||
assertEquals(HeartRate.of(257), heartRate);
|
assertEquals(HeartRate.of(257), heartRate);
|
||||||
@@ -14,7 +14,7 @@ public class BluetoothHandlerCyclingCadence implements SensorHandlerInterface {
|
|||||||
private static final String TAG = BluetoothHandlerCyclingCadence.class.getSimpleName();
|
private static final String TAG = BluetoothHandlerCyclingCadence.class.getSimpleName();
|
||||||
|
|
||||||
public static final List<ServiceMeasurementUUID> CYCLING_CADENCE = List.of(
|
public static final List<ServiceMeasurementUUID> CYCLING_CADENCE = List.of(
|
||||||
BluetoothHandlerManagerCyclingPower.CYCLING_POWER,
|
BluetoothHandlerCyclingPower.CYCLING_POWER,
|
||||||
BluetoothHandlerCyclingDistanceSpeed.CYCLING_SPEED_CADENCE
|
BluetoothHandlerCyclingDistanceSpeed.CYCLING_SPEED_CADENCE
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -30,8 +30,8 @@ public class BluetoothHandlerCyclingCadence implements SensorHandlerInterface {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handlePayload(SensorManager.SensorDataChangedObserver observer, ServiceMeasurementUUID serviceMeasurementUUID, String sensorName, String address, BluetoothGattCharacteristic characteristic) {
|
public void handlePayload(SensorManager.SensorDataChangedObserver observer, ServiceMeasurementUUID serviceMeasurementUUID, String sensorName, String address, BluetoothGattCharacteristic characteristic) {
|
||||||
if (serviceMeasurementUUID.equals(BluetoothHandlerManagerCyclingPower.CYCLING_POWER)) {
|
if (serviceMeasurementUUID.equals(BluetoothHandlerCyclingPower.CYCLING_POWER)) {
|
||||||
BluetoothHandlerManagerCyclingPower.Data data = BluetoothHandlerManagerCyclingPower.parseCyclingPower(characteristic);
|
BluetoothHandlerCyclingPower.Data data = BluetoothHandlerCyclingPower.parseCyclingPower(characteristic);
|
||||||
if (data != null && data.crank() != null) {
|
if (data != null && data.crank() != null) {
|
||||||
observer.onChange(new Raw<>(observer.getNow(), data.crank()));
|
observer.onChange(new Raw<>(observer.getNow(), data.crank()));
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -13,7 +13,7 @@ import de.dennisguse.opentracks.sensors.sensorData.AggregatorCyclingPower;
|
|||||||
import de.dennisguse.opentracks.sensors.sensorData.Raw;
|
import de.dennisguse.opentracks.sensors.sensorData.Raw;
|
||||||
import de.dennisguse.opentracks.sensors.sensorData.SensorHandlerInterface;
|
import de.dennisguse.opentracks.sensors.sensorData.SensorHandlerInterface;
|
||||||
|
|
||||||
public class BluetoothHandlerManagerCyclingPower implements SensorHandlerInterface {
|
public class BluetoothHandlerCyclingPower implements SensorHandlerInterface {
|
||||||
|
|
||||||
public static final ServiceMeasurementUUID CYCLING_POWER = new ServiceMeasurementUUID(
|
public static final ServiceMeasurementUUID CYCLING_POWER = new ServiceMeasurementUUID(
|
||||||
new UUID(0x181800001000L, 0x800000805f9b34fbL),
|
new UUID(0x181800001000L, 0x800000805f9b34fbL),
|
||||||
+1
-1
@@ -13,7 +13,7 @@ import de.dennisguse.opentracks.sensors.sensorData.AggregatorHeartRate;
|
|||||||
import de.dennisguse.opentracks.sensors.sensorData.Raw;
|
import de.dennisguse.opentracks.sensors.sensorData.Raw;
|
||||||
import de.dennisguse.opentracks.sensors.sensorData.SensorHandlerInterface;
|
import de.dennisguse.opentracks.sensors.sensorData.SensorHandlerInterface;
|
||||||
|
|
||||||
public class BluetoothHandlerManagerHeartRate implements SensorHandlerInterface {
|
public class BluetoothHandlerHeartRate implements SensorHandlerInterface {
|
||||||
|
|
||||||
public static final ServiceMeasurementUUID HEARTRATE = new ServiceMeasurementUUID(
|
public static final ServiceMeasurementUUID HEARTRATE = new ServiceMeasurementUUID(
|
||||||
new UUID(0x180D00001000L, 0x800000805f9b34fbL),
|
new UUID(0x180D00001000L, 0x800000805f9b34fbL),
|
||||||
@@ -57,10 +57,10 @@ public class BluetoothRemoteSensorManager implements SensorConnector, SharedPref
|
|||||||
this.handler = handler;
|
this.handler = handler;
|
||||||
|
|
||||||
BluetoothAdapter bluetoothAdapter = BluetoothUtils.getAdapter(context);
|
BluetoothAdapter bluetoothAdapter = BluetoothUtils.getAdapter(context);
|
||||||
this.heartRate = new BluetoothConnectionManager(bluetoothAdapter, observer, new BluetoothHandlerManagerHeartRate());
|
this.heartRate = new BluetoothConnectionManager(bluetoothAdapter, observer, new BluetoothHandlerHeartRate());
|
||||||
this.cyclingCadence = new BluetoothConnectionManager(bluetoothAdapter, observer, new BluetoothHandlerCyclingCadence());
|
this.cyclingCadence = new BluetoothConnectionManager(bluetoothAdapter, observer, new BluetoothHandlerCyclingCadence());
|
||||||
this.cyclingSpeed = new BluetoothConnectionManager(bluetoothAdapter, observer, new BluetoothHandlerCyclingDistanceSpeed());
|
this.cyclingSpeed = new BluetoothConnectionManager(bluetoothAdapter, observer, new BluetoothHandlerCyclingDistanceSpeed());
|
||||||
this.cyclingPower = new BluetoothConnectionManager(bluetoothAdapter, observer, new BluetoothHandlerManagerCyclingPower());
|
this.cyclingPower = new BluetoothConnectionManager(bluetoothAdapter, observer, new BluetoothHandlerCyclingPower());
|
||||||
this.runningSpeedAndCadence = new BluetoothConnectionManager(bluetoothAdapter, observer, new BluetoothHandlerRunningSpeedAndCadence());
|
this.runningSpeedAndCadence = new BluetoothConnectionManager(bluetoothAdapter, observer, new BluetoothHandlerRunningSpeedAndCadence());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+3
-3
@@ -3,16 +3,16 @@ package de.dennisguse.opentracks.sensors.sensorData;
|
|||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
|
|
||||||
import de.dennisguse.opentracks.data.models.Power;
|
import de.dennisguse.opentracks.data.models.Power;
|
||||||
import de.dennisguse.opentracks.sensors.BluetoothHandlerManagerCyclingPower;
|
import de.dennisguse.opentracks.sensors.BluetoothHandlerCyclingPower;
|
||||||
|
|
||||||
public class AggregatorCyclingPower extends Aggregator<BluetoothHandlerManagerCyclingPower.Data, Power> {
|
public class AggregatorCyclingPower extends Aggregator<BluetoothHandlerCyclingPower.Data, Power> {
|
||||||
|
|
||||||
public AggregatorCyclingPower(String name, String address) {
|
public AggregatorCyclingPower(String name, String address) {
|
||||||
super(name, address);
|
super(name, address);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void computeValue(Raw<BluetoothHandlerManagerCyclingPower.Data> current) {
|
public void computeValue(Raw<BluetoothHandlerCyclingPower.Data> current) {
|
||||||
this.aggregatedValue = current.value().power();
|
this.aggregatedValue = current.value().power();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ import de.dennisguse.opentracks.data.models.Position;
|
|||||||
import de.dennisguse.opentracks.data.models.Speed;
|
import de.dennisguse.opentracks.data.models.Speed;
|
||||||
import de.dennisguse.opentracks.sensors.BluetoothHandlerCyclingCadence;
|
import de.dennisguse.opentracks.sensors.BluetoothHandlerCyclingCadence;
|
||||||
import de.dennisguse.opentracks.sensors.BluetoothHandlerCyclingDistanceSpeed;
|
import de.dennisguse.opentracks.sensors.BluetoothHandlerCyclingDistanceSpeed;
|
||||||
import de.dennisguse.opentracks.sensors.BluetoothHandlerManagerCyclingPower;
|
import de.dennisguse.opentracks.sensors.BluetoothHandlerCyclingPower;
|
||||||
import de.dennisguse.opentracks.sensors.BluetoothHandlerRunningSpeedAndCadence;
|
import de.dennisguse.opentracks.sensors.BluetoothHandlerRunningSpeedAndCadence;
|
||||||
import de.dennisguse.opentracks.settings.PreferencesUtils;
|
import de.dennisguse.opentracks.settings.PreferencesUtils;
|
||||||
|
|
||||||
@@ -119,8 +119,8 @@ public class SensorDataAggregator {
|
|||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (value instanceof BluetoothHandlerManagerCyclingPower.Data) {
|
if (value instanceof BluetoothHandlerCyclingPower.Data) {
|
||||||
this.cyclingPower.add((Raw<BluetoothHandlerManagerCyclingPower.Data>) data);
|
this.cyclingPower.add((Raw<BluetoothHandlerCyclingPower.Data>) data);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (value instanceof AtmosphericPressure) {
|
if (value instanceof AtmosphericPressure) {
|
||||||
|
|||||||
+2
-2
@@ -7,7 +7,7 @@ import androidx.preference.PreferenceDialogFragmentCompat;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import de.dennisguse.opentracks.sensors.BluetoothHandlerManagerCyclingPower;
|
import de.dennisguse.opentracks.sensors.BluetoothHandlerCyclingPower;
|
||||||
|
|
||||||
public class BluetoothLeCyclingPowerPreference extends BluetoothLeSensorPreference {
|
public class BluetoothLeCyclingPowerPreference extends BluetoothLeSensorPreference {
|
||||||
|
|
||||||
@@ -29,6 +29,6 @@ public class BluetoothLeCyclingPowerPreference extends BluetoothLeSensorPreferen
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PreferenceDialogFragmentCompat createInstance() {
|
public PreferenceDialogFragmentCompat createInstance() {
|
||||||
return BluetoothLeSensorPreference.BluetoothLeSensorPreferenceDialog.newInstance(getKey(), List.of(BluetoothHandlerManagerCyclingPower.CYCLING_POWER));
|
return BluetoothLeSensorPreference.BluetoothLeSensorPreferenceDialog.newInstance(getKey(), List.of(BluetoothHandlerCyclingPower.CYCLING_POWER));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+2
-2
@@ -5,7 +5,7 @@ import android.util.AttributeSet;
|
|||||||
|
|
||||||
import androidx.preference.PreferenceDialogFragmentCompat;
|
import androidx.preference.PreferenceDialogFragmentCompat;
|
||||||
|
|
||||||
import de.dennisguse.opentracks.sensors.BluetoothHandlerManagerHeartRate;
|
import de.dennisguse.opentracks.sensors.BluetoothHandlerHeartRate;
|
||||||
|
|
||||||
public class BluetoothLeHeartRatePreference extends BluetoothLeSensorPreference {
|
public class BluetoothLeHeartRatePreference extends BluetoothLeSensorPreference {
|
||||||
|
|
||||||
@@ -27,6 +27,6 @@ public class BluetoothLeHeartRatePreference extends BluetoothLeSensorPreference
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PreferenceDialogFragmentCompat createInstance() {
|
public PreferenceDialogFragmentCompat createInstance() {
|
||||||
return BluetoothLeSensorPreference.BluetoothLeSensorPreferenceDialog.newInstance(getKey(), BluetoothHandlerManagerHeartRate.HEART_RATE_SUPPORTING_DEVICES);
|
return BluetoothLeSensorPreference.BluetoothLeSensorPreferenceDialog.newInstance(getKey(), BluetoothHandlerHeartRate.HEART_RATE_SUPPORTING_DEVICES);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user