]> git.ipfire.org Git - thirdparty/strongswan.git/commitdiff
android: Show the actual error description in the notification
authorTobias Brunner <tobias@strongswan.org>
Wed, 13 Jun 2018 14:31:41 +0000 (16:31 +0200)
committerTobias Brunner <tobias@strongswan.org>
Tue, 3 Jul 2018 09:31:36 +0000 (11:31 +0200)
src/frontends/android/app/src/main/java/org/strongswan/android/logic/CharonVpnService.java
src/frontends/android/app/src/main/java/org/strongswan/android/logic/VpnStateService.java
src/frontends/android/app/src/main/java/org/strongswan/android/ui/VpnStateFragment.java
src/frontends/android/app/src/main/res/values-de/strings.xml
src/frontends/android/app/src/main/res/values-pl/strings.xml
src/frontends/android/app/src/main/res/values-ru/strings.xml
src/frontends/android/app/src/main/res/values-ua/strings.xml
src/frontends/android/app/src/main/res/values-zh-rCN/strings.xml
src/frontends/android/app/src/main/res/values-zh-rTW/strings.xml
src/frontends/android/app/src/main/res/values/strings.xml

index 53d84cf0cb957ced64dbaf4253ad2f99084c4af1..24cc1da9097f5c76b6f3cc1a070b698871c9c131 100644 (file)
@@ -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));
                }
 
index cd30049f76fb8ef868e35a6f0772c714721d073b..5effafdf10cbe5fb4db9dc9fb7b5660dbb565d58 100644 (file)
@@ -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.
         *
index d75db9b6e458b555f471c4fd187fcbf66168254f..0e4a583294d10f4eefdf0caa66f19ad854a85432 100644 (file)
@@ -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;
        }
 
index c3ea58ced972f79c81d2457a4cd1f24c81498a80..45de885dd5759a39039b96cceec8e29d07fb9e03 100644 (file)
@@ -31,6 +31,7 @@
     <string name="strongswan_shortcut">strongSwan-Verknüpfung</string>
     <string name="permanent_notification_name">VPN Verbindungsstatus</string>
     <string name="permanent_notification_description">Zeigt Informationen zum Verbindungsstatus der VPN Verbindung und dient als permanente Notification dazu, den VPN Dienst im Hintergrund am Laufen zu halten.</string>
+    <string name="tap_for_details">Antippen für Details.</string>
 
     <!-- Settings -->
     <string name="pref_title">Einstellungen</string>
index 9b668a9aa31ea6bfa790ce7b668f1ff8598b142c..091417b5259553ebde083ffbaaea4146cae4589c 100644 (file)
@@ -31,6 +31,7 @@
     <string name="strongswan_shortcut">Skrót strongSwan</string>
     <string name="permanent_notification_name">VPN connection state</string>
     <string name="permanent_notification_description">Provides information about the VPN connection state and serves as permanent notification to keep the VPN service running in the background.</string>
+    <string name="tap_for_details">Tap for details.</string>
 
     <!-- Settings -->
     <string name="pref_title">Settings</string>
index b081f21e3efc078793e1f4b428b14e4cc09eb7f8..5b53893bad95cc29c93366a10b89bac7757aa19d 100644 (file)
@@ -28,6 +28,7 @@
     <string name="strongswan_shortcut">Ссылка на strongSwan</string>
     <string name="permanent_notification_name">VPN connection state</string>
     <string name="permanent_notification_description">Provides information about the VPN connection state and serves as permanent notification to keep the VPN service running in the background.</string>
+    <string name="tap_for_details">Tap for details.</string>
 
     <!-- Settings -->
     <string name="pref_title">Settings</string>
index 192f8aa2c4d0e2d366976a05c52a273a0967b6b0..c21c2f8fff7979410e52b5ecc832f5a3cba23499 100644 (file)
@@ -29,6 +29,7 @@
     <string name="strongswan_shortcut">strongSwan посилання</string>
     <string name="permanent_notification_name">VPN connection state</string>
     <string name="permanent_notification_description">Provides information about the VPN connection state and serves as permanent notification to keep the VPN service running in the background.</string>
+    <string name="tap_for_details">Tap for details.</string>
 
     <!-- Settings -->
     <string name="pref_title">Settings</string>
index 982ca236a522fd26bb8767b1e9d92079a52c68fa..74ad2490a9a02fc53da242cf09352ecd703b1902 100644 (file)
@@ -28,6 +28,7 @@
     <string name="strongswan_shortcut">strongSwan快捷方式</string>
     <string name="permanent_notification_name">VPN connection state</string>
     <string name="permanent_notification_description">Provides information about the VPN connection state and serves as permanent notification to keep the VPN service running in the background.</string>
+    <string name="tap_for_details">Tap for details.</string>
 
     <!-- Settings -->
     <string name="pref_title">Settings</string>
index 975a8f145d36c955c3a3c211c86504cbf10abcfa..e7f004e3872773ec446cc1feadd824a38b67498f 100644 (file)
@@ -28,6 +28,7 @@
     <string name="strongswan_shortcut">strongSwan快速選單</string>
     <string name="permanent_notification_name">VPN connection state</string>
     <string name="permanent_notification_description">Provides information about the VPN connection state and serves as permanent notification to keep the VPN service running in the background.</string>
+    <string name="tap_for_details">Tap for details.</string>
 
     <!-- Settings -->
     <string name="pref_title">Settings</string>
index 1021d19aa7d88d12f1ed4a28b0d8c717ddc70700..8c0bf5f6c5dedc47dbabf769c56c60e769902ff0 100644 (file)
@@ -31,6 +31,7 @@
     <string name="strongswan_shortcut">strongSwan shortcut</string>
     <string name="permanent_notification_name">VPN connection state</string>
     <string name="permanent_notification_description">Provides information about the VPN connection state and serves as permanent notification to keep the VPN service running in the background.</string>
+    <string name="tap_for_details">Tap for details.</string>
 
     <!-- Settings -->
     <string name="pref_title">Settings</string>