Added some debug messages.

This commit is contained in:
Adrian Tiberius 2015-06-25 05:01:42 +02:00
parent bac3393c0b
commit cecad8cfd3
1 changed files with 33 additions and 14 deletions

View File

@ -29,6 +29,10 @@ public class EthereumAidlService extends Service {
public static String log = ""; public static String log = "";
boolean isConnected = false;
boolean isInitialized = false;
public EthereumAidlService() { public EthereumAidlService() {
} }
@ -39,6 +43,7 @@ public class EthereumAidlService extends Service {
listener.trace(message); listener.trace(message);
} catch (Exception e) { } catch (Exception e) {
// Remove listener // Remove listener
System.out.println("ERRORRRR: " + e.getMessage());
clientListeners.remove(listener); clientListeners.remove(listener);
} }
} }
@ -53,6 +58,7 @@ public class EthereumAidlService extends Service {
protected void initializeEthereum() { protected void initializeEthereum() {
if (!isInitialized) {
System.setProperty("sun.arch.data.model", "32"); System.setProperty("sun.arch.data.model", "32");
System.setProperty("leveldb.mmap", "false"); System.setProperty("leveldb.mmap", "false");
@ -64,6 +70,11 @@ public class EthereumAidlService extends Service {
.ethereumModule(new EthereumModule(this)) .ethereumModule(new EthereumModule(this))
.build().ethereum(); .build().ethereum();
ethereum.addListener(new EthereumListener()); ethereum.addListener(new EthereumListener());
isInitialized = true;
} else {
System.out.println(" Already initialized");
System.out.println("x " + (ethereum != null));
}
} }
@Override @Override
@ -88,20 +99,28 @@ public class EthereumAidlService extends Service {
public void connect(String ip, int port, String remoteId) throws RemoteException { public void connect(String ip, int port, String remoteId) throws RemoteException {
if (!isConnected) {
System.out.println("Connecting to : " + ip);
ethereum.connect(ip, port, remoteId); ethereum.connect(ip, port, remoteId);
isConnected = true;
} else {
System.out.println("Already connected");
System.out.println("x " + ethereum.isConnected());
}
} }
public void addListener(IListener listener) throws RemoteException { public void addListener(IListener listener) throws RemoteException {
if (!clientListeners.contains(listener)) { clientListeners.clear();
clientListeners.add(listener); clientListeners.add(listener);
} }
}
public void removeListener(IListener listener) throws RemoteException { public void removeListener(IListener listener) throws RemoteException {
if (clientListeners.contains(listener)) { try {
clientListeners.remove(listener); clientListeners.remove(listener);
} catch (Exception e) {
System.out.println("ERRORRRR: " + e.getMessage());
} }
} }