aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/traccar/BaseProtocolDecoder.java
diff options
context:
space:
mode:
authorIván Ávalos <avalos@disroot.org>2024-03-07 22:59:12 -0600
committerIván Ávalos <avalos@disroot.org>2024-03-07 22:59:12 -0600
commit00d3ddf7b5e335a5112a28a547c4c9ec2c3bd1d2 (patch)
treea02ecb75a8533194314d32c0c667520bff5e919d /src/main/java/org/traccar/BaseProtocolDecoder.java
parent8e1bc703227a875c20e453704d774ce5772f2621 (diff)
parent75b404db5c790bf37c05fabf1cbbd2027ad1db25 (diff)
downloadtrackermap-server-00d3ddf7b5e335a5112a28a547c4c9ec2c3bd1d2.tar.gz
trackermap-server-00d3ddf7b5e335a5112a28a547c4c9ec2c3bd1d2.tar.bz2
trackermap-server-00d3ddf7b5e335a5112a28a547c4c9ec2c3bd1d2.zip
Merge branch 'master' of https://github.com/traccar/traccar
Diffstat (limited to 'src/main/java/org/traccar/BaseProtocolDecoder.java')
-rw-r--r--src/main/java/org/traccar/BaseProtocolDecoder.java22
1 files changed, 16 insertions, 6 deletions
diff --git a/src/main/java/org/traccar/BaseProtocolDecoder.java b/src/main/java/org/traccar/BaseProtocolDecoder.java
index 382daf92f..495a866c0 100644
--- a/src/main/java/org/traccar/BaseProtocolDecoder.java
+++ b/src/main/java/org/traccar/BaseProtocolDecoder.java
@@ -29,9 +29,8 @@ import org.traccar.model.Position;
import org.traccar.session.ConnectionManager;
import org.traccar.session.DeviceSession;
import org.traccar.session.cache.CacheManager;
-import org.traccar.storage.StorageException;
-import javax.inject.Inject;
+import jakarta.inject.Inject;
import java.net.InetSocketAddress;
import java.net.SocketAddress;
import java.util.Collection;
@@ -52,6 +51,8 @@ public abstract class BaseProtocolDecoder extends ExtendedObjectDecoder {
private MediaManager mediaManager;
private CommandsManager commandsManager;
+ private String modelOverride;
+
public BaseProtocolDecoder(Protocol protocol) {
this.protocol = protocol;
}
@@ -125,22 +126,31 @@ public abstract class BaseProtocolDecoder extends ExtendedObjectDecoder {
}
protected TimeZone getTimeZone(long deviceId, String defaultTimeZone) {
- TimeZone result = TimeZone.getTimeZone(defaultTimeZone);
String timeZoneName = AttributeUtil.lookup(cacheManager, Keys.DECODER_TIMEZONE, deviceId);
if (timeZoneName != null) {
- result = TimeZone.getTimeZone(timeZoneName);
+ return TimeZone.getTimeZone(timeZoneName);
+ } else if (defaultTimeZone != null) {
+ return TimeZone.getTimeZone(defaultTimeZone);
}
- return result;
+ return null;
}
public DeviceSession getDeviceSession(Channel channel, SocketAddress remoteAddress, String... uniqueIds) {
try {
return connectionManager.getDeviceSession(protocol, channel, remoteAddress, uniqueIds);
- } catch (StorageException e) {
+ } catch (Exception e) {
throw new RuntimeException(e);
}
}
+ public void setModelOverride(String modelOverride) {
+ this.modelOverride = modelOverride;
+ }
+
+ public String getDeviceModel(DeviceSession deviceSession) {
+ return modelOverride != null ? modelOverride : deviceSession.getModel();
+ }
+
public void getLastLocation(Position position, Date deviceTime) {
if (position.getDeviceId() != 0) {
position.setOutdated(true);