hiding things from Android
This commit is contained in:
parent
1b26cd17bb
commit
592c226655
|
@ -153,7 +153,7 @@ public class BinaryProtocol implements BinaryProtocolCommands {
|
||||||
communicationLoggingListener = new CommunicationLoggingListener() {
|
communicationLoggingListener = new CommunicationLoggingListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onPortHolderMessage(Class clazz, String message) {
|
public void onPortHolderMessage(Class clazz, String message) {
|
||||||
MessagesCentral.getInstance().postMessage(clazz, message);
|
linkManager.messageListener.postMessage(clazz, message);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -100,7 +100,7 @@ public class CommandQueue {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (counter != 1)
|
if (counter != 1)
|
||||||
MessagesCentral.getInstance().postMessage(CommandQueue.class, "Took " + counter + " attempts");
|
linkManager.messageListener.postMessage(CommandQueue.class, "Took " + counter + " attempts");
|
||||||
}
|
}
|
||||||
|
|
||||||
public CommandQueue(LinkManager linkManager) {
|
public CommandQueue(LinkManager linkManager) {
|
||||||
|
@ -109,7 +109,7 @@ public class CommandQueue {
|
||||||
@SuppressWarnings("InfiniteLoopStatement")
|
@SuppressWarnings("InfiniteLoopStatement")
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
MessagesCentral.getInstance().postMessage(COMMAND_QUEUE_CLASS, "SerialIO started");
|
linkManager.messageListener.postMessage(COMMAND_QUEUE_CLASS, "SerialIO started");
|
||||||
while (true) {
|
while (true) {
|
||||||
try {
|
try {
|
||||||
sendPendingCommand();
|
sendPendingCommand();
|
||||||
|
@ -134,13 +134,12 @@ public class CommandQueue {
|
||||||
* TODO: add example, todo: refactor method and add unit test
|
* TODO: add example, todo: refactor method and add unit test
|
||||||
*/
|
*/
|
||||||
public void handleConfirmationMessage(final String message) {
|
public void handleConfirmationMessage(final String message) {
|
||||||
MessagesCentral mc = MessagesCentral.getInstance();
|
|
||||||
String confirmation = LinkManager.unpackConfirmation(message);
|
String confirmation = LinkManager.unpackConfirmation(message);
|
||||||
if (confirmation == null)
|
if (confirmation == null)
|
||||||
mc.postMessage(CommandQueue.class, "Broken confirmation length: " + message);
|
linkManager.messageListener.postMessage(CommandQueue.class, "Broken confirmation length: " + message);
|
||||||
pendingConfirmations.add(confirmation);
|
pendingConfirmations.add(confirmation);
|
||||||
if (LinkManager.LOG_LEVEL.isDebugEnabled())
|
if (LinkManager.LOG_LEVEL.isDebugEnabled())
|
||||||
mc.postMessage(CommandQueue.class, "got valid conf! " + confirmation + ", still pending: " + pendingCommands.size());
|
linkManager.messageListener.postMessage(CommandQueue.class, "got valid conf! " + confirmation + ", still pending: " + pendingCommands.size());
|
||||||
|
|
||||||
// FileLog.MAIN.logLine("templog got valid conf " + confirmation + " " + System.currentTimeMillis() + " " + new Date());
|
// FileLog.MAIN.logLine("templog got valid conf " + confirmation + " " + System.currentTimeMillis() + " " + new Date());
|
||||||
|
|
||||||
|
|
|
@ -48,6 +48,12 @@ public class LinkManager implements Closeable {
|
||||||
private boolean isStarted;
|
private boolean isStarted;
|
||||||
private boolean compositeLogicEnabled = true;
|
private boolean compositeLogicEnabled = true;
|
||||||
private boolean needPullData = true;
|
private boolean needPullData = true;
|
||||||
|
public MessagesListener messageListener = new MessagesListener() {
|
||||||
|
@Override
|
||||||
|
public void postMessage(Class<?> source, String message) {
|
||||||
|
System.out.println(source + ": " + message);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
public LinkManager() {
|
public LinkManager() {
|
||||||
engineState = new EngineState(new EngineState.EngineStateListenerImpl() {
|
engineState = new EngineState(new EngineState.EngineStateListenerImpl() {
|
||||||
|
@ -206,7 +212,7 @@ public class LinkManager implements Closeable {
|
||||||
Callable<IoStream> streamFactory = new Callable<IoStream>() {
|
Callable<IoStream> streamFactory = new Callable<IoStream>() {
|
||||||
@Override
|
@Override
|
||||||
public IoStream call() {
|
public IoStream call() {
|
||||||
MessagesCentral.getInstance().postMessage(getClass(), "Opening port: " + port);
|
messageListener.postMessage(getClass(), "Opening port: " + port);
|
||||||
Socket socket;
|
Socket socket;
|
||||||
try {
|
try {
|
||||||
int portPart = TcpConnector.getTcpPort(port);
|
int portPart = TcpConnector.getTcpPort(port);
|
||||||
|
@ -228,7 +234,7 @@ public class LinkManager implements Closeable {
|
||||||
Callable<IoStream> ioStreamCallable = new Callable<IoStream>() {
|
Callable<IoStream> ioStreamCallable = new Callable<IoStream>() {
|
||||||
@Override
|
@Override
|
||||||
public IoStream call() {
|
public IoStream call() {
|
||||||
MessagesCentral.getInstance().postMessage(getClass(), "Opening port: " + port);
|
messageListener.postMessage(getClass(), "Opening port: " + port);
|
||||||
IoStream stream = ((Callable<IoStream>) () -> SerialIoStreamJSerialComm.openPort(port)).call();
|
IoStream stream = ((Callable<IoStream>) () -> SerialIoStreamJSerialComm.openPort(port)).call();
|
||||||
if (stream == null) {
|
if (stream == null) {
|
||||||
// error already reported
|
// error already reported
|
||||||
|
@ -296,4 +302,8 @@ public class LinkManager implements Closeable {
|
||||||
System.out.println("All ports: " + Arrays.toString(ports));
|
System.out.println("All ports: " + Arrays.toString(ports));
|
||||||
return port;
|
return port;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public interface MessagesListener {
|
||||||
|
void postMessage(Class<?> source, String message);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,7 +51,7 @@ public class StreamConnector implements LinkConnector {
|
||||||
@Override
|
@Override
|
||||||
public void restart() {
|
public void restart() {
|
||||||
linkManager.execute(() -> {
|
linkManager.execute(() -> {
|
||||||
MessagesCentral.getInstance().postMessage(StreamConnector.this.getClass(), "Restarting serial IO");
|
linkManager.messageListener.postMessage(StreamConnector.this.getClass(), "Restarting serial IO");
|
||||||
portHolder.close();
|
portHolder.close();
|
||||||
portHolder.connectAndReadConfiguration();
|
portHolder.connectAndReadConfiguration();
|
||||||
});
|
});
|
||||||
|
|
|
@ -2,7 +2,6 @@ package com.rusefi.ts_plugin;
|
||||||
|
|
||||||
import com.devexperts.logging.Logging;
|
import com.devexperts.logging.Logging;
|
||||||
import com.efiAnalytics.plugin.ecu.ControllerAccess;
|
import com.efiAnalytics.plugin.ecu.ControllerAccess;
|
||||||
import com.rusefi.auth.AutoTokenUtil;
|
|
||||||
import com.rusefi.shared.FileUtil;
|
import com.rusefi.shared.FileUtil;
|
||||||
import com.rusefi.tools.online.Online;
|
import com.rusefi.tools.online.Online;
|
||||||
import com.rusefi.tools.online.UploadResult;
|
import com.rusefi.tools.online.UploadResult;
|
||||||
|
|
Loading…
Reference in New Issue