android: Log retries to the same log file
It's cleared when a new connection is started or there is a manual retry.
This commit is contained in:
parent
1350ee1ec7
commit
fb3772ec95
|
@ -79,6 +79,7 @@ public class CharonVpnService extends VpnService implements Runnable, VpnStateSe
|
|||
public static final String DISCONNECT_ACTION = "org.strongswan.android.CharonVpnService.DISCONNECT";
|
||||
private static final String NOTIFICATION_CHANNEL = "org.strongswan.android.CharonVpnService.VPN_STATE_NOTIFICATION";
|
||||
public static final String LOG_FILE = "charon.log";
|
||||
public static final String KEY_IS_RETRY = "retry";
|
||||
public static final int VPN_STATE_NOTIFICATION_ID = 1;
|
||||
|
||||
private String mLogFile;
|
||||
|
@ -137,6 +138,7 @@ public class CharonVpnService extends VpnService implements Runnable, VpnStateSe
|
|||
if (intent != null)
|
||||
{
|
||||
VpnProfile profile = null;
|
||||
boolean retry = false;
|
||||
|
||||
if (VPN_SERVICE_ACTION.equals(intent.getAction()))
|
||||
{ /* triggered when Always-on VPN is activated */
|
||||
|
@ -159,12 +161,18 @@ public class CharonVpnService extends VpnService implements Runnable, VpnStateSe
|
|||
String password = bundle.getString(VpnProfileDataSource.KEY_PASSWORD);
|
||||
profile.setPassword(password);
|
||||
|
||||
retry = bundle.getBoolean(CharonVpnService.KEY_IS_RETRY, false);
|
||||
|
||||
SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(this);
|
||||
pref.edit().putString(Constants.PREF_MRU_VPN_PROFILE, profile.getUUID().toString())
|
||||
.apply();
|
||||
}
|
||||
}
|
||||
}
|
||||
if (profile != null && !retry)
|
||||
{ /* delete the log file if this is not an automatic retry */
|
||||
deleteFile(LOG_FILE);
|
||||
}
|
||||
setNextProfile(profile);
|
||||
}
|
||||
return START_NOT_STICKY;
|
||||
|
|
|
@ -295,6 +295,10 @@ public class VpnStateService extends Service
|
|||
/* reset if this is a manual retry or a new connection */
|
||||
mTimeoutProvider.reset();
|
||||
}
|
||||
else
|
||||
{ /* mark this as an automatic retry */
|
||||
profileInfo.putBoolean(CharonVpnService.KEY_IS_RETRY, true);
|
||||
}
|
||||
intent.putExtras(profileInfo);
|
||||
context.startService(intent);
|
||||
}
|
||||
|
|
|
@ -469,7 +469,7 @@ static void set_options(char *logfile)
|
|||
lib->settings->set_str(lib->settings,
|
||||
"charon.filelog.%s.time_format", "%b %e %T", logfile);
|
||||
lib->settings->set_bool(lib->settings,
|
||||
"charon.filelog.%s.append", FALSE, logfile);
|
||||
"charon.filelog.%s.append", TRUE, logfile);
|
||||
lib->settings->set_bool(lib->settings,
|
||||
"charon.filelog.%s.flush_line", TRUE, logfile);
|
||||
lib->settings->set_int(lib->settings,
|
||||
|
|
Loading…
Reference in New Issue