diff options
Diffstat (limited to 'main/src/main/java/de/blinkt/openvpn/OpenVPNTileService.java')
-rw-r--r-- | main/src/main/java/de/blinkt/openvpn/OpenVPNTileService.java | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/main/src/main/java/de/blinkt/openvpn/OpenVPNTileService.java b/main/src/main/java/de/blinkt/openvpn/OpenVPNTileService.java index 3996f25e..ce14cc98 100644 --- a/main/src/main/java/de/blinkt/openvpn/OpenVPNTileService.java +++ b/main/src/main/java/de/blinkt/openvpn/OpenVPNTileService.java @@ -13,11 +13,13 @@ import android.content.Intent; import android.content.ServiceConnection; import android.os.Build; import android.os.IBinder; +import android.os.RemoteException; import android.service.quicksettings.Tile; import android.service.quicksettings.TileService; import android.widget.Toast; import de.blinkt.openvpn.core.ConnectionStatus; +import de.blinkt.openvpn.core.IOpenVPNServiceInternal; import de.blinkt.openvpn.core.OpenVPNService; import de.blinkt.openvpn.core.ProfileManager; import de.blinkt.openvpn.core.VpnStatus; @@ -57,10 +59,14 @@ public class OpenVPNTileService extends TileService implements VpnStatus.StateLi bindService(intent, new ServiceConnection() { @Override public void onServiceConnected(ComponentName componentName, IBinder binder) { - OpenVPNService service = ((OpenVPNService.LocalBinder) binder).getService(); + IOpenVPNServiceInternal service = IOpenVPNServiceInternal.Stub.asInterface(binder); - if (service != null && service.getManagement() != null) - service.getManagement().stopVPN(false); + if (service != null) + try { + service.stopVPN(false); + } catch (RemoteException e) { + VpnStatus.logException(e); + } unbindService(this); } @@ -119,7 +125,7 @@ public class OpenVPNTileService extends TileService implements VpnStatus.StateLi t.setState(Tile.STATE_INACTIVE); } } else { - vpn = ProfileManager.getLastConnectedVpn(); + vpn = ProfileManager.get(getBaseContext(), VpnStatus.getLastConnectedVPNProfile()); String name; if (vpn == null) name = "null?!"; @@ -129,11 +135,15 @@ public class OpenVPNTileService extends TileService implements VpnStatus.StateLi t.setState(Tile.STATE_ACTIVE); } - t.updateTile(); } @Override + public void setConnectedVPN(String uuid) { + + } + + @Override public void onStopListening() { VpnStatus.removeStateListener(this); super.onStopListening(); |