forked from upstream-mirrors/OpenTracks
Renamed SensorManager to RemoteSensorManager.
This commit is contained in:
+5
-5
@@ -24,13 +24,13 @@ import android.os.Looper;
|
||||
import android.os.Message;
|
||||
import android.util.Log;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import de.dennisguse.opentracks.R;
|
||||
import de.dennisguse.opentracks.content.sensor.SensorDataSet;
|
||||
import de.dennisguse.opentracks.content.sensor.SensorState;
|
||||
import de.dennisguse.opentracks.util.PreferencesUtils;
|
||||
import de.dennisguse.opentracks.util.UnitConversions;
|
||||
import de.dennisguse.opentracks.R;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
* Bluetooth sensor manager.
|
||||
@@ -39,7 +39,7 @@ import java.util.ArrayList;
|
||||
*
|
||||
* @author Sandor Dornbush
|
||||
*/
|
||||
public class BluetoothSensorManager extends SensorManager {
|
||||
public class BluetoothRemoteSensorManager extends RemoteSensorManager {
|
||||
|
||||
private static final String TAG = BluetoothConnectionManager.class.getSimpleName();
|
||||
private static final BluetoothAdapter bluetoothAdapter = getDefaultBluetoothAdapter();
|
||||
@@ -71,7 +71,7 @@ public class BluetoothSensorManager extends SensorManager {
|
||||
/**
|
||||
* @param context the context
|
||||
*/
|
||||
public BluetoothSensorManager(Context context) {
|
||||
public BluetoothRemoteSensorManager(Context context) {
|
||||
this.context = context;
|
||||
bluetoothConnectionManager = new BluetoothConnectionManager(context, messageHandler);
|
||||
}
|
||||
+7
-7
@@ -18,23 +18,23 @@ package de.dennisguse.opentracks.services.sensors;
|
||||
|
||||
import android.util.Log;
|
||||
|
||||
import de.dennisguse.opentracks.content.sensor.SensorDataSet;
|
||||
import de.dennisguse.opentracks.content.sensor.SensorState;
|
||||
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
|
||||
import de.dennisguse.opentracks.content.sensor.SensorDataSet;
|
||||
import de.dennisguse.opentracks.content.sensor.SensorState;
|
||||
|
||||
/**
|
||||
* Manage the connection to a sensor.
|
||||
* Manage the connection to a remote sensor.
|
||||
*
|
||||
* @author Sandor Dornbush
|
||||
*/
|
||||
public abstract class SensorManager {
|
||||
public abstract class RemoteSensorManager {
|
||||
|
||||
public static final long MAX_SENSOR_DATE_SET_AGE = 5000;
|
||||
public static final long MAX_SENSOR_STATE_AGE = 20000;
|
||||
|
||||
private static final String TAG = SensorManager.class.getSimpleName();
|
||||
private static final String TAG = RemoteSensorManager.class.getSimpleName();
|
||||
private static final int RETRY_PERIOD = 20000;
|
||||
|
||||
private SensorState sensorState = SensorState.NONE;
|
||||
@@ -88,7 +88,7 @@ public abstract class SensorManager {
|
||||
}
|
||||
}
|
||||
};
|
||||
timer = new Timer(SensorManager.class.getSimpleName());
|
||||
timer = new Timer(RemoteSensorManager.class.getSimpleName());
|
||||
timer.schedule(timerTask, RETRY_PERIOD, RETRY_PERIOD);
|
||||
}
|
||||
|
||||
+22
-26
@@ -19,16 +19,16 @@ package de.dennisguse.opentracks.services.sensors;
|
||||
import android.content.Context;
|
||||
|
||||
/**
|
||||
* A factory of {@link SensorManager}.
|
||||
* A factory of {@link RemoteSensorManager}.
|
||||
*
|
||||
* @author Sandor Dornbush
|
||||
*/
|
||||
public class SensorManagerFactory {
|
||||
public class RemoteSensorManagerFactory {
|
||||
|
||||
private static SensorManager systemSensorManager = null;
|
||||
private static SensorManager sensorManagerTemporary = null;
|
||||
private static RemoteSensorManager remoteSensorManagerSystem = null;
|
||||
private static RemoteSensorManager remoteSensorManagerTemporary = null;
|
||||
|
||||
private SensorManagerFactory() {
|
||||
private RemoteSensorManagerFactory() {
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -36,49 +36,45 @@ public class SensorManagerFactory {
|
||||
*
|
||||
* @param context the context
|
||||
*/
|
||||
public static SensorManager getSystemSensorManager(Context context) {
|
||||
public static RemoteSensorManager getSystemSensorManager(Context context) {
|
||||
releaseSensorManagerTemporary();
|
||||
releaseSystemSensorManager();
|
||||
systemSensorManager = getSensorManager(context);
|
||||
if (systemSensorManager != null) {
|
||||
systemSensorManager.startSensor();
|
||||
}
|
||||
return systemSensorManager;
|
||||
remoteSensorManagerSystem = getSensorManager(context);
|
||||
remoteSensorManagerSystem.startSensor();
|
||||
return remoteSensorManagerSystem;
|
||||
}
|
||||
|
||||
/**
|
||||
* Releases the system sensor manager.
|
||||
*/
|
||||
public static void releaseSystemSensorManager() {
|
||||
if (systemSensorManager != null) {
|
||||
systemSensorManager.stopSensor();
|
||||
if (remoteSensorManagerSystem != null) {
|
||||
remoteSensorManagerSystem.stopSensor();
|
||||
}
|
||||
systemSensorManager = null;
|
||||
remoteSensorManagerSystem = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the temp sensor manager.
|
||||
*/
|
||||
public static SensorManager getSensorManagerTemporary(Context context) {
|
||||
public static RemoteSensorManager getSensorManagerTemporary(Context context) {
|
||||
releaseSensorManagerTemporary();
|
||||
if (systemSensorManager != null) {
|
||||
if (remoteSensorManagerSystem != null) {
|
||||
return null;
|
||||
}
|
||||
sensorManagerTemporary = getSensorManager(context);
|
||||
if (sensorManagerTemporary != null) {
|
||||
sensorManagerTemporary.startSensor();
|
||||
}
|
||||
return sensorManagerTemporary;
|
||||
remoteSensorManagerTemporary = getSensorManager(context);
|
||||
remoteSensorManagerTemporary.startSensor();
|
||||
return remoteSensorManagerTemporary;
|
||||
}
|
||||
|
||||
/**
|
||||
* Releases the temp sensor manager.
|
||||
*/
|
||||
public static void releaseSensorManagerTemporary() {
|
||||
if (sensorManagerTemporary != null) {
|
||||
sensorManagerTemporary.stopSensor();
|
||||
if (remoteSensorManagerTemporary != null) {
|
||||
remoteSensorManagerTemporary.stopSensor();
|
||||
}
|
||||
sensorManagerTemporary = null;
|
||||
remoteSensorManagerTemporary = null;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -86,7 +82,7 @@ public class SensorManagerFactory {
|
||||
*
|
||||
* @param context the context
|
||||
*/
|
||||
private static SensorManager getSensorManager(Context context) {
|
||||
return new BluetoothSensorManager(context);
|
||||
private static RemoteSensorManager getSensorManager(Context context) {
|
||||
return new BluetoothRemoteSensorManager(context);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user