android: Show the actual error description in the notification
This commit is contained in:
+6
-2
@@ -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));
|
||||
}
|
||||
|
||||
|
||||
+30
@@ -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.
|
||||
*
|
||||
|
||||
+1
-25
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user