Compare commits

...

5 Commits

Author SHA1 Message Date
zzz
abe20c95d0 - Enable NTP based on SDK version
- Disable SSL reseed (temp until merge)
- Update release notes
- Restrict addressbook to only hosts.txt file
2012-07-30 21:59:15 +00:00
zzz
52a60b37e2 handle core versions without the 3rd digit 2012-06-29 12:43:09 +00:00
zzz
adb5c56f26 disable upnp again 2011-07-10 13:45:25 +00:00
zzz
177ac2e3a1 - Addressbook message tweak
- Tweak log levels
2011-07-05 13:07:03 +00:00
zzz
1219725e6a - Notification icon rotations
- Clean up debug text on main screen
- Move most logging from System.err.println to Util
- Stub out HTTP auth handler
- Don't restart Peers page on orientation change
- Add inbound/outbound arrows, not loaded yet
- Tweak log levels
2011-07-04 16:15:45 +00:00
21 changed files with 172 additions and 111 deletions

View File

@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="net.i2p.android.router"
android.versionCode="4208704"
android.versionName="0.8.7-4_b1-API8"
android.versionCode="4720640"
android.versionName="0.9.1-0_b1-API8"
android:installLocation="preferExternal"
>
<uses-permission android:name="android.permission.INTERNET" />
@ -67,6 +67,7 @@
</activity>
<activity android:name=".activity.PeersActivity"
android:label="I2P Peers and Transport Status"
android:configChanges="orientation|keyboardHidden"
android.theme="@android:style/Theme.NoTitleBar"
android:launchMode="singleTop" >
</activity>

View File

@ -165,6 +165,8 @@
<copy file="LICENSE.txt" tofile="res/raw/license_app_txt" />
<copy file="licenses/LICENSE-Apache2.0.txt" tofile="res/raw/license_apache20_txt" />
<copy file="${i2pbase}/installer/resources/themes/console/images/i2plogo.png" todir="res/drawable/" />
<copy file="${i2pbase}/installer/resources/themes/console/images/outbound.png" todir="res/drawable/" />
<copy file="${i2pbase}/installer/resources/themes/console/images/inbound.png" todir="res/drawable/" />
<copy file="${i2pbase}/installer/resources/themes/console/light/images/header.png" todir="res/drawable/" />
<copy file="${i2pbase}/installer/resources/themes/console/light/console.css" tofile="res/raw/console_css" />
<copy file="${i2pbase}/installer/resources/blocklist.txt" tofile="res/raw/blocklist_txt" />
@ -210,6 +212,8 @@
<target name="distclean" depends="clean">
<delete dir="${jar.libs.dir}" verbose="${verbose}" />
<delete file="res/drawable/i2plogo.png" verbose="${verbose}"/>
<delete file="res/drawable/outbound.png" verbose="${verbose}"/>
<delete file="res/drawable/inbound.png" verbose="${verbose}"/>
<delete file="res/drawable/header.png" verbose="${verbose}"/>
<delete file="res/raw/console_css" verbose="${verbose}"/>
<delete file="res/raw/blocklist_txt" verbose="${verbose}" />

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

View File

@ -1,23 +1,23 @@
logger.consoleBufferSize=250
logger.dateFormat=MM/dd HH:mm:ss.SSS
logger.defaultLevel=INFO
logger.defaultLevel=WARN
logger.displayOnScreen=true
logger.logFileSize=64k
logger.logRotationLimit=2
logger.minimumOnScreenLevel=WARN
logger.record.net.i2p.crypto=WARN
logger.record.net.i2p.router.InNetMessagePool=WARN
logger.record.net.i2p.router.Router=INFO
logger.record.net.i2p.router.Router=WARN
logger.record.net.i2p.router.Shitlist=WARN
logger.record.net.i2p.router.networkdb=WARN
logger.record.net.i2p.router.peermanager=WARN
logger.record.net.i2p.router.peermanager.ProfileOrganizer=WARN
logger.record.net.i2p.router.transport=WARN
logger.record.net.i2p.router.transport=ERROR
logger.record.net.i2p.router.transport.FIFOBandwidthRefiller=ERROR
logger.record.net.i2p.router.tunnel=WARN
logger.record.net.i2p.stat.Rate=ERROR
logger.record.net.i2p.util.I2PThread=ERROR
logger.record.net.i2p.util.LogManager=WARN
logger.record.net.i2p.util.LogWriter=WARN
logger.record.net.i2p.util.NativeBigInteger=DEBUG
logger.record.net.i2p.util.NativeBigInteger=ERROR
logger.record.net.org.cybergarage.util.Debug=DEBUG

View File

@ -1,20 +1,20 @@
******* Please read all of the following *******
This is the first alpha release of the I2P Android app.
This is an alpha release of the I2P Android app.
WARNING - This is ALPHA SOFTWARE. It may crash your phone. Do not rely upon it for strong anonymity. Tunnels may be as short as one hop. There may be serious security holes in the app.
Minimum Android OS is 2.2 (API 8). The app is only tested on the Motorola Droid. It uses a lot of RAM. You need at least 256 MB of RAM. 512 should be much better.
Minimum Android OS is 2.2 (API 8). It uses a lot of RAM. You need at least 256 MB of RAM. 512 should be much better.
The app may use a lot of RAM even after the router has stopped and there is no icon in the notification bar. Go to Settings -> Applications -> Running Services and stop the I2P service if necessary. Or Settings -> Applications -> Manage Applications -> Running -> I2P and force stop.
The app may be moved to the SD card if you have Froyo (2.2) or higher. The app does not store any files on the SD card.
The app may be moved to the SD card. The app does not store any files on the SD card.
The app runs on either WIFI or mobile networks. For now, the app is very low bandwidth, as it does not allow participating tunnels. It does not route traffic for other routers.
The app uses TCP only for router-router connections, with a maximum of 24 simultaneous. UDP is disabled.
UPnP is enabled but it doesn't appear to be working.
UPnP is disabled. With UDP disabled also, you do not publish an IP address and should not be getting incoming connections.
NTP is disabled. If you have cell service, your phone or tablet should have the correct time. If you do not have cell service, ensure your device has accurate time.

View File

@ -20,6 +20,7 @@ i2cp.disableInterface=true
# Todo: implement a NamingService using the android native SQLite
#
i2p.naming.impl=net.i2p.client.naming.HostsTxtNamingService
i2p.hostsfilelist=hosts.txt
#
##### Tunnels
#
@ -49,9 +50,10 @@ i2np.ntcp.maxConnections=24
i2np.udp.enable=false
i2np.udp.maxConnections=12
#
# no COMM at all!!!
#i2p.vmCommSystem=true
#
# not on android
i2np.upnp.enable=true
i2np.upnp.enable=false
routerconsole.geoip.enable=false
#
# temp until certs are included
router.reseedSSLDisable=true

View File

@ -14,6 +14,7 @@ CORE=`grep 'public final static String VERSION' $I2PBASE/core/java/src/net/i2p/C
MAJOR=`echo $CORE | cut -d '.' -f 1`
MINOR=`echo $CORE | cut -d '.' -f 2`
RELEASE=`echo $CORE | cut -d '.' -f 3`
RELEASE=${RELEASE:-0}
ROUTERBUILD=$((`grep 'public final static long BUILD' $I2PBASE/router/java/src/net/i2p/router/RouterVersion.java | \
cut -d '=' -f 2 | \
@ -26,7 +27,7 @@ SDK=`grep 'android:minSdkVersion' $MANIFEST | \
cut -d '"' -f 2`
# don't let build number get too long
VERSIONSTRING="${CORE}-${ROUTERBUILD}_b$(($ANDROIDBUILD % 512))-API$SDK"
VERSIONSTRING="${MAJOR}.${MINOR}.${RELEASE}-${ROUTERBUILD}_b$(($ANDROIDBUILD % 512))-API$SDK"
#
# Android version code is an integer.

View File

@ -39,14 +39,21 @@ public class AddressbookActivity extends ListActivity {
// get the names
NamingService ns = ctx.namingService();
// After router shutdown we get nothing... why?
Set<String> names = ns.getNames();
// set the header
TextView tv = (TextView) getLayoutInflater().inflate(R.layout.addressbook_header, null);
tv.setText(names.size() + " hosts in address book. Start typing to filter.");
int sz = names.size();
if (sz > 1)
tv.setText(sz + " hosts in address book. Start typing to filter.");
else if (sz > 0)
tv.setText("1 host in address book.");
else
tv.setText("No hosts in address book, or your router is not up.");
ListView lv = getListView();
lv.addHeaderView(tv, "", false);
lv.setTextFilterEnabled(true);
lv.setTextFilterEnabled(sz > 1);
// set the list
List<String> nameList = new ArrayList(names);

View File

@ -41,7 +41,7 @@ public abstract class I2PActivityBase extends Activity {
@Override
public void onCreate(Bundle savedInstanceState)
{
System.err.println(this + " onCreate called");
Util.i(this + " onCreate called");
super.onCreate(savedInstanceState);
_myDir = getFilesDir().getAbsolutePath();
}
@ -49,14 +49,14 @@ public abstract class I2PActivityBase extends Activity {
@Override
public void onRestart()
{
System.err.println(this + " onRestart called");
Util.i(this + " onRestart called");
super.onRestart();
}
@Override
public void onStart()
{
System.err.println(this + " onStart called");
Util.i(this + " onStart called");
super.onStart();
_sharedPrefs = getSharedPreferences(SHARED_PREFS, 0);
if (_sharedPrefs.getBoolean(PREF_AUTO_START, DEFAULT_AUTO_START))
@ -87,28 +87,28 @@ public abstract class I2PActivityBase extends Activity {
@Override
public void onResume()
{
System.err.println(this + " onResume called");
Util.i(this + " onResume called");
super.onResume();
}
@Override
public void onPause()
{
System.err.println(this + " onPause called");
Util.i(this + " onPause called");
super.onPause();
}
@Override
public void onSaveInstanceState(Bundle outState)
{
System.err.println(this + " onSaveInstanceState called");
Util.i(this + " onSaveInstanceState called");
super.onSaveInstanceState(outState);
}
@Override
public void onStop()
{
System.err.println(this + " onStop called");
Util.i(this + " onStop called");
unbindRouter();
super.onStop();
}
@ -116,7 +116,7 @@ public abstract class I2PActivityBase extends Activity {
@Override
public void onDestroy()
{
System.err.println(this + " onDestroy called");
Util.i(this + " onDestroy called");
super.onDestroy();
}
@ -151,9 +151,11 @@ public abstract class I2PActivityBase extends Activity {
MenuItem addressbook = menu.findItem(R.id.menu_addressbook);
addressbook.setVisible(showAddressbook);
addressbook.setEnabled(showAddressbook);
boolean showReload = showAddressbook || (this instanceof PeersActivity);
MenuItem reload = menu.findItem(R.id.menu_reload);
reload.setVisible(showAddressbook);
reload.setEnabled(showAddressbook);
reload.setVisible(showReload);
reload.setEnabled(showReload);
return super.onPrepareOptionsMenu(menu);
}
@ -208,14 +210,14 @@ public abstract class I2PActivityBase extends Activity {
protected boolean startRouter() {
Intent intent = new Intent();
intent.setClassName(this, "net.i2p.android.router.service.RouterService");
System.err.println(this + " calling startService");
Util.i(this + " calling startService");
ComponentName name = startService(intent);
if (name == null)
System.err.println(this + " XXXXXXXXXXXXXXXXXXXX got from startService: " + name);
System.err.println(this + " got from startService: " + name);
Util.i(this + " XXXXXXXXXXXXXXXXXXXX got from startService: " + name);
Util.i(this + " got from startService: " + name);
boolean success = bindRouter(true);
if (!success)
System.err.println(this + " Bind router failed");
Util.i(this + " Bind router failed");
return success;
}
@ -225,10 +227,10 @@ public abstract class I2PActivityBase extends Activity {
protected boolean bindRouter(boolean autoCreate) {
Intent intent = new Intent();
intent.setClassName(this, "net.i2p.android.router.service.RouterService");
System.err.println(this + " calling bindService");
Util.i(this + " calling bindService");
_connection = new RouterConnection();
boolean success = bindService(intent, _connection, autoCreate ? BIND_AUTO_CREATE : 0);
System.err.println(this + " bindService: auto create? " + autoCreate + " success? " + success);
Util.i(this + " bindService: auto create? " + autoCreate + " success? " + success);
return success;
}
@ -243,7 +245,7 @@ public abstract class I2PActivityBase extends Activity {
protected class RouterConnection implements ServiceConnection {
public void onServiceConnected(ComponentName name, IBinder service) {
System.err.println(this + " connected to router service");
Util.i(this + " connected to router service");
RouterBinder binder = (RouterBinder) service;
RouterService svc = binder.getService();
_routerService = svc;
@ -252,7 +254,7 @@ public abstract class I2PActivityBase extends Activity {
}
public void onServiceDisconnected(ComponentName name) {
System.err.println(this + " disconnected from router service!!!!!!!");
Util.i(this + " disconnected from router service!!!!!!!");
// save memory
_routerService = null;
_isBound = false;

View File

@ -9,6 +9,7 @@ import android.net.Uri;
import android.os.AsyncTask;
import android.view.Gravity;
import android.view.View;
import android.webkit.HttpAuthHandler;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.Toast;
@ -173,6 +174,12 @@ class I2PWebViewClient extends WebViewClient {
super.onPageFinished(view, url);
}
@Override
public void onReceivedHttpAuthRequest(WebView view, HttpAuthHandler handler, String host, String realm) {
Util.e("ORHAR URL: " + host);
super.onReceivedHttpAuthRequest(view, handler, host, realm);
}
/******
API 11 :(

View File

@ -256,11 +256,11 @@ public class MainActivity extends I2PActivityBase {
private void updateStatus() {
RouterContext ctx = getRouterContext();
TextView tv = (TextView) findViewById(R.id.main_status_text);
/***
if (!Util.isConnected(this)) {
tv.setText("No Internet connection is available");
tv.setVisibility(View.VISIBLE);
} else ****/ if (ctx != null) {
} else if (ctx != null) {
int active = ctx.commSystem().countActivePeers();
int known = Math.max(ctx.netDb().getKnownRouters() - 1, 0);
int inEx = ctx.tunnelManager().getFreeTunnelCount();
@ -303,7 +303,9 @@ public class MainActivity extends I2PActivityBase {
tv.setText(_savedStatus);
tv.setVisibility(View.VISIBLE);
} else {
//tv.setVisibility(View.INVISIBLE);
// network but no router context
tv.setVisibility(View.INVISIBLE);
/****
RouterService svc = _routerService;
String status =
"connected? " + Util.isConnected(this) +
@ -317,6 +319,7 @@ public class MainActivity extends I2PActivityBase {
"\ncan stop? " + (svc == null ? "null" : svc.canManualStop());
tv.setText(status);
tv.setVisibility(View.VISIBLE);
****/
}
}

View File

@ -2,6 +2,7 @@ package net.i2p.android.router.activity;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.MenuItem;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.TextView;
@ -70,6 +71,9 @@ public class PeersActivity extends I2PActivityBase {
}
try {
wv.loadData(data, "text/html", "UTF-8");
// figure out a way to get /themes/console/images/outbound.png to load
//String url = "file://" + _myDir + "/docs/";
//wv.loadDataWithBaseURL(url, data, "text/html", "UTF-8", url);
} catch (Exception e) {
}
}
@ -87,4 +91,17 @@ public class PeersActivity extends I2PActivityBase {
}
return super.onKeyDown(keyCode, event);
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
WebView wv = (WebView) findViewById(R.id.peers_webview);
switch (item.getItemId()) {
case R.id.menu_reload:
update();
return true;
default:
return super.onOptionsItemSelected(item);
}
}
}

View File

@ -38,7 +38,7 @@ public class I2PReceiver extends BroadcastReceiver {
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
System.err.println("Got broadcast: " + action);
//Util.w("Got broadcast: " + action);
if (action.equals(ConnectivityManager.CONNECTIVITY_ACTION)) {
boolean failover = intent.getBooleanExtra(ConnectivityManager.EXTRA_IS_FAILOVER, false);
@ -47,7 +47,7 @@ public class I2PReceiver extends BroadcastReceiver {
NetworkInfo other = (NetworkInfo) intent.getParcelableExtra(ConnectivityManager.EXTRA_OTHER_NETWORK_INFO);
/*****
System.err.println("No conn? " + noConn + " failover? " + failover +
Util.w("No conn? " + noConn + " failover? " + failover +
" info: " + info + " other: " + other);
printInfo(info);
printInfo(other);
@ -63,10 +63,10 @@ public class I2PReceiver extends BroadcastReceiver {
if (++_unconnectedCount >= 3) {
RouterService svc = _routerService;
if (_isBound && svc != null) {
System.err.println("********* Network down, already bound");
Util.w("********* Network down, already bound");
svc.networkStop();
} else {
System.err.println("********* Network down, binding to router");
Util.w("********* Network down, binding to router");
// connection will call networkStop()
bindRouter();
}
@ -81,10 +81,10 @@ public class I2PReceiver extends BroadcastReceiver {
/****
private static void printInfo(NetworkInfo ni) {
if (ni == null) {
System.err.println("Network info is null");
Util.w("Network info is null");
return;
}
System.err.println(
Util.w(
"state: " + ni.getState() +
" detail: " + ni.getDetailedState() +
" extrainfo: " + ni.getExtraInfo() +
@ -101,10 +101,10 @@ public class I2PReceiver extends BroadcastReceiver {
private boolean bindRouter() {
Intent intent = new Intent();
intent.setClassName(_context, "net.i2p.android.router.service.RouterService");
System.err.println(this + " calling bindService");
Util.w(this + " calling bindService");
_connection = new RouterConnection();
boolean success = _context.bindService(intent, _connection, 0);
System.err.println(this + " got from bindService: " + success);
Util.w(this + " got from bindService: " + success);
return success;
}
@ -123,7 +123,7 @@ public class I2PReceiver extends BroadcastReceiver {
_isBound = true;
_unconnectedCount = 0;
_wasConnected = false;
System.err.println("********* Network down, stopping router");
Util.w("********* Network down, stopping router");
_routerService.networkStop();
// this doesn't work here... TODO where to unbind
//_context.unbindService(this);
@ -132,7 +132,7 @@ public class I2PReceiver extends BroadcastReceiver {
public void onServiceDisconnected(ComponentName name) {
_isBound = false;
_routerService = null;
System.err.println("********* Receiver unbinding from router");
Util.w("********* Receiver unbinding from router");
}
}
}

View File

@ -41,23 +41,23 @@ class Init {
}
void debugStuff() {
System.err.println("java.io.tmpdir" + ": " + System.getProperty("java.io.tmpdir"));
System.err.println("java.vendor" + ": " + System.getProperty("java.vendor"));
System.err.println("java.version" + ": " + System.getProperty("java.version"));
System.err.println("os.arch" + ": " + System.getProperty("os.arch"));
System.err.println("os.name" + ": " + System.getProperty("os.name"));
System.err.println("os.version" + ": " + System.getProperty("os.version"));
System.err.println("user.dir" + ": " + System.getProperty("user.dir"));
System.err.println("user.home" + ": " + System.getProperty("user.home"));
System.err.println("user.name" + ": " + System.getProperty("user.name"));
System.err.println("getFilesDir()" + ": " + myDir);
System.err.println("max mem" + ": " + DataHelper.formatSize(Runtime.getRuntime().maxMemory()));
System.err.println("Package" + ": " + ctx.getPackageName());
System.err.println("Version" + ": " + _ourVersion);
System.err.println("MODEL" + ": " + Build.MODEL);
System.err.println("DISPLAY" + ": " + Build.DISPLAY);
System.err.println("VERSION" + ": " + Build.VERSION.RELEASE);
System.err.println("SDK" + ": " + Build.VERSION.SDK);
Util.i("java.io.tmpdir" + ": " + System.getProperty("java.io.tmpdir"));
Util.i("java.vendor" + ": " + System.getProperty("java.vendor"));
Util.i("java.version" + ": " + System.getProperty("java.version"));
Util.i("os.arch" + ": " + System.getProperty("os.arch"));
Util.i("os.name" + ": " + System.getProperty("os.name"));
Util.i("os.version" + ": " + System.getProperty("os.version"));
Util.i("user.dir" + ": " + System.getProperty("user.dir"));
Util.i("user.home" + ": " + System.getProperty("user.home"));
Util.i("user.name" + ": " + System.getProperty("user.name"));
Util.i("getFilesDir()" + ": " + myDir);
Util.i("max mem" + ": " + DataHelper.formatSize(Runtime.getRuntime().maxMemory()));
Util.i("Package" + ": " + ctx.getPackageName());
Util.i("Version" + ": " + _ourVersion);
Util.i("MODEL" + ": " + Build.MODEL);
Util.i("DISPLAY" + ": " + Build.DISPLAY);
Util.i("VERSION" + ": " + Build.VERSION.RELEASE);
Util.i("SDK" + ": " + Build.VERSION.SDK);
}
void initialize() {
@ -65,6 +65,12 @@ class Init {
Properties props = new Properties();
props.setProperty("i2p.dir.temp", myDir + "/tmp");
props.setProperty("i2p.dir.pid", myDir + "/tmp");
// Time disabled in default router.config
// But lots of time problems on Android, not all carriers support NITZ
// and there was no NTP before 3.0. Tablets should be fine?
// Phones in airplane mode with wifi enabled still a problem.
if (Build.VERSION.SDK_INT < 11) // Honeycomb 3.0
props.setProperty("time.disabled", "false");
mergeResourceToFile(R.raw.router_config, "router.config", props);
mergeResourceToFile(R.raw.logger_config, "logger.config", null);
mergeResourceToFile(R.raw.i2ptunnel_config, "i2ptunnel.config", null);
@ -101,6 +107,8 @@ class Init {
imgDir.mkdir();
copyResourceToFile(R.drawable.i2plogo, "docs/themes/console/images/i2plogo.png");
copyResourceToFile(R.drawable.itoopie_sm, "docs/themes/console/images/itoopie_sm.png");
copyResourceToFile(R.drawable.outbound, "docs/themes/console/images/outbound.png");
copyResourceToFile(R.drawable.inbound, "docs/themes/console/images/inbound.png");
File img2Dir = new File(cssDir, "images");
img2Dir.mkdir();
@ -122,7 +130,7 @@ class Init {
InputStream in = null;
FileOutputStream out = null;
System.err.println("Creating file " + f + " from resource");
Util.i("Creating file " + f + " from resource");
byte buf[] = new byte[4096];
try {
// Context methods
@ -165,9 +173,9 @@ class Init {
try {
fin = new FileInputStream(new File(myDir, f));
DataHelper.loadProps(props, fin);
System.err.println("Merging resource into file " + f);
Util.i("Merging resource into file " + f);
} catch (IOException ioe) {
System.err.println("Creating file " + f + " from resource");
Util.i("Creating file " + f + " from resource");
}
// override user settings
@ -177,7 +185,7 @@ class Init {
props.putAll(overrides);
File path = new File(myDir, f);
DataHelper.storeProps(props, path);
System.err.println("Saved " + props.size() +" properties in " + f);
Util.i("Saved " + props.size() +" properties in " + f);
} catch (IOException ioe) {
} catch (Resources.NotFoundException nfe) {
} finally {
@ -199,7 +207,7 @@ class Init {
fin = ctx.openFileInput(CONFIG_FILE);
DataHelper.loadProps(props, fin);
} catch (IOException ioe) {
System.err.println("Looks like a new install");
Util.i("Looks like a new install");
} finally {
if (fin != null) try { fin.close(); } catch (IOException ioe) {}
}
@ -209,12 +217,12 @@ class Init {
boolean newVersion = !_ourVersion.equals(oldVersion);
if (newVersion) {
System.err.println("New version " + _ourVersion);
Util.i("New version " + _ourVersion);
props.setProperty(PROP_INSTALLED_VERSION, _ourVersion);
try {
DataHelper.storeProps(props, ctx.getFileStreamPath(CONFIG_FILE));
} catch (IOException ioe) {
System.err.println("Failed to write " + CONFIG_FILE);
Util.i("Failed to write " + CONFIG_FILE);
}
}
return newVersion;
@ -227,7 +235,7 @@ class Init {
if (files != null) {
for (int i = 0; i < files.length; i++) {
File f = files[i];
System.err.println("Deleting old file/dir " + f);
Util.i("Deleting old file/dir " + f);
FileUtil.rmdir(f, false);
}
}

View File

@ -2,6 +2,7 @@ package net.i2p.android.router.service;
import net.i2p.addressbook.DaemonThread;
import net.i2p.android.apps.NewsFetcher;
import net.i2p.android.router.util.Util;
import net.i2p.i2ptunnel.TunnelControllerGroup;
import net.i2p.router.Job;
import net.i2p.router.JobImpl;
@ -71,17 +72,17 @@ class LoadClientsJob extends JobImpl {
public String getName() { return "Start I2P Tunnel"; };
public void runJob() {
System.err.println("Starting i2ptunnel");
Util.i("Starting i2ptunnel");
TunnelControllerGroup tcg = TunnelControllerGroup.getInstance();
int sz = tcg.getControllers().size();
System.err.println("i2ptunnel started " + sz + " clients");
Util.i("i2ptunnel started " + sz + " clients");
}
}
private class ClientShutdownHook implements Runnable {
public void run() {
System.err.println("client shutdown hook");
Util.i("client shutdown hook");
// i2ptunnel registers its own hook
if (_fetcherThread != null)
_fetcherThread.interrupt();

View File

@ -60,7 +60,7 @@ public class RouterService extends Service {
public void onCreate() {
State lastState = getSavedState();
setState(State.INIT);
System.err.println(this + " onCreate called" +
Util.i(this + " onCreate called" +
" Saved state is: " + lastState +
" Current state is: " + _state);
@ -86,14 +86,14 @@ public class RouterService extends Service {
/** NOT called by system if it restarts us after a crash */
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
System.err.println(this + " onStart called" +
Util.i(this + " onStart called" +
" Intent is: " + intent +
" Flags is: " + flags +
" ID is: " + startId +
" Current state is: " + _state);
boolean restart = intent != null && intent.getBooleanExtra(EXTRA_RESTART, false);
if (restart)
System.err.println(this + " RESTARTING");
Util.i(this + " RESTARTING");
synchronized (_stateLock) {
if (_state != State.INIT)
//return START_STICKY;
@ -101,14 +101,14 @@ public class RouterService extends Service {
_receiver = new I2PReceiver(this);
if (Util.isConnected(this)) {
if (restart)
_statusBar.replace("I2P is restarting");
_statusBar.replace(StatusBar.ICON1, "I2P is restarting");
else
_statusBar.replace("I2P is starting up");
_statusBar.replace(StatusBar.ICON1, "I2P is starting up");
setState(State.STARTING);
_starterThread = new Thread(new Starter());
_starterThread.start();
} else {
_statusBar.replace("I2P is waiting for a network connection");
_statusBar.replace(StatusBar.ICON6, "I2P is waiting for a network connection");
setState(State.WAITING);
_handler.postDelayed(new Waiter(), 10*1000);
}
@ -123,14 +123,14 @@ public class RouterService extends Service {
/** maybe this goes away when the receiver can bind to us */
private class Waiter implements Runnable {
public void run() {
System.err.println(MARKER + this + " waiter handler" +
Util.i(MARKER + this + " waiter handler" +
" Current state is: " + _state);
if (_state == State.WAITING) {
if (Util.isConnected(RouterService.this)) {
synchronized (_stateLock) {
if (_state != State.WAITING)
return;
_statusBar.replace("Network connected, I2P is starting up");
_statusBar.replace(StatusBar.ICON1, "Network connected, I2P is starting up");
setState(State.STARTING);
_starterThread = new Thread(new Starter());
_starterThread.start();
@ -144,11 +144,11 @@ public class RouterService extends Service {
private class Starter implements Runnable {
public void run() {
System.err.println(MARKER + this + " starter thread" +
Util.i(MARKER + this + " starter thread" +
" Current state is: " + _state);
//System.err.println(MARKER + this + " JBigI speed test started");
//Util.i(MARKER + this + " JBigI speed test started");
//NativeBigInteger.main(null);
//System.err.println(MARKER + this + " JBigI speed test finished, launching router");
//Util.i(MARKER + this + " JBigI speed test finished, launching router");
RouterLaunch.main(null);
synchronized (_stateLock) {
if (_state != State.STARTING)
@ -157,7 +157,7 @@ public class RouterService extends Service {
List contexts = RouterContext.listContexts();
if ( (contexts == null) || (contexts.isEmpty()) )
throw new IllegalStateException("No contexts. This is usually because the router is either starting up or shutting down.");
_statusBar.update("I2P is running");
_statusBar.replace(StatusBar.ICON2, "I2P is running");
_context = (RouterContext)contexts.get(0);
_context.router().setKillVMOnEnd(false);
Job loadJob = new LoadClientsJob(_context);
@ -166,7 +166,7 @@ public class RouterService extends Service {
_context.addFinalShutdownTask(new FinalShutdownHook());
_starterThread = null;
}
System.err.println("Router.main finished");
Util.i("Router.main finished");
}
}
@ -215,9 +215,9 @@ public class RouterService extends Service {
boolean haveTunnels = inCl > 0 && outCl > 0;
if (haveTunnels != _hadTunnels) {
if (haveTunnels)
_statusBar.replace("Client tunnels are ready");
_statusBar.replace(StatusBar.ICON3, "Client tunnels are ready");
else
_statusBar.replace("Client tunnels are down");
_statusBar.replace(StatusBar.ICON2, "Client tunnels are down");
_hadTunnels = haveTunnels;
}
_statusBar.update(status, details);
@ -226,7 +226,7 @@ public class RouterService extends Service {
@Override
public IBinder onBind(Intent intent)
{
System.err.println(this + "onBind called" +
Util.i(this + "onBind called" +
" Current state is: " + _state);
return _binder;
}
@ -264,7 +264,7 @@ public class RouterService extends Service {
* Stop and don't restart the router, but keep the service
*/
public void manualStop() {
System.err.println("manualStop called" +
Util.i("manualStop called" +
" Current state is: " + _state);
synchronized (_stateLock) {
if (!canManualStop())
@ -272,7 +272,7 @@ public class RouterService extends Service {
if (_state == State.STARTING)
_starterThread.interrupt();
if (_state == State.STARTING || _state == State.RUNNING) {
_statusBar.replace("Stopping I2P");
_statusBar.replace(StatusBar.ICON4, "Stopping I2P");
Thread stopperThread = new Thread(new Stopper(State.MANUAL_STOPPING, State.MANUAL_STOPPED));
stopperThread.start();
}
@ -283,7 +283,7 @@ public class RouterService extends Service {
* Stop the router and kill the service
*/
public void manualQuit() {
System.err.println("manualQuit called" +
Util.i("manualQuit called" +
" Current state is: " + _state);
synchronized (_stateLock) {
if (!canManualStop())
@ -291,7 +291,7 @@ public class RouterService extends Service {
if (_state == State.STARTING)
_starterThread.interrupt();
if (_state == State.STARTING || _state == State.RUNNING) {
_statusBar.replace("Stopping I2P");
_statusBar.replace(StatusBar.ICON4, "Stopping I2P");
Thread stopperThread = new Thread(new Stopper(State.MANUAL_QUITTING, State.MANUAL_QUITTED));
stopperThread.start();
} else if (_state == State.WAITING) {
@ -305,13 +305,13 @@ public class RouterService extends Service {
* Stop and then spin waiting for a network connection, then restart
*/
public void networkStop() {
System.err.println("networkStop called" +
Util.i("networkStop called" +
" Current state is: " + _state);
synchronized (_stateLock) {
if (_state == State.STARTING)
_starterThread.interrupt();
if (_state == State.STARTING || _state == State.RUNNING) {
_statusBar.replace("Network disconnected, stopping I2P");
_statusBar.replace(StatusBar.ICON4, "Network disconnected, stopping I2P");
// don't change state, let the shutdown hook do it
Thread stopperThread = new Thread(new Stopper(State.NETWORK_STOPPING, State.NETWORK_STOPPING));
stopperThread.start();
@ -325,12 +325,12 @@ public class RouterService extends Service {
}
public void manualStart() {
System.err.println("restart called" +
Util.i("restart called" +
" Current state is: " + _state);
synchronized (_stateLock) {
if (!canManualStart())
return;
_statusBar.replace("I2P is starting up");
_statusBar.replace(StatusBar.ICON1, "I2P is starting up");
setState(State.STARTING);
_starterThread = new Thread(new Starter());
_starterThread.start();
@ -346,7 +346,7 @@ public class RouterService extends Service {
*/
@Override
public void onDestroy() {
System.err.println("onDestroy called" +
Util.i("onDestroy called" +
" Current state is: " + _state);
_handler.removeCallbacks(_updater);
@ -368,7 +368,7 @@ public class RouterService extends Service {
_starterThread.interrupt();
if (_state == State.STARTING || _state == State.RUNNING) {
// should this be in a thread?
_statusBar.replace("I2P is shutting down");
_statusBar.replace(StatusBar.ICON5, "I2P is shutting down");
Thread stopperThread = new Thread(new Stopper(State.STOPPING, State.STOPPED));
stopperThread.start();
}
@ -393,13 +393,13 @@ public class RouterService extends Service {
}
public void run() {
System.err.println(MARKER + this + " stopper thread" +
Util.i(MARKER + this + " stopper thread" +
" Current state is: " + _state);
RouterContext ctx = _context;
if (ctx != null)
ctx.router().shutdown(Router.EXIT_HARD);
_statusBar.off();
System.err.println("********** Router shutdown complete");
Util.i("********** Router shutdown complete");
synchronized (_stateLock) {
if (_state == nextState)
setState(stopState);
@ -414,9 +414,9 @@ public class RouterService extends Service {
*/
private class ShutdownHook implements Runnable {
public void run() {
System.err.println(this + " shutdown hook" +
Util.i(this + " shutdown hook" +
" Current state is: " + _state);
_statusBar.replace("I2P is shutting down");
_statusBar.replace(StatusBar.ICON5, "I2P is shutting down");
I2PReceiver rcvr = _receiver;
if (rcvr != null) {
synchronized(rcvr) {
@ -450,7 +450,7 @@ public class RouterService extends Service {
*/
private class FinalShutdownHook implements Runnable {
public void run() {
System.err.println(this + " final shutdown hook" +
Util.i(this + " final shutdown hook" +
" Current state is: " + _state);
_statusBar.off();
//I2PReceiver rcvr = _receiver;
@ -469,7 +469,7 @@ public class RouterService extends Service {
_handler.postDelayed(new Waiter(), 10*1000);
} else if (_state == State.STARTING || _state == State.RUNNING ||
_state == State.STOPPING) {
System.err.println(this + " died of unknown causes");
Util.i(this + " died of unknown causes");
setState(State.STOPPED);
stopSelf();
} else if (_state == State.MANUAL_QUITTING) {

View File

@ -11,7 +11,7 @@ import java.lang.Thread.UncaughtExceptionHandler;
import net.i2p.android.router.R;
import net.i2p.android.router.activity.MainActivity;
public class StatusBar {
class StatusBar {
private final Context ctx;
private final Intent intent;
@ -20,13 +20,20 @@ public class StatusBar {
private static final int ID = 1;
public static final int ICON1 = R.drawable.ic_launcher_itoopie_300;
public static final int ICON2 = R.drawable.ic_launcher_itoopie_330;
public static final int ICON3 = R.drawable.ic_launcher_itoopie;
public static final int ICON4 = R.drawable.ic_launcher_itoopie_120;
public static final int ICON5 = R.drawable.ic_launcher_itoopie_150;
public static final int ICON6 = R.drawable.ic_launcher_itoopie_180;
StatusBar(Context cx) {
ctx = cx;
String ns = Context.NOTIFICATION_SERVICE;
mgr = (NotificationManager)ctx.getSystemService(ns);
Thread.currentThread().setUncaughtExceptionHandler(new CrashHandler(mgr));
int icon = R.drawable.ic_launcher_itoopie;
int icon = ICON1;
// won't be shown if replace() is called
String text = "Starting I2P";
long now = System.currentTimeMillis();
@ -37,9 +44,10 @@ public class StatusBar {
}
/** remove and re-add */
public void replace(String tickerText) {
public void replace(int icon, String tickerText) {
off();
notif.tickerText = tickerText;
notif.icon = icon;
notif.tickerText= tickerText;
update(tickerText);
}