Use the I2P Android client library

The build script looks for the client library in Maven Central. It is possible              
to use a local .aar by placing it in a folder "aars" in the base folder, and
uncommenting the flatDir{} section in the base build.gradle.
This commit is contained in:
str4d
2014-07-16 01:45:14 +00:00
parent 4e5fd63c1d
commit e461e5e3c4
7 changed files with 13 additions and 69 deletions

View File

@@ -1,33 +0,0 @@
package net.i2p.android.router.service;
import net.i2p.android.router.service.IRouterStateCallback;
/**
* An interface for determining the state of the I2P RouterService.
*/
interface IRouterState {
/**
* This allows I2P to inform on state changes.
*/
void registerCallback(IRouterStateCallback cb);
/**
* Remove registered callback interface.
*/
void unregisterCallback(IRouterStateCallback cb);
/**
* Determines whether the RouterService has been started. If it hasn't, no
* state changes will ever occur from this RouterService instance, and the
* client should unbind and inform the user that the I2P router is not
* running (and optionally send a net.i2p.android.router.START_I2P Intent).
*/
boolean isStarted();
/**
* Get the state of the I2P router
**/
String getState();
}

View File

@@ -1,13 +0,0 @@
package net.i2p.android.router.service;
/**
* Callback interface used to send synchronous notifications of the current
* RouterService state back to registered clients. Note that this is a
* one-way interface so the server does not block waiting for the client.
*/
oneway interface IRouterStateCallback {
/**
* Called when the state of the I2P router changes
*/
void stateChanged(String newState);
}

View File

@@ -8,6 +8,7 @@ import javax.mail.MessagingException;
import net.i2p.android.router.service.IRouterState;
import net.i2p.android.router.service.IRouterStateCallback;
import net.i2p.android.router.service.State;
import net.i2p.router.Router;
import net.i2p.router.RouterContext;
import net.i2p.router.RouterLaunch;
@@ -146,8 +147,8 @@ public class BoteService extends Service implements NetworkStatusListener, NewEm
mStateService = IRouterState.Stub.asInterface(service);
try {
mStateService.registerCallback(mStatusListener);
String state = mStateService.getState();
if ("ACTIVE".equals(state))
final int state = mStateService.getState();
if (state == State.ACTIVE)
I2PBote.getInstance().connectNow();
} catch (RemoteException e) {
// TODO Auto-generated catch block
@@ -164,11 +165,11 @@ public class BoteService extends Service implements NetworkStatusListener, NewEm
private final IRouterStateCallback.Stub mStatusListener =
new IRouterStateCallback.Stub() {
public void stateChanged(String newState) throws RemoteException {
if ("STOPPING".equals(newState) ||
"MANUAL_STOPPING".equals(newState) ||
"MANUAL_QUITTING".equals(newState) ||
"NETWORK_STOPPING".equals(newState))
public void stateChanged(int newState) throws RemoteException {
if (newState == State.STOPPING ||
newState == State.MANUAL_STOPPING ||
newState == State.MANUAL_QUITTING ||
newState == State.NETWORK_STOPPING)
stopSelf();
}
};