From 7530522cbca477cb822cb494ffe12480e5237934 Mon Sep 17 00:00:00 2001 From: Abyss777 Date: Wed, 13 Sep 2017 13:46:38 +0500 Subject: Re implement "getSupportedCommands" function --- src/org/traccar/database/CommandsManager.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/org/traccar/database') diff --git a/src/org/traccar/database/CommandsManager.java b/src/org/traccar/database/CommandsManager.java index 6eb6d9035..deb802b29 100644 --- a/src/org/traccar/database/CommandsManager.java +++ b/src/org/traccar/database/CommandsManager.java @@ -81,17 +81,17 @@ public class CommandsManager extends ExtendedObjectManager { } } - public Collection getSupportedCommands(long deviceId, boolean textChannel) { + public Collection getSupportedCommands(long deviceId) { List result = new ArrayList<>(); Position lastPosition = Context.getIdentityManager().getLastPosition(deviceId); + boolean online = Context.getConnectionManager().getActiveDevice(deviceId) != null; for (long commandId : getAllDeviceItems(deviceId)) { Command command = getById(commandId); - if (command.getTextChannel() == textChannel) { + if (command.getTextChannel() || online) { if (lastPosition != null) { BaseProtocol protocol = Context.getServerManager().getProtocol(lastPosition.getProtocol()); - Collection protocolCommands = - textChannel ? protocol.getSupportedTextCommands() : protocol.getSupportedDataCommands(); - if (protocolCommands.contains(command.getType())) { + if (protocol.getSupportedTextCommands().contains(command.getType()) + || online && protocol.getSupportedDataCommands().contains(command.getType())) { result.add(commandId); } } else if (command.getType().equals(Command.TYPE_CUSTOM)) { -- cgit v1.2.3