android: Unregister listener in case of error alerts

This avoids triggering additional errors via e.g. ike_updown() that
might cause the error message displayed in the GUI to change if the
status fragment is recreated.

References #2134.
This commit is contained in:
Tobias Brunner 2016-11-02 16:35:50 +01:00
parent ef2ad9db1c
commit d6d12bab14
1 changed files with 9 additions and 3 deletions

View File

@ -550,6 +550,8 @@ METHOD(listener_t, alert, bool,
private_android_service_t *this, ike_sa_t *ike_sa, alert_t alert,
va_list args)
{
bool stay_registered = TRUE;
if (this->ike_sa == ike_sa)
{
switch (alert)
@ -557,11 +559,13 @@ METHOD(listener_t, alert, bool,
case ALERT_PEER_ADDR_FAILED:
charonservice->update_status(charonservice,
CHARONSERVICE_LOOKUP_ERROR);
break;
return FALSE;
case ALERT_PEER_AUTH_FAILED:
charonservice->update_status(charonservice,
CHARONSERVICE_PEER_AUTH_ERROR);
break;
return FALSE;
case ALERT_KEEP_ON_CHILD_SA_FAILURE:
{
uint32_t *id = malloc_thing(uint32_t);
@ -593,6 +597,7 @@ METHOD(listener_t, alert, bool,
(job_t*)callback_job_create_with_prio(
(callback_job_cb_t)terminate, id, free,
(callback_job_cancel_t)return_false, JOB_PRIO_HIGH));
stay_registered = FALSE;
}
else
{
@ -609,6 +614,7 @@ METHOD(listener_t, alert, bool,
{
charonservice->update_status(charonservice,
CHARONSERVICE_UNREACHABLE_ERROR);
stay_registered = FALSE;
}
}
this->lock->unlock(this->lock);
@ -617,7 +623,7 @@ METHOD(listener_t, alert, bool,
break;
}
}
return TRUE;
return stay_registered;
}
static void add_auth_cfg_pw(private_android_service_t *this,