diff options
author | Arne Schwabe <arne@rfc2549.org> | 2016-05-22 11:47:06 +0200 |
---|---|---|
committer | Arne Schwabe <arne@rfc2549.org> | 2016-05-22 11:47:06 +0200 |
commit | d1bf5e72905f681281f6db13005107a31849cb3e (patch) | |
tree | 99debc13291ca82e17d239304ec04eb73a36f95a /main | |
parent | b4c4cf706ecb2f66c87113c2472ce2790404670f (diff) |
Make Tile work in passive mode which suits OpenVPN for Android well enough.
Diffstat (limited to 'main')
-rw-r--r-- | main/src/main/AndroidManifest.xml | 3 | ||||
-rw-r--r-- | main/src/main/java/de/blinkt/openvpn/OpenVPNTileService.java | 18 | ||||
-rw-r--r-- | main/src/main/java/de/blinkt/openvpn/core/OpenVPNService.java | 11 |
3 files changed, 14 insertions, 18 deletions
diff --git a/main/src/main/AndroidManifest.xml b/main/src/main/AndroidManifest.xml index dbc44a68..53509ae4 100644 --- a/main/src/main/AndroidManifest.xml +++ b/main/src/main/AndroidManifest.xml @@ -84,12 +84,15 @@ <service android:name=".OpenVPNTileService" + android:value="true" android:label="@string/qs_title" android:icon="@drawable/icon" android:permission="android.permission.BIND_QUICK_SETTINGS_TILE"> <intent-filter> <action android:name="android.service.quicksettings.action.QS_TILE" /> </intent-filter> + <meta-data android:name="android.service.quicksettings.ACTIVE_TILE" + android:value="false" /> </service> <activity android:name=".api.GrantPermissionsActivity"> diff --git a/main/src/main/java/de/blinkt/openvpn/OpenVPNTileService.java b/main/src/main/java/de/blinkt/openvpn/OpenVPNTileService.java index 244eb62c..7d954894 100644 --- a/main/src/main/java/de/blinkt/openvpn/OpenVPNTileService.java +++ b/main/src/main/java/de/blinkt/openvpn/OpenVPNTileService.java @@ -59,7 +59,7 @@ 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(); + OpenVPNService service = ((OpenVPNService.LocalBinder) binder).getService(); if (service != null && service.getManagement() != null) service.getManagement().stopVPN(false); @@ -72,8 +72,7 @@ public class OpenVPNTileService extends TileService implements VpnStatus.StateLi } }, Context.BIND_AUTO_CREATE); - } - else + } else launchVPN(bootProfile, this); } @@ -90,11 +89,9 @@ public class OpenVPNTileService extends TileService implements VpnStatus.StateLi context.startActivity(startVpnIntent); } - @SuppressLint("Override") @TargetApi(Build.VERSION_CODES.N) @Override - public int onTileAdded() { - return TILE_MODE_ACTIVE; + public void onTileAdded() { } @Override @@ -125,9 +122,16 @@ public class OpenVPNTileService extends TileService implements VpnStatus.StateLi } } else { vpn = ProfileManager.getLastConnectedVpn(); - t.setLabel(getString(R.string.qs_disconnect, vpn.getName())); + String name; + if (vpn == null) + name = "null?!"; + else + name = vpn.getName(); + t.setLabel(getString(R.string.qs_disconnect, name)); t.setState(Tile.STATE_ACTIVE); } + + t.updateTile(); } diff --git a/main/src/main/java/de/blinkt/openvpn/core/OpenVPNService.java b/main/src/main/java/de/blinkt/openvpn/core/OpenVPNService.java index 752fbb2a..321140fd 100644 --- a/main/src/main/java/de/blinkt/openvpn/core/OpenVPNService.java +++ b/main/src/main/java/de/blinkt/openvpn/core/OpenVPNService.java @@ -929,12 +929,6 @@ public class OpenVPNService extends VpnService implements StateListener, Callbac if (mProcessThread == null && !mNotificationAlwaysVisible) return; - - if (Build.VERSION.SDK_INT > Build.VERSION_CODES.M) - tileUpdateN(); - - - boolean lowpriority = false; // Display byte count only after being connected @@ -963,11 +957,6 @@ public class OpenVPNService extends VpnService implements StateListener, Callbac } } - @TargetApi(Build.VERSION_CODES.N) - private void tileUpdateN() { - TileService.requestListeningState(this, new ComponentName(this, OpenVPNTileService.class)); - } - private void doSendBroadcast(String state, ConnectionStatus level) { Intent vpnstatus = new Intent(); vpnstatus.setAction("de.blinkt.openvpn.VPN_STATUS"); |