diff options
author | Yves Fischer <yvesf-git@xapek.org> | 2014-09-09 19:59:51 +0200 |
---|---|---|
committer | Yves Fischer <yvesf-git@xapek.org> | 2014-09-09 19:59:51 +0200 |
commit | eca476b9136c97f4f2dacc9769c05e9b397c38dc (patch) | |
tree | 6d0aedf259c84e42e613a057d02dce9bc8daca06 /src/org/xapek | |
parent | 612c5fdabe925c35403653b170287ffb5bcb854b (diff) | |
download | andiodine-eca476b9136c97f4f2dacc9769c05e9b397c38dc.tar.gz andiodine-eca476b9136c97f4f2dacc9769c05e9b397c38dc.zip |
Fix crash on close via VPN-popup, issue #12 v1.3-alpha
Diffstat (limited to 'src/org/xapek')
-rw-r--r-- | src/org/xapek/andiodine/FragmentStatus.java | 4 | ||||
-rw-r--r-- | src/org/xapek/andiodine/IodineMain.java | 36 | ||||
-rw-r--r-- | src/org/xapek/andiodine/IodineVpnService.java | 1 |
3 files changed, 27 insertions, 14 deletions
diff --git a/src/org/xapek/andiodine/FragmentStatus.java b/src/org/xapek/andiodine/FragmentStatus.java index c12afd9..c1f709a 100644 --- a/src/org/xapek/andiodine/FragmentStatus.java +++ b/src/org/xapek/andiodine/FragmentStatus.java @@ -46,7 +46,9 @@ public class FragmentStatus extends Fragment { } else if (IodineVpnService.ACTION_STATUS_CONNECT.equals(intent.getAction())) { mStatus.setText("Connect"); } else if (IodineVpnService.ACTION_STATUS_CONNECTED.equals(intent.getAction())) { - mStatus.setText("Connected"); + mStatus.setText("Connected: " + IodineClient.getIp() + '/' + + IodineClient.getNetbits() + " MTU: " + + IodineClient.getMtu() + '\n'); } else if (IodineVpnService.ACTION_STATUS_DISCONNECT.equals(intent.getAction())) { mStatus.setText("Disconnect"); } diff --git a/src/org/xapek/andiodine/IodineMain.java b/src/org/xapek/andiodine/IodineMain.java index b53ea10..f631c1d 100644 --- a/src/org/xapek/andiodine/IodineMain.java +++ b/src/org/xapek/andiodine/IodineMain.java @@ -39,7 +39,8 @@ public class IodineMain extends Activity { ft.replace(R.id.main_fragment_status, fragmentList); ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE); ft.commit(); - } else if (IodineVpnService.ACTION_STATUS_CONNECT.equals(intent.getAction())) { + } else if (IodineVpnService.ACTION_STATUS_CONNECT.equals(intent.getAction()) + || IodineVpnService.ACTION_STATUS_CONNECTED.equals(intent.getAction())) { // Switch to Status Fragment FragmentTransaction ft = getFragmentManager().beginTransaction(); ft.replace(R.id.main_fragment_status, fragmentStatus); @@ -57,12 +58,6 @@ public class IodineMain extends Activity { mConfigDatabase = new ConfigDatabase(this); - IntentFilter intentFilterStatusUpdates = new IntentFilter(); - intentFilterStatusUpdates.addAction(IodineVpnService.ACTION_STATUS_CONNECT); - intentFilterStatusUpdates.addAction(IodineVpnService.ACTION_STATUS_ERROR); - intentFilterStatusUpdates.addAction(IodineVpnService.ACTION_STATUS_IDLE); - registerReceiver(broadcastReceiverStatusUpdates, intentFilterStatusUpdates); - startService(new Intent(this, IodineVpnService.class)); } @@ -73,8 +68,27 @@ public class IodineMain extends Activity { } @Override - protected void onDestroy() { + protected void onResume() { + super.onResume(); + IntentFilter intentFilterStatusUpdates = new IntentFilter(); + intentFilterStatusUpdates.addAction(IodineVpnService.ACTION_STATUS_CONNECT); + intentFilterStatusUpdates.addAction(IodineVpnService.ACTION_STATUS_CONNECTED); + intentFilterStatusUpdates.addAction(IodineVpnService.ACTION_STATUS_ERROR); + intentFilterStatusUpdates.addAction(IodineVpnService.ACTION_STATUS_IDLE); + registerReceiver(broadcastReceiverStatusUpdates, intentFilterStatusUpdates); + + Log.d(TAG, "Request CONTROL_UPDATE"); + sendBroadcast(new Intent(IodineVpnService.ACTION_CONTROL_UPDATE)); + } + + @Override + protected void onPause() { unregisterReceiver(broadcastReceiverStatusUpdates); + super.onPause(); + } + + @Override + protected void onDestroy() { mConfigDatabase.close(); super.onDestroy(); } @@ -89,14 +103,10 @@ public class IodineMain extends Activity { .setCancelable(true)// .create() // .show(); + scanner.close(); } else if (item.getItemId() == R.id.menu_main_add) { startActivity(new Intent(this, IodinePref.class)); } return super.onOptionsItemSelected(item); } - - - private void vpnServiceDisconnect() { - sendBroadcast(new Intent(IodineVpnService.ACTION_CONTROL_DISCONNECT)); - } } diff --git a/src/org/xapek/andiodine/IodineVpnService.java b/src/org/xapek/andiodine/IodineVpnService.java index dcc3715..2adad1c 100644 --- a/src/org/xapek/andiodine/IodineVpnService.java +++ b/src/org/xapek/andiodine/IodineVpnService.java @@ -188,6 +188,7 @@ public class IodineVpnService extends VpnService implements Runnable { } private void sendStatus() { + Log.d(TAG, "Send status: " + currentActionStatus); if (currentActionStatus != null) { Intent intent = new Intent(currentActionStatus); |