diff options
author | Jason A. Donenfeld <Jason@zx2c4.com> | 2018-12-11 03:24:34 +0100 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2018-12-11 03:47:32 +0100 |
commit | dc2463a0ab032e09afbd4aaac5eeb1992c53d55e (patch) | |
tree | 392478daa48cd0b8883e98ad7426dc0e8c3e32d5 /app/src/main/java/com/wireguard/android/backend | |
parent | b514717076be159077cd1956928c1c51ba7b7225 (diff) |
Fix locale usage
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'app/src/main/java/com/wireguard/android/backend')
-rw-r--r-- | app/src/main/java/com/wireguard/android/backend/GoBackend.java | 15 | ||||
-rw-r--r-- | app/src/main/java/com/wireguard/android/backend/WgQuickBackend.java | 6 |
2 files changed, 10 insertions, 11 deletions
diff --git a/app/src/main/java/com/wireguard/android/backend/GoBackend.java b/app/src/main/java/com/wireguard/android/backend/GoBackend.java index e9ac079b..b9cb573d 100644 --- a/app/src/main/java/com/wireguard/android/backend/GoBackend.java +++ b/app/src/main/java/com/wireguard/android/backend/GoBackend.java @@ -27,7 +27,6 @@ import com.wireguard.config.Peer; import java.net.InetAddress; import java.util.Collections; -import java.util.Locale; import java.util.Objects; import java.util.Set; import java.util.concurrent.TimeUnit; @@ -96,7 +95,7 @@ public final class GoBackend implements Backend { @Override public String getTypePrettyName() { - return context.getResources().getString(R.string.type_name_go_userspace); + return context.getString(R.string.type_name_go_userspace); } @Override @@ -112,7 +111,7 @@ public final class GoBackend implements Backend { if (state == originalState) return originalState; if (state == State.UP && currentTunnel != null) - throw new IllegalStateException(context.getResources().getString(R.string.multiple_tunnels_error)); + throw new IllegalStateException(context.getString(R.string.multiple_tunnels_error)); Log.d(TAG, "Changing tunnel " + tunnel.getName() + " to state " + state); setStateInternal(tunnel, tunnel.getConfig(), state); return getState(tunnel); @@ -124,10 +123,10 @@ public final class GoBackend implements Backend { if (state == State.UP) { Log.i(TAG, "Bringing tunnel up"); - Objects.requireNonNull(config, context.getResources().getString(R.string.no_config_error)); + Objects.requireNonNull(config, context.getString(R.string.no_config_error)); if (VpnService.prepare(context) != null) - throw new Exception(context.getResources().getString(R.string.vpn_not_authed_error)); + throw new Exception(context.getString(R.string.vpn_not_authed_error)); final VpnService service; if (!vpnService.isDone()) @@ -136,7 +135,7 @@ public final class GoBackend implements Backend { try { service = vpnService.get(2, TimeUnit.SECONDS); } catch (final TimeoutException e) { - throw new Exception(context.getResources().getString(R.string.vpn_start_error), e); + throw new Exception(context.getString(R.string.vpn_start_error), e); } if (currentTunnelHandle != -1) { @@ -174,12 +173,12 @@ public final class GoBackend implements Backend { builder.setBlocking(true); try (final ParcelFileDescriptor tun = builder.establish()) { if (tun == null) - throw new Exception(context.getResources().getString(R.string.tun_create_error)); + throw new Exception(context.getString(R.string.tun_create_error)); Log.d(TAG, "Go backend v" + wgVersion()); currentTunnelHandle = wgTurnOn(tunnel.getName(), tun.detachFd(), goConfig); } if (currentTunnelHandle < 0) - throw new Exception(String.format(Locale.getDefault(), context.getResources().getString(R.string.tunnel_on_error), currentTunnelHandle)); + throw new Exception(context.getString(R.string.tunnel_on_error, currentTunnelHandle)); currentTunnel = tunnel; diff --git a/app/src/main/java/com/wireguard/android/backend/WgQuickBackend.java b/app/src/main/java/com/wireguard/android/backend/WgQuickBackend.java index 7535b95c..25f48d07 100644 --- a/app/src/main/java/com/wireguard/android/backend/WgQuickBackend.java +++ b/app/src/main/java/com/wireguard/android/backend/WgQuickBackend.java @@ -88,7 +88,7 @@ public final class WgQuickBackend implements Backend { @Override public String getTypePrettyName() { - return context.getResources().getString(R.string.type_name_kernel_module); + return context.getString(R.string.type_name_kernel_module); } @Override @@ -96,7 +96,7 @@ public final class WgQuickBackend implements Backend { final List<String> output = new ArrayList<>(); if (Application.getRootShell() .run(output, "cat /sys/module/wireguard/version") != 0 || output.isEmpty()) - throw new Exception(context.getResources().getString(R.string.module_version_error)); + throw new Exception(context.getString(R.string.module_version_error)); return output.get(0); } @@ -128,6 +128,6 @@ public final class WgQuickBackend implements Backend { // noinspection ResultOfMethodCallIgnored tempFile.delete(); if (result != 0) - throw new Exception(context.getResources().getString(R.string.tunnel_config_error)); + throw new Exception(context.getString(R.string.tunnel_config_error)); } } |