I2P Address: [http://git.idk.i2p]

Skip to content
Snippets Groups Projects
Commit 1219725e authored by zzz's avatar zzz
Browse files

- 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
parent db1932a9
No related branches found
No related tags found
No related merge requests found
Showing
with 143 additions and 98 deletions
......@@ -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>
......
......@@ -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}" />
......
res/drawable/ic_launcher_itoopie_120.png

3.45 KiB

res/drawable/ic_launcher_itoopie_150.png

3.45 KiB

res/drawable/ic_launcher_itoopie_180.png

2.65 KiB

res/drawable/ic_launcher_itoopie_300.png

3.42 KiB

res/drawable/ic_launcher_itoopie_330.png

3.44 KiB

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
......@@ -19,5 +19,5 @@ 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
......@@ -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;
......
......@@ -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 :(
......
......@@ -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);
****/
}
}
......
......@@ -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);
}
}
}
......@@ -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");
}
}
}
......@@ -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() {
......@@ -101,6 +101,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 +124,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 +167,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 +179,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 +201,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 +211,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 +229,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);
}
}
......
......@@ -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();
......
......@@ -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) {
......
......@@ -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);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment