From: Tobias Brunner Date: Wed, 13 Jun 2018 14:31:41 +0000 (+0200) Subject: android: Show the actual error description in the notification X-Git-Tag: 5.7.0dr5~20^2~41 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=a7d679ff1b192936af4045b934f3a07a8e46b8c9;p=thirdparty%2Fstrongswan.git android: Show the actual error description in the notification --- diff --git a/src/frontends/android/app/src/main/java/org/strongswan/android/logic/CharonVpnService.java b/src/frontends/android/app/src/main/java/org/strongswan/android/logic/CharonVpnService.java index 53d84cf0cb..24cc1da909 100644 --- a/src/frontends/android/app/src/main/java/org/strongswan/android/logic/CharonVpnService.java +++ b/src/frontends/android/app/src/main/java/org/strongswan/android/logic/CharonVpnService.java @@ -402,9 +402,10 @@ public class CharonVpnService extends VpnService implements Runnable, VpnStateSe int s = R.string.state_disabled; if (error != ErrorState.NO_ERROR) { - s = R.string.state_error; + s = mService.getErrorText(); builder.setSmallIcon(R.drawable.ic_notification_warning); builder.setColor(ContextCompat.getColor(this, R.color.error_text)); + builder.setContentText(getString(R.string.tap_for_details)); } else { @@ -438,7 +439,10 @@ public class CharonVpnService extends VpnService implements Runnable, VpnStateSe PendingIntent.FLAG_UPDATE_CURRENT); builder.addAction(R.drawable.ic_notification_disconnect, getString(R.string.disconnect), pending); } - builder.setContentText(name); + if (error == ErrorState.NO_ERROR) + { + builder.setContentText(name); + } builder.setPublicVersion(buildNotification(true)); } diff --git a/src/frontends/android/app/src/main/java/org/strongswan/android/logic/VpnStateService.java b/src/frontends/android/app/src/main/java/org/strongswan/android/logic/VpnStateService.java index cd30049f76..5effafdf10 100644 --- a/src/frontends/android/app/src/main/java/org/strongswan/android/logic/VpnStateService.java +++ b/src/frontends/android/app/src/main/java/org/strongswan/android/logic/VpnStateService.java @@ -22,6 +22,7 @@ import android.os.Binder; import android.os.Handler; import android.os.IBinder; +import org.strongswan.android.R; import org.strongswan.android.data.VpnProfile; import org.strongswan.android.logic.imc.ImcState; import org.strongswan.android.logic.imc.RemediationInstruction; @@ -166,6 +167,35 @@ public class VpnStateService extends Service return mError; } + /** + * Get a description of the current error, if any. + * + * @return error description text id + */ + public int getErrorText() + { + switch (mError) + { + case AUTH_FAILED: + if (mImcState == ImcState.BLOCK) + { + return R.string.error_assessment_failed; + } + else + { + return R.string.error_auth_failed; + } + case PEER_AUTH_FAILED: + return R.string.error_peer_auth_failed; + case LOOKUP_FAILED: + return R.string.error_lookup_failed; + case UNREACHABLE: + return R.string.error_unreachable; + default: + return R.string.error_generic; + } + } + /** * Get the current IMC state, if any. * diff --git a/src/frontends/android/app/src/main/java/org/strongswan/android/ui/VpnStateFragment.java b/src/frontends/android/app/src/main/java/org/strongswan/android/ui/VpnStateFragment.java index d75db9b6e4..0e4a583294 100644 --- a/src/frontends/android/app/src/main/java/org/strongswan/android/ui/VpnStateFragment.java +++ b/src/frontends/android/app/src/main/java/org/strongswan/android/ui/VpnStateFragment.java @@ -263,31 +263,7 @@ public class VpnStateFragment extends Fragment implements VpnStateListener enableActionButton(null); mStateView.setText(R.string.state_error); mStateView.setTextColor(mColorStateError); - switch (error) - { - case AUTH_FAILED: - if (imcState == ImcState.BLOCK) - { - showError(R.string.error_assessment_failed); - } - else - { - showError(R.string.error_auth_failed); - } - break; - case PEER_AUTH_FAILED: - showError(R.string.error_peer_auth_failed); - break; - case LOOKUP_FAILED: - showError(R.string.error_lookup_failed); - break; - case UNREACHABLE: - showError(R.string.error_unreachable); - break; - default: - showError(R.string.error_generic); - break; - } + showError(mService.getErrorText()); return true; } diff --git a/src/frontends/android/app/src/main/res/values-de/strings.xml b/src/frontends/android/app/src/main/res/values-de/strings.xml index c3ea58ced9..45de885dd5 100644 --- a/src/frontends/android/app/src/main/res/values-de/strings.xml +++ b/src/frontends/android/app/src/main/res/values-de/strings.xml @@ -31,6 +31,7 @@ strongSwan-Verknüpfung VPN Verbindungsstatus Zeigt Informationen zum Verbindungsstatus der VPN Verbindung und dient als permanente Notification dazu, den VPN Dienst im Hintergrund am Laufen zu halten. + Antippen für Details. Einstellungen diff --git a/src/frontends/android/app/src/main/res/values-pl/strings.xml b/src/frontends/android/app/src/main/res/values-pl/strings.xml index 9b668a9aa3..091417b525 100644 --- a/src/frontends/android/app/src/main/res/values-pl/strings.xml +++ b/src/frontends/android/app/src/main/res/values-pl/strings.xml @@ -31,6 +31,7 @@ Skrót strongSwan VPN connection state Provides information about the VPN connection state and serves as permanent notification to keep the VPN service running in the background. + Tap for details. Settings diff --git a/src/frontends/android/app/src/main/res/values-ru/strings.xml b/src/frontends/android/app/src/main/res/values-ru/strings.xml index b081f21e3e..5b53893bad 100644 --- a/src/frontends/android/app/src/main/res/values-ru/strings.xml +++ b/src/frontends/android/app/src/main/res/values-ru/strings.xml @@ -28,6 +28,7 @@ Ссылка на strongSwan VPN connection state Provides information about the VPN connection state and serves as permanent notification to keep the VPN service running in the background. + Tap for details. Settings diff --git a/src/frontends/android/app/src/main/res/values-ua/strings.xml b/src/frontends/android/app/src/main/res/values-ua/strings.xml index 192f8aa2c4..c21c2f8fff 100644 --- a/src/frontends/android/app/src/main/res/values-ua/strings.xml +++ b/src/frontends/android/app/src/main/res/values-ua/strings.xml @@ -29,6 +29,7 @@ strongSwan посилання VPN connection state Provides information about the VPN connection state and serves as permanent notification to keep the VPN service running in the background. + Tap for details. Settings diff --git a/src/frontends/android/app/src/main/res/values-zh-rCN/strings.xml b/src/frontends/android/app/src/main/res/values-zh-rCN/strings.xml index 982ca236a5..74ad2490a9 100644 --- a/src/frontends/android/app/src/main/res/values-zh-rCN/strings.xml +++ b/src/frontends/android/app/src/main/res/values-zh-rCN/strings.xml @@ -28,6 +28,7 @@ strongSwan快捷方式 VPN connection state Provides information about the VPN connection state and serves as permanent notification to keep the VPN service running in the background. + Tap for details. Settings diff --git a/src/frontends/android/app/src/main/res/values-zh-rTW/strings.xml b/src/frontends/android/app/src/main/res/values-zh-rTW/strings.xml index 975a8f145d..e7f004e387 100644 --- a/src/frontends/android/app/src/main/res/values-zh-rTW/strings.xml +++ b/src/frontends/android/app/src/main/res/values-zh-rTW/strings.xml @@ -28,6 +28,7 @@ strongSwan快速選單 VPN connection state Provides information about the VPN connection state and serves as permanent notification to keep the VPN service running in the background. + Tap for details. Settings diff --git a/src/frontends/android/app/src/main/res/values/strings.xml b/src/frontends/android/app/src/main/res/values/strings.xml index 1021d19aa7..8c0bf5f6c5 100644 --- a/src/frontends/android/app/src/main/res/values/strings.xml +++ b/src/frontends/android/app/src/main/res/values/strings.xml @@ -31,6 +31,7 @@ strongSwan shortcut VPN connection state Provides information about the VPN connection state and serves as permanent notification to keep the VPN service running in the background. + Tap for details. Settings